Cleanup - `disable_deprecated_loader` (#29653)
* Removes the gating of disable_deprecated_loader. * Adds create_program(). Renames create_deprecated_program() -> load_program(). Renames load_and_finalize_deprecated_program() -> load_and_finalize_program(). * Fixes test_sol_alloc_free_no_longer_deployable().
This commit is contained in:
parent
2b88401ef7
commit
9d1a0c52f8
|
@ -42,9 +42,8 @@ use {
|
|||
feature_set::{
|
||||
cap_accounts_data_allocations_per_transaction, cap_bpf_program_instruction_accounts,
|
||||
check_slice_translation_size, disable_deploy_of_alloc_free_syscall,
|
||||
disable_deprecated_loader, enable_bpf_loader_extend_program_ix,
|
||||
enable_bpf_loader_set_authority_checked_ix, enable_program_redeployment_cooldown,
|
||||
limit_max_instruction_trace_length, FeatureSet,
|
||||
enable_bpf_loader_extend_program_ix, enable_bpf_loader_set_authority_checked_ix,
|
||||
enable_program_redeployment_cooldown, limit_max_instruction_trace_length, FeatureSet,
|
||||
},
|
||||
instruction::{AccountMeta, InstructionError},
|
||||
loader_instruction::LoaderInstruction,
|
||||
|
@ -439,20 +438,15 @@ fn process_instruction_common(
|
|||
} else {
|
||||
drop(program);
|
||||
debug_assert_eq!(first_instruction_account, 1);
|
||||
let disable_deprecated_loader = invoke_context
|
||||
.feature_set
|
||||
.is_active(&disable_deprecated_loader::id());
|
||||
if bpf_loader_upgradeable::check_id(program_id) {
|
||||
process_loader_upgradeable_instruction(
|
||||
first_instruction_account,
|
||||
invoke_context,
|
||||
use_jit,
|
||||
)
|
||||
} else if bpf_loader::check_id(program_id)
|
||||
|| (!disable_deprecated_loader && bpf_loader_deprecated::check_id(program_id))
|
||||
{
|
||||
} else if bpf_loader::check_id(program_id) {
|
||||
process_loader_instruction(first_instruction_account, invoke_context, use_jit)
|
||||
} else if disable_deprecated_loader && bpf_loader_deprecated::check_id(program_id) {
|
||||
} else if bpf_loader_deprecated::check_id(program_id) {
|
||||
ic_logger_msg!(log_collector, "Deprecated loader is no longer supported");
|
||||
Err(InstructionError::UnsupportedProgramId)
|
||||
} else {
|
||||
|
|
|
@ -26,7 +26,7 @@ use {
|
|||
bank::Bank,
|
||||
bank_client::BankClient,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
loader_utils::{create_deprecated_program, load_program_from_file},
|
||||
loader_utils::{load_program, load_program_from_file},
|
||||
},
|
||||
solana_sdk::{
|
||||
bpf_loader,
|
||||
|
@ -159,8 +159,7 @@ fn bench_program_execute_noop(bencher: &mut Bencher) {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let invoke_program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, "noop");
|
||||
let invoke_program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, "noop");
|
||||
|
||||
let mint_pubkey = mint_keypair.pubkey();
|
||||
let account_metas = vec![AccountMeta::new(mint_pubkey, true)];
|
||||
|
|
|
@ -21,9 +21,9 @@ use {
|
|||
TransactionExecutionResult, TransactionResults,
|
||||
},
|
||||
loader_utils::{
|
||||
create_deprecated_program, load_and_finalize_deprecated_program,
|
||||
load_program_from_file, load_upgradeable_buffer, load_upgradeable_program,
|
||||
set_upgrade_authority, upgrade_program,
|
||||
create_program, load_and_finalize_program, load_program, load_program_from_file,
|
||||
load_upgradeable_buffer, load_upgradeable_program, set_upgrade_authority,
|
||||
upgrade_program,
|
||||
},
|
||||
},
|
||||
solana_sbf_rust_invoke::instructions::*,
|
||||
|
@ -421,8 +421,7 @@ fn test_program_sbf_sanity() {
|
|||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Call user program
|
||||
let program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.0);
|
||||
let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.0);
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||
AccountMeta::new(Keypair::new().pubkey(), false),
|
||||
|
@ -460,10 +459,6 @@ fn test_program_sbf_loader_deprecated() {
|
|||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(50);
|
||||
genesis_config
|
||||
.accounts
|
||||
.remove(&solana_sdk::feature_set::disable_deprecated_loader::id())
|
||||
.unwrap();
|
||||
genesis_config
|
||||
.accounts
|
||||
.remove(&solana_sdk::feature_set::disable_deploy_of_alloc_free_syscall::id())
|
||||
|
@ -471,14 +466,9 @@ fn test_program_sbf_loader_deprecated() {
|
|||
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_client = BankClient::new(bank);
|
||||
let program_id = create_program(&bank, &bpf_loader_deprecated::id(), program);
|
||||
|
||||
let program_id = create_deprecated_program(
|
||||
&bank_client,
|
||||
&bpf_loader_deprecated::id(),
|
||||
&mint_keypair,
|
||||
program,
|
||||
);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
||||
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas);
|
||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||
|
@ -493,7 +483,6 @@ fn test_sol_alloc_free_no_longer_deployable() {
|
|||
|
||||
let program_keypair = Keypair::new();
|
||||
let program_address = program_keypair.pubkey();
|
||||
let loader_address = bpf_loader_deprecated::id();
|
||||
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
|
@ -502,13 +491,12 @@ fn test_sol_alloc_free_no_longer_deployable() {
|
|||
} = create_genesis_config(50);
|
||||
let mut bank = Bank::new_for_tests(&genesis_config);
|
||||
|
||||
bank.deactivate_feature(&solana_sdk::feature_set::disable_deprecated_loader::id());
|
||||
let (name, id, entrypoint) = solana_bpf_loader_deprecated_program!();
|
||||
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(), &loader_address);
|
||||
let mut program_account = AccountSharedData::new(1, elf.len(), &bpf_loader::id());
|
||||
program_account
|
||||
.data_as_mut_slice()
|
||||
.get_mut(..)
|
||||
|
@ -521,7 +509,7 @@ fn test_sol_alloc_free_no_longer_deployable() {
|
|||
Message::new(
|
||||
&[loader_instruction::finalize(
|
||||
&program_keypair.pubkey(),
|
||||
&loader_address,
|
||||
&bpf_loader::id(),
|
||||
)],
|
||||
Some(&mint_keypair.pubkey()),
|
||||
),
|
||||
|
@ -600,8 +588,7 @@ fn test_program_sbf_duplicate_accounts() {
|
|||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
let program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
let payee_account = AccountSharedData::new(10, 1, &program_id);
|
||||
let payee_pubkey = Pubkey::new_unique();
|
||||
bank.store_account(&payee_pubkey, &payee_account);
|
||||
|
@ -701,8 +688,7 @@ fn test_program_sbf_error_handling() {
|
|||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
||||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
||||
|
||||
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas.clone());
|
||||
|
@ -806,8 +792,7 @@ fn test_return_data_and_log_data_syscall() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
|
||||
bank.freeze();
|
||||
|
||||
|
@ -873,11 +858,11 @@ fn test_program_sbf_invoke_sanity() {
|
|||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let invoke_program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.1);
|
||||
load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.1);
|
||||
let invoked_program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.2);
|
||||
load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.2);
|
||||
let noop_program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.3);
|
||||
load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program.3);
|
||||
|
||||
let argument_keypair = Keypair::new();
|
||||
let account = AccountSharedData::new(42, 100, &invoke_program_id);
|
||||
|
@ -1269,13 +1254,13 @@ fn test_program_sbf_program_id_spoofing() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let malicious_swap_pubkey = create_deprecated_program(
|
||||
let malicious_swap_pubkey = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_spoof1",
|
||||
);
|
||||
let malicious_system_pubkey = create_deprecated_program(
|
||||
let malicious_system_pubkey = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1322,13 +1307,13 @@ fn test_program_sbf_caller_has_access_to_cpi_program() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let caller_pubkey = create_deprecated_program(
|
||||
let caller_pubkey = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_caller_access",
|
||||
);
|
||||
let caller2_pubkey = create_deprecated_program(
|
||||
let caller2_pubkey = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1362,7 +1347,7 @@ fn test_program_sbf_ro_modify() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_pubkey = create_deprecated_program(
|
||||
let program_pubkey = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1417,7 +1402,7 @@ fn test_program_sbf_call_depth() {
|
|||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
||||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let program_id = create_deprecated_program(
|
||||
let program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1452,7 +1437,7 @@ fn test_program_sbf_compute_budget() {
|
|||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
||||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let program_id = create_deprecated_program(
|
||||
let program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1553,7 +1538,7 @@ fn test_program_sbf_instruction_introspection() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_id = create_deprecated_program(
|
||||
let program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1611,7 +1596,7 @@ fn test_program_sbf_test_use_latest_executor() {
|
|||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
||||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let panic_id = create_deprecated_program(
|
||||
let panic_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1619,7 +1604,7 @@ fn test_program_sbf_test_use_latest_executor() {
|
|||
);
|
||||
|
||||
// Write the panic program into the program account
|
||||
let (program_keypair, instruction) = load_and_finalize_deprecated_program(
|
||||
let (program_keypair, instruction) = load_and_finalize_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
None,
|
||||
|
@ -1640,7 +1625,7 @@ fn test_program_sbf_test_use_latest_executor() {
|
|||
.is_err());
|
||||
|
||||
// Write the noop program into the same program account
|
||||
let (program_keypair, instruction) = load_and_finalize_deprecated_program(
|
||||
let (program_keypair, instruction) = load_and_finalize_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
Some(program_keypair),
|
||||
|
@ -1848,7 +1833,7 @@ fn test_program_sbf_invoke_upgradeable_via_cpi() {
|
|||
let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!();
|
||||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let invoke_and_return = create_deprecated_program(
|
||||
let invoke_and_return = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -1965,8 +1950,7 @@ fn test_program_sbf_disguised_as_sbf_loader() {
|
|||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
let program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||
let account_metas = vec![AccountMeta::new_readonly(program_id, false)];
|
||||
let instruction = Instruction::new_with_bytes(bpf_loader::id(), &[1], account_metas);
|
||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||
|
@ -1997,8 +1981,7 @@ fn test_program_sbf_c_dup() {
|
|||
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
let program_id =
|
||||
create_deprecated_program(&bank_client, &bpf_loader::id(), &mint_keypair, "ser");
|
||||
let program_id = load_program(&bank_client, &bpf_loader::id(), &mint_keypair, "ser");
|
||||
let account_metas = vec![
|
||||
AccountMeta::new_readonly(account_address, false),
|
||||
AccountMeta::new_readonly(account_address, false),
|
||||
|
@ -2025,7 +2008,7 @@ fn test_program_sbf_upgrade_via_cpi() {
|
|||
let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!();
|
||||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let invoke_and_return = create_deprecated_program(
|
||||
let invoke_and_return = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -2133,7 +2116,7 @@ fn test_program_sbf_upgrade_self_via_cpi() {
|
|||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
let noop_program_id = create_deprecated_program(
|
||||
let noop_program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -2223,7 +2206,7 @@ fn test_program_sbf_set_upgrade_authority_via_cpi() {
|
|||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Deploy CPI invoker program
|
||||
let invoke_and_return = create_deprecated_program(
|
||||
let invoke_and_return = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -2435,7 +2418,7 @@ fn test_program_sbf_finalize() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_pubkey = create_deprecated_program(
|
||||
let program_pubkey = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -2443,7 +2426,7 @@ fn test_program_sbf_finalize() {
|
|||
);
|
||||
|
||||
// Write the noop program into the same program account
|
||||
let (program_keypair, _instruction) = load_and_finalize_deprecated_program(
|
||||
let (program_keypair, _instruction) = load_and_finalize_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
None,
|
||||
|
@ -2481,7 +2464,7 @@ fn test_program_sbf_ro_account_modify() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_id = create_deprecated_program(
|
||||
let program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -2548,7 +2531,7 @@ fn test_program_sbf_realloc() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_id = create_deprecated_program(
|
||||
let program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -2856,14 +2839,14 @@ fn test_program_sbf_realloc_invoke() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let realloc_program_id = create_deprecated_program(
|
||||
let realloc_program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_realloc",
|
||||
);
|
||||
|
||||
let realloc_invoke_program_id = create_deprecated_program(
|
||||
let realloc_invoke_program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -3398,25 +3381,25 @@ fn test_program_sbf_processed_inner_instruction() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let sibling_program_id = create_deprecated_program(
|
||||
let sibling_program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_sibling_instructions",
|
||||
);
|
||||
let sibling_inner_program_id = create_deprecated_program(
|
||||
let sibling_inner_program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_sibling_inner_instructions",
|
||||
);
|
||||
let noop_program_id = create_deprecated_program(
|
||||
let noop_program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_noop",
|
||||
);
|
||||
let invoke_and_return_program_id = create_deprecated_program(
|
||||
let invoke_and_return_program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -3481,7 +3464,7 @@ fn test_program_fees() {
|
|||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
let program_id = create_deprecated_program(
|
||||
let program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -3553,7 +3536,7 @@ fn test_get_minimum_delegation() {
|
|||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_id = create_deprecated_program(
|
||||
let program_id = load_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
|
@ -3572,39 +3555,25 @@ fn test_program_sbf_inner_instruction_alignment_checks() {
|
|||
solana_logger::setup();
|
||||
|
||||
let GenesisConfigInfo {
|
||||
mut genesis_config,
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(50);
|
||||
genesis_config
|
||||
.accounts
|
||||
.remove(&solana_sdk::feature_set::disable_deprecated_loader::id())
|
||||
.unwrap();
|
||||
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_client = BankClient::new(bank);
|
||||
|
||||
// load aligned program
|
||||
let noop = create_deprecated_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_noop",
|
||||
);
|
||||
|
||||
// Load unaligned program
|
||||
let inner_instruction_alignment_check = create_deprecated_program(
|
||||
&bank_client,
|
||||
let noop = create_program(&bank, &bpf_loader_deprecated::id(), "solana_sbf_rust_noop");
|
||||
let inner_instruction_alignment_check = create_program(
|
||||
&bank,
|
||||
&bpf_loader_deprecated::id(),
|
||||
&mint_keypair,
|
||||
"solana_sbf_rust_inner_instruction_alignment_check",
|
||||
);
|
||||
|
||||
// invoke unaligned program, which will call aligned program twice,
|
||||
// unaligned should be allowed once invoke completes
|
||||
let bank_client = BankClient::new(bank);
|
||||
let mut instruction = Instruction::new_with_bytes(
|
||||
inner_instruction_alignment_check,
|
||||
&[0],
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use {
|
||||
crate::bank_client::BankClient,
|
||||
crate::{bank::Bank, bank_client::BankClient},
|
||||
serde::Serialize,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, WritableAccount},
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
client::{Client, SyncClient},
|
||||
clock::Clock,
|
||||
|
@ -33,7 +34,22 @@ pub fn load_program_from_file(name: &str) -> Vec<u8> {
|
|||
program
|
||||
}
|
||||
|
||||
pub fn load_and_finalize_deprecated_program<T: Client>(
|
||||
// Creates an unverified program by bypassing the loader built-in program
|
||||
pub fn create_program(bank: &Bank, loader_id: &Pubkey, name: &str) -> Pubkey {
|
||||
let program_id = Pubkey::new_unique();
|
||||
let elf = load_program_from_file(name);
|
||||
let mut program_account = AccountSharedData::new(1, elf.len(), loader_id);
|
||||
program_account
|
||||
.data_as_mut_slice()
|
||||
.get_mut(..)
|
||||
.unwrap()
|
||||
.copy_from_slice(&elf);
|
||||
program_account.set_executable(true);
|
||||
bank.store_account(&program_id, &program_account);
|
||||
program_id
|
||||
}
|
||||
|
||||
pub fn load_and_finalize_program<T: Client>(
|
||||
bank_client: &T,
|
||||
loader_id: &Pubkey,
|
||||
program_keypair: Option<Keypair>,
|
||||
|
@ -75,14 +91,14 @@ pub fn load_and_finalize_deprecated_program<T: Client>(
|
|||
(program_keypair, instruction)
|
||||
}
|
||||
|
||||
pub fn create_deprecated_program<T: Client>(
|
||||
pub fn load_program<T: Client>(
|
||||
bank_client: &T,
|
||||
loader_id: &Pubkey,
|
||||
payer_keypair: &Keypair,
|
||||
name: &str,
|
||||
) -> Pubkey {
|
||||
let (program_keypair, instruction) =
|
||||
load_and_finalize_deprecated_program(bank_client, loader_id, None, payer_keypair, name);
|
||||
load_and_finalize_program(bank_client, loader_id, None, payer_keypair, name);
|
||||
let message = Message::new(&[instruction], Some(&payer_keypair.pubkey()));
|
||||
bank_client
|
||||
.send_and_confirm_message(&[payer_keypair, &program_keypair], message)
|
||||
|
|
Loading…
Reference in New Issue