Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Closed
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
994 changes: 974 additions & 20 deletions core/src/cluster_info_vote_listener.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::{
cluster_info::ClusterInfo,
cluster_info_vote_listener::VoteTracker,
commitment::{AggregateCommitmentService, BlockCommitmentCache, CommitmentAggregationData},
consensus::{StakeLockout, Tower},
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
Expand Down Expand Up @@ -168,6 +169,7 @@ impl ReplayStage {
cluster_info: Arc<RwLock<ClusterInfo>>,
ledger_signal_receiver: Receiver<bool>,
poh_recorder: Arc<Mutex<PohRecorder>>,
_vote_tracker: Arc<VoteTracker>,
) -> (Self, Receiver<Vec<Arc<Bank>>>) {
let ReplayStageConfig {
my_pubkey,
Expand Down
10 changes: 8 additions & 2 deletions core/src/tpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ use crate::{
banking_stage::BankingStage,
broadcast_stage::{BroadcastStage, BroadcastStageType},
cluster_info::ClusterInfo,
cluster_info_vote_listener::ClusterInfoVoteListener,
cluster_info_vote_listener::{ClusterInfoVoteListener, VoteTracker},
fetch_stage::FetchStage,
poh_recorder::{PohRecorder, WorkingBankEntry},
sigverify::TransactionSigVerifier,
sigverify_stage::{DisabledSigVerifier, SigVerifyStage},
};
use crossbeam_channel::unbounded;
use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender};
use solana_ledger::{
bank_forks::BankForks, blockstore::Blockstore, blockstore_processor::TransactionStatusSender,
};
use std::{
net::UdpSocket,
sync::{
Expand Down Expand Up @@ -46,6 +48,8 @@ impl Tpu {
broadcast_type: &BroadcastStageType,
exit: &Arc<AtomicBool>,
shred_version: u16,
vote_tracker: Arc<VoteTracker>,
bank_forks: Arc<RwLock<BankForks>>,
) -> Self {
let (packet_sender, packet_receiver) = channel();
let fetch_stage = FetchStage::new_with_sender(
Expand All @@ -72,6 +76,8 @@ impl Tpu {
sigverify_disabled,
verified_vote_sender,
&poh_recorder,
vote_tracker,
bank_forks,
);

let banking_stage = BankingStage::new(
Expand Down
4 changes: 4 additions & 0 deletions core/src/tvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use crate::{
blockstream_service::BlockstreamService,
cluster_info::ClusterInfo,
cluster_info_vote_listener::VoteTracker,
commitment::BlockCommitmentCache,
ledger_cleanup_service::LedgerCleanupService,
poh_recorder::PohRecorder,
Expand Down Expand Up @@ -88,6 +89,7 @@ impl Tvu {
transaction_status_sender: Option<TransactionStatusSender>,
rewards_recorder_sender: Option<RewardsRecorderSender>,
snapshot_package_sender: Option<SnapshotPackageSender>,
vote_tracker: Arc<VoteTracker>,
) -> Self {
let keypair: Arc<Keypair> = cluster_info
.read()
Expand Down Expand Up @@ -171,6 +173,7 @@ impl Tvu {
cluster_info.clone(),
ledger_signal_receiver,
poh_recorder.clone(),
vote_tracker,
);

let blockstream_service = if let Some(blockstream_unix_socket) = blockstream_unix_socket {
Expand Down Expand Up @@ -302,6 +305,7 @@ pub mod tests {
None,
None,
None,
Arc::new(VoteTracker::new(&bank)),
);
exit.store(true, Ordering::Relaxed);
tvu.join().unwrap();
Expand Down
6 changes: 6 additions & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::{
broadcast_stage::BroadcastStageType,
cluster_info::{ClusterInfo, Node},
cluster_info_vote_listener::VoteTracker,
commitment::BlockCommitmentCache,
contact_info::ContactInfo,
gossip_service::{discover_cluster, GossipService},
Expand Down Expand Up @@ -383,6 +384,8 @@ impl Validator {
"New shred signal for the TVU should be the same as the clear bank signal."
);

let vote_tracker = Arc::new({ VoteTracker::new(bank_forks.read().unwrap().root_bank()) });

let tvu = Tvu::new(
vote_account,
voting_keypair,
Expand Down Expand Up @@ -431,6 +434,7 @@ impl Validator {
transaction_status_sender.clone(),
rewards_recorder_sender,
snapshot_package_sender,
vote_tracker.clone(),
);

if config.dev_sigverify_disabled {
Expand All @@ -450,6 +454,8 @@ impl Validator {
&config.broadcast_stage_type,
&exit,
node.info.shred_version,
vote_tracker,
bank_forks,
);

datapoint_info!("validator-new", ("id", id.to_string(), String));
Expand Down
4 changes: 4 additions & 0 deletions ledger/src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ impl BankForks {
self.banks.get(&bank_slot)
}

pub fn root_bank(&self) -> &Arc<Bank> {
self.banks.get(&self.root()).expect("Root bank must exist")
}

pub fn new_from_banks(initial_forks: &[Arc<Bank>], rooted_path: Vec<Slot>) -> Self {
let mut banks = HashMap::new();
let working_bank = initial_forks[0].clone();
Expand Down
7 changes: 2 additions & 5 deletions runtime/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,11 @@ impl MessageProcessor {
.accounts
.iter()
.map(|&index| {
let is_signer = message.is_signer(index as usize);
let index = index as usize;
let key = &message.account_keys[index];
let is_writable = message.is_writable(index);
(
key,
index < message.header.num_required_signatures as usize,
is_writable,
)
(key, is_signer, is_writable)
})
.zip(program_accounts.iter())
.map(|((key, is_signer, is_writable), account)| {
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ impl Message {
- self.header.num_readonly_unsigned_accounts as usize)
}

pub fn is_signer(&self, i: usize) -> bool {
i < self.header.num_required_signatures as usize
}

pub fn get_account_keys_by_lock_type(&self) -> (Vec<&Pubkey>, Vec<&Pubkey>) {
let mut writable_keys = vec![];
let mut readonly_keys = vec![];
Expand Down