Ledger¶
This section is part of the
Ledger.Conway.Ledger
module of the formal ledger
specification,
where the entire state transformation of the ledger state caused by a
valid transaction can now be given as a combination of the previously
defined transition systems.
Conway specifics
As there is nothing new to the Conway era in this part of the ledger, we do not present any details of the Agda formalization.
Types and functions for the LEDGER transition system¶
record LEnv : Type where field slot : Slot ppolicy : Maybe ScriptHash pparams : PParams enactState : EnactState treasury : Coin
record LState : Type where
field utxoSt : UTxOState govSt : GovState certState : CertState
txgov : TxBody → List (GovVote ⊎ GovProposal) txgov txb = map inj₂ txprop ++ map inj₁ txvote where open TxBody txb rmOrphanDRepVotes : CertState → GovState → GovState rmOrphanDRepVotes cs govSt = L.map (map₂ go) govSt where ifDRepRegistered : Voter → Type ifDRepRegistered (r , c) = r ≡ DRep → c ∈ dom (cs .gState .dreps) go : GovActionState → GovActionState go gas = record gas { votes = filterKeys ifDRepRegistered (gas .votes) } allColdCreds : GovState → EnactState → ℙ Credential allColdCreds govSt es = ccCreds (es .cc) ∪ concatMapˢ (λ (_ , st) → proposedCC (st .action)) (fromList govSt)
LEDGER transition system¶
data _⊢_⇀⦇_,LEDGER⦈_ : LEnv → LState → Tx → LState → Type where LEDGER-V : let txb = tx .body
rewards = certState .dState .rewards in ∙ isValid tx ≡ true ∙ $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3377}{\htmlId{3792}{\htmlClass{Generalizable}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3420}{\htmlId{3799}{\htmlClass{Generalizable}{\text{pp}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3461}{\htmlId{3804}{\htmlClass{Generalizable}{\text{treasury}}}}\, \end{pmatrix}$ ⊢ utxoSt ⇀⦇ tx ,UTXOW⦈ utxoSt' ∙ $\begin{pmatrix} \,\href{Ledger.Conway.Types.Epoch.html#812}{\htmlId{3855}{\htmlClass{Function}{\text{epoch}}}}\, \,\href{Ledger.Conway.Ledger.html#3377}{\htmlId{3861}{\htmlClass{Generalizable}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3420}{\htmlId{3868}{\htmlClass{Generalizable}{\text{pp}}}}\, \\ \,\href{Ledger.Conway.Transaction.html#4883}{\htmlId{3873}{\htmlClass{Function}{\text{txvote}}}}\, \\ \,\href{Ledger.Conway.Transaction.html#4855}{\htmlId{3882}{\htmlClass{Function}{\text{txwdrls}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3043}{\htmlId{3892}{\htmlClass{Function}{\text{allColdCreds}}}}\, \,\href{Ledger.Conway.Ledger.html#3306}{\htmlId{3905}{\htmlClass{Generalizable}{\text{govSt}}}}\, \,\href{Ledger.Conway.Ledger.html#3435}{\htmlId{3911}{\htmlClass{Generalizable}{\text{enactState}}}}\, \end{pmatrix}$ ⊢ certState ⇀⦇ txcerts ,CERTS⦈ certState' ∙ $\begin{pmatrix} \,\href{Ledger.Conway.Transaction.html#5130}{\htmlId{3974}{\htmlClass{Function}{\text{txid}}}}\, \\ \,\href{Ledger.Conway.Types.Epoch.html#812}{\htmlId{3981}{\htmlClass{Function}{\text{epoch}}}}\, \,\href{Ledger.Conway.Ledger.html#3377}{\htmlId{3987}{\htmlClass{Generalizable}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3420}{\htmlId{3994}{\htmlClass{Generalizable}{\text{pp}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3391}{\htmlId{3999}{\htmlClass{Generalizable}{\text{ppolicy}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3435}{\htmlId{4009}{\htmlClass{Generalizable}{\text{enactState}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3342}{\htmlId{4022}{\htmlClass{Generalizable}{\text{certState'}}}}\, \\ \,\href{Class.IsSet.html#916}{\htmlId{4035}{\htmlClass{Function}{\text{dom}}}}\, \,\href{Ledger.Conway.Ledger.html#3712}{\htmlId{4039}{\htmlClass{Bound}{\text{rewards}}}}\, \end{pmatrix}$ ⊢ rmOrphanDRepVotes certState' govSt ⇀⦇ txgov txb ,GOVS⦈ govSt' ──────────────────────────────── $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3377}{\htmlId{4160}{\htmlClass{Generalizable}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3391}{\htmlId{4167}{\htmlClass{Generalizable}{\text{ppolicy}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3420}{\htmlId{4177}{\htmlClass{Generalizable}{\text{pp}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3435}{\htmlId{4182}{\htmlClass{Generalizable}{\text{enactState}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3461}{\htmlId{4195}{\htmlClass{Generalizable}{\text{treasury}}}}\, \end{pmatrix}$ ⊢ $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3277}{\htmlId{4210}{\htmlClass{Generalizable}{\text{utxoSt}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3306}{\htmlId{4219}{\htmlClass{Generalizable}{\text{govSt}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3332}{\htmlId{4227}{\htmlClass{Generalizable}{\text{certState}}}}\, \end{pmatrix}$ ⇀⦇ tx ,LEDGER⦈ $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3284}{\htmlId{4256}{\htmlClass{Generalizable}{\text{utxoSt'}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3312}{\htmlId{4266}{\htmlClass{Generalizable}{\text{govSt'}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3342}{\htmlId{4275}{\htmlClass{Generalizable}{\text{certState'}}}}\, \end{pmatrix}$ LEDGER-I : ∙ isValid tx ≡ false ∙ $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3377}{\htmlId{4335}{\htmlClass{Generalizable}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3420}{\htmlId{4342}{\htmlClass{Generalizable}{\text{pp}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3461}{\htmlId{4347}{\htmlClass{Generalizable}{\text{treasury}}}}\, \end{pmatrix}$ ⊢ utxoSt ⇀⦇ tx ,UTXOW⦈ utxoSt' ──────────────────────────────── $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3377}{\htmlId{4436}{\htmlClass{Generalizable}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3391}{\htmlId{4443}{\htmlClass{Generalizable}{\text{ppolicy}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3420}{\htmlId{4453}{\htmlClass{Generalizable}{\text{pp}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3435}{\htmlId{4458}{\htmlClass{Generalizable}{\text{enactState}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3461}{\htmlId{4471}{\htmlClass{Generalizable}{\text{treasury}}}}\, \end{pmatrix}$ ⊢ $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3277}{\htmlId{4486}{\htmlClass{Generalizable}{\text{utxoSt}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3306}{\htmlId{4495}{\htmlClass{Generalizable}{\text{govSt}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3332}{\htmlId{4503}{\htmlClass{Generalizable}{\text{certState}}}}\, \end{pmatrix}$ ⇀⦇ tx ,LEDGER⦈ $\begin{pmatrix} \,\href{Ledger.Conway.Ledger.html#3284}{\htmlId{4532}{\htmlClass{Generalizable}{\text{utxoSt'}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3306}{\htmlId{4542}{\htmlClass{Generalizable}{\text{govSt}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3332}{\htmlId{4550}{\htmlClass{Generalizable}{\text{certState}}}}\, \end{pmatrix}$
LEDGERS transition system¶
_⊢_⇀⦇_,LEDGERS⦈_ : LEnv → LState → List Tx → LState → Type _⊢_⇀⦇_,LEDGERS⦈_ = ReflexiveTransitiveClosure {sts = _⊢_⇀⦇_,LEDGER⦈_}