-
Notifications
You must be signed in to change notification settings - Fork 22
smite: validate negotiated features and channel types in accept_channel oracle
#209
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
base: master
Are you sure you want to change the base?
Changes from all commits
1f02ca6
e6450a4
165f6cf
b56ea18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ impl<T: Target> SnapshotSetup<T> for PostInitSetup { | |
| // Echo features but strip the bits that would take us off the | ||
| // single-funded `open_channel` path this setup is built for. | ||
| let our_init = init_for_single_funded(&target_init); | ||
| conn.send_message(&Message::Init(our_init).encode())?; | ||
| conn.send_message(&Message::Init(our_init.clone()).encode())?; | ||
|
|
||
| // Drain any remaining post-init noise so the snapshot starts with a | ||
| // clean connection. | ||
|
|
@@ -86,7 +86,11 @@ impl<T: Target> SnapshotSetup<T> for PostInitSetup { | |
| // this is the floor. Dynamic per-target queries can replace it | ||
| // later. | ||
| block_height: u32::try_from(INITIAL_BLOCKS).expect("fits in u32"), | ||
| target_features: target_init.features, | ||
| // Since we echo the same features the target sent, but strip both | ||
| // required and optional bits to exercise only the single funded | ||
| // flow and avoid unrelated noise, negotiated features are just the | ||
| // features we sent in our init. | ||
| negotiated_features: Features::from(our_init.features), | ||
|
Comment on lines
+89
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be a bitwise-or of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spec-wise, yes, but I think see: |
||
| }; | ||
|
|
||
| Ok((conn, context)) | ||
|
|
||
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.
Related to my other comment about removing the check for
OPTION_CHANNEL_TYPE: I interpret "can be safely ignored" as "don't check if the feature is enabled; assume it is", so a peer who didn't set this bit ininitisn't wrong.I think it could make sense to distinguish which bits we set here because we assume them to be negotiated (
OPTION_STATIC_REMOTEKEYandOPTION_CHANNEL_TYPE) vs. for other reasons (OPTION_ANCHORS). So instead of adding assumed feature bits manually here, we could have a list of assumed features, and then include them here for our sampleProgramContextin the tests and inSnapshotSetupduring fuzzing.However, this is related to the question of whether we even need to include assumed bits in our context in the first place if we can assume them to be set, so all checks based on these features are unconditional.
We could also postpone this discussion for an
InitOracle, because it would be more concerned with the meaning of bits, like that only one bit should be set for a feature.WDYT?
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.
Will remove the check for
OPTION_CHANNEL_TYPEbeing present in the negotiated features, so I think we can safely removeOPTION_CHANNEL_TYPEfrom the negotiated features as well