-
Notifications
You must be signed in to change notification settings - Fork 913
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
pay: Use the networkheight as current height #7190
pay: Use the networkheight as current height #7190
Conversation
6f36435
to
8593a93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs fixup folding, but code looks great!
8593a93
to
dcea838
Compare
I had to rework this patch a bit, since the This calls both |
Addressing a bunch of test failures that were reliant on the old behavior now. |
There is at least one broken test due to the |
I found out that we use the It's a bit strange to have |
It is getting replaced with a paymod that adjusts the chain height used to offset all calculations from.
The `chainlag` is defined as the positive difference between the height of the last block processed by the node and the best height known by the bitcoin backend. The chainlag is positive when we are still catching up with the blockchain, and `0` otherwise. The `chainlag` is used as an additional offset to the CLTV values when sending payments, allowing payments to be sent even before the chain sync completes.
This actually uses the `chainlag` to make unsynced payments possible.
These tests were related to sending early payments, and will now fail, as the underlying behavior changed.
2d845cc
to
231b163
Compare
Ready for review @rustyrussell 🤗 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! nits only.
@@ -132,6 +133,7 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd, | |||
p->local_invreq_id = NULL; | |||
p->groupid = 0; | |||
p->mods = NULL; | |||
p->chainlag = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this initialization is overzealous? We shouldn't access chainlag without purposefully setting it first as far as I can tell.
Co-authored-by: Alex Myers <[email protected]>
We used to use the sync height, i.e., the height of the last block that
we processed as the offset for all calculations. This can result in CLTVs
that are too close to the current height while still synchronizing with
the blockchain.
This PR adds the
networkheight
towaitblockheight
so we can retrievethe current height of the block that our bitcoin backend has seen.
This means that CLTV calculations are correct as long as a) the backend
is in sync and b) the peer is in sync.
Sending the payment without sync is safe, because if the peer accepts the
HTLC they ensured the channel is still open and active.