Skip to content
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
2,722 changes: 1,575 additions & 1,147 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ license = "Apache-2.0"
edition = "2021"

[workspace.metadata.cli]
solana = "2.3.4"
solana = "3.0.0"

[workspace.lints.rust.unexpected_cfgs]
level = "warn"
Expand Down
1 change: 0 additions & 1 deletion clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ thiserror = "1.0"

[dev-dependencies]
assert_matches = "1.5.0"
solana-sdk = "2.2.1"
2 changes: 2 additions & 0 deletions clients/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(non_local_definitions)] // <-- Rustc warning on `FromPrimitive`

mod generated;
mod hooked;

Expand Down
52 changes: 31 additions & 21 deletions program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,43 @@ bpf-entrypoint = []
test-sbf = []

[dependencies]
arrayref = "0.3.8"
bincode = "1.3.3"
borsh = { version = "1.5.1", features = ["derive", "unstable__schema"] }
num-derive = "0.4"
num-traits = "0.2"
num_enum = "0.7.3"
solana-program = "2.2.1"
thiserror = "1.0.63"
solana-account-info = { version = "3.0.0", features = ["bincode"] }
solana-clock = "3.0.0"
solana-cpi = "3.0.0"
solana-instruction-error = "2.0.0"
solana-msg = "3.0.0"
solana-native-token = "3.0.0"
solana-program-entrypoint = "3.0.0"
solana-program-error = "3.0.0"
solana-pubkey = "3.0.0"
solana-rent = "3.0.0"
solana-stake-interface = { version = "2", features = ["bincode", "borsh", "sysvar"] }
solana-sysvar = "3.0.0"
solana-vote-interface = { version = "4.0.1", features = ["bincode"] }

[dev-dependencies]
assert_matches = "1.5.0"
agave-feature-set = "3.0.0"
arbitrary = { version = "1.4.1", features = ["derive"] }
mollusk-svm = { version = "0.4.0", features = ["all-builtins"] }
assert_matches = "1.5.0"
mollusk-svm = { version = "0.6.1", features = ["all-builtins"] }
proptest = "1.6.0"
solana-account = { version = "2.2.1", features = ["bincode"] }
solana-config-interface = { version = "1", features = ["serde"] }
solana-feature-set = "2.2.1"
solana-logger = "2.2.1"
solana-program-test = "2.3.4"
solana-program-runtime = "2.2.0"
solana-stake-interface = { version = "1", features = ["bincode"] }
solana-system-interface = { version = "1", features = ["bincode"] }
solana-vote-program = "2.2.0"
solana-sdk = "2.2.1"
solana-sdk-ids = "2.2.1"
solana-sysvar = { version = "2.2.1", features = ["bincode"] }
rand = "0.8.5"
solana-account = { version = "3.0.0", features = ["bincode"] }
solana-config-interface = { version = "2", features = ["serde"] }
solana-epoch-rewards = "3.0.0"
solana-epoch-schedule = "3.0.0"
solana-instruction = "3.0.0"
solana-keypair = "3.0.0"
solana-logger = "3.0.0"
solana-program-test = "3.0.0"
solana-sdk-ids = "3.0.0"
solana-signature = "3.0.0"
solana-signer = "3.0.0"
solana-system-interface = { version = "2.0.0", features = ["bincode"] }
solana-sysvar-id = "3.0.0"
solana-transaction = "3.0.0"
solana-vote-program = "3.0.0"
test-case = "3.3.1"

[lib]
Expand Down
7 changes: 5 additions & 2 deletions program/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

use {
crate::processor::Processor,
solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg, pubkey::Pubkey},
solana_account_info::AccountInfo,
solana_msg::msg,
solana_program_entrypoint::{entrypoint, ProgramResult},
solana_pubkey::Pubkey,
};

solana_program::entrypoint!(process_instruction);
entrypoint!(process_instruction);
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
Expand Down
18 changes: 8 additions & 10 deletions program/src/helpers/delegate.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use {
crate::PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH,
solana_program::{
account_info::AccountInfo,
clock::Epoch,
program_error::ProgramError,
pubkey::Pubkey,
stake::{
instruction::StakeError,
state::{Delegation, Meta, Stake},
},
solana_account_info::AccountInfo,
solana_clock::Epoch,
solana_program_error::ProgramError,
solana_pubkey::Pubkey,
solana_stake_interface::{
error::StakeError,
state::{Delegation, Meta, Stake},
sysvar::stake_history::StakeHistorySysvar,
vote::state::VoteState,
},
solana_vote_interface::state::VoteStateV3 as VoteState,
};

/// After calling `validate_delegated_amount()`, this struct contains calculated
Expand Down
23 changes: 9 additions & 14 deletions program/src/helpers/merge.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use {
crate::{helpers::checked_add, PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH},
solana_program::{
clock::{Clock, Epoch},
entrypoint::ProgramResult,
msg,
program_error::ProgramError,
stake::{instruction::StakeError, stake_flags::StakeFlags, state::*},
stake_history::StakeHistoryGetEntry,
solana_clock::{Clock, Epoch},
solana_msg::msg,
solana_program_error::{ProgramError, ProgramResult},
solana_stake_interface::{
error::StakeError, stake_flags::StakeFlags, stake_history::StakeHistoryGetEntry, state::*,
},
std::convert::TryFrom,
};
Expand Down Expand Up @@ -233,13 +231,10 @@ mod tests {
super::*,
crate::id,
proptest::prelude::*,
solana_sdk::{
account::{AccountSharedData, ReadableAccount},
account_utils::StateMut,
pubkey::Pubkey,
stake_history::{StakeHistory, StakeHistoryEntry},
sysvar::rent::Rent,
},
solana_account::{state_traits::StateMut, AccountSharedData, ReadableAccount},
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_stake_interface::stake_history::{StakeHistory, StakeHistoryEntry},
};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion program/src/helpers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use solana_program::{instruction::InstructionError, program_error::ProgramError};
use {solana_instruction_error::InstructionError, solana_program_error::ProgramError};

pub(crate) mod delegate;
pub(crate) use delegate::*;
Expand Down
5 changes: 4 additions & 1 deletion program/src/helpers/split.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use solana_program::{program_error::ProgramError, rent::Rent, stake::state::Meta, sysvar::Sysvar};
use {
solana_program_error::ProgramError, solana_rent::Rent, solana_stake_interface::state::Meta,
solana_sysvar::Sysvar,
};

/// After calling `validate_split_amount()`, this struct contains calculated
/// values that are used by the caller.
Expand Down
6 changes: 2 additions & 4 deletions program/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use solana_program::native_token::LAMPORTS_PER_SOL;
use solana_native_token::LAMPORTS_PER_SOL;

pub mod helpers;
pub mod processor;

#[cfg(feature = "bpf-entrypoint")]
pub mod entrypoint;

pub use solana_program;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could eventually re-export some core types, but I haven't found that super useful in the past, so I'm happy to have this removal

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me! ✂️


solana_program::declare_id!("Stake11111111111111111111111111111111111111");
solana_pubkey::declare_id!("Stake11111111111111111111111111111111111111");

// placeholders for features
// we have ONE feature in the current stake program we care about:
Expand Down
43 changes: 21 additions & 22 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
use {
crate::{helpers::*, id, PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH},
solana_program::{
account_info::{next_account_info, AccountInfo},
clock::Clock,
entrypoint::ProgramResult,
msg,
program::set_return_data,
program_error::ProgramError,
pubkey::Pubkey,
rent::Rent,
stake::{
instruction::{
AuthorizeCheckedWithSeedArgs, AuthorizeWithSeedArgs, LockupArgs, LockupCheckedArgs,
StakeError, StakeInstruction,
},
stake_flags::StakeFlags,
state::{Authorized, Lockup, Meta, StakeAuthorize, StakeStateV2},
tools::{acceptable_reference_epoch_credits, eligible_for_deactivate_delinquent},
solana_account_info::{next_account_info, AccountInfo},
solana_clock::Clock,
solana_cpi::set_return_data,
solana_msg::msg,
solana_program_error::{ProgramError, ProgramResult},
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_stake_interface::{
error::StakeError,
instruction::{
AuthorizeCheckedWithSeedArgs, AuthorizeWithSeedArgs, LockupArgs, LockupCheckedArgs,
StakeInstruction,
},
sysvar::{epoch_rewards::EpochRewards, stake_history::StakeHistorySysvar, Sysvar},
vote::{program as solana_vote_program, state::VoteState},
stake_flags::StakeFlags,
state::{Authorized, Lockup, Meta, StakeAuthorize, StakeStateV2},
sysvar::stake_history::StakeHistorySysvar,
tools::{acceptable_reference_epoch_credits, eligible_for_deactivate_delinquent},
},
solana_sysvar::{epoch_rewards::EpochRewards, Sysvar, SysvarSerialize},
solana_vote_interface::{program as solana_vote_program, state::VoteStateV3 as VoteState},
std::{collections::HashSet, mem::MaybeUninit},
};

Expand Down Expand Up @@ -582,7 +581,7 @@ impl Processor {

// Truncate state upon zero balance
if split_lamports == source_lamport_balance {
source_stake_account_info.realloc(0, false)?;
source_stake_account_info.resize(0)?;
}

relocate_lamports(
Expand Down Expand Up @@ -677,7 +676,7 @@ impl Processor {
}

// Truncate state upon zero balance
source_stake_account_info.realloc(0, false)?;
source_stake_account_info.resize(0)?;
} else {
// a partial withdrawal must not deplete the reserve
let withdraw_lamports_and_reserve = checked_add(withdraw_lamports, reserve)?;
Expand Down Expand Up @@ -794,7 +793,7 @@ impl Processor {
}

// Source is about to be drained, truncate its state
source_stake_account_info.realloc(0, false)?;
source_stake_account_info.resize(0)?;

// Drain the source stake account
relocate_lamports(
Expand Down
43 changes: 21 additions & 22 deletions program/tests/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@ use {
arbitrary::{Arbitrary, Unstructured},
mollusk_svm::{result::Check, Mollusk},
solana_account::{Account, ReadableAccount, WritableAccount},
solana_sdk::{
instruction::{AccountMeta, Instruction},
native_token::LAMPORTS_PER_SOL,
pubkey::Pubkey,
stake::{
instruction::{self, LockupArgs},
stake_flags::StakeFlags,
state::{
warmup_cooldown_rate, Authorized, Delegation, Lockup, Meta, Stake, StakeAuthorize,
StakeStateV2, NEW_WARMUP_COOLDOWN_RATE,
},
},
stake_history::StakeHistoryEntry,
sysvar::{
clock::Clock, epoch_rewards::EpochRewards, epoch_schedule::EpochSchedule, rent::Rent,
stake_history::StakeHistory, SysvarId,
},
vote::{
program as vote_program,
state::{VoteState, VoteStateVersions},
solana_clock::Clock,
solana_epoch_rewards::EpochRewards,
solana_epoch_schedule::EpochSchedule,
solana_instruction::{AccountMeta, Instruction},
solana_native_token::LAMPORTS_PER_SOL,
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_sdk_ids::system_program,
solana_stake_interface::{
instruction::{self, LockupArgs},
stake_flags::StakeFlags,
stake_history::{StakeHistory, StakeHistoryEntry},
state::{
warmup_cooldown_rate, Authorized, Delegation, Lockup, Meta, Stake, StakeAuthorize,
StakeStateV2, NEW_WARMUP_COOLDOWN_RATE,
},
},
solana_sdk_ids::system_program,
solana_stake_program::{get_minimum_delegation, id},
solana_sysvar_id::SysvarId,
solana_vote_interface::{
program as vote_program,
state::{VoteStateV3 as VoteState, VoteStateVersions},
},
std::{
collections::{HashMap, HashSet},
sync::LazyLock,
Expand Down Expand Up @@ -165,7 +164,7 @@ impl Env {

// create two vote accounts
let vote_rent_exemption = Rent::default().minimum_balance(VoteState::size_of());
let vote_state_versions = VoteStateVersions::new_current(VoteState::default());
let vote_state_versions = VoteStateVersions::new_v3(VoteState::default());
let vote_data = bincode::serialize(&vote_state_versions).unwrap();
let vote_account = Account::create(
vote_rent_exemption,
Expand Down
32 changes: 15 additions & 17 deletions program/tests/program_test.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#![allow(clippy::arithmetic_side_effects)]

use {
solana_account::Account as SolanaAccount,
solana_clock::Clock,
solana_instruction::Instruction,
solana_keypair::Keypair,
solana_program_entrypoint::ProgramResult,
solana_program_error::ProgramError,
solana_program_test::*,
solana_sdk::{
account::Account as SolanaAccount,
entrypoint::ProgramResult,
instruction::Instruction,
program_error::ProgramError,
pubkey::Pubkey,
signature::{Keypair, Signer},
signers::Signers,
sysvar::rent::Rent,
transaction::{Transaction, TransactionError},
vote::{
instruction as vote_instruction,
state::{VoteInit, VoteState, VoteStateVersions},
},
},
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_sdk_ids::system_program,
solana_signer::Signer,
solana_stake_interface::{
error::StakeError,
instruction::{self as ixn, LockupArgs},
Expand All @@ -26,7 +20,11 @@ use {
state::{Authorized, Delegation, Lockup, Meta, Stake, StakeAuthorize, StakeStateV2},
},
solana_system_interface::instruction as system_instruction,
solana_sysvar::clock::Clock,
solana_transaction::{Signers, Transaction, TransactionError},
solana_vote_interface::{
instruction as vote_instruction,
state::{VoteInit, VoteStateV3 as VoteState},
},
test_case::{test_case, test_matrix},
};

Expand Down Expand Up @@ -115,7 +113,7 @@ pub async fn create_vote(
},
rent_voter,
vote_instruction::CreateVoteAccountConfig {
space: VoteStateVersions::vote_state_size_of(true) as u64,
space: VoteState::size_of() as u64,
..Default::default()
},
));
Expand Down
Loading