diff --git a/Cargo.lock b/Cargo.lock index 581c878bf42f09..1b5d56544fc5ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10200,10 +10200,23 @@ dependencies = [ "rand 0.8.5", "serde", "serde_derive", + "solana-account", + "solana-bincode", + "solana-clock", "solana-frozen-abi", "solana-frozen-abi-macro", - "solana-sdk", + "solana-hash", + "solana-instruction", + "solana-keypair", + "solana-packet", + "solana-program", + "solana-pubkey", + "solana-sdk-ids", + "solana-sha256-hasher", + "solana-signature", + "solana-signer", "solana-svm-transaction", + "solana-transaction", "thiserror 2.0.9", ] diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index c90c1945909501..d20f90ee83b424 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -8426,8 +8426,18 @@ dependencies = [ "log", "serde", "serde_derive", - "solana-sdk", + "solana-account", + "solana-bincode", + "solana-clock", + "solana-hash", + "solana-instruction", + "solana-packet", + "solana-program", + "solana-pubkey", + "solana-sdk-ids", + "solana-signature", "solana-svm-transaction", + "solana-transaction", "thiserror 2.0.9", ] diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 3c60a9a79b7b0e..d653ac22e7a069 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -7762,8 +7762,18 @@ dependencies = [ "log", "serde", "serde_derive", - "solana-sdk", + "solana-account", + "solana-bincode", + "solana-clock", + "solana-hash", + "solana-instruction", + "solana-packet", + "solana-program", + "solana-pubkey", + "solana-sdk-ids", + "solana-signature", "solana-svm-transaction", + "solana-transaction", "thiserror 2.0.9", ] diff --git a/vote/Cargo.toml b/vote/Cargo.toml index 520a4b33b5ee91..9ea95b72841a95 100644 --- a/vote/Cargo.toml +++ b/vote/Cargo.toml @@ -15,14 +15,24 @@ log = { workspace = true } rand = { workspace = true, optional = true } serde = { workspace = true, features = ["rc"] } serde_derive = { workspace = true } +solana-account = { workspace = true, features = ["bincode"] } +solana-bincode = { workspace = true } +solana-clock = { workspace = true } solana-frozen-abi = { workspace = true, optional = true, features = [ "frozen-abi", ] } solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } -solana-sdk = { workspace = true } +solana-hash = { workspace = true } +solana-instruction = { workspace = true } +solana-packet = { workspace = true } +solana-program = { workspace = true } +solana-pubkey = { workspace = true } +solana-sdk-ids = { workspace = true } +solana-signature = { workspace = true } solana-svm-transaction = { workspace = true } +solana-transaction = { workspace = true } thiserror = { workspace = true } [lib] @@ -32,17 +42,17 @@ name = "solana_vote" [dev-dependencies] bincode = { workspace = true } rand = { workspace = true } +solana-keypair = { workspace = true } +solana-sha256-hasher = { workspace = true } +solana-signer = { workspace = true } +solana-transaction = { workspace = true, features = ["bincode"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [features] dev-context-only-utils = ["dep:rand"] -frozen-abi = [ - "dep:solana-frozen-abi", - "dep:solana-frozen-abi-macro", - "solana-sdk/frozen-abi", -] +frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] [lints] workspace = true diff --git a/vote/benches/vote_account.rs b/vote/benches/vote_account.rs index 34d3de33f5dc0d..1f2b07e29605b9 100644 --- a/vote/benches/vote_account.rs +++ b/vote/benches/vote_account.rs @@ -3,11 +3,9 @@ extern crate test; use { rand::Rng, - solana_sdk::{ - account::AccountSharedData, - pubkey::Pubkey, - vote::state::{VoteInit, VoteState, VoteStateVersions}, - }, + solana_account::AccountSharedData, + solana_program::vote::state::{VoteInit, VoteState, VoteStateVersions}, + solana_pubkey::Pubkey, solana_vote::vote_account::VoteAccount, test::Bencher, }; @@ -22,7 +20,7 @@ fn new_rand_vote_account( authorized_withdrawer: Pubkey::new_unique(), commission: rng.gen(), }; - let clock = solana_sdk::sysvar::clock::Clock { + let clock = solana_clock::Clock { slot: rng.gen(), epoch_start_timestamp: rng.gen(), epoch: rng.gen(), @@ -33,7 +31,7 @@ fn new_rand_vote_account( let account = AccountSharedData::new_data( rng.gen(), // lamports &VoteStateVersions::new_current(vote_state.clone()), - &solana_sdk::vote::program::id(), // owner + &solana_sdk_ids::vote::id(), // owner ) .unwrap(); (account, vote_state) diff --git a/vote/src/vote_account.rs b/vote/src/vote_account.rs index 3edd9a7bf0288a..18fffa5ddf5465 100644 --- a/vote/src/vote_account.rs +++ b/vote/src/vote_account.rs @@ -4,12 +4,10 @@ use { de::{MapAccess, Visitor}, ser::{Serialize, Serializer}, }, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, - instruction::InstructionError, - pubkey::Pubkey, - vote::state::VoteState, - }, + solana_account::{AccountSharedData, ReadableAccount}, + solana_instruction::error::InstructionError, + solana_program::vote::state::VoteState, + solana_pubkey::Pubkey, std::{ cmp::Ordering, collections::{hash_map::Entry, HashMap}, @@ -98,10 +96,8 @@ impl VoteAccount { pub fn new_random() -> VoteAccount { use { rand::Rng as _, - solana_sdk::{ - clock::Clock, - vote::state::{VoteInit, VoteStateVersions}, - }, + solana_clock::Clock, + solana_program::vote::state::{VoteInit, VoteStateVersions}, }; let mut rng = rand::thread_rng(); @@ -123,7 +119,7 @@ impl VoteAccount { let account = AccountSharedData::new_data( rng.gen(), // lamports &VoteStateVersions::new_current(vote_state.clone()), - &solana_sdk::vote::program::id(), // owner + &solana_sdk_ids::vote::id(), // owner ) .unwrap(); @@ -325,7 +321,7 @@ impl From for AccountSharedData { impl TryFrom for VoteAccount { type Error = Error; fn try_from(account: AccountSharedData) -> Result { - if !solana_sdk::vote::program::check_id(account.owner()) { + if !solana_sdk_ids::vote::check_id(account.owner()) { return Err(Error::InvalidOwner(*account.owner())); } @@ -485,12 +481,10 @@ mod tests { super::*, bincode::Options, rand::Rng, - solana_sdk::{ - account::WritableAccount, - pubkey::Pubkey, - sysvar::clock::Clock, - vote::state::{VoteInit, VoteStateVersions}, - }, + solana_account::WritableAccount, + solana_clock::Clock, + solana_program::vote::state::{VoteInit, VoteStateVersions}, + solana_pubkey::Pubkey, std::iter::repeat_with, }; @@ -515,7 +509,7 @@ mod tests { let account = AccountSharedData::new_data( rng.gen(), // lamports &VoteStateVersions::new_current(vote_state.clone()), - &solana_sdk::vote::program::id(), // owner + &solana_sdk_ids::vote::id(), // owner ) .unwrap(); (account, vote_state) @@ -576,7 +570,7 @@ mod tests { #[should_panic(expected = "InvalidAccountData")] fn test_vote_account_try_from_invalid_account() { let mut account = AccountSharedData::default(); - account.set_owner(solana_sdk::vote::program::id()); + account.set_owner(solana_sdk_ids::vote::id()); VoteAccount::try_from(account).unwrap(); } @@ -640,8 +634,7 @@ mod tests { // bad data let invalid_account_data = - AccountSharedData::new_data(42, &vec![0xFF; 42], &solana_sdk::vote::program::id()) - .unwrap(); + AccountSharedData::new_data(42, &vec![0xFF; 42], &solana_sdk_ids::vote::id()).unwrap(); vote_accounts_hash_map.insert(Pubkey::new_unique(), (0xBB, invalid_account_data)); // wrong owner diff --git a/vote/src/vote_parser.rs b/vote/src/vote_parser.rs index aa65027ef96e6b..b64657f268c6fe 100644 --- a/vote/src/vote_parser.rs +++ b/vote/src/vote_parser.rs @@ -1,10 +1,8 @@ use { - crate::vote_transaction::VoteTransaction, - solana_sdk::{ - hash::Hash, program_utils::limited_deserialize, pubkey::Pubkey, signature::Signature, - transaction::Transaction, vote::instruction::VoteInstruction, - }, - solana_svm_transaction::svm_transaction::SVMTransaction, + crate::vote_transaction::VoteTransaction, solana_bincode::limited_deserialize, + solana_hash::Hash, solana_program::vote::instruction::VoteInstruction, solana_pubkey::Pubkey, + solana_signature::Signature, solana_svm_transaction::svm_transaction::SVMTransaction, + solana_transaction::Transaction, }; pub type ParsedVote = (Pubkey, VoteTransaction, Option, Signature); @@ -13,7 +11,7 @@ pub type ParsedVote = (Pubkey, VoteTransaction, Option, Signature); pub fn parse_sanitized_vote_transaction(tx: &impl SVMTransaction) -> Option { // Check first instruction for a vote let (program_id, first_instruction) = tx.program_instructions_iter().next()?; - if !solana_sdk::vote::program::check_id(program_id) { + if !solana_sdk_ids::vote::check_id(program_id) { return None; } let first_account = usize::from(*first_instruction.accounts.first()?); @@ -30,7 +28,7 @@ pub fn parse_vote_transaction(tx: &Transaction) -> Option { let first_instruction = message.instructions.first()?; let program_id_index = usize::from(first_instruction.program_id_index); let program_id = message.account_keys.get(program_id_index)?; - if !solana_sdk::vote::program::check_id(program_id) { + if !solana_sdk_ids::vote::check_id(program_id) { return None; } let first_account = usize::from(*first_instruction.accounts.first()?); @@ -43,7 +41,12 @@ pub fn parse_vote_transaction(tx: &Transaction) -> Option { fn parse_vote_instruction_data( vote_instruction_data: &[u8], ) -> Option<(VoteTransaction, Option)> { - match limited_deserialize(vote_instruction_data).ok()? { + match limited_deserialize( + vote_instruction_data, + solana_packet::PACKET_DATA_SIZE as u64, + ) + .ok()? + { VoteInstruction::Vote(vote) => Some((VoteTransaction::from(vote), None)), VoteInstruction::VoteSwitch(vote, hash) => Some((VoteTransaction::from(vote), Some(hash))), VoteInstruction::UpdateVoteState(vote_state_update) => { @@ -77,12 +80,11 @@ fn parse_vote_instruction_data( mod test { use { super::*, - solana_sdk::{ - clock::Slot, - hash::hash, - signature::{Keypair, Signer}, - vote::{instruction as vote_instruction, state::Vote}, - }, + solana_clock::Slot, + solana_keypair::Keypair, + solana_program::vote::{instruction as vote_instruction, state::Vote}, + solana_sha256_hasher::hash, + solana_signer::Signer, }; // Reimplemented locally from Vote program. diff --git a/vote/src/vote_transaction.rs b/vote/src/vote_transaction.rs index 3cb1ab5c0b4d16..c88ea0a2f7ea35 100644 --- a/vote/src/vote_transaction.rs +++ b/vote/src/vote_transaction.rs @@ -1,7 +1,7 @@ -use solana_sdk::{ - clock::{Slot, UnixTimestamp}, - hash::Hash, - vote::state::{TowerSync, Vote, VoteStateUpdate}, +use { + solana_clock::{Slot, UnixTimestamp}, + solana_hash::Hash, + solana_program::vote::state::{TowerSync, Vote, VoteStateUpdate}, }; #[derive(Debug, PartialEq, Eq, Clone)]