Save RNG for generating random storage sampling offsets (#4450)
* Save RNG for generating random storage sampling offsets * fix clippy * fix stable-perf * fix chacha
This commit is contained in:
@ -22,6 +22,7 @@ pub enum StorageInstruction {
|
||||
sha_state: Hash,
|
||||
slot: u64,
|
||||
signature: Signature,
|
||||
proof_index: u64,
|
||||
},
|
||||
AdvertiseStorageRecentBlockhash {
|
||||
hash: Hash,
|
||||
@ -109,11 +110,13 @@ pub fn mining_proof(
|
||||
sha_state: Hash,
|
||||
slot: u64,
|
||||
signature: Signature,
|
||||
proof_index: u64,
|
||||
) -> Instruction {
|
||||
let storage_instruction = StorageInstruction::SubmitMiningProof {
|
||||
sha_state,
|
||||
slot,
|
||||
signature,
|
||||
proof_index,
|
||||
};
|
||||
let account_metas = vec![AccountMeta::new(*storage_pubkey, true)];
|
||||
Instruction::new(id(), &storage_instruction, account_metas)
|
||||
|
@ -43,6 +43,7 @@ pub fn process_instruction(
|
||||
sha_state,
|
||||
slot,
|
||||
signature,
|
||||
..
|
||||
} => {
|
||||
if me_unsigned || !rest.is_empty() {
|
||||
// This instruction must be signed by `me`
|
||||
@ -154,6 +155,7 @@ mod tests {
|
||||
Hash::default(),
|
||||
SLOTS_PER_SEGMENT,
|
||||
Signature::default(),
|
||||
0,
|
||||
);
|
||||
// the proof is for slot 16, which is in segment 0, need to move the tick height into segment 2
|
||||
let ticks_till_next_segment = TICKS_IN_SEGMENT * 2;
|
||||
@ -197,7 +199,7 @@ mod tests {
|
||||
let mut accounts = [Account::default()];
|
||||
|
||||
let ix =
|
||||
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default());
|
||||
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default(), 0);
|
||||
// move tick height into segment 1
|
||||
let ticks_till_next_segment = TICKS_IN_SEGMENT + 1;
|
||||
|
||||
@ -217,7 +219,7 @@ mod tests {
|
||||
accounts[1].data.resize(STORAGE_ACCOUNT_SPACE as usize, 0);
|
||||
|
||||
let ix =
|
||||
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default());
|
||||
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default(), 0);
|
||||
|
||||
// submitting a proof for a slot in the past, so this should fail
|
||||
assert!(test_instruction(&ix, &mut accounts, 0).is_err());
|
||||
@ -235,7 +237,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let ix =
|
||||
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default());
|
||||
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default(), 0);
|
||||
// move tick height into segment 1
|
||||
let ticks_till_next_segment = TICKS_IN_SEGMENT + 1;
|
||||
|
||||
@ -493,6 +495,7 @@ mod tests {
|
||||
sha_state,
|
||||
slot,
|
||||
Signature::default(),
|
||||
0,
|
||||
)],
|
||||
Some(&mint_keypair.pubkey()),
|
||||
);
|
||||
@ -586,6 +589,7 @@ mod tests {
|
||||
Hash::default(),
|
||||
slot,
|
||||
Signature::default(),
|
||||
0,
|
||||
)],
|
||||
Some(&mint_pubkey),
|
||||
);
|
||||
|
Reference in New Issue
Block a user