singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.Registry.Replay

Description

The chain commits a registry's trie by its root only. This module rebuilds the trie itself from the transactions that moved the registry's state token since create, so a reader needs nobody's local copy.

The lineage is chained by spends, never by the order the transactions are given in: create mints the token under Minting(seed), and each fold spends the previous state output. A transaction whose bytes say it failed its scripts (isValid = false) spent only its collateral and is never in the lineage, whatever its body's inputs name. Every fold applies its requests the way the state validator does (onchain/validators/registry/fold.ak): the spending inputs in ledger order, an inline RequestDatum naming this registry's token takes the next action of the state input's Modify redeemer, Rejected leaves the trie as it is and Update walks the request's edge with walkEdge. After every fold the rebuilt root must equal the root in that fold's state datum.

The answer is the trie rebuilt into the caller's Trie, or one named TrieFailure. On a refusal the caller's trie holds a partial replay and must be discarded.

Synopsis

Documentation

replayLineage Source #

Arguments

:: Monad m 
=> Trie m

An empty trie the replay fills

-> RegistryIdentity 
-> TxIn

The selected state output

-> Root

The root the selection expects at that output

-> Map TxIn (TxOut ConwayEra)

Resolved spent and reference outputs

-> [ConwayTx]

The state token's history

-> m (Either TrieFailure Replayed) 

Rebuild the registry's trie into the given trie, from the history of its state token up to the selected state output.

The history is the ledger's own transactions, in any order; a transaction whose bytes say it failed its scripts (isValid = false) is left out before anything else reads the history, since it spent only its collateral. The map resolves every input they spend or reference. The selection is a state output and the root the caller expects there.

data Replayed Source #

A replay that reached the selected state output from create.

Constructors

Replayed 

Fields

  • replayedCreate :: TxId

    The transaction that minted the state token

  • replayedFolds :: [TxId]

    Every fold from create to the selected output, in chain order

  • replayedKeys :: [ByteString]

    The distinct keys the applied updates named, ascending

Instances

Instances details
Show Replayed Source # 
Instance details

Defined in Singular.Registry.Replay

Methods

showsPrec :: Int -> Replayed -> ShowS Source #

show :: Replayed -> String Source #

showList :: [Replayed] -> ShowS Source #

Eq Replayed Source # 
Instance details

Defined in Singular.Registry.Replay

Methods

(==) :: Replayed -> Replayed -> Bool Source #

(/=) :: Replayed -> Replayed -> Bool Source #

appliedKeys :: [(OnChainRequest, RequestAction)] -> [ByteString] Source #

The distinct keys applied updates named, ascending. Rejected requests are not applied and name nothing here.

replayedLineage :: Replayed -> PublicLineage Source #

A replay as its public lineage: the create, the folds in chain order and the distinct keys the applied updates named.