Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: solana-labs/solana
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8a837d0a8c25edbc5aeab30ab8a82cce7beccbc1
Choose a base ref
..
head repository: solana-labs/solana
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c90a97046d756a0a46503de3889ad9f2480ae47f
Choose a head ref
Showing with 10 additions and 33 deletions.
  1. +1 −1 ledger/Cargo.toml
  2. +6 −31 ledger/src/blockstore.rs
  3. +2 −1 ledger/src/shred/merkle.rs
  4. +1 −0 programs/bpf/Cargo.lock
2 changes: 1 addition & 1 deletion ledger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ documentation = "https://docs.rs/solana-ledger"
edition = "2021"

[dependencies]
assert_matches = "1.5.0"
bincode = "1.3.3"
bitflags = "1.3.1"
byteorder = "1.4.3"
@@ -68,7 +69,6 @@ default-features = false
features = ["lz4"]

[dev-dependencies]
assert_matches = "1.5.0"
bs58 = "0.4.0"
matches = "0.1.9"
solana-account-decoder = { path = "../account-decoder", version = "=1.15.0" }
37 changes: 6 additions & 31 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ use {
},
slot_stats::{ShredSource, SlotsStats},
},
assert_matches::debug_assert_matches,
bincode::deserialize,
crossbeam_channel::{bounded, Receiver, Sender, TrySendError},
dashmap::DashSet,
@@ -1369,7 +1370,8 @@ impl Blockstore {
}

fn should_insert_coding_shred(shred: &Shred, last_root: &RwLock<u64>) -> bool {
shred.is_code() && shred.sanitize().is_ok() && shred.slot() > *last_root.read().unwrap()
debug_assert_matches!(shred.sanitize(), Ok(()));
shred.is_code() && shred.slot() > *last_root.read().unwrap()
}

fn insert_coding_shred(
@@ -1383,7 +1385,8 @@ impl Blockstore {

// Assert guaranteed by integrity checks on the shred that happen before
// `insert_coding_shred` is called
assert!(shred.is_code() && shred.sanitize().is_ok());
debug_assert_matches!(shred.sanitize(), Ok(()));
assert!(shred.is_code());

// Commit step: commit all changes to the mutable structures at once, or none at all.
// We don't want only a subset of these changes going through.
@@ -1432,23 +1435,7 @@ impl Blockstore {
} else {
false
};
if let Err(err) = shred.sanitize() {
let leader_pubkey = leader_schedule
.and_then(|leader_schedule| leader_schedule.slot_leader_at(slot, None));

datapoint_error!(
"blockstore_error",
(
"error",
format!(
"Leader {:?}, slot {}: received invalid shred: {:?}",
leader_pubkey, slot, err,
),
String
)
);
return false;
}
debug_assert_matches!(shred.sanitize(), Ok(()));
// Check that we do not receive shred_index >= than the last_index
// for the slot
let last_index = slot_meta.last_index;
@@ -6322,18 +6309,6 @@ pub mod tests {
&last_root
));

// Trying to insert a shred with index < position should fail
{
let mut coding_shred = coding_shred.clone();
let index = coding_shred.index() - coding_shred.fec_set_index() - 1;
coding_shred.set_index(index as u32);

assert!(!Blockstore::should_insert_coding_shred(
&coding_shred,
&last_root
));
}

// Trying to insert value into slot <= than last root should fail
{
let mut coding_shred = coding_shred.clone();
3 changes: 2 additions & 1 deletion ledger/src/shred/merkle.rs
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ use {
},
shredder::{self, ReedSolomonCache},
},
assert_matches::debug_assert_matches,
itertools::Itertools,
rayon::{prelude::*, ThreadPool},
reed_solomon_erasure::Error::{InvalidIndex, TooFewParityShards, TooFewShards},
@@ -1007,7 +1008,7 @@ fn make_erasure_batch(
shred.set_merkle_branch(merkle_branch)?;
shred.set_signature(signature);
debug_assert!(shred.verify(&keypair.pubkey()));
debug_assert!(shred.sanitize().is_ok());
debug_assert_matches!(shred.sanitize(), Ok(()));
// Assert that shred payload is fully populated.
debug_assert_eq!(shred, {
let shred = shred.payload().clone();
1 change: 1 addition & 0 deletions programs/bpf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.