| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
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
- replayLineage :: Monad m => Trie m -> RegistryIdentity -> TxIn -> Root -> Map TxIn (TxOut ConwayEra) -> [ConwayTx] -> m (Either TrieFailure Replayed)
- data Replayed = Replayed {
- replayedCreate :: TxId
- replayedFolds :: [TxId]
- replayedKeys :: [ByteString]
- appliedKeys :: [(OnChainRequest, RequestAction)] -> [ByteString]
- replayedLineage :: Replayed -> PublicLineage
Documentation
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.
A replay that reached the selected state output from create.
Constructors
| Replayed | |
Fields
| |
Instances
| Show Replayed Source # | |
Defined in Singular.Registry.Replay | |
| Eq Replayed Source # | |
Defined in Singular.Registry.Replay | |
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.