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

Update replicators to use a blockhash to generate offsets #4712

Merged
merged 1 commit into from
Jun 17, 2019
Merged
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
2 changes: 1 addition & 1 deletion core/src/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl Replicator {
use rand_chacha::ChaChaRng;

let mut rng_seed = [0u8; 32];
rng_seed.copy_from_slice(&self.signature.to_bytes()[0..32]);
rng_seed.copy_from_slice(&self.blockhash.as_ref());
let mut rng = ChaChaRng::from_seed(rng_seed);
for _ in 0..NUM_STORAGE_SAMPLES {
self.sampling_offsets
Expand Down
17 changes: 7 additions & 10 deletions core/src/storage_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl StorageStage {
Ok(())
}

fn process_entry_crossing(
fn process_turn(
storage_keypair: &Arc<Keypair>,
state: &Arc<RwLock<StorageStateInner>>,
_blocktree: &Arc<Blocktree>,
Expand Down Expand Up @@ -428,7 +428,7 @@ impl StorageStage {
Ok(())
}

fn process_replicator_storage(
fn collect_proofs(
slot: u64,
account_id: Pubkey,
account: Account,
Expand All @@ -441,6 +441,7 @@ impl StorageStage {
if let Some(proofs) = proofs.get(&segment) {
for proof in proofs.iter() {
{
// TODO do this only once per account and segment? and maybe do it somewhere else
debug!(
"generating storage_keys from storage txs current_key_idx: {}",
*current_key_idx
Expand All @@ -453,11 +454,8 @@ impl StorageStage {
}

let mut statew = storage_state.write().unwrap();
let max_segment_index = get_segment_from_slot(slot);
if statew.replicator_map.len() < max_segment_index {
statew
.replicator_map
.resize(max_segment_index, HashMap::new());
if statew.replicator_map.len() < segment {
statew.replicator_map.resize(segment, HashMap::new());
}
let proof_segment_index = proof.segment_index;
if proof_segment_index < statew.replicator_map.len() {
Expand Down Expand Up @@ -503,7 +501,7 @@ impl StorageStage {
// find proofs, and use them to update
// the storage_keys with their signatures
for (account_id, account) in replicator_accounts.into_iter() {
Self::process_replicator_storage(
Self::collect_proofs(
bank.slot(),
account_id,
account,
Expand All @@ -513,8 +511,7 @@ impl StorageStage {
}

// TODO un-ignore this result and be sure to drain all pending proofs
//process a "crossing"
let _ignored = Self::process_entry_crossing(
let _ignored = Self::process_turn(
&storage_keypair,
&storage_state,
&blocktree,
Expand Down