link: increase expiry grace delta
This commit increase the expiry grace delta to a value above the broadcast delta. This prevents htlcs from being accepted that would immediately trigger a channel force close. A correct delta is generated in server.go where there is access to the broadcast delta and passed via the peer to the links. Co-authored-by: Jim Posen <jim.posen@gmail.com>
This commit is contained in:
6 files changed
+77
-37
No files matched your search
+16
-16
@@ -30,18 +30,6 @@ func init() {
|
||||
}
|
||||
|
||||
const (
|
||||
// expiryGraceDelta is the minimum difference between the current block
|
||||
// height and the CLTV we require on 1) an outgoing HTLC in order to
|
||||
// forward as an intermediary hop, or 2) an incoming HTLC to reveal the
|
||||
// preimage as the final hop. We'll reject any HTLC's who's timeout minus
|
||||
// this value is less than or equal to the current block height. We require
|
||||
// this in order to ensure that we have sufficient time to claim or
|
||||
// timeout an HTLC on chain.
|
||||
//
|
||||
// This MUST be greater than the maximum BroadcastDelta of the
|
||||
// ChannelArbitrator for the outbound channel.
|
||||
expiryGraceDelta = 2
|
||||
|
||||
// maxCltvExpiry is the maximum outgoing time lock that the node accepts
|
||||
// for forwarded payments. The value is relative to the current block
|
||||
// height. The reason to have a maximum is to prevent funds getting
|
||||
@@ -246,6 +234,18 @@ type ChannelLinkConfig struct {
|
||||
// fee rate. A random timeout will be selected between these values.
|
||||
MinFeeUpdateTimeout time.Duration
|
||||
MaxFeeUpdateTimeout time.Duration
|
||||
|
||||
// ExpiryGraceDelta is the minimum difference between the current block
|
||||
// height and the CLTV we require on 1) an outgoing HTLC in order to
|
||||
// forward as an intermediary hop, or 2) an incoming HTLC to reveal the
|
||||
// preimage as the final hop. We'll reject any HTLC's who's timeout minus
|
||||
// this value is less than or equal to the current block height. We require
|
||||
// this in order to ensure that we have sufficient time to claim or
|
||||
// timeout an HTLC on chain.
|
||||
//
|
||||
// This MUST be greater than the maximum BroadcastDelta of the
|
||||
// ChannelArbitrator for the outbound channel.
|
||||
ExpiryGraceDelta uint32
|
||||
}
|
||||
|
||||
// channelLink is the service which drives a channel's commitment update
|
||||
@@ -2150,9 +2150,9 @@ func (l *channelLink) HtlcSatifiesPolicy(payHash [32]byte,
|
||||
}
|
||||
|
||||
// We want to avoid offering an HTLC which will expire in the near
|
||||
// future, so we'll reject an HTLC if the outgoing expiration time is
|
||||
// too close to the current height.
|
||||
if outgoingTimeout-expiryGraceDelta <= heightNow {
|
||||
// future, so we'll reject an HTLC if the outgoing expiration time is too
|
||||
// close to the current height.
|
||||
if outgoingTimeout-l.cfg.ExpiryGraceDelta <= heightNow {
|
||||
l.errorf("htlc(%x) has an expiry that's too soon: "+
|
||||
"outgoing_expiry=%v, best_height=%v", payHash[:],
|
||||
outgoingTimeout, heightNow)
|
||||
@@ -2675,7 +2675,7 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor,
|
||||
|
||||
// First, we'll check the expiry of the HTLC itself against, the current
|
||||
// block height. If the timeout is too soon, then we'll reject the HTLC.
|
||||
if pd.Timeout-expiryGraceDelta <= heightNow {
|
||||
if pd.Timeout-l.cfg.ExpiryGraceDelta <= heightNow {
|
||||
log.Errorf("htlc(%x) has an expiry that's too soon: expiry=%v"+
|
||||
", best_height=%v", pd.RHash[:], pd.Timeout, heightNow)
|
||||
|
||||
|
||||
Reference in new issue
Block a user