Skip to content

Commit 03466ec

Browse files
ksn6bw-solana
authored andcommitted
refactor: introducing votor-messages crate (anza-xyz#328)
1 parent eae726f commit 03466ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+544
-454
lines changed

Cargo.lock

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ members = [
148148
"vortexor",
149149
"vote",
150150
"votor",
151+
"votor-messages",
151152
"watchtower",
152153
"wen-restart",
153154
"zk-keygen",
@@ -569,6 +570,7 @@ solana-vote = { path = "vote", version = "=2.3.0" }
569570
solana-vote-interface = "=2.2.2"
570571
solana-vote-program = { path = "programs/vote", version = "=2.3.0", default-features = false }
571572
solana-votor = { path = "votor", version = "=2.3.0" }
573+
solana-votor-messages = { path = "votor-messages", version = "=2.3.0" }
572574
solana-wen-restart = { path = "wen-restart", version = "=2.3.0" }
573575
solana-zk-elgamal-proof-program = { path = "programs/zk-elgamal-proof", version = "=2.3.0" }
574576
solana-zk-keygen = { path = "zk-keygen", version = "=2.3.0" }

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ solana-udp-client = { workspace = true }
8888
solana-version = { workspace = true }
8989
solana-vote = { workspace = true }
9090
solana-vote-program = { workspace = true }
91+
solana-votor-messages = { workspace = true }
9192
spl-memo = { workspace = true, features = ["no-entrypoint"] }
9293
thiserror = { workspace = true }
9394
tiny-bip39 = { workspace = true }

cli/src/vote.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ use {
4040
solana_rpc_client_nonce_utils::blockhash_query::BlockhashQuery,
4141
solana_system_interface::error::SystemError,
4242
solana_transaction::Transaction,
43-
solana_vote::alpenglow::{
44-
bls_message::BLS_KEYPAIR_DERIVE_SEED, instruction::InitializeAccountInstructionData,
45-
state::VoteState as AlpenglowVoteState,
46-
},
4743
solana_vote_program::{
4844
authorized_voters::AuthorizedVoters,
4945
vote_error::VoteError,
@@ -53,6 +49,10 @@ use {
5349
VOTE_CREDITS_MAXIMUM_PER_SLOT,
5450
},
5551
},
52+
solana_votor_messages::{
53+
bls_message::BLS_KEYPAIR_DERIVE_SEED, instruction::InitializeAccountInstructionData,
54+
state::VoteState as AlpenglowVoteState,
55+
},
5656
std::rc::Rc,
5757
};
5858

@@ -849,7 +849,7 @@ pub fn process_create_vote_account(
849849

850850
let required_balance = rpc_client
851851
.get_minimum_balance_for_rent_exemption(if is_alpenglow {
852-
solana_vote::alpenglow::state::VoteState::size()
852+
solana_votor_messages::state::VoteState::size()
853853
} else {
854854
VoteState::size_of()
855855
})?
@@ -887,11 +887,11 @@ pub fn process_create_vote_account(
887887
from_pubkey,
888888
to_pubkey,
889889
lamports,
890-
solana_vote::alpenglow::state::VoteState::size() as u64,
891-
&solana_vote::alpenglow::id(),
890+
solana_votor_messages::state::VoteState::size() as u64,
891+
&solana_votor_messages::id(),
892892
);
893893

894-
let init_ix = solana_vote::alpenglow::instruction::initialize_account(
894+
let init_ix = solana_votor_messages::instruction::initialize_account(
895895
*to_pubkey,
896896
&initialize_account_ixn_meta,
897897
);
@@ -1374,7 +1374,7 @@ impl VoteStateWrapper {
13741374
}
13751375

13761376
const SOLANA_VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id();
1377-
const ALPENGLOW_VOTE_PROGRAM_ID: Pubkey = solana_vote::alpenglow::id();
1377+
const ALPENGLOW_VOTE_PROGRAM_ID: Pubkey = solana_votor_messages::id();
13781378

13791379
pub(crate) fn get_vote_account(
13801380
rpc_client: &RpcClient,

core/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ serde_derive = { workspace = true }
5151
slab = { workspace = true }
5252
solana-accounts-db = { workspace = true }
5353
solana-bloom = { workspace = true }
54-
solana-bls-signatures = { workspace = true, features = ["solana-signer-derive"] }
54+
solana-bls-signatures = { workspace = true, features = [
55+
"solana-signer-derive",
56+
] }
5557
solana-builtins-default-costs = { workspace = true }
5658
solana-client = { workspace = true }
5759
solana-compute-budget = { workspace = true }
@@ -100,6 +102,7 @@ solana-version = { workspace = true }
100102
solana-vote = { workspace = true }
101103
solana-vote-program = { workspace = true }
102104
solana-votor = { workspace = true }
105+
solana-votor-messages = { workspace = true }
103106
solana-wen-restart = { workspace = true }
104107
strum = { workspace = true, features = ["derive"] }
105108
strum_macros = { workspace = true }

core/src/repair/certificate_service.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use {
77
crate::result::{Error, Result},
88
crossbeam_channel::{Receiver, RecvTimeoutError},
99
solana_ledger::blockstore::Blockstore,
10-
solana_vote::alpenglow::bls_message::CertificateMessage,
11-
solana_votor::CertificateId,
10+
solana_votor_messages::bls_message::{Certificate, CertificateMessage},
1211
std::{
1312
sync::{
1413
atomic::{AtomicBool, Ordering},
@@ -19,7 +18,7 @@ use {
1918
},
2019
};
2120

22-
pub(crate) type CertificateReceiver = Receiver<(CertificateId, CertificateMessage)>;
21+
pub(crate) type CertificateReceiver = Receiver<(Certificate, CertificateMessage)>;
2322
pub struct CertificateService {
2423
t_cert_insert: JoinHandle<()>,
2524
}
@@ -73,8 +72,8 @@ impl CertificateService {
7372
}
7473

7574
fn receive_new_certificates(
76-
certificate_receiver: &Receiver<(CertificateId, CertificateMessage)>,
77-
) -> Result<Vec<(CertificateId, CertificateMessage)>> {
75+
certificate_receiver: &Receiver<(Certificate, CertificateMessage)>,
76+
) -> Result<Vec<(Certificate, CertificateMessage)>> {
7877
const RECV_TIMEOUT: Duration = Duration::from_millis(200);
7978
Ok(
8079
std::iter::once(certificate_receiver.recv_timeout(RECV_TIMEOUT)?)
@@ -85,18 +84,18 @@ impl CertificateService {
8584

8685
fn insert_certificate(
8786
blockstore: &Blockstore,
88-
cert_id: CertificateId,
87+
cert_id: Certificate,
8988
vote_certificate: CertificateMessage,
9089
) -> Result<()> {
9190
match cert_id {
92-
CertificateId::NotarizeFallback(slot, block_id) => blockstore
91+
Certificate::NotarizeFallback(slot, block_id) => blockstore
9392
.insert_new_notarization_fallback_certificate(slot, block_id, vote_certificate)?,
94-
CertificateId::Skip(slot) => {
93+
Certificate::Skip(slot) => {
9594
blockstore.insert_new_skip_certificate(slot, vote_certificate)?
9695
}
97-
CertificateId::Finalize(_)
98-
| CertificateId::FinalizeFast(_, _)
99-
| CertificateId::Notarize(_, _) => {
96+
Certificate::Finalize(_)
97+
| Certificate::FinalizeFast(_, _)
98+
| Certificate::Notarize(_, _) => {
10099
panic!("Programmer error, certificate pool should not notify for {cert_id:?}")
101100
}
102101
}

core/src/replay_stage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ use {
8282
transaction::Transaction,
8383
},
8484
solana_timings::ExecuteTimings,
85-
solana_vote::{alpenglow::bls_message::CertificateMessage, vote_transaction::VoteTransaction},
85+
solana_vote::vote_transaction::VoteTransaction,
8686
solana_votor::{
8787
event::{CompletedBlock, VotorEvent, VotorEventReceiver, VotorEventSender},
8888
root_utils,
8989
vote_history::VoteHistory,
9090
vote_history_storage::VoteHistoryStorage,
9191
voting_utils::{BLSOp, GenerateVoteTxResult},
9292
votor::{LeaderWindowNotifier, Votor, VotorConfig},
93-
CertificateId,
9493
},
94+
solana_votor_messages::bls_message::{Certificate, CertificateMessage},
9595
std::{
9696
collections::{HashMap, HashSet},
9797
num::NonZeroUsize,
@@ -300,7 +300,7 @@ pub struct ReplaySenders {
300300
pub drop_bank_sender: Sender<Vec<BankWithScheduler>>,
301301
pub block_metadata_notifier: Option<BlockMetadataNotifierArc>,
302302
pub dumped_slots_sender: Sender<Vec<(u64, Hash)>>,
303-
pub certificate_sender: Sender<(CertificateId, CertificateMessage)>,
303+
pub certificate_sender: Sender<(Certificate, CertificateMessage)>,
304304
pub votor_event_sender: VotorEventSender,
305305
pub own_vote_sender: BLSVerifiedMessageSender,
306306
}

core/src/sigverifier/bls_sigverifier.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use {
1313
solana_runtime::epoch_stakes_service::EpochStakesService,
1414
solana_sdk::clock::Slot,
1515
solana_streamer::packet::PacketBatch,
16-
solana_vote::alpenglow::bls_message::BLSMessage,
16+
solana_votor_messages::bls_message::BLSMessage,
1717
stats::{BLSSigVerifierStats, StatsUpdater},
1818
std::{collections::HashMap, sync::Arc},
1919
};
@@ -56,7 +56,7 @@ impl SigVerifier for BLSSigVerifier {
5656
let slot = match &message {
5757
BLSMessage::Vote(vote_message) => vote_message.vote.slot(),
5858
BLSMessage::Certificate(certificate_message) => {
59-
certificate_message.certificate.slot
59+
certificate_message.certificate.slot()
6060
}
6161
};
6262

@@ -148,9 +148,10 @@ mod tests {
148148
},
149149
},
150150
solana_sdk::{hash::Hash, signer::Signer},
151-
solana_vote::alpenglow::{
152-
bls_message::{BLSMessage, CertificateMessage, VoteMessage},
153-
certificate::{Certificate, CertificateType},
151+
solana_votor_messages::{
152+
bls_message::{
153+
BLSMessage, Certificate, CertificateMessage, CertificateType, VoteMessage,
154+
},
154155
vote::Vote,
155156
},
156157
stats::STATS_INTERVAL_DURATION,
@@ -228,18 +229,17 @@ mod tests {
228229
bitmap.set(3, true);
229230
bitmap.set(5, true);
230231
let vote_rank: usize = 2;
232+
233+
let certificate = Certificate::new(CertificateType::Finalize, 4, None);
234+
231235
let messages = vec![
232236
BLSMessage::Vote(VoteMessage {
233237
vote: Vote::new_finalization_vote(5),
234238
signature: Signature::default(),
235239
rank: vote_rank as u16,
236240
}),
237241
BLSMessage::Certificate(CertificateMessage {
238-
certificate: Certificate {
239-
slot: 4,
240-
certificate_type: CertificateType::Finalize,
241-
block_id: None,
242-
},
242+
certificate,
243243
signature: Signature::default(),
244244
bitmap,
245245
}),

0 commit comments

Comments
 (0)