singular_state_history
Generated worlds of the Singular state validator, for the history statements.
A world is a set of unspent outputs, the registries created in it and the
requests that wait for a fold. A step proposes one transaction against it,
the ledger rules and the real handlers of singular_state decide, and an
accepted transaction becomes the next world: its inputs leave the unspent
set and its outputs enter it with fresh references. A refused proposal
leaves the world as it was.
What the statements read is the world itself. The live supply of a key’s token is counted over every unspent output; the leaf of a key is read from the leaves the world keeps for its registry, which the state output of the last world of a run must commit to, with the root the trie library computes; a burn or a mint is read from the mint of the transaction.
The proposals are the rules’ own transactions (a registry is created, a request is made, a termination is booked, a holding moves, a batch of requests is folded) and, beside them, the transactions an attacker would try: the ones that break exactly one rule of a fold.
Not modelled: lovelace. Every proposal conserves every other asset, which is what the supply of a token depends on, and the world checks it.
Types
A choice among the proposals a world allows: the kind, the registry it is about, the key it is about, the registry that holds the terminal key when the proposal mints its token elsewhere, and, of a fold, the keys of the requests it folds.
Constructors
-
Candidate { kind: Kind, registry: Int, key: ByteArray, other: Int, keys: List<ByteArray>, }
What an accepted proposal does to the registries and the requests waiting.
Constructors
-
Unchanged -
Created(Registry) -
Advanced(Int, List<Held>) -
Requested(Pending)
What a proposal is. The first five follow the rules; the others are the transactions an attacker tries, each one breaking one rule of the fold.
Constructors
-
CreateRegistry -
RequestRegistration -
BookTermination -
MoveHolding -
FoldBatch -
TerminateKeepingToken -
RegisterWithTwoTokens -
RegisterActiveKey -
RegisterTerminalKey -
BurnOutsideFold -
BurnBesideRegistration -
MintTerminalKeyThroughAnotherRegistry
What a trie says about a key.
Constructors
-
Active -
Terminal -
Absent
One step of a run: the proposal, whether it was accepted, whether the ledger’s rules held for it whatever the scripts said, and the world before and after.
Constructors
-
Outcome { proposal: Proposal, accepted: Bool, lawful: Bool, before: World, after: World, }
A request that waits for a fold, with the index of the registry it names.
Constructors
-
Pending { registry: Int, step: Step }
A transaction proposed against a world, with the redeemers the ledger would hand the state script and what it does if the ledger accepts it.
Constructors
-
Proposal { kind: Kind, tx: Transaction, mint_redeemer: Option<StateMint>, state_spends: List<(OutputReference, StateSpend)>, effect: Effect, }
A registry of the world: the seed that names it, the output that carries its state token now, the leaves its trie holds, and the name of the token of each key, as the producer names it, found once when the registry is created.
Constructors
-
Registry { seed: OutputReference, state: OutputReference, held: List<Held>, names: List<(ByteArray, AssetName)>, }
A proposal named by what it is, for a run written by hand.
Constructors
-
Want { kind: Kind, registry: Int, keys: List<ByteArray> }
The unspent outputs, the registries, the requests waiting and the number of transactions accepted so far.
Constructors
-
World { unspent: List<Input>, registries: List<Registry>, pending: List<Pending>, used: Int, }
Functions
The world before anything is created: plain outputs, and for each registry the world can create one registration request of each key and a second one of the first key.
The keys the proposals draw on: key_a and key_t share the first nibble of
their hashes, key_t and key_v share three, and key_b and key_c share
none with them, so the tries of a run have nodes below the root, and proofs of
several steps with leaf steps among them.
Every proposal the world allows, grouped by what it is.
The proposal a choice selects. One choice in three is an attack when the world allows one; the others follow the rules. Within the class the choice names a group, then a member of it, so a kind with many members does not crowd out the others.
scripts_accept(
mint: fn(StateMint, Transaction) -> Bool,
spend: fn(Option<Data>, StateSpend, OutputReference, Transaction) -> Bool,
proposal: Proposal,
) -> Bool
The scripts the ledger would run for the proposal, run by the handlers of the state validator that the test module hands in (a module that imports the validator cannot export anything): the mint handler when the state policy is minted, the spend handler for each input at the state script. A script the transaction brings no redeemer for fails.
The steps of a run: each choice selects a proposal of the world it finds, the ledger’s rules and the scripts decide, and an accepted proposal makes the next world.
A run written by hand. It stops at the first proposal the world does not allow.
The live supply of the token of key in registry: its quantity over every
unspent output.
The last world of a run is read as a whole: no key has more than one live token (a corollary of the supply of each step), and the state output of every registry commits to the leaves the world holds for it, with the root the trie library computes from them: the outputs the folds wrote carry the root of the proof builder.
History statement supply_in_step: after an accepted step, for every
registry and key, the live supply of the key’s token is one when its leaf is
active and zero otherwise. The tokens of the whole policy are counted too, so
a token of a key the world does not know is a violation.
History statement one_live_token: at most one token of a key is live.
History statement burn_only_terminating_fold: an accepted transaction
burns the token of a key only in a fold of its registry that terminates the
key, whose final leaf is terminal; and every burn of the state policy is the
token of a key of a registry of the world.
History statement no_remint_after_terminal: an accepted transaction mints
no token of a key that is terminal in a registry, in a fold of that
registry or of another, and the key stays terminal.
Whether the proposal folds registrations and terminations together.
Whether a run has the accepted proposals the rules produce: every proposal that is not an attack is accepted, and every one is lawful for the ledger.