You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add more comments about timelock assumptions and security model
Rename HTLC_FAIL_ANTI_REORG_DELAY to ANTI_REORG_DELAY because
we are going to rely on it also to remove bump candidates outpoint
from tracker after claim get enough depth.
Rename HTLC_FAIL_TIMEOUT_BLOCKS to GRACE_PERIOD_BLOCKS because
it's carrying more meaningfully that we are doing a favor to our
peer instead of ruthlessly enforcing the contract.
CLTV_EXPIRY_DELTA should be > to GRACE_PERIOD_BLOCKS +
+CLTV_CLAIM_BUFFER + ANTI_REORG_DELAY.
When we reached height + GRACE_PERIOD_BLOCKS and we have pending
unsolved outbound HTLC, we fail onchain with
our local commitment tx. At this point we expect to get in chain in a
worst-case delay of CLTV_CLAIM_BUFFER. When our HTLC-timeout is
confirmed with ANTI_REORG_DELAY we may safely fail backward the
corresponding inbound output.
Copy file name to clipboardExpand all lines: src/ln/channelmanager.rs
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ use secp256k1;
28
28
use chain::chaininterface::{BroadcasterInterface,ChainListener,ChainWatchInterface,FeeEstimator};
29
29
use chain::transaction::OutPoint;
30
30
use ln::channel::{Channel,ChannelError};
31
-
use ln::channelmonitor::{ChannelMonitor,ChannelMonitorUpdateErr,ManyChannelMonitor,CLTV_CLAIM_BUFFER,HTLC_FAIL_TIMEOUT_BLOCKS,HTLC_FAIL_ANTI_REORG_DELAY};
31
+
use ln::channelmonitor::{ChannelMonitor,ChannelMonitorUpdateErr,ManyChannelMonitor,CLTV_CLAIM_BUFFER,GRACE_PERIOD_BLOCKS,ANTI_REORG_DELAY};
return_err!("The final CLTV expiry is too soon to handle",17,&[0;0]);
825
825
}
826
826
// final_incorrect_htlc_amount
@@ -912,8 +912,8 @@ impl ChannelManager {
912
912
breakSome(("Forwarding node has tampered with the intended HTLC values or origin node has an obsolete cltv_expiry_delta",0x1000 | 13,Some(self.get_channel_update(chan).unwrap())));
913
913
}
914
914
let cur_height = self.latest_block_height.load(Ordering::Acquire)asu32 + 1;
915
-
// We want to have at least HTLC_FAIL_TIMEOUT_BLOCKS to fail prior to going on chain CLAIM_BUFFER blocks before expiration
916
-
if msg.cltv_expiry <= cur_height + CLTV_CLAIM_BUFFER + HTLC_FAIL_TIMEOUT_BLOCKSasu32{// expiry_too_soon
915
+
// We want to have at least GRACE_PERIOD_BLOCKS to fail prior to going on chain CLAIM_BUFFER blocks before expiration
916
+
if msg.cltv_expiry <= cur_height + CLTV_CLAIM_BUFFER + GRACE_PERIOD_BLOCKSasu32{// expiry_too_soon
917
917
breakSome(("CLTV expiry is too close",0x1000 | 14,Some(self.get_channel_update(chan).unwrap())));
918
918
}
919
919
if msg.cltv_expiry > cur_height + CLTV_FAR_FAR_AWAYasu32{// expiry_too_far
log_trace!(self,"Failing HTLC with payment_hash {} from {} remote commitment tx due to broadcast of remote commitment transaction", log_bytes!(htlc.payment_hash.0), $commitment_tx);
log_trace!(self,"Failing HTLC with payment_hash {} from {} local commitment tx due to broadcast of transaction, waiting confirmation (at height{})", log_bytes!($payment_hash.0), $commitment_tx, height + HTLC_FAIL_ANTI_REORG_DELAY - 1);
log_trace!(self,"Failing HTLC with payment_hash {} from {} local commitment tx due to broadcast of transaction, waiting confirmation (at height{})", log_bytes!($payment_hash.0), $commitment_tx, height + ANTI_REORG_DELAY - 1);
0 commit comments