Add adjustable stack size and call depth (bp #12728) (#12769)

* Add adjustable stack size and call depth (#12728)

(cherry picked from commit c3907be623)

# Conflicts:
#	programs/bpf/Cargo.lock
#	programs/bpf/Cargo.toml
#	programs/bpf/build.rs
#	programs/bpf_loader/Cargo.toml
#	programs/bpf_loader/src/lib.rs
#	runtime/src/feature_set.rs
#	runtime/src/process_instruction.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-10-09 23:27:59 +00:00
committed by GitHub
parent 079ea91d6f
commit ad31768dd9
12 changed files with 140 additions and 12 deletions

View File

@@ -45,6 +45,10 @@ pub mod max_invoke_depth_4 {
solana_sdk::declare_id!("EdM9xggY5y7AhNMskRG8NgGMnaP4JFNsWi8ZZtyT1af5");
}
pub mod max_program_call_depth_64 {
solana_sdk::declare_id!("YCKSgA6XmjtkQrHBQjpyNrX6EMhJPcYcLWMVgWn36iv");
}
lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@@ -59,6 +63,7 @@ lazy_static! {
(compute_budget_balancing::id(), "compute budget balancing"),
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
(max_invoke_depth_4::id(), "max invoke call depth 4"),
(max_program_call_depth_64::id(), "max program call depth 64")
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()

View File

@@ -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},
@@ -88,6 +90,10 @@ pub struct ComputeBudget {
pub invoke_units: u64,
/// Maximum cross-program invocation depth allowed including the orignal caller
pub max_invoke_depth: usize,
/// 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 {
@@ -105,6 +111,8 @@ impl ComputeBudget {
create_program_address_units: 0,
invoke_units: 0,
max_invoke_depth: 1,
max_call_depth: 20,
stack_frame_size: 4_096,
};
if feature_set.is_active(&compute_budget_balancing::id()) {
@@ -121,9 +129,14 @@ 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
}
}