pub struct ExecutionLimits {
pub max_commands: usize,
pub max_loop_iterations: usize,
pub max_function_depth: usize,
pub timeout: Duration,
pub parser_timeout: Duration,
pub max_input_bytes: usize,
pub max_ast_depth: usize,
pub max_parser_operations: usize,
}Expand description
Resource limits for script execution
Fields§
§max_commands: usizeMaximum number of commands that can be executed (fuel model) Default: 10,000
max_loop_iterations: usizeMaximum iterations for a single loop Default: 10,000
max_function_depth: usizeMaximum function call depth (recursion limit) Default: 100
timeout: DurationExecution timeout Default: 30 seconds
parser_timeout: DurationParser timeout (separate from execution timeout) Default: 5 seconds This limits how long the parser can spend parsing a script before giving up. Protects against parser hang attacks (V3 in threat model).
max_input_bytes: usizeMaximum input script size in bytes Default: 10MB (10,000,000 bytes) Protects against memory exhaustion from large scripts (V1 in threat model).
max_ast_depth: usizeMaximum AST nesting depth during parsing Default: 100 Protects against stack overflow from deeply nested scripts (V4 in threat model).
max_parser_operations: usizeMaximum parser operations (fuel model for parsing) Default: 100,000 Protects against parser DoS attacks that could otherwise cause CPU exhaustion.
Implementations§
Source§impl ExecutionLimits
impl ExecutionLimits
Sourcepub fn max_commands(self, count: usize) -> Self
pub fn max_commands(self, count: usize) -> Self
Set maximum command count
Sourcepub fn max_loop_iterations(self, count: usize) -> Self
pub fn max_loop_iterations(self, count: usize) -> Self
Set maximum loop iterations
Sourcepub fn max_function_depth(self, depth: usize) -> Self
pub fn max_function_depth(self, depth: usize) -> Self
Set maximum function depth
Sourcepub fn parser_timeout(self, timeout: Duration) -> Self
pub fn parser_timeout(self, timeout: Duration) -> Self
Set parser timeout
Sourcepub fn max_input_bytes(self, bytes: usize) -> Self
pub fn max_input_bytes(self, bytes: usize) -> Self
Set maximum input script size in bytes
Sourcepub fn max_ast_depth(self, depth: usize) -> Self
pub fn max_ast_depth(self, depth: usize) -> Self
Set maximum AST nesting depth
Sourcepub fn max_parser_operations(self, ops: usize) -> Self
pub fn max_parser_operations(self, ops: usize) -> Self
Set maximum parser operations
Trait Implementations§
Source§impl Clone for ExecutionLimits
impl Clone for ExecutionLimits
Source§fn clone(&self) -> ExecutionLimits
fn clone(&self) -> ExecutionLimits
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more