Crate themelio_stf
source ·Expand description
themelio-stf: themelio’s core state transition function
This crate contains the data structures and core algorithms that comprise Themelio’s core state transition function. Any piece of software needing to validate Themelio transactions or answer questions like “what happens to the Themelio state if transactions A, B, and C happen” can use this minimal-dependency crate.
The State
type
The most important type in the crate is State
, and the closely associated type SealedState
. The yellow paper talks about them further, but in short:
State
represents an mutable Themelio world-state and it’s not directly serializable. It includes all the information needed to validate new transactions and blocks, such as a SMT of all outstanding coins, Melmint parameters, etc. It has methods takingTransaction
s etc that advance the state, as well as others to produce serializable blocks, headers, etc.SealedState
represents a sealed state. This roughly corresponds to the notion of “the blockchain state at a given height”. Blocks represent transitions from oneSealedState
to another.
Note
This crate is the most consensus-critical part of Themelio, and essentially defines the entire on-chain logic of the Themelio blockchain.
Versions incompatible with the latest Themelio state are thus all yanked.
Modules
Structs
A mapping that contains the coins, exposing a safeish API for the rest of the crate.
ConfirmedState represents a fully confirmed state with a consensus proof.
Configuration of a genesis state. Serializable via serde.
Legacy MelPoW hasher
SealedState represents an immutable state at a finalized block height.
It cannot be constructed except through sealing a State or restoring from persistent storage.
SmtMapping is a type-safe, constant-time cloneable, imperative-style interface to a sparse Merkle tree.
World state of the Themelio blockchain
New (TIP-910) MelPoW hasher
Enums
A error that happens while applying a transaction to a state
Functions
Reward calculator. Returns the value in real DOSC.
DOSC inflation ratio.
DOSC inflation calculator.
Presealing function that is called before a state is sealed to apply melmint actions.
Type Definitions
A pool
A stake mapping