This crate contains the data structures and core algorithms that comprise Themelio’s core state machine. Any piece of software needing to parse Themelio data, validate Themelio transactions, or answer questions like “what happens to the Themelio state if transactions A, B, and C happen” can use this minimal-depedency crate.
Roughly, the structs in this crate are organized as follows:
Staterepresents a full 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 taking
Transactions etc that advance the state, as well as others to produce serializable blocks, headers, etc.
Transactionrepresents a serializable Themelio transaction. It has some helper methods to count coins, estimate fees, etc, largely to help build wallets.
StakeDoc, which every
Stateincludes, encapsulates the Symphonia epoch-based stake information.
SmtMappingrepresents a type-safe SMT-backed mapping that is extensively used within the crate.
An abbreviated block
A (serialized) block.
The data bound to a coin ID. Contains the “contents” of a coin, i.e. its constraint hash, value, and coin type.
A coin ID, consisting of a transaction hash and index. Uniquely identifies a coin in Themelio’s history.
ConfirmedState represents a fully confirmed state with a consensus proof.
Configuration of a genesis state. Serializable via serde.
A block header, which commits to a particular SealedState.
A type that wraps a bytevector, serializing as hexadecimal for JSON.
ProposerAction describes the standard action that the proposer takes when proposing a block.
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.
StakeDoc is a stake document. It encapsulates all the information needed to verify consensus proofs.
World state of the Themelio blockchain
Transaction represents an individual, serializable Themelio transaction.
A newtype representing the hash of a transaction.
Identifies a network.
A error that happens while applying a transaction to a state
An enumeration of all the different possible transaction kinds. Currently contains a “faucet” kind that will be (obviously) removed in production.
Coin destruction covhash
Maximum coin value
A stake epoch is 200,000 blocks.
Reward calculator. Returns the value in real DOSC.
DOSC inflation calculator.
DOSC inflation ratio.
Denomination for a particular liquidity token
Presealing function that is called before a state is sealed to apply melmint actions.
A stake mapping