# Crate sp_state_machine[−][src]

## 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.

Block identifier that could be used to determine fork of this block.

Changes trie build cache.

Blocks range where configuration has been constant.

Changes tries state at some block.

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

In-memory implementation of changes trie storage.

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.

The storage transaction are calculated as part of the `storage_root`

and
`changes_trie_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.

The action to perform when block-with-changes-trie is imported.

Externalities Error.

Like `ExecutionStrategy`

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

Strategy for executing a call into the runtime.

Transcation index operation.

## Traits

Requirements for block number that can be used with changes tries.

Changes trie storage. Provides access to trie roots and trie nodes.

Changes trie storage. Provides access to trie roots and trie nodes.

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 proof check backend.

Create state where changes tries are disabled.

Check execution proof, generated by `prove_execution`

call.

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

call.

Return changes of given key at given blocks range.
`max`

is the number of best known block.
Changes are returned in descending order (i.e. last block comes first).

Returns proof of changes of given key at given blocks range.
`max`

is the number of best known block.

Check key changes proof and return changes of the key at given blocks range.
`max`

is the number of best known block.
Changes are returned in descending order (i.e. last block comes first).

Similar to the `key_changes_proof_check`

function, but works with prepared proof storage.

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.

Generate range storage read proof on an existing trie backend.

Generate storage read proof.

Generate storage read proof on pre-created trie backend.

Prune obsolete changes tries. Pruning happens at the same block, where highest
level digest is created. Pruning guarantees to save changes tries for last
`min_blocks_to_keep`

blocks. We only prune changes tries at `max_digest_interval`

ranges.

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`

call.

Check storage range proof on pre-created proving backend.

## Type Definitions

Type of changes trie transaction.

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.

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.