Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: don't send anchorspends for onchain commitment txs #7593

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

niftynei
Copy link
Collaborator

Ordering we were using for setting the channel state was causing us to send anchorspend transactions for onchain commitments.

This would occasionally show up in the CI as a flake, due to a race condition with onchaind adding commitment tx utxos that were then picked up in the anchorspend construction, which would fail due to bookkeeper assertions around spent/unspent utxos. (See #7526)

Also includes a fix to not include currently CSV locked outputs in the construction of anchorspends.

Fixes #7526

@niftynei niftynei added this to the v24.08 milestone Aug 20, 2024
if not anchors:
tags = check_utxos_channel(l1, [channel_id], expected_1)
check_utxos_channel(l2, [channel_id], expected_2, tags)
tags = check_utxos_channel(l1, [channel_id], expected_1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can now re-activate this part of the test, since we're no longer sending out anchorspend txs, which were causing this to fail.

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

ACK 84f55b1

Comment on lines +487 to +489
/* Don't add csv-locked ones */
if (utxo_is_csv_locked(utxo, blockheight))
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a fix for: #6973?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely!

@ShahanaFarooqui ShahanaFarooqui modified the milestones: v24.08, v24.11 Aug 21, 2024
When building a tx to spend *now* we shouldn't include CSV locked utxos
as we want them to be immediately spendable.
We were seeing occassional spends of commitment tx utxos in
anchorspend txs, which was causing occasional test fails.

We shouldn't be sending anchorspends at all for onchain funding-spends.
The logic is in place for this, but the ordering of the state update to
channel was incorrect, which lead to loglines as follows
(we'd expect to see failure in ONCHAIN not NORMAL), given that the
reason=onchain...

"Peer permanent failure in CHANNELD_NORMAL: Funding transaction spent (reason=onchain)"

A quick reordering of the state change + firing of `drop_to_chain` fixes
the issue of sending the anchorspend tx, which removes the race case
of onchaind adding utxos from the commitment tx to the utxoset, where
the anchorspend construction was picking them up.

Fixes ElementsProject#7526
@rustyrussell
Copy link
Contributor

Changed milestone to next point release, since this fixes a nasty issue.

@rustyrussell
Copy link
Contributor

This is buggy, hence the CI failures.

"2024-09-20T03:41:23.4480770Z lightningd-2 2024-09-20T03:18:40.405Z UNUSUAL 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#1: Not dropping our unilateral close onchain since we already saw theirs confirm."

But l2 is the one which did the unilateral close, so this is wrong!

@rustyrussell
Copy link
Contributor

rustyrussell commented Sep 20, 2024

OK, I think the premise here is wrong.

We should consider sending anchorspends after broadcast, and we do, if we consider the feerate insufficient. We don't if we've seen the tx mined, though. I don't see the problem?

I'll cherry pick the csv spend fix into a separate PR for this point release.

EDIT: I think I might understand some of this. Christian recently changed this code not to re-xmit commitment transactions once we've seen one onchain, which itself removes many cases where we would spend the anchors.

@niftynei
Copy link
Collaborator Author

niftynei commented Sep 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI Complaint about spend_tag in test_onchain_their_unilateral_out[True]
5 participants