Ledger
{-# OPTIONS --safe #-}
import Data.List as L
open import Ledger.Prelude
open import Ledger.Conway.Abstract
open import Ledger.Conway.Transaction using (TransactionStructure)
module Ledger.Conway.Conformance.Ledger
(txs : _) (open TransactionStructure txs)
(abs : AbstractFunctions txs) (open AbstractFunctions abs)
where
open import Ledger.Conway.Enact govStructure
open import Ledger.Conway.Conformance.Gov txs abs
open import Ledger.Conway.Conformance.Utxo txs abs
open import Ledger.Conway.Conformance.Utxow txs abs
open import Ledger.Conway.Conformance.Certs govStructure
open import Ledger.Conway.Ledger txs abs public
using (LEnv; HasCast-LEnv; allColdCreds; rmOrphanDRepVotes; txgov)
open Tx
record LState : Type where
constructor ⟦_,_,_⟧ˡ
field
utxoSt : UTxOState
govSt : GovState
certState : CertState
instance
unquoteDecl HasCast-LState = derive-HasCast
[ (quote LState , HasCast-LState) ]
private variable
Γ : LEnv
s s' s'' : LState
utxoSt' : UTxOState
govSt' : GovState
certState' : CertState
tx : Tx
open UTxOState
data
_⊢_⇀⦇_,LEDGER⦈_ : LEnv → LState → Tx → LState → Type
where
LEDGER-V :
let open LState s; txb = tx .body; open TxBody txb; open LEnv Γ
open CertState certState; open DState dState
utxoSt'' = record utxoSt' { deposits = updateDeposits pparams txb (deposits utxoSt') }
in
∙ isValid tx ≡ true
∙ record { LEnv Γ } ⊢ utxoSt ⇀⦇ tx ,UTXOW⦈ utxoSt'
∙ $\begin{pmatrix} \,\href{Ledger.Conway.Types.Epoch.html#812}{\htmlId{1499}{\htmlClass{Function}{\text{epoch}}}}\, \,\href{Ledger.Conway.Ledger.html#1356}{\htmlId{1505}{\htmlClass{Function}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#1414}{\htmlId{1512}{\htmlClass{Function}{\text{pparams}}}}\, \\ \,\href{Ledger.Conway.Transaction.html#4883}{\htmlId{1522}{\htmlClass{Function}{\text{txvote}}}}\, \\ \,\href{Ledger.Conway.Transaction.html#4855}{\htmlId{1531}{\htmlClass{Function}{\text{txwdrls}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#3043}{\htmlId{1541}{\htmlClass{Function}{\text{allColdCreds}}}}\, \,\href{Ledger.Conway.Conformance.Ledger.html#813}{\htmlId{1554}{\htmlClass{Function}{\text{govSt}}}}\, \,\href{Ledger.Conway.Ledger.html#1440}{\htmlId{1560}{\htmlClass{Function}{\text{enactState}}}}\, \end{pmatrix}$ ⊢ certState ⇀⦇ txcerts ,CERTS⦈ certState'
∙ $\begin{pmatrix} \,\href{Ledger.Conway.Transaction.html#5130}{\htmlId{1624}{\htmlClass{Function}{\text{txid}}}}\, \\ \,\href{Ledger.Conway.Types.Epoch.html#812}{\htmlId{1631}{\htmlClass{Function}{\text{epoch}}}}\, \,\href{Ledger.Conway.Ledger.html#1356}{\htmlId{1637}{\htmlClass{Function}{\text{slot}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#1414}{\htmlId{1644}{\htmlClass{Function}{\text{pparams}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#1379}{\htmlId{1654}{\htmlClass{Function}{\text{ppolicy}}}}\, \\ \,\href{Ledger.Conway.Ledger.html#1440}{\htmlId{1664}{\htmlClass{Function}{\text{enactState}}}}\, \\ \,\href{Ledger.Conway.Conformance.Ledger.html#1051}{\htmlId{1678}{\htmlClass{Generalizable}{\text{certState'}}}}\, \\ \,\href{Class.IsSet.html#916}{\htmlId{1691}{\htmlClass{Function}{\text{dom}}}}\,
\,\href{Ledger.Conway.Conformance.Certs.html#685}{\htmlId{1699}{\htmlClass{Function}{\text{rewards}}}}\, \end{pmatrix}$ ⊢ govSt ⇀⦇ txgov txb ,GOVS⦈ govSt'
────────────────────────────────
Γ ⊢ s ⇀⦇ tx ,LEDGER⦈ $\begin{pmatrix} \,\href{Ledger.Conway.Conformance.Ledger.html#1314}{\htmlId{1814}{\htmlClass{Bound}{\text{utxoSt''}}}}\, \\ \,\href{Ledger.Conway.Conformance.Ledger.html#1031}{\htmlId{1825}{\htmlClass{Generalizable}{\text{govSt'}}}}\, \\ \,\href{Ledger.Conway.Conformance.Ledger.html#1051}{\htmlId{1834}{\htmlClass{Generalizable}{\text{certState'}}}}\, \end{pmatrix}$
LEDGER-I : let open LState s; txb = tx .body; open TxBody txb; open LEnv Γ in
∙ isValid tx ≡ false
∙ record { LEnv Γ } ⊢ utxoSt ⇀⦇ tx ,UTXOW⦈ utxoSt'
────────────────────────────────
Γ ⊢ s ⇀⦇ tx ,LEDGER⦈ $\begin{pmatrix} \,\href{Ledger.Conway.Conformance.Ledger.html#1009}{\htmlId{2081}{\htmlClass{Generalizable}{\text{utxoSt'}}}}\, \\ \,\href{Ledger.Conway.Conformance.Ledger.html#813}{\htmlId{2091}{\htmlClass{Function}{\text{govSt}}}}\, \\ \,\href{Ledger.Conway.Conformance.Ledger.html#839}{\htmlId{2099}{\htmlClass{Function}{\text{certState}}}}\, \end{pmatrix}$
pattern LEDGER-V⋯ w x y z = LEDGER-V (w , x , y , z)
pattern LEDGER-I⋯ y z = LEDGER-I (y , z)
_⊢_⇀⦇_,LEDGERS⦈_ : LEnv → LState → List Tx → LState → Type
_⊢_⇀⦇_,LEDGERS⦈_ = ReflexiveTransitiveClosure {sts = _⊢_⇀⦇_,LEDGER⦈_}