Skip to content

Commit

Permalink
Merge pull request #5187 from bottlepay/config-commit-time
Browse files Browse the repository at this point in the history
config: add commit time parameter
  • Loading branch information
cfromknecht committed Apr 9, 2021
2 parents c27e9ab + ffd346e commit 213b264
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
14 changes: 14 additions & 0 deletions config.go
Expand Up @@ -141,6 +141,15 @@ 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

// defaultChannelCommitBatchSize is the default maximum number of
// channel state updates that is accumulated before signing a new
// commitment.
defaultChannelCommitBatchSize = 10
)

var (
Expand Down Expand Up @@ -291,6 +300,9 @@ 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."`
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."`

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."`
Expand Down Expand Up @@ -511,6 +523,8 @@ func DefaultConfig() Config {
DB: lncfg.DefaultDB(),
registeredChains: chainreg.NewChainRegistry(),
ActiveNetParams: chainreg.BitcoinTestNetParams,
ChannelCommitInterval: defaultChannelCommitInterval,
ChannelCommitBatchSize: defaultChannelCommitBatchSize,
}
}

Expand Down
14 changes: 12 additions & 2 deletions peer/brontide.go
Expand Up @@ -308,6 +308,16 @@ 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

// ChannelCommitBatchSize is the maximum number of channel state updates
// that is accumulated before signing a new commitment.
ChannelCommitBatchSize uint32

// Quit is the server's quit channel. If this is closed, we halt operation.
Quit chan struct{}
}
Expand Down Expand Up @@ -813,10 +823,10 @@ 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,
BatchSize: p.cfg.ChannelCommitBatchSize,
UnsafeReplay: p.cfg.UnsafeReplay,
MinFeeUpdateTimeout: htlcswitch.DefaultMinLinkFeeUpdateTimeout,
MaxFeeUpdateTimeout: htlcswitch.DefaultMaxLinkFeeUpdateTimeout,
Expand Down
9 changes: 9 additions & 0 deletions sample-lnd.conf
Expand Up @@ -264,6 +264,15 @@
; 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 maximum number of channel state updates that is accumulated before signing
; a new commitment.
; channel-commit-batch-size=10

; 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.
Expand Down
4 changes: 3 additions & 1 deletion server.go
Expand Up @@ -3137,7 +3137,9 @@ 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,
ChannelCommitBatchSize: s.cfg.ChannelCommitBatchSize,
Quit: s.quit,
}

copy(pCfg.PubKeyBytes[:], peerAddr.IdentityKey.SerializeCompressed())
Expand Down

0 comments on commit 213b264

Please sign in to comment.