From a181d2628772391cdc20461b3277ab943a896e35 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 8 Apr 2021 14:29:03 +0200 Subject: [PATCH] config: add channel commit interval parameter --- config.go | 7 +++++++ peer/brontide.go | 8 +++++++- sample-lnd.conf | 5 +++++ server.go | 3 ++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index be22891d..73f46c0d 100644 --- a/config.go +++ b/config.go @@ -141,6 +141,10 @@ const ( // commitment output. // TODO(halseth): find a more scientific choice of value. defaultMaxLocalCSVDelay = 10000 + + // defaultChannelCommitInterval is the default maximum time between receiving a + // channel state update and signing a new commitment. + defaultChannelCommitInterval = 50 * time.Millisecond ) var ( @@ -289,6 +293,8 @@ 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"` 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."` + 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."` NumGraphSyncPeers int `long:"numgraphsyncpeers" description:"The number of peers that we should receive new graph updates from. This option can be tuned to save bandwidth for light clients or routing nodes."` @@ -507,6 +513,7 @@ func DefaultConfig() Config { DB: lncfg.DefaultDB(), registeredChains: chainreg.NewChainRegistry(), ActiveNetParams: chainreg.BitcoinTestNetParams, + ChannelCommitInterval: defaultChannelCommitInterval, } } diff --git a/peer/brontide.go b/peer/brontide.go index cb1f45fd..07c7f61c 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -308,6 +308,12 @@ type Config struct { // ChannelLink. ServerPubKey [33]byte + // ChannelCommitInterval is 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 + // Quit is the server's quit channel. If this is closed, we halt operation. Quit chan struct{} } @@ -813,7 +819,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint, UpdateContractSignals: updateContractSignals, OnChannelFailure: onChannelFailure, SyncStates: syncStates, - BatchTicker: ticker.New(50 * time.Millisecond), + BatchTicker: ticker.New(p.cfg.ChannelCommitInterval), FwdPkgGCTicker: ticker.New(time.Hour), PendingCommitTicker: ticker.New(time.Minute), BatchSize: 10, diff --git a/sample-lnd.conf b/sample-lnd.conf index 50ee6433..130c4067 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -264,6 +264,11 @@ ; for the channel closure is not set. ; coop-close-target-confs=10 +; 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. +; channel-commit-interval=50ms + ; 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. diff --git a/server.go b/server.go index e54348f9..11994894 100644 --- a/server.go +++ b/server.go @@ -3137,7 +3137,8 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, CoopCloseTargetConfs: s.cfg.CoopCloseTargetConfs, MaxAnchorsCommitFeeRate: chainfee.SatPerKVByte( s.cfg.MaxCommitFeeRateAnchors * 1000).FeePerKWeight(), - Quit: s.quit, + ChannelCommitInterval: s.cfg.ChannelCommitInterval, + Quit: s.quit, } copy(pCfg.PubKeyBytes[:], peerAddr.IdentityKey.SerializeCompressed())