Add compute budget program as a noop (#20992)
This commit is contained in:
@ -14779,6 +14779,60 @@ pub(crate) mod tests {
|
|||||||
assert_eq!(rent_debits.0.len(), 2);
|
assert_eq!(rent_debits.0.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_compute_budget_program_noop() {
|
||||||
|
solana_logger::setup();
|
||||||
|
let GenesisConfigInfo {
|
||||||
|
mut genesis_config,
|
||||||
|
mint_keypair,
|
||||||
|
..
|
||||||
|
} = create_genesis_config_with_leader(
|
||||||
|
1_000_000_000_000_000,
|
||||||
|
&Pubkey::new_unique(),
|
||||||
|
bootstrap_validator_stake_lamports(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// activate all features except..
|
||||||
|
activate_all_features(&mut genesis_config);
|
||||||
|
genesis_config
|
||||||
|
.accounts
|
||||||
|
.remove(&feature_set::tx_wide_compute_cap::id());
|
||||||
|
genesis_config
|
||||||
|
.accounts
|
||||||
|
.remove(&feature_set::requestable_heap_size::id());
|
||||||
|
let mut bank = Bank::new_for_tests(&genesis_config);
|
||||||
|
|
||||||
|
fn mock_ix_processor(
|
||||||
|
_first_instruction_account: usize,
|
||||||
|
_data: &[u8],
|
||||||
|
invoke_context: &mut dyn InvokeContext,
|
||||||
|
) -> std::result::Result<(), InstructionError> {
|
||||||
|
let compute_budget = invoke_context.get_compute_budget();
|
||||||
|
assert_eq!(
|
||||||
|
*compute_budget,
|
||||||
|
ComputeBudget {
|
||||||
|
max_units: 200_000,
|
||||||
|
heap_size: None,
|
||||||
|
..ComputeBudget::default()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
let program_id = solana_sdk::pubkey::new_rand();
|
||||||
|
bank.add_builtin("mock_program", &program_id, mock_ix_processor);
|
||||||
|
|
||||||
|
let message = Message::new(
|
||||||
|
&[
|
||||||
|
ComputeBudgetInstruction::request_units(1),
|
||||||
|
ComputeBudgetInstruction::request_heap_frame(48 * 1024),
|
||||||
|
Instruction::new_with_bincode(program_id, &0, vec![]),
|
||||||
|
],
|
||||||
|
Some(&mint_keypair.pubkey()),
|
||||||
|
);
|
||||||
|
let tx = Transaction::new(&[&mint_keypair], message, bank.last_blockhash());
|
||||||
|
bank.process_transaction(&tx).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_compute_request_instruction() {
|
fn test_compute_request_instruction() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
@ -158,7 +158,7 @@ fn feature_builtins() -> Vec<(Builtin, Pubkey, ActivationType)> {
|
|||||||
solana_sdk::compute_budget::id(),
|
solana_sdk::compute_budget::id(),
|
||||||
solana_compute_budget_program::process_instruction,
|
solana_compute_budget_program::process_instruction,
|
||||||
),
|
),
|
||||||
feature_set::tx_wide_compute_cap::id(),
|
feature_set::add_compute_budget_program::id(),
|
||||||
ActivationType::NewProgram,
|
ActivationType::NewProgram,
|
||||||
),
|
),
|
||||||
// TODO when feature `prevent_calling_precompiles_as_programs` is
|
// TODO when feature `prevent_calling_precompiles_as_programs` is
|
||||||
|
@ -253,6 +253,10 @@ pub mod disable_fee_calculator {
|
|||||||
solana_sdk::declare_id!("2jXx2yDmGysmBKfKYNgLj2DQyAQv6mMk2BPh4eSbyB4H");
|
solana_sdk::declare_id!("2jXx2yDmGysmBKfKYNgLj2DQyAQv6mMk2BPh4eSbyB4H");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod add_compute_budget_program {
|
||||||
|
solana_sdk::declare_id!("4d5AKtxoh93Dwm1vHXUU3iRATuMndx1c431KgT2td52r");
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Map of feature identifiers to user-visible description
|
/// Map of feature identifiers to user-visible description
|
||||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||||
@ -311,6 +315,7 @@ lazy_static! {
|
|||||||
(turbine_peers_shuffle::id(), "turbine peers shuffle patch"),
|
(turbine_peers_shuffle::id(), "turbine peers shuffle patch"),
|
||||||
(requestable_heap_size::id(), "Requestable heap frame size"),
|
(requestable_heap_size::id(), "Requestable heap frame size"),
|
||||||
(disable_fee_calculator::id(), "deprecate fee calculator"),
|
(disable_fee_calculator::id(), "deprecate fee calculator"),
|
||||||
|
(add_compute_budget_program::id(), "Add compute_budget_program"),
|
||||||
/*************** ADD NEW FEATURES HERE ***************/
|
/*************** ADD NEW FEATURES HERE ***************/
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
Reference in New Issue
Block a user