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

initial_world() -> World

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.

universe() -> List<ByteArray>

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.

registry_at(world: World, index: Int) -> Registry

The registry of the world at index.

identity_of(registry: Registry) -> RegistryIdentity

The identity of the registry the seed names.

leaf_of(registry: Registry, key: ByteArray) -> Leaf

What the trie of registry says about key.

is_attack(kind: Kind) -> Bool

Whether the kind is an attack.

name_of(kind: Kind) -> String

The name of a kind, for the tables the property runs print.

groups(world: World) -> List<List<Candidate>>

Every proposal the world allows, grouped by what it is.

choose(world: World, choice: Int) -> Option<Candidate>

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.

build(world: World, chosen: Candidate) -> Proposal

The proposal for a candidate of the world.

ledger_accepts(proposal: Proposal, world: World) -> Bool

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.

advance(world: World, proposal: Proposal) -> World

The world after an accepted proposal.

run(
  scripts: fn(Proposal) -> Bool,
  world: World,
  choices: List<Int>,
) -> List<Outcome>

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.

run_script(
  scripts: fn(Proposal) -> Bool,
  world: World,
  wants: List<Want>,
) -> List<Outcome>

A run written by hand. It stops at the first proposal the world does not allow.

live_supply(world: World, registry: Registry, key: ByteArray) -> Int

The live supply of the token of key in registry: its quantity over every unspent output.

runs_end_committed(outcomes: List<Outcome>) -> Bool

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.

supply_follows_leaves(outcome: Outcome) -> Bool

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.

at_most_one_live_token(outcome: Outcome) -> Bool

History statement one_live_token: at most one token of a key is live.

burns_belong_to_terminating_folds(outcome: Outcome) -> Bool

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.

terminal_keys_are_never_minted_again(outcome: Outcome) -> Bool

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.

changes_of(proposal: Proposal) -> List<Change>

The changes of the folds a proposal carries.

folds_registrations(proposal: Proposal) -> Bool

Whether the proposal folds a registration.

folds_terminations(proposal: Proposal) -> Bool

Whether the proposal folds a termination.

is_mixed_fold(proposal: Proposal) -> Bool

Whether the proposal folds registrations and terminations together.

allowed_attacks(world: World) -> List<Kind>

The kinds of attack the world allows.

rules_are_followed(outcomes: List<Outcome>) -> Bool

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.

describe(outcome: Outcome) -> String

The name of an outcome, for the tables the property runs print.

Search Document