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

Merged
merged 5 commits into from
Nov 25, 2024

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

wallet/wallet.c Outdated
Comment on lines 487 to 474
/* 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
@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

@rustyrussell
Copy link
Contributor

OK, I've solved this a different (more intrusive way). Christian already changed the code so we don't send our own unilateral close tx when we have already seen a spend onchain, which basically resolves this (since we don't create anchors in that case either).

Changing the order made some messages make less sense, e.g. channel_fail_permanent prints the current state of the channel, and this doesn't work any more.

@rustyrussell rustyrussell force-pushed the nifty/anchor-acct branch 2 times, most recently from 42f3339 to 17d89a1 Compare November 25, 2024 04:08
niftynei and others added 5 commits November 25, 2024 15:40
We don't need to change these txs.

Signed-off-by: Rusty Russell <[email protected]>
Cleans up the API: we have two functions now, one which is explicitly for
"I'm failing this because I saw this tx onchain".

Now we can correctly report the tx which closed the channel (previously
we would always report our own tx(s)!).

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Fixed: JSON-RPC: `close` now correctly reports the txid of the remote onchain unilateral tx if it races with a peer close.
Changelog-Fixed: Protocol: we no longer try to spend anchors if a commitment tx is already mined (reported by @niftynei).
Fixes: ElementsProject#7526
@rustyrussell rustyrussell merged commit 46fde41 into ElementsProject:master Nov 25, 2024
39 checks passed
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