Skip to main content

ExecutionLimits

Struct ExecutionLimits 

Source
pub struct ExecutionLimits {
    pub max_commands: usize,
    pub max_loop_iterations: usize,
    pub max_total_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: usize

Maximum number of commands that can be executed (fuel model) Default: 10,000

§max_loop_iterations: usize

Maximum iterations for a single loop Default: 10,000

§max_total_loop_iterations: usize

Maximum total loop iterations across all loops (nested and sequential). Prevents nested loop multiplication attack (TM-DOS-018). Default: 1,000,000

§max_function_depth: usize

Maximum function call depth (recursion limit) Default: 100

§timeout: Duration

Execution timeout Default: 30 seconds

§parser_timeout: Duration

Parser 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: usize

Maximum 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: usize

Maximum AST nesting depth during parsing Default: 100 Protects against stack overflow from deeply nested scripts (V4 in threat model).

§max_parser_operations: usize

Maximum parser operations (fuel model for parsing) Default: 100,000 Protects against parser DoS attacks that could otherwise cause CPU exhaustion.

Implementations§

Source§

impl ExecutionLimits

Source

pub fn new() -> Self

Create new limits with defaults

Source

pub fn max_commands(self, count: usize) -> Self

Set maximum command count

Source

pub fn max_loop_iterations(self, count: usize) -> Self

Set maximum loop iterations (per-loop)

Source

pub fn max_total_loop_iterations(self, count: usize) -> Self

Set maximum total loop iterations (across all nested/sequential loops). Prevents TM-DOS-018 nested loop multiplication.

Source

pub fn max_function_depth(self, depth: usize) -> Self

Set maximum function depth

Source

pub fn timeout(self, timeout: Duration) -> Self

Set execution timeout

Source

pub fn parser_timeout(self, timeout: Duration) -> Self

Set parser timeout

Source

pub fn max_input_bytes(self, bytes: usize) -> Self

Set maximum input script size in bytes

Source

pub fn max_ast_depth(self, depth: usize) -> Self

Set maximum AST nesting depth

Source

pub fn max_parser_operations(self, ops: usize) -> Self

Set maximum parser operations

Trait Implementations§

Source§

impl Clone for ExecutionLimits

Source§

fn clone(&self) -> ExecutionLimits

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExecutionLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExecutionLimits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.