Duplicate forwarded-HTLC claim can assert while freeing an already-released blocker
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
Hướng nghiên cứu
Start from the FreeDuplicateClaimImmediately path and actions_blocking_raa_monitor_updates / ForwardedPaymentInboundClaim bookkeeping in the ChannelManager (the issue names those types). Reproduce with the provided functional test (three nodes, forwarded C→B→A plus an unrelated MPP claim holding A-B blockers, then on-chain HTLC-success replay). Done when duplicate forwarded-claim cleanup no longer debug_assert!s if the forwarded blocker was already released and only other blockers occupy the downstream entry, and the new test passes without should_panic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Note: This draft was AI-generated and may contain mistakes.
This was found while triaging a rare crash from chanmon consistency fuzzing. The
crash was minimized to a focused functional test that does not require splice or
node reload.
Problem
When a forwarded HTLC claim is replayed from an on-chain monitor event after the
same preimage was already learned off-chain, LDK can treat the upstream claim as
a duplicate and run the FreeDuplicateClaimImmediately cleanup path.
That cleanup path assumes that if the downstream channel has an occupied
actions_blocking_raa_monitor_updates entry, the entry still contains the
specific ForwardedPaymentInboundClaim blocker being freed. This is not always
true. The original successful forwarded claim may already have released that
blocker, while an unrelated blocker for the same downstream channel still keeps
the entry occupied.
In that case, the immediate duplicate-free path scans the occupied list, does
not find the forwarded blocker, and hits:
assertion failed: found_blocker
Affected behavior / minimal sequence
The minimized functional reproducer uses three nodes, A, B, and C:
- Route a payment C -> B -> A, so B has a downstream edge on A-B and an
upstream edge on B-C. - Separately send an unrelated repeated-channel MPP payment A -> B.
- B claims the MPP payment, while B's A-B monitor updates remain
InProgress.
This leaves aClaimedMPPPaymentblocker occupying A-B's
actions_blocking_raa_monitor_updatesentry. - A claims the forwarded payment off-chain. B learns the preimage from A,
claims upstream on B-C, and the successful upstream monitor update releases
the A-BForwardedPaymentInboundClaimblocker once. - A later publishes its commitment transaction and HTLC-success transaction.
B's A-B monitor sees the same preimage on-chain and replays the forwarded
claim. - The replayed upstream B-C claim is a duplicate, so
FreeDuplicateClaimImmediatelytries to remove the already-released
A-BForwardedPaymentInboundClaimblocker. - A-B still has the unrelated MPP blocker, so the entry is occupied but does
not contain the forwarded blocker. The debug assertion fires.
Expected behavior
Duplicate forwarded-HTLC claim cleanup should tolerate the forwarded blocker
already having been released. It should either use the existing idempotent
release helper or otherwise treat the missing blocker as a completed cleanup
when the downstream channel entry is occupied only by other blockers.
Actual behavior
The immediate duplicate-free path treats an occupied downstream blocker entry
without the target ForwardedPaymentInboundClaim as an internal inconsistency
and triggers debug_assert!(found_blocker).
Why this looks like a project bug
This does not appear to depend on fuzz-harness-only behavior. The focused
reproducer uses normal functional-test helpers for channels, payments, async
monitor persistence, block connection, and monitor-generated on-chain preimage
replay. It does not require splice or reload.
The on-chain duplicate preimage path is expected in general: a monitor can
observe an HTLC resolution after the ChannelManager already learned the same
preimage off-chain. Async monitor persistence can also legitimately leave other
RAA blockers on the same downstream channel. The bug appears to be the
bookkeeping assumption that an occupied downstream blocker list must contain the
specific forwarded blocker being freed.
Impact
The verified impact is a debug-assertion crash in the duplicate forwarded-claim
cleanup path. The assertion is a debug_assert!, so the exact panic is not
expected in normal release builds.
I have not verified funds loss. I also have not verified whether release builds
always recover cleanly from this exact bookkeeping state, or whether they can
leave monitor updates blocked longer than necessary.
Focused reproducer test
#[test]
#[should_panic(expected = "assertion failed: found_blocker")]
fn test_duplicate_onchain_forward_claim_with_other_downstream_blocker() {
let chanmon_cfgs = create_chanmon_cfgs(3);
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
let legacy_cfg = test_legacy_channel_config();
let node_chanmgrs = create_node_chanmgrs(
3,
&node_cfgs,
&[Some(legacy_cfg.clone()), Some(legacy_cfg.clone()), Some(legacy_cfg)],
);
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
let node_a_id = nodes[0].node.get_our_node_id();
let node_b_id = nodes[1].node.get_our_node_id();
let chan_ab = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 50_000_000);
create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 100_000, 50_000_000);
// Route C -> B -> A, leaving B's downstream edge on the A-B channel.
let (forward_preimage, forward_hash, _, _) =
route_payment(&nodes[2], &[&nodes[1], &nodes[0]], 1_000_000);
// Keep an unrelated same-channel MPP claim pending on B. Its in-progress
// monitor updates leave A-B's blocker list occupied after the forwarded
// blocker below has been released.
let (mpp_preimage, mpp_hash, mpp_secret) =
get_payment_preimage_hash(&nodes[1], Some(1_000_000), None);
let mpp_parts = [333_333, 333_333, 333_334];
let mpp_paths = mpp_parts
.iter()
.map(|amt| Path {
hops: vec![RouteHop {
pubkey: node_b_id,
node_features: nodes[1].node.node_features(),
short_channel_id: chan_ab.0.contents.short_channel_id,
channel_features: nodes[1].node.channel_features(),
fee_msat: *amt,
cltv_expiry_delta: TEST_FINAL_CLTV,
maybe_announced_channel: true,
}],
blinded_tail: None,
})
.collect();
let payment_params = PaymentParameters::from_node_id(node_b_id, TEST_FINAL_CLTV)
.with_bolt11_features(nodes[1].node.bolt11_invoice_features())
.unwrap();
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 1_000_000);
let route = Route { paths: mpp_paths, route_params: Some(route_params) };
let onion = RecipientOnionFields::secret_only(mpp_secret, 1_000_000);
nodes[0].node.send_payment_with_route(route, mpp_hash, onion, PaymentId(mpp_hash.0)).unwrap();
check_added_monitors(&nodes[0], 1);
let mut mpp_msg_events = nodes[0].node.get_and_clear_pending_msg_events();
let mut mpp_parts_received = 0;
while mpp_parts_received < mpp_parts.len() {
assert_eq!(mpp_msg_events.len(), 1);
let mpp_event = SendEvent::from_event(mpp_msg_events.pop().unwrap());
mpp_parts_received += mpp_event.msgs.len();
for update_add in mpp_event.msgs.iter() {
nodes[1].node.handle_update_add_htlc(node_a_id, update_add);
check_added_monitors(&nodes[1], 0);
}
nodes[1].node.handle_commitment_signed_batch_test(node_a_id, &mpp_event.commitment_msg);
check_added_monitors(&nodes[1], 1);
let (extra_msg, bs_raa, next_mpp_msg_events) =
do_main_commitment_signed_dance(&nodes[1], &nodes[0], false);
assert!(extra_msg.is_none());
nodes[1].node.handle_revoke_and_ack(node_a_id, &bs_raa);
check_added_monitors(&nodes[1], 1);
nodes[1].node.process_pending_htlc_forwards();
let events = nodes[1].node.get_and_clear_pending_events();
if mpp_parts_received == mpp_parts.len() {
assert_eq!(events.len(), 1);
match &events[0] {
Event::PaymentClaimable { payment_hash, amount_msat, .. } => {
assert_eq!(*payment_hash, mpp_hash);
assert_eq!(*amount_msat, 1_000_000);
},
_ => panic!("Unexpected event"),
}
} else {
assert!(events.is_empty(), "{:?}", events);
}
mpp_msg_events = next_mpp_msg_events;
}
assert!(mpp_msg_events.is_empty());
// Hold all three MPP monitor updates so the ClaimedMPPPayment blocker
// remains in actions_blocking_raa_monitor_updates.
for _ in 0..mpp_parts.len() {
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
}
nodes[1].node.claim_funds(mpp_preimage);
check_added_monitors(&nodes[1], 3);
// A's off-chain fulfill makes B claim from C. That upstream monitor update
// completes and releases B's ForwardedPaymentInboundClaim blocker on A-B once.
nodes[0].node.claim_funds(forward_preimage);
expect_payment_claimed!(nodes[0], forward_hash, 1_000_000);
check_added_monitors(&nodes[0], 1);
let as_updates = get_htlc_update_msgs(&nodes[0], &node_b_id);
nodes[1].node.handle_update_fulfill_htlc(node_a_id, as_updates.update_fulfill_htlcs[0].clone());
check_added_monitors(&nodes[1], 1);
// A's commitment plus HTLC-success replays the same preimage through B's A-B
// monitor. The forwarded claim is now a duplicate, but A-B still has the MPP
// blocker above, so the immediate duplicate-free path finds an occupied list
// that no longer contains the forwarded blocker.
let as_txn = get_local_commitment_txn!(nodes[0], chan_ab.2);
assert!(as_txn.len() >= 2, "Expected commitment + HTLC-success tx, got {}", as_txn.len());
mine_transaction(&nodes[1], &as_txn[0]);
let htlc_success_tx = as_txn
.iter()
.skip(1)
.find(|tx| {
tx.input.iter().any(|input| {
input.witness.iter().any(|witness_item| witness_item == forward_preimage.0)
})
})
.expect("expected an HTLC-success tx for the forwarded payment");
mine_transaction(&nodes[1], htlc_success_tx);
connect_blocks(&nodes[1], ANTI_REORG_DELAY);
nodes[1].node.get_and_clear_pending_events();
}
- Ngôn ngữ chính
- Rust
- Star
- 1.4k
- Fork
- 482
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của lightningdevkit/rust-lightning
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
lightningdevkit/rust-lightning#4767 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
lightningdevkit/rust-lightning#1849 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
lightningdevkit/rust-lightning#4764 · 3 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 22/100
lightningdevkit/rust-lightning#4757 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
lightningdevkit/rust-lightning#4738 · 3 bình luận ·
Tất cả issue của lightningdevkit/rust-lightning
Issue tương tự
-
bug help wanted ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
userFRM/egui-charts#4292 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Tripstack-Corp/spyc#1352 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
marketing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:tui enhancement P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
agent-of-empires/agent-of-empires#6077 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày