Skip to content

Commit

Permalink
config: add commit time parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
joostjager committed Apr 8, 2021
1 parent cd87fe8 commit 9ca8c9c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config.go
Expand Up @@ -141,6 +141,10 @@ const (
// commitment output.
// TODO(halseth): find a more scientific choice of value.
defaultMaxLocalCSVDelay = 10000

// defaultCommitTime is the default maximum time between receiving a
// channel state update and signing a new commitment.
defaultCommitTime = 50 * time.Millisecond
)

var (
Expand Down Expand Up @@ -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."`

CommitTime time.Duration `long:"commit-time" 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."`
Expand Down Expand Up @@ -507,6 +513,7 @@ func DefaultConfig() Config {
DB: lncfg.DefaultDB(),
registeredChains: chainreg.NewChainRegistry(),
ActiveNetParams: chainreg.BitcoinTestNetParams,
CommitTime: defaultCommitTime,
}
}

Expand Down
8 changes: 7 additions & 1 deletion peer/brontide.go
Expand Up @@ -308,6 +308,12 @@ type Config struct {
// ChannelLink.
ServerPubKey [33]byte

// CommitTime 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.
CommitTime time.Duration

// Quit is the server's quit channel. If this is closed, we halt operation.
Quit chan struct{}
}
Expand Down Expand Up @@ -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.CommitTime),
FwdPkgGCTicker: ticker.New(time.Hour),
PendingCommitTicker: ticker.New(time.Minute),
BatchSize: 10,
Expand Down
5 changes: 5 additions & 0 deletions sample-lnd.conf
Expand Up @@ -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.
; commit-time=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.
Expand Down
3 changes: 2 additions & 1 deletion server.go
Expand Up @@ -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,
CommitTime: s.cfg.CommitTime,
Quit: s.quit,
}

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

0 comments on commit 9ca8c9c

Please sign in to comment.