Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chainfee: allow specifying min relay feerate from the API source #8891

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions chanbackup/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,3 @@ func DisableLog() {
func UseLogger(logger btclog.Logger) {
log = logger
}

// logClosure is used to provide a closure over expensive logging operations so
// don't have to be performed when the logging level doesn't warrant it.
type logClosure func() string

// String invokes the underlying function and returns the result.
func (c logClosure) String() string {
return c()
}

// newLogClosure returns a new closure over a function that returns a string
// which itself provides a Stringer interface so that it can be used with the
// logging system.
func newLogClosure(c func() string) logClosure {
return logClosure(c)
}
ProofOfKeags marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions chanbackup/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnutils"
)

// Swapper is an interface that allows the chanbackup.SubSwapper to update the
Expand Down Expand Up @@ -278,9 +279,8 @@ func (s *SubSwapper) backupUpdater() {
)
for i, closedChan := range chanUpdate.ClosedChans {
log.Debugf("Removing channel %v from backup "+
"state", newLogClosure(func() string {
return chanUpdate.ClosedChans[i].String()
}))
"state", lnutils.NewLogClosure(
chanUpdate.ClosedChans[i].String))

delete(s.backupState, closedChan)

Expand Down
7 changes: 3 additions & 4 deletions chanbackup/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"net"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnutils"
)

// ChannelRestorer is an interface that allows the Recover method to map the
Expand Down Expand Up @@ -63,9 +63,8 @@ func Recover(backups []Single, restorer ChannelRestorer,
log.Infof("Attempting to connect to node=%x (addrs=%v) to "+
"restore ChannelPoint(%v)",
backup.RemoteNodePub.SerializeCompressed(),
newLogClosure(func() string {
return spew.Sdump(backups[i].Addresses)
}), backup.FundingOutpoint)
lnutils.SpewLogClosure(backups[i].Addresses),
backup.FundingOutpoint)

err = peerConnector.ConnectPeer(
backup.RemoteNodePub, backup.Addresses,
Expand Down
19 changes: 6 additions & 13 deletions contractcourt/breach_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/labels"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
)
Expand Down Expand Up @@ -732,9 +732,8 @@ justiceTxBroadcast:
}
finalTx := justiceTxs.spendAll

brarLog.Debugf("Broadcasting justice tx: %v", newLogClosure(func() string {
return spew.Sdump(finalTx)
}))
brarLog.Debugf("Broadcasting justice tx: %v", lnutils.SpewLogClosure(
finalTx))

// We'll now attempt to broadcast the transaction which finalized the
// channel's retribution against the cheating counter party.
Expand Down Expand Up @@ -857,9 +856,7 @@ Loop:

brarLog.Debugf("Broadcasting justice tx "+
"spending commitment outs: %v",
newLogClosure(func() string {
return spew.Sdump(tx)
}))
lnutils.SpewLogClosure(tx))

err = b.cfg.PublishTransaction(tx, label)
if err != nil {
Expand All @@ -874,9 +871,7 @@ Loop:

brarLog.Debugf("Broadcasting justice tx "+
"spending HTLC outs: %v",
newLogClosure(func() string {
return spew.Sdump(tx)
}))
lnutils.SpewLogClosure(tx))

err = b.cfg.PublishTransaction(tx, label)
if err != nil {
Expand All @@ -891,9 +886,7 @@ Loop:

brarLog.Debugf("Broadcasting justice tx "+
"spending second-level HTLC output: %v",
newLogClosure(func() string {
return spew.Sdump(tx)
}))
lnutils.SpewLogClosure(tx))

err = b.cfg.PublishTransaction(tx, label)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion contractcourt/chain_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
)
Expand Down Expand Up @@ -1254,7 +1255,7 @@ func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail
spendHeight := uint32(spendEvent.SpendingHeight)

log.Debugf("Punishment breach retribution created: %v",
newLogClosure(func() string {
lnutils.NewLogClosure(func() string {
retribution.KeyRing.LocalHtlcKey = nil
retribution.KeyRing.RemoteHtlcKey = nil
retribution.KeyRing.ToLocalKey = nil
Expand Down
28 changes: 7 additions & 21 deletions contractcourt/channel_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/fn"
Expand All @@ -24,6 +23,7 @@ import (
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/labels"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/sweep"
Expand Down Expand Up @@ -465,10 +465,8 @@ func (c *ChannelArbitrator) Start(state *chanArbStartState) error {
}

log.Debugf("Starting ChannelArbitrator(%v), htlc_set=%v, state=%v",
c.cfg.ChanPoint, newLogClosure(func() string {
return spew.Sdump(c.activeHTLCs)
}), state.currentState,
)
c.cfg.ChanPoint, lnutils.SpewLogClosure(c.activeHTLCs),
state.currentState)

// Set our state from our starting state.
c.state = state.currentState
Expand Down Expand Up @@ -958,10 +956,7 @@ func (c *ChannelArbitrator) stateStep(
// Otherwise, we'll log that we checked the HTLC actions as the
// commitment transaction has already been broadcast.
log.Tracef("ChannelArbitrator(%v): logging chain_actions=%v",
c.cfg.ChanPoint,
newLogClosure(func() string {
return spew.Sdump(chainActions)
}))
c.cfg.ChanPoint, lnutils.SpewLogClosure(chainActions))

// Depending on the type of trigger, we'll either "tunnel"
// through to a farther state, or just proceed linearly to the
Expand Down Expand Up @@ -1096,10 +1091,7 @@ func (c *ChannelArbitrator) stateStep(
// channel resolution state.
log.Infof("Broadcasting force close transaction %v, "+
"ChannelPoint(%v): %v", closeTx.TxHash(),
c.cfg.ChanPoint,
newLogClosure(func() string {
return spew.Sdump(closeTx)
}))
c.cfg.ChanPoint, lnutils.SpewLogClosure(closeTx))

// At this point, we'll now broadcast the commitment
// transaction itself.
Expand Down Expand Up @@ -1224,9 +1216,7 @@ func (c *ChannelArbitrator) stateStep(
if len(pktsToSend) != 0 {
log.Debugf("ChannelArbitrator(%v): sending "+
"resolution message=%v", c.cfg.ChanPoint,
newLogClosure(func() string {
return spew.Sdump(pktsToSend)
}))
lnutils.SpewLogClosure(pktsToSend))

err := c.cfg.DeliverResolutionMsg(pktsToSend...)
if err != nil {
Expand Down Expand Up @@ -2741,11 +2731,7 @@ func (c *ChannelArbitrator) notifyContractUpdate(upd *ContractUpdate) {
c.unmergedSet[upd.HtlcKey] = newHtlcSet(upd.Htlcs)

log.Tracef("ChannelArbitrator(%v): fresh set of htlcs=%v",
c.cfg.ChanPoint,
newLogClosure(func() string {
return spew.Sdump(upd)
}),
)
c.cfg.ChanPoint, lnutils.SpewLogClosure(upd))
}

// updateActiveHTLCs merges the unmerged set of HTLCs from the link with
Expand Down
16 changes: 0 additions & 16 deletions contractcourt/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,3 @@ func UseBreachLogger(logger btclog.Logger) {
func UseNurseryLogger(logger btclog.Logger) {
utxnLog = logger
}

// logClosure is used to provide a closure over expensive logging operations so
// don't have to be performed when the logging level doesn't warrant it.
type logClosure func() string

// String invokes the underlying function and returns the result.
func (c logClosure) String() string {
return c()
}

// newLogClosure returns a new closure over a function that returns a string
// which itself provides a Stringer interface so that it can be used with the
// logging system.
func newLogClosure(c func() string) logClosure {
return logClosure(c)
}
ProofOfKeags marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 2 additions & 4 deletions contractcourt/utxonursery.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/labels"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/sweep"
)
Expand Down Expand Up @@ -947,10 +948,7 @@ func (u *UtxoNursery) waitForSweepConf(classHeight uint32,
func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) error {
utxnLog.Infof("Publishing CLTV-delayed HTLC output using timeout tx "+
"(txid=%v): %v", baby.timeoutTx.TxHash(),
newLogClosure(func() string {
return spew.Sdump(baby.timeoutTx)
}),
)
lnutils.SpewLogClosure(baby.timeoutTx))

// We'll now broadcast the HTLC transaction, then wait for it to be
// confirmed before transitioning it to kindergarten.
Expand Down
7 changes: 2 additions & 5 deletions discovery/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil/bech32"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tor"
"github.com/miekg/dns"
Expand Down Expand Up @@ -431,10 +431,7 @@ search:
}

log.Tracef("Retrieved SRV records from dns seed: %v",
newLogClosure(func() string {
return spew.Sdump(addrs)
}),
)
lnutils.SpewLogClosure(addrs))

// Next, we'll need to issue an A record request for each of
// the nodes, skipping it if nothing comes back.
Expand Down
16 changes: 0 additions & 16 deletions discovery/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,3 @@ func DisableLog() {
func UseLogger(logger btclog.Logger) {
log = logger
}

// logClosure is used to provide a closure over expensive logging operations
// so don't have to be performed when the logging level doesn't warrant it.
type logClosure func() string

// String invokes the underlying function and returns the result.
func (c logClosure) String() string {
return c()
}

// newLogClosure returns a new closure over a function that returns a string
// which itself provides a Stringer interface so that it can be used with the
// logging system.
func newLogClosure(c func() string) logClosure {
return logClosure(c)
}
18 changes: 18 additions & 0 deletions docs/release-notes/release-notes-0.18.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@

# Improvements
## Functional Updates

* A new field, `min_relay_feerate`, is [now
expected](https://github.com/lightningnetwork/lnd/pull/8891) in the response
from querying the external fee estimation URL. The new response should have
the format,
```json
yyforyongyu marked this conversation as resolved.
Show resolved Hide resolved
{
"fee_by_block_target": {
"2": 5076,
"3": 4228,
"26": 4200
},
"min_relay_feerate": 1000
}
```
All units are `sats/kvB`. If the new field `min_relay_feerate` is not set,
the default floor feerate (1012 sats/kvB) will be used.

## RPC Updates

* [`xImportMissionControl`](https://github.com/lightningnetwork/lnd/pull/8779)
Expand Down
3 changes: 1 addition & 2 deletions graph/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs"
Expand Down Expand Up @@ -1432,7 +1431,7 @@ func (b *Builder) processUpdate(msg interface{},
}

log.Tracef("New channel update applied: %v",
newLogClosure(func() string { return spew.Sdump(msg) }))
lnutils.SpewLogClosure(msg))
b.stats.incNumChannelUpdates()

default:
Expand Down
16 changes: 0 additions & 16 deletions graph/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,3 @@ func DisableLog() {
func UseLogger(logger btclog.Logger) {
log = logger
}

// logClosure is used to provide a closure over expensive logging operations so
// don't have to be performed when the logging level doesn't warrant it.
type logClosure func() string

// String invokes the underlying function and returns the result.
func (c logClosure) String() string {
return c()
}

// newLogClosure returns a new closure over a function that returns a string
// which itself provides a Stringer interface so that it can be used with the
// logging system.
func newLogClosure(c func() string) logClosure {
return logClosure(c)
}
ProofOfKeags marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading