Skip to content

Commit f1cc871

Browse files
committed
adopt improvements from PR #1169
1 parent 038d00b commit f1cc871

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

src/Ledger/Dijkstra/Specification/Utxo.lagda.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ record HasDepositsChange {a} (A : Type a) : Type a where
142142
field DepositsChangeOf : A → DepositsChange
143143
open HasDepositsChange ⦃...⦄ public
144144
145+
record HasDepositsChangeTop {a} (A : Type a) : Type a where
146+
field DepositsChangeTopOf : A → ℤ
147+
open HasDepositsChangeTop ⦃...⦄ public
148+
149+
record HasDepositsChangeSub {a} (A : Type a) : Type a where
150+
field DepositsChangeSubOf : A → ℤ
151+
open HasDepositsChangeSub ⦃...⦄ public
152+
145153
record HasScriptPool {a} (A : Type a) : Type a where
146154
field ScriptPoolOf : A → ℙ Script
147155
open HasScriptPool ⦃...⦄ public
@@ -210,6 +218,18 @@ instance
210218
HasDonations-UTxOState : HasDonations UTxOState
211219
HasDonations-UTxOState .DonationsOf = UTxOState.donations
212220
221+
HasDepositsChangeTop-DepositsChange : HasDepositsChangeTop DepositsChange
222+
HasDepositsChangeTop-DepositsChange .DepositsChangeTopOf = DepositsChange.depositsChangeTop
223+
224+
HasDepositsChangeSub-DepositsChange : HasDepositsChangeSub DepositsChange
225+
HasDepositsChangeSub-DepositsChange .DepositsChangeSubOf = DepositsChange.depositsChangeSub
226+
227+
HasDepositsChangeTop-UTxOEnv : HasDepositsChangeTop UTxOEnv
228+
HasDepositsChangeTop-UTxOEnv .DepositsChangeTopOf = DepositsChangeTopOf ∘ DepositsChangeOf
229+
230+
HasDepositsChangeSub-UTxOEnv : HasDepositsChangeSub UTxOEnv
231+
HasDepositsChangeSub-UTxOEnv .DepositsChangeSubOf = DepositsChangeSubOf ∘ DepositsChangeOf
232+
213233
unquoteDecl HasCast-DepositsChange
214234
HasCast-UTxOEnv
215235
HasCast-SubUTxOEnv
@@ -257,6 +277,9 @@ minfee pp txTop utxo = pp .a * (SizeOf txTop) + pp .b
257277
instance
258278
HasCoin-UTxO : HasCoin UTxO
259279
HasCoin-UTxO .getCoin = cbalance
280+
281+
HasCoin-UTxOState : HasCoin UTxOState
282+
HasCoin-UTxOState .getCoin s = getCoin (UTxOOf s) + FeesOf s + DonationsOf s
260283
```
261284
-->
262285

@@ -301,6 +324,16 @@ collateralCheck pp txTop utxo =
301324
× coin (balance (utxo ∣ CollateralInputsOf txTop)) * 100 ≥ (TxFeesOf txTop) * pp .collateralPercentage
302325
× (CollateralInputsOf txTop) ≢ ∅
303326
327+
producedTx : Tx ℓ → Value
328+
producedTx tx = balance (outs tx)
329+
+ inject (DonationsOf tx)
330+
+ inject (getCoin (DirectDepositsOf tx))
331+
332+
consumedTx : Tx ℓ → UTxO → Value
333+
consumedTx tx utxo = balance (utxo ∣ SpendInputsOf tx)
334+
+ MintedValueOf tx
335+
+ inject (getCoin (WithdrawalsOf tx))
336+
304337
module _ (depositsChange : DepositsChange) where
305338
306339
open DepositsChange depositsChange
@@ -317,11 +350,6 @@ module _ (depositsChange : DepositsChange) where
317350
depositRefundsTop : Coin
318351
depositRefundsTop = negPart depositsChangeTop
319352
320-
consumedTx : Tx ℓ → UTxO → Value
321-
consumedTx tx utxo = balance (utxo ∣ SpendInputsOf tx)
322-
+ MintedValueOf tx
323-
+ inject (getCoin (WithdrawalsOf tx))
324-
325353
consumed : TopLevelTx → UTxO → Value
326354
consumed txTop utxo = consumedTx txTop utxo
327355
+ inject depositRefundsTop
@@ -338,11 +366,6 @@ In the preservation-of-value equation, direct deposits appear on the
338366
the transaction and that amount is deposited into accounts.
339367

340368
```agda
341-
producedTx : Tx ℓ → Value
342-
producedTx tx = balance (outs tx)
343-
+ inject (DonationsOf tx)
344-
+ inject (getCoin (DirectDepositsOf tx))
345-
346369
produced : TopLevelTx → Value
347370
produced txTop = producedTx txTop
348371
+ inject (TxFeesOf txTop)

src/Ledger/Dijkstra/Specification/Utxow/Properties/PoV.lagda.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ derivation as their final premise. We factor out an extractor:
5151
UTXOW⇒UTXO : ∀ {Γ : UTxOEnv} {s s' : UTxOState} {tx : TopLevelTx}
5252
→ Γ ⊢ s ⇀⦇ tx ,UTXOW⦈ s' → ∃[ legacyMode ] ((Γ , legacyMode) ⊢ s ⇀⦇ tx ,UTXO⦈ s')
5353
54-
UTXOW⇒UTXO (UTXOW-normal-⋯ _ _ _ _ _ _ _ _ _ _ utxo) = false , utxo
55-
UTXOW⇒UTXO (UTXOW-legacy-⋯ _ _ _ _ _ _ _ _ _ _ _ _ _ utxo) = true , utxo
54+
UTXOW⇒UTXO (UTXOW-normal-⋯ _ _ _ _ _ _ _ _ _ _ _ utxo) = false , utxo
55+
UTXOW⇒UTXO (UTXOW-legacy-⋯ _ _ _ _ _ _ _ _ _ _ _ utxo) = true , utxo
5656
```
5757

5858
## `UTXOW-I-getCoin`: collateral collection preserves `getCoin`

0 commit comments

Comments
 (0)