diff --git a/cabal.project b/cabal.project index 80ba318a436..f7c8c12a4bb 100644 --- a/cabal.project +++ b/cabal.project @@ -50,11 +50,11 @@ repository cardano-haskell-packages d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee -- repeating the index-state for hackage to work around hackage.nix parsing limitation -index-state: 2024-06-04T00:00:00Z +index-state: 2024-06-29T00:00:00Z index-state: - , hackage.haskell.org 2024-06-04T00:00:00Z - , cardano-haskell-packages 2024-05-29T10:15:00Z + , hackage.haskell.org 2024-06-29T00:00:00Z + , cardano-haskell-packages 2024-06-29T00:00:00Z packages: lib/address-derivation-discovery @@ -116,9 +116,9 @@ source-repository-package source-repository-package type: git - location: https://github.com/IntersectMBO/cardano-addresses - tag: 126964483d188c2362393d2a6eea8c65dfc43097 - --sha256: 1w152imj28ap5dfdc8x9ly0cy7dn500v7k63vw11f70gvgg6x7my + location: https://github.com/Anviking/cardano-addresses + tag: 2bca06deaa60e54a5322ac757387d744bf043367 + --sha256: 1y1mzfly7jac40b9g4xc078rcm5zqhc3xxv77kwxi10yph1jwq7z subdir: command-line core @@ -186,16 +186,14 @@ allow-newer: , cardano-addresses-cli:mtl , servant-openapi3:* , cardano-ledger-alonzo-test:base, plutus-ledger-api - , cardano-crypto-class:vector - , plutus-core:cardano-crypto-class - constraints: - base == 4.18.2.0 + base >= 4.18.2.0 && < 5 , bimap >= 0.4.0 , openapi3 >= 3.2.0 , libsystemd-journal >= 1.4.4 , systemd >= 2.3.0 + , singletons-th < 3.3 -- dependency of systemd-2.3.0 , network >= 3.1.1.1 -- choose versions that work with base >= 4.12 @@ -211,14 +209,16 @@ constraints: -- Cave: This version of `bech32` -- does not work with optparse-applicative >= 0.18.1.0 - , bech32 == 1.1.3 + , bech32 >= 1.1.7 -- Cardano Node dependencies: - , any.io-classes ==1.4.1.0 + , io-classes >= 1.4 , io-classes -asserts - , any.io-classes-mtl ==0.1.1.0 , optparse-applicative-fork >= 0.18.1 - , ouroboros-network ^>= 0.16 + + , ouroboros-consensus-cardano ^>= 0.17 + , ouroboros-network ^>= 0.16.1 + , ouroboros-network-protocols ^>= 0.9 -- TH Name shadowing warnings need to be addressed when bumping to 2.13.3.5 , persistent ^>= 2.14.6.0 @@ -324,4 +324,4 @@ tests: False -- ------------------------------------------------------------------------- package bitvec - flags: -simd \ No newline at end of file + flags: -simd diff --git a/flake.lock b/flake.lock index 390b0f75d68..8835bd1ca27 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1719922263, - "narHash": "sha256-Jm1BjEKWwu2K6L/pgt/n3++wdRfs58PpLsteXjVgEtA=", + "lastModified": 1719559353, + "narHash": "sha256-oVMUrDPUbVVsTWOsmtZkpHFr+oKPEezlSADm/s3A2/o=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "52a272bdbc16e0f5df58fcbaeb3681e50c9b340c", + "rev": "35bd2072a08607a3b2e4b56cf9c243c449908017", "type": "github" }, "original": { @@ -1038,11 +1038,11 @@ "stackage": "stackage_2" }, "locked": { - "lastModified": 1716943838, - "narHash": "sha256-r3Ho90C0ZePq9TRSF7VXLQuYfNnoXh/59aUa92AXyK0=", + "lastModified": 1719535822, + "narHash": "sha256-IteIKK4+GEZI2nHqCz0zRVgQ3aqs/WXKTOt2sbHJmGk=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "48b3a84d33b4bef9eea2b615ef5d710b0f72bc92", + "rev": "72bc84d0a4e8d0536505628040d96fd0a9e16c70", "type": "github" }, "original": { @@ -1535,11 +1535,11 @@ "iserv-proxy_2": { "flake": false, "locked": { - "lastModified": 1710581758, - "narHash": "sha256-UNUXGiKLGUv1TuQumV70rfjCJERP4w8KZEDxsMG0RHc=", + "lastModified": 1717479972, + "narHash": "sha256-7vE3RQycHI1YT9LHJ1/fUaeln2vIpYm6Mmn8FTpYeVo=", "owner": "stable-haskell", "repo": "iserv-proxy", - "rev": "50ea210590ab0519149bfd163d5ba199be925fb6", + "rev": "2ed34002247213fc435d0062350b91bab920626e", "type": "github" }, "original": { @@ -2707,11 +2707,11 @@ "stackage_2": { "flake": false, "locked": { - "lastModified": 1716942040, - "narHash": "sha256-YxHXqVGGHTy0PkVExdK9z6zHAJbGEd/9rwZdV+RaAU4=", + "lastModified": 1719102283, + "narHash": "sha256-pon+cXgMWPlCiBx9GlRcjsjTHbCc8fDVgOGb3Z7qhRM=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "686ed0e27db02a273ed04aa41788cc787052b706", + "rev": "7df45e0bd9852810d8070f9c5257f8e7a4677b91", "type": "github" }, "original": { diff --git a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/SharedKey.hs b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/SharedKey.hs index 5f29b912e20..1de74eb9be7 100644 --- a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/SharedKey.hs +++ b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/SharedKey.hs @@ -147,6 +147,7 @@ constructAddressFromIx role pTemplate dTemplate ix = Nothing -> createEnterpriseAddress pScript +-- | NOTE: The roles 'DRep', 'CCCold', 'CCHot' are not supported. replaceCosignersWithVerKeys :: CA.Role -> ScriptTemplate @@ -180,10 +181,22 @@ replaceCosignersWithVerKeys role' (ScriptTemplate xpubs scriptTemplate) ix = CA.UTxOExternal -> CA.Payment CA.UTxOInternal -> CA.Payment CA.Stake -> CA.Delegation + CA.DRep -> unsupportedRole + CA.CCCold -> unsupportedRole + CA.CCHot -> unsupportedRole deriveMultisigPublicKey accXPub = case role' of CA.UTxOExternal -> deriveAddressPublicKey accXPub role' CA.UTxOInternal -> deriveAddressPublicKey accXPub role' CA.Stake -> deriveDelegationPublicKey accXPub + CA.DRep -> unsupportedRole + CA.CCCold -> unsupportedRole + CA.CCHot -> unsupportedRole + + unsupportedRole :: forall a. HasCallStack => a + unsupportedRole = error $ mconcat + [ "replaceCosignersWithVerKeys: unsupported role " + , show role' + ] -- | Convert 'NetworkDiscriminant type parameter to -- 'Cardano.Address.NetworkTag'. diff --git a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/AssignReedemers.hs b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/AssignReedemers.hs index 913433d1e24..1fbdef9f3c9 100644 --- a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/AssignReedemers.hs +++ b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/AssignReedemers.hs @@ -4,22 +4,12 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-orphans #-} module Cardano.Wallet.Api.Http.Server.Error.AssignReedemers () where import Prelude -import Cardano.Ledger.Alonzo.Plutus.TxInfo - ( AlonzoContextError (..) - ) -import Cardano.Ledger.Babbage.TxInfo - ( BabbageContextError (..) - ) -import Cardano.Ledger.Conway.TxInfo - ( ConwayContextError (..) - ) import Cardano.Wallet.Api.Http.Server.Error.IsServerError ( IsServerError (..) , apiError @@ -32,14 +22,12 @@ import Fmt ) import Internal.Cardano.Write.Tx ( IsRecentEra (..) - , RecentEra (RecentEraBabbage, RecentEraConway) ) import Internal.Cardano.Write.Tx.Balance ( ErrAssignRedeemers (..) ) import Servant.Server - ( ServerError - , err400 + ( err400 ) import qualified Data.Text as T @@ -53,7 +41,7 @@ instance IsRecentEra era => IsServerError (ErrAssignRedeemers era) where , "redeemers:" , pretty r <> ";" , "Its execution is failing with the following error:" - , T.pack failure <> "." + , T.pack (show failure) <> "." ] ErrAssignRedeemersTargetNotFound r -> apiError err400 RedeemerTargetNotFound @@ -72,129 +60,3 @@ instance IsRecentEra era => IsServerError (ErrAssignRedeemers era) where , "into a valid Plutus data:" , pretty r <> "." ] - ErrAssignRedeemersTranslationError x -> case recentEra @era of - RecentEraBabbage -> fromBabbageContextError x - RecentEraConway -> fromConwayContextError x - -fromAlonzoContextError :: AlonzoContextError era -> ServerError -fromAlonzoContextError = \case - TranslationLogicMissingInput inp -> - apiError err400 UnresolvedInputs - $ T.unwords - [ "The transaction I was given contains inputs I don't know" - , "about. Please ensure all foreign inputs are specified as " - , "part of the API request. The unknown input is:\n\n" - , T.pack $ show inp - ] - TimeTranslationPastHorizon t -> - apiError err400 PastHorizon - $ T.unwords - [ "The transaction's validity interval is past the horizon" - , "of safe slot-to-time conversions." - , "This may happen when I know about a future era" - , "which has not yet been confirmed on-chain. Try setting the" - , "bounds of the validity interval to be earlier.\n\n" - , "Here are the full details: " <> t - ] - -fromBabbageContextError - :: forall era - . IsRecentEra era - => BabbageContextError era - -> ServerError -fromBabbageContextError = \case - AlonzoContextError e -> fromAlonzoContextError e - ByronTxOutInContext txOut -> - apiError err400 TranslationByronTxOutInContext - $ T.unwords - [ "The transaction I was given contains a Byron-style TxOut" - , "which is not supported when executing Plutus scripts. " - , "The offending TxOut is:\n\n" - , T.pack $ show txOut - ] - RedeemerPointerPointsToNothing ptr -> - apiError err400 RedeemerTargetNotFound - $ T.unwords - [ "I was unable to resolve one of your redeemers to the location" - , "indicated in the request payload:" - , T.pack $ show ptr - , "Please double-check both your serialised transaction and" - , "the provided redeemers." - ] - InlineDatumsNotSupported x -> - apiError err400 RedeemerInvalidData - $ T.unwords - [ "Inline datum is not supported in Plutus V1" - , "The offending data is:\n\n" - , T.pack $ show x - ] - ReferenceScriptsNotSupported x -> - apiError err400 RedeemerScriptFailure - $ T.unwords - [ "Reference scripts are not supported in Plutus V1" - , "The offending script is:\n\n" - , T.pack $ show x - ] - ReferenceInputsNotSupported x -> - apiError err400 UnresolvedInputs - $ T.unwords - [ "Reference inputs are not supported in Plutus V1" - , "The offending input is:\n\n" - , T.pack $ show x - ] - -fromConwayContextError - :: forall era - . IsRecentEra era - => ConwayContextError era - -> ServerError -fromConwayContextError = \case - BabbageContextError e -> fromBabbageContextError e - CertificateNotSupported x -> - apiError err400 UnsupportedMediaType - $ T.unwords - [ "The transaction I was given contains a certificate which" - , "is not supported in the current era." - , "The offending certificate is:\n\n" - , T.pack $ show x - ] - PlutusPurposeNotSupported x -> - apiError err400 UnsupportedMediaType - $ T.unwords - [ "The transaction I was given contains a Plutus script" - , "which is not supported in the current era." - , "The offending script is:\n\n" - , T.pack $ show x - ] - CurrentTreasuryFieldNotSupported x -> - apiError err400 UnsupportedMediaType - $ T.unwords - [ "The transaction I was given contains a current treasury" - , "which is not supported in the current era." - , "The offending treasury is:\n\n" - , T.pack $ show x - ] - VotingProceduresFieldNotSupported x -> - apiError err400 UnsupportedMediaType - $ T.unwords - [ "The transaction I was given contains a voting procedure" - , "which is not supported in the current era." - , "The offending procedure is:\n\n" - , T.pack $ show x - ] - ProposalProceduresFieldNotSupported x -> - apiError err400 UnsupportedMediaType - $ T.unwords - [ "The transaction I was given contains a proposal procedure" - , "which is not supported in the current era." - , "The offending procedure is:\n\n" - , T.pack $ show x - ] - TreasuryDonationFieldNotSupported x -> - apiError err400 UnsupportedMediaType - $ T.unwords - [ "The transaction I was given contains a treasury donation" - , "which is not supported in the current era." - , "The offending donation is:\n\n" - , T.pack $ show x - ] diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs index b3e70444683..22bacafce97 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs @@ -154,7 +154,9 @@ import Cardano.Crypto.Hash ( Hash (UnsafeHash) ) import Cardano.Ledger.Allegra.Scripts - ( translateTimelock + ( AllegraEraScript + , Timelock + , translateTimelock ) import Cardano.Ledger.Alonzo.Plutus.Context ( EraPlutusContext @@ -376,6 +378,8 @@ type RecentEraConstraints era = , Show (PParams era) , Show (Script era) , EraPlutusContext era + , AllegraEraScript era + , Core.NativeScript era ~ Timelock era ) -- | Returns a proof that the given era is a recent era. diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Redeemers.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Redeemers.hs index 0dcf27917bd..44434451863 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Redeemers.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Redeemers.hs @@ -24,11 +24,9 @@ module Internal.Cardano.Write.Tx.Redeemers import Prelude -import Cardano.Ledger.Alonzo.Plutus.Context - ( EraPlutusContext (..) - ) import Cardano.Ledger.Api ( AsItem (..) + , TransactionScriptFailure , Tx , bodyTxL , rdmrsTxWitsL @@ -64,9 +62,6 @@ import Control.Monad.Trans.State.Strict , modify' , put ) -import Data.Bifunctor - ( bimap - ) import Data.ByteString ( ByteString ) @@ -120,16 +115,17 @@ import qualified Data.Set as Set import qualified Data.Text as T data ErrAssignRedeemers era - = ErrAssignRedeemersScriptFailure Redeemer String + = ErrAssignRedeemersScriptFailure Redeemer (TransactionScriptFailure era) | ErrAssignRedeemersTargetNotFound Redeemer -- ^ The given redeemer target couldn't be located in the transaction. | ErrAssignRedeemersInvalidData Redeemer String -- ^ Redeemer's data isn't a valid Plutus' data. - | ErrAssignRedeemersTranslationError (ContextError era) deriving (Generic) -deriving instance Eq (ContextError era) => Eq (ErrAssignRedeemers era) -deriving instance Show (ContextError era) => Show (ErrAssignRedeemers era) +deriving instance Eq (TransactionScriptFailure era) + => Eq (ErrAssignRedeemers era) +deriving instance Show (TransactionScriptFailure era) + => Show (ErrAssignRedeemers era) assignScriptRedeemers :: forall era. IsRecentEra era @@ -142,8 +138,7 @@ assignScriptRedeemers assignScriptRedeemers pparams timeTranslation utxo redeemers tx = do flip execStateT tx $ do indexedRedeemers <- StateT assignNullRedeemers - executionUnits <- get - >>= lift . evaluateExecutionUnits indexedRedeemers + executionUnits <- evaluateExecutionUnits indexedRedeemers <$> get modifyM (assignExecutionUnits executionUnits) modify' addScriptIntegrityHash where @@ -192,22 +187,19 @@ assignScriptRedeemers pparams timeTranslation utxo redeemers tx = do evaluateExecutionUnits :: Map (Alonzo.PlutusPurpose Alonzo.AsIx era) Redeemer -> Tx era - -> Either (ErrAssignRedeemers era) - (Map (Alonzo.PlutusPurpose Alonzo.AsIx era) + -> (Map (Alonzo.PlutusPurpose Alonzo.AsIx era) (Either (ErrAssignRedeemers era) Alonzo.ExUnits)) evaluateExecutionUnits indexedRedeemers ledgerTx = Ledger.evalTxExUnits pparams ledgerTx utxo epochInformation systemStart - & bimap - ErrAssignRedeemersTranslationError (hoistScriptFailure indexedRedeemers) + & hoistScriptFailure indexedRedeemers hoistScriptFailure - :: Show scriptFailure - => Map (Alonzo.PlutusPurpose Alonzo.AsIx era) Redeemer - -> Map (Alonzo.PlutusPurpose Alonzo.AsIx era) (Either scriptFailure a) + :: Map (Alonzo.PlutusPurpose Alonzo.AsIx era) Redeemer + -> Map (Alonzo.PlutusPurpose Alonzo.AsIx era) (Either (TransactionScriptFailure era) a) -> Map (Alonzo.PlutusPurpose Alonzo.AsIx era) (Either (ErrAssignRedeemers era) a) hoistScriptFailure indexedRedeemers = Map.mapWithKey $ \ptr -> left $ \e -> - ErrAssignRedeemersScriptFailure (indexedRedeemers ! ptr) (show e) + ErrAssignRedeemersScriptFailure (indexedRedeemers ! ptr) e -- | Change execution units for each redeemers in the transaction to what -- they ought to be. diff --git a/lib/balance-tx/test/data/balanceTx/pingPong_2/golden b/lib/balance-tx/test/data/balanceTx/pingPong_2/golden index ed1b91397b7..4382104a3bc 100644 --- a/lib/balance-tx/test/data/balanceTx/pingPong_2/golden +++ b/lib/balance-tx/test/data/balanceTx/pingPong_2/golden @@ -39,26 +39,26 @@ 1.900000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 128877}) 1.950000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 78877}) 2.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 28877}) - 2.050000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2050000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3075000}) - 2.100000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2100000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3150000}) - 2.150000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2150000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3225000}) - 2.200000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2200000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3300000}) - 2.250000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2250000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3375000}) - 2.300000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2300000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3450000}) - 2.350000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2350000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3525000}) - 2.400000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2400000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3600000}) - 2.450000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2450000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3675000}) - 2.500000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2500000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3750000}) - 2.550000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2550000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3825000}) - 2.600000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2600000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3900000}) - 2.650000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2650000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3975000}) - 2.700000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2700000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4050000}) - 2.750000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2750000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4125000}) - 2.800000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2800000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4200000}) - 2.850000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2850000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4275000}) - 2.900000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2900000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4350000}) - 2.950000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2950000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4425000}) - 3.000000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx 0),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 3000000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4500000}) + 2.050000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2050000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3075000}) + 2.100000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2100000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3150000}) + 2.150000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2150000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3225000}) + 2.200000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2200000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3300000}) + 2.250000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2250000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3375000}) + 2.300000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2300000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3450000}) + 2.350000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2350000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3525000}) + 2.400000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2400000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3600000}) + 2.450000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2450000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3675000}) + 2.500000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2500000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3750000}) + 2.550000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2550000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3825000}) + 2.600000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2600000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3900000}) + 2.650000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2650000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 3975000}) + 2.700000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2700000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4050000}) + 2.750000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2750000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4125000}) + 2.800000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2800000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4200000}) + 2.850000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2850000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4275000}) + 2.900000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2900000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4350000}) + 2.950000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 2950000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4425000}) + 3.000000,ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError {largestCombinationAvailable = UTxO (fromList [(TxIn (TxId {unTxId = SafeHash "3030303030303030303030303030303030303030303030303030303030303030"}) (TxIx {unTxIx = 0}),(Addr Testnet (KeyHashObj (KeyHash "b1e5e0fb74c86c801f646841e07cdb42df8b82ef3ce4e57cb5412e77")) StakeRefNull,MaryValue (Coin 3000000) (MultiAsset (fromList [])),NoDatum,SNothing))]), minimumCollateralAmount = Coin 4500000}) 3.050000,0.607518,0.607518 3.100000,0.607518,0.607518 3.150000,0.607518,0.607518 diff --git a/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/Balance/TokenBundleSizeSpec.hs b/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/Balance/TokenBundleSizeSpec.hs index b9a121f1ae6..a14916ef693 100644 --- a/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/Balance/TokenBundleSizeSpec.hs +++ b/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/Balance/TokenBundleSizeSpec.hs @@ -28,7 +28,7 @@ import Data.Monoid.Monus ( Monus ((<\>)) ) import Data.Word - ( Word64 + ( Word32 ) import Internal.Cardano.Write.Tx ( IsRecentEra (..) @@ -299,7 +299,7 @@ instance Arbitrary PParamsInRecentEra where [ fromIntegral . max 0 . (4000 +) <$> arbitrary @Int -- Generate more extreme values (both small and large) - , fromIntegral <$> arbitrary @Word64 + , fromIntegral <$> arbitrary @Word32 ] babbageTokenBundleSizeAssessor :: TokenBundleSizeAssessor diff --git a/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/BalanceSpec.hs b/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/BalanceSpec.hs index fc7206eb6e9..954fa22f70d 100644 --- a/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/BalanceSpec.hs +++ b/lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/BalanceSpec.hs @@ -55,6 +55,7 @@ import Cardano.Ledger.Api , EraTxWits (bootAddrTxWitsL, scriptTxWitsL) , MaryEraTxBody (..) , ShelleyEraTxBody (..) + , TransactionScriptFailure (..) , ValidityInterval (..) , addrTxWitsL , allInputsTxBodyF @@ -712,10 +713,12 @@ spec_balanceTx = describe "balanceTx" $ do case balance (withValidityBeyondHorizon pingPong_2) of Left (ErrBalanceTxAssignRedeemers - (ErrAssignRedeemersTranslationError + (ErrAssignRedeemersScriptFailure + _redeemer + (ContextError (AlonzoContextError (TimeTranslationPastHorizon - _pastHoriozon)))) -> return () + _pastHoriozon))))) -> return () other -> expectationFailure $ "Expected pastHorizon failure; got " <> show other @@ -1301,10 +1304,8 @@ prop_balanceTxValid counterexample counterexampleText $ property False Left (ErrBalanceTxAssignRedeemers - (ErrAssignRedeemersTranslationError x)) -> - case recentEra @era of - RecentEraBabbage -> prop_babbageContextError x - RecentEraConway -> prop_conwayContextError x + (ErrAssignRedeemersScriptFailure _ e)) -> + prop_transactionScriptFailure e Left ErrBalanceTxUnableToCreateChange {} -> label "unable to create change" $ property True Left ErrBalanceTxInputResolutionConflicts{} -> @@ -1316,38 +1317,61 @@ prop_balanceTxValid balanceTxArgs Wallet _ walletUTxO _ = wallet - prop_babbageContextError :: BabbageContextError era -> Property - prop_babbageContextError = \case - AlonzoContextError (TranslationLogicMissingInput _) -> - succeedWithLabel "TranslationLogicMissingInput" - AlonzoContextError (TimeTranslationPastHorizon _) -> - succeedWithLabel "TimeTranslationPastHorizon" - ByronTxOutInContext _ -> - succeedWithLabel "ByronTxOutInContext" - RedeemerPointerPointsToNothing _ -> - succeedWithLabel "RedeemerPointerPointsToNothing" - InlineDatumsNotSupported _ -> - succeedWithLabel "InlineDatumsNotSupported" - ReferenceScriptsNotSupported _ -> - succeedWithLabel "ReferenceScriptsNotSupported" - ReferenceInputsNotSupported _ -> - succeedWithLabel "ReferenceInputsNotSupported" - - prop_conwayContextError :: ConwayContextError era -> Property - prop_conwayContextError = \case - BabbageContextError e -> prop_babbageContextError e - CertificateNotSupported _ -> - succeedWithLabel "CertificateNotSupported" - PlutusPurposeNotSupported _ -> - succeedWithLabel "PlutusPurposeNotSupported" - CurrentTreasuryFieldNotSupported _ -> - succeedWithLabel "CurrentTreasuryFieldNotSupported" - VotingProceduresFieldNotSupported _ -> - succeedWithLabel "VotingProceduresFieldNotSupported" - ProposalProceduresFieldNotSupported _ -> - succeedWithLabel "ProposalProceduresFieldNotSupported" - TreasuryDonationFieldNotSupported _ -> - succeedWithLabel "TreasuryDonationFieldNotSupported" + prop_transactionScriptFailure :: TransactionScriptFailure era -> Property + prop_transactionScriptFailure = \case + RedeemerPointsToUnknownScriptHash{} + -> succeedWithLabel "RedeemerPointsToUnknownScriptHash" + MissingScript{} + -> succeedWithLabel "MissingScript" + MissingDatum{} + -> succeedWithLabel "MissingDatum" + ValidationFailure{} + -> succeedWithLabel "ValidationFailure" + UnknownTxIn{} + -> succeedWithLabel "UnknownTxIn" + InvalidTxIn{} + -> succeedWithLabel "InvalidTxIn" + IncompatibleBudget{} + -> succeedWithLabel "IncompatibleBudget" + NoCostModelInLedgerState{} + -> succeedWithLabel "NoCostModelInLedgerState" + ContextError e + -> case recentEra @era of + RecentEraBabbage -> prop_babbageContextError e + RecentEraConway -> prop_conwayContextError e + where + prop_babbageContextError :: BabbageContextError era -> Property + prop_babbageContextError = \case + AlonzoContextError (TranslationLogicMissingInput _) -> + succeedWithLabel "TranslationLogicMissingInput" + AlonzoContextError (TimeTranslationPastHorizon _) -> + succeedWithLabel "TimeTranslationPastHorizon" + ByronTxOutInContext _ -> + succeedWithLabel "ByronTxOutInContext" + RedeemerPointerPointsToNothing _ -> + succeedWithLabel "RedeemerPointerPointsToNothing" + InlineDatumsNotSupported _ -> + succeedWithLabel "InlineDatumsNotSupported" + ReferenceScriptsNotSupported _ -> + succeedWithLabel "ReferenceScriptsNotSupported" + ReferenceInputsNotSupported _ -> + succeedWithLabel "ReferenceInputsNotSupported" + + prop_conwayContextError :: ConwayContextError era -> Property + prop_conwayContextError = \case + BabbageContextError e -> prop_babbageContextError e + CertificateNotSupported _ -> + succeedWithLabel "CertificateNotSupported" + PlutusPurposeNotSupported _ -> + succeedWithLabel "PlutusPurposeNotSupported" + CurrentTreasuryFieldNotSupported _ -> + succeedWithLabel "CurrentTreasuryFieldNotSupported" + VotingProceduresFieldNotSupported _ -> + succeedWithLabel "VotingProceduresFieldNotSupported" + ProposalProceduresFieldNotSupported _ -> + succeedWithLabel "ProposalProceduresFieldNotSupported" + TreasuryDonationFieldNotSupported _ -> + succeedWithLabel "TreasuryDonationFieldNotSupported" succeedWithLabel l = label l $ property True diff --git a/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs b/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs index dc67fef6fbd..d310bc4f4b3 100644 --- a/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs +++ b/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs @@ -137,7 +137,7 @@ import Cardano.Api , CostModel (..) , Eon (..) , EpochNo (EpochNo) - , ExecutionUnitPrices (ExecutionUnitPrices) + , ExecutionUnitPrices (..) , ExecutionUnits (ExecutionUnits) , Featured (..) , HasTypeProxy (AsType) @@ -171,7 +171,7 @@ import Cardano.Api , ScriptWitnessInCtx (ScriptWitnessForSpending, ScriptWitnessForStakeAddr) , SerialiseAsCBOR (deserialiseFromCBOR, serialiseToCBOR) , ShelleyAddr - , ShelleyBasedEra + , ShelleyBasedEra (..) , ShelleyToBabbageEra (..) , ShelleyWitnessSigningKey (..) , SimpleScript (..) @@ -253,11 +253,10 @@ import Cardano.Api.Byron ) import Cardano.Api.Shelley ( Hash (..) - , LedgerProtocolParameters + , LedgerProtocolParameters (..) , PlutusScript (..) , PlutusScriptOrReferenceInput (..) , PoolId - , ProtocolParameters (..) , ReferenceScript (..) , SimpleScriptOrReferenceInput (..) , StakeCredential (..) @@ -265,11 +264,11 @@ import Cardano.Api.Shelley , StakePoolMetadataReference (..) , StakePoolParameters (..) , StakePoolRelay (..) - , convertToLedgerProtocolParameters , toShelleyPoolParams ) import Cardano.Ledger.Api ( StandardCrypto + , emptyPParams ) import Cardano.Ledger.Credential.Safe ( Ptr @@ -384,11 +383,6 @@ import Test.QuickCheck , vector , vectorOf ) -import Test.QuickCheck.Extra - ( GenSeed (..) - , genSizeDefault - , generateWith - ) import Test.QuickCheck.Hedgehog ( hedgehog ) @@ -1295,13 +1289,13 @@ genExecutionUnitPrices = ExecutionUnitPrices <$> genRational <*> genRational protocolParametersForHashing :: ShelleyBasedEra era -> LedgerProtocolParameters era -protocolParametersForHashing era = - either (error . show) id - $ convertToLedgerProtocolParameters era - $ generateWith - (GenSeed 0) - genSizeDefault - genRecentEraProtocolParameters +protocolParametersForHashing = \case + ShelleyBasedEraShelley -> LedgerProtocolParameters emptyPParams + ShelleyBasedEraAllegra -> LedgerProtocolParameters emptyPParams + ShelleyBasedEraMary -> LedgerProtocolParameters emptyPParams + ShelleyBasedEraAlonzo -> LedgerProtocolParameters emptyPParams + ShelleyBasedEraBabbage -> LedgerProtocolParameters emptyPParams + ShelleyBasedEraConway -> LedgerProtocolParameters emptyPParams genValidProtocolVersion :: Gen (Natural, Natural) genValidProtocolVersion = do @@ -1309,39 +1303,6 @@ genValidProtocolVersion = do minor <- genNat pure (major, minor) --- | Generates a set of protocol parameters for a recent era. --- --- Uses 'Just' as necessary to be convertible to @Ledger.PParams era@ --- for 'IsRecentEra' eras, and keep our tests from throwing exceptions. -genRecentEraProtocolParameters :: Gen ProtocolParameters -genRecentEraProtocolParameters = - ProtocolParameters - <$> genValidProtocolVersion - <*> (Just <$> genRational) - <*> liftArbitrary genPraosNonce - <*> genNat - <*> genNat - <*> genNat - <*> genCoin - <*> genCoin - <*> liftArbitrary genCoin - <*> genCoin - <*> genCoin - <*> genCoin - <*> genInterval - <*> genNat - <*> genRationalInt64 - <*> genRational - <*> genRational - <*> genCostModels - <*> (Just <$> genExecutionUnitPrices) - <*> (Just <$> genExecutionUnits) - <*> (Just <$> genExecutionUnits) - <*> (Just <$> genNat) - <*> (Just <$> genNat) - <*> (Just <$> genNat) - <*> (Just <$> genCoin) - genInterval :: Gen Ledger.EpochInterval genInterval = Ledger.EpochInterval <$> arbitrary @@ -1819,6 +1780,8 @@ genTxBodyContent era = withEraWitness era $ \sbe -> do txValidityUpperBound <- genTxValidityUpperBound era txProposalProcedures <- genMaybeFeaturedInEra genProposals era txVotingProcedures <- genMaybeFeaturedInEra genVotingProcedures era + txCurrentTreasuryValue <- genMaybeFeaturedInEra (const genCoin) era + txTreasuryDonation <- genMaybeFeaturedInEra (const genCoin) era let txBody = @@ -1849,6 +1812,8 @@ genTxBodyContent era = withEraWitness era $ \sbe -> do , Api.txValidityUpperBound , Api.txProposalProcedures , Api.txVotingProcedures + , Api.txCurrentTreasuryValue + , Api.txTreasuryDonation } let witnesses = collectTxBodyScriptWitnesses sbe txBody diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs index 0d300586b1a..c36e571e810 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs @@ -6,6 +6,7 @@ {-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} -- | -- Copyright: © 2020 IOHK @@ -154,6 +155,7 @@ import qualified Cardano.Ledger.Mary.Value as Ledger import qualified Cardano.Ledger.Plutus.Language as Ledger import qualified Cardano.Ledger.SafeHash as SafeHash import qualified Cardano.Ledger.Shelley.API as Ledger +import qualified Cardano.Ledger.Shelley.Scripts as Scripts import qualified Cardano.Wallet.Primitive.Types.Coin as Coin import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle import qualified Cardano.Wallet.Primitive.Types.TokenMap as TokenMap @@ -384,44 +386,55 @@ fromBabbageTxOut (Babbage.BabbageTxOut addr val _ _) = TxOut (toWallet addr) (toWallet val) toWalletScript - :: LCore.Era crypto + :: forall era. + ( Scripts.AllegraEraScript era + , Ledger.NativeScript era ~ Scripts.Timelock era + ) => (Hash "VerificationKey" -> KeyRole) - -> Scripts.Timelock crypto + -> Scripts.Timelock era -> Script KeyHash -toWalletScript tokeyrole = fromLedgerScript - where - fromLedgerScript (Scripts.RequireSignature (Ledger.KeyHash h)) = +toWalletScript tokeyrole = \case + Scripts.RequireSignature (Ledger.KeyHash h) -> let payload = hashToBytes h in RequireSignatureOf (KeyHash (tokeyrole (Hash payload)) payload) - fromLedgerScript (Scripts.RequireAllOf contents) = - RequireAllOf $ map fromLedgerScript $ toList contents - fromLedgerScript (Scripts.RequireAnyOf contents) = - RequireAnyOf $ map fromLedgerScript $ toList contents - fromLedgerScript (Scripts.RequireMOf num contents) = - RequireSomeOf (fromIntegral num) $ fromLedgerScript <$> toList contents - fromLedgerScript (Scripts.RequireTimeExpire (SlotNo slot)) = + Scripts.RequireAllOf contents -> + RequireAllOf $ map (toWalletScript tokeyrole) $ toList contents + Scripts.RequireAnyOf contents -> + RequireAnyOf $ map (toWalletScript tokeyrole) $ toList contents + Scripts.RequireMOf num contents -> + RequireSomeOf (fromIntegral num) $ (toWalletScript tokeyrole) <$> toList contents + Scripts.RequireTimeExpire (SlotNo slot) -> ActiveUntilSlot $ fromIntegral slot - fromLedgerScript (Scripts.RequireTimeStart (SlotNo slot)) = + Scripts.RequireTimeStart (SlotNo slot) -> ActiveFromSlot $ fromIntegral slot toWalletScriptFromShelley - :: LCore.Era crypto + :: forall era. + ( Scripts.ShelleyEraScript era + , Ledger.NativeScript era ~ Scripts.MultiSig era + ) => KeyRole - -> Ledger.MultiSig crypto + -> Ledger.MultiSig era -> Script KeyHash toWalletScriptFromShelley keyrole = fromLedgerScript' where - fromLedgerScript' (Ledger.RequireSignature (Ledger.KeyHash h)) = + fromLedgerScript' :: Ledger.MultiSig era -> Script KeyHash + + fromLedgerScript' (Scripts.RequireSignature (Ledger.KeyHash h)) = RequireSignatureOf (KeyHash keyrole (hashToBytes h)) - fromLedgerScript' (Ledger.RequireAllOf contents) = + fromLedgerScript' (Scripts.RequireAllOf contents) = RequireAllOf $ map fromLedgerScript' $ toList contents - fromLedgerScript' (Ledger.RequireAnyOf contents) = + fromLedgerScript' (Scripts.RequireAnyOf contents) = RequireAnyOf $ map fromLedgerScript' $ toList contents - fromLedgerScript' (Ledger.RequireMOf num contents) = + fromLedgerScript' (Scripts.RequireMOf num contents) = RequireSomeOf (fromIntegral num) $ fromLedgerScript' <$> toList contents + fromLedgerScript' _ = error "impossible" toLedgerTimelockScript - :: LCore.Era era + :: forall era. + ( Scripts.AllegraEraScript era + , LCore.NativeScript era ~ Scripts.Timelock era + ) => Script KeyHash -> Scripts.Timelock era toLedgerTimelockScript s = case s of diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs index c7a9cc945b8..16090d58148 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs @@ -343,6 +343,7 @@ import qualified Ouroboros.Consensus.Protocol.Praos as Consensus import qualified Ouroboros.Consensus.Protocol.Praos.Header as Consensus import qualified Ouroboros.Consensus.Protocol.TPraos as Consensus import qualified Ouroboros.Consensus.Shelley.Ledger as O +import qualified Ouroboros.Consensus.Shelley.Ledger.Query.Types as Consensus import qualified Ouroboros.Network.Block as O -------------------------------------------------------------------------------- @@ -730,12 +731,12 @@ fromPoolId (SL.KeyHash x) = PoolId $ hashToBytes x fromPoolDistr :: forall crypto. () - => SL.PoolDistr crypto + => Consensus.PoolDistr crypto -> Map PoolId Percentage fromPoolDistr = - Map.map (unsafeMkPercentage . SL.individualPoolStake) + Map.map (unsafeMkPercentage . Consensus.individualPoolStake) . Map.mapKeys fromPoolId - . SL.unPoolDistr + . Consensus.unPoolDistr -- NOTE: This function disregards results that are using staking keys fromNonMyopicMemberRewards diff --git a/lib/unit/test/data/Cardano/CLISpec/key --help b/lib/unit/test/data/Cardano/CLISpec/key --help index 4418e3b2251..055c9742d10 100644 --- a/lib/unit/test/data/Cardano/CLISpec/key --help +++ b/lib/unit/test/data/Cardano/CLISpec/key --help @@ -18,22 +18,22 @@ Available commands: a given key Example: - $ cardano-wallet recovery-phrase generate --size 15 \ - | cardano-wallet key from-recovery-phrase Shelley > root.prv + $ cardano-wallet recovery-phrase generate --size 15 \ + | cardano-wallet key from-recovery-phrase Shelley > root.prv - $ cat root.prv \ - | cardano-wallet key child 1852H/1815H/0H \ - | tee acct.prv \ - | cardano-wallet key public --with-chain-code > acct.pub + $ cat root.prv \ + | cardano-wallet key child 1852H/1815H/0H \ + | tee acct.prv \ + | cardano-wallet key public --with-chain-code > acct.pub - $ cardano-wallet key inspect <<< $(cat acct.prv) + $ cardano-wallet key inspect <<< $(cat acct.prv) { "key_type": "private", "chain_code": "67bef6f80df02c7452e20e76ffb4bb57cae8aac2adf042b21a6b19e4f7b1f511", "extended_key": "90ead3efad7aacac242705ede323665387f49ed847bed025eb333708ccf6aa54403482a867daeb18f38c57d6cddd7e6fd6aed4a3209f7425a3d1c5d9987a9c5f" } - $ cardano-wallet key inspect <<< $(cat acct.pub) + $ cardano-wallet key inspect <<< $(cat acct.pub) { "key_type": "public", "chain_code": "67bef6f80df02c7452e20e76ffb4bb57cae8aac2adf042b21a6b19e4f7b1f511", diff --git a/lib/unit/test/data/Cardano/CLISpec/key from-recovery-phrase --help b/lib/unit/test/data/Cardano/CLISpec/key from-recovery-phrase --help index 2b7dbd531be..a043469b332 100644 --- a/lib/unit/test/data/Cardano/CLISpec/key from-recovery-phrase --help +++ b/lib/unit/test/data/Cardano/CLISpec/key from-recovery-phrase --help @@ -25,27 +25,27 @@ Available options: The recovery phrase without passphrase is read from stdin. Example: - $ cardano-wallet recovery-phrase generate \ - | cardano-wallet key from-recovery-phrase Icarus + $ cardano-wallet recovery-phrase generate \ + | cardano-wallet key from-recovery-phrase Icarus The recovery phrase with passphrase can be entered interactively or from file. In both cases passhrase can take form of mnemonic, base16, base64, utf8 or octet array. In interactive case one can select explicit, sensitive or silent mode. Example: - $ cardano-wallet key from-recovery-phrase Shelley --passphrase from-mnemonic --sensitive - Please enter a [9, 12, 15, 18, 21, 24] word mnemonic: - ********************************************************************************************************** - Please enter a 9–12 word second factor: - ************************************************************* + $ cardano-wallet key from-recovery-phrase Shelley --passphrase from-mnemonic --sensitive + Please enter a [9, 12, 15, 18, 21, 24] word mnemonic: + ********************************************************************************************************** + Please enter a 9–12 word second factor: + ************************************************************* In case of passphrase reading from file the recovery phrase is read from stdin. Example: - $ echo "Secret Secondary Phrase" > sndfactor.prv - $ cardano-wallet recovery-phrase generate \ - | cardano-wallet key from-recovery-phrase Shelley --from-file "./sndfactor.prv" + $ echo "Secret Secondary Phrase" > sndfactor.prv + $ cardano-wallet recovery-phrase generate \ + | cardano-wallet key from-recovery-phrase Shelley --from-file "./sndfactor.prv" - $ cardano-wallet recovery-phrase generate --size 12 > sndfactor.prv - $ cardano-wallet recovery-phrase generate \ - | cardano-wallet key from-recovery-phrase Shelley --passphrase from-mnemonic --from-file "./sndfactor.prv" + $ cardano-wallet recovery-phrase generate --size 12 > sndfactor.prv + $ cardano-wallet recovery-phrase generate \ + | cardano-wallet key from-recovery-phrase Shelley --passphrase from-mnemonic --from-file "./sndfactor.prv" diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs index 855aa58b861..07d8d05ad0f 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs @@ -960,6 +960,8 @@ mkUnsignedTx Nothing , Cardano.txVotingProcedures = Nothing + , txCurrentTreasuryValue = Nothing + , txTreasuryDonation = Nothing } where era = Write.recentEra @era