# Crate sp_state_machine

source · [−]## Expand description

Substrate state machine implementation.

## Re-exports

`pub use crate::backend::Backend;`

## Modules

State machine backends. These manage the code and storage of contracts.

## Macros

Logs a message at the debug level.

Logs a message at the error level.

Constructs an event at the trace level.

Logs a message at the warn level.

## Structs

Simple Map-based Externalities impl.

Storage proof in compact form.

Wraps a read-only backend, call executor, and current overlayed changes.

Multiple key value state. States are ordered by root storage key.

A key value state at any storage level.

substrate trie layout

substrate trie layout, with external value nodes.

In-memory storage for offchain workers recoding changes for the actual offchain storage implementation.

The set of changes that are overlaid onto the backend.

Global proof recorder, act as a layer over a hash db for recording queried data.

Patricia trie-based backend which also tracks all touched storage trie values. These can be sent to remote node and used as a proof of execution.

Patricia trie-based backend specialized in get value proofs.

Simple read-only externalities for any backend.

The substrate state machine.

Accumulated usage statistics specific to state machine crate.

A storage changes structure that can be generated by the data collected in `OverlayedChanges`

.

A proof that some set of key-value pairs are included in the storage trie. The proof contains the storage values so that the partial storage backend can be reconstructed by a verifier that does not already have access to the key-value pairs.

Storage transactions are calculated as part of the `storage_root`

.
These transactions can be reused for importing the block into the
storage. So, we cache them to not require a recomputation of those transactions.

Simple HashMap-based Externalities impl.

Patricia trie-based backend. Transaction type is an overlay of changes to commit.

Usage statistics for state backend.

Measured count of operations and total bytes.

## Enums

Storage backend trust level.

Externalities Error.

Like `ExecutionStrategy`

only it also stores a handler in case of consensus failure.

Strategy for executing a call into the runtime.

Transaction index operation.

## Constants

State machine only allows a single level of child trie.

## Traits

State Machine Error bound.

Trait for inspecting state in any backend.

Patricia trie-based storage trait.

Key-value pairs storage that is used by trie backend essence.

A key-value datastore implemented as a database-backed modified Merkle tree.

## Functions

Create a backend used for checking the proof., using `H`

as hasher.

Check execution proof, generated by `prove_execution`

call.

Check execution proof on proving backend, generated by `prove_execution`

call.

Evaluate to ExecutionManager::NativeElseWasm, without having to figure out the type.

Create a new empty instance of in-memory backend.

Generate child storage read proof.

Generate storage read proof on pre-created trie backend.

Prove execution using the given state backend, overlayed changes, and call executor.

Prove execution using the given trie backend, overlayed changes, and call executor. Produces a state-backend-specific “transaction” which can be used to apply the changes to the backing store, such as the disk. Execution proof is the set of all ‘touched’ storage DBValues from the backend.

Generate range storage read proof, with child tries
content.
A size limit is applied to the proof with the
exception that `start_at`

and its following element
are always part of the proof.
If a key different than `start_at`

is a child trie root,
the child trie content will be included in the proof.

Generate range storage read proof, with child tries
content.
See `prove_range_read_with_child_with_size`

.

Generate range storage read proof.

Generate range storage read proof on an existing trie backend.

Generate storage read proof.

Generate storage read proof on pre-created trie backend.

Check child storage read proof, generated by `prove_child_read`

call.

Check child storage read proof on pre-created proving backend.

Check storage read proof, generated by `prove_read`

call.

Check storage read proof on pre-created proving backend.

Check child storage range proof, generated by `prove_range_read_with_size`

call.

Check storage range proof on pre-created proving backend.

Check storage range proof with child trie included, generated by
`prove_range_read_with_child_with_size`

call.

Check storage range proof on pre-created proving backend.

## Type Definitions

In memory arrays of storage values for multiple child tries.

Database value

Default error type to use with state machine trie backend.

Default handler of the execution manager.

Trie backend with in-memory storage.

Proving Trie backend with in-memory storage.

Reexport from `hash_db`

, with genericity set for `Hasher`

trait.
This uses a noops `KeyFunction`

(key addressing must be hashed or using
an encoding scheme that avoid key conflict).

In memory array of storage values.

In memory array of storage values.

Storage key.

Storage value.

Persistent trie database write-access interface for the a given hasher.

Persistent trie database write-access interface for the a given hasher.