-
Notifications
You must be signed in to change notification settings - Fork 345
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
Handle if funding output is in a coinbase transaction #1924
Handle if funding output is in a coinbase transaction #1924
Conversation
35ebc72
to
5155b21
Compare
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #1924 +/- ##
==========================================
+ Coverage 90.58% 90.59% +0.01%
==========================================
Files 110 110
Lines 57526 57573 +47
Branches 57526 57573 +47
==========================================
+ Hits 52112 52161 +49
+ Misses 5414 5412 -2
☔ View full report in Codecov by Sentry. |
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.
Thanks for looking into this!
A few assorted notes:
- this def. needs testing
- we should introduce a constant for the maturation delay
- the extended number of required confirmations need to be reflected in other places, e.g., in
ChannelDetails::confirmations_required
, otherwise users might be confused why the channel isn't ready after this value has been reached. I therefore wonder if the check should be moved toaccept_channel
, i.e., if we could simply setChannel::minimum_depth
tomin(100, minimum_depth)
for coinbase-funded channels there and call it a day?
I don't think this would work in |
Ah, you're of course right, I think I meant |
5155b21
to
c5a477e
Compare
Haven't started on tests just yet but made it so it should handle the zero-conf case AFIAK and made it so it updates the Does this look like I am on the right track? |
177e373
to
3b06a34
Compare
7d1645a Add constant for coinbase maturity (benthecarman) Pull request description: Not sure if this is the best place to put this but it is nice to have a constant for this instead of having other libraries make their own (ie lightningdevkit/rust-lightning#1924 (review)) ACKs for top commit: tcharding: ACK 7d1645a apoelstra: ACK 7d1645a Tree-SHA512: 5ac2a3359cadd303158c66ba45db8f4bf8cc80b6c19604262999ff361fd0bd98e2a4851c57da1962cb5c74f5789a85c8b3861f1742706a60ce1fbc57c3c200cc
3b06a34
to
956188b
Compare
Still working on understanding the testing infra around the channel stuff but I think the logic for this is correct now |
lightning/src/ln/channel.rs
Outdated
@@ -5142,6 +5145,15 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> { | |||
} | |||
} | |||
} | |||
|
|||
// if this is a coinbase transaction and not a 0-conf channel |
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.
This should go in the txid == funding_txo check, otherwise we'll do this any time we see a coinbase tx at all.
Looks like this needs a rebase, would be good to move this forward. Can we help with test writing here? |
yeah sorry haven't had time to get to this, if this is a priority feel free to write the test for me haha |
7ed3790
to
0f01921
Compare
Grrrrr, alright, this is gonna slip to 117 :(. |
I've rebased and am writing a test for this case. |
Rebased....where? |
Just locally |
0f01921
to
696725c
Compare
lightning/src/ln/functional_tests.rs
Outdated
{ | ||
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap(); | ||
assert_eq!(added_monitors.len(), 1); | ||
assert_eq!(added_monitors[0].0, funding_output); | ||
added_monitors.clear(); | ||
} |
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.
nit: I don't think this is testing anything new, could probably just be check_added_monitors
?
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 forget all the utils lol.
lightning/src/ln/functional_tests.rs
Outdated
{ | ||
let mut added_monitors = nodes[0].chain_monitor.added_monitors.lock().unwrap(); | ||
assert_eq!(added_monitors.len(), 1); | ||
assert_eq!(added_monitors[0].0, funding_output); | ||
added_monitors.clear(); | ||
} |
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.
nit: ^ same here
// Note that 0conf channels with coinbase funding transactions are unaffected and are | ||
// immediately operational after opening. |
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.
Would it be worth adding the coinbase case to the 0conf test? FWIW it doesn't look like too much work since we already have functional_test_utils::open_zero_conf_channel
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.
Yeah, we thought it would be good to add them, so will be doing that definitely in this PR. Maybe some closes on those channels before maturity too.
d3fc6f8
to
418b0dc
Compare
LGTM, feel free to squash IMO. |
418b0dc
to
b28bf0b
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.
LGTM
Closes #1396