diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index ec3c5a7647eebe..896a8baad9cac7 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -213,7 +213,7 @@ fn bank_forks_from_snapshot( genesis_config, &process_options.runtime_config, process_options.debug_keys.clone(), - Some(&crate::builtins::get()), + None, process_options.account_indexes.clone(), process_options.limit_load_slot_count_from_snapshot, process_options.shrink_ratio, diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index c0d3ca6d7494f7..19bced5877fe11 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -713,7 +713,7 @@ pub(crate) fn process_blockstore_for_bank_0( Arc::new(opts.runtime_config.clone()), account_paths, opts.debug_keys.clone(), - Some(&crate::builtins::get()), + None, opts.account_indexes.clone(), opts.shrink_ratio, false, diff --git a/ledger/src/builtins.rs b/ledger/src/builtins.rs deleted file mode 100644 index 2bbead8635c691..00000000000000 --- a/ledger/src/builtins.rs +++ /dev/null @@ -1,38 +0,0 @@ -use { - solana_program_runtime::builtin_program::BuiltinProgram, - solana_runtime::builtins::{BuiltinFeatureTransition, Builtins}, - solana_sdk::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable}, -}; - -/// Builtin programs that are always available -fn genesis_builtins() -> Vec { - vec![ - BuiltinProgram { - name: "solana_bpf_loader_deprecated_program".to_string(), - program_id: bpf_loader_deprecated::id(), - process_instruction: solana_bpf_loader_program::process_instruction, - }, - BuiltinProgram { - name: "solana_bpf_loader_program".to_string(), - program_id: bpf_loader::id(), - process_instruction: solana_bpf_loader_program::process_instruction, - }, - BuiltinProgram { - name: "solana_bpf_loader_upgradeable_program".to_string(), - program_id: bpf_loader_upgradeable::id(), - process_instruction: solana_bpf_loader_program::process_instruction, - }, - ] -} - -/// Dynamic feature transitions for builtin programs -fn builtin_feature_transitions() -> Vec { - vec![] -} - -pub(crate) fn get() -> Builtins { - Builtins { - genesis_builtins: genesis_builtins(), - feature_transitions: builtin_feature_transitions(), - } -} diff --git a/ledger/src/lib.rs b/ledger/src/lib.rs index 847729dbfea312..98b677f60ad755 100644 --- a/ledger/src/lib.rs +++ b/ledger/src/lib.rs @@ -14,7 +14,6 @@ pub mod blockstore_meta; pub mod blockstore_metrics; pub mod blockstore_options; pub mod blockstore_processor; -pub mod builtins; pub mod genesis_utils; pub mod leader_schedule; pub mod leader_schedule_cache; diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 0f8ddc978f2467..87369ab9a663c7 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -72,9 +72,6 @@ pub use { pub mod programs; -#[macro_use] -extern crate solana_bpf_loader_program; - /// Errors from the program test environment #[derive(Error, Debug, PartialEq, Eq)] pub enum ProgramTestError { @@ -787,16 +784,6 @@ impl ProgramTest { }), ); - // Add loaders - macro_rules! add_builtin { - ($b:expr) => { - bank.add_builtin(&$b.0, &$b.1, $b.2) - }; - } - add_builtin!(solana_bpf_loader_deprecated_program!()); - add_builtin!(solana_bpf_loader_program!()); - add_builtin!(solana_bpf_loader_upgradeable_program!()); - // Add commonly-used SPL programs as a convenience to the user for (program_id, account) in programs::spl_programs(&Rent::default()).iter() { bank.store_account(program_id, account); diff --git a/programs/bpf-loader-tests/tests/common.rs b/programs/bpf-loader-tests/tests/common.rs index e4e6d2eb254f5e..eeaf957a7e140c 100644 --- a/programs/bpf-loader-tests/tests/common.rs +++ b/programs/bpf-loader-tests/tests/common.rs @@ -1,12 +1,12 @@ #![allow(dead_code)] use { - solana_bpf_loader_program::{process_instruction, upgradeable::id}, + solana_bpf_loader_program::process_instruction, solana_program_test::*, solana_sdk::{ account::AccountSharedData, account_utils::StateMut, - bpf_loader_upgradeable::UpgradeableLoaderState, + bpf_loader_upgradeable::{id, UpgradeableLoaderState}, instruction::{Instruction, InstructionError}, pubkey::Pubkey, signature::{Keypair, Signer}, diff --git a/programs/bpf_loader/src/deprecated.rs b/programs/bpf_loader/src/deprecated.rs deleted file mode 100644 index 3c1ee26602dda5..00000000000000 --- a/programs/bpf_loader/src/deprecated.rs +++ /dev/null @@ -1,6 +0,0 @@ -solana_sdk::declare_builtin!( - solana_sdk::bpf_loader_deprecated::ID, - solana_bpf_loader_deprecated_program, - solana_bpf_loader_program::process_instruction, - deprecated::id -); diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index cc5ee285a10985..cf4f841cadf89c 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -1,10 +1,8 @@ #![deny(clippy::integer_arithmetic)] #![deny(clippy::indexing_slicing)] -pub mod deprecated; pub mod serialization; pub mod syscalls; -pub mod upgradeable; use { solana_measure::measure::Measure, @@ -61,12 +59,6 @@ use { }, }; -solana_sdk::declare_builtin!( - solana_sdk::bpf_loader::ID, - solana_bpf_loader_program, - solana_bpf_loader_program::process_instruction -); - #[allow(clippy::too_many_arguments)] pub fn load_program_from_bytes( feature_set: &FeatureSet, diff --git a/programs/bpf_loader/src/upgradeable.rs b/programs/bpf_loader/src/upgradeable.rs deleted file mode 100644 index 89aaed9fb5e260..00000000000000 --- a/programs/bpf_loader/src/upgradeable.rs +++ /dev/null @@ -1,6 +0,0 @@ -solana_sdk::declare_builtin!( - solana_sdk::bpf_loader_upgradeable::ID, - solana_bpf_loader_upgradeable_program, - solana_bpf_loader_program::process_instruction, - upgradeable::id -); diff --git a/programs/sbf/benches/bpf_loader.rs b/programs/sbf/benches/bpf_loader.rs index 8c5358c408338d..a2ba7df20fa841 100644 --- a/programs/sbf/benches/bpf_loader.rs +++ b/programs/sbf/benches/bpf_loader.rs @@ -6,8 +6,6 @@ use {solana_rbpf::memory_region::MemoryState, std::slice}; extern crate test; -#[macro_use] -extern crate solana_bpf_loader_program; use { byteorder::{ByteOrder, LittleEndian, WriteBytesExt}, @@ -193,9 +191,7 @@ fn bench_program_execute_noop(bencher: &mut Bencher) { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_benches(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_benches(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); diff --git a/programs/sbf/tests/programs.rs b/programs/sbf/tests/programs.rs index a06363a947680d..7861b3d0a2935e 100644 --- a/programs/sbf/tests/programs.rs +++ b/programs/sbf/tests/programs.rs @@ -9,9 +9,6 @@ #![allow(clippy::unnecessary_cast)] #![allow(clippy::uninlined_format_args)] -#[macro_use] -extern crate solana_bpf_loader_program; - #[cfg(feature = "sbf_rust")] use { itertools::izip, @@ -313,9 +310,7 @@ fn test_program_sbf_sanity() { .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); // Call user program @@ -361,9 +356,7 @@ fn test_program_sbf_loader_deprecated() { .accounts .remove(&solana_sdk::feature_set::disable_deploy_of_alloc_free_syscall::id()) .unwrap(); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_deprecated_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let program_id = create_program(&bank, &bpf_loader_deprecated::id(), program); let bank_client = BankClient::new(bank); @@ -389,9 +382,6 @@ fn test_sol_alloc_free_no_longer_deployable() { } = create_genesis_config(50); let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); - // Populate loader account with elf that depends on _sol_alloc_free syscall let elf = load_program_from_file("solana_sbf_rust_deprecated_loader"); let mut program_account = AccountSharedData::new(1, elf.len(), &bpf_loader::id()); @@ -481,9 +471,7 @@ fn test_program_sbf_duplicate_accounts() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program); @@ -582,9 +570,7 @@ fn test_program_sbf_error_handling() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program); let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)]; @@ -684,9 +670,7 @@ fn test_return_data_and_log_data_syscall() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -749,9 +733,7 @@ fn test_program_sbf_invoke_sanity() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -1144,9 +1126,7 @@ fn test_program_sbf_program_id_spoofing() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -1197,9 +1177,7 @@ fn test_program_sbf_caller_has_access_to_cpi_program() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -1237,9 +1215,7 @@ fn test_program_sbf_ro_modify() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -1294,9 +1270,7 @@ fn test_program_sbf_call_depth() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); let program_id = load_program( &bank_client, @@ -1329,9 +1303,7 @@ fn test_program_sbf_compute_budget() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); let program_id = load_program( &bank_client, @@ -1457,10 +1429,7 @@ fn test_program_sbf_instruction_introspection() { mint_keypair, .. } = create_genesis_config(50_000); - let mut bank = Bank::new_for_tests(&genesis_config); - - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -1518,9 +1487,7 @@ fn test_program_sbf_test_use_latest_executor() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); let panic_id = load_program( &bank_client, @@ -1587,9 +1554,7 @@ fn test_program_sbf_upgrade() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); // Deploy upgrade program @@ -1718,9 +1683,7 @@ fn test_program_sbf_invoke_stable_genesis_and_bank() { mint_keypair, .. } = get_stable_genesis_config(); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -1894,9 +1857,7 @@ fn test_program_sbf_invoke_in_same_tx_as_deployment() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -1990,9 +1951,7 @@ fn test_program_sbf_invoke_in_same_tx_as_redeployment() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -2094,9 +2053,7 @@ fn test_program_sbf_invoke_in_same_tx_as_undeployment() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -2183,11 +2140,7 @@ fn test_program_sbf_invoke_upgradeable_via_cpi() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); let invoke_and_return = load_program( &bank_client, @@ -2308,8 +2261,6 @@ fn test_program_sbf_disguised_as_sbf_loader() { let mut feature_set = FeatureSet::all_enabled(); feature_set.deactivate(&solana_sdk::feature_set::native_programs_consume_cu::id()); bank.feature_set = Arc::new(feature_set); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); bank.deactivate_feature( &solana_sdk::feature_set::remove_bpf_loader_incorrect_program_id::id(), ); @@ -2336,9 +2287,7 @@ fn test_program_reads_from_program_account() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); let program_id = load_program( @@ -2364,9 +2313,7 @@ fn test_program_sbf_c_dup() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let account_address = Pubkey::new_unique(); let account = AccountSharedData::new_data(42, &[1_u8, 2, 3], &system_program::id()).unwrap(); @@ -2395,11 +2342,7 @@ fn test_program_sbf_upgrade_via_cpi() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); let invoke_and_return = load_program( &bank_client, @@ -2502,11 +2445,7 @@ fn test_program_sbf_set_upgrade_authority_via_cpi() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank_client = BankClient::new(bank); // Deploy CPI invoker program @@ -2595,9 +2534,7 @@ fn test_program_upgradeable_locks() { mint_keypair, .. } = create_genesis_config(2_000_000_000); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -2716,9 +2653,7 @@ fn test_program_sbf_finalize() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -2762,9 +2697,7 @@ fn test_program_sbf_ro_account_modify() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -2829,9 +2762,7 @@ fn test_program_sbf_realloc() { let mint_pubkey = mint_keypair.pubkey(); let signer = &[&mint_keypair]; - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -3126,9 +3057,7 @@ fn test_program_sbf_realloc_invoke() { let mint_pubkey = mint_keypair.pubkey(); let signer = &[&mint_keypair]; - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -3644,9 +3573,7 @@ fn test_program_sbf_processed_inner_instruction() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -3728,9 +3655,6 @@ fn test_program_fees() { FeeStructure::new(0.000005, 0.0, vec![(200, 0.0000005), (1400000, 0.000005)]); bank.fee_structure = fee_structure.clone(); bank.feature_set = Arc::new(FeatureSet::all_enabled()); - - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); let bank_client = BankClient::new(bank); let program_id = load_program( @@ -3803,9 +3727,6 @@ fn test_get_minimum_delegation() { } = create_genesis_config(100_123_456_789); let mut bank = Bank::new_for_tests(&genesis_config); bank.feature_set = Arc::new(FeatureSet::all_enabled()); - - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -3832,11 +3753,7 @@ fn test_program_sbf_inner_instruction_alignment_checks() { mint_keypair, .. } = create_genesis_config(50); - let mut bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - bank.add_builtin(&name, &id, entrypoint); - let (name, id, entrypoint) = solana_bpf_loader_deprecated_program!(); - bank.add_builtin(&name, &id, entrypoint); + let bank = Bank::new_for_tests(&genesis_config); let noop = create_program(&bank, &bpf_loader_deprecated::id(), "solana_sbf_rust_noop"); let inner_instruction_alignment_check = create_program( &bank, diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index e52aa8f0892c5d..08869f4eea4da4 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -30,7 +30,6 @@ use { rand::Rng, rayon::ThreadPoolBuilder, serde::{Deserialize, Serialize}, - solana_bpf_loader_program::solana_bpf_loader_program, solana_logger, solana_program_runtime::{ compute_budget::{self, ComputeBudget, MAX_COMPUTE_UNIT_LIMIT}, @@ -6922,25 +6921,25 @@ fn test_bank_hash_consistency() { if bank.slot == 0 { assert_eq!( bank.hash().to_string(), - "5gY6TCgB9NymbbxgFgAjvYLpXjyXiVyyruS1aEwbWKLK" + "FVZwMQ5YJiivwGctYDvPcoQrTECbUaNcmTnJeFDdb1a3" ); } if bank.slot == 32 { assert_eq!( bank.hash().to_string(), - "6uJ5C4QDXWCN39EjJ5Frcz73nnS2jMJ55KgkQff12Fqp" + "5AMuFif3LzgsBV8JXGVwdJpHbpZpYKRtcvyrfZjhMGvx" ); } if bank.slot == 64 { assert_eq!( bank.hash().to_string(), - "Ddk6ouAvSSA1U3Cw6BoKdM5v5LdRc9ShruGDzci9fKbY" + "GDmYzhnPdXoFLvbr88vPoVF5EYyUbCZJLMWBG9JJv8DQ" ); } if bank.slot == 128 { assert_eq!( bank.hash().to_string(), - "ANodC5vnedLWqeAyhcoErzR3ptNansb5YX6UTQ9cfP7S" + "J6Q2ng27mQMyDF2g7CbKSQDwZAeeaNnkUUZifax3FR9Y" ); break; } @@ -7164,7 +7163,7 @@ fn test_shrink_candidate_slots_cached() { // No more slots should be shrunk assert_eq!(bank2.shrink_candidate_slots(), 0); // alive_counts represents the count of alive accounts in the three slots 0,1,2 - assert_eq!(alive_counts, vec![11, 1, 7]); + assert_eq!(alive_counts, vec![14, 1, 7]); } #[test] @@ -7828,11 +7827,6 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() { let (genesis_config, mint_keypair) = create_genesis_config(1_000_000_000); let mut bank = Bank::new_for_tests(&genesis_config); bank.feature_set = Arc::new(FeatureSet::all_enabled()); - bank.add_builtin( - "solana_bpf_loader_upgradeable_program", - &bpf_loader_upgradeable::id(), - solana_bpf_loader_program::process_instruction, - ); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(&bank); @@ -12752,8 +12746,6 @@ fn test_runtime_feature_enable_with_executor_cache() { .accounts .remove(&feature_set::reject_callx_r10::id()); let mut root_bank = Bank::new_for_tests(&genesis_config); - let (name, id, entrypoint) = solana_bpf_loader_program!(); - root_bank.add_builtin(&name, &id, entrypoint); // Test a basic transfer let amount = genesis_config.rent.minimum_balance(0); diff --git a/runtime/src/builtins.rs b/runtime/src/builtins.rs index 7396f21c7a4006..12164fc67a804c 100644 --- a/runtime/src/builtins.rs +++ b/runtime/src/builtins.rs @@ -1,6 +1,8 @@ use { solana_program_runtime::builtin_program::BuiltinProgram, - solana_sdk::{feature_set, pubkey::Pubkey}, + solana_sdk::{ + bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, feature_set, pubkey::Pubkey, + }, }; #[derive(Clone, Debug)] @@ -94,6 +96,21 @@ fn genesis_builtins() -> Vec { program_id: solana_config_program::id(), process_instruction: solana_config_program::config_processor::process_instruction, }, + BuiltinProgram { + name: "solana_bpf_loader_deprecated_program".to_string(), + program_id: bpf_loader_deprecated::id(), + process_instruction: solana_bpf_loader_program::process_instruction, + }, + BuiltinProgram { + name: "solana_bpf_loader_program".to_string(), + program_id: bpf_loader::id(), + process_instruction: solana_bpf_loader_program::process_instruction, + }, + BuiltinProgram { + name: "solana_bpf_loader_upgradeable_program".to_string(), + program_id: bpf_loader_upgradeable::id(), + process_instruction: solana_bpf_loader_program::process_instruction, + }, ] } diff --git a/runtime/src/genesis_utils.rs b/runtime/src/genesis_utils.rs index dcaf2157e7d04a..45acf5c9ef305e 100644 --- a/runtime/src/genesis_utils.rs +++ b/runtime/src/genesis_utils.rs @@ -26,7 +26,7 @@ pub fn bootstrap_validator_stake_lamports() -> u64 { // Number of lamports automatically used for genesis accounts pub const fn genesis_sysvar_and_builtin_program_lamports() -> u64 { - const NUM_BUILTIN_PROGRAMS: u64 = 4; + const NUM_BUILTIN_PROGRAMS: u64 = 7; const NUM_PRECOMPILES: u64 = 2; const FEES_SYSVAR_MIN_BALANCE: u64 = 946_560; const STAKE_HISTORY_MIN_BALANCE: u64 = 114_979_200; diff --git a/sdk/src/builtins.rs b/sdk/src/builtins.rs deleted file mode 100644 index e837abcdb26e0d..00000000000000 --- a/sdk/src/builtins.rs +++ /dev/null @@ -1,77 +0,0 @@ -//! Solana helper macros for declaring built-in programs. - -#[rustversion::since(1.46.0)] -#[macro_export] -macro_rules! declare_builtin_name { - ($name:ident, $id:path, $entrypoint:expr) => { - #[macro_export] - macro_rules! $name { - () => { - // Subtle: - // The outer `declare_builtin_name!` macro may be expanded in another - // crate, causing the macro `$name!` to be defined in that - // crate. We want to emit a call to `$crate::id()`, and have - // `$crate` be resolved in the crate where `$name!` gets defined, - // *not* in this crate (where `declare_builtin_name! is defined). - // - // When a macro_rules! macro gets expanded, any $crate tokens - // in its output will be 'marked' with the crate they were expanded - // from. This includes nested macros like our macro `$name` - even - // though it looks like a separate macro, Rust considers it to be - // just another part of the output of `declare_program!`. - // - // We pass `$name` as the second argument to tell `respan!` to - // apply use the `Span` of `$name` when resolving `$crate::id`. - // This causes `$crate` to behave as though it was written - // at the same location as the `$name` value passed - // to `declare_builtin_name!` (e.g. the 'foo' in - // `declare_builtin_name(foo)` - // - // See the `respan!` macro for more details. - // This should use `crate::respan!` once - // https://github.com/rust-lang/rust/pull/72121 is merged: - // see https://github.com/solana-labs/solana/issues/10933. - // For now, we need to use `::solana_sdk` - // - // `respan!` respans the path `$crate::id`, which we then call (hence the extra - // parens) - ( - stringify!($name).to_string(), - ::solana_sdk::respan!($crate::$id, $name)(), - $entrypoint, - ) - }; - } - }; -} - -#[rustversion::not(since(1.46.0))] -#[macro_export] -macro_rules! declare_builtin_name { - ($name:ident, $id:path, $entrypoint:expr) => { - #[macro_export] - macro_rules! $name { - () => { - (stringify!($name).to_string(), $crate::$id(), $entrypoint) - }; - } - }; -} - -/// Convenience macro to declare a built-in program. -/// -/// bs58_string: bs58 string representation the program's id -/// name: Name of the program -/// entrypoint: Program's entrypoint, must be of `type Entrypoint` -/// id: Path to the program id access function, used if this macro is not -/// called in `src/lib` -#[macro_export] -macro_rules! declare_builtin { - ($bs58_string:expr, $name:ident, $entrypoint:expr) => { - $crate::declare_builtin!($bs58_string, $name, $entrypoint, id); - }; - ($bs58_string:expr, $name:ident, $entrypoint:expr, $id:path) => { - $crate::declare_id!($bs58_string); - $crate::declare_builtin_name!($name, $id, $entrypoint); - }; -} diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index a18ac583a8e3f6..acea5822b7a85b 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -57,7 +57,6 @@ pub use solana_program::{ pub mod account; pub mod account_utils; -pub mod builtins; pub mod client; pub mod commitment_config; pub mod compute_budget;