Refactor: Rename `max_invoke_depth` to `max_invoke_stack_height` (#28427)
Refactor: Rename max_invoke_depth to max_invoke_stack_height
This commit is contained in:
parent
108a02cfd4
commit
70445b7402
|
@ -84,7 +84,7 @@ max_units: 1,400,000,
|
||||||
log_u64_units: 100,
|
log_u64_units: 100,
|
||||||
create_program address units: 1500,
|
create_program address units: 1500,
|
||||||
invoke_units: 1000,
|
invoke_units: 1000,
|
||||||
max_invoke_depth: 4,
|
max_invoke_stack_height: 5,
|
||||||
max_instruction_trace_length: 64,
|
max_instruction_trace_length: 64,
|
||||||
max_call_depth: 64,
|
max_call_depth: 64,
|
||||||
stack_frame_size: 4096,
|
stack_frame_size: 4096,
|
||||||
|
@ -97,7 +97,7 @@ Then any transaction:
|
||||||
- Could execute 1,400,000 BPF instructions, if it did nothing else.
|
- Could execute 1,400,000 BPF instructions, if it did nothing else.
|
||||||
- Cannot exceed 4k of stack usage.
|
- Cannot exceed 4k of stack usage.
|
||||||
- Cannot exceed a BPF call depth of 64.
|
- Cannot exceed a BPF call depth of 64.
|
||||||
- Cannot exceed 4 levels of cross-program invocations.
|
- Cannot exceed invoke stack height of 5 (4 levels of cross-program invocations).
|
||||||
|
|
||||||
> **NOTE:** Since the compute budget is consumed incrementally as the transaction executes,
|
> **NOTE:** Since the compute budget is consumed incrementally as the transaction executes,
|
||||||
> the total budget consumption will be a combination of the various costs of the
|
> the total budget consumption will be a combination of the various costs of the
|
||||||
|
|
|
@ -35,8 +35,11 @@ pub struct ComputeBudget {
|
||||||
/// Number of compute units consumed by an invoke call (not including the cost incurred by
|
/// Number of compute units consumed by an invoke call (not including the cost incurred by
|
||||||
/// the called program)
|
/// the called program)
|
||||||
pub invoke_units: u64,
|
pub invoke_units: u64,
|
||||||
/// Maximum cross-program invocation depth allowed
|
/// Maximum program instruction invocation stack height. Invocation stack
|
||||||
pub max_invoke_depth: usize,
|
/// height starts at 1 for transaction instructions and the stack height is
|
||||||
|
/// incremented each time a program invokes an instruction and decremented
|
||||||
|
/// when a program returns.
|
||||||
|
pub max_invoke_stack_height: usize,
|
||||||
/// Maximum cross-program invocation and instructions per transaction
|
/// Maximum cross-program invocation and instructions per transaction
|
||||||
pub max_instruction_trace_length: usize,
|
pub max_instruction_trace_length: usize,
|
||||||
/// Base number of compute units consumed to call SHA256
|
/// Base number of compute units consumed to call SHA256
|
||||||
|
@ -113,7 +116,7 @@ impl ComputeBudget {
|
||||||
log_64_units: 100,
|
log_64_units: 100,
|
||||||
create_program_address_units: 1500,
|
create_program_address_units: 1500,
|
||||||
invoke_units: 1000,
|
invoke_units: 1000,
|
||||||
max_invoke_depth: 4,
|
max_invoke_stack_height: 5,
|
||||||
max_instruction_trace_length: 64,
|
max_instruction_trace_length: 64,
|
||||||
sha256_base_cost: 85,
|
sha256_base_cost: 85,
|
||||||
sha256_byte_cost: 1,
|
sha256_byte_cost: 1,
|
||||||
|
|
|
@ -931,7 +931,7 @@ pub fn with_mock_invoke_context<R, F: FnMut(&mut InvokeContext) -> R>(
|
||||||
let mut transaction_context = TransactionContext::new(
|
let mut transaction_context = TransactionContext::new(
|
||||||
preparation.transaction_accounts,
|
preparation.transaction_accounts,
|
||||||
Some(Rent::default()),
|
Some(Rent::default()),
|
||||||
compute_budget.max_invoke_depth.saturating_add(1),
|
compute_budget.max_invoke_stack_height,
|
||||||
compute_budget.max_instruction_trace_length,
|
compute_budget.max_instruction_trace_length,
|
||||||
);
|
);
|
||||||
transaction_context.enable_cap_accounts_data_allocations_per_transaction();
|
transaction_context.enable_cap_accounts_data_allocations_per_transaction();
|
||||||
|
@ -967,7 +967,7 @@ pub fn mock_process_instruction(
|
||||||
let mut transaction_context = TransactionContext::new(
|
let mut transaction_context = TransactionContext::new(
|
||||||
preparation.transaction_accounts,
|
preparation.transaction_accounts,
|
||||||
Some(Rent::default()),
|
Some(Rent::default()),
|
||||||
compute_budget.max_invoke_depth.saturating_add(1),
|
compute_budget.max_invoke_stack_height,
|
||||||
compute_budget.max_instruction_trace_length,
|
compute_budget.max_instruction_trace_length,
|
||||||
);
|
);
|
||||||
transaction_context.enable_cap_accounts_data_allocations_per_transaction();
|
transaction_context.enable_cap_accounts_data_allocations_per_transaction();
|
||||||
|
@ -1190,7 +1190,7 @@ mod tests {
|
||||||
let mut transaction_context = TransactionContext::new(
|
let mut transaction_context = TransactionContext::new(
|
||||||
accounts,
|
accounts,
|
||||||
Some(Rent::default()),
|
Some(Rent::default()),
|
||||||
ComputeBudget::default().max_invoke_depth,
|
ComputeBudget::default().max_invoke_stack_height,
|
||||||
MAX_DEPTH,
|
MAX_DEPTH,
|
||||||
);
|
);
|
||||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||||
|
|
|
@ -4086,7 +4086,7 @@ impl Bank {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
compute_budget.max_invoke_depth.saturating_add(1),
|
compute_budget.max_invoke_stack_height,
|
||||||
if self
|
if self
|
||||||
.feature_set
|
.feature_set
|
||||||
.is_active(&feature_set::limit_max_instruction_trace_length::id())
|
.is_active(&feature_set::limit_max_instruction_trace_length::id())
|
||||||
|
@ -18267,7 +18267,7 @@ pub(crate) mod tests {
|
||||||
let transaction_context = TransactionContext::new(
|
let transaction_context = TransactionContext::new(
|
||||||
loaded_txs[0].0.as_ref().unwrap().accounts.clone(),
|
loaded_txs[0].0.as_ref().unwrap().accounts.clone(),
|
||||||
Some(Rent::default()),
|
Some(Rent::default()),
|
||||||
compute_budget.max_invoke_depth.saturating_add(1),
|
compute_budget.max_invoke_stack_height,
|
||||||
compute_budget.max_instruction_trace_length,
|
compute_budget.max_instruction_trace_length,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue