Merge pull request #6186 from yyforyongyu/itest-fix-pending-ticker
htlcswitch: fix PendingCommitTicker and make it configurable
This commit is contained in:
7 files changed
+79
-26
No files matched your search
@@ -168,14 +168,24 @@ const (
|
|||||||
// TODO(halseth): find a more scientific choice of value.
|
// TODO(halseth): find a more scientific choice of value.
|
||||||
defaultMaxLocalCSVDelay = 10000
|
defaultMaxLocalCSVDelay = 10000
|
||||||
|
|
||||||
// defaultChannelCommitInterval is the default maximum time between receiving a
|
// defaultChannelCommitInterval is the default maximum time between
|
||||||
// channel state update and signing a new commitment.
|
// receiving a channel state update and signing a new commitment.
|
||||||
defaultChannelCommitInterval = 50 * time.Millisecond
|
defaultChannelCommitInterval = 50 * time.Millisecond
|
||||||
|
|
||||||
// maxChannelCommitInterval is the maximum time the commit interval can
|
// maxChannelCommitInterval is the maximum time the commit interval can
|
||||||
// be configured to.
|
// be configured to.
|
||||||
maxChannelCommitInterval = time.Hour
|
maxChannelCommitInterval = time.Hour
|
||||||
|
|
||||||
|
// defaultPendingCommitInterval specifies the default timeout value
|
||||||
|
// while waiting for the remote party to revoke a locally initiated
|
||||||
|
// commitment state.
|
||||||
|
defaultPendingCommitInterval = 1 * time.Minute
|
||||||
|
|
||||||
|
// maxPendingCommitInterval specifies the max allowed duration when
|
||||||
|
// waiting for the remote party to revoke a locally initiated
|
||||||
|
// commitment state.
|
||||||
|
maxPendingCommitInterval = 5 * time.Minute
|
||||||
|
|
||||||
// defaultChannelCommitBatchSize is the default maximum number of
|
// defaultChannelCommitBatchSize is the default maximum number of
|
||||||
// channel state updates that is accumulated before signing a new
|
// channel state updates that is accumulated before signing a new
|
||||||
// commitment.
|
// commitment.
|
||||||
@@ -340,8 +350,11 @@ type Config struct {
|
|||||||
MaxChanSize int64 `long:"maxchansize" description:"The largest channel size (in satoshis) that we should accept. Incoming channels larger than this will be rejected"`
|
MaxChanSize int64 `long:"maxchansize" description:"The largest channel size (in satoshis) that we should accept. Incoming channels larger than this will be rejected"`
|
||||||
CoopCloseTargetConfs uint32 `long:"coop-close-target-confs" description:"The target number of blocks that a cooperative channel close transaction should confirm in. This is used to estimate the fee to use as the lower bound during fee negotiation for the channel closure."`
|
CoopCloseTargetConfs uint32 `long:"coop-close-target-confs" description:"The target number of blocks that a cooperative channel close transaction should confirm in. This is used to estimate the fee to use as the lower bound during fee negotiation for the channel closure."`
|
||||||
|
|
||||||
ChannelCommitInterval time.Duration `long:"channel-commit-interval" description:"The maximum time that is allowed to pass between receiving a channel state update and signing the next commitment. Setting this to a longer duration allows for more efficient channel operations at the cost of latency."`
|
ChannelCommitInterval time.Duration `long:"channel-commit-interval" description:"The maximum time that is allowed to pass between receiving a channel state update and signing the next commitment. Setting this to a longer duration allows for more efficient channel operations at the cost of latency."`
|
||||||
ChannelCommitBatchSize uint32 `long:"channel-commit-batch-size" description:"The maximum number of channel state updates that is accumulated before signing a new commitment."`
|
|
||||||
|
PendingCommitInterval time.Duration `long:"pending-commit-interval" description:"The maximum time that is allowed to pass while waiting for the remote party to revoke a locally initiated commitment state. Setting this to a longer duration if a slow response is expected from the remote party or large number of payments are attempted at the same time."`
|
||||||
|
|
||||||
|
ChannelCommitBatchSize uint32 `long:"channel-commit-batch-size" description:"The maximum number of channel state updates that is accumulated before signing a new commitment."`
|
||||||
|
|
||||||
DefaultRemoteMaxHtlcs uint16 `long:"default-remote-max-htlcs" description:"The default max_htlc applied when opening or accepting channels. This value limits the number of concurrent HTLCs that the remote party can add to the commitment. The maximum possible value is 483."`
|
DefaultRemoteMaxHtlcs uint16 `long:"default-remote-max-htlcs" description:"The default max_htlc applied when opening or accepting channels. This value limits the number of concurrent HTLCs that the remote party can add to the commitment. The maximum possible value is 483."`
|
||||||
|
|
||||||
@@ -601,6 +614,7 @@ func DefaultConfig() Config {
|
|||||||
registeredChains: chainreg.NewChainRegistry(),
|
registeredChains: chainreg.NewChainRegistry(),
|
||||||
ActiveNetParams: chainreg.BitcoinTestNetParams,
|
ActiveNetParams: chainreg.BitcoinTestNetParams,
|
||||||
ChannelCommitInterval: defaultChannelCommitInterval,
|
ChannelCommitInterval: defaultChannelCommitInterval,
|
||||||
|
PendingCommitInterval: defaultPendingCommitInterval,
|
||||||
ChannelCommitBatchSize: defaultChannelCommitBatchSize,
|
ChannelCommitBatchSize: defaultChannelCommitBatchSize,
|
||||||
CoinSelectionStrategy: defaultCoinSelectionStrategy,
|
CoinSelectionStrategy: defaultCoinSelectionStrategy,
|
||||||
RemoteSigner: &lncfg.RemoteSigner{
|
RemoteSigner: &lncfg.RemoteSigner{
|
||||||
@@ -1578,6 +1592,14 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
maxChannelCommitInterval)
|
maxChannelCommitInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Limit PendingCommitInterval so we don't wait too long for the remote
|
||||||
|
// party to send back a revoke.
|
||||||
|
if cfg.PendingCommitInterval > maxPendingCommitInterval {
|
||||||
|
return nil, mkErr("pending-commit-interval (%v) must be less "+
|
||||||
|
"than %v", cfg.PendingCommitInterval,
|
||||||
|
maxPendingCommitInterval)
|
||||||
|
}
|
||||||
|
|
||||||
if err := cfg.Gossip.Parse(); err != nil {
|
if err := cfg.Gossip.Parse(); err != nil {
|
||||||
return nil, mkErr("error parsing gossip syncer: %v", err)
|
return nil, mkErr("error parsing gossip syncer: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,10 +101,14 @@
|
|||||||
* [Make etcd leader election session
|
* [Make etcd leader election session
|
||||||
TTL](https://github.com/lightningnetwork/lnd/pull/6342) configurable.
|
TTL](https://github.com/lightningnetwork/lnd/pull/6342) configurable.
|
||||||
|
|
||||||
|
|
||||||
* [Fix race condition in the htlc interceptor unit
|
* [Fix race condition in the htlc interceptor unit
|
||||||
test](https://github.com/lightningnetwork/lnd/pull/6353).
|
test](https://github.com/lightningnetwork/lnd/pull/6353).
|
||||||
|
|
||||||
|
* [A new config option, `pending-commit-interval` is
|
||||||
|
added](https://github.com/lightningnetwork/lnd/pull/6186). This value
|
||||||
|
specifies the maximum duration it allows for a remote peer to respond to a
|
||||||
|
locally initiated commitment update.
|
||||||
|
|
||||||
## RPC Server
|
## RPC Server
|
||||||
|
|
||||||
* [Add value to the field
|
* [Add value to the field
|
||||||
|
|||||||
@@ -1084,8 +1084,13 @@ func (l *channelLink) htlcManager() {
|
|||||||
// batch is empty.
|
// batch is empty.
|
||||||
if l.channel.PendingLocalUpdateCount() > 0 {
|
if l.channel.PendingLocalUpdateCount() > 0 {
|
||||||
l.cfg.BatchTicker.Resume()
|
l.cfg.BatchTicker.Resume()
|
||||||
|
l.log.Tracef("BatchTicker resumed, "+
|
||||||
|
"PendingLocalUpdateCount=%d",
|
||||||
|
l.channel.PendingLocalUpdateCount())
|
||||||
} else {
|
} else {
|
||||||
l.cfg.BatchTicker.Pause()
|
l.cfg.BatchTicker.Pause()
|
||||||
|
l.log.Trace("BatchTicker paused due to zero " +
|
||||||
|
"PendingLocalUpdateCount")
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@@ -2102,6 +2107,7 @@ func (l *channelLink) updateCommitTx() error {
|
|||||||
theirCommitSig, htlcSigs, pendingHTLCs, err := l.channel.SignNextCommitment()
|
theirCommitSig, htlcSigs, pendingHTLCs, err := l.channel.SignNextCommitment()
|
||||||
if err == lnwallet.ErrNoWindow {
|
if err == lnwallet.ErrNoWindow {
|
||||||
l.cfg.PendingCommitTicker.Resume()
|
l.cfg.PendingCommitTicker.Resume()
|
||||||
|
l.log.Trace("PendingCommitTicker resumed")
|
||||||
|
|
||||||
l.log.Tracef("revocation window exhausted, unable to send: "+
|
l.log.Tracef("revocation window exhausted, unable to send: "+
|
||||||
"%v, pend_updates=%v, dangling_closes%v",
|
"%v, pend_updates=%v, dangling_closes%v",
|
||||||
@@ -2123,6 +2129,7 @@ func (l *channelLink) updateCommitTx() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
l.cfg.PendingCommitTicker.Pause()
|
l.cfg.PendingCommitTicker.Pause()
|
||||||
|
l.log.Trace("PendingCommitTicker paused after ackDownStreamPackets")
|
||||||
|
|
||||||
// The remote party now has a new pending commitment, so we'll update
|
// The remote party now has a new pending commitment, so we'll update
|
||||||
// the contract court to be aware of this new set (the prior old remote
|
// the contract court to be aware of this new set (the prior old remote
|
||||||
|
|||||||
+4
-1
@@ -3530,7 +3530,10 @@ func (lc *LightningChannel) SignNextCommitment() (lnwire.Sig, []lnwire.Sig,
|
|||||||
// party, then we're unable to create new states. Each time we create a
|
// party, then we're unable to create new states. Each time we create a
|
||||||
// new state, we consume a prior revocation point.
|
// new state, we consume a prior revocation point.
|
||||||
commitPoint := lc.channelState.RemoteNextRevocation
|
commitPoint := lc.channelState.RemoteNextRevocation
|
||||||
if lc.remoteCommitChain.hasUnackedCommitment() || commitPoint == nil {
|
unacked := lc.remoteCommitChain.hasUnackedCommitment()
|
||||||
|
if unacked || commitPoint == nil {
|
||||||
|
lc.log.Tracef("waiting for remote ack=%v, nil "+
|
||||||
|
"RemoteNextRevocation: %v", unacked, commitPoint == nil)
|
||||||
return sig, htlcSigs, nil, ErrNoWindow
|
return sig, htlcSigs, nil, ErrNoWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+29
-20
@@ -318,6 +318,13 @@ type Config struct {
|
|||||||
// operations at the cost of latency.
|
// operations at the cost of latency.
|
||||||
ChannelCommitInterval time.Duration
|
ChannelCommitInterval time.Duration
|
||||||
|
|
||||||
|
// PendingCommitInterval is the maximum time that is allowed to pass
|
||||||
|
// while waiting for the remote party to revoke a locally initiated
|
||||||
|
// commitment state. Setting this to a longer duration if a slow
|
||||||
|
// response is expected from the remote party or large number of
|
||||||
|
// payments are attempted at the same time.
|
||||||
|
PendingCommitInterval time.Duration
|
||||||
|
|
||||||
// ChannelCommitBatchSize is the maximum number of channel state updates
|
// ChannelCommitBatchSize is the maximum number of channel state updates
|
||||||
// that is accumulated before signing a new commitment.
|
// that is accumulated before signing a new commitment.
|
||||||
ChannelCommitBatchSize uint32
|
ChannelCommitBatchSize uint32
|
||||||
@@ -832,26 +839,28 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
|
|||||||
}
|
}
|
||||||
|
|
||||||
linkCfg := htlcswitch.ChannelLinkConfig{
|
linkCfg := htlcswitch.ChannelLinkConfig{
|
||||||
Peer: p,
|
Peer: p,
|
||||||
DecodeHopIterators: p.cfg.Sphinx.DecodeHopIterators,
|
DecodeHopIterators: p.cfg.Sphinx.DecodeHopIterators,
|
||||||
ExtractErrorEncrypter: p.cfg.Sphinx.ExtractErrorEncrypter,
|
ExtractErrorEncrypter: p.cfg.Sphinx.ExtractErrorEncrypter,
|
||||||
FetchLastChannelUpdate: p.cfg.FetchLastChanUpdate,
|
FetchLastChannelUpdate: p.cfg.FetchLastChanUpdate,
|
||||||
HodlMask: p.cfg.Hodl.Mask(),
|
HodlMask: p.cfg.Hodl.Mask(),
|
||||||
Registry: p.cfg.Invoices,
|
Registry: p.cfg.Invoices,
|
||||||
BestHeight: p.cfg.Switch.BestHeight,
|
BestHeight: p.cfg.Switch.BestHeight,
|
||||||
Circuits: p.cfg.Switch.CircuitModifier(),
|
Circuits: p.cfg.Switch.CircuitModifier(),
|
||||||
ForwardPackets: p.cfg.InterceptSwitch.ForwardPackets,
|
ForwardPackets: p.cfg.InterceptSwitch.ForwardPackets,
|
||||||
FwrdingPolicy: *forwardingPolicy,
|
FwrdingPolicy: *forwardingPolicy,
|
||||||
FeeEstimator: p.cfg.FeeEstimator,
|
FeeEstimator: p.cfg.FeeEstimator,
|
||||||
PreimageCache: p.cfg.WitnessBeacon,
|
PreimageCache: p.cfg.WitnessBeacon,
|
||||||
ChainEvents: chainEvents,
|
ChainEvents: chainEvents,
|
||||||
UpdateContractSignals: updateContractSignals,
|
UpdateContractSignals: updateContractSignals,
|
||||||
NotifyContractUpdate: notifyContractUpdate,
|
NotifyContractUpdate: notifyContractUpdate,
|
||||||
OnChannelFailure: onChannelFailure,
|
OnChannelFailure: onChannelFailure,
|
||||||
SyncStates: syncStates,
|
SyncStates: syncStates,
|
||||||
BatchTicker: ticker.New(p.cfg.ChannelCommitInterval),
|
BatchTicker: ticker.New(p.cfg.ChannelCommitInterval),
|
||||||
FwdPkgGCTicker: ticker.New(time.Hour),
|
FwdPkgGCTicker: ticker.New(time.Hour),
|
||||||
PendingCommitTicker: ticker.New(time.Minute),
|
PendingCommitTicker: ticker.New(
|
||||||
|
p.cfg.PendingCommitInterval,
|
||||||
|
),
|
||||||
BatchSize: p.cfg.ChannelCommitBatchSize,
|
BatchSize: p.cfg.ChannelCommitBatchSize,
|
||||||
UnsafeReplay: p.cfg.UnsafeReplay,
|
UnsafeReplay: p.cfg.UnsafeReplay,
|
||||||
MinFeeUpdateTimeout: htlcswitch.DefaultMinLinkFeeUpdateTimeout,
|
MinFeeUpdateTimeout: htlcswitch.DefaultMinLinkFeeUpdateTimeout,
|
||||||
|
|||||||
@@ -297,6 +297,13 @@
|
|||||||
; capped at 1 hour. The default is 50 milliseconds.
|
; capped at 1 hour. The default is 50 milliseconds.
|
||||||
; channel-commit-interval=1h
|
; channel-commit-interval=1h
|
||||||
|
|
||||||
|
; The maximum time that is allowed to pass while waiting for the remote party
|
||||||
|
; to revoke a locally initiated commitment state. Setting this to a longer
|
||||||
|
; duration if a slow response is expected from the remote party or large
|
||||||
|
; number of payments are attempted at the same time.
|
||||||
|
; (default: 1m0s)
|
||||||
|
; pending-commit-interval=5m
|
||||||
|
|
||||||
; The maximum number of channel state updates that is accumulated before signing
|
; The maximum number of channel state updates that is accumulated before signing
|
||||||
; a new commitment.
|
; a new commitment.
|
||||||
; channel-commit-batch-size=10
|
; channel-commit-batch-size=10
|
||||||
|
|||||||
@@ -3526,6 +3526,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
|
|||||||
MaxAnchorsCommitFeeRate: chainfee.SatPerKVByte(
|
MaxAnchorsCommitFeeRate: chainfee.SatPerKVByte(
|
||||||
s.cfg.MaxCommitFeeRateAnchors * 1000).FeePerKWeight(),
|
s.cfg.MaxCommitFeeRateAnchors * 1000).FeePerKWeight(),
|
||||||
ChannelCommitInterval: s.cfg.ChannelCommitInterval,
|
ChannelCommitInterval: s.cfg.ChannelCommitInterval,
|
||||||
|
PendingCommitInterval: s.cfg.PendingCommitInterval,
|
||||||
ChannelCommitBatchSize: s.cfg.ChannelCommitBatchSize,
|
ChannelCommitBatchSize: s.cfg.ChannelCommitBatchSize,
|
||||||
HandleCustomMessage: s.handleCustomMessage,
|
HandleCustomMessage: s.handleCustomMessage,
|
||||||
Quit: s.quit,
|
Quit: s.quit,
|
||||||
|
|||||||
Reference in new issue
Block a user