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
impl NetworkConfigBuilder
Sourcepub fn with_base(self, base: NetworkConfig) -> Self
pub fn with_base(self, base: NetworkConfig) -> Self
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.
Sourcepub fn with_config_param(self, param: ConfigParam) -> Self
pub fn with_config_param(self, param: ConfigParam) -> Self
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.
Sourcepub fn with_max_sha256_buffers(self, max_sha256_buffers: u32) -> Self
pub fn with_max_sha256_buffers(self, max_sha256_buffers: u32) -> Self
Concurrently open incremental SHA-256 buffers permitted per invocation
frame (the cap thruput_sdk::Hasher allocates against).
Sourcepub fn with_max_cross_invoke_depth(self, max_cross_invoke_depth: u32) -> Self
pub fn with_max_cross_invoke_depth(self, max_cross_invoke_depth: u32) -> Self
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.
Sourcepub fn with_max_new_contracts_per_tx(
self,
max_new_contracts_per_tx: u32,
) -> Self
pub fn with_max_new_contracts_per_tx( self, max_new_contracts_per_tx: u32, ) -> Self
Contracts one transaction may attach in contracts_to_deploy.
Sourcepub fn with_max_bytestring_len(self, max_bytestring_len: u32) -> Self
pub fn with_max_bytestring_len(self, max_bytestring_len: u32) -> Self
Bytes one bytestring storage item may hold.
Sourcepub fn with_max_contract_size_bytes(self, max_contract_size_bytes: u32) -> Self
pub fn with_max_contract_size_bytes(self, max_contract_size_bytes: u32) -> Self
Bytes one attached contract’s code blob (ContractBlob.data) may
hold, checked before any attached contract is verified or executed.
Sourcepub fn with_max_savepoint_depth(self, max_savepoint_depth: u32) -> Self
pub fn with_max_savepoint_depth(self, max_savepoint_depth: u32) -> Self
Storage savepoints one transaction may have open at once: one per
TryInvoke frame still executing, plus the one the root commit
takes.
Sourcepub fn with_max_sha256_buffer_bytes(self, max_sha256_buffer_bytes: u32) -> Self
pub fn with_max_sha256_buffer_bytes(self, max_sha256_buffer_bytes: u32) -> Self
Bytes one incremental SHA-256 buffer may absorb between resets, the
per-buffer companion of
with_max_sha256_buffers.
Sourcepub fn with_max_auth_token_depth(self, max_auth_token_depth: u32) -> Self
pub fn with_max_auth_token_depth(self, max_auth_token_depth: u32) -> Self
Levels of AuthTokenNode nesting an auth token may carry, counted
from its root.
Sourcepub fn with_max_rv32_code_bytes(self, max_rv32_code_bytes: u32) -> Self
pub fn with_max_rv32_code_bytes(self, max_rv32_code_bytes: u32) -> Self
Bytes of code (code_size in the artifact header) an RV32 artifact
may carry to be attached as a contract.
Sourcepub fn with_max_rv32_memory_bytes(self, max_rv32_memory_bytes: u32) -> Self
pub fn with_max_rv32_memory_bytes(self, max_rv32_memory_bytes: u32) -> Self
Bytes of guest data memory (memory_bytes in the artifact header)
an RV32 artifact may declare to be attached as a contract.
Sourcepub fn is_stock(&self) -> bool
pub fn is_stock(&self) -> bool
Whether this builder would produce exactly the stock configuration: no base of its own and nothing overridden.
Sourcepub fn build(self) -> NetworkConfig
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.