Skip to content

Commit

Permalink
fix ValueNotConservedUTxO in Shelley-MA
Browse files Browse the repository at this point in the history
The problem with the ValueNotConservedUTxO predicate failure in Shelley
was still present in Shelley-MA, namely it could fail to serialize under
certain conditions.

See b57ab4e

Relates: CAD-2168
  • Loading branch information
Jared Corduan committed Nov 2, 2020
1 parent d6179d7 commit f7cafe2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Rules/Utxo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Cardano.Ledger.Shelley (ShelleyBased)
import Cardano.Ledger.ShelleyMA (MaryOrAllegra, ShelleyMAEra)
import Cardano.Ledger.ShelleyMA.Timelocks
import Cardano.Ledger.ShelleyMA.TxBody (TxBody)
import Cardano.Ledger.Torsor (Torsor (..))
import qualified Cardano.Ledger.Val as Val
import Cardano.Slotting.Slot (SlotNo)
import Control.Iterate.SetAlgebra (dom, eval, (∪), (⊆), (⋪), (◁))
Expand Down Expand Up @@ -93,8 +94,8 @@ data UtxoPredicateFailure era
!Coin -- the minimum fee for this transaction
!Coin -- the fee supplied in this transaction
| ValueNotConservedUTxO
!(Core.Value era) -- the Coin consumed by this transaction
!(Core.Value era) -- the Coin produced by this transaction
!(Delta (Core.Value era)) -- the Coin consumed by this transaction
!(Delta (Core.Value era)) -- the Coin produced by this transaction
| WrongNetwork
!Network -- the expected network id
!(Set (Addr era)) -- the set of addresses with incorrect network IDs
Expand All @@ -117,7 +118,7 @@ deriving stock instance
ShelleyBased era =>
Eq (UtxoPredicateFailure era)

instance NoThunks (Core.Value era) => NoThunks (UtxoPredicateFailure era)
instance NoThunks (Delta (Core.Value era)) => NoThunks (UtxoPredicateFailure era)

-- | Calculate the value consumed by the transation.
--
Expand Down Expand Up @@ -204,7 +205,7 @@ utxoTransition = do

let consumed_ = consumed pp utxo txb
produced_ = Shelley.produced pp stakepools txb
consumed_ == produced_ ?! ValueNotConservedUTxO consumed_ produced_
consumed_ == produced_ ?! ValueNotConservedUTxO (toDelta consumed_) (toDelta produced_)

-- process Protocol Parameter Update Proposals
ppup' <- trans @(PPUP era) $ TRC (PPUPEnv slot pp genDelegs, ppup, txup tx)
Expand Down

0 comments on commit f7cafe2

Please sign in to comment.