discards serialized gossip crds votes if cannot parse tx (#22129)

This commit is contained in:
behzad nouri
2021-12-29 19:31:26 +00:00
committed by GitHub
parent b1d9a2e60e
commit c9c78622a8
6 changed files with 53 additions and 51 deletions

View File

@@ -1,5 +1,7 @@
use {
rand::{CryptoRng, Rng, RngCore},
solana_sdk::{
clock::Slot,
hash::Hash,
instruction::CompiledInstruction,
signature::{Keypair, Signer},
@@ -50,15 +52,21 @@ pub fn test_multisig_tx() -> Transaction {
)
}
pub fn vote_tx() -> Transaction {
let keypair = Keypair::new();
pub fn new_test_vote_tx<R>(rng: &mut R) -> Transaction
where
R: CryptoRng + RngCore,
{
let mut slots: Vec<Slot> = std::iter::repeat_with(|| rng.gen()).take(5).collect();
slots.sort_unstable();
slots.dedup();
let switch_proof_hash = rng.gen_bool(0.5).then(|| solana_sdk::hash::new_rand(rng));
vote_transaction::new_vote_transaction(
vec![2],
Hash::default(),
Hash::default(),
&keypair,
&keypair,
&keypair,
None,
slots,
solana_sdk::hash::new_rand(rng), // bank_hash
solana_sdk::hash::new_rand(rng), // blockhash
&Keypair::generate(rng), // node_keypair
&Keypair::generate(rng), // vote_keypair
&Keypair::generate(rng), // authorized_voter_keypair
switch_proof_hash,
)
}