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

Zero fee htlc preparation: Part 1 #6073

Merged

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Mar 7, 2023

(Based on #5708, starts at chaintopology: rename broadcast_tx callback name. ) Merged!

This is infrastructure neatening, plus enhancements to broadcast_tx to allow us to specify a minumum target block, and a hook for replacing txs (which we'll use for RBF).

It was once only called on failure, now it's always called (if set).
It was called different things in different places, so unify it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We'll use this to do RBF.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We can add the htable to the memleak detection, and we already do this
for the watches.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fun story.  We're changing onchaind to hand txs to us, and we will
construct them and do the broadcast for it.  lightningd tells onchaind
the witness it used (with flags to indicate which fields were
signatures so should be ignored) so onchaind can recognize the tx
when/if it is mined.

And when onchaind was waiting for a CLTV delay, it wouldn't tell
lightningd yet, but wait until the parent was sufficiently deep

But this caused bugs!

In particular, on replay, onchaind would see transactions which it
hasn't sent yet.  This was not a problem before, as onchaind had
created the tx, even if it hadn't told lightningd to broadcast it, so
recognized the variant when it came in.  When we're relying on
lightningd to tell us what the tx will look like, this doesn't work
any more.

The cause of this is that we fire off txowatches ("this output was
spent!") while we process blocks, and only fire off txwatches ("this
tx increased depth") once all the current blocks are processed.  Often
this didn't matter, since we replay messages to onchaind from the
database, *but* we trim the last few blocks on restart (or, if there's
a small reorg while we're stopped), and we can hit this misordering.

Changing our topology code to only ever process one block at a time
would be a solution, but slows down catchup (and tests, where we often
mine a run of blocks).

So, this seems like a premature optimization, but it's really
required!  And in future, lightningd can use this knowledge of pending
transactions to combine them in more clever ways.

Note that if a tx is valid at block N, we broadcast it once we see
block N-1, to get it in the mempool for block N.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…haind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We need to actually steal it onto requested context in this case!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We only do this in one place now, but we're going to add another.

Also, make queued messages const.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Firstly, amount should not be `static`, so use a separate line to
declare those (fee is static, as it's cached across calls).

Secondly, new_tracked_output doesn't take(), it copies.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fixes: ElementsProject#4473
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: wallet: we no longer make txs below minrelaytxfee or mempoolminfee.
@cdecker
Copy link
Member

cdecker commented Apr 5, 2023

ACK 85e2833

@rustyrussell rustyrussell merged commit e6db0ea into ElementsProject:master Apr 5, 2023
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.

2 participants