Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions vote/src/vote_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl VoteAccount {
let vote_state = VoteStateV4::new_with_defaults(&vote_pubkey, &vote_init, &clock);
let account = AccountSharedData::new_data(
rng.random(), // lamports
&VoteStateVersions::new_v4(vote_state.clone()),
&VoteStateVersions::new_v4(vote_state),
&solana_sdk_ids::vote::id(), // owner
)
.unwrap();
Expand Down Expand Up @@ -485,7 +485,7 @@ mod tests {
let vote_state = VoteStateV4::new_with_defaults(&vote_pubkey, &vote_init, &clock);
AccountSharedData::new_data(
rng.random(), // lamports
&VoteStateVersions::new_v4(vote_state.clone()),
&VoteStateVersions::new_v4(vote_state),
&solana_sdk_ids::vote::id(), // owner
)
.unwrap()
Expand Down Expand Up @@ -712,7 +712,7 @@ mod tests {
let ret = vote_accounts.insert(pubkey, vote_account2.clone(), || {
panic!("should not be called")
});
assert_eq!(ret, Some(vote_account1.clone()));
assert_eq!(ret, Some(vote_account1));
assert_eq!(vote_accounts.get(&pubkey), Some(&vote_account2));
// stake is unchanged
assert_eq!(vote_accounts.get_delegated_stake(&pubkey), 42);
Expand All @@ -722,10 +722,8 @@ mod tests {
let new_node_pubkey = Pubkey::new_unique();
let account3 = new_rand_vote_account(&mut rng, Some(new_node_pubkey));
let vote_account3 = VoteAccount::try_from(account3).unwrap();
let ret = vote_accounts.insert(pubkey, vote_account3.clone(), || {
panic!("should not be called")
});
assert_eq!(ret, Some(vote_account2.clone()));
let ret = vote_accounts.insert(pubkey, vote_account3, || panic!("should not be called"));
assert_eq!(ret, Some(vote_account2));
assert_eq!(vote_accounts.staked_nodes().get(&node_pubkey), None);
assert_eq!(
vote_accounts.staked_nodes().get(&new_node_pubkey),
Expand Down Expand Up @@ -755,9 +753,7 @@ mod tests {
let new_node_pubkey = Pubkey::new_unique();
let account2 = new_rand_vote_account(&mut rng, Some(new_node_pubkey));
let vote_account2 = VoteAccount::try_from(account2).unwrap();
let ret = vote_accounts.insert(pubkey, vote_account2.clone(), || {
panic!("should not be called")
});
let ret = vote_accounts.insert(pubkey, vote_account2, || panic!("should not be called"));
assert_eq!(ret, Some(vote_account1));
assert_eq!(vote_accounts.get_delegated_stake(&pubkey), 0);
assert_eq!(vote_accounts.staked_nodes().get(&node_pubkey), None);
Expand Down
22 changes: 11 additions & 11 deletions votor/src/consensus_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ mod tests {
root_bank.epoch_stakes_map(),
root_bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_1.clone()),
ConsensusMessage::Certificate(cert_1),
&mut vec![]
)
.is_ok());
Expand All @@ -1890,7 +1890,7 @@ mod tests {
root_bank.epoch_stakes_map(),
root_bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_2.clone()),
ConsensusMessage::Certificate(cert_2),
&mut vec![]
)
.is_ok());
Expand Down Expand Up @@ -1959,7 +1959,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_3.clone()),
ConsensusMessage::Certificate(cert_3),
&mut vec![]
)
.is_ok());
Expand All @@ -1974,7 +1974,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_4.clone()),
ConsensusMessage::Certificate(cert_4),
&mut vec![]
)
.is_ok());
Expand All @@ -1998,7 +1998,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_5.clone()),
ConsensusMessage::Certificate(cert_5),
&mut vec![]
)
.is_ok());
Expand All @@ -2015,7 +2015,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_5_finalize.clone()),
ConsensusMessage::Certificate(cert_5_finalize),
&mut vec![]
)
.is_ok());
Expand All @@ -2032,7 +2032,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_5.clone()),
ConsensusMessage::Certificate(cert_5),
&mut vec![]
)
.is_ok());
Expand All @@ -2056,7 +2056,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_6.clone()),
ConsensusMessage::Certificate(cert_6),
&mut vec![]
)
.is_ok());
Expand All @@ -2080,7 +2080,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_6_finalize.clone()),
ConsensusMessage::Certificate(cert_6_finalize),
&mut vec![]
)
.is_ok());
Expand All @@ -2096,7 +2096,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_6_notarize_fallback.clone()),
ConsensusMessage::Certificate(cert_6_notarize_fallback),
&mut vec![]
)
.is_ok());
Expand All @@ -2121,7 +2121,7 @@ mod tests {
bank.epoch_stakes_map(),
bank.slot(),
&Pubkey::new_unique(),
ConsensusMessage::Certificate(cert_7.clone()),
ConsensusMessage::Certificate(cert_7),
&mut vec![]
)
.is_ok());
Expand Down
26 changes: 13 additions & 13 deletions votor/src/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl EventHandler {
*my_pubkey = new_pubkey;
// The vote history file for the new identity must exist for set-identity to succeed
vctx.vote_history = VoteHistory::restore(ctx.vote_history_storage.as_ref(), my_pubkey)?;
vctx.identity_keypair = new_identity.clone();
vctx.identity_keypair = new_identity;
warn!("set-identity: from {my_old_pubkey} to {my_pubkey}");
}
Ok(())
Expand Down Expand Up @@ -866,8 +866,8 @@ mod tests {
let (consensus_metrics_sender, consensus_metrics_receiver) = unbounded();
let (leader_window_info_sender, leader_window_info_receiver) = unbounded();
let timer_manager = Arc::new(PlRwLock::new(TimerManager::new(
event_sender.clone(),
exit.clone(),
event_sender,
exit,
Arc::new(MigrationStatus::default()),
)));

Expand Down Expand Up @@ -1290,12 +1290,12 @@ mod tests {
test_context.check_for_vote(&Vote::new_notarization_vote(slot, block_id_2));
test_context.check_for_commitment(CommitmentType::Notarize, slot);
// Slot 3 somehow links to block 1, should not trigger Notarize vote because it has a wrong parent (not 2)
let _ = test_context.create_block_and_send_block_event(3, bank1.clone());
let _ = test_context.create_block_and_send_block_event(3, bank1);
test_context.check_no_vote_or_commitment();

// Slot 4 completed replay without parent ready or parent notarized should not trigger Notarize vote
let slot = 4;
let bank4 = test_context.create_block_and_send_block_event(slot, bank2.clone());
let bank4 = test_context.create_block_and_send_block_event(slot, bank2);
let block_id_4 = bank4.block_id().unwrap();

// Send parent ready for slot 4 should trigger Notarize vote for slot 4
Expand Down Expand Up @@ -1329,7 +1329,7 @@ mod tests {
test_context.send_block_notarized_event((1, block_id_1));
test_context.check_for_vote(&Vote::new_finalization_vote(1));

let bank2 = test_context.create_block_and_send_block_event(2, bank1.clone());
let bank2 = test_context.create_block_and_send_block_event(2, bank1);
let block_id_2 = bank2.block_id().unwrap();
// Both Notarize and Finalize votes should trigger for 2
test_context.check_for_vote(&Vote::new_notarization_vote(2, block_id_2));
Expand All @@ -1339,7 +1339,7 @@ mod tests {

// Create bank3 but do not Notarize, so Finalize vote should not trigger
let slot = 3;
let bank3 = test_context.create_block_only(slot, bank2.clone());
let bank3 = test_context.create_block_only(slot, bank2);
let block_id_3 = bank3.block_id().unwrap();
// Check no notarization vote for 3
test_context.check_no_vote_or_commitment();
Expand All @@ -1362,7 +1362,7 @@ mod tests {

// Simulate that block 4 never arrives, we create block 4 but send timeout event
let slot = 4;
let bank4 = test_context.create_block_only(slot, bank3.clone());
let bank4 = test_context.create_block_only(slot, bank3);
test_context.send_timeout_event(slot);
// We did eventually complete replay for 4
test_context.send_block_event(slot, bank4.clone());
Expand All @@ -1375,8 +1375,8 @@ mod tests {
// Now we get block 5, it's replayed and we get block_notarized, but since 4~7 is a bad
// window already, we shouldn't have notarize or finalize vote for 5
let slot = 5;
let bank5 = test_context.create_block_only(slot, bank4.clone());
test_context.send_block_event(slot, bank5.clone());
let bank5 = test_context.create_block_only(slot, bank4);
test_context.send_block_event(slot, bank5);
test_context.check_no_vote_or_commitment();
}

Expand Down Expand Up @@ -1545,7 +1545,7 @@ mod tests {
let bank4 = test_context.create_block_and_send_block_event(4, root_bank);
let block_id_4 = bank4.block_id().unwrap();

let bank5 = test_context.create_block_and_send_block_event(5, bank4.clone());
let bank5 = test_context.create_block_and_send_block_event(5, bank4);
let block_id_5 = bank5.block_id().unwrap();

test_context.send_finalized_event((5, block_id_5), true);
Expand All @@ -1555,11 +1555,11 @@ mod tests {

// We are partitioned off from rest of the network, and suddenly received finalize for
// slot 9 a little before we finished replay slot 9
let bank9 = test_context.create_block_only(9, bank5.clone());
let bank9 = test_context.create_block_only(9, bank5);
let block_id_9 = bank9.block_id().unwrap();
test_context.send_finalized_event((9, block_id_9), true);

test_context.send_block_event(9, bank9.clone());
test_context.send_block_event(9, bank9);

// We should now have parent ready for slot 9
test_context.check_parent_ready_slot((9, (5, block_id_5)));
Expand Down
4 changes: 2 additions & 2 deletions votor/src/staked_validators_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ mod tests {

// Create our staked validators cache - set include_self to false
let mut svc =
StakedValidatorsCache::new(bank_forks.clone(), Duration::from_secs(5), 5, false, None);
StakedValidatorsCache::new(bank_forks, Duration::from_secs(5), 5, false, None);

let (sockets, _) =
svc.get_staked_validators_by_slot(slot_num, &cluster_info, Instant::now());
Expand All @@ -567,7 +567,7 @@ mod tests {

// Create our staked validators cache - set include_self to false
let mut svc = StakedValidatorsCache::new(
bank_forks.clone(),
bank_forks,
Duration::from_secs(5),
5,
false,
Expand Down
2 changes: 1 addition & 1 deletion votor/src/voting_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ mod tests {
"TestAlpenglowConnectionCache",
10,
)),
bank_forks.clone(),
bank_forks,
Some(VotingServiceOverride {
additional_listeners: vec![listener],
alpenglow_port_override: AlpenglowPortOverride::default(),
Expand Down
17 changes: 7 additions & 10 deletions votor/src/votor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ impl Votor {
} = config;

let migration_status = bank_forks.read().unwrap().migration_status();
let identity_keypair = cluster_info.keypair().clone();
let identity_keypair = cluster_info.keypair();
let has_new_vote_been_rooted = !wait_for_vote_to_start_leader;

// Get the sharable root bank
let sharable_banks = bank_forks.read().unwrap().sharable_banks();

let shared_context = SharedContext {
blockstore: blockstore.clone(),
bank_forks: bank_forks.clone(),
bank_forks,
cluster_info: cluster_info.clone(),
rpc_subscriptions,
highest_parent_ready,
Expand All @@ -186,7 +186,7 @@ impl Votor {
let voting_context = VotingContext {
vote_history,
vote_account_pubkey: vote_account,
identity_keypair: identity_keypair.clone(),
identity_keypair,
authorized_voter_keypairs,
derived_bls_keypairs: HashMap::new(),
has_new_vote_been_rooted,
Expand All @@ -195,7 +195,7 @@ impl Votor {
commitment_sender: commitment_sender.clone(),
wait_to_vote_slot,
sharable_banks: sharable_banks.clone(),
consensus_metrics_sender: consensus_metrics_sender.clone(),
consensus_metrics_sender,
};

let root_context = RootContext {
Expand Down Expand Up @@ -226,7 +226,7 @@ impl Votor {
let consensus_pool_context = ConsensusPoolContext {
exit: exit.clone(),
migration_status,
cluster_info: cluster_info.clone(),
cluster_info,
my_vote_pubkey: vote_account,
blockstore,
sharable_banks,
Expand All @@ -237,11 +237,8 @@ impl Votor {
commitment_sender,
};

let metrics = ConsensusMetrics::start_metrics_loop(
epoch_schedule,
consensus_metrics_receiver,
exit.clone(),
);
let metrics =
ConsensusMetrics::start_metrics_loop(epoch_schedule, consensus_metrics_receiver, exit);
let event_handler = EventHandler::new(event_handler_context);
let consensus_pool_service = ConsensusPoolService::new(consensus_pool_context);

Expand Down
Loading