Add updated duplicate broadcast test (#18506)

This commit is contained in:
carllin
2021-07-10 22:22:07 -07:00
committed by GitHub
parent 899b09872b
commit 175083c4c1
6 changed files with 484 additions and 310 deletions

View File

@ -8,7 +8,11 @@ use rayon::prelude::*;
use solana_client::thin_client::create_client;
use solana_core::consensus::VOTE_THRESHOLD_DEPTH;
use solana_gossip::{
cluster_info::VALIDATOR_PORT_RANGE, contact_info::ContactInfo, gossip_service::discover_cluster,
cluster_info::{self, VALIDATOR_PORT_RANGE},
contact_info::ContactInfo,
crds_value::{self, CrdsData, CrdsValue},
gossip_error::GossipError,
gossip_service::discover_cluster,
};
use solana_ledger::{
blockstore::Blockstore,
@ -25,11 +29,13 @@ use solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
system_transaction,
timing::duration_as_ms,
timing::{duration_as_ms, timestamp},
transport::TransportError,
};
use solana_vote_program::vote_transaction;
use std::{
collections::{HashMap, HashSet},
net::SocketAddr,
path::Path,
sync::{Arc, RwLock},
thread::sleep,
@ -406,3 +412,34 @@ fn verify_slot_ticks(
}
entries.last().unwrap().hash
}
pub fn submit_vote_to_cluster_gossip(
node_keypair: &Keypair,
vote_keypair: &Keypair,
vote_slot: Slot,
vote_hash: Hash,
blockhash: Hash,
gossip_addr: SocketAddr,
) -> Result<(), GossipError> {
let vote_tx = vote_transaction::new_vote_transaction(
vec![vote_slot],
vote_hash,
blockhash,
node_keypair,
vote_keypair,
vote_keypair,
None,
);
cluster_info::push_messages_to_peer(
vec![CrdsValue::new_signed(
CrdsData::Vote(
0,
crds_value::Vote::new(node_keypair.pubkey(), vote_tx, timestamp()),
),
node_keypair,
)],
node_keypair.pubkey(),
gossip_addr,
)
}