-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
verifies shred-version in fetch stage #26070
verifies shred-version in fetch stage #26070
Conversation
} else if shred.version() != shred_version { | ||
inc_new_counter_debug!("streamer-recv_window-incorrect_shred_version", 1); | ||
false | ||
} else if shred.index() >= MAX_DATA_SHREDS_PER_SLOT as u32 { | ||
inc_new_counter_warn!("streamer-recv_window-shred_index_overrun", 1); | ||
false | ||
} else if shred.sanitize().is_err() { | ||
inc_new_counter_warn!("streamer-recv_window-invalid-shred", 1); | ||
false |
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.
} else if shred.version() != shred_version {
moved earlier in the pipeline in the shred-fetch stage.
} else if shred.index() >= MAX_DATA_SHREDS_PER_SLOT as u32 {
is already checked in shred.sanitize()
.
} else if shred.sanitize().is_err() {
shreds are already sanitized when de-serialized.
7f43a18
to
2b50afc
Compare
@@ -187,15 +186,6 @@ pub(crate) fn should_retransmit_and_persist( | |||
} else if !verify_shred_slot(shred, root) { | |||
inc_new_counter_debug!("streamer-recv_window-outdated_transmission", 1); | |||
false |
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 follow up with moving this to fetch-stage as well.
Shred versions are not verified until window-service where resources are already wasted to sig-verify and deserialize shreds. The commit verifies shred-version earlier in the pipeline in fetch stage.
84b006b
to
0adb8ed
Compare
... in favor of just passing packet flags.
0adb8ed
to
dc57aef
Compare
stats.shred_version_mismatch += 1; | ||
return true; | ||
} | ||
let hash = packet_hasher.hash_packet(packet); | ||
match shreds_received.put(hash, ()) { | ||
None => false, | ||
Some(()) => { | ||
stats.duplicate_shred += 1; |
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.
Should we be using checked math here?
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 just moved the old code here.
I don't think we can ingest usize::max
packets in one or two seconds anyways, but nonetheless I will revisit this in follow up changes.
solana-labs#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit.
solana-labs#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit.
solana-labs#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit.
solana-labs#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit.
solana-labs#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit.
#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit.
#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit. (cherry picked from commit 06a8419)
#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit. (cherry picked from commit 06a8419)
reduces MAX_CODE_SHREDS_PER_SLOT (#30543) #26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit. (cherry picked from commit 06a8419) Co-authored-by: behzad nouri <behzadnouri@gmail.com>
reduces MAX_CODE_SHREDS_PER_SLOT (#30543) #26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit. (cherry picked from commit 06a8419) Co-authored-by: behzad nouri <behzadnouri@gmail.com>
solana-labs#26070 introduced MAX_CODE_SHREDS_PER_SLOT which because of how coding shreds are generated was later set larger than MAX_DATA_SHREDS_PER_SLOT. The old code was discarding: index >= MAX_DATA_SHREDS_PER_SLOT regardless of if the shred is code or data: https://github.com/solana-labs/solana/blob/v1.13.6/core/src/window_service.rs#L193-L195 Since that many code (or data) shreds will probably never result in a rooted slot anyways, the commit reduces MAX_CODE_SHREDS_PER_SLOT to what previously was the effective limit.
Problem
Shred versions are not verified until window-service where resources are
already wasted to sig-verify and deserialize shreds.
Summary of Changes
The commit verifies shred-version earlier in the pipeline in fetch stage.