Bump max invoke depth to 4 (#12742) (#12764)

(cherry picked from commit 2cd7cd3149)

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-10-09 18:49:44 +00:00
committed by GitHub
parent bb5c76483a
commit 4b9f2e987a
9 changed files with 139 additions and 87 deletions

View File

@@ -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
}
}