Update replicators to use the storage blockhash to generate offsets (#4712)
This commit is contained in:
parent
d86358eedc
commit
8fbf0e2d9f
|
@ -437,7 +437,7 @@ impl Replicator {
|
||||||
use rand_chacha::ChaChaRng;
|
use rand_chacha::ChaChaRng;
|
||||||
|
|
||||||
let mut rng_seed = [0u8; 32];
|
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);
|
let mut rng = ChaChaRng::from_seed(rng_seed);
|
||||||
for _ in 0..NUM_STORAGE_SAMPLES {
|
for _ in 0..NUM_STORAGE_SAMPLES {
|
||||||
self.sampling_offsets
|
self.sampling_offsets
|
||||||
|
|
|
@ -350,7 +350,7 @@ impl StorageStage {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_entry_crossing(
|
fn process_turn(
|
||||||
storage_keypair: &Arc<Keypair>,
|
storage_keypair: &Arc<Keypair>,
|
||||||
state: &Arc<RwLock<StorageStateInner>>,
|
state: &Arc<RwLock<StorageStateInner>>,
|
||||||
_blocktree: &Arc<Blocktree>,
|
_blocktree: &Arc<Blocktree>,
|
||||||
|
@ -428,7 +428,7 @@ impl StorageStage {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_replicator_storage(
|
fn collect_proofs(
|
||||||
slot: u64,
|
slot: u64,
|
||||||
account_id: Pubkey,
|
account_id: Pubkey,
|
||||||
account: Account,
|
account: Account,
|
||||||
|
@ -441,6 +441,7 @@ impl StorageStage {
|
||||||
if let Some(proofs) = proofs.get(&segment) {
|
if let Some(proofs) = proofs.get(&segment) {
|
||||||
for proof in proofs.iter() {
|
for proof in proofs.iter() {
|
||||||
{
|
{
|
||||||
|
// TODO do this only once per account and segment? and maybe do it somewhere else
|
||||||
debug!(
|
debug!(
|
||||||
"generating storage_keys from storage txs current_key_idx: {}",
|
"generating storage_keys from storage txs current_key_idx: {}",
|
||||||
*current_key_idx
|
*current_key_idx
|
||||||
|
@ -453,11 +454,8 @@ impl StorageStage {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut statew = storage_state.write().unwrap();
|
let mut statew = storage_state.write().unwrap();
|
||||||
let max_segment_index = get_segment_from_slot(slot);
|
if statew.replicator_map.len() < segment {
|
||||||
if statew.replicator_map.len() < max_segment_index {
|
statew.replicator_map.resize(segment, HashMap::new());
|
||||||
statew
|
|
||||||
.replicator_map
|
|
||||||
.resize(max_segment_index, HashMap::new());
|
|
||||||
}
|
}
|
||||||
let proof_segment_index = proof.segment_index;
|
let proof_segment_index = proof.segment_index;
|
||||||
if proof_segment_index < statew.replicator_map.len() {
|
if proof_segment_index < statew.replicator_map.len() {
|
||||||
|
@ -503,7 +501,7 @@ impl StorageStage {
|
||||||
// find proofs, and use them to update
|
// find proofs, and use them to update
|
||||||
// the storage_keys with their signatures
|
// the storage_keys with their signatures
|
||||||
for (account_id, account) in replicator_accounts.into_iter() {
|
for (account_id, account) in replicator_accounts.into_iter() {
|
||||||
Self::process_replicator_storage(
|
Self::collect_proofs(
|
||||||
bank.slot(),
|
bank.slot(),
|
||||||
account_id,
|
account_id,
|
||||||
account,
|
account,
|
||||||
|
@ -513,8 +511,7 @@ impl StorageStage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO un-ignore this result and be sure to drain all pending proofs
|
// TODO un-ignore this result and be sure to drain all pending proofs
|
||||||
//process a "crossing"
|
let _ignored = Self::process_turn(
|
||||||
let _ignored = Self::process_entry_crossing(
|
|
||||||
&storage_keypair,
|
&storage_keypair,
|
||||||
&storage_state,
|
&storage_state,
|
||||||
&blocktree,
|
&blocktree,
|
||||||
|
|
Loading…
Reference in New Issue