Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove solana-sdk from vote-program #4331

Merged
merged 1 commit into from
Jan 9, 2025
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
17 changes: 16 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions programs/vote/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,38 @@ 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",
] }
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]
Expand All @@ -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]
Expand Down
18 changes: 8 additions & 10 deletions programs/vote/benches/process_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion programs/vote/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
66 changes: 32 additions & 34 deletions programs/vote/src/vote_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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},
};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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()),
Expand Down Expand Up @@ -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) =
Expand Down
Loading
Loading