plumb staking_account and voting_keypair from multinode-demo to Vote (#3199)
* plumb staking_account and voting_keypair from bash to Vote
This commit is contained in:
committed by
Greg Fitzgerald
parent
c8c85ff93b
commit
0acdbc0d03
@ -596,7 +596,7 @@ mod tests {
|
||||
let one = hash(&zero.as_ref());
|
||||
let keypair = Keypair::new();
|
||||
let vote_account = Keypair::new();
|
||||
let tx0 = VoteTransaction::new_vote(&vote_account, 1, one, 1);
|
||||
let tx0 = VoteTransaction::new_vote(vote_account.pubkey(), &vote_account, 1, one, 1);
|
||||
let tx1 = BudgetTransaction::new_timestamp(
|
||||
&keypair,
|
||||
keypair.pubkey(),
|
||||
@ -644,7 +644,8 @@ mod tests {
|
||||
let next_hash = solana_sdk::hash::hash(&hash.as_ref());
|
||||
let keypair = Keypair::new();
|
||||
let vote_account = Keypair::new();
|
||||
let tx_small = VoteTransaction::new_vote(&vote_account, 1, next_hash, 2);
|
||||
let tx_small =
|
||||
VoteTransaction::new_vote(vote_account.pubkey(), &vote_account, 1, next_hash, 2);
|
||||
let tx_large = BudgetTransaction::new_payment(&keypair, keypair.pubkey(), 1, next_hash, 0);
|
||||
|
||||
let tx_small_size = tx_small.serialized_size().unwrap() as usize;
|
||||
|
@ -80,6 +80,7 @@ impl Fullnode {
|
||||
mut node: Node,
|
||||
keypair: &Arc<Keypair>,
|
||||
ledger_path: &str,
|
||||
vote_account: Pubkey,
|
||||
voting_keypair: T,
|
||||
entrypoint_info_option: Option<&NodeInfo>,
|
||||
config: &FullnodeConfig,
|
||||
@ -182,7 +183,7 @@ impl Fullnode {
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let voting_keypair_option = if config.voting_disabled {
|
||||
let voting_keypair = if config.voting_disabled {
|
||||
None
|
||||
} else {
|
||||
Some(Arc::new(voting_keypair))
|
||||
@ -190,7 +191,8 @@ impl Fullnode {
|
||||
|
||||
// Setup channel for rotation indications
|
||||
let tvu = Tvu::new(
|
||||
voting_keypair_option,
|
||||
vote_account,
|
||||
voting_keypair,
|
||||
&bank_forks,
|
||||
&bank_forks_info,
|
||||
&cluster_info,
|
||||
@ -344,7 +346,13 @@ pub fn make_active_set_entries(
|
||||
let new_vote_account_entry = next_entry_mut(&mut last_entry_hash, 1, vec![new_vote_account_tx]);
|
||||
|
||||
// 3) Create vote entry
|
||||
let vote_tx = VoteTransaction::new_vote(&voting_keypair, slot_to_vote_on, *blockhash, 0);
|
||||
let vote_tx = VoteTransaction::new_vote(
|
||||
voting_keypair.pubkey(),
|
||||
&voting_keypair,
|
||||
slot_to_vote_on,
|
||||
*blockhash,
|
||||
0,
|
||||
);
|
||||
let vote_entry = next_entry_mut(&mut last_entry_hash, 1, vec![vote_tx]);
|
||||
|
||||
// 4) Create `num_ending_ticks` empty ticks
|
||||
@ -372,11 +380,13 @@ mod tests {
|
||||
GenesisBlock::new_with_leader(10_000, leader_keypair.pubkey(), 1000);
|
||||
let (validator_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
|
||||
|
||||
let voting_keypair = Keypair::new();
|
||||
let validator = Fullnode::new(
|
||||
validator_node,
|
||||
&Arc::new(validator_keypair),
|
||||
&validator_ledger_path,
|
||||
Keypair::new(),
|
||||
voting_keypair.pubkey(),
|
||||
voting_keypair,
|
||||
Some(&leader_node.info),
|
||||
&FullnodeConfig::default(),
|
||||
);
|
||||
@ -398,11 +408,13 @@ mod tests {
|
||||
GenesisBlock::new_with_leader(10_000, leader_keypair.pubkey(), 1000);
|
||||
let (validator_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
|
||||
ledger_paths.push(validator_ledger_path.clone());
|
||||
let voting_keypair = Keypair::new();
|
||||
Fullnode::new(
|
||||
validator_node,
|
||||
&Arc::new(validator_keypair),
|
||||
&validator_ledger_path,
|
||||
Keypair::new(),
|
||||
voting_keypair.pubkey(),
|
||||
voting_keypair,
|
||||
Some(&leader_node.info),
|
||||
&FullnodeConfig::default(),
|
||||
)
|
||||
|
@ -172,7 +172,8 @@ mod tests {
|
||||
|
||||
// Get another validator to vote, so we now have 2/3 consensus
|
||||
let voting_keypair = &vote_accounts[7].0;
|
||||
let vote_tx = VoteTransaction::new_vote(voting_keypair, 7, blockhash, 0);
|
||||
let vote_tx =
|
||||
VoteTransaction::new_vote(voting_keypair.pubkey(), voting_keypair, 7, blockhash, 0);
|
||||
bank.process_transaction(&vote_tx).unwrap();
|
||||
|
||||
LeaderConfirmationService::compute_confirmation(&bank, &mut last_confirmation_time);
|
||||
|
@ -52,6 +52,7 @@ impl LocalCluster {
|
||||
leader_node,
|
||||
&leader_keypair,
|
||||
&leader_ledger_path,
|
||||
voting_keypair.pubkey(),
|
||||
voting_keypair,
|
||||
None,
|
||||
fullnode_config,
|
||||
@ -87,6 +88,7 @@ impl LocalCluster {
|
||||
validator_node,
|
||||
&validator_keypair,
|
||||
&ledger_path,
|
||||
voting_keypair.pubkey(),
|
||||
voting_keypair,
|
||||
Some(&leader_node_info),
|
||||
fullnode_config,
|
||||
|
@ -54,6 +54,7 @@ impl ReplayStage {
|
||||
#[allow(clippy::new_ret_no_self, clippy::too_many_arguments)]
|
||||
pub fn new<T>(
|
||||
my_id: Pubkey,
|
||||
vote_account: Pubkey,
|
||||
voting_keypair: Option<Arc<T>>,
|
||||
blocktree: Arc<Blocktree>,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
@ -131,6 +132,7 @@ impl ReplayStage {
|
||||
if let Some(ref voting_keypair) = voting_keypair {
|
||||
let keypair = voting_keypair.as_ref();
|
||||
let vote = VoteTransaction::new_vote(
|
||||
vote_account,
|
||||
keypair,
|
||||
*latest_slot_vote,
|
||||
parent.last_blockhash(),
|
||||
@ -387,6 +389,7 @@ mod test {
|
||||
let (exit, poh_recorder, poh_service, _entry_receiver) = create_test_recorder(&bank);
|
||||
let (replay_stage, _slot_full_receiver, ledger_writer_recv) = ReplayStage::new(
|
||||
my_keypair.pubkey(),
|
||||
voting_keypair.pubkey(),
|
||||
Some(voting_keypair.clone()),
|
||||
blocktree.clone(),
|
||||
&Arc::new(RwLock::new(bank_forks)),
|
||||
@ -398,7 +401,8 @@ mod test {
|
||||
);
|
||||
|
||||
let keypair = voting_keypair.as_ref();
|
||||
let vote = VoteTransaction::new_vote(keypair, 0, bank.last_blockhash(), 0);
|
||||
let vote =
|
||||
VoteTransaction::new_vote(keypair.pubkey(), keypair, 0, bank.last_blockhash(), 0);
|
||||
cluster_info_me.write().unwrap().push_vote(vote);
|
||||
|
||||
info!("Send ReplayStage an entry, should see it on the ledger writer receiver");
|
||||
|
@ -597,7 +597,8 @@ mod tests {
|
||||
}
|
||||
let mut vote_txs: Vec<_> = Vec::new();
|
||||
let keypair = Keypair::new();
|
||||
let vote_tx = VoteTransaction::new_vote(&keypair, 123456, Hash::default(), 1);
|
||||
let vote_tx =
|
||||
VoteTransaction::new_vote(keypair.pubkey(), &keypair, 123456, Hash::default(), 1);
|
||||
vote_txs.push(vote_tx);
|
||||
let vote_entries = vec![Entry::new(&Hash::default(), 1, vote_txs)];
|
||||
storage_entry_sender.send(vote_entries).unwrap();
|
||||
|
@ -431,6 +431,7 @@ pub fn new_fullnode() -> (Fullnode, NodeInfo, Keypair, String) {
|
||||
node,
|
||||
&node_keypair,
|
||||
&ledger_path,
|
||||
voting_keypair.pubkey(),
|
||||
voting_keypair,
|
||||
None,
|
||||
&FullnodeConfig::default(),
|
||||
|
@ -24,6 +24,7 @@ use crate::retransmit_stage::RetransmitStage;
|
||||
use crate::rpc_subscriptions::RpcSubscriptions;
|
||||
use crate::service::Service;
|
||||
use crate::storage_stage::{StorageStage, StorageState};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use std::net::UdpSocket;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
@ -54,6 +55,7 @@ impl Tvu {
|
||||
/// * `blocktree` - the ledger itself
|
||||
#[allow(clippy::new_ret_no_self, clippy::too_many_arguments)]
|
||||
pub fn new<T>(
|
||||
vote_account: Pubkey,
|
||||
voting_keypair: Option<Arc<T>>,
|
||||
bank_forks: &Arc<RwLock<BankForks>>,
|
||||
bank_forks_info: &[BankForksInfo],
|
||||
@ -106,6 +108,7 @@ impl Tvu {
|
||||
|
||||
let (replay_stage, slot_full_receiver, forward_entry_receiver) = ReplayStage::new(
|
||||
keypair.pubkey(),
|
||||
vote_account,
|
||||
voting_keypair,
|
||||
blocktree.clone(),
|
||||
&bank_forks,
|
||||
@ -202,8 +205,10 @@ pub mod tests {
|
||||
.expect("Expected to successfully open ledger");
|
||||
let bank = bank_forks.working_bank();
|
||||
let (exit, poh_recorder, poh_service, _entry_receiver) = create_test_recorder(&bank);
|
||||
let voting_keypair = Keypair::new();
|
||||
let tvu = Tvu::new(
|
||||
Some(Arc::new(Keypair::new())),
|
||||
voting_keypair.pubkey(),
|
||||
Some(Arc::new(voting_keypair)),
|
||||
&Arc::new(RwLock::new(bank_forks)),
|
||||
&bank_forks_info,
|
||||
&cref1,
|
||||
|
@ -115,7 +115,8 @@ pub mod tests {
|
||||
|
||||
pub fn push_vote<T: KeypairUtil>(voting_keypair: &T, bank: &Bank, slot: u64) {
|
||||
let blockhash = bank.last_blockhash();
|
||||
let tx = VoteTransaction::new_vote(voting_keypair, slot, blockhash, 0);
|
||||
let tx =
|
||||
VoteTransaction::new_vote(voting_keypair.pubkey(), voting_keypair, slot, blockhash, 0);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user