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

Require static_remotekey #539

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

Based on #441 (tough I could maybe drop that), #472, and #537, this adds support for, requires, and drops code for pre-static_remotekey channels. Since this is gonna be required for simplified_commitment (which we're gonna want for 0.1 so that we don't have to rely on fee prediction) I don't see a reason to support non-static_remotekey channels.

[ ] I need to PR the changes to the test chases for channel transaction unit tests upstream to compare with other implementations.

@TheBlueMatt TheBlueMatt added this to the 0.1 milestone Mar 9, 2020
@TheBlueMatt
Copy link
Collaborator Author

CC lightning/bolts#758

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Far simpler than expected, would have my vote to go after ChanMonitor refactoring patchset

// Thanks to data loss protection, we may be able to claim our non-htlc funds
// back, this is the script we have to spend from but we need to
// scan every commitment transaction for that
to_remote_rescue: Option<(Script, SecretKey)>,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I'm already cutting out a lot of code based on to_remote_output after the #562 patchset, so rebasing this on top should even simplify change further.

@TheBlueMatt
Copy link
Collaborator Author

Rebased on #590 (which was rebased on master).

@codecov
Copy link

codecov bot commented Apr 28, 2020

Codecov Report

Merging #539 into master will increase coverage by 0.01%.
The diff coverage is 92.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #539      +/-   ##
==========================================
+ Coverage   91.12%   91.13%   +0.01%     
==========================================
  Files          34       34              
  Lines       20544    20504      -40     
==========================================
- Hits        18720    18686      -34     
+ Misses       1824     1818       -6     
Impacted Files Coverage Δ
lightning/src/ln/channel.rs 86.60% <ø> (+0.18%) ⬆️
lightning/src/ln/channelmanager.rs 85.49% <0.00%> (+0.03%) ⬆️
lightning/src/ln/peer_handler.rs 58.25% <60.00%> (-0.05%) ⬇️
lightning/src/chain/keysinterface.rs 96.98% <100.00%> (ø)
lightning/src/ln/chan_utils.rs 97.17% <100.00%> (-0.02%) ⬇️
lightning/src/ln/channelmonitor.rs 95.52% <100.00%> (+0.01%) ⬆️
lightning/src/ln/features.rs 98.71% <100.00%> (+0.05%) ⬆️
lightning/src/ln/functional_tests.rs 97.02% <100.00%> (-0.02%) ⬇️
lightning/src/ln/msgs.rs 90.14% <100.00%> (ø)
lightning/src/util/enforcing_trait_impls.rs 100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9098240...07db23d. Read the comment docs.

@TheBlueMatt TheBlueMatt force-pushed the 2020-03-static-remotekey branch from 524c324 to acdd6d8 Compare April 29, 2020 01:01
@jkczyz jkczyz self-requested a review April 29, 2020 18:17
This makes it easier to amend the full_stack_target
test_no_existing_test_breakage test by always providing the
neccessary data in the log.
It appears the local signatures which are specified in the channel
transaction-generation tests were never checked directly (though
they were checked as a part of the overall fully-signed-transaction
tests).

Check them explicitly so that they can be updated for static remote
key.
@TheBlueMatt TheBlueMatt force-pushed the 2020-03-static-remotekey branch from acdd6d8 to b007a68 Compare April 29, 2020 19:26
@TheBlueMatt
Copy link
Collaborator Author

Rebased on master directly now and updated the fuzz tests for the new tx format.

@TheBlueMatt TheBlueMatt force-pushed the 2020-03-static-remotekey branch from b007a68 to 0e42876 Compare April 29, 2020 20:10
@valentinewallace valentinewallace self-requested a review April 29, 2020 20:52
@@ -97,7 +97,7 @@ mod sealed {
// Byte 0
DataLossProtect | InitialRoutingSync | UpfrontShutdownScript,
// Byte 1
VariableLengthOnion | PaymentSecret,
VariableLengthOnion | StaticRemoteKey | PaymentSecret,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update commit message as anything listed here is considered known as of #590.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, thats a code bug, not a commit message bug :p.

Comment on lines -644 to +635
5u8.write(w)?;
4u8.write(w)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is no concern yet that this changes the serialization format. At what point will we need to be mindful about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so yet, no, but its probably something worth discussing. My answer was always "0.1", ie "once we actually think its reasonable to start testing on mainnet", but that's probably now "once we support anchor outputs, or at least the insecure-HTLCs version that it looks like we'll get first".

@@ -3467,18 +3456,20 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
pub fn get_channel_reestablish(&self) -> msgs::ChannelReestablish {
assert_eq!(self.channel_state & ChannelState::PeerDisconnected as u32, ChannelState::PeerDisconnected as u32);
assert_ne!(self.cur_remote_commitment_transaction_number, INITIAL_COMMITMENT_NUMBER);
let mut pk = [2; 33]; pk[1] = 0xff; // Select a dummy pubkey which is valid in both "real" and fuzztarget modes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow what is meant by this comment. If it's valid in "real" mode why wouldn't it also be valid in fuzztarget mode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment to be more verbose, but essentially fuzztarget mode has an arbitrary validity criteria, which we want to match, as well as actually being valid.

@TheBlueMatt TheBlueMatt force-pushed the 2020-03-static-remotekey branch from 0e42876 to a37cd6d Compare May 3, 2020 02:14
Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few docs points, but otherwise ACK. I can take the TODO if this get first.

return Err(ChannelError::CloseDelayBroadcast {
msg: "We have fallen behind - we have received proof that if we broadcast remote is going to claim our funds - we can't do any automated broadcasting",
update: monitor_update
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter anymore now but did we forget to implement "my_current_per_commitment_point" does not match the expected value"? I'm not even sure you can verify this given you don't have a comparison base if you're fallen behind.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yea, seems so. One of those awkward "checking this has no value except to enforce that people don't generally set it wrong".........

self.their_pubkeys.as_ref().unwrap().payment_basepoint
} else {
self.local_keys.pubkeys().payment_basepoint
}.serialize());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No? Its indented because its a parameter to a fn.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My earlier comment was rather to make the expression inside WPubkeyHash::hash() (i.e. the payment basepoint) a local variable, which would be more readable IMHO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. Missed that. Also responded too quick to antoine's comment, the whole thing did have an extra indent, I'd intended that for these lines but not the top "let" line. Fixed.

@TheBlueMatt TheBlueMatt force-pushed the 2020-03-static-remotekey branch from a37cd6d to e1e3090 Compare May 4, 2020 17:58
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment but otherwise looks good!

self.their_pubkeys.as_ref().unwrap().payment_basepoint
} else {
self.local_keys.pubkeys().payment_basepoint
}.serialize());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My earlier comment was rather to make the expression inside WPubkeyHash::hash() (i.e. the payment basepoint) a local variable, which would be more readable IMHO.

This adds the ability to check for static_remotekey in appropriate
feature contexts and prints it at connect time. It is still
considered unknown for the purposes of requires_unknown_bits() as
we don't yet implement it.
This simplifies channelmonitor quite nicely (as expected) as we
never have to be concerned with learning data in a DataLossProtect
which is require for us to claim our funds from the latest remote
commitment transaction.
We no longer derive any keys from the payment point, so they aren't
a "base" but simply a point/key.
@TheBlueMatt TheBlueMatt force-pushed the 2020-03-static-remotekey branch from e1e3090 to 07db23d Compare May 6, 2020 01:43
@TheBlueMatt
Copy link
Collaborator Author

Fixes issues and squashed. Will confer with @ariard on ordering with #610 and then merge.

@ariard
Copy link

ariard commented May 6, 2020

ACK 07db23d, just fixing my nit comments + Jeff one since last review.

@TheBlueMatt TheBlueMatt merged commit d2520f4 into lightningdevkit:master May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants