Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

13 changes: 7 additions & 6 deletions core/benches/shredder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use {
CODING_SHREDS_PER_FEC_BLOCK, DATA_SHREDS_PER_FEC_BLOCK,
},
solana_perf::test_tx,
solana_votor_messages::SliceRoot,
test::{black_box, Bencher},
};

Expand Down Expand Up @@ -43,7 +44,7 @@ fn bench_shredder_ticks(bencher: &mut Bencher) {
let num_ticks = max_ticks_per_n_shreds(1, Some(SHRED_SIZE_TYPICAL)) * num_shreds as u64;
let entries = create_ticks(num_ticks, 0, Hash::default());
let reed_solomon_cache = ReedSolomonCache::default();
let chained_merkle_root = Some(Hash::new_from_array(rand::thread_rng().gen()));
let chained_merkle_root = Some(SliceRoot(Hash::new_from_array(rand::thread_rng().gen())));
bencher.iter(|| {
let shredder = Shredder::new(1, 0, 0, 0).unwrap();
shredder.entries_to_merkle_shreds_for_tests(
Expand Down Expand Up @@ -71,7 +72,7 @@ fn bench_shredder_large_entries(bencher: &mut Bencher) {
Some(shred_size),
);
let entries = make_large_unchained_entries(txs_per_entry, num_entries);
let chained_merkle_root = Some(Hash::new_from_array(rand::thread_rng().gen()));
let chained_merkle_root = Some(SliceRoot(Hash::new_from_array(rand::thread_rng().gen())));
let reed_solomon_cache = ReedSolomonCache::default();
// 1Mb
bencher.iter(|| {
Expand All @@ -98,7 +99,7 @@ fn bench_deshredder(bencher: &mut Bencher) {
let num_ticks = max_ticks_per_n_shreds(1, Some(shred_size)) * num_shreds as u64;
let entries = create_ticks(num_ticks, 0, Hash::default());
let shredder = Shredder::new(1, 0, 0, 0).unwrap();
let chained_merkle_root = Some(Hash::new_from_array(rand::thread_rng().gen()));
let chained_merkle_root = Some(SliceRoot(Hash::new_from_array(rand::thread_rng().gen())));
let (data_shreds, _) = shredder.entries_to_merkle_shreds_for_tests(
&kp,
&entries,
Expand All @@ -120,7 +121,7 @@ fn bench_deshredder(bencher: &mut Bencher) {
fn bench_deserialize_hdr(bencher: &mut Bencher) {
let keypair = Keypair::new();
let shredder = Shredder::new(2, 1, 0, 0).unwrap();
let merkle_root = Some(Hash::new_from_array(rand::thread_rng().gen()));
let merkle_root = Some(SliceRoot(Hash::new_from_array(rand::thread_rng().gen())));
let mut stats = ProcessShredsStats::default();
let reed_solomon_cache = ReedSolomonCache::default();
let mut shreds = shredder
Expand Down Expand Up @@ -155,7 +156,7 @@ fn bench_shredder_coding(bencher: &mut Bencher) {
let entries = make_entries();
let shredder = Shredder::new(1, 0, 0, 0).unwrap();
let reed_solomon_cache = ReedSolomonCache::default();
let merkle_root = Some(Hash::new_from_array(rand::thread_rng().gen()));
let merkle_root = Some(SliceRoot(Hash::new_from_array(rand::thread_rng().gen())));
bencher.iter(|| {
let result: Vec<_> = shredder
.make_merkle_shreds_from_entries(
Expand All @@ -178,7 +179,7 @@ fn bench_shredder_decoding(bencher: &mut Bencher) {
let entries = make_entries();
let shredder = Shredder::new(1, 0, 0, 0).unwrap();
let reed_solomon_cache = ReedSolomonCache::default();
let merkle_root = Some(Hash::new_from_array(rand::thread_rng().gen()));
let merkle_root = Some(SliceRoot(Hash::new_from_array(rand::thread_rng().gen())));
let (_data_shreds, mut coding_shreds): (Vec<_>, Vec<_>) = shredder
.make_merkle_shreds_from_entries(
&Keypair::new(),
Expand Down
16 changes: 9 additions & 7 deletions core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use {
MAX_LOCKOUT_HISTORY,
},
},
solana_votor_messages::SliceRoot,
std::{
cmp::Ordering,
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -616,19 +617,19 @@ impl Tower {
pub fn record_bank_vote(&mut self, bank: &Bank) -> Option<Slot> {
// Returns the new root if one is made after applying a vote for the given bank to
// `self.vote_state`
let block_id = bank.block_id().unwrap_or_else(|| {
let chained_merkle_id = bank.chained_merkle_id().unwrap_or_else(|| {
// This can only happen for our leader bank
// Note: since the new shred format is yet to be rolled out to all clusters,
// this can also happen for non-leader banks. Once rolled out we can assert
// here that this is our leader bank.
Hash::default()
SliceRoot(Hash::default())
});
self.record_bank_vote_and_update_lockouts(
bank.slot(),
bank.hash(),
bank.feature_set
.is_active(&agave_feature_set::enable_tower_sync_ix::id()),
block_id,
chained_merkle_id,
)
}

Expand All @@ -638,8 +639,9 @@ impl Tower {
&mut self,
vote_hash: Hash,
enable_tower_sync_ix: bool,
block_id: Hash,
chained_merkle_id: SliceRoot,
) {
let block_id = chained_merkle_id.0;
let mut new_vote = if enable_tower_sync_ix {
VoteTransaction::from(TowerSync::new(
self.vote_state.votes.clone(),
Expand All @@ -664,7 +666,7 @@ impl Tower {
vote_slot: Slot,
vote_hash: Hash,
enable_tower_sync_ix: bool,
block_id: Hash,
chained_merkle_id: SliceRoot,
) -> Option<Slot> {
if let Some(last_voted_slot) = self.vote_state.last_voted_slot() {
if vote_slot <= last_voted_slot {
Expand All @@ -681,7 +683,7 @@ impl Tower {
let old_root = self.root();

self.vote_state.process_next_vote_slot(vote_slot);
self.update_last_vote_from_vote_state(vote_hash, enable_tower_sync_ix, block_id);
self.update_last_vote_from_vote_state(vote_hash, enable_tower_sync_ix, chained_merkle_id);

let new_root = self.root();

Expand All @@ -699,7 +701,7 @@ impl Tower {

#[cfg(feature = "dev-context-only-utils")]
pub fn record_vote(&mut self, slot: Slot, hash: Hash) -> Option<Slot> {
self.record_bank_vote_and_update_lockouts(slot, hash, true, Hash::default())
self.record_bank_vote_and_update_lockouts(slot, hash, true, SliceRoot(Hash::default()))
}

#[cfg(feature = "dev-context-only-utils")]
Expand Down
3 changes: 2 additions & 1 deletion core/src/repair/repair_weighted_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub mod test {
shred::{ProcessShredsStats, ReedSolomonCache, Shred, Shredder},
},
solana_runtime::bank_utils,
solana_votor_messages::SliceRoot,
trees::tr,
};

Expand Down Expand Up @@ -293,7 +294,7 @@ pub mod test {
&keypair,
&[],
true,
Some(Hash::default()),
Some(SliceRoot(Hash::default())),
last_shred as u32,
last_shred as u32,
&reed_solomon_cache,
Expand Down
5 changes: 3 additions & 2 deletions core/src/repair/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ mod tests {
solana_runtime::bank::Bank,
solana_streamer::socket::SocketAddrSpace,
solana_time_utils::timestamp,
solana_votor_messages::SliceRoot,
std::{io::Cursor, net::Ipv4Addr},
};

Expand Down Expand Up @@ -2035,7 +2036,7 @@ mod tests {
&keypair,
&[],
true,
Some(Hash::default()),
Some(SliceRoot(Hash::default())),
index as u32,
index as u32,
&reed_solomon_cache,
Expand Down Expand Up @@ -2516,7 +2517,7 @@ mod tests {
&keypair,
&[],
true,
Some(Hash::default()),
Some(SliceRoot(Hash::default())),
0,
0,
&reed_solomon_cache,
Expand Down
4 changes: 2 additions & 2 deletions core/src/repair/standard_repair_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ impl StandardRepairHandler {

let get_parent_location_meta = |(location, meta): &(BlockLocation, SlotMeta)| {
let parent_slot = meta.parent_slot?;
let parent_block_id = self
let parent_chained_merkle_id = self
.blockstore
.get_parent_block_id_from_location(meta.slot, *location)
.ok()??;
let parent_location = self
.blockstore
.get_block_location(parent_slot, parent_block_id)
.get_block_location(parent_slot, parent_chained_merkle_id.0)
.ok()??;
let parent_meta = self
.blockstore
Expand Down
19 changes: 10 additions & 9 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ use {
voting_utils::GenerateVoteTxResult,
votor::{LeaderWindowNotifier, Votor, VotorConfig},
},
solana_votor_messages::consensus_message::ConsensusMessage,
solana_votor_messages::{consensus_message::ConsensusMessage, SliceRoot},
std::{
collections::{HashMap, HashSet},
num::{NonZeroUsize, Saturating},
Expand Down Expand Up @@ -3471,8 +3471,8 @@ impl ReplayStage {
}
};

if bank.block_id().is_none() {
bank.set_block_id(block_id);
if bank.chained_merkle_id().is_none() {
bank.set_chained_merkle_id(block_id);
}

let r_replay_stats = replay_stats.read().unwrap();
Expand Down Expand Up @@ -3579,7 +3579,7 @@ impl ReplayStage {
// 2) Shredding finishes before replay, we notify here
//
// For non leader banks (2) is always true, so notify here
if *is_alpenglow_migration_complete && bank.block_id().is_some() {
if *is_alpenglow_migration_complete && bank.chained_merkle_id().is_some() {
// Leader blocks will not have a block id, broadcast stage will
// take care of notifying the voting loop
let _ = votor_event_sender.send(VotorEvent::Block(CompletedBlock {
Expand Down Expand Up @@ -3953,7 +3953,7 @@ impl ReplayStage {
// we must have the compatible versions of both duplicates in order to replay `bank`
// successfully, so we are once again guaranteed that `bank_vote_state.last_voted_slot()`
// is present in bank forks and progress map.
let block_id = {
let chained_merkle_id = {
// The block_id here will only be relevant if we need to refresh this last vote.
let bank = bank_forks
.read()
Expand All @@ -3964,15 +3964,16 @@ impl ReplayStage {
// that means that it was created from a different instance (hot spare setup or a previous restart),
// and thus we must have replayed and set the block_id from the shreds.
// Note: since the new shred format is not rolled out everywhere, we have to provide a default
bank.block_id().unwrap_or_default()
bank.chained_merkle_id()
.unwrap_or(SliceRoot(Hash::default()))
};
tower.update_last_vote_from_vote_state(
progress
.get_hash(last_voted_slot)
.expect("Must exist for us to have frozen descendant"),
bank.feature_set
.is_active(&agave_feature_set::enable_tower_sync_ix::id()),
block_id,
chained_merkle_id,
);
// Since we are updating our tower we need to update associated caches for previously computed
// slots as well.
Expand Down Expand Up @@ -4682,7 +4683,7 @@ pub(crate) mod tests {
slot: Slot,
) -> Arc<Bank> {
let bank = Bank::new_from_parent(parent, collector_id, slot);
bank.set_block_id(Some(Hash::new_unique()));
bank.set_chained_merkle_id(Some(SliceRoot(Hash::new_unique())));
bank_forks
.write()
.unwrap()
Expand Down Expand Up @@ -5295,7 +5296,7 @@ pub(crate) mod tests {
&keypair,
&gibberish,
true,
Some(Hash::default()),
Some(SliceRoot(Hash::default())),
0,
0,
&reed_solomon_cache,
Expand Down
5 changes: 3 additions & 2 deletions core/src/vote_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use {
solana_signer::Signer,
solana_vote::vote_transaction,
solana_vote_program::vote_state::{Lockout, TowerSync},
solana_votor_messages::SliceRoot,
std::{
collections::{HashMap, HashSet, VecDeque},
sync::{Arc, RwLock},
Expand Down Expand Up @@ -151,7 +152,7 @@ impl VoteSimulator {

new_bank.fill_bank_with_ticks_for_tests();
if !visit.node().has_no_child() || is_frozen {
new_bank.set_block_id(Some(Hash::new_unique()));
new_bank.set_chained_merkle_id(Some(SliceRoot(Hash::new_unique())));
new_bank.freeze();
self.progress
.get_fork_stats_mut(new_bank.slot())
Expand Down Expand Up @@ -395,7 +396,7 @@ pub fn initialize_state(

genesis_config.poh_config.hashes_per_tick = Some(2);
let (bank0, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
bank0.set_block_id(Some(Hash::new_unique()));
bank0.set_chained_merkle_id(Some(SliceRoot(Hash::new_unique())));

for pubkey in validator_keypairs_map.keys() {
bank0.transfer(10_000, &mint_keypair, pubkey).unwrap();
Expand Down
3 changes: 2 additions & 1 deletion core/src/window_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ mod test {
solana_signer::Signer,
solana_streamer::socket::SocketAddrSpace,
solana_time_utils::timestamp,
solana_votor_messages::SliceRoot,
};

fn local_entries_to_shred(
Expand All @@ -494,7 +495,7 @@ mod test {
entries,
true, // is_last_in_slot
// chained_merkle_root
Some(Hash::new_from_array(rand::thread_rng().gen())),
Some(SliceRoot(Hash::new_from_array(rand::thread_rng().gen()))),
0, // next_shred_index
0, // next_code_index
&ReedSolomonCache::default(),
Expand Down
1 change: 1 addition & 0 deletions gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ solana-transaction = "=3.0.1"
solana-version = { workspace = true }
solana-vote = { workspace = true }
solana-vote-program = { workspace = true }
solana-votor-messages = { workspace = true }
static_assertions = { workspace = true }
thiserror = { workspace = true }

Expand Down
3 changes: 2 additions & 1 deletion gossip/src/duplicate_shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ pub(crate) mod tests {
solana_signature::Signature,
solana_signer::Signer,
solana_system_transaction::transfer,
solana_votor_messages::SliceRoot,
std::sync::Arc,
};

Expand Down Expand Up @@ -457,7 +458,7 @@ pub(crate) mod tests {
&entries,
is_last_in_slot,
// chained_merkle_root
Some(Hash::new_from_array(rng.gen())),
Some(SliceRoot(Hash::new_from_array(rng.gen()))),
next_shred_index,
next_code_index, // next_code_index
&ReedSolomonCache::default(),
Expand Down
1 change: 1 addition & 0 deletions ledger-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ solana-unified-scheduler-pool = { workspace = true }
solana-version = { workspace = true }
solana-vote = { workspace = true }
solana-vote-program = { workspace = true }
solana-votor-messages = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"] }

Expand Down
5 changes: 3 additions & 2 deletions ledger-tool/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use {
UiTransactionEncoding, VersionedConfirmedBlock, VersionedConfirmedBlockWithEntries,
VersionedTransactionWithStatusMeta,
},
solana_votor_messages::SliceRoot,
std::{
cell::RefCell,
collections::HashMap,
Expand Down Expand Up @@ -360,8 +361,8 @@ pub struct CliDuplicateShred {
index: u32,
shred_type: ShredType,
version: u16,
merkle_root: Option<Hash>,
chained_merkle_root: Option<Hash>,
merkle_root: Option<SliceRoot>,
chained_merkle_root: Option<SliceRoot>,
last_in_slot: bool,
#[serde(with = "serde_bytes")]
payload: Vec<u8>,
Expand Down
Loading