Repository navigation
[2/3] aux revocation: exchange revocation AuxSigs in RevokeAndAck - #11111
GeorgeTsagk wants to merge 3 commits into
Conversation
da59bf0 to
e5bc76a
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
🔴 PR Severity: CRITICAL
🔴 Critical (16 files)
🟠 High (1 file)
🟡 Medium (1 file)
🟢 Low (14 files, tests)
AnalysisThis PR modifies core commitment-transaction and HTLC-resolution logic across To override, add a |
e5bc76a to
3311774
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
3311774 to
4032f41
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
4032f41 to
f86a7e7
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
|
@gijswijs: review reminder |
3 similar comments
|
@gijswijs: review reminder |
|
@gijswijs: review reminder |
|
@gijswijs: review reminder |
bc2e49b to
27ebd33
Compare
|
@gijswijs: review reminder |
27ebd33 to
ca4505e
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
|
@gijswijs: review reminder |
2 similar comments
|
@gijswijs: review reminder |
|
@gijswijs: review reminder |
|
@gijswijs: review reminder |
1 similar comment
|
@gijswijs: review reminder |
litbot-9000
left a comment
There was a problem hiding this comment.
Reviewed with the rest of the stack and with taproot-assets#1994 (which pins this at 2069f100d). I confirmed the three blockers inline (index collision, sig-less entries, unbounded allocation) with scratch tests against this branch.
These parts are correct: key ring and height selection on both sides, the dust classification agreeing between sender and receiver, no side effects on sign failure, atomic persistence of the blob with the commitment, the identical-bytes retransmit, and the gating to custom SigHashDefault channels.
Test gaps:
- Every test HTLC goes Alice→Bob, so there's no bidirectional or same-index coverage, and the fake verifier accepts any blob. That's why the collision below slipped through.
- Switching the receiver's dust limit from
RemoteChanCfgtoLocalChanCfgsurvives the suite, because the test channels use symmetric dust limits. - The "restart" in
TestRevocationAuxSigsRetransmissionisRefresh()on the same instance, and the retransmittedRevokeAndAckis never fed to Alice, so verification after a restart isn't exercised. TestUnpackRevocationAuxSigsCorruptdoesn't cover duplicates, trailing bytes or an oversized count.
Posted by claudell (automated review agent) at georgetsagk's request.
ca4505e to
908ad9a
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
908ad9a to
69392f1
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
69392f1 to
6fe839f
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
|
@GeorgeTsagk, remember to re-request review from reviewers when ready |
6fe839f to
336d40e
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
c8cfca3 to
875ee3c
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
875ee3c to
0014158
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
|
@litbot-9000: review reminder |
0014158 to
259fd9a
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
The RevokeAndAck message gains a CustomRecords field, encoded and decoded with the standard ParseAndExtractCustomRecords/MergeAndEncode helpers. The field is additive and backward-compatible on the wire: peers that send no records produce byte-identical encodings to before this change, and unknown odd records are tolerated on receive. The following commits use this field to carry revocation AuxSigs for aux/custom (taproot asset) channels; a vanilla lnd channel never populates it.
When an aux/custom (taproot asset) channel revokes a commitment that was built with DeterministicHTLCs, the revoking party now signs the second-level HTLC virtual transaction of every non-dust HTLC on the commitment being revoked, and ships the signatures to the peer inside the RevokeAndAck message's custom records. This hands the honest party the asset-level puzzle piece it needs at breach time: if the cheater later broadcasts the revoked commitment and takes an HTLC to the second level, the breached party holds the cheater's half of the asset witness for that transition. An HTLC has exactly one second-level path on the commitment of the party that revokes it: the success tx for an HTLC it received, the timeout tx for one it offered. That is the path that is signed. Changes: - Sender: signLocalHtlcAuxSigs derives the second-level tx of each non-dust HTLC on the revoked commitment and submits a sign job to the aux signer. The signatures are packed as one TLV stream per HTLC, tagged with the HTLC's index and direction. The index alone does not identify an HTLC: both parties count the HTLCs they offer from zero, so a commitment regularly carries an incoming and an outgoing HTLC with the same index. One entry is packed per non-dust HTLC even when the signer produces no signature for it (a BTC-only HTLC), in lockstep with the BTC-level signatures. A signing failure fails the revocation as a whole, before any state is advanced: the peer requires the sigs, so a sig-less RevokeAndAck would just fail the channel on their side. - Receiver: ReceiveRevocation verifies the received aux sigs against the revoked commitment's key ring BEFORE the revocation is accepted and the tail advances, then injects the sigs into the remote commitment's HTLC custom records so they are persisted in the revocation log for breach-time consumption. Presence is enforced, mirroring the aux sig count check on CommitSig: an entry is required for every non-dust HTLC on the revoked commitment (a peer cannot strip our breach protection by withholding the records), and entries for unknown or dust HTLCs are rejected. A verify job is handed to the aux signer for every non-dust HTLC, with or without a sig, as only the aux signer knows whether the HTLC carries aux outputs and therefore owes one. Whatever the peer put under our storage record type on its own UpdateAddHTLC is dropped before the sigs are injected, so only verified sigs reach the revocation log. - Decoding: the blob comes from the peer and is decoded accordingly. The declared entry count never sizes an allocation, every entry must consume exactly the length it declares, an HTLC may appear only once and nothing may follow the last entry. - Retransmission: the packed sig blob is persisted in a new optional TLV field on the channel info, written atomically with the commitment advance in UpdateCommitment, and re-attached when the RevokeAndAck is retransmitted on channel reestablish. Only the latest revocation can ever be owed, so a single overwritten slot suffices. If the write fails the previous blob stays in memory. - BaseAuxJob gains the WhoseCommit and HtlcTimeout fields needed to describe a sign job for our own commitment to the aux signer. The gate is factored into a single predicate, exchangesRevocationAuxSigs, used by both hooks and (defense in depth) inside the sign and verify functions themselves. It requires an explicit HasTapscriptRoot() on the channel type, and that the commitment being revoked records SigHashDefault in its own blob. Both peers hold that record for the same commitment, so they agree on which revocations carry the signatures even while the sighash type used for new commitments is changing. A vanilla lnd channel never signs, attaches, reads, or verifies these records and its RevokeAndAck is byte-identical to before this change.
Coverage for the revocation AuxSig exchange introduced in the previous commits: - lnwire codec: encode/decode round trips for RevokeAndAck with and without custom records, including a byte-for-byte assertion that the no-records encoding is identical to the legacy wire format. - TLV blob: pack/unpack round trips, including the same HTLC index in both directions, and rejection of corrupt and hostile blobs: truncation, garbage, duplicate entries, trailing bytes, undeclared entries, lengths beyond the blob, cut-off records, missing or invalid index and direction records. A declared entry count in the billions must not make the decoder allocate for it. - Custom-channel-only gating: a non-custom taproot channel with an aux signer that pushes SigHashDefault attaches nothing and ignores stray records. The gate follows the sighash recorded for the commitment being revoked, not the one new commitments use. - Happy path over a funded tapscript-root channel pair: one sig for every non-dust HTLC, the dust decision made with the dust limit of the commitment's owner, the sig matched to the right verify job, and the verified sig persisted into the revocation log entry of the revoked commitment. - Same HTLC index in both directions: each HTLC is signed once for its own path, gets its own entry, and keeps its own sig through verification and persistence. - BTC-only HTLCs: sig-less lockstep entries are attached, and accepted once the aux signer has been asked about them. - Rejection before the remote chain tail advances: unverifiable sigs, malformed blob, missing sig for a non-dust HTLC, a sig tagged with the wrong direction, withheld blob, a sig withheld from its entry, the sig of another HTLC, an extra entry for an unknown HTLC index or for the other direction, and entries for HTLCs that are dust for both parties or for the signer only. - A custom record the peer planted under our storage type never reaches the revocation log. - Sign-time failure: an aux signer error fails RevokeCurrentCommitment before any state advances, for both batch-level and per-job errors. - Retransmission: after a restart, with the channel rebuilt from disk, a retransmitted RevokeAndAck carries the original aux sigs without signing again, and the peer verifies and accepts them.
259fd9a to
851eaeb
Compare
Points the lnd module and its submodules at the companion series on the GeorgeTsagk/lnd fork: 1. lightningnetwork/lnd#11094, deterministic second-level HTLCs 2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck 3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow The pin is at the tip of part 3, which contains all three. It also adapts the call sites that the new aux interfaces touch. This is temporary and has to be dropped once the lnd series lands.
This is part 2 of the HTLC revocation series for aux/custom (taproot asset) channels, stacked on #11094. Only the last three commits are new here.
When a custom channel with deterministic HTLCs revokes a commitment, the revoking party signs second-level transactions for both spending paths of every non-dust HTLC on the revoked commitment and ships the signatures in the RevokeAndAck. This hands the honest party the asset-level material it needs at breach time: whichever path a cheater later uses to take an HTLC to the second level, a valid asset witness is already in hand.
Scope:
RevokeAndAckgainsCustomRecords. Additive and backward compatible, a message without records is byte-identical to today (pinned by test).No lnd-native channel can enter these paths, so end-to-end coverage lives in the taproot-assets custom channel itest suite; unit tests here cover the happy path, dust exclusion, all rejection cases, retransmission across a restart, and codec round trips.
Previous PR: #11094
Next PR: #11112