diff --git a/Cargo.lock b/Cargo.lock index 601b38665906f8..5e8a9bd16350bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10136,14 +10136,29 @@ dependencies = [ "num-traits", "serde", "serde_derive", + "solana-account", + "solana-bincode", + "solana-clock", + "solana-epoch-schedule", "solana-feature-set", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-hash", + "solana-instruction", + "solana-keypair", "solana-logger", "solana-metrics", + "solana-packet", "solana-program", "solana-program-runtime", - "solana-sdk", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-sha256-hasher", + "solana-signer", + "solana-slot-hashes", + "solana-transaction", + "solana-transaction-context", "test-case", "thiserror 2.0.9", ] diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 75d501900df95e..d6fe60bb456ed3 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -8387,11 +8387,25 @@ dependencies = [ "num-traits", "serde", "serde_derive", + "solana-account", + "solana-bincode", + "solana-clock", + "solana-epoch-schedule", "solana-feature-set", + "solana-hash", + "solana-instruction", + "solana-keypair", "solana-metrics", + "solana-packet", "solana-program", "solana-program-runtime", - "solana-sdk", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-signer", + "solana-slot-hashes", + "solana-transaction", + "solana-transaction-context", "thiserror 2.0.9", ] diff --git a/programs/vote/Cargo.toml b/programs/vote/Cargo.toml index 80d4cbe34d4987..4ab1c4e6c3a2eb 100644 --- a/programs/vote/Cargo.toml +++ b/programs/vote/Cargo.toml @@ -16,6 +16,10 @@ num-derive = { workspace = true } num-traits = { workspace = true } serde = { workspace = true } serde_derive = { workspace = true } +solana-account = { workspace = true } +solana-bincode = { workspace = true } +solana-clock = { workspace = true } +solana-epoch-schedule = { workspace = true } solana-feature-set = { workspace = true } solana-frozen-abi = { workspace = true, optional = true, features = [ "frozen-abi", @@ -23,15 +27,27 @@ solana-frozen-abi = { workspace = true, optional = true, features = [ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } +solana-hash = { workspace = true } +solana-instruction = { workspace = true } +solana-keypair = { workspace = true } solana-metrics = { workspace = true } +solana-packet = { workspace = true } solana-program = { workspace = true } solana-program-runtime = { workspace = true } -solana-sdk = { workspace = true } +solana-pubkey = { workspace = true } +solana-rent = { workspace = true } +solana-sdk-ids = { workspace = true } +solana-signer = { workspace = true } +solana-slot-hashes = { workspace = true } +solana-transaction = { workspace = true, features = ["bincode"] } +solana-transaction-context = { workspace = true, features = ["bincode"] } thiserror = { workspace = true } [dev-dependencies] assert_matches = { workspace = true } solana-logger = { workspace = true } +solana-pubkey = { workspace = true, features = ["rand"] } +solana-sha256-hasher = { workspace = true } test-case = { workspace = true } [lib] @@ -46,8 +62,7 @@ frozen-abi = [ "dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "solana-program/frozen-abi", - "solana-program-runtime/frozen-abi", - "solana-sdk/frozen-abi", + "solana-program-runtime/frozen-abi" ] [lints] diff --git a/programs/vote/benches/process_vote.rs b/programs/vote/benches/process_vote.rs index 06c392abb60a75..e291caa744021f 100644 --- a/programs/vote/benches/process_vote.rs +++ b/programs/vote/benches/process_vote.rs @@ -3,17 +3,15 @@ extern crate test; use { + solana_account::{create_account_for_test, Account, AccountSharedData}, + solana_clock::{Clock, Slot}, + solana_hash::Hash, + solana_instruction::AccountMeta, solana_program_runtime::invoke_context::mock_process_instruction, - solana_sdk::{ - account::{create_account_for_test, Account, AccountSharedData}, - clock::{Clock, Slot}, - hash::Hash, - instruction::AccountMeta, - pubkey::Pubkey, - slot_hashes::{SlotHashes, MAX_ENTRIES}, - sysvar, - transaction_context::TransactionAccount, - }, + solana_pubkey::Pubkey, + solana_sdk_ids::sysvar, + solana_slot_hashes::{SlotHashes, MAX_ENTRIES}, + solana_transaction_context::TransactionAccount, solana_vote_program::{ vote_instruction::VoteInstruction, vote_state::{ diff --git a/programs/vote/src/lib.rs b/programs/vote/src/lib.rs index 978d42f6d98282..9e43defeceb5e6 100644 --- a/programs/vote/src/lib.rs +++ b/programs/vote/src/lib.rs @@ -11,7 +11,7 @@ extern crate solana_metrics; #[cfg(feature = "frozen-abi")] extern crate solana_frozen_abi_macro; -pub use solana_sdk::vote::{ +pub use solana_program::vote::{ authorized_voters, error as vote_error, instruction as vote_instruction, program::{check_id, id}, }; diff --git a/programs/vote/src/vote_processor.rs b/programs/vote/src/vote_processor.rs index 8cb4db468f9b72..600e6e88599417 100644 --- a/programs/vote/src/vote_processor.rs +++ b/programs/vote/src/vote_processor.rs @@ -3,18 +3,16 @@ use { crate::vote_state, log::*, + solana_bincode::limited_deserialize, solana_feature_set as feature_set, + solana_instruction::error::InstructionError, solana_program::vote::{instruction::VoteInstruction, program::id, state::VoteAuthorize}, solana_program_runtime::{ declare_process_instruction, invoke_context::InvokeContext, sysvar_cache::get_sysvar_with_account_check, }, - solana_sdk::{ - instruction::InstructionError, - program_utils::limited_deserialize, - pubkey::Pubkey, - transaction_context::{BorrowedAccount, InstructionContext, TransactionContext}, - }, + solana_pubkey::Pubkey, + solana_transaction_context::{BorrowedAccount, InstructionContext, TransactionContext}, std::collections::HashSet, }; @@ -66,7 +64,7 @@ declare_process_instruction!(Entrypoint, DEFAULT_COMPUTE_UNITS, |invoke_context| } let signers = instruction_context.get_signers(transaction_context)?; - match limited_deserialize(data)? { + match limited_deserialize(data, solana_packet::PACKET_DATA_SIZE as u64)? { VoteInstruction::InitializeAccount(vote_init) => { let rent = get_sysvar_with_account_check::rent(invoke_context, instruction_context, 1)?; if !rent.is_exempt(me.get_lamports(), me.get_data().len()) { @@ -271,19 +269,19 @@ mod tests { }, }, bincode::serialize, - solana_program_runtime::invoke_context::mock_process_instruction, - solana_sdk::{ - account::{self, Account, AccountSharedData, ReadableAccount}, - account_utils::StateMut, - hash::Hash, - instruction::{AccountMeta, Instruction}, - pubkey::Pubkey, - sysvar::{ - self, clock::Clock, epoch_schedule::EpochSchedule, rent::Rent, - slot_hashes::SlotHashes, - }, - vote::instruction::{tower_sync, tower_sync_switch}, + solana_account::{ + self as account, state_traits::StateMut, Account, AccountSharedData, ReadableAccount, }, + solana_clock::Clock, + solana_epoch_schedule::EpochSchedule, + solana_hash::Hash, + solana_instruction::{AccountMeta, Instruction}, + solana_program::vote::instruction::{tower_sync, tower_sync_switch}, + solana_program_runtime::invoke_context::mock_process_instruction, + solana_pubkey::Pubkey, + solana_rent::Rent, + solana_sdk_ids::sysvar, + solana_slot_hashes::SlotHashes, std::{collections::HashSet, str::FromStr}, }; @@ -386,24 +384,24 @@ mod tests { fn create_test_account() -> (Pubkey, AccountSharedData) { let rent = Rent::default(); let balance = VoteState::get_rent_exempt_reserve(&rent); - let vote_pubkey = solana_sdk::pubkey::new_rand(); + let vote_pubkey = solana_pubkey::new_rand(); ( vote_pubkey, - vote_state::create_account(&vote_pubkey, &solana_sdk::pubkey::new_rand(), 0, balance), + vote_state::create_account(&vote_pubkey, &solana_pubkey::new_rand(), 0, balance), ) } fn create_test_account_with_authorized() -> (Pubkey, Pubkey, Pubkey, AccountSharedData) { - let vote_pubkey = solana_sdk::pubkey::new_rand(); - let authorized_voter = solana_sdk::pubkey::new_rand(); - let authorized_withdrawer = solana_sdk::pubkey::new_rand(); + let vote_pubkey = solana_pubkey::new_rand(); + let authorized_voter = solana_pubkey::new_rand(); + let authorized_withdrawer = solana_pubkey::new_rand(); ( vote_pubkey, authorized_voter, authorized_withdrawer, vote_state::create_account_with_authorized( - &solana_sdk::pubkey::new_rand(), + &solana_pubkey::new_rand(), &authorized_voter, &authorized_withdrawer, 0, @@ -517,9 +515,9 @@ mod tests { #[test] fn test_initialize_vote_account() { - let vote_pubkey = solana_sdk::pubkey::new_rand(); + let vote_pubkey = solana_pubkey::new_rand(); let vote_account = AccountSharedData::new(100, VoteState::size_of(), &id()); - let node_pubkey = solana_sdk::pubkey::new_rand(); + let node_pubkey = solana_pubkey::new_rand(); let node_account = AccountSharedData::default(); let instruction_data = serialize(&VoteInstruction::InitializeAccount(VoteInit { node_pubkey, @@ -612,7 +610,7 @@ mod tests { fn test_vote_update_validator_identity() { let (vote_pubkey, _authorized_voter, authorized_withdrawer, vote_account) = create_test_account_with_authorized(); - let node_pubkey = solana_sdk::pubkey::new_rand(); + let node_pubkey = solana_pubkey::new_rand(); let instruction_data = serialize(&VoteInstruction::UpdateValidatorIdentity).unwrap(); let transaction_accounts = vec![ (vote_pubkey, vote_account), @@ -825,7 +823,7 @@ mod tests { sysvar::slot_hashes::id(), account::create_account_shared_data_for_test(&SlotHashes::new(&[( *vote.slots.last().unwrap(), - solana_sdk::hash::hash(&[0u8]), + solana_sha256_hasher::hash(&[0u8]), )])), ); process_instruction( @@ -875,7 +873,7 @@ mod tests { #[test] fn test_authorize_voter() { let (vote_pubkey, vote_account) = create_test_account(); - let authorized_voter_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_voter_pubkey = solana_pubkey::new_rand(); let clock = Clock { epoch: 1, leader_schedule_epoch: 2, @@ -1006,7 +1004,7 @@ mod tests { #[test] fn test_authorize_withdrawer() { let (vote_pubkey, vote_account) = create_test_account(); - let authorized_withdrawer_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_withdrawer_pubkey = solana_pubkey::new_rand(); let instruction_data = serialize(&VoteInstruction::Authorize( authorized_withdrawer_pubkey, VoteAuthorize::Withdrawer, @@ -1064,7 +1062,7 @@ mod tests { ); // should pass, verify authorized_withdrawer can authorize a new authorized_voter - let authorized_voter_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_voter_pubkey = solana_pubkey::new_rand(); transaction_accounts.push((authorized_voter_pubkey, AccountSharedData::default())); let instruction_data = serialize(&VoteInstruction::Authorize( authorized_voter_pubkey, @@ -1083,7 +1081,7 @@ mod tests { fn test_vote_withdraw() { let (vote_pubkey, vote_account) = create_test_account(); let lamports = vote_account.lamports(); - let authorized_withdrawer_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_withdrawer_pubkey = solana_pubkey::new_rand(); let mut transaction_accounts = vec![ (vote_pubkey, vote_account.clone()), (sysvar::clock::id(), create_default_clock_account()), @@ -1173,7 +1171,7 @@ mod tests { #[test] fn test_vote_state_withdraw() { - let authorized_withdrawer_pubkey = solana_sdk::pubkey::new_rand(); + let authorized_withdrawer_pubkey = solana_pubkey::new_rand(); let (vote_pubkey_1, vote_account_with_epoch_credits_1) = create_test_account_with_epoch_credits(&[2, 1]); let (vote_pubkey_2, vote_account_with_epoch_credits_2) = diff --git a/programs/vote/src/vote_state/mod.rs b/programs/vote/src/vote_state/mod.rs index fd2d8b96bb2066..d732925bec6ad8 100644 --- a/programs/vote/src/vote_state/mod.rs +++ b/programs/vote/src/vote_state/mod.rs @@ -4,21 +4,18 @@ pub use solana_program::vote::state::{vote_state_versions::*, *}; use { log::*, serde_derive::{Deserialize, Serialize}, + solana_account::{AccountSharedData, ReadableAccount, WritableAccount}, + solana_clock::{Clock, Epoch, Slot, UnixTimestamp}, + solana_epoch_schedule::EpochSchedule, solana_feature_set::{self as feature_set, FeatureSet}, + solana_hash::Hash, + solana_instruction::error::InstructionError, solana_program::vote::{error::VoteError, program::id}, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount, WritableAccount}, - clock::{Epoch, Slot, UnixTimestamp}, - epoch_schedule::EpochSchedule, - hash::Hash, - instruction::InstructionError, - pubkey::Pubkey, - rent::Rent, - slot_hashes::SlotHash, - sysvar::clock::Clock, - transaction_context::{ - BorrowedAccount, IndexOfAccount, InstructionContext, TransactionContext, - }, + solana_pubkey::Pubkey, + solana_rent::Rent, + solana_slot_hashes::SlotHash, + solana_transaction_context::{ + BorrowedAccount, IndexOfAccount, InstructionContext, TransactionContext, }, std::{ cmp::Ordering, @@ -1216,10 +1213,10 @@ mod tests { super::*, crate::vote_state, assert_matches::assert_matches, - solana_sdk::{ - account::AccountSharedData, account_utils::StateMut, clock::DEFAULT_SLOTS_PER_EPOCH, - hash::hash, transaction_context::InstructionAccount, - }, + solana_account::{state_traits::StateMut, AccountSharedData}, + solana_clock::DEFAULT_SLOTS_PER_EPOCH, + solana_sha256_hasher::hash, + solana_transaction_context::InstructionAccount, std::cell::RefCell, test_case::test_case, }; @@ -1229,7 +1226,7 @@ mod tests { fn vote_state_new_for_test(auth_pubkey: &Pubkey) -> VoteState { VoteState::new( &VoteInit { - node_pubkey: solana_sdk::pubkey::new_rand(), + node_pubkey: solana_pubkey::new_rand(), authorized_voter: *auth_pubkey, authorized_withdrawer: *auth_pubkey, commission: 0, @@ -1241,12 +1238,12 @@ mod tests { fn create_test_account() -> (Pubkey, RefCell) { let rent = Rent::default(); let balance = VoteState::get_rent_exempt_reserve(&rent); - let vote_pubkey = solana_sdk::pubkey::new_rand(); + let vote_pubkey = solana_pubkey::new_rand(); ( vote_pubkey, RefCell::new(vote_state::create_account( &vote_pubkey, - &solana_sdk::pubkey::new_rand(), + &solana_pubkey::new_rand(), 0, balance, )), @@ -1257,8 +1254,8 @@ mod tests { fn test_vote_state_upgrade_from_1_14_11() { // Create an initial vote account that is sized for the 1_14_11 version of vote state, and has only the // required lamports for rent exempt minimum at that size - let node_pubkey = solana_sdk::pubkey::new_rand(); - let withdrawer_pubkey = solana_sdk::pubkey::new_rand(); + let node_pubkey = solana_pubkey::new_rand(); + let withdrawer_pubkey = solana_pubkey::new_rand(); let mut vote_state = VoteState::new( &VoteInit { node_pubkey, @@ -1271,20 +1268,17 @@ mod tests { // Simulate prior epochs completed with credits and each setting a new authorized voter vote_state.increment_credits(0, 100); assert_eq!( - vote_state - .set_new_authorized_voter(&solana_sdk::pubkey::new_rand(), 0, 1, |_pubkey| Ok(())), + vote_state.set_new_authorized_voter(&solana_pubkey::new_rand(), 0, 1, |_pubkey| Ok(())), Ok(()) ); vote_state.increment_credits(1, 200); assert_eq!( - vote_state - .set_new_authorized_voter(&solana_sdk::pubkey::new_rand(), 1, 2, |_pubkey| Ok(())), + vote_state.set_new_authorized_voter(&solana_pubkey::new_rand(), 1, 2, |_pubkey| Ok(())), Ok(()) ); vote_state.increment_credits(2, 300); assert_eq!( - vote_state - .set_new_authorized_voter(&solana_sdk::pubkey::new_rand(), 2, 3, |_pubkey| Ok(())), + vote_state.set_new_authorized_voter(&solana_pubkey::new_rand(), 2, 3, |_pubkey| Ok(())), Ok(()) ); // Simulate votes having occurred @@ -1309,7 +1303,7 @@ mod tests { // Create a fake TransactionContext with a fake InstructionContext with a single account which is the // vote account that was just created - let processor_account = AccountSharedData::new(0, 0, &solana_sdk::native_loader::id()); + let processor_account = AccountSharedData::new(0, 0, &solana_sdk_ids::native_loader::id()); let transaction_context = TransactionContext::new( vec![(id(), processor_account), (node_pubkey, vote_account)], rent.clone(), @@ -1464,7 +1458,7 @@ mod tests { // Create a fake TransactionContext with a fake InstructionContext with a single account which is the // vote account that was just created - let processor_account = AccountSharedData::new(0, 0, &solana_sdk::native_loader::id()); + let processor_account = AccountSharedData::new(0, 0, &solana_sdk_ids::native_loader::id()); let transaction_context = TransactionContext::new( vec![(id(), processor_account), (node_pubkey, vote_account)], rent, @@ -1627,7 +1621,7 @@ mod tests { #[test] fn test_vote_double_lockout_after_expiration() { - let voter_pubkey = solana_sdk::pubkey::new_rand(); + let voter_pubkey = solana_pubkey::new_rand(); let mut vote_state = vote_state_new_for_test(&voter_pubkey); for i in 0..3 { @@ -1655,7 +1649,7 @@ mod tests { #[test] fn test_expire_multiple_votes() { - let voter_pubkey = solana_sdk::pubkey::new_rand(); + let voter_pubkey = solana_pubkey::new_rand(); let mut vote_state = vote_state_new_for_test(&voter_pubkey); for i in 0..3 { @@ -1686,7 +1680,7 @@ mod tests { #[test] fn test_vote_credits() { - let voter_pubkey = solana_sdk::pubkey::new_rand(); + let voter_pubkey = solana_pubkey::new_rand(); let mut vote_state = vote_state_new_for_test(&voter_pubkey); for i in 0..MAX_LOCKOUT_HISTORY { @@ -1705,7 +1699,7 @@ mod tests { #[test] fn test_duplicate_vote() { - let voter_pubkey = solana_sdk::pubkey::new_rand(); + let voter_pubkey = solana_pubkey::new_rand(); let mut vote_state = vote_state_new_for_test(&voter_pubkey); process_slot_vote_unchecked(&mut vote_state, 0); process_slot_vote_unchecked(&mut vote_state, 1); @@ -1717,7 +1711,7 @@ mod tests { #[test] fn test_nth_recent_lockout() { - let voter_pubkey = solana_sdk::pubkey::new_rand(); + let voter_pubkey = solana_pubkey::new_rand(); let mut vote_state = vote_state_new_for_test(&voter_pubkey); for i in 0..MAX_LOCKOUT_HISTORY { process_slot_vote_unchecked(&mut vote_state, i as u64); @@ -1760,9 +1754,9 @@ mod tests { /// check that two accounts with different data can be brought to the same state with one vote submission #[test] fn test_process_missed_votes() { - let account_a = solana_sdk::pubkey::new_rand(); + let account_a = solana_pubkey::new_rand(); let mut vote_state_a = vote_state_new_for_test(&account_a); - let account_b = solana_sdk::pubkey::new_rand(); + let account_b = solana_pubkey::new_rand(); let mut vote_state_b = vote_state_new_for_test(&account_b); // process some votes on account a diff --git a/programs/vote/src/vote_transaction.rs b/programs/vote/src/vote_transaction.rs index 4f19b5e01d68cc..ec4a72a98e8057 100644 --- a/programs/vote/src/vote_transaction.rs +++ b/programs/vote/src/vote_transaction.rs @@ -1,14 +1,13 @@ use { + solana_clock::Slot, + solana_hash::Hash, + solana_keypair::Keypair, solana_program::vote::{ self, state::{TowerSync, Vote, VoteStateUpdate}, }, - solana_sdk::{ - clock::Slot, - hash::Hash, - signature::{Keypair, Signer}, - transaction::Transaction, - }, + solana_signer::Signer, + solana_transaction::Transaction, }; pub fn new_vote_transaction( diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index cc303970411206..803c9687a2450d 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -7723,11 +7723,25 @@ dependencies = [ "num-traits", "serde", "serde_derive", + "solana-account", + "solana-bincode", + "solana-clock", + "solana-epoch-schedule", "solana-feature-set", + "solana-hash", + "solana-instruction", + "solana-keypair", "solana-metrics", + "solana-packet", "solana-program", "solana-program-runtime", - "solana-sdk", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-signer", + "solana-slot-hashes", + "solana-transaction", + "solana-transaction-context", "thiserror 2.0.9", ]