Bump max invoke depth to 4 (#12742)
This commit is contained in:
@ -33,7 +33,7 @@ pub mod bpf_loader2_program {
|
||||
solana_sdk::declare_id!("DFBnrgThdzH4W6wZ12uGPoWcMnvfZj11EHnxHcVxLPhD");
|
||||
}
|
||||
|
||||
pub mod compute_budget_config2 {
|
||||
pub mod compute_budget_balancing {
|
||||
solana_sdk::declare_id!("HxvjqDSiF5sYdSYuCXsUnS8UeAoWsMT9iGoFP8pgV1mB");
|
||||
}
|
||||
|
||||
@ -49,6 +49,10 @@ pub mod ristretto_mul_syscall_enabled {
|
||||
solana_sdk::declare_id!("HRe7A6aoxgjKzdjbBv6HTy7tJ4YWqE6tVmYCGho6S9Aq");
|
||||
}
|
||||
|
||||
pub mod max_invoke_depth_4 {
|
||||
solana_sdk::declare_id!("EdM9xggY5y7AhNMskRG8NgGMnaP4JFNsWi8ZZtyT1af5");
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
/// Map of feature identifiers to user-visible description
|
||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||
@ -59,10 +63,11 @@ lazy_static! {
|
||||
(inflation_kill_switch::id(), "inflation kill switch"),
|
||||
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
||||
(bpf_loader2_program::id(), "bpf_loader2 program"),
|
||||
(compute_budget_config2::id(), "1ms compute budget"),
|
||||
(compute_budget_balancing::id(), "compute budget balancing"),
|
||||
(sha256_syscall_enabled::id(), "sha256 syscall"),
|
||||
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
||||
(ristretto_mul_syscall_enabled::id(), "ristretto multiply syscall"),
|
||||
(max_invoke_depth_4::id(), "max invoke call depth 4"),
|
||||
/*************** ADD NEW FEATURES HERE ***************/
|
||||
]
|
||||
.iter()
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
feature_set::{compute_budget_config2, instructions_sysvar_enabled, FeatureSet},
|
||||
feature_set::{instructions_sysvar_enabled, FeatureSet},
|
||||
instruction_recorder::InstructionRecorder,
|
||||
log_collector::LogCollector,
|
||||
native_loader::NativeLoader,
|
||||
@ -244,7 +244,7 @@ impl ThisInvokeContext {
|
||||
}
|
||||
impl InvokeContext for ThisInvokeContext {
|
||||
fn push(&mut self, key: &Pubkey) -> Result<(), InstructionError> {
|
||||
if self.program_ids.len() >= self.compute_budget.max_invoke_depth {
|
||||
if self.program_ids.len() > self.compute_budget.max_invoke_depth {
|
||||
return Err(InstructionError::CallDepth);
|
||||
}
|
||||
if self.program_ids.contains(key) && self.program_ids.last() != Some(key) {
|
||||
@ -416,21 +416,7 @@ impl MessageProcessor {
|
||||
}
|
||||
|
||||
fn get_compute_budget(feature_set: &FeatureSet) -> ComputeBudget {
|
||||
if feature_set.is_active(&compute_budget_config2::id()) {
|
||||
ComputeBudget::default()
|
||||
} else {
|
||||
// Original
|
||||
ComputeBudget {
|
||||
max_units: 100_000,
|
||||
log_units: 0,
|
||||
log_64_units: 0,
|
||||
create_program_address_units: 0,
|
||||
invoke_units: 0,
|
||||
max_invoke_depth: 2,
|
||||
sha256_base_cost: 0,
|
||||
sha256_byte_cost: 0,
|
||||
}
|
||||
}
|
||||
ComputeBudget::new(feature_set)
|
||||
}
|
||||
|
||||
/// Create the KeyedAccounts that will be passed to the program
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::feature_set::{compute_budget_balancing, max_invoke_depth_4, FeatureSet};
|
||||
use solana_sdk::{
|
||||
account::{Account, KeyedAccount},
|
||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||
@ -94,17 +95,42 @@ pub struct ComputeBudget {
|
||||
}
|
||||
impl Default for ComputeBudget {
|
||||
fn default() -> Self {
|
||||
// Tuned for ~1ms
|
||||
Self::new(&FeatureSet::all_enabled())
|
||||
}
|
||||
}
|
||||
impl ComputeBudget {
|
||||
pub fn new(feature_set: &FeatureSet) -> Self {
|
||||
let mut compute_budget =
|
||||
// Original
|
||||
ComputeBudget {
|
||||
max_units: 200_000,
|
||||
log_units: 100,
|
||||
log_64_units: 100,
|
||||
create_program_address_units: 1500,
|
||||
invoke_units: 1000,
|
||||
max_invoke_depth: 2,
|
||||
max_units: 100_000,
|
||||
log_units: 0,
|
||||
log_64_units: 0,
|
||||
create_program_address_units: 0,
|
||||
invoke_units: 0,
|
||||
max_invoke_depth: 1,
|
||||
sha256_base_cost: 85,
|
||||
sha256_byte_cost: 1,
|
||||
};
|
||||
|
||||
if feature_set.is_active(&compute_budget_balancing::id()) {
|
||||
compute_budget = ComputeBudget {
|
||||
max_units: 200_000,
|
||||
log_units: 100,
|
||||
log_64_units: 100,
|
||||
create_program_address_units: 1500,
|
||||
invoke_units: 1000,
|
||||
..compute_budget
|
||||
};
|
||||
}
|
||||
if feature_set.is_active(&max_invoke_depth_4::id()) {
|
||||
compute_budget = ComputeBudget {
|
||||
max_invoke_depth: 4,
|
||||
..compute_budget
|
||||
}
|
||||
}
|
||||
|
||||
compute_budget
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user