-
Notifications
You must be signed in to change notification settings - Fork 407
Revocation enforcement #764
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
Revocation enforcement #764
Conversation
8bbb6d6
to
3e82940
Compare
Codecov Report
@@ Coverage Diff @@
## main #764 +/- ##
==========================================
+ Coverage 91.24% 91.28% +0.04%
==========================================
Files 37 37
Lines 22846 22920 +74
==========================================
+ Hits 20845 20922 +77
+ Misses 2001 1998 -3
Continue to review full report at Codecov.
|
I'm seeing a fuzzing problem, but after trying to fix it, looks like there's an actual out of order revocation. The fuzz target is: |
27b2eee
to
dff0448
Compare
Fuzzing issue fixed |
dff0448
to
c602db1
Compare
07e0a82
to
9b840d7
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.
One nit.
lightning/src/ln/functional_tests.rs
Outdated
@@ -7411,7 +7407,7 @@ fn test_data_loss_protect() { | |||
tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())}; | |||
fee_estimator = test_utils::TestFeeEstimator { sat_per_kw: 253 }; | |||
persister = test_utils::TestPersister::new(); | |||
monitor = test_utils::TestChainMonitor::new(Some(&chain_source), &tx_broadcaster, &logger, &fee_estimator, &persister); | |||
monitor = test_utils::TestChainMonitor::new(Some(&chain_source), &tx_broadcaster, &logger, &fee_estimator, &persister, &keys_manager); |
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.
Hmm, at least here, maybe elsewhere - dont we create the TestKeysInterface a few lines up, meaning we lose the state tracking?
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 is done, but together with the fix for the other nit, a significant issue was uncovered in data_loss_protect
handling.
It looks like the Node
Drop
implementation does a serialization round-trip, which ends up trying to broadcast a revoked commitment tx, since we restored an old state. This seems to be an actual issue with channel reestablish - not sure how you intended it to recover going forward since it's out of sync. It seems like if there's data-loss, we have to update our commitment number instead of just erroring in channel_reestablish
?
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.
Hmm, can you push the branch that demonstrates that somewhere? I suppose the "right" answer could be to not panic, return an Err, make sure ChannelMonitor
handles that fine (it should?) and then hope we can broadcast the current state when our counterparty broadcasts theirs. That's not quite enough because we should be able to broadcast the old state manually, but then it'd be up to the signer to accept a stale state if we give up waiting on our counterparty.
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 suppose we could tweak the signer to check a boolean whether we should panic or not and in a few tests (like this one), let it Err instead of panicing and then test that we can still claim a counterparty-broadcasted tx or retry broadcasting our state later.
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.
Sorry, pushed now, forgot yesterday.
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.
It seems like full support for data_loss_protect
would entail putting the system in a state where it doesn't try to go on-chain, because we don't have the needed data for a non-revoked tx. Punting on that for later, I've added a commit that marks the node as failed and doesn't try to execute Node::Drop
for the node that suffered the data-loss in test_data_loss_protect
.
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.
As discussed elsewhere, we now return Err
when there is a revocation issue and err_on_sign_revoked_holder_tx
is on in TestKeysInterface
/ EnforcingChannelKeys
.
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.
... however, this workaround no longer works as a result of OnChainTx.holder_commitment
no longer being optional. As part of that change, we panic if an Err
is return when trying to sign the latest commitment. Also, this is now an issue also in tests that test justice reactions by simulating a bad actor - they panic during HTLC claims when they react to their own broadcast.
I see a couple of approaches:
- propagate the
Err
up the call stack and don't panic - simulate bad actor / data loss more accurately by rolling back the signer or at least the revocation counter
The rebase that fails tests was pushed just now.
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.
Actually, the simplest fix is to disable the revocation enforcement for these spots.
a1644a2
to
c8bd159
Compare
Due to issues described in #775, The panic has been changed to an |
Can we have the test enforcing signer have an internal setting to either panic or return an Err so we still ensure we hit panics in most tests, with a comment pointing to the new issue in |
Added |
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 looks good mod the fuzzers failing to compile. One nit bug no need to fix it now.
10a87ba
to
ebc80c3
Compare
This allows stateful validation in EnforcingChannelKeys
We want to make sure that we don't sign revoked transactions. Given that ChannelKeys are not singletons and revocation enforcement is stateful, we need to store the revocation state in KeysInterface.
ebc80c3
to
29d46ce
Compare
Ran into an issue in #764 (comment) after rebase, will look into possible approaches. |
29d46ce
to
592399a
Compare
This has been corrected, and the PR is ready for final review. |
f240e4a
to
55f4ef8
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.
Just minor comments otherwise SGTM.
55f4ef8
to
f8e0405
Compare
Added some more docs, please take a look. I believe this addresses all outstanding comments. |
When simulating a bad actor that broadcasts a revoked tx, the policy check would otherwise panic.
f8e0405
to
142b0d6
Compare
Post-Merge Code Review ACK 142b0d6 |
We want to make sure that we don't sign revoked transactions.
Given that
ChannelKeys
(actuallyEnforcingChannelKeys
) are not singletons and revocation enforcement is stateful, we need to store the revocation state inKeysInterface
.This builds on #761. The first new commit "Use TestKeysInterface in functional tests" could be folded in to that PR.