* Add adjustable stack size and call depth (#12728)
(cherry picked from commit c3907be623)
# Conflicts:
# programs/bpf/Cargo.toml
# programs/bpf_loader/Cargo.toml
* resolve conflicts
Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
use crate::feature_set::{compute_budget_balancing, max_invoke_depth_4, FeatureSet};
|
||||
use crate::feature_set::{
|
||||
compute_budget_balancing, max_invoke_depth_4, max_program_call_depth_64, FeatureSet,
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::{Account, KeyedAccount},
|
||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||
@@ -92,6 +94,10 @@ pub struct ComputeBudget {
|
||||
pub sha256_base_cost: u64,
|
||||
/// Incremental number of units consumed by sha256 (based on bytes)
|
||||
pub sha256_byte_cost: u64,
|
||||
/// Maximum BPF to BPF call depth
|
||||
pub max_call_depth: usize,
|
||||
/// Size of a stack frame in bytes, must match the size specified in the LLVM BPF backend
|
||||
pub stack_frame_size: usize,
|
||||
}
|
||||
impl Default for ComputeBudget {
|
||||
fn default() -> Self {
|
||||
@@ -111,6 +117,8 @@ impl ComputeBudget {
|
||||
max_invoke_depth: 1,
|
||||
sha256_base_cost: 85,
|
||||
sha256_byte_cost: 1,
|
||||
max_call_depth: 20,
|
||||
stack_frame_size: 4_096,
|
||||
};
|
||||
|
||||
if feature_set.is_active(&compute_budget_balancing::id()) {
|
||||
@@ -127,9 +135,15 @@ impl ComputeBudget {
|
||||
compute_budget = ComputeBudget {
|
||||
max_invoke_depth: 4,
|
||||
..compute_budget
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if feature_set.is_active(&max_program_call_depth_64::id()) {
|
||||
compute_budget = ComputeBudget {
|
||||
max_call_depth: 64,
|
||||
..compute_budget
|
||||
};
|
||||
}
|
||||
compute_budget
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user