{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Ledger.Alonzo.Rules.Utxo (
AlonzoUTXO,
AlonzoUtxoPredFailure (..),
allegraToAlonzoUtxoPredFailure,
AlonzoUtxoEvent (..),
validateCollateralContainsNonADA,
validateExUnitsTooBigUTxO,
validateOutputTooBigUTxO,
validateInsufficientCollateral,
validateOutsideForecast,
validateScriptsNotPaidUTxO,
validateTooManyCollateralInputs,
validateWrongNetworkInTxBody,
vKeyLocked,
) where
import Cardano.Ledger.Address (
Addr (..),
CompactAddr,
RewardAccount,
isBootstrapCompactAddr,
isPayCredScriptCompactAddr,
)
import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure, shelleyToAllegraUtxoPredFailure)
import qualified Cardano.Ledger.Allegra.Rules as Allegra
import Cardano.Ledger.Allegra.Scripts (ValidityInterval (..))
import Cardano.Ledger.Alonzo.Era (AlonzoEra, AlonzoUTXO)
import Cardano.Ledger.Alonzo.PParams
import Cardano.Ledger.Alonzo.Rules.Ppup ()
import Cardano.Ledger.Alonzo.Rules.Utxos (AlonzoUTXOS, AlonzoUtxosPredFailure)
import Cardano.Ledger.Alonzo.Scripts (ExUnits (..), pointWiseExUnits)
import Cardano.Ledger.Alonzo.Tx (AlonzoEraTx (..), totExUnits)
import Cardano.Ledger.Alonzo.TxBody (
AllegraEraTxBody (..),
AlonzoEraTxBody (..),
AlonzoEraTxOut (..),
MaryEraTxBody (..),
)
import Cardano.Ledger.Alonzo.TxWits (AlonzoEraTxWits (..), unRedeemersL)
import Cardano.Ledger.BaseTypes (
Mismatch (..),
Network,
ProtVer (..),
Relation (..),
ShelleyBase,
StrictMaybe (..),
epochInfo,
knownNonZero,
networkId,
systemStart,
(%.),
)
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..), serialize)
import Cardano.Ledger.Binary.Coders (
Decode (..),
Encode (..),
Wrapped (Open),
decode,
encode,
(!>),
(<!),
)
import Cardano.Ledger.Coin (Coin (unCoin), DeltaCoin, rationalToCoinViaCeiling, toDeltaCoin)
import Cardano.Ledger.Core
import Cardano.Ledger.Credential (Credential (..))
import Cardano.Ledger.Rules.ValidationMode (
Test,
runTest,
runTestOnSignal,
)
import Cardano.Ledger.Shelley.LedgerState (UTxOState (utxosUtxo))
import Cardano.Ledger.Shelley.Rules (ShelleyPpupPredFailure, ShelleyUtxoPredFailure, UtxoEnv (..))
import qualified Cardano.Ledger.Shelley.Rules as Shelley
import Cardano.Ledger.State
import Cardano.Ledger.TxIn (TxIn)
import qualified Cardano.Ledger.Val as Val
import Cardano.Slotting.EpochInfo.API (EpochInfo, epochInfoSlotToUTCTime)
import Cardano.Slotting.EpochInfo.Extend (unsafeLinearExtendEpochInfo)
import Cardano.Slotting.Slot (SlotNo)
import Cardano.Slotting.Time (SystemStart)
import Control.DeepSeq (NFData)
import Control.Monad (unless)
import Control.Monad.Trans.Reader (asks)
import Control.SetAlgebra (eval, (◁))
import Control.State.Transition.Extended
import qualified Data.ByteString.Lazy as BSL (length)
import Data.Coerce (coerce)
import Data.Either (isRight)
import Data.Foldable as F (foldl', sequenceA_, toList)
import qualified Data.Map.Strict as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Word (Word32)
import GHC.Generics (Generic)
import Lens.Micro
import NoThunks.Class (NoThunks)
import Numeric.Natural (Natural)
import Validation
data AlonzoUtxoPredFailure era
=
BadInputsUTxO
(Set TxIn)
| OutsideValidityIntervalUTxO
ValidityInterval
SlotNo
| MaxTxSizeUTxO (Mismatch RelLTEQ Word32)
| InputSetEmptyUTxO
| FeeTooSmallUTxO (Mismatch RelGTEQ Coin)
| ValueNotConservedUTxO (Mismatch RelEQ (Value era))
|
WrongNetwork
Network
(Set Addr)
| WrongNetworkWithdrawal
Network
(Set RewardAccount)
|
OutputTooSmallUTxO
[TxOut era]
|
UtxosFailure (PredicateFailure (EraRule "UTXOS" era))
|
OutputBootAddrAttrsTooBig
[TxOut era]
|
OutputTooBigUTxO
[(Int, Int, TxOut era)]
| InsufficientCollateral
DeltaCoin
Coin
|
ScriptsNotPaidUTxO
(UTxO era)
| ExUnitsTooBigUTxO (Mismatch RelLTEQ ExUnits)
|
CollateralContainsNonADA (Value era)
|
WrongNetworkInTxBody (Mismatch RelEQ Network)
|
OutsideForecast
SlotNo
|
TooManyCollateralInputs (Mismatch RelLTEQ Natural)
| NoCollateralInputs
deriving ((forall x.
AlonzoUtxoPredFailure era -> Rep (AlonzoUtxoPredFailure era) x)
-> (forall x.
Rep (AlonzoUtxoPredFailure era) x -> AlonzoUtxoPredFailure era)
-> Generic (AlonzoUtxoPredFailure era)
forall x.
Rep (AlonzoUtxoPredFailure era) x -> AlonzoUtxoPredFailure era
forall x.
AlonzoUtxoPredFailure era -> Rep (AlonzoUtxoPredFailure era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (AlonzoUtxoPredFailure era) x -> AlonzoUtxoPredFailure era
forall era x.
AlonzoUtxoPredFailure era -> Rep (AlonzoUtxoPredFailure era) x
$cfrom :: forall era x.
AlonzoUtxoPredFailure era -> Rep (AlonzoUtxoPredFailure era) x
from :: forall x.
AlonzoUtxoPredFailure era -> Rep (AlonzoUtxoPredFailure era) x
$cto :: forall era x.
Rep (AlonzoUtxoPredFailure era) x -> AlonzoUtxoPredFailure era
to :: forall x.
Rep (AlonzoUtxoPredFailure era) x -> AlonzoUtxoPredFailure era
Generic)
type instance EraRuleFailure "UTXO" AlonzoEra = AlonzoUtxoPredFailure AlonzoEra
instance InjectRuleFailure "UTXO" AlonzoUtxoPredFailure AlonzoEra
instance InjectRuleFailure "UTXO" ShelleyPpupPredFailure AlonzoEra where
injectFailure :: ShelleyPpupPredFailure AlonzoEra -> EraRuleFailure "UTXO" AlonzoEra
injectFailure = PredicateFailure (EraRule "UTXOS" AlonzoEra)
-> AlonzoUtxoPredFailure AlonzoEra
AlonzoUtxosPredFailure AlonzoEra -> AlonzoUtxoPredFailure AlonzoEra
forall era.
PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
UtxosFailure (AlonzoUtxosPredFailure AlonzoEra
-> AlonzoUtxoPredFailure AlonzoEra)
-> (ShelleyPpupPredFailure AlonzoEra
-> AlonzoUtxosPredFailure AlonzoEra)
-> ShelleyPpupPredFailure AlonzoEra
-> AlonzoUtxoPredFailure AlonzoEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyPpupPredFailure AlonzoEra
-> EraRuleFailure "UTXOS" AlonzoEra
ShelleyPpupPredFailure AlonzoEra
-> AlonzoUtxosPredFailure AlonzoEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure
instance InjectRuleFailure "UTXO" ShelleyUtxoPredFailure AlonzoEra where
injectFailure :: ShelleyUtxoPredFailure AlonzoEra -> EraRuleFailure "UTXO" AlonzoEra
injectFailure = AllegraUtxoPredFailure AlonzoEra -> AlonzoUtxoPredFailure AlonzoEra
forall (t :: * -> *) era.
(EraRuleFailure "PPUP" era ~ t era,
InjectRuleFailure "UTXOS" t era) =>
AllegraUtxoPredFailure era -> AlonzoUtxoPredFailure era
allegraToAlonzoUtxoPredFailure (AllegraUtxoPredFailure AlonzoEra
-> AlonzoUtxoPredFailure AlonzoEra)
-> (ShelleyUtxoPredFailure AlonzoEra
-> AllegraUtxoPredFailure AlonzoEra)
-> ShelleyUtxoPredFailure AlonzoEra
-> AlonzoUtxoPredFailure AlonzoEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxoPredFailure AlonzoEra
-> AllegraUtxoPredFailure AlonzoEra
forall era.
ShelleyUtxoPredFailure era -> AllegraUtxoPredFailure era
shelleyToAllegraUtxoPredFailure
instance InjectRuleFailure "UTXO" AllegraUtxoPredFailure AlonzoEra where
injectFailure :: AllegraUtxoPredFailure AlonzoEra -> EraRuleFailure "UTXO" AlonzoEra
injectFailure = AllegraUtxoPredFailure AlonzoEra -> EraRuleFailure "UTXO" AlonzoEra
AllegraUtxoPredFailure AlonzoEra -> AlonzoUtxoPredFailure AlonzoEra
forall (t :: * -> *) era.
(EraRuleFailure "PPUP" era ~ t era,
InjectRuleFailure "UTXOS" t era) =>
AllegraUtxoPredFailure era -> AlonzoUtxoPredFailure era
allegraToAlonzoUtxoPredFailure
instance InjectRuleFailure "UTXO" AlonzoUtxosPredFailure AlonzoEra where
injectFailure :: AlonzoUtxosPredFailure AlonzoEra -> EraRuleFailure "UTXO" AlonzoEra
injectFailure = PredicateFailure (EraRule "UTXOS" AlonzoEra)
-> AlonzoUtxoPredFailure AlonzoEra
AlonzoUtxosPredFailure AlonzoEra -> EraRuleFailure "UTXO" AlonzoEra
forall era.
PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
UtxosFailure
deriving stock instance
( Era era
, Show (Value era)
, Show (TxOut era)
, Show (TxBody TopTx era)
, Show (PredicateFailure (EraRule "UTXOS" era))
) =>
Show (AlonzoUtxoPredFailure era)
deriving stock instance
( Era era
, Eq (Value era)
, Eq (TxOut era)
, Eq (PredicateFailure (EraRule "UTXOS" era))
) =>
Eq (AlonzoUtxoPredFailure era)
instance
( NoThunks (Value era)
, NoThunks (UTxO era)
, NoThunks (PredicateFailure (EraRule "UTXOS" era))
, NoThunks (TxOut era)
) =>
NoThunks (AlonzoUtxoPredFailure era)
instance
( Era era
, NFData (Value era)
, NFData (UTxO era)
, NFData (PredicateFailure (EraRule "UTXOS" era))
, NFData (TxOut era)
) =>
NFData (AlonzoUtxoPredFailure era)
newtype AlonzoUtxoEvent era
= UtxosEvent (Event (EraRule "UTXOS" era))
deriving ((forall x. AlonzoUtxoEvent era -> Rep (AlonzoUtxoEvent era) x)
-> (forall x. Rep (AlonzoUtxoEvent era) x -> AlonzoUtxoEvent era)
-> Generic (AlonzoUtxoEvent era)
forall x. Rep (AlonzoUtxoEvent era) x -> AlonzoUtxoEvent era
forall x. AlonzoUtxoEvent era -> Rep (AlonzoUtxoEvent era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (AlonzoUtxoEvent era) x -> AlonzoUtxoEvent era
forall era x. AlonzoUtxoEvent era -> Rep (AlonzoUtxoEvent era) x
$cfrom :: forall era x. AlonzoUtxoEvent era -> Rep (AlonzoUtxoEvent era) x
from :: forall x. AlonzoUtxoEvent era -> Rep (AlonzoUtxoEvent era) x
$cto :: forall era x. Rep (AlonzoUtxoEvent era) x -> AlonzoUtxoEvent era
to :: forall x. Rep (AlonzoUtxoEvent era) x -> AlonzoUtxoEvent era
Generic)
deriving instance Show (Event (EraRule "UTXOS" era)) => Show (AlonzoUtxoEvent era)
deriving instance Eq (Event (EraRule "UTXOS" era)) => Eq (AlonzoUtxoEvent era)
instance NFData (Event (EraRule "UTXOS" era)) => NFData (AlonzoUtxoEvent era)
isKeyHashAddr :: Addr -> Bool
isKeyHashAddr :: Addr -> Bool
isKeyHashAddr (AddrBootstrap BootstrapAddress
_) = Bool
True
isKeyHashAddr (Addr Network
_ (KeyHashObj KeyHash Payment
_) StakeReference
_) = Bool
True
isKeyHashAddr Addr
_ = Bool
False
isKeyHashCompactAddr :: CompactAddr -> Bool
isKeyHashCompactAddr :: CompactAddr -> Bool
isKeyHashCompactAddr CompactAddr
cAddr =
CompactAddr -> Bool
isBootstrapCompactAddr CompactAddr
cAddr Bool -> Bool -> Bool
|| Bool -> Bool
not (CompactAddr -> Bool
isPayCredScriptCompactAddr CompactAddr
cAddr)
vKeyLocked :: EraTxOut era => TxOut era -> Bool
vKeyLocked :: forall era. EraTxOut era => TxOut era -> Bool
vKeyLocked TxOut era
txOut =
case TxOut era
txOut TxOut era
-> Getting
(Either Addr CompactAddr) (TxOut era) (Either Addr CompactAddr)
-> Either Addr CompactAddr
forall s a. s -> Getting a s a -> a
^. Getting
(Either Addr CompactAddr) (TxOut era) (Either Addr CompactAddr)
forall era.
EraTxOut era =>
Lens' (TxOut era) (Either Addr CompactAddr)
Lens' (TxOut era) (Either Addr CompactAddr)
addrEitherTxOutL of
Left Addr
addr -> Addr -> Bool
isKeyHashAddr Addr
addr
Right CompactAddr
cAddr -> CompactAddr -> Bool
isKeyHashCompactAddr CompactAddr
cAddr
feesOK ::
forall era.
( AlonzoEraTx era
, EraUTxO era
) =>
PParams era ->
Tx TopTx era ->
UTxO era ->
Test (AlonzoUtxoPredFailure era)
feesOK :: forall era.
(AlonzoEraTx era, EraUTxO era) =>
PParams era
-> Tx TopTx era -> UTxO era -> Test (AlonzoUtxoPredFailure era)
feesOK PParams era
pp Tx TopTx era
tx u :: UTxO era
u@(UTxO Map TxIn (TxOut era)
utxo) =
let txBody :: TxBody TopTx era
txBody = Tx TopTx era
tx Tx TopTx era
-> Getting (TxBody TopTx era) (Tx TopTx era) (TxBody TopTx era)
-> TxBody TopTx era
forall s a. s -> Getting a s a -> a
^. Getting (TxBody TopTx era) (Tx TopTx era) (TxBody TopTx era)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxBody l era)
forall (l :: TxLevel). Lens' (Tx l era) (TxBody l era)
bodyTxL
collateral :: Set TxIn
collateral = TxBody TopTx era
txBody TxBody TopTx era
-> Getting (Set TxIn) (TxBody TopTx era) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody TopTx era) (Set TxIn)
forall era.
AlonzoEraTxBody era =>
Lens' (TxBody TopTx era) (Set TxIn)
Lens' (TxBody TopTx era) (Set TxIn)
collateralInputsTxBodyL
utxoCollateral :: Map TxIn (TxOut era)
utxoCollateral = Exp (Map TxIn (TxOut era)) -> Map TxIn (TxOut era)
forall s t. Embed s t => Exp t -> s
eval (Set TxIn
collateral Set TxIn -> Map TxIn (TxOut era) -> Exp (Map TxIn (TxOut era))
forall k s1 s2 (f :: * -> * -> *) v.
(Ord k, HasExp s1 (Sett k ()), HasExp s2 (f k v)) =>
s1 -> s2 -> Exp (f k v)
◁ Map TxIn (TxOut era)
utxo)
theFee :: Coin
theFee = TxBody TopTx era
txBody TxBody TopTx era -> Getting Coin (TxBody TopTx era) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody TopTx era) Coin
forall era. EraTxBody era => Lens' (TxBody TopTx era) Coin
Lens' (TxBody TopTx era) Coin
feeTxBodyL
minFee :: Coin
minFee = PParams era -> Tx TopTx era -> UTxO era -> Coin
forall era (t :: TxLevel).
EraUTxO era =>
PParams era -> Tx t era -> UTxO era -> Coin
forall (t :: TxLevel). PParams era -> Tx t era -> UTxO era -> Coin
getMinFeeTxUtxo PParams era
pp Tx TopTx era
tx UTxO era
u
in [Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()]
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Applicative f) =>
t (f a) -> f ()
sequenceA_
[
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless
(Coin
minFee Coin -> Coin -> Bool
forall a. Ord a => a -> a -> Bool
<= Coin
theFee)
(Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
forall era. Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
FeeTooSmallUTxO Mismatch {mismatchSupplied :: Coin
mismatchSupplied = Coin
theFee, mismatchExpected :: Coin
mismatchExpected = Coin
minFee})
,
Bool
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Bool
forall a. Map (PlutusPurpose AsIx era) a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Bool)
-> Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Bool
forall a b. (a -> b) -> a -> b
$ Tx TopTx era
tx Tx TopTx era
-> Getting
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Tx TopTx era)
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
-> Map (PlutusPurpose AsIx era) (Data era, ExUnits)
forall s a. s -> Getting a s a -> a
^. (TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> Tx TopTx era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Tx TopTx era)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxWits era)
forall (l :: TxLevel). Lens' (Tx l era) (TxWits era)
witsTxL ((TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> Tx TopTx era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Tx TopTx era))
-> ((Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> Getting
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Tx TopTx era)
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era)
forall era.
AlonzoEraTxWits era =>
Lens' (TxWits era) (Redeemers era)
Lens' (TxWits era) (Redeemers era)
rdmrsTxWitsL ((Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> ((Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era))
-> (Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era)
forall era.
AlonzoEraScript era =>
Lens'
(Redeemers era) (Map (PlutusPurpose AsIx era) (Data era, ExUnits))
Lens'
(Redeemers era) (Map (PlutusPurpose AsIx era) (Data era, ExUnits))
unRedeemersL) (Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$
PParams era
-> TxBody TopTx era
-> Map TxIn (TxOut era)
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall era.
(EraTxBody era, AlonzoEraPParams era) =>
PParams era
-> TxBody TopTx era
-> Map TxIn (TxOut era)
-> Test (AlonzoUtxoPredFailure era)
validateCollateral PParams era
pp TxBody TopTx era
txBody Map TxIn (TxOut era)
utxoCollateral
]
validateCollateral ::
( EraTxBody era
, AlonzoEraPParams era
) =>
PParams era ->
TxBody TopTx era ->
Map.Map TxIn (TxOut era) ->
Test (AlonzoUtxoPredFailure era)
validateCollateral :: forall era.
(EraTxBody era, AlonzoEraPParams era) =>
PParams era
-> TxBody TopTx era
-> Map TxIn (TxOut era)
-> Test (AlonzoUtxoPredFailure era)
validateCollateral PParams era
pp TxBody TopTx era
txb Map TxIn (TxOut era)
utxoCollateral =
[Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()]
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Applicative f) =>
t (f a) -> f ()
sequenceA_
[
Map TxIn (TxOut era)
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall era.
EraTxOut era =>
Map TxIn (TxOut era) -> Test (AlonzoUtxoPredFailure era)
validateScriptsNotPaidUTxO Map TxIn (TxOut era)
utxoCollateral
,
PParams era
-> TxBody TopTx era
-> DeltaCoin
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall era.
(EraTxBody era, AlonzoEraPParams era) =>
PParams era
-> TxBody TopTx era
-> DeltaCoin
-> Test (AlonzoUtxoPredFailure era)
validateInsufficientCollateral PParams era
pp TxBody TopTx era
txb DeltaCoin
bal
,
Map TxIn (TxOut era)
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall (f :: * -> *) era.
(Foldable f, EraTxOut era) =>
f (TxOut era) -> Test (AlonzoUtxoPredFailure era)
validateCollateralContainsNonADA Map TxIn (TxOut era)
utxoCollateral
,
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureIf (Map TxIn (TxOut era) -> Bool
forall a. Map TxIn a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Map TxIn (TxOut era)
utxoCollateral) AlonzoUtxoPredFailure era
forall era. AlonzoUtxoPredFailure era
NoCollateralInputs
]
where
bal :: DeltaCoin
bal = Coin -> DeltaCoin
toDeltaCoin (Coin -> DeltaCoin) -> Coin -> DeltaCoin
forall a b. (a -> b) -> a -> b
$ Map TxIn (TxOut era) -> Coin
forall era (f :: * -> *).
(EraTxOut era, Foldable f) =>
f (TxOut era) -> Coin
sumAllCoin Map TxIn (TxOut era)
utxoCollateral
validateScriptsNotPaidUTxO ::
EraTxOut era =>
Map.Map TxIn (TxOut era) ->
Test (AlonzoUtxoPredFailure era)
validateScriptsNotPaidUTxO :: forall era.
EraTxOut era =>
Map TxIn (TxOut era) -> Test (AlonzoUtxoPredFailure era)
validateScriptsNotPaidUTxO Map TxIn (TxOut era)
utxoCollateral =
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless ((TxOut era -> Bool) -> Map TxIn (TxOut era) -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all TxOut era -> Bool
forall era. EraTxOut era => TxOut era -> Bool
vKeyLocked Map TxIn (TxOut era)
utxoCollateral) (AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$
UTxO era -> AlonzoUtxoPredFailure era
forall era. UTxO era -> AlonzoUtxoPredFailure era
ScriptsNotPaidUTxO (Map TxIn (TxOut era) -> UTxO era
forall era. Map TxIn (TxOut era) -> UTxO era
UTxO ((TxOut era -> Bool) -> Map TxIn (TxOut era) -> Map TxIn (TxOut era)
forall a k. (a -> Bool) -> Map k a -> Map k a
Map.filter (Bool -> Bool
not (Bool -> Bool) -> (TxOut era -> Bool) -> TxOut era -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOut era -> Bool
forall era. EraTxOut era => TxOut era -> Bool
vKeyLocked) Map TxIn (TxOut era)
utxoCollateral))
validateInsufficientCollateral ::
( EraTxBody era
, AlonzoEraPParams era
) =>
PParams era ->
TxBody TopTx era ->
DeltaCoin ->
Test (AlonzoUtxoPredFailure era)
validateInsufficientCollateral :: forall era.
(EraTxBody era, AlonzoEraPParams era) =>
PParams era
-> TxBody TopTx era
-> DeltaCoin
-> Test (AlonzoUtxoPredFailure era)
validateInsufficientCollateral PParams era
pp TxBody TopTx era
txBody DeltaCoin
bal =
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless (Int -> DeltaCoin -> DeltaCoin
forall t i. (Val t, Integral i) => i -> t -> t
Val.scale (Int
100 :: Int) DeltaCoin
bal DeltaCoin -> DeltaCoin -> Bool
forall a. Ord a => a -> a -> Bool
>= Natural -> DeltaCoin -> DeltaCoin
forall t i. (Val t, Integral i) => i -> t -> t
Val.scale Natural
collPerc (Coin -> DeltaCoin
toDeltaCoin Coin
txfee)) (AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$
DeltaCoin -> Coin -> AlonzoUtxoPredFailure era
forall era. DeltaCoin -> Coin -> AlonzoUtxoPredFailure era
InsufficientCollateral DeltaCoin
bal (Coin -> AlonzoUtxoPredFailure era)
-> Coin -> AlonzoUtxoPredFailure era
forall a b. (a -> b) -> a -> b
$
Rational -> Coin
rationalToCoinViaCeiling (Rational -> Coin) -> Rational -> Coin
forall a b. (a -> b) -> a -> b
$
(Natural -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
collPerc Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Coin -> Integer
unCoin Coin
txfee) Integer -> NonZero Integer -> Rational
forall a. Integral a => a -> NonZero a -> Ratio a
%. forall (n :: Natural). (KnownNat n, 1 <= n) => NonZero Integer
knownNonZero @100
where
txfee :: Coin
txfee = TxBody TopTx era
txBody TxBody TopTx era -> Getting Coin (TxBody TopTx era) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody TopTx era) Coin
forall era. EraTxBody era => Lens' (TxBody TopTx era) Coin
Lens' (TxBody TopTx era) Coin
feeTxBodyL
collPerc :: Natural
collPerc = PParams era
pp PParams era -> Getting Natural (PParams era) Natural -> Natural
forall s a. s -> Getting a s a -> a
^. Getting Natural (PParams era) Natural
forall era. AlonzoEraPParams era => Lens' (PParams era) Natural
Lens' (PParams era) Natural
ppCollateralPercentageL
validateCollateralContainsNonADA ::
(Foldable f, EraTxOut era) =>
f (TxOut era) ->
Test (AlonzoUtxoPredFailure era)
validateCollateralContainsNonADA :: forall (f :: * -> *) era.
(Foldable f, EraTxOut era) =>
f (TxOut era) -> Test (AlonzoUtxoPredFailure era)
validateCollateralContainsNonADA f (TxOut era)
collateralTxOuts =
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless (f (TxOut era) -> Bool
forall era (f :: * -> *).
(EraTxOut era, Foldable f) =>
f (TxOut era) -> Bool
areAllAdaOnly f (TxOut era)
collateralTxOuts) (AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$
Value era -> AlonzoUtxoPredFailure era
forall era. Value era -> AlonzoUtxoPredFailure era
CollateralContainsNonADA (Value era -> AlonzoUtxoPredFailure era)
-> Value era -> AlonzoUtxoPredFailure era
forall a b. (a -> b) -> a -> b
$
f (TxOut era) -> Value era
forall era (f :: * -> *).
(EraTxOut era, Foldable f) =>
f (TxOut era) -> Value era
sumAllValue f (TxOut era)
collateralTxOuts
validateOutsideForecast ::
( MaryEraTxBody era
, AlonzoEraTxWits era
, EraTx era
) =>
EpochInfo (Either a) ->
SlotNo ->
SystemStart ->
Tx l era ->
Test (AlonzoUtxoPredFailure era)
validateOutsideForecast :: forall era a (l :: TxLevel).
(MaryEraTxBody era, AlonzoEraTxWits era, EraTx era) =>
EpochInfo (Either a)
-> SlotNo
-> SystemStart
-> Tx l era
-> Test (AlonzoUtxoPredFailure era)
validateOutsideForecast EpochInfo (Either a)
ei SlotNo
slotNo SystemStart
sysSt Tx l era
tx =
case Tx l era
tx Tx l era
-> Getting ValidityInterval (Tx l era) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. (TxBody l era -> Const ValidityInterval (TxBody l era))
-> Tx l era -> Const ValidityInterval (Tx l era)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxBody l era)
forall (l :: TxLevel). Lens' (Tx l era) (TxBody l era)
bodyTxL ((TxBody l era -> Const ValidityInterval (TxBody l era))
-> Tx l era -> Const ValidityInterval (Tx l era))
-> ((ValidityInterval -> Const ValidityInterval ValidityInterval)
-> TxBody l era -> Const ValidityInterval (TxBody l era))
-> Getting ValidityInterval (Tx l era) ValidityInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ValidityInterval -> Const ValidityInterval ValidityInterval)
-> TxBody l era -> Const ValidityInterval (TxBody l era)
forall era (l :: TxLevel).
AllegraEraTxBody era =>
Lens' (TxBody l era) ValidityInterval
forall (l :: TxLevel). Lens' (TxBody l era) ValidityInterval
vldtTxBodyL of
ValidityInterval StrictMaybe SlotNo
_ (SJust SlotNo
ifj)
| Bool -> Bool
not (Bool -> Bool)
-> (Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Bool)
-> Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Bool
forall a. Map (PlutusPurpose AsIx era) a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Bool)
-> Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Bool
forall a b. (a -> b) -> a -> b
$ Tx l era
tx Tx l era
-> Getting
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Tx l era)
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
-> Map (PlutusPurpose AsIx era) (Data era, ExUnits)
forall s a. s -> Getting a s a -> a
^. (TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> Tx l era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Tx l era)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxWits era)
forall (l :: TxLevel). Lens' (Tx l era) (TxWits era)
witsTxL ((TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> Tx l era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Tx l era))
-> ((Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> Getting
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Tx l era)
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era)
forall era.
AlonzoEraTxWits era =>
Lens' (TxWits era) (Redeemers era)
Lens' (TxWits era) (Redeemers era)
rdmrsTxWitsL ((Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era))
-> ((Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era))
-> (Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> TxWits era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (TxWits era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map (PlutusPurpose AsIx era) (Data era, ExUnits)
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits))
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)))
-> Redeemers era
-> Const
(Map (PlutusPurpose AsIx era) (Data era, ExUnits)) (Redeemers era)
forall era.
AlonzoEraScript era =>
Lens'
(Redeemers era) (Map (PlutusPurpose AsIx era) (Data era, ExUnits))
Lens'
(Redeemers era) (Map (PlutusPurpose AsIx era) (Data era, ExUnits))
unRedeemersL ->
let ei' :: EpochInfo (Either a)
ei' = SlotNo -> EpochInfo (Either a) -> EpochInfo (Either a)
forall (m :: * -> *).
Monad m =>
SlotNo -> EpochInfo m -> EpochInfo m
unsafeLinearExtendEpochInfo SlotNo
slotNo EpochInfo (Either a)
ei
in
Bool
-> AlonzoUtxoPredFailure era -> Test (AlonzoUtxoPredFailure era)
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless (Either a UTCTime -> Bool
forall a b. Either a b -> Bool
isRight (EpochInfo (Either a) -> SystemStart -> SlotNo -> Either a UTCTime
forall (m :: * -> *).
(HasCallStack, Monad m) =>
EpochInfo m -> SystemStart -> SlotNo -> m UTCTime
epochInfoSlotToUTCTime EpochInfo (Either a)
ei' SystemStart
sysSt SlotNo
ifj)) (AlonzoUtxoPredFailure era -> Test (AlonzoUtxoPredFailure era))
-> AlonzoUtxoPredFailure era -> Test (AlonzoUtxoPredFailure era)
forall a b. (a -> b) -> a -> b
$ SlotNo -> AlonzoUtxoPredFailure era
forall era. SlotNo -> AlonzoUtxoPredFailure era
OutsideForecast SlotNo
ifj
ValidityInterval
_ -> () -> Test (AlonzoUtxoPredFailure era)
forall a. a -> Validation (NonEmpty (AlonzoUtxoPredFailure era)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
validateOutputTooSmallUTxO ::
(AlonzoEraTxOut era, Foldable f) =>
PParams era ->
f (TxOut era) ->
Test (AlonzoUtxoPredFailure era)
validateOutputTooSmallUTxO :: forall era (f :: * -> *).
(AlonzoEraTxOut era, Foldable f) =>
PParams era -> f (TxOut era) -> Test (AlonzoUtxoPredFailure era)
validateOutputTooSmallUTxO PParams era
pp f (TxOut era)
outputs =
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless ([TxOut era] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [TxOut era]
outputsTooSmall) (AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$ [TxOut era] -> AlonzoUtxoPredFailure era
forall era. [TxOut era] -> AlonzoUtxoPredFailure era
OutputTooSmallUTxO [TxOut era]
outputsTooSmall
where
outputsTooSmall :: [TxOut era]
outputsTooSmall =
(TxOut era -> Bool) -> [TxOut era] -> [TxOut era]
forall a. (a -> Bool) -> [a] -> [a]
filter
( \TxOut era
txOut ->
let v :: Value era
v = TxOut era
txOut TxOut era
-> Getting (Value era) (TxOut era) (Value era) -> Value era
forall s a. s -> Getting a s a -> a
^. Getting (Value era) (TxOut era) (Value era)
forall era. EraTxOut era => Lens' (TxOut era) (Value era)
Lens' (TxOut era) (Value era)
valueTxOutL
in
Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (Integer -> Integer -> Bool) -> Value era -> Value era -> Bool
forall t. Val t => (Integer -> Integer -> Bool) -> t -> t -> Bool
Val.pointwise Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>=) Value era
v (Coin -> Value era
forall t s. Inject t s => t -> s
Val.inject (Coin -> Value era) -> Coin -> Value era
forall a b. (a -> b) -> a -> b
$ PParams era -> TxOut era -> Coin
forall era. EraTxOut era => PParams era -> TxOut era -> Coin
getMinCoinTxOut PParams era
pp TxOut era
txOut)
)
(f (TxOut era) -> [TxOut era]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList f (TxOut era)
outputs)
validateOutputTooBigUTxO ::
( EraTxOut era
, AlonzoEraPParams era
, Foldable f
) =>
PParams era ->
f (TxOut era) ->
Test (AlonzoUtxoPredFailure era)
validateOutputTooBigUTxO :: forall era (f :: * -> *).
(EraTxOut era, AlonzoEraPParams era, Foldable f) =>
PParams era -> f (TxOut era) -> Test (AlonzoUtxoPredFailure era)
validateOutputTooBigUTxO PParams era
pp f (TxOut era)
outputs =
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless ([(Int, Int, TxOut era)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(Int, Int, TxOut era)]
outputsTooBig) (AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$ [(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era
forall era. [(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era
OutputTooBigUTxO [(Int, Int, TxOut era)]
outputsTooBig
where
maxValSize :: Natural
maxValSize = PParams era
pp PParams era -> Getting Natural (PParams era) Natural -> Natural
forall s a. s -> Getting a s a -> a
^. Getting Natural (PParams era) Natural
forall era. AlonzoEraPParams era => Lens' (PParams era) Natural
Lens' (PParams era) Natural
ppMaxValSizeL
protVer :: ProtVer
protVer = PParams era
pp PParams era -> Getting ProtVer (PParams era) ProtVer -> ProtVer
forall s a. s -> Getting a s a -> a
^. Getting ProtVer (PParams era) ProtVer
forall era. EraPParams era => Lens' (PParams era) ProtVer
Lens' (PParams era) ProtVer
ppProtocolVersionL
outputsTooBig :: [(Int, Int, TxOut era)]
outputsTooBig = ([(Int, Int, TxOut era)] -> TxOut era -> [(Int, Int, TxOut era)])
-> [(Int, Int, TxOut era)]
-> f (TxOut era)
-> [(Int, Int, TxOut era)]
forall b a. (b -> a -> b) -> b -> f a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' [(Int, Int, TxOut era)] -> TxOut era -> [(Int, Int, TxOut era)]
accum [] f (TxOut era)
outputs
accum :: [(Int, Int, TxOut era)] -> TxOut era -> [(Int, Int, TxOut era)]
accum [(Int, Int, TxOut era)]
ans TxOut era
txOut =
let v :: Value era
v = TxOut era
txOut TxOut era
-> Getting (Value era) (TxOut era) (Value era) -> Value era
forall s a. s -> Getting a s a -> a
^. Getting (Value era) (TxOut era) (Value era)
forall era. EraTxOut era => Lens' (TxOut era) (Value era)
Lens' (TxOut era) (Value era)
valueTxOutL
serSize :: Natural
serSize = Int64 -> Natural
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Natural) -> Int64 -> Natural
forall a b. (a -> b) -> a -> b
$ ByteString -> Int64
BSL.length (ByteString -> Int64) -> ByteString -> Int64
forall a b. (a -> b) -> a -> b
$ Version -> Value era -> ByteString
forall a. EncCBOR a => Version -> a -> ByteString
serialize (ProtVer -> Version
pvMajor ProtVer
protVer) Value era
v
in if Natural
serSize Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
> Natural
maxValSize
then (Natural -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
serSize, Natural -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
maxValSize, TxOut era
txOut) (Int, Int, TxOut era)
-> [(Int, Int, TxOut era)] -> [(Int, Int, TxOut era)]
forall a. a -> [a] -> [a]
: [(Int, Int, TxOut era)]
ans
else [(Int, Int, TxOut era)]
ans
validateWrongNetworkInTxBody ::
AlonzoEraTxBody era =>
Network ->
TxBody l era ->
Test (AlonzoUtxoPredFailure era)
validateWrongNetworkInTxBody :: forall era (l :: TxLevel).
AlonzoEraTxBody era =>
Network -> TxBody l era -> Test (AlonzoUtxoPredFailure era)
validateWrongNetworkInTxBody Network
netId TxBody l era
txBody =
case TxBody l era
txBody TxBody l era
-> Getting
(StrictMaybe Network) (TxBody l era) (StrictMaybe Network)
-> StrictMaybe Network
forall s a. s -> Getting a s a -> a
^. Getting (StrictMaybe Network) (TxBody l era) (StrictMaybe Network)
forall era (l :: TxLevel).
AlonzoEraTxBody era =>
Lens' (TxBody l era) (StrictMaybe Network)
forall (l :: TxLevel). Lens' (TxBody l era) (StrictMaybe Network)
networkIdTxBodyL of
StrictMaybe Network
SNothing -> () -> Test (AlonzoUtxoPredFailure era)
forall a. a -> Validation (NonEmpty (AlonzoUtxoPredFailure era)) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
SJust Network
bid ->
Bool
-> AlonzoUtxoPredFailure era -> Test (AlonzoUtxoPredFailure era)
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless (Network
netId Network -> Network -> Bool
forall a. Eq a => a -> a -> Bool
== Network
bid) (AlonzoUtxoPredFailure era -> Test (AlonzoUtxoPredFailure era))
-> AlonzoUtxoPredFailure era -> Test (AlonzoUtxoPredFailure era)
forall a b. (a -> b) -> a -> b
$
Mismatch RelEQ Network -> AlonzoUtxoPredFailure era
forall era. Mismatch RelEQ Network -> AlonzoUtxoPredFailure era
WrongNetworkInTxBody Mismatch {mismatchSupplied :: Network
mismatchSupplied = Network
bid, mismatchExpected :: Network
mismatchExpected = Network
netId}
validateExUnitsTooBigUTxO ::
( AlonzoEraTxWits era
, EraTx era
, AlonzoEraPParams era
) =>
PParams era ->
Tx l era ->
Test (AlonzoUtxoPredFailure era)
validateExUnitsTooBigUTxO :: forall era (l :: TxLevel).
(AlonzoEraTxWits era, EraTx era, AlonzoEraPParams era) =>
PParams era -> Tx l era -> Test (AlonzoUtxoPredFailure era)
validateExUnitsTooBigUTxO PParams era
pp Tx l era
tx =
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless ((Natural -> Natural -> Bool) -> ExUnits -> ExUnits -> Bool
pointWiseExUnits Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
(<=) ExUnits
totalExUnits ExUnits
maxTxExUnits) (AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$
Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era
ExUnitsTooBigUTxO Mismatch {mismatchSupplied :: ExUnits
mismatchSupplied = ExUnits
totalExUnits, mismatchExpected :: ExUnits
mismatchExpected = ExUnits
maxTxExUnits}
where
maxTxExUnits :: ExUnits
maxTxExUnits = PParams era
pp PParams era -> Getting ExUnits (PParams era) ExUnits -> ExUnits
forall s a. s -> Getting a s a -> a
^. Getting ExUnits (PParams era) ExUnits
forall era. AlonzoEraPParams era => Lens' (PParams era) ExUnits
Lens' (PParams era) ExUnits
ppMaxTxExUnitsL
totalExUnits :: ExUnits
totalExUnits = Tx l era -> ExUnits
forall era (l :: TxLevel).
(EraTx era, AlonzoEraTxWits era) =>
Tx l era -> ExUnits
totExUnits Tx l era
tx
validateTooManyCollateralInputs ::
AlonzoEraTxBody era =>
PParams era ->
TxBody TopTx era ->
Test (AlonzoUtxoPredFailure era)
validateTooManyCollateralInputs :: forall era.
AlonzoEraTxBody era =>
PParams era -> TxBody TopTx era -> Test (AlonzoUtxoPredFailure era)
validateTooManyCollateralInputs PParams era
pp TxBody TopTx era
txBody =
Bool
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall e. Bool -> e -> Validation (NonEmpty e) ()
failureUnless (Natural
numColl Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
<= Natural
maxColl) (AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ())
-> AlonzoUtxoPredFailure era
-> Validation (NonEmpty (AlonzoUtxoPredFailure era)) ()
forall a b. (a -> b) -> a -> b
$
Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era
TooManyCollateralInputs Mismatch {mismatchSupplied :: Natural
mismatchSupplied = Natural
numColl, mismatchExpected :: Natural
mismatchExpected = Natural
maxColl}
where
maxColl, numColl :: Natural
maxColl :: Natural
maxColl = PParams era
pp PParams era -> Getting Natural (PParams era) Natural -> Natural
forall s a. s -> Getting a s a -> a
^. Getting Natural (PParams era) Natural
forall era. AlonzoEraPParams era => Lens' (PParams era) Natural
Lens' (PParams era) Natural
ppMaxCollateralInputsL
numColl :: Natural
numColl = Int -> Natural
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Natural) -> (Set TxIn -> Int) -> Set TxIn -> Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set TxIn -> Int
forall a. Set a -> Int
Set.size (Set TxIn -> Natural) -> Set TxIn -> Natural
forall a b. (a -> b) -> a -> b
$ TxBody TopTx era
txBody TxBody TopTx era
-> Getting (Set TxIn) (TxBody TopTx era) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody TopTx era) (Set TxIn)
forall era.
AlonzoEraTxBody era =>
Lens' (TxBody TopTx era) (Set TxIn)
Lens' (TxBody TopTx era) (Set TxIn)
collateralInputsTxBodyL
utxoTransition ::
forall era.
( EraUTxO era
, AlonzoEraTx era
, AtMostEra "Babbage" era
, EraRule "UTXO" era ~ AlonzoUTXO era
, InjectRuleFailure "UTXO" ShelleyUtxoPredFailure era
, InjectRuleFailure "UTXO" AlonzoUtxoPredFailure era
, InjectRuleFailure "UTXO" AllegraUtxoPredFailure era
, Embed (EraRule "UTXOS" era) (AlonzoUTXO era)
, Environment (EraRule "UTXOS" era) ~ UtxoEnv era
, State (EraRule "UTXOS" era) ~ UTxOState era
, Signal (EraRule "UTXOS" era) ~ Tx TopTx era
, EraCertState era
, SafeToHash (TxWits era)
) =>
TransitionRule (EraRule "UTXO" era)
utxoTransition :: forall era.
(EraUTxO era, AlonzoEraTx era, AtMostEra "Babbage" era,
EraRule "UTXO" era ~ AlonzoUTXO era,
InjectRuleFailure "UTXO" ShelleyUtxoPredFailure era,
InjectRuleFailure "UTXO" AlonzoUtxoPredFailure era,
InjectRuleFailure "UTXO" AllegraUtxoPredFailure era,
Embed (EraRule "UTXOS" era) (AlonzoUTXO era),
Environment (EraRule "UTXOS" era) ~ UtxoEnv era,
State (EraRule "UTXOS" era) ~ UTxOState era,
Signal (EraRule "UTXOS" era) ~ Tx TopTx era, EraCertState era,
SafeToHash (TxWits era)) =>
TransitionRule (EraRule "UTXO" era)
utxoTransition = do
TRC (UtxoEnv slot pp dpstate, utxos, tx) <- Rule
(AlonzoUTXO era)
'Transition
(RuleContext 'Transition (AlonzoUTXO era))
F (Clause (AlonzoUTXO era) 'Transition) (TRC (AlonzoUTXO era))
forall sts (rtype :: RuleType).
Rule sts rtype (RuleContext rtype sts)
judgmentContext
let utxo = UTxOState era -> UTxO era
forall era. UTxOState era -> UTxO era
utxosUtxo State (AlonzoUTXO era)
UTxOState era
utxos
let txBody = Tx TopTx era
Signal (AlonzoUTXO era)
tx Tx TopTx era
-> Getting (TxBody TopTx era) (Tx TopTx era) (TxBody TopTx era)
-> TxBody TopTx era
forall s a. s -> Getting a s a -> a
^. Getting (TxBody TopTx era) (Tx TopTx era) (TxBody TopTx era)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxBody l era)
forall (l :: TxLevel). Lens' (Tx l era) (TxBody l era)
bodyTxL
inputsAndCollateral =
Set TxIn -> Set TxIn -> Set TxIn
forall a. Ord a => Set a -> Set a -> Set a
Set.union
(TxBody TopTx era
txBody TxBody TopTx era
-> Getting (Set TxIn) (TxBody TopTx era) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody TopTx era) (Set TxIn)
forall era (l :: TxLevel).
EraTxBody era =>
Lens' (TxBody l era) (Set TxIn)
forall (l :: TxLevel). Lens' (TxBody l era) (Set TxIn)
inputsTxBodyL)
(TxBody TopTx era
txBody TxBody TopTx era
-> Getting (Set TxIn) (TxBody TopTx era) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody TopTx era) (Set TxIn)
forall era.
AlonzoEraTxBody era =>
Lens' (TxBody TopTx era) (Set TxIn)
Lens' (TxBody TopTx era) (Set TxIn)
collateralInputsTxBodyL)
runTest $
Allegra.validateOutsideValidityIntervalUTxO slot txBody
sysSt <- liftSTS $ asks systemStart
ei <- liftSTS $ asks epochInfo
runTest $ validateOutsideForecast ei slot sysSt tx
runTestOnSignal $ Shelley.validateInputSetEmptyUTxO txBody
runTest $ feesOK pp tx utxo
runTest $ Shelley.validateBadInputsUTxO utxo inputsAndCollateral
runTest $ Shelley.validateValueNotConservedUTxO pp utxo dpstate txBody
let outputs = TxBody TopTx era
txBody TxBody TopTx era
-> Getting
(StrictSeq (TxOut era)) (TxBody TopTx era) (StrictSeq (TxOut era))
-> StrictSeq (TxOut era)
forall s a. s -> Getting a s a -> a
^. Getting
(StrictSeq (TxOut era)) (TxBody TopTx era) (StrictSeq (TxOut era))
forall era (l :: TxLevel).
EraTxBody era =>
Lens' (TxBody l era) (StrictSeq (TxOut era))
forall (l :: TxLevel). Lens' (TxBody l era) (StrictSeq (TxOut era))
outputsTxBodyL
runTest $ validateOutputTooSmallUTxO pp outputs
runTest $ validateOutputTooBigUTxO pp outputs
runTestOnSignal $ Shelley.validateOutputBootAddrAttrsTooBig outputs
netId <- liftSTS $ asks networkId
runTestOnSignal $ Shelley.validateWrongNetwork netId outputs
runTestOnSignal $ Shelley.validateWrongNetworkWithdrawal netId txBody
runTestOnSignal $ validateWrongNetworkInTxBody netId txBody
runTestOnSignal $ Shelley.validateMaxTxSizeUTxO pp tx
runTest $ validateExUnitsTooBigUTxO pp tx
trans @(EraRule "UTXOS" era) =<< coerce <$> judgmentContext
instance
forall era.
( EraUTxO era
, AlonzoEraTx era
, Embed (EraRule "UTXOS" era) (AlonzoUTXO era)
, Environment (EraRule "UTXOS" era) ~ UtxoEnv era
, State (EraRule "UTXOS" era) ~ UTxOState era
, Signal (EraRule "UTXOS" era) ~ Tx TopTx era
, EraRule "UTXO" era ~ AlonzoUTXO era
, InjectRuleFailure "UTXO" ShelleyUtxoPredFailure era
, InjectRuleFailure "UTXO" AlonzoUtxoPredFailure era
, InjectRuleFailure "UTXO" AllegraUtxoPredFailure era
, AtMostEra "Babbage" era
, EraCertState era
, SafeToHash (TxWits era)
) =>
STS (AlonzoUTXO era)
where
type State (AlonzoUTXO era) = UTxOState era
type Signal (AlonzoUTXO era) = Tx TopTx era
type Environment (AlonzoUTXO era) = UtxoEnv era
type BaseM (AlonzoUTXO era) = ShelleyBase
type PredicateFailure (AlonzoUTXO era) = AlonzoUtxoPredFailure era
type Event (AlonzoUTXO era) = AlonzoUtxoEvent era
initialRules :: [InitialRule (AlonzoUTXO era)]
initialRules = []
transitionRules :: [TransitionRule (AlonzoUTXO era)]
transitionRules = [TransitionRule (EraRule "UTXO" era)
TransitionRule (AlonzoUTXO era)
forall era.
(EraUTxO era, AlonzoEraTx era, AtMostEra "Babbage" era,
EraRule "UTXO" era ~ AlonzoUTXO era,
InjectRuleFailure "UTXO" ShelleyUtxoPredFailure era,
InjectRuleFailure "UTXO" AlonzoUtxoPredFailure era,
InjectRuleFailure "UTXO" AllegraUtxoPredFailure era,
Embed (EraRule "UTXOS" era) (AlonzoUTXO era),
Environment (EraRule "UTXOS" era) ~ UtxoEnv era,
State (EraRule "UTXOS" era) ~ UTxOState era,
Signal (EraRule "UTXOS" era) ~ Tx TopTx era, EraCertState era,
SafeToHash (TxWits era)) =>
TransitionRule (EraRule "UTXO" era)
utxoTransition]
assertions :: [Assertion (AlonzoUTXO era)]
assertions = [Assertion (AlonzoUTXO era)
forall era (rule :: * -> *).
(EraTx era, SafeToHash (TxWits era),
Signal (rule era) ~ Tx TopTx era) =>
Assertion (rule era)
Shelley.validSizeComputationCheck]
instance
( Era era
, STS (AlonzoUTXOS era)
, PredicateFailure (EraRule "UTXOS" era) ~ AlonzoUtxosPredFailure era
, Event (EraRule "UTXOS" era) ~ Event (AlonzoUTXOS era)
) =>
Embed (AlonzoUTXOS era) (AlonzoUTXO era)
where
wrapFailed :: PredicateFailure (AlonzoUTXOS era)
-> PredicateFailure (AlonzoUTXO era)
wrapFailed = PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
PredicateFailure (AlonzoUTXOS era)
-> PredicateFailure (AlonzoUTXO era)
forall era.
PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
UtxosFailure
wrapEvent :: Event (AlonzoUTXOS era) -> Event (AlonzoUTXO era)
wrapEvent = Event (EraRule "UTXOS" era) -> AlonzoUtxoEvent era
Event (AlonzoUTXOS era) -> Event (AlonzoUTXO era)
forall era. Event (EraRule "UTXOS" era) -> AlonzoUtxoEvent era
UtxosEvent
instance
( Era era
, EncCBOR (TxOut era)
, EncCBOR (Value era)
, EncCBOR (PredicateFailure (EraRule "UTXOS" era))
) =>
EncCBOR (AlonzoUtxoPredFailure era)
where
encCBOR :: AlonzoUtxoPredFailure era -> Encoding
encCBOR AlonzoUtxoPredFailure era
x = Encode Open (AlonzoUtxoPredFailure era) -> Encoding
forall (w :: Wrapped) t. Encode w t -> Encoding
encode (AlonzoUtxoPredFailure era
-> Encode Open (AlonzoUtxoPredFailure era)
forall era.
(Era era, EncCBOR (TxOut era), EncCBOR (Value era),
EncCBOR (PredicateFailure (EraRule "UTXOS" era))) =>
AlonzoUtxoPredFailure era
-> Encode Open (AlonzoUtxoPredFailure era)
encFail AlonzoUtxoPredFailure era
x)
encFail ::
forall era.
( Era era
, EncCBOR (TxOut era)
, EncCBOR (Value era)
, EncCBOR (PredicateFailure (EraRule "UTXOS" era))
) =>
AlonzoUtxoPredFailure era ->
Encode Open (AlonzoUtxoPredFailure era)
encFail :: forall era.
(Era era, EncCBOR (TxOut era), EncCBOR (Value era),
EncCBOR (PredicateFailure (EraRule "UTXOS" era))) =>
AlonzoUtxoPredFailure era
-> Encode Open (AlonzoUtxoPredFailure era)
encFail (BadInputsUTxO Set TxIn
ins) =
(Set TxIn -> AlonzoUtxoPredFailure era)
-> Word -> Encode Open (Set TxIn -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era. Set TxIn -> AlonzoUtxoPredFailure era
BadInputsUTxO @era) Word
0 Encode Open (Set TxIn -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Set TxIn)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Set TxIn -> Encode (Closed Dense) (Set TxIn)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Set TxIn
ins
encFail (OutsideValidityIntervalUTxO ValidityInterval
a SlotNo
b) =
(ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open (ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era
forall era. ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era
OutsideValidityIntervalUTxO Word
1 Encode
Open (ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) ValidityInterval
-> Encode Open (SlotNo -> AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> ValidityInterval -> Encode (Closed Dense) ValidityInterval
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To ValidityInterval
a Encode Open (SlotNo -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) SlotNo
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> SlotNo -> Encode (Closed Dense) SlotNo
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To SlotNo
b
encFail (MaxTxSizeUTxO Mismatch RelLTEQ Word32
m) =
(Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open (Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era
MaxTxSizeUTxO Word
2 Encode Open (Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Mismatch RelLTEQ Word32)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Mismatch RelLTEQ Word32
-> Encode (Closed Dense) (Mismatch RelLTEQ Word32)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Mismatch RelLTEQ Word32
m
encFail AlonzoUtxoPredFailure era
InputSetEmptyUTxO =
AlonzoUtxoPredFailure era
-> Word -> Encode Open (AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum AlonzoUtxoPredFailure era
forall era. AlonzoUtxoPredFailure era
InputSetEmptyUTxO Word
3
encFail (FeeTooSmallUTxO Mismatch RelGTEQ Coin
m) =
(Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era)
-> Word
-> Encode Open (Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
forall era. Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
FeeTooSmallUTxO Word
4 Encode Open (Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Mismatch RelGTEQ Coin)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Mismatch RelGTEQ Coin
-> Encode (Closed Dense) (Mismatch RelGTEQ Coin)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Mismatch RelGTEQ Coin
m
encFail (ValueNotConservedUTxO Mismatch RelEQ (Value era)
m) =
(Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open (Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era. Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era
ValueNotConservedUTxO @era) Word
5 Encode
Open (Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Mismatch RelEQ (Value era))
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Mismatch RelEQ (Value era)
-> Encode (Closed Dense) (Mismatch RelEQ (Value era))
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Mismatch RelEQ (Value era)
m
encFail (OutputTooSmallUTxO [TxOut era]
outs) =
([TxOut era] -> AlonzoUtxoPredFailure era)
-> Word -> Encode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era. [TxOut era] -> AlonzoUtxoPredFailure era
OutputTooSmallUTxO @era) Word
6 Encode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) [TxOut era]
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> [TxOut era] -> Encode (Closed Dense) [TxOut era]
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To [TxOut era]
outs
encFail (UtxosFailure PredicateFailure (EraRule "UTXOS" era)
a) =
(PredicateFailure (EraRule "UTXOS" era)
-> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open
(PredicateFailure (EraRule "UTXOS" era)
-> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era.
PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
UtxosFailure @era) Word
7 Encode
Open
(PredicateFailure (EraRule "UTXOS" era)
-> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (PredicateFailure (EraRule "UTXOS" era))
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> PredicateFailure (EraRule "UTXOS" era)
-> Encode (Closed Dense) (PredicateFailure (EraRule "UTXOS" era))
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To PredicateFailure (EraRule "UTXOS" era)
a
encFail (WrongNetwork Network
right Set Addr
wrongs) =
(Network -> Set Addr -> AlonzoUtxoPredFailure era)
-> Word
-> Encode Open (Network -> Set Addr -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era. Network -> Set Addr -> AlonzoUtxoPredFailure era
WrongNetwork @era) Word
8 Encode Open (Network -> Set Addr -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) Network
-> Encode Open (Set Addr -> AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Network -> Encode (Closed Dense) Network
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Network
right Encode Open (Set Addr -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Set Addr)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Set Addr -> Encode (Closed Dense) (Set Addr)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Set Addr
wrongs
encFail (WrongNetworkWithdrawal Network
right Set RewardAccount
wrongs) =
(Network -> Set RewardAccount -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open (Network -> Set RewardAccount -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era.
Network -> Set RewardAccount -> AlonzoUtxoPredFailure era
WrongNetworkWithdrawal @era) Word
9 Encode
Open (Network -> Set RewardAccount -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) Network
-> Encode Open (Set RewardAccount -> AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Network -> Encode (Closed Dense) Network
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Network
right Encode Open (Set RewardAccount -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Set RewardAccount)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Set RewardAccount -> Encode (Closed Dense) (Set RewardAccount)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Set RewardAccount
wrongs
encFail (OutputBootAddrAttrsTooBig [TxOut era]
outs) =
([TxOut era] -> AlonzoUtxoPredFailure era)
-> Word -> Encode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era. [TxOut era] -> AlonzoUtxoPredFailure era
OutputBootAddrAttrsTooBig @era) Word
10 Encode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) [TxOut era]
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> [TxOut era] -> Encode (Closed Dense) [TxOut era]
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To [TxOut era]
outs
encFail (OutputTooBigUTxO [(Int, Int, TxOut era)]
outs) =
([(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open ([(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum (forall era. [(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era
OutputTooBigUTxO @era) Word
12 Encode Open ([(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) [(Int, Int, TxOut era)]
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> [(Int, Int, TxOut era)]
-> Encode (Closed Dense) [(Int, Int, TxOut era)]
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To [(Int, Int, TxOut era)]
outs
encFail (InsufficientCollateral DeltaCoin
a Coin
b) =
(DeltaCoin -> Coin -> AlonzoUtxoPredFailure era)
-> Word
-> Encode Open (DeltaCoin -> Coin -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum DeltaCoin -> Coin -> AlonzoUtxoPredFailure era
forall era. DeltaCoin -> Coin -> AlonzoUtxoPredFailure era
InsufficientCollateral Word
13 Encode Open (DeltaCoin -> Coin -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) DeltaCoin
-> Encode Open (Coin -> AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> DeltaCoin -> Encode (Closed Dense) DeltaCoin
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To DeltaCoin
a Encode Open (Coin -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) Coin
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Coin -> Encode (Closed Dense) Coin
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Coin
b
encFail (ScriptsNotPaidUTxO UTxO era
a) =
(UTxO era -> AlonzoUtxoPredFailure era)
-> Word -> Encode Open (UTxO era -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum UTxO era -> AlonzoUtxoPredFailure era
forall era. UTxO era -> AlonzoUtxoPredFailure era
ScriptsNotPaidUTxO Word
14 Encode Open (UTxO era -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (UTxO era)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> UTxO era -> Encode (Closed Dense) (UTxO era)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To UTxO era
a
encFail (ExUnitsTooBigUTxO Mismatch RelLTEQ ExUnits
m) =
(Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open (Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era
ExUnitsTooBigUTxO Word
15 Encode Open (Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Mismatch RelLTEQ ExUnits)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Mismatch RelLTEQ ExUnits
-> Encode (Closed Dense) (Mismatch RelLTEQ ExUnits)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Mismatch RelLTEQ ExUnits
m
encFail (CollateralContainsNonADA Value era
a) =
(Value era -> AlonzoUtxoPredFailure era)
-> Word -> Encode Open (Value era -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum Value era -> AlonzoUtxoPredFailure era
forall era. Value era -> AlonzoUtxoPredFailure era
CollateralContainsNonADA Word
16 Encode Open (Value era -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Value era)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Value era -> Encode (Closed Dense) (Value era)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Value era
a
encFail (WrongNetworkInTxBody Mismatch RelEQ Network
m) =
(Mismatch RelEQ Network -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open (Mismatch RelEQ Network -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum Mismatch RelEQ Network -> AlonzoUtxoPredFailure era
forall era. Mismatch RelEQ Network -> AlonzoUtxoPredFailure era
WrongNetworkInTxBody Word
17 Encode Open (Mismatch RelEQ Network -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Mismatch RelEQ Network)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Mismatch RelEQ Network
-> Encode (Closed Dense) (Mismatch RelEQ Network)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Mismatch RelEQ Network
m
encFail (OutsideForecast SlotNo
a) =
(SlotNo -> AlonzoUtxoPredFailure era)
-> Word -> Encode Open (SlotNo -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum SlotNo -> AlonzoUtxoPredFailure era
forall era. SlotNo -> AlonzoUtxoPredFailure era
OutsideForecast Word
18 Encode Open (SlotNo -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) SlotNo
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> SlotNo -> Encode (Closed Dense) SlotNo
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To SlotNo
a
encFail (TooManyCollateralInputs Mismatch RelLTEQ Natural
m) =
(Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era)
-> Word
-> Encode
Open (Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era
TooManyCollateralInputs Word
19 Encode Open (Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era)
-> Encode (Closed Dense) (Mismatch RelLTEQ Natural)
-> Encode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> Mismatch RelLTEQ Natural
-> Encode (Closed Dense) (Mismatch RelLTEQ Natural)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To Mismatch RelLTEQ Natural
m
encFail AlonzoUtxoPredFailure era
NoCollateralInputs =
AlonzoUtxoPredFailure era
-> Word -> Encode Open (AlonzoUtxoPredFailure era)
forall t. t -> Word -> Encode Open t
Sum AlonzoUtxoPredFailure era
forall era. AlonzoUtxoPredFailure era
NoCollateralInputs Word
20
decFail ::
( Era era
, DecCBOR (TxOut era)
, DecCBOR (Value era)
, DecCBOR (PredicateFailure (EraRule "UTXOS" era))
) =>
Word ->
Decode Open (AlonzoUtxoPredFailure era)
decFail :: forall era.
(Era era, DecCBOR (TxOut era), DecCBOR (Value era),
DecCBOR (PredicateFailure (EraRule "UTXOS" era))) =>
Word -> Decode Open (AlonzoUtxoPredFailure era)
decFail Word
0 = (Set TxIn -> AlonzoUtxoPredFailure era)
-> Decode Open (Set TxIn -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Set TxIn -> AlonzoUtxoPredFailure era
forall era. Set TxIn -> AlonzoUtxoPredFailure era
BadInputsUTxO Decode Open (Set TxIn -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 0)) (Set TxIn)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 0)) (Set TxIn)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
1 = (ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era)
-> Decode
Open (ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era
forall era. ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era
OutsideValidityIntervalUTxO Decode
Open (ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 2)) ValidityInterval
-> Decode Open (SlotNo -> AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 2)) ValidityInterval
forall t (w :: Wrapped). DecCBOR t => Decode w t
From Decode Open (SlotNo -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 1)) SlotNo
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 1)) SlotNo
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
2 = (Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era)
-> Decode
Open (Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era
MaxTxSizeUTxO Decode Open (Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 3)) (Mismatch RelLTEQ Word32)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 3)) (Mismatch RelLTEQ Word32)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
3 = AlonzoUtxoPredFailure era
-> Decode Open (AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD AlonzoUtxoPredFailure era
forall era. AlonzoUtxoPredFailure era
InputSetEmptyUTxO
decFail Word
4 = (Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era)
-> Decode Open (Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
forall era. Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
FeeTooSmallUTxO Decode Open (Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 4)) (Mismatch RelGTEQ Coin)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 4)) (Mismatch RelGTEQ Coin)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
5 = (Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era)
-> Decode
Open (Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era
forall era. Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era
ValueNotConservedUTxO Decode
Open (Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 5)) (Mismatch RelEQ (Value era))
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 5)) (Mismatch RelEQ (Value era))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
6 = ([TxOut era] -> AlonzoUtxoPredFailure era)
-> Decode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD [TxOut era] -> AlonzoUtxoPredFailure era
forall era. [TxOut era] -> AlonzoUtxoPredFailure era
OutputTooSmallUTxO Decode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 6)) [TxOut era]
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 6)) [TxOut era]
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
7 = (PredicateFailure (EraRule "UTXOS" era)
-> AlonzoUtxoPredFailure era)
-> Decode
Open
(PredicateFailure (EraRule "UTXOS" era)
-> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
forall era.
PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
UtxosFailure Decode
Open
(PredicateFailure (EraRule "UTXOS" era)
-> AlonzoUtxoPredFailure era)
-> Decode
(Closed (ZonkAny 7)) (PredicateFailure (EraRule "UTXOS" era))
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode
(Closed (ZonkAny 7)) (PredicateFailure (EraRule "UTXOS" era))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
8 = (Network -> Set Addr -> AlonzoUtxoPredFailure era)
-> Decode Open (Network -> Set Addr -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Network -> Set Addr -> AlonzoUtxoPredFailure era
forall era. Network -> Set Addr -> AlonzoUtxoPredFailure era
WrongNetwork Decode Open (Network -> Set Addr -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 9)) Network
-> Decode Open (Set Addr -> AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 9)) Network
forall t (w :: Wrapped). DecCBOR t => Decode w t
From Decode Open (Set Addr -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 8)) (Set Addr)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 8)) (Set Addr)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
9 = (Network -> Set RewardAccount -> AlonzoUtxoPredFailure era)
-> Decode
Open (Network -> Set RewardAccount -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Network -> Set RewardAccount -> AlonzoUtxoPredFailure era
forall era.
Network -> Set RewardAccount -> AlonzoUtxoPredFailure era
WrongNetworkWithdrawal Decode
Open (Network -> Set RewardAccount -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 11)) Network
-> Decode Open (Set RewardAccount -> AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 11)) Network
forall t (w :: Wrapped). DecCBOR t => Decode w t
From Decode Open (Set RewardAccount -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 10)) (Set RewardAccount)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 10)) (Set RewardAccount)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
10 = ([TxOut era] -> AlonzoUtxoPredFailure era)
-> Decode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD [TxOut era] -> AlonzoUtxoPredFailure era
forall era. [TxOut era] -> AlonzoUtxoPredFailure era
OutputBootAddrAttrsTooBig Decode Open ([TxOut era] -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 12)) [TxOut era]
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 12)) [TxOut era]
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
12 = ([(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era)
-> Decode
Open ([(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD [(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era
forall era. [(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era
OutputTooBigUTxO Decode Open ([(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 13)) [(Int, Int, TxOut era)]
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 13)) [(Int, Int, TxOut era)]
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
13 = (DeltaCoin -> Coin -> AlonzoUtxoPredFailure era)
-> Decode Open (DeltaCoin -> Coin -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD DeltaCoin -> Coin -> AlonzoUtxoPredFailure era
forall era. DeltaCoin -> Coin -> AlonzoUtxoPredFailure era
InsufficientCollateral Decode Open (DeltaCoin -> Coin -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 15)) DeltaCoin
-> Decode Open (Coin -> AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 15)) DeltaCoin
forall t (w :: Wrapped). DecCBOR t => Decode w t
From Decode Open (Coin -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 14)) Coin
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 14)) Coin
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
14 = (UTxO era -> AlonzoUtxoPredFailure era)
-> Decode Open (UTxO era -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD UTxO era -> AlonzoUtxoPredFailure era
forall era. UTxO era -> AlonzoUtxoPredFailure era
ScriptsNotPaidUTxO Decode Open (UTxO era -> AlonzoUtxoPredFailure era)
-> Decode (Closed Dense) (UTxO era)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! (forall s. Decoder s (UTxO era))
-> Decode (Closed Dense) (UTxO era)
forall t. (forall s. Decoder s t) -> Decode (Closed Dense) t
D (Map TxIn (TxOut era) -> UTxO era
forall era. Map TxIn (TxOut era) -> UTxO era
UTxO (Map TxIn (TxOut era) -> UTxO era)
-> Decoder s (Map TxIn (TxOut era)) -> Decoder s (UTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (Map TxIn (TxOut era))
forall s. Decoder s (Map TxIn (TxOut era))
forall a s. DecCBOR a => Decoder s a
decCBOR)
decFail Word
15 = (Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era)
-> Decode
Open (Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era
ExUnitsTooBigUTxO Decode Open (Mismatch RelLTEQ ExUnits -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 16)) (Mismatch RelLTEQ ExUnits)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 16)) (Mismatch RelLTEQ ExUnits)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
16 = (Value era -> AlonzoUtxoPredFailure era)
-> Decode Open (Value era -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Value era -> AlonzoUtxoPredFailure era
forall era. Value era -> AlonzoUtxoPredFailure era
CollateralContainsNonADA Decode Open (Value era -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 17)) (Value era)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 17)) (Value era)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
17 = (Mismatch RelEQ Network -> AlonzoUtxoPredFailure era)
-> Decode
Open (Mismatch RelEQ Network -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Mismatch RelEQ Network -> AlonzoUtxoPredFailure era
forall era. Mismatch RelEQ Network -> AlonzoUtxoPredFailure era
WrongNetworkInTxBody Decode Open (Mismatch RelEQ Network -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 18)) (Mismatch RelEQ Network)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 18)) (Mismatch RelEQ Network)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
18 = (SlotNo -> AlonzoUtxoPredFailure era)
-> Decode Open (SlotNo -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD SlotNo -> AlonzoUtxoPredFailure era
forall era. SlotNo -> AlonzoUtxoPredFailure era
OutsideForecast Decode Open (SlotNo -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 19)) SlotNo
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 19)) SlotNo
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
19 = (Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era)
-> Decode
Open (Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era
TooManyCollateralInputs Decode Open (Mismatch RelLTEQ Natural -> AlonzoUtxoPredFailure era)
-> Decode (Closed (ZonkAny 20)) (Mismatch RelLTEQ Natural)
-> Decode Open (AlonzoUtxoPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 20)) (Mismatch RelLTEQ Natural)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
decFail Word
20 = AlonzoUtxoPredFailure era
-> Decode Open (AlonzoUtxoPredFailure era)
forall t. t -> Decode Open t
SumD AlonzoUtxoPredFailure era
forall era. AlonzoUtxoPredFailure era
NoCollateralInputs
decFail Word
n = Word -> Decode Open (AlonzoUtxoPredFailure era)
forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
n
instance
( Era era
, DecCBOR (TxOut era)
, DecCBOR (Value era)
, EncCBOR (Value era)
, DecCBOR (PredicateFailure (EraRule "UTXOS" era))
) =>
DecCBOR (AlonzoUtxoPredFailure era)
where
decCBOR :: forall s. Decoder s (AlonzoUtxoPredFailure era)
decCBOR = Decode (Closed Dense) (AlonzoUtxoPredFailure era)
-> Decoder s (AlonzoUtxoPredFailure era)
forall t (w :: Wrapped) s. Typeable t => Decode w t -> Decoder s t
decode (Text
-> (Word -> Decode Open (AlonzoUtxoPredFailure era))
-> Decode (Closed Dense) (AlonzoUtxoPredFailure era)
forall t.
Text -> (Word -> Decode Open t) -> Decode (Closed Dense) t
Summands Text
"UtxoPredicateFailure" Word -> Decode Open (AlonzoUtxoPredFailure era)
forall era.
(Era era, DecCBOR (TxOut era), DecCBOR (Value era),
DecCBOR (PredicateFailure (EraRule "UTXOS" era))) =>
Word -> Decode Open (AlonzoUtxoPredFailure era)
decFail)
allegraToAlonzoUtxoPredFailure ::
forall t era.
( EraRuleFailure "PPUP" era ~ t era
, InjectRuleFailure "UTXOS" t era
) =>
AllegraUtxoPredFailure era ->
AlonzoUtxoPredFailure era
allegraToAlonzoUtxoPredFailure :: forall (t :: * -> *) era.
(EraRuleFailure "PPUP" era ~ t era,
InjectRuleFailure "UTXOS" t era) =>
AllegraUtxoPredFailure era -> AlonzoUtxoPredFailure era
allegraToAlonzoUtxoPredFailure = \case
Allegra.BadInputsUTxO Set TxIn
x -> Set TxIn -> AlonzoUtxoPredFailure era
forall era. Set TxIn -> AlonzoUtxoPredFailure era
BadInputsUTxO Set TxIn
x
Allegra.OutsideValidityIntervalUTxO ValidityInterval
vi SlotNo
slotNo -> ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era
forall era. ValidityInterval -> SlotNo -> AlonzoUtxoPredFailure era
OutsideValidityIntervalUTxO ValidityInterval
vi SlotNo
slotNo
Allegra.MaxTxSizeUTxO Mismatch RelLTEQ Word32
m -> Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era
forall era. Mismatch RelLTEQ Word32 -> AlonzoUtxoPredFailure era
MaxTxSizeUTxO Mismatch RelLTEQ Word32
m
AllegraUtxoPredFailure era
Allegra.InputSetEmptyUTxO -> AlonzoUtxoPredFailure era
forall era. AlonzoUtxoPredFailure era
InputSetEmptyUTxO
Allegra.FeeTooSmallUTxO Mismatch RelGTEQ Coin
m -> Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
forall era. Mismatch RelGTEQ Coin -> AlonzoUtxoPredFailure era
FeeTooSmallUTxO Mismatch RelGTEQ Coin
m
Allegra.ValueNotConservedUTxO Mismatch RelEQ (Value era)
m -> Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era
forall era. Mismatch RelEQ (Value era) -> AlonzoUtxoPredFailure era
ValueNotConservedUTxO Mismatch RelEQ (Value era)
m
Allegra.WrongNetwork Network
x Set Addr
y -> Network -> Set Addr -> AlonzoUtxoPredFailure era
forall era. Network -> Set Addr -> AlonzoUtxoPredFailure era
WrongNetwork Network
x Set Addr
y
Allegra.WrongNetworkWithdrawal Network
x Set RewardAccount
y -> Network -> Set RewardAccount -> AlonzoUtxoPredFailure era
forall era.
Network -> Set RewardAccount -> AlonzoUtxoPredFailure era
WrongNetworkWithdrawal Network
x Set RewardAccount
y
Allegra.OutputTooSmallUTxO [TxOut era]
x -> [TxOut era] -> AlonzoUtxoPredFailure era
forall era. [TxOut era] -> AlonzoUtxoPredFailure era
OutputTooSmallUTxO [TxOut era]
x
Allegra.UpdateFailure EraRuleFailure "PPUP" era
x -> PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
forall era.
PredicateFailure (EraRule "UTXOS" era) -> AlonzoUtxoPredFailure era
UtxosFailure (forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure @"UTXOS" @t t era
EraRuleFailure "PPUP" era
x)
Allegra.OutputBootAddrAttrsTooBig [TxOut era]
xs -> [TxOut era] -> AlonzoUtxoPredFailure era
forall era. [TxOut era] -> AlonzoUtxoPredFailure era
OutputBootAddrAttrsTooBig [TxOut era]
xs
Allegra.OutputTooBigUTxO [TxOut era]
xs -> [(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era
forall era. [(Int, Int, TxOut era)] -> AlonzoUtxoPredFailure era
OutputTooBigUTxO ((TxOut era -> (Int, Int, TxOut era))
-> [TxOut era] -> [(Int, Int, TxOut era)]
forall a b. (a -> b) -> [a] -> [b]
map (Int
0,Int
0,) [TxOut era]
xs)