Skip to main content

NetworkConfigBuilder

Struct NetworkConfigBuilder 

Source
pub struct NetworkConfigBuilder { /* private fields */ }
Expand description

Builder for a NetworkConfig stating non-default execution parameters.

Overrides are applied to a base configuration – stock_network_config unless with_base says otherwise – so setting one parameter leaves every other one at the value the chain would have used:

use thruput_native_exec::network_config::NetworkConfigBuilder;

let config = NetworkConfigBuilder::new()
    .with_max_sha256_buffers(2)
    .build();

Most tests never name this type: the same with_* setters are on TestEnvironmentBuilder, which builds the configuration and the environment together.

A setter is only usable against a hogd build that knows its parameter. The stock configuration states what that build’s genesis states, and build refuses to leave a gap below a newer parameter, so the ones protocol 0.35 introduced (with_max_contract_size_bytes and later) need a hogd built from that protocol or newer.

Implementations§

Source§

impl NetworkConfigBuilder

Source

pub fn new() -> NetworkConfigBuilder

A builder with no overrides, over the stock configuration.

Source

pub fn with_base(self, base: NetworkConfig) -> NetworkConfigBuilder

Apply the overrides to base instead of to stock_network_config.

Use this to start from a configuration a test already has in hand (e.g. one read back off another environment). base must itself state a gapless prefix of the id space, as any configuration hogd accepts does.

Source

pub fn with_config_param(self, param: ConfigParam) -> NetworkConfigBuilder

State param, replacing whatever the base says for it.

The typed setters below cover the parameters this SDK release knows; this is the escape hatch for one it does not.

Source

pub fn with_max_sha256_buffers( self, max_sha256_buffers: u32, ) -> NetworkConfigBuilder

Concurrently open incremental SHA-256 buffers permitted per invocation frame (the cap thruput_sdk::Hasher allocates against).

Source

pub fn with_max_cross_invoke_depth( self, max_cross_invoke_depth: u32, ) -> NetworkConfigBuilder

Invocation frames one transaction may have open at once.

The harness opens its frames directly, so one the executor refuses is an unrecoverable panic rather than the error a contract would observe. To assert on the cap, have the frame call through the Invoke syscall (thruput_sdk::call::try_call_raw_with), which reports it as RawCallError::DepthExceeded.

Source

pub fn with_max_new_contracts_per_tx( self, max_new_contracts_per_tx: u32, ) -> NetworkConfigBuilder

Contracts one transaction may attach in contracts_to_deploy.

Source

pub fn with_max_bytestring_len( self, max_bytestring_len: u32, ) -> NetworkConfigBuilder

Bytes one bytestring storage item may hold.

Source

pub fn with_max_contract_size_bytes( self, max_contract_size_bytes: u32, ) -> NetworkConfigBuilder

Bytes one attached contract’s code blob (ContractBlob.data) may hold, checked before any attached contract is verified or executed.

Source

pub fn with_max_savepoint_depth( self, max_savepoint_depth: u32, ) -> NetworkConfigBuilder

Storage savepoints one transaction may have open at once: one per TryInvoke frame still executing, plus the one the root commit takes.

Source

pub fn with_max_sha256_buffer_bytes( self, max_sha256_buffer_bytes: u32, ) -> NetworkConfigBuilder

Bytes one incremental SHA-256 buffer may absorb between resets, the per-buffer companion of with_max_sha256_buffers.

Source

pub fn with_max_auth_token_depth( self, max_auth_token_depth: u32, ) -> NetworkConfigBuilder

Levels of AuthTokenNode nesting an auth token may carry, counted from its root.

Source

pub fn with_max_rv32_code_bytes( self, max_rv32_code_bytes: u32, ) -> NetworkConfigBuilder

Bytes of code (code_size in the artifact header) an RV32 artifact may carry to be attached as a contract.

Source

pub fn with_max_rv32_memory_bytes( self, max_rv32_memory_bytes: u32, ) -> NetworkConfigBuilder

Bytes of guest data memory (memory_bytes in the artifact header) an RV32 artifact may declare to be attached as a contract.

Source

pub fn is_stock(&self) -> bool

Whether this builder would produce exactly the stock configuration: no base of its own and nothing overridden.

Source

pub fn build(self) -> NetworkConfig

The configuration: the base with every override applied.

Panics rather than hand hogd a list it would reject: the parameters must come out a gapless prefix of the id space (ids 0, 1, 2, …), which is what gives one configuration one encoding, and hence one config hash.

Trait Implementations§

Source§

impl Clone for NetworkConfigBuilder

Source§

fn clone(&self) -> NetworkConfigBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NetworkConfigBuilder

Source§

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

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

impl Default for NetworkConfigBuilder

Source§

fn default() -> NetworkConfigBuilder

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.