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

removes shred wire layout specs from sigverify #25520

Merged
merged 1 commit into from
May 26, 2022

Conversation

behzadnouri
Copy link
Contributor

@behzadnouri behzadnouri commented May 24, 2022

Problem

sigverify_shreds relies on wire layout of shreds:
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L39-L46
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L298-L305

In preparation of #25237
which adds a new shred variant with different layout and signed message,
this commit removes shred layout specification from sigverify and
instead encapsulate that in shred module.

Summary of Changes

removed shred wire layout specs from sigverify

@behzadnouri behzadnouri force-pushed the shred-sig-verify branch 3 times, most recently from 553222a to 87e5f0d Compare May 24, 2022 20:35
}

// Returns chunk of the payload which is signed.
pub(crate) fn get_signed_message(shred: &[u8]) -> Option<&[u8]> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This may need to return Option<&[[u8]]> to account for a non-contiguous buffer if the signed data refers to everything protected by merkle vs just the signature for the merkle root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the signed data refers to everything protected by merkle

not sure why should we want to sign everything,
but even then, in #25237 that is still a contiguous slice.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, you can disregard. I was considering support for a shred layout where the merkle hashed data is non-contiguous.

@@ -538,50 +576,39 @@ impl From<ShredData> for Shred {

// Get slot, index, and type from a packet with partial deserialize
pub fn get_shred_slot_index_type(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can get_shred_slot_index_type just be removed and replaced with layout::get_slot? It looks like the only usage outside of tests is in process_packet which only uses the slot value.

Copy link
Contributor Author

@behzadnouri behzadnouri May 24, 2022

Choose a reason for hiding this comment

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

yeah, I don't like it either, but even though it only uses slot, it effectively also validates index and shred_type and discards packets which have invalid index or shred_type:
https://github.com/solana-labs/solana/blob/2fb096c48/core/src/shred_fetch_stage.rs#L40

So it wouldn't be the same as just layout::get_slot.

Copy link
Contributor

Choose a reason for hiding this comment

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

it seems ok to me to replace it given that the shred is going to go through another round of decode and verification. If you want to keep it to preserve the existing behavior I'm ok with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leaning on keeping it for now since it does not intervene with current changes,
and it also gathers and submits ShredFetchStats metrics

jbiseda
jbiseda previously approved these changes May 25, 2022
@mergify mergify bot dismissed jbiseda’s stale review May 25, 2022 17:24

Pull request has been modified.

sigverify_shreds relies on wire layout specs of shreds:
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L39-L46
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L298-L305

In preparation of
solana-labs#25237
which adds a new shred variant with different layout and signed message,
this commit removes shred layout specification from sigverify and
instead encapsulate that in shred module.
@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #25520 (8848fce) into master (f9f6b94) will increase coverage by 0.0%.
The diff coverage is 77.0%.

@@            Coverage Diff            @@
##           master   #25520     +/-   ##
=========================================
  Coverage    82.0%    82.0%             
=========================================
  Files         655      620     -35     
  Lines      171822   170457   -1365     
  Branches      335        0    -335     
=========================================
- Hits       140972   139879   -1093     
+ Misses      30734    30578    -156     
+ Partials      116        0    -116     

@behzadnouri behzadnouri merged commit de612c2 into solana-labs:master May 26, 2022
@behzadnouri behzadnouri deleted the shred-sig-verify branch May 26, 2022 13:06
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jun 29, 2022
sigverify_shreds relies on wire layout specs of shreds:
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L39-L46
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L298-L305

In preparation of
solana-labs#25237
which adds a new shred variant with different layout and signed message,
this commit removes shred layout specification from sigverify and
instead encapsulate that in shred module.
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jun 29, 2022
sigverify_shreds relies on wire layout specs of shreds:
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L39-L46
https://github.com/solana-labs/solana/blob/0376ab41a/ledger/src/sigverify_shreds.rs#L298-L305

In preparation of
solana-labs#25237
which adds a new shred variant with different layout and signed message,
this commit removes shred layout specification from sigverify and
instead encapsulate that in shred module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants