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 bpf-loader-program #4322

Merged
merged 1 commit into from
Jan 8, 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
28 changes: 27 additions & 1 deletion Cargo.lock

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

31 changes: 29 additions & 2 deletions programs/bpf_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,53 @@ bincode = { workspace = true }
byteorder = { workspace = true }
libsecp256k1 = { workspace = true }
scopeguard = { workspace = true }
solana-account = { workspace = true }
solana-account-info = { workspace = true }
solana-bincode = { workspace = true }
solana-bn254 = { workspace = true }
solana-clock = { workspace = true }
solana-compute-budget = { workspace = true }
solana-cpi = { workspace = true }
solana-curve25519 = { workspace = true }
solana-define-syscall = { workspace = true }
solana-feature-set = { workspace = true }
solana-hash = { workspace = true }
solana-instruction = { workspace = true }
solana-keccak-hasher = { workspace = true }
solana-log-collector = { workspace = true }
solana-measure = { workspace = true }
solana-packet = { workspace = true }
solana-poseidon = { workspace = true }
solana-precompiles = { workspace = true }
solana-program = { workspace = true }
solana-program-entrypoint = { workspace = true }
solana-program-memory = { workspace = true }
solana-program-runtime = { workspace = true, features = ["metrics"] }
solana-pubkey = { workspace = true }
solana-sbpf = { workspace = true }
solana-sdk = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-secp256k1-recover = { workspace = true }
solana-sha256-hasher = { workspace = true }
solana-stable-layout = { workspace = true }
solana-system-interface = { workspace = true }
solana-sysvar = { workspace = true }
solana-sysvar-id = { workspace = true }
solana-timings = { workspace = true }
solana-transaction-context = { workspace = true, features = ["bincode"] }
solana-type-overrides = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
assert_matches = { workspace = true }
rand = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
solana-epoch-rewards = { workspace = true }
solana-epoch-schedule = { workspace = true }
solana-fee-calculator = { workspace = true }
solana-last-restart-slot = { workspace = true }
solana-pubkey = { workspace = true, features = ["rand"] }
solana-rent = { workspace = true }
solana-slot-hashes = { workspace = true }
solana-transaction-context = { workspace = true, features = ["dev-context-only-utils"] }
test-case = { workspace = true }

[lib]
Expand Down
26 changes: 12 additions & 14 deletions programs/bpf_loader/benches/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
extern crate test;

use {
solana_account::{Account, AccountSharedData},
solana_bpf_loader_program::serialization::serialize_parameters,
solana_sdk::{
account::{Account, AccountSharedData},
bpf_loader, bpf_loader_deprecated,
pubkey::Pubkey,
sysvar::rent::Rent,
transaction_context::{IndexOfAccount, InstructionAccount, TransactionContext},
},
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_sdk_ids::{bpf_loader, bpf_loader_deprecated},
solana_transaction_context::{IndexOfAccount, InstructionAccount, TransactionContext},
test::Bencher,
};

fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionContext {
let program_id = solana_sdk::pubkey::new_rand();
let program_id = solana_pubkey::new_rand();
let transaction_accounts = vec![
(
program_id,
Expand All @@ -28,7 +26,7 @@ fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionC
}),
),
(
solana_sdk::pubkey::new_rand(),
solana_pubkey::new_rand(),
AccountSharedData::from(Account {
lamports: 1,
data: vec![1u8; 100000],
Expand All @@ -38,7 +36,7 @@ fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionC
}),
),
(
solana_sdk::pubkey::new_rand(),
solana_pubkey::new_rand(),
AccountSharedData::from(Account {
lamports: 2,
data: vec![11u8; 100000],
Expand All @@ -48,7 +46,7 @@ fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionC
}),
),
(
solana_sdk::pubkey::new_rand(),
solana_pubkey::new_rand(),
AccountSharedData::from(Account {
lamports: 3,
data: vec![],
Expand All @@ -58,7 +56,7 @@ fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionC
}),
),
(
solana_sdk::pubkey::new_rand(),
solana_pubkey::new_rand(),
AccountSharedData::from(Account {
lamports: 4,
data: vec![1u8; 100000],
Expand All @@ -68,7 +66,7 @@ fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionC
}),
),
(
solana_sdk::pubkey::new_rand(),
solana_pubkey::new_rand(),
AccountSharedData::from(Account {
lamports: 5,
data: vec![11u8; 10000],
Expand All @@ -78,7 +76,7 @@ fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionC
}),
),
(
solana_sdk::pubkey::new_rand(),
solana_pubkey::new_rand(),
AccountSharedData::from(Account {
lamports: 6,
data: vec![],
Expand Down
57 changes: 27 additions & 30 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ pub mod serialization;
pub mod syscalls;

use {
solana_account::WritableAccount,
solana_bincode::limited_deserialize,
solana_clock::Slot,
solana_compute_budget::compute_budget::MAX_INSTRUCTION_STACK_DEPTH,
solana_feature_set::{
bpf_account_data_direct_mapping, enable_bpf_loader_set_authority_checked_ix,
remove_accounts_executable_flag_checks,
},
solana_instruction::{error::InstructionError, AccountMeta},
solana_log_collector::{ic_logger_msg, ic_msg, LogCollector},
solana_measure::measure::Measure,
solana_program::{
bpf_loader_upgradeable::UpgradeableLoaderState,
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
},
solana_program_entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
solana_program_runtime::{
invoke_context::{BpfAllocator, InvokeContext, SerializedAccountMetadata, SyscallContext},
loaded_programs::{
Expand All @@ -22,6 +31,7 @@ use {
stable_log,
sysvar_cache::get_sysvar_with_account_check,
},
solana_pubkey::Pubkey,
solana_sbpf::{
declare_builtin_function,
ebpf::{self, MM_HEAP_START},
Expand All @@ -32,20 +42,11 @@ use {
verifier::RequisiteVerifier,
vm::{ContextObject, EbpfVm},
},
solana_sdk::{
account::WritableAccount,
bpf_loader, bpf_loader_deprecated,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::Slot,
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
instruction::{AccountMeta, InstructionError},
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
loader_v4, native_loader,
program_utils::limited_deserialize,
pubkey::Pubkey,
system_instruction::{self, MAX_PERMITTED_DATA_LENGTH},
transaction_context::{IndexOfAccount, InstructionContext, TransactionContext},
solana_sdk_ids::{
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, loader_v4, native_loader,
},
solana_system_interface::{instruction as system_instruction, MAX_PERMITTED_DATA_LENGTH},
solana_transaction_context::{IndexOfAccount, InstructionContext, TransactionContext},
solana_type_overrides::sync::{atomic::Ordering, Arc},
std::{cell::RefCell, mem, rc::Rc},
syscalls::{create_program_runtime_environment_v1, morph_into_deployment_environment_v1},
Expand Down Expand Up @@ -511,7 +512,7 @@ fn process_loader_upgradeable_instruction(
let instruction_data = instruction_context.get_instruction_data();
let program_id = instruction_context.get_last_program_key(transaction_context)?;

match limited_deserialize(instruction_data)? {
match limited_deserialize(instruction_data, solana_packet::PACKET_DATA_SIZE as u64)? {
UpgradeableLoaderInstruction::InitializeBuffer => {
instruction_context.check_number_of_instruction_accounts(2)?;
let mut buffer =
Expand Down Expand Up @@ -677,7 +678,7 @@ fn process_loader_upgradeable_instruction(
let signers = [[new_program_id.as_ref(), &[bump_seed]]]
.iter()
.map(|seeds| Pubkey::create_program_address(seeds, caller_program_id))
.collect::<Result<Vec<Pubkey>, solana_sdk::pubkey::PubkeyError>>()?;
.collect::<Result<Vec<Pubkey>, solana_pubkey::PubkeyError>>()?;
invoke_context.native_invoke(instruction.into(), signers.as_slice())?;

// Load and verify the program bits
Expand Down Expand Up @@ -1572,9 +1573,8 @@ pub fn execute<'a, 'b: 'a>(

pub mod test_utils {
use {
super::*,
super::*, solana_account::ReadableAccount, solana_program::loader_v4::LoaderV4State,
solana_program_runtime::loaded_programs::DELAY_VISIBILITY_SLOT_OFFSET,
solana_sdk::{account::ReadableAccount, loader_v4::LoaderV4State},
};

pub fn load_all_invoked_programs(invoke_context: &mut InvokeContext) {
Expand Down Expand Up @@ -1637,22 +1637,19 @@ mod tests {
super::*,
assert_matches::assert_matches,
rand::Rng,
solana_account::{
create_account_shared_data_for_test as create_account_for_test, state_traits::StateMut,
AccountSharedData, ReadableAccount, WritableAccount,
},
solana_clock::Clock,
solana_epoch_schedule::EpochSchedule,
solana_instruction::{error::InstructionError, AccountMeta},
solana_program_runtime::{
invoke_context::mock_process_instruction, with_mock_invoke_context,
},
solana_sdk::{
account::{
create_account_shared_data_for_test as create_account_for_test, AccountSharedData,
ReadableAccount, WritableAccount,
},
account_utils::StateMut,
clock::Clock,
epoch_schedule::EpochSchedule,
instruction::{AccountMeta, InstructionError},
pubkey::Pubkey,
rent::Rent,
system_program, sysvar,
},
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_sdk_ids::{system_program, sysvar},
std::{fs::File, io::Read, ops::Range, sync::atomic::AtomicU64},
};

Expand Down
Loading
Loading