From 9666df0c0ae7350547e2fec4d9d48185f094f55b Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Tue, 19 Mar 2024 15:46:04 +0100 Subject: [PATCH 01/24] Update flake input CHaP --- cabal.project | 4 ++-- flake.lock | 10 +++++----- flake.nix | 2 +- nix/haskell.nix | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cabal.project b/cabal.project index 4398b7e568d..4ffffdb2ab1 100644 --- a/cabal.project +++ b/cabal.project @@ -36,10 +36,10 @@ -------------------------------------------------------------------------------- -- Custom repository for cardano haskell packages, see --- https://github.com/input-output-hk/cardano-haskell-packages +-- https://github.com/intersectmbo/cardano-haskell-packages -- for more information. repository cardano-haskell-packages - url: https://input-output-hk.github.io/cardano-haskell-packages + url: https://chap.intersectmbo.org/ secure: True root-keys: 3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f diff --git a/flake.lock b/flake.lock index 2e8dfc4b4fb..2b3ef824ce6 100644 --- a/flake.lock +++ b/flake.lock @@ -3,15 +3,15 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1704361777, - "narHash": "sha256-4LPIpUKstLc38SuXx21dKfW2CpgpS7JgiPw4vn5ICkk=", - "owner": "input-output-hk", + "lastModified": 1710781777, + "narHash": "sha256-yiwhwdGNgFm6mzx5XNhTt67Xykl+aczahwM+FmMiMkY=", + "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "d1bf57e5f1a64a49fde395bf40570e129723f043", + "rev": "e1a84b0e3c8745bf30648966cdc8440b7155b9c8", "type": "github" }, "original": { - "owner": "input-output-hk", + "owner": "intersectmbo", "ref": "repo", "repo": "cardano-haskell-packages", "type": "github" diff --git a/flake.nix b/flake.nix index eb231743638..5c0733ca0d8 100644 --- a/flake.nix +++ b/flake.nix @@ -120,7 +120,7 @@ nixpkgs.follows = "haskellNix/nixpkgs-unstable"; hostNixpkgs.follows = "nixpkgs"; CHaP = { - url = "github:input-output-hk/cardano-haskell-packages?ref=repo"; + url = "github:intersectmbo/cardano-haskell-packages?ref=repo"; flake = false; }; haskellNix = { diff --git a/nix/haskell.nix b/nix/haskell.nix index 169407198ca..0cb36644e39 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix @@ -159,7 +159,7 @@ hls: CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [ shellHook = "export LOCAL_CLUSTER_CONFIGS=${localClusterConfigs}"; }; - inputMap = { "https://input-output-hk.github.io/cardano-haskell-packages" = CHaP; }; + inputMap = { "https://chap.intersectmbo.org/" = CHaP; }; modules = let inherit (config) src coverage profiling; From 562ae047cfae38a2312857f314aa81d1089409f4 Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Tue, 19 Mar 2024 18:13:26 +0100 Subject: [PATCH 02/24] Update flake input hackage --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 2b3ef824ce6..201a5cda926 100644 --- a/flake.lock +++ b/flake.lock @@ -913,11 +913,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1705278263, - "narHash": "sha256-7y7BujULv8Wma0eOTVnki6wCRtZhpn3Iw+IXOI0yO+0=", + "lastModified": 1710807758, + "narHash": "sha256-lQY4KSZQlMyKizC+Xbsl29hxNPHV52pRTDZac+vPaeU=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "5eba43fa91e04a2f5c9e81d545358624ffa2fe43", + "rev": "dc3cafd9dbaeebe37c96613a9d145e162cadcf79", "type": "github" }, "original": { From 92af1c1f49230d28216f4adef8942ad92f68429d Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Tue, 19 Mar 2024 17:17:25 +0100 Subject: [PATCH 03/24] Update index-state in cabal.project --- cabal.project | 6 +++--- nix/haskell.nix | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cabal.project b/cabal.project index 4ffffdb2ab1..1f7755469f9 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-01-12T11:04:55Z +index-state: 2024-03-19T15:29:53Z index-state: - , hackage.haskell.org 2024-01-12T11:04:55Z - , cardano-haskell-packages 2023-12-18T12:30:16Z + , hackage.haskell.org 2024-03-19T15:29:53Z + , cardano-haskell-packages 2024-03-15T17:07:52Z packages: lib/address-derivation-discovery diff --git a/nix/haskell.nix b/nix/haskell.nix index 0cb36644e39..2d60a77e6ae 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix @@ -96,7 +96,7 @@ hls: CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [ filter = lib.cleanSourceFilter; }; - indexState = "2024-01-12T11:04:55Z"; + indexState = "2024-03-15T17:07:52Z"; localClusterConfigs = config.src + /lib/local-cluster/test/data/cluster-configs; From 98dfb5ad375be23a15420085d8442e05aecfcaff Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Tue, 19 Mar 2024 18:10:01 +0100 Subject: [PATCH 04/24] Update nix/project-package-list.nix --- nix/project-package-list.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/project-package-list.nix b/nix/project-package-list.nix index ad0a1b9f719..a960ee0c8ce 100644 --- a/nix/project-package-list.nix +++ b/nix/project-package-list.nix @@ -1 +1 @@ -[ "address-derivation-discovery" "cardano-api-extra" "cardano-balance-tx" "cardano-coin-selection" "cardano-numeric" "cardano-wallet" "cardano-wallet-api" "cardano-wallet-benchmarks" "cardano-wallet-blackbox-benchmarks" "cardano-wallet-integration" "cardano-wallet-launcher" "cardano-wallet-network-layer" "cardano-wallet-primitive" "cardano-wallet-read" "cardano-wallet-secrets" "cardano-wallet-test-utils" "cardano-wallet-unit" "customer-deposit-wallet" "delta-store" "delta-table" "delta-types" "faucet" "local-cluster" "text-class" "wai-middleware-logging" ] +[ "address-derivation-discovery" "cardano-api-extra" "cardano-balance-tx" "cardano-coin-selection" "cardano-numeric" "cardano-wallet" "cardano-wallet-benchmarks" "cardano-wallet-blackbox-benchmarks" "cardano-wallet-integration" "cardano-wallet-launcher" "cardano-wallet-network-layer" "cardano-wallet-primitive" "cardano-wallet-read" "cardano-wallet-secrets" "cardano-wallet-test-utils" "cardano-wallet-unit" "customer-deposit-wallet" "delta-store" "delta-table" "delta-types" "faucet" "local-cluster" "text-class" "wai-middleware-logging" ] From 88e04a4f8cdf7be8bfb381a790d17b4d662bc186 Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Wed, 20 Mar 2024 13:12:10 +0100 Subject: [PATCH 05/24] Bump `cabal.project` to cardano-node-8.9.0 --- cabal.project | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cabal.project b/cabal.project index 1f7755469f9..c324e3d5479 100644 --- a/cabal.project +++ b/cabal.project @@ -201,15 +201,16 @@ constraints: , bech32 == 1.1.3 -- Cardano Node dependencies: - , cardano-api ^>= 8.36.1.1 - , cardano-crypto-class ==2.1.4.0 + , cardano-node == 8.9.0 + , cardano-api ^>=8.39.2.0 + , cardano-crypto-class >=2.1.4.0 , cardano-crypto-class +secp256k1-support , cardano-slotting ^>= 0.1.2 - , optparse-applicative-fork == 0.18.1.0 - , ouroboros-network ^>= 0.10.2.1 - , plutus-core == 1.15.0.1 + , optparse-applicative-fork >= 0.18.1 + , ouroboros-network ^>= 0.12 + , plutus-core ==1.21.0.0 , plutus-core -with-cert -with-inline-r - , plutus-ledger-api ==1.15.0.1 + , plutus-ledger-api ==1.21.0.0 -- TH Name shadowing warnings need to be addressed when bumping to 2.13.3.5 , persistent ^>= 2.14.6.0 From 678a7c4dfed8d83acbe0619f7373d9b5f72beaec Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 21 Mar 2024 13:41:33 +0000 Subject: [PATCH 06/24] Fixes for `read` package --- .../Cardano/Wallet/Read/Tx/CollateralInputs.hs | 2 +- .../lib/Cardano/Wallet/Read/Tx/Gen/Alonzo.hs | 6 +++--- .../lib/Cardano/Wallet/Read/Tx/Gen/Babbage.hs | 6 ++++-- .../lib/Cardano/Wallet/Read/Tx/Gen/Conway.hs | 10 ++++++---- .../lib/Cardano/Wallet/Read/Tx/Gen/Mary.hs | 10 ++++++---- .../lib/Cardano/Wallet/Read/Tx/Gen/Shelley.hs | 18 ++++++------------ lib/read/lib/Cardano/Wallet/Read/Tx/Hash.hs | 6 ++---- .../lib/Cardano/Wallet/Read/Tx/Withdrawals.hs | 1 - 8 files changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/CollateralInputs.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/CollateralInputs.hs index 7579671351c..bce3b0c903b 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/CollateralInputs.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/CollateralInputs.hs @@ -23,7 +23,7 @@ module Cardano.Wallet.Read.Tx.CollateralInputs import Prelude -import Cardano.Ledger.Babbage.TxBody +import Cardano.Ledger.Api ( collateralInputsTxBodyL ) import Cardano.Ledger.Core diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Alonzo.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Alonzo.hs index a4969e817b3..e3e0e2dc275 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Alonzo.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Alonzo.hs @@ -29,6 +29,9 @@ import Cardano.Ledger.Api.Era ( AlonzoEra , StandardCrypto ) +import Cardano.Ledger.Api.Tx.In + ( TxIn + ) import Cardano.Ledger.BaseTypes ( Network ) @@ -39,9 +42,6 @@ import Cardano.Ledger.Keys import Cardano.Ledger.Mary.Value ( MultiAsset ) -import Cardano.Ledger.Shelley.Tx - ( TxIn - ) import Cardano.Wallet.Read.Tx.Gen.Address ( decodeShelleyAddress ) diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Babbage.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Babbage.hs index 19c0964094b..eb9d81ed207 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Babbage.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Babbage.hs @@ -18,6 +18,9 @@ import Cardano.Ledger.Alonzo import Cardano.Ledger.Alonzo.TxAuxData ( AuxiliaryDataHash ) +import Cardano.Ledger.Api + ( Datum (NoDatum) + ) import Cardano.Ledger.Api.Era ( BabbageEra , StandardCrypto @@ -29,7 +32,6 @@ import Cardano.Ledger.Babbage.Tx import Cardano.Ledger.Babbage.TxBody ( BabbageTxBody (..) , BabbageTxOut (..) - , Datum (NoDatum) , ScriptIntegrityHash ) import Cardano.Ledger.Babbage.TxWits @@ -54,7 +56,7 @@ import Cardano.Ledger.Keys import Cardano.Ledger.Mary.Value ( MultiAsset ) -import Cardano.Ledger.Shelley.Tx +import Cardano.Ledger.Shelley.API.Types ( TxIn ) import Cardano.Wallet.Read.Tx.Gen.Address diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Conway.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Conway.hs index bb9ac74fe7b..fa00336c384 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Conway.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Conway.hs @@ -20,16 +20,21 @@ import Cardano.Ledger.Alonzo.Tx import Cardano.Ledger.Alonzo.TxAuxData ( AuxiliaryDataHash ) +import Cardano.Ledger.Api + ( Datum (NoDatum) + ) import Cardano.Ledger.Api.Era ( ConwayEra , StandardCrypto ) +import Cardano.Ledger.Api.Tx.In + ( TxIn + ) import Cardano.Ledger.Babbage ( BabbageTxOut ) import Cardano.Ledger.Babbage.TxBody ( BabbageTxOut (..) - , Datum (..) ) import Cardano.Ledger.BaseTypes ( Network @@ -63,9 +68,6 @@ import Cardano.Ledger.Keys import Cardano.Ledger.Mary.Value ( MultiAsset ) -import Cardano.Ledger.Shelley.Tx - ( TxIn - ) import Cardano.Wallet.Read.Tx.Gen.Address ( decodeShelleyAddress ) diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Mary.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Mary.hs index 42e3a934283..ac10d0bfa3b 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Mary.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Mary.hs @@ -9,6 +9,9 @@ where import Prelude +import Cardano.Ledger.Allegra.Core + ( ValidityInterval (..) + ) import Cardano.Ledger.Allegra.TxAuxData ( AllegraTxAuxData ) @@ -21,16 +24,15 @@ import Cardano.Ledger.Coin ) import Cardano.Ledger.Mary.TxBody ( MaryTxBody (..) - , StrictMaybe (..) - , ValidityInterval (..) ) import Cardano.Ledger.Mary.Value ( MaryValue (..) , MultiAsset ) -import Cardano.Ledger.Shelley.Tx +import Cardano.Ledger.Shelley.API.Types ( ShelleyTx (ShelleyTx) - , ShelleyTxOut (..) + , ShelleyTxOut (ShelleyTxOut) + , StrictMaybe (..) ) import Cardano.Wallet.Read.Tx.Gen.Address ( decodeShelleyAddress diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Shelley.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Shelley.hs index 8bc9ac3e35f..1799b4bc9e8 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Shelley.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/Gen/Shelley.hs @@ -53,27 +53,21 @@ import Cardano.Ledger.Keys import Cardano.Ledger.SafeHash ( unsafeMakeSafeHash ) -import Cardano.Ledger.Shelley.PParams - ( Update - ) -import Cardano.Ledger.Shelley.Tx +import Cardano.Ledger.Shelley.API.Types ( ShelleyTx (ShelleyTx) + , ShelleyTxAuxData , ShelleyTxBody (ShelleyTxBody) , ShelleyTxOut (ShelleyTxOut) + , ShelleyTxWits , TxIn (..) + , Withdrawals (Withdrawals) ) -import Cardano.Ledger.Shelley.TxAuxData - ( ShelleyTxAuxData - ) -import Cardano.Ledger.Shelley.TxBody - ( Withdrawals (Withdrawals) +import Cardano.Ledger.Shelley.PParams + ( Update ) import Cardano.Ledger.Shelley.TxCert ( ShelleyTxCert ) -import Cardano.Ledger.Shelley.TxWits - ( ShelleyTxWits - ) import Cardano.Ledger.Slot ( SlotNo (..) ) diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/Hash.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/Hash.hs index a92d8edc49e..dc94a57ad36 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/Hash.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/Hash.hs @@ -29,11 +29,9 @@ import Cardano.Chain.UTxO import Cardano.Crypto ( serializeCborHash ) -import Cardano.Ledger.Block - ( txid - ) import Cardano.Ledger.Core ( bodyTxL + , txIdTxBody ) import Cardano.Ledger.TxIn ( TxId (..) @@ -72,7 +70,7 @@ getEraTxHash = case theEra @era of mkShelleyHash = onTx $ \tx -> shelleyTxHash tx shelleyTxHash :: SL.Core.EraTx era => SL.Core.Tx era -> Crypto.ByteString -shelleyTxHash tx = fromShelleyTxId $ txid (tx ^. bodyTxL) +shelleyTxHash tx = fromShelleyTxId $ txIdTxBody (tx ^. bodyTxL) byronTxHash :: ATxAux a -> Crypto.ByteString byronTxHash = CryptoC.hashToBytes . serializeCborHash . taTx diff --git a/lib/read/lib/Cardano/Wallet/Read/Tx/Withdrawals.hs b/lib/read/lib/Cardano/Wallet/Read/Tx/Withdrawals.hs index b2ecea3cc90..290e33944c3 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Tx/Withdrawals.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Tx/Withdrawals.hs @@ -63,7 +63,6 @@ import Data.Map ) import qualified Cardano.Ledger.Api as Ledger -import qualified Cardano.Ledger.Core as Ledger type family WithdrawalsType era where WithdrawalsType Byron = () From a589230717b68741a2b14dfb6138d044e738503d Mon Sep 17 00:00:00 2001 From: paolino Date: Wed, 20 Mar 2024 16:59:54 +0000 Subject: [PATCH 07/24] Fixes for `cardano-api-extra` --- .../spec/Internal/Cardano/Write/TxSpec.hs | 9 ++-- lib/cardano-api-extra/lib/Cardano/Api/Gen.hs | 47 ++++++++++++------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/lib/balance-tx/test/spec/Internal/Cardano/Write/TxSpec.hs b/lib/balance-tx/test/spec/Internal/Cardano/Write/TxSpec.hs index fd5e6a64c08..059a1e6f687 100644 --- a/lib/balance-tx/test/spec/Internal/Cardano/Write/TxSpec.hs +++ b/lib/balance-tx/test/spec/Internal/Cardano/Write/TxSpec.hs @@ -10,6 +10,10 @@ module Internal.Cardano.Write.TxSpec where import Prelude +import Cardano.Api.Gen + ( genTxIn + , genTxOut + ) import Cardano.Ledger.Api ( PParams , coinTxOutL @@ -67,7 +71,6 @@ import Test.Utils.Laws ) import qualified Cardano.Api as CardanoApi -import qualified Cardano.Api.Gen as CardanoApi import qualified Data.ByteString as BS import qualified Data.Map as Map @@ -143,8 +146,8 @@ instance Arbitrary (CardanoApi.UTxO CardanoApi.BabbageEra) where arbitrary = CardanoApi.UTxO . Map.fromList <$> liftArbitrary genTxInOutEntry where genTxInOutEntry = (,) - <$> CardanoApi.genTxIn - <*> CardanoApi.genTxOut CardanoApi.BabbageEra + <$> genTxIn + <*> genTxOut CardanoApi.BabbageEra -------------------------------------------------------------------------------- -- Helpers diff --git a/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs b/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs index 7a0a4731231..4bb4891c769 100644 --- a/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs +++ b/lib/cardano-api-extra/lib/Cardano/Api/Gen.hs @@ -210,12 +210,14 @@ import Cardano.Api , TxOut (..) , TxOutDatum (..) , TxOutValue (..) + , TxProposalProcedures (..) , TxReturnCollateral (..) , TxScriptValidity (TxScriptValidity) , TxTotalCollateral (..) , TxUpdateProposal (..) , TxValidityLowerBound (TxValidityLowerBound) , TxValidityUpperBound (..) + , TxVotingProcedures (..) , TxWithdrawals (..) , UpdateProposal (UpdateProposal) , Value @@ -225,7 +227,6 @@ import Cardano.Api , Witness (..) , byronAddressInEra , collectTxBodyScriptWitnesses - , conwayEraOnwardsConstraints , createAndValidateTransactionBody , forEraMaybeEon , hashScript @@ -258,7 +259,6 @@ import Cardano.Api.Shelley , PlutusScript (..) , PlutusScriptOrReferenceInput (..) , PoolId - , Proposal (..) , ProtocolParameters (..) , ReferenceScript (..) , SimpleScriptOrReferenceInput (..) @@ -1219,6 +1219,11 @@ genNat = do Large (n :: Word64) <- arbitrary pure $ fromIntegral n +genLarge :: (Integral a, Bounded a) => Gen a +genLarge = do + Large (n :: a) <- arbitrary + pure n + genRational :: Gen Rational genRational = (\d -> ratioToRational (1 % d)) <$> genDenominator @@ -1324,7 +1329,7 @@ genRecentEraProtocolParameters = <*> genLovelace <*> genLovelace <*> genLovelace - <*> genEpochNo + <*> genInterval <*> genNat <*> genRationalInt64 <*> genRational @@ -1338,6 +1343,9 @@ genRecentEraProtocolParameters = <*> (Just <$> genNat) <*> (Just <$> genLovelace) +genInterval :: Gen Ledger.EpochInterval +genInterval = Ledger.EpochInterval <$> arbitrary + genWitnessNetworkIdOrByronAddress :: Gen WitnessNetworkIdOrByronAddress genWitnessNetworkIdOrByronAddress = oneof @@ -1494,7 +1502,7 @@ genStakePoolRelay = do genDnsName = do txtLength <- choose (1, 63) txt <- T.pack <$> vectorOf txtLength arbitraryASCIIChar - case Ledger.textToDns txt of + case Ledger.textToDns 64 txt of Nothing -> error "wrong generator for DnsName" Just dns -> return dns @@ -1657,11 +1665,11 @@ genProtocolParametersUpdate = do protocolUpdateExtraPraosEntropy <- liftArbitrary (liftArbitrary genPraosNonce) protocolUpdateMaxBlockHeaderSize <- - liftArbitrary genNat + liftArbitrary genLarge protocolUpdateMaxBlockBodySize <- - liftArbitrary genNat + liftArbitrary genLarge protocolUpdateMaxTxSize <- - liftArbitrary genNat + liftArbitrary genLarge protocolUpdateTxFeeFixed <- liftArbitrary genLovelace protocolUpdateTxFeePerByte <- @@ -1675,7 +1683,7 @@ genProtocolParametersUpdate = do protocolUpdateMinPoolCost <- liftArbitrary genLovelace protocolUpdatePoolRetireMaxEpoch <- - liftArbitrary genEpochNo + liftArbitrary genInterval protocolUpdateStakePoolTargetNum <- liftArbitrary genNat protocolUpdatePoolPledgeInfluence <- @@ -1774,18 +1782,21 @@ genMaybeFeaturedInEra f = inEonForEra (pure Nothing) $ \w -> fmap Just (genFeaturedInEra w (f w)) -genProposals :: forall era. ConwayEraOnwards era -> Gen [Proposal era] +genProposals :: forall era. ConwayEraOnwards era -> Gen (ShelleyApi.TxProposalProcedures BuildTx era) genProposals w = case w of - ConwayEraOnwardsConway -> vectorOf 10 $ genProposal w - -genProposal :: ConwayEraOnwards era -> Gen (Proposal era) -genProposal w = case w of - ConwayEraOnwardsConway -> fmap Proposal arbitrary + ConwayEraOnwardsConway -> + oneof + [ pure TxProposalProceduresNone + , TxProposalProcedures <$> arbitrary <*> pure (BuildTxWith mempty) + ] -genVotingProcedures :: ConwayEraOnwards era -> Gen (ShelleyApi.VotingProcedures era) -genVotingProcedures w = - conwayEraOnwardsConstraints w - $ ShelleyApi.VotingProcedures <$> arbitrary +genVotingProcedures :: ConwayEraOnwards era -> Gen (ShelleyApi.TxVotingProcedures BuildTx era) +genVotingProcedures w = case w of + ConwayEraOnwardsConway -> + oneof + [ TxVotingProcedures <$> arbitrary <*> pure (BuildTxWith mempty) + , pure TxVotingProceduresNone + ] genTxBodyContent :: CardanoEra era -> Gen (TxBodyContent BuildTx era) genTxBodyContent era = withEraWitness era $ \sbe -> do From cbb85faf65f69c87029937dbb7eeadec7846eb10 Mon Sep 17 00:00:00 2001 From: Paolo Veronelli Date: Thu, 21 Mar 2024 13:47:21 +0000 Subject: [PATCH 08/24] Fixes for `primitive` package --- lib/primitive/cardano-wallet-primitive.cabal | 1 + .../Wallet/Primitive/Ledger/Convert.hs | 23 +++++++++++++-- .../Primitive/Ledger/Read/Tx/Features/Mint.hs | 24 +++++++--------- .../Ledger/Read/Tx/Features/Scripts.hs | 28 +++++++++---------- .../Wallet/Primitive/Ledger/Shelley.hs | 5 +--- .../Wallet/Primitive/CollateralSpec.hs | 11 ++++---- 6 files changed, 51 insertions(+), 41 deletions(-) diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index b2861895dd6..8f23943f2d4 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -230,6 +230,7 @@ test-suite test , cardano-api , cardano-crypto-class , cardano-ledger-allegra:{testlib} + , cardano-ledger-api , cardano-ledger-core:{cardano-ledger-core, testlib} , cardano-ledger-shelley , cardano-numeric diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs index d5aef291ea6..705cf44043e 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs @@ -4,6 +4,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} -- | @@ -25,6 +26,7 @@ module Cardano.Wallet.Primitive.Ledger.Convert , toLedgerTimelockScript , toLedgerDelegatee , toLedgerDRep + , toPlutusScriptInfo -- * Conversions from ledger specification types to wallet types , toWalletAddress @@ -85,6 +87,9 @@ import Cardano.Wallet.Primitive.Types.Pool import Cardano.Wallet.Primitive.Types.TokenBundle ( TokenBundle (..) ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( PlutusVersion (..) + ) import Cardano.Wallet.Primitive.Types.TokenPolicyId ( TokenPolicyId (..) ) @@ -137,6 +142,8 @@ import Ouroboros.Consensus.Shelley.Eras import qualified Cardano.Crypto.Hash.Class as Crypto import qualified Cardano.Ledger.Address as Ledger import qualified Cardano.Ledger.Allegra.Scripts as Scripts +import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo +import qualified Cardano.Ledger.Api as Ledger import qualified Cardano.Ledger.Babbage as Babbage import qualified Cardano.Ledger.Babbage.TxBody as Babbage import qualified Cardano.Ledger.Conway.TxCert as Conway @@ -144,6 +151,7 @@ import qualified Cardano.Ledger.Core as LCore import qualified Cardano.Ledger.DRep as Ledger import qualified Cardano.Ledger.Keys as Ledger 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.Wallet.Primitive.Types.Coin as Coin @@ -326,7 +334,7 @@ instance Convert Address (Ledger.Addr StandardCrypto) where toWallet = toWalletAddress toLedgerAddress :: Address -> Ledger.Addr StandardCrypto -toLedgerAddress (Address bytes) = case Ledger.deserialiseAddr bytes of +toLedgerAddress (Address bytes) = case Ledger.decodeAddrLenient bytes of Just addr -> addr Nothing -> error $ unwords [ "toLedger @Address: Invalid address:" @@ -348,7 +356,7 @@ toBabbageTxOut (TxOut addr bundle) = Babbage.BabbageTxOut (toLedger addr) (toLedger bundle) - Babbage.NoDatum + Ledger.NoDatum Ledger.SNothing toConwayTxOut @@ -358,7 +366,7 @@ toConwayTxOut (TxOut addr bundle) = Babbage.BabbageTxOut (toLedger addr) (toLedger bundle) - Babbage.NoDatum + Ledger.NoDatum Ledger.SNothing -- NOTE: Inline scripts and datums will be lost in the conversion. @@ -476,3 +484,12 @@ toLedgerDRep = \case FromDRepID (DRepFromScriptHash (DRepScriptHash scripthash)) -> Ledger.DRepCredential . Ledger.ScriptHashObj . Ledger.ScriptHash . Crypto.UnsafeHash $ toShort scripthash + +toPlutusScriptInfo + :: forall era. Alonzo.AlonzoEraScript era + => Alonzo.PlutusScript era + -> PlutusVersion +toPlutusScriptInfo script = case Alonzo.plutusScriptLanguage @era script of + Ledger.PlutusV1 -> PlutusVersionV1 + Ledger.PlutusV2 -> PlutusVersionV2 + Ledger.PlutusV3 -> PlutusVersionV3 diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Mint.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Mint.hs index 79334d0b87a..117f6fedc36 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Mint.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Mint.hs @@ -43,7 +43,8 @@ import Cardano.Ledger.Shelley.TxWits , scriptWits ) import Cardano.Wallet.Primitive.Ledger.Convert - ( toWalletAssetName + ( toPlutusScriptInfo + , toWalletAssetName , toWalletScript , toWalletTokenPolicyId , toWalletTokenQuantity @@ -62,7 +63,6 @@ import Cardano.Wallet.Primitive.Types.TokenMap import Cardano.Wallet.Primitive.Types.TokenMapWithScripts ( AnyScript (..) , PlutusScriptInfo (PlutusScriptInfo) - , PlutusVersion (..) , ReferenceInput (ReferenceInput) , ScriptReference (ViaSpending) , TokenMapWithScripts (TokenMapWithScripts) @@ -113,7 +113,6 @@ import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import qualified Cardano.Ledger.Core as Core import qualified Cardano.Ledger.Mary.Value as SL -import qualified Cardano.Ledger.Plutus.Language as Ledger import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Wallet.Primitive.Types.TokenMap as TokenMap import qualified Data.Map.Strict as Map @@ -246,8 +245,8 @@ fromAlonzoScriptMap = where toAnyScript (Alonzo.TimelockScript script) = NativeScript (toWalletScript (const Policy) script) ViaSpending - toAnyScript s@(Alonzo.PlutusScript (Ledger.Plutus ver _)) = - PlutusScript (PlutusScriptInfo (toPlutusVer ver) + toAnyScript s@(Alonzo.PlutusScript script) = + PlutusScript (PlutusScriptInfo (toPlutusScriptInfo @StandardAlonzo script) (hashAlonzoScript s)) ViaSpending hashAlonzoScript = fromLedgerScriptHash . Core.hashScript @(Cardano.ShelleyLedgerEra Cardano.AlonzoEra) @@ -257,9 +256,10 @@ fromLedgerScriptToAnyScriptBabbage = toAnyScript where toAnyScript (Alonzo.TimelockScript script) = NativeScript (toWalletScript (const Policy) script) ViaSpending - toAnyScript s@(Alonzo.PlutusScript (Ledger.Plutus ver _)) = + toAnyScript s@(Alonzo.PlutusScript script) = PlutusScript - (PlutusScriptInfo (toPlutusVer ver) (hashBabbageScript s)) + (PlutusScriptInfo (toPlutusScriptInfo @StandardBabbage script) + (hashBabbageScript s)) ViaSpending hashBabbageScript = fromLedgerScriptHash . Core.hashScript @(Cardano.ShelleyLedgerEra Cardano.BabbageEra) @@ -269,18 +269,14 @@ fromLedgerScriptToAnyScriptConway = toAnyScript where toAnyScript (Alonzo.TimelockScript script) = NativeScript (toWalletScript (const Policy) script) ViaSpending - toAnyScript s@(Alonzo.PlutusScript (Ledger.Plutus ver _)) = + toAnyScript s@(Alonzo.PlutusScript script) = PlutusScript - (PlutusScriptInfo (toPlutusVer ver) (hashConwayScript s)) + (PlutusScriptInfo (toPlutusScriptInfo @StandardConway script) + (hashConwayScript s)) ViaSpending hashConwayScript = fromLedgerScriptHash . Core.hashScript @(Cardano.ShelleyLedgerEra Cardano.ConwayEra) -toPlutusVer :: Ledger.Language -> PlutusVersion -toPlutusVer Ledger.PlutusV1 = PlutusVersionV1 -toPlutusVer Ledger.PlutusV2 = PlutusVersionV2 -toPlutusVer Ledger.PlutusV3 = PlutusVersionV3 - fromBabbageScriptMap :: Map (SL.ScriptHash StandardCrypto) (Core.Script StandardBabbage) -> Map TokenPolicyId AnyScript diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Scripts.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Scripts.hs index 9df2a3db933..312f8bc6e57 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Scripts.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Scripts.hs @@ -10,7 +10,6 @@ module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Scripts ( alonzoAnyExplicitScript , babbageAnyExplicitScript , conwayAnyExplicitScript - , toPlutusVer ) where @@ -31,7 +30,8 @@ import Cardano.Ledger.Mary.Value ( PolicyID (..) ) import Cardano.Wallet.Primitive.Ledger.Convert - ( toWalletScript + ( toPlutusScriptInfo + , toWalletScript , toWalletTokenPolicyId ) import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint @@ -42,7 +42,6 @@ import Cardano.Wallet.Primitive.Types.AnyExplicitScripts ) import Cardano.Wallet.Primitive.Types.TokenMapWithScripts ( PlutusScriptInfo (PlutusScriptInfo) - , PlutusVersion (..) , ScriptReference (ViaSpending) ) import Cardano.Wallet.Primitive.Types.TokenPolicyId @@ -52,9 +51,13 @@ import Cardano.Wallet.Primitive.Types.WitnessCount ( WitnessCountCtx , toKeyRole ) +import Ouroboros.Consensus.Shelley.Eras + ( StandardAlonzo + , StandardBabbage + , StandardConway + ) import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo -import qualified Cardano.Ledger.Plutus.Language as Plutus alonzoAnyExplicitScript :: WitnessCountCtx -> AlonzoScript Alonzo -> AnyExplicitScript @@ -63,10 +66,10 @@ alonzoAnyExplicitScript witCtx = \case NativeExplicitScript (toWalletScript (toKeyRole witCtx) script) ViaSpending - script@(Alonzo.PlutusScript (Plutus.Plutus ver _)) -> + script@(Alonzo.PlutusScript s) -> PlutusExplicitScript (PlutusScriptInfo - (toPlutusVer ver) + (toPlutusScriptInfo @StandardAlonzo s) (fromLedgerScriptHash $ hashScript @Alonzo script) ) ViaSpending @@ -86,10 +89,10 @@ babbageAnyExplicitScript witCtx (scriptRef, scriptH, script) = NativeExplicitScript (toWalletScript (toKeyRole witCtx) timelockScript) scriptRef - Alonzo.PlutusScript (Plutus.Plutus ver _) -> + Alonzo.PlutusScript s -> PlutusExplicitScript (PlutusScriptInfo - (toPlutusVer ver) + (toPlutusScriptInfo @StandardBabbage s) (fromLedgerScriptHash $ hashScript @Babbage script) ) scriptRef @@ -109,15 +112,10 @@ conwayAnyExplicitScript witCtx (scriptRef, scriptH, script) = NativeExplicitScript (toWalletScript (toKeyRole witCtx) timelockScript) scriptRef - Alonzo.PlutusScript (Plutus.Plutus ver _) -> + Alonzo.PlutusScript s -> PlutusExplicitScript (PlutusScriptInfo - (toPlutusVer ver) + (toPlutusScriptInfo @StandardConway s) (fromLedgerScriptHash $ hashScript @Conway script) ) scriptRef - -toPlutusVer :: Plutus.Language -> PlutusVersion -toPlutusVer Plutus.PlutusV1 = PlutusVersionV1 -toPlutusVer Plutus.PlutusV2 = PlutusVersionV2 -toPlutusVer Plutus.PlutusV3 = PlutusVersionV3 diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs index c1e1e3c0c79..dbe3c5a7675 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Shelley.hs @@ -270,9 +270,6 @@ import Fmt import GHC.Stack ( HasCallStack ) -import Numeric.Natural - ( Natural - ) import Ouroboros.Consensus.Byron.Ledger ( byronBlockRaw ) @@ -575,7 +572,7 @@ toTip genesisHash (W.BlockHeader sl bl h _) (BlockNo $ fromIntegral $ getQuantity bl) -- NOTE: Unsafe conversion from Natural -> Word16 -fromMaxSize :: Natural -> Quantity "byte" Word16 +fromMaxSize :: Word32 -> Quantity "byte" Word16 fromMaxSize = Quantity . fromIntegral fromShelleyPParams diff --git a/lib/primitive/test/spec/Cardano/Wallet/Primitive/CollateralSpec.hs b/lib/primitive/test/spec/Cardano/Wallet/Primitive/CollateralSpec.hs index e0ecd4a87e6..353493de359 100644 --- a/lib/primitive/test/spec/Cardano/Wallet/Primitive/CollateralSpec.hs +++ b/lib/primitive/test/spec/Cardano/Wallet/Primitive/CollateralSpec.hs @@ -86,6 +86,7 @@ import Test.QuickCheck ) import qualified Cardano.Ledger.Address as L +import qualified Cardano.Ledger.Api.Tx.Address as L import qualified Cardano.Ledger.Crypto as CC import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle import qualified Data.Binary.Get as B @@ -377,8 +378,8 @@ prop_genAddress_coverage = simplifyAddress :: Address -> Maybe Address simplifyAddress (Address addrBytes) = do -- Don't try to simplify malformed addresses or stake addresses. Note that - -- "deserialiseAddr" will not parse stake addresses. - _ <- L.deserialiseAddr addrBytes :: Maybe (L.Addr CC.StandardCrypto) + -- "decodeAddrLenient" will not parse stake addresses. + _ <- L.decodeAddrLenient addrBytes :: Maybe (L.Addr CC.StandardCrypto) bytes <- case runGetMaybe getAddressType (BL.fromStrict addrBytes) of Just BootstrapAddress -> @@ -444,10 +445,10 @@ prop_simplifyAddress_validAddress = Just (Address simplifiedBytes) -> let originalAddress :: Maybe (L.Addr CC.StandardCrypto) - originalAddress = L.deserialiseAddr addrBytes + originalAddress = L.decodeAddrLenient addrBytes simplifiedAddress :: Maybe (L.Addr CC.StandardCrypto) - simplifiedAddress = L.deserialiseAddr simplifiedBytes + simplifiedAddress = L.decodeAddrLenient simplifiedBytes commonErrorOutput :: Testable prop => prop -> Property commonErrorOutput prop = @@ -571,7 +572,7 @@ prop_addressSuitableForCollateral = -- | Returns True if the given address parses as a known address. isValidAddress :: Address -> Bool isValidAddress (Address addrBytes) = - isJust (L.deserialiseAddr addrBytes + isJust (L.decodeAddrLenient addrBytes :: Maybe (L.Addr CC.StandardCrypto)) || isJust (L.deserialiseRewardAcnt addrBytes From 47b5227122c5c86b4e740f44b9335d4b94c9b012 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 21 Mar 2024 13:43:52 +0000 Subject: [PATCH 09/24] Fixes for `address-derivation-discovery` --- .../address-derivation-discovery.cabal | 1 + .../lib/Cardano/Wallet/Address/Encoding.hs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/address-derivation-discovery/address-derivation-discovery.cabal b/lib/address-derivation-discovery/address-derivation-discovery.cabal index a42d0165dff..d69bb4e332f 100644 --- a/lib/address-derivation-discovery/address-derivation-discovery.cabal +++ b/lib/address-derivation-discovery/address-derivation-discovery.cabal @@ -50,6 +50,7 @@ library , cardano-addresses , cardano-crypto , cardano-crypto-class + , cardano-ledger-api , cardano-ledger-byron , cardano-ledger-core , cardano-ledger-shelley diff --git a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Encoding.hs b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Encoding.hs index 2c69d4313b8..33560e28ae7 100644 --- a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Encoding.hs +++ b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Encoding.hs @@ -110,9 +110,9 @@ import qualified Cardano.Address.Style.Shelley as CA import qualified Cardano.Byron.Codec.Cbor as CBOR import qualified Cardano.Chain.Common as Byron import qualified Cardano.Ledger.Address as SL +import qualified Cardano.Ledger.Api as SL import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Credential as SL -import qualified Cardano.Ledger.Crypto as SL import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Wallet.Primitive.Types.Address as W import qualified Cardano.Wallet.Primitive.Types.RewardAccount as W @@ -253,7 +253,7 @@ shelleyDecodeAddress serverNetwork = decodeShelleyAddress :: forall c. (SL.Crypto c) => ByteString -> Either TextDecodingError W.Address decodeShelleyAddress bytes = do - case SL.deserialiseAddr @c bytes of + case SL.decodeAddrLenient @c bytes of Just (SL.Addr addrNetwork _ _) -> do guardNetwork addrNetwork serverNetwork pure (W.Address bytes) From d824c87d584eb5ba374512c99e68b5a80918eba7 Mon Sep 17 00:00:00 2001 From: paolino Date: Wed, 20 Mar 2024 18:34:37 +0000 Subject: [PATCH 10/24] Fixes for `local-cluster` package --- .../Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs | 2 +- .../lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs index 6d07fdc439d..9e1f1c9cd80 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs @@ -505,7 +505,7 @@ configurePool metadataServer recipe = do SJust $ Ledger.PoolMetadata ( fromMaybe (error "invalid url (too long)") - $ textToUrl + $ textToUrl 128 $ T.pack metadataURL ) (blake2b256 (BL.toStrict metadataBytes)) diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs index d0ea4b38651..35440a83d4a 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs @@ -37,7 +37,8 @@ import Cardano.Ledger.Api , ppTauL ) import Cardano.Ledger.BaseTypes - ( Network (Testnet) + ( EpochInterval (..) + , Network (Testnet) , natVersion ) import Cardano.Ledger.Shelley.API @@ -104,7 +105,7 @@ import System.FilePath ( () ) -import qualified Cardano.Ledger.Address as Ledger +import qualified Cardano.Ledger.Api.Tx.Address as Ledger import qualified Cardano.Ledger.Core as Ledger import qualified Cardano.Ledger.Shelley.API as Ledger import qualified Data.Aeson as Aeson @@ -160,7 +161,7 @@ generateGenesis initialFunds genesisMods = do & ppMaxBBSizeL .~ 239_857 & ppMaxBHSizeL - .~ 217_569 + .~ 1_100 & ppMaxTxSizeL .~ 16_384 & ppMinPoolCostL @@ -187,7 +188,7 @@ generateGenesis initialFunds genesisMods = do -- in advance retirements may be announced. For testing purposes, -- we allow retirements to be announced far into the future. & ppEMaxL - .~ 1_000_000 + .~ EpochInterval 1_000_000 let shelleyGenesisData = foldr @@ -209,7 +210,7 @@ generateGenesis initialFunds genesisMods = do , sgInitialFunds = ListMap.fromList [ ( fromMaybe (error "sgInitialFunds: invalid addr") - $ Ledger.deserialiseAddr + $ Ledger.decodeAddrLenient $ unAddress address , Ledger.Coin $ intCast c ) From 752961135d4b86fe9cd82f57db6d168c6a2b18ad Mon Sep 17 00:00:00 2001 From: johannes Date: Fri, 22 Mar 2024 12:24:23 +0000 Subject: [PATCH 11/24] Fixes for `balance-tx` package Notes: - We shouldn't need to generate script wit maps for voting in Api.Gen - "Downgrade" terminology mirroring ledger's "upgrade" - Need proper error handling for downgradePlutusScript in later commit Fix & update balance-tx unit tests - Add and propagate error ErrTxOutInvalidInEra - Fix test PParam protocolParamMaxBlockHeaderSize overflow - Update goldens. 4 byte difference indicated by the error messages. I.e. something intermediatly has changed, but not the final result, or at least not found here. There could still be a change in observable balanceTx behaviour, and it could be an undesirable one... Update: it seems the switch from `evaluateTransactionFee` to `calcMinFeeTx` may not have been what we wanted, need to look into this --- lib/balance-tx/cardano-balance-tx.cabal | 1 + .../lib/internal/Internal/Cardano/Write/Tx.hs | 104 +++++++++++++----- .../Internal/Cardano/Write/Tx/Balance.hs | 7 +- .../Internal/Cardano/Write/Tx/Redeemers.hs | 102 +++++++++++------ .../test/data/balanceTx/1ada-payment/golden | 8 +- .../data/balanceTx/binary/testPParams/golden | 2 +- .../test/data/balanceTx/delegate/golden | 8 +- .../test/data/balanceTx/pingPong_1/golden | 8 +- .../test/data/balanceTx/pingPong_2/golden | 82 +++++++------- .../Internal/Cardano/Write/Tx/BalanceSpec.hs | 64 +++++++---- 10 files changed, 248 insertions(+), 138 deletions(-) diff --git a/lib/balance-tx/cardano-balance-tx.cabal b/lib/balance-tx/cardano-balance-tx.cabal index 2af6d80ef33..e0e3403ff09 100644 --- a/lib/balance-tx/cardano-balance-tx.cabal +++ b/lib/balance-tx/cardano-balance-tx.cabal @@ -119,6 +119,7 @@ test-suite test , cardano-ledger-api , cardano-ledger-babbage:{cardano-ledger-babbage, testlib} , cardano-ledger-byron + , cardano-ledger-conway , cardano-ledger-conway:testlib , cardano-ledger-core , cardano-ledger-mary:testlib 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 f6552f2ccbc..a0ae7a5420c 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs @@ -92,6 +92,7 @@ module Internal.Cardano.Write.Tx , BabbageTxOut (..) , TxOutInBabbage , TxOutInRecentEra (..) + , ErrInvalidTxOutInEra (..) , unwrapTxOutInRecentEra , computeMinimumCoinForTxOut @@ -133,6 +134,7 @@ module Internal.Cardano.Write.Tx -- * UTxO , Shelley.UTxO (..) , utxoFromTxOutsInRecentEra + , unsafeUtxoFromTxOutsInRecentEra -- * Policy and asset identifiers , type PolicyId @@ -153,12 +155,12 @@ import Cardano.Crypto.Hash import Cardano.Ledger.Allegra.Scripts ( translateTimelock ) -import Cardano.Ledger.Alonzo.Plutus.TxInfo +import Cardano.Ledger.Alonzo.Plutus.Context ( EraPlutusContext - , ExtendedUTxO ) import Cardano.Ledger.Alonzo.Scripts - ( AlonzoScript (..) + ( AlonzoEraScript + , AlonzoScript (..) ) import Cardano.Ledger.Alonzo.TxWits ( AlonzoTxWits @@ -168,6 +170,7 @@ import Cardano.Ledger.Alonzo.UTxO ) import Cardano.Ledger.Api ( coinTxOutL + , estimateMinFeeTx , ppKeyDepositL ) import Cardano.Ledger.Api.UTxO @@ -178,6 +181,7 @@ import Cardano.Ledger.Babbage.TxBody ) import Cardano.Ledger.BaseTypes ( ProtVer (..) + , StrictMaybe (..) , Version , maybeToStrictMaybe ) @@ -187,6 +191,9 @@ import Cardano.Ledger.Coin import Cardano.Ledger.Conway.PParams ( ppDRepDepositL ) +import Cardano.Ledger.Conway.Scripts + ( PlutusScript (..) + ) import Cardano.Ledger.Crypto ( StandardCrypto ) @@ -200,9 +207,6 @@ import Cardano.Ledger.Plutus.Data ( BinaryData , Datum (..) ) -import Cardano.Ledger.Plutus.Language - ( Language (PlutusV1) - ) import Cardano.Ledger.SafeHash ( SafeHash , extractHash @@ -213,8 +217,10 @@ import Cardano.Ledger.Val , modifyCoin ) import Control.Arrow - ( second - , (>>>) + ( (>>>) + ) +import Data.Bits + ( Bits ) import Data.ByteString ( ByteString @@ -275,7 +281,6 @@ import qualified Cardano.Ledger.Credential as Core import qualified Cardano.Ledger.Keys as Ledger import qualified Cardano.Ledger.Mary.Value as Value import qualified Cardano.Ledger.Plutus.Data as Alonzo -import qualified Cardano.Ledger.Shelley.API.Wallet as Shelley import qualified Cardano.Ledger.Shelley.UTxO as Shelley import qualified Cardano.Ledger.TxIn as Ledger import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert @@ -344,22 +349,25 @@ type RecentEraConstraints era = , Core.Tx era ~ Babbage.AlonzoTx era , Core.Value era ~ Value , Core.TxWits era ~ AlonzoTxWits era - , ExtendedUTxO era + -- , ExtendedUTxO era , Alonzo.AlonzoEraPParams era , Ledger.AlonzoEraTx era , ScriptsNeeded era ~ AlonzoScriptsNeeded era - , EraPlutusContext 'PlutusV1 era + , AlonzoEraScript era + -- , EraPlutusContext 'PlutusV1 era , Eq (TxOut era) , Ledger.Crypto (Core.EraCrypto era) , Show (TxOut era) , Show (Core.Tx era) , Eq (Core.Tx era) , Babbage.BabbageEraTxBody era + , Alonzo.AlonzoEraTxBody era , Shelley.EraUTxO era , Show (TxOut era) , Eq (TxOut era) , Show (PParams era) , Show (Script era) + , EraPlutusContext era ) -- | Returns a proof that the given era is a recent era. @@ -535,7 +543,7 @@ type ScriptHash = Core.ScriptHash StandardCrypto type Value = MaryValue StandardCrypto unsafeAddressFromBytes :: ByteString -> Address -unsafeAddressFromBytes bytes = case Ledger.deserialiseAddr bytes of +unsafeAddressFromBytes bytes = case Ledger.decodeAddr bytes of Just addr -> addr Nothing -> error "unsafeAddressFromBytes: failed to deserialise" @@ -566,12 +574,16 @@ data TxOutInRecentEra = (Maybe (AlonzoScript LatestLedgerEra)) -- Same contents as 'TxOut LatestLedgerEra'. +data ErrInvalidTxOutInEra + = InlinePlutusV3ScriptNotSupportedInBabbage + deriving (Show, Eq) + unwrapTxOutInRecentEra :: forall era. IsRecentEra era => TxOutInRecentEra - -> TxOut era + -> Either ErrInvalidTxOutInEra (TxOut era) unwrapTxOutInRecentEra recentEraTxOut = case recentEra @era of - RecentEraConway -> recentEraToConwayTxOut recentEraTxOut + RecentEraConway -> pure $ recentEraToConwayTxOut recentEraTxOut RecentEraBabbage -> recentEraToBabbageTxOut recentEraTxOut recentEraToConwayTxOut @@ -582,25 +594,36 @@ recentEraToConwayTxOut (TxOutInRecentEra addr val datum mscript) = recentEraToBabbageTxOut :: TxOutInRecentEra - -> Babbage.BabbageTxOut (Babbage.BabbageEra StandardCrypto) + -> Either ErrInvalidTxOutInEra (BabbageTxOut BabbageEra) recentEraToBabbageTxOut (TxOutInRecentEra addr val datum mscript) = Babbage.BabbageTxOut addr val - (castDatum datum) - (maybeToStrictMaybe (castScript <$> mscript)) + (downgradeDatum datum) + <$> (maybe (Right SNothing) (fmap SJust . downgradeScript) mscript) where - castDatum = \case + downgradeDatum = \case Alonzo.NoDatum -> Alonzo.NoDatum Alonzo.DatumHash h -> Alonzo.DatumHash h Alonzo.Datum binaryData -> Alonzo.Datum (coerce binaryData) - castScript :: AlonzoScript StandardConway -> AlonzoScript StandardBabbage - castScript = \case - Alonzo.TimelockScript timelockEra -> - Alonzo.TimelockScript (translateTimelock timelockEra) - Alonzo.PlutusScript bs -> - Alonzo.PlutusScript bs + + downgradeScript + :: AlonzoScript ConwayEra + -> Either ErrInvalidTxOutInEra (AlonzoScript BabbageEra) + downgradeScript = \case + TimelockScript timelockEra + -> pure $ Alonzo.TimelockScript (translateTimelock timelockEra) + PlutusScript s + -> PlutusScript <$> downgradePlutusScript s + + downgradePlutusScript + :: PlutusScript ConwayEra + -> Either ErrInvalidTxOutInEra (PlutusScript BabbageEra) + downgradePlutusScript = \case + ConwayPlutusV1 s -> pure $ BabbagePlutusV1 s + ConwayPlutusV2 s -> pure $ BabbagePlutusV2 s + ConwayPlutusV3 _s -> Left InlinePlutusV3ScriptNotSupportedInBabbage -- -- MinimumUTxO @@ -661,9 +684,20 @@ isBelowMinimumCoinForTxOut pp out = utxoFromTxOutsInRecentEra :: IsRecentEra era => [(TxIn, TxOutInRecentEra)] - -> Shelley.UTxO era + -> Either ErrInvalidTxOutInEra (Shelley.UTxO era) utxoFromTxOutsInRecentEra = - Shelley.UTxO . Map.fromList . map (second unwrapTxOutInRecentEra) + fmap (Shelley.UTxO . Map.fromList) . mapM (secondM unwrapTxOutInRecentEra) + + where + secondM :: Monad m => (o -> m o') -> (i, o) -> m (i, o') + secondM f (i, o) = f o >>= \o' -> return (i, o') + +unsafeUtxoFromTxOutsInRecentEra + :: IsRecentEra era + => [(TxIn, TxOutInRecentEra)] + -> Shelley.UTxO era +unsafeUtxoFromTxOutsInRecentEra = + either (error . show) id . utxoFromTxOutsInRecentEra -------------------------------------------------------------------------------- -- Tx @@ -804,10 +838,18 @@ evaluateMinimumFee pp tx kwc = KeyWitnessCounts {nKeyWits, nBootstrapWits} = kwc mainFee :: Coin - mainFee = Shelley.evaluateTransactionFee pp tx nKeyWits + mainFee = + estimateMinFeeTx pp tx + (unsafeIntCast nKeyWits) + accountForBootWitsElsewhere FeePerByte feePerByte = getFeePerByte pp + -- 'estimateMinFeeTx' appears to assume byron/bootstrap wits contain no + -- address attributes or payload. For now, let's keep using our own + -- estimation. + accountForBootWitsElsewhere = 0 + bootWitnessFee :: Coin bootWitnessFee = Coin $ intCast $ feePerByte * byteCount where @@ -820,6 +862,14 @@ evaluateMinimumFee pp tx kwc = sizeOf_BootstrapWitnesses 0 = 0 sizeOf_BootstrapWitnesses n = 4 + 180 * n + unsafeIntCast + :: (HasCallStack, Integral a, Integral b, Bits a, Bits b, Show a) + => a + -> b + unsafeIntCast x = fromMaybe err $ intCastMaybe x + where + err = error $ "unsafeIntCast failed for " <> show x + -- | Evaluate the /balance/ of a transaction using the ledger. -- -- The balance is defined as: diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs index f1e63d67ac7..4862d4a5a73 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs @@ -161,7 +161,8 @@ import Data.Group ( Group (invert) ) import Data.IntCast - ( intCastMaybe + ( intCast + , intCastMaybe ) import Data.List.NonEmpty ( NonEmpty (..) @@ -392,7 +393,7 @@ data ErrBalanceTx era | ErrBalanceTxInsufficientCollateral (ErrBalanceTxInsufficientCollateralError era) | ErrBalanceTxConflictingNetworks - | ErrBalanceTxAssignRedeemers ErrAssignRedeemers + | ErrBalanceTxAssignRedeemers (ErrAssignRedeemers era) | ErrBalanceTxInternalError (ErrBalanceTxInternalError era) | ErrBalanceTxInputResolutionConflicts (NonEmpty (TxOut era, TxOut era)) @@ -824,7 +825,7 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment -> Tx era -> ExceptT (ErrBalanceTx era) m (Tx era) guardTxSize witCount tx = do - let maxSize = W.TxSize (pp ^. ppMaxTxSizeL) + let maxSize = W.TxSize $ intCast (pp ^. ppMaxTxSizeL) when (estimateSignedTxSize pp witCount tx > maxSize) $ throwE ErrBalanceTxMaxSizeLimitExceeded pure tx 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 f0c9eed36ed..af76f0b1ce8 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 @@ -4,9 +4,11 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UndecidableInstances #-} {- HLINT ignore "Use <$>" -} -- | @@ -22,11 +24,12 @@ module Internal.Cardano.Write.Tx.Redeemers import Prelude -import Cardano.Ledger.Alonzo.Plutus.TxInfo - ( TranslationError +import Cardano.Ledger.Alonzo.Plutus.Context + ( EraPlutusContext (..) ) import Cardano.Ledger.Api - ( Tx + ( AsItem (..) + , Tx , bodyTxL , rdmrsTxWitsL , scriptIntegrityHashTxBodyL @@ -79,6 +82,9 @@ import Data.Map.Strict ( Map , (!) ) +import Data.Word + ( Word32 + ) import Fmt ( Buildable (..) ) @@ -89,8 +95,8 @@ import Internal.Cardano.Write.Tx ( IsRecentEra (..) , PParams , PolicyId + , RecentEra (..) , RewardAccount - , StandardCrypto , TxIn , UTxO ) @@ -100,26 +106,30 @@ import Internal.Cardano.Write.Tx.TimeTranslation , systemStartTime ) -import qualified Cardano.Ledger.Alonzo.PlutusScriptApi as Alonzo import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import qualified Cardano.Ledger.Alonzo.Tx as Alonzo +import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo import qualified Cardano.Ledger.Alonzo.TxWits as Alonzo +import qualified Cardano.Ledger.Api as Alonzo +import qualified Cardano.Ledger.Api as Conway import qualified Cardano.Ledger.Api as Ledger -import qualified Cardano.Ledger.Plutus.Data as Alonzo import qualified Data.ByteString.Lazy as BL import qualified Data.Map as Map import qualified Data.Map.Merge.Strict as Map import qualified Data.Set as Set import qualified Data.Text as T -data ErrAssignRedeemers +data ErrAssignRedeemers era = ErrAssignRedeemersScriptFailure Redeemer String | 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 (TranslationError StandardCrypto) - deriving (Generic, Eq, Show) + | ErrAssignRedeemersTranslationError (ContextError era) + deriving (Generic) + +deriving instance Eq (ContextError era) => Eq (ErrAssignRedeemers era) +deriving instance Show (ContextError era) => Show (ErrAssignRedeemers era) assignScriptRedeemers :: forall era. IsRecentEra era @@ -128,7 +138,7 @@ assignScriptRedeemers -> UTxO era -> [Redeemer] -> Tx era - -> Either ErrAssignRedeemers (Tx era) + -> Either (ErrAssignRedeemers era) (Tx era) assignScriptRedeemers pparams timeTranslation utxo redeemers tx = do flip execStateT tx $ do indexedRedeemers <- StateT assignNullRedeemers @@ -149,8 +159,8 @@ assignScriptRedeemers pparams timeTranslation utxo redeemers tx = do -- 'Redeemer' type which is mapped to an 'Alonzo.ScriptPurpose'. assignNullRedeemers :: Tx era - -> Either ErrAssignRedeemers - ( Map Alonzo.RdmrPtr Redeemer + -> Either (ErrAssignRedeemers era) + ( Map (Alonzo.PlutusPurpose Alonzo.AsIndex era) Redeemer , Tx era ) assignNullRedeemers ledgerTx = do @@ -164,9 +174,9 @@ assignScriptRedeemers pparams timeTranslation utxo redeemers tx = do ) where parseRedeemer rd = do - let mPtr = Alonzo.rdptr - (view bodyTxL ledgerTx) - (toScriptPurpose rd) + let mPtr = Alonzo.redeemerPointer + (view bodyTxL ledgerTx) + (toScriptPurpose @era rd) ptr <- case mPtr of SNothing -> Left $ ErrAssignRedeemersTargetNotFound rd SJust ptr -> pure ptr @@ -180,31 +190,32 @@ assignScriptRedeemers pparams timeTranslation utxo redeemers tx = do -- | Evaluate execution units of each script/redeemer in the transaction. -- This may fail for each script. evaluateExecutionUnits - :: Map Alonzo.RdmrPtr Redeemer + :: Map (Alonzo.PlutusPurpose Alonzo.AsIndex era) Redeemer -> Tx era - -> Either ErrAssignRedeemers - (Map Alonzo.RdmrPtr (Either ErrAssignRedeemers Alonzo.ExUnits)) + -> Either (ErrAssignRedeemers era) + (Map (Alonzo.PlutusPurpose Alonzo.AsIndex era) + (Either (ErrAssignRedeemers era) Alonzo.ExUnits)) evaluateExecutionUnits indexedRedeemers ledgerTx = Ledger.evalTxExUnits pparams ledgerTx utxo epochInformation systemStart & bimap - ErrAssignRedeemersTranslationError - (hoistScriptFailure indexedRedeemers) + ErrAssignRedeemersTranslationError (hoistScriptFailure indexedRedeemers) hoistScriptFailure :: Show scriptFailure - => Map Alonzo.RdmrPtr Redeemer - -> Map Alonzo.RdmrPtr (Either scriptFailure a) - -> Map Alonzo.RdmrPtr (Either ErrAssignRedeemers a) + => Map (Alonzo.PlutusPurpose Alonzo.AsIndex era) Redeemer + -> Map (Alonzo.PlutusPurpose Alonzo.AsIndex era) (Either scriptFailure a) + -> Map (Alonzo.PlutusPurpose Alonzo.AsIndex era) (Either (ErrAssignRedeemers era) a) hoistScriptFailure indexedRedeemers = Map.mapWithKey $ \ptr -> left $ \e -> ErrAssignRedeemersScriptFailure (indexedRedeemers ! ptr) (show e) -- | Change execution units for each redeemers in the transaction to what -- they ought to be. assignExecutionUnits - :: Map Alonzo.RdmrPtr (Either ErrAssignRedeemers Alonzo.ExUnits) + :: Map (Alonzo.PlutusPurpose Alonzo.AsIndex era) + (Either (ErrAssignRedeemers era) Alonzo.ExUnits) -> Tx era - -> Either ErrAssignRedeemers (Tx era) + -> Either (ErrAssignRedeemers era) (Tx era) assignExecutionUnits exUnits ledgerTx = do let Alonzo.Redeemers rdmrs = view (witsTxL . rdmrsTxWitsL) ledgerTx @@ -234,14 +245,14 @@ assignScriptRedeemers pparams timeTranslation utxo redeemers tx = do Alonzo.hashScriptIntegrity (Set.fromList $ Alonzo.getLanguageView pparams <$> langs) (Alonzo.txrdmrs wits) - (Alonzo.txdats wits) + (Alonzo.txdats' wits) where wits = Alonzo.wits ledgerTx langs = - [ l + [ Alonzo.plutusScriptLanguage plutus | (_hash, script) <- Map.toList (Alonzo.txscripts wits) , (not . Ledger.isNativeScript @era) script - , Just l <- [Alonzo.language script] + , Just plutus <- [Alonzo.toPlutusScript script] ] -- @@ -273,14 +284,41 @@ redeemerData = \case toScriptPurpose :: IsRecentEra era => Redeemer - -> Alonzo.ScriptPurpose era + -> Alonzo.PlutusPurpose AsItem era toScriptPurpose = \case RedeemerSpending _ txin -> - Alonzo.Spending txin + mkSpendingPurpose $ AsItem txin RedeemerMinting _ pid -> - Alonzo.Minting pid + mkMintingPurpose $ AsItem pid RedeemerRewarding _ acc -> - Alonzo.Rewarding acc + mkRewardingPurpose $ AsItem acc + +mkSpendingPurpose + :: forall era + . IsRecentEra era + => AsItem Word32 TxIn + -> Alonzo.PlutusPurpose AsItem era +mkSpendingPurpose = case recentEra @era of + RecentEraBabbage -> Alonzo.AlonzoSpending + RecentEraConway -> Conway.ConwaySpending + +mkMintingPurpose + :: forall era + . IsRecentEra era + => AsItem Word32 PolicyId + -> Alonzo.PlutusPurpose AsItem era +mkMintingPurpose = case recentEra @era of + RecentEraBabbage -> Alonzo.AlonzoMinting + RecentEraConway -> Conway.ConwayMinting + +mkRewardingPurpose + :: forall era + . IsRecentEra era + => AsItem Word32 RewardAccount + -> Alonzo.PlutusPurpose AsItem era +mkRewardingPurpose = case recentEra @era of + RecentEraBabbage -> Alonzo.AlonzoRewarding + RecentEraConway -> Conway.ConwayRewarding -------------------------------------------------------------------------------- -- Utils diff --git a/lib/balance-tx/test/data/balanceTx/1ada-payment/golden b/lib/balance-tx/test/data/balanceTx/1ada-payment/golden index f8d856c5fbf..2a925a3a5c5 100644 --- a/lib/balance-tx/test/data/balanceTx/1ada-payment/golden +++ b/lib/balance-tx/test/data/balanceTx/1ada-payment/golden @@ -18,10 +18,10 @@ 0.850000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 850000) (MultiAsset (fromList [])), required = MaryValue (Coin 1000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 150000) (MultiAsset (fromList []))}) 0.900000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 900000) (MultiAsset (fromList [])), required = MaryValue (Coin 1000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 100000) (MultiAsset (fromList []))}) 0.950000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 950000) (MultiAsset (fromList [])), required = MaryValue (Coin 1000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 50000) (MultiAsset (fromList []))}) - 1.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 168845, shortfall = Coin 168845}) - 1.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 168845, shortfall = Coin 118845}) - 1.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 168845, shortfall = Coin 68845}) - 1.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 168845, shortfall = Coin 18845}) + 1.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 169021, shortfall = Coin 169021}) + 1.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 169021, shortfall = Coin 119021}) + 1.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 169021, shortfall = Coin 69021}) + 1.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 169021, shortfall = Coin 19021}) 1.200000,0.200000,0.163741 1.250000,0.250000,0.163741 1.300000,0.300000,0.163741 diff --git a/lib/balance-tx/test/data/balanceTx/binary/testPParams/golden b/lib/balance-tx/test/data/balanceTx/binary/testPParams/golden index d7021ddb3e9..c3bd44107ce 100644 --- a/lib/balance-tx/test/data/balanceTx/binary/testPParams/golden +++ b/lib/balance-tx/test/data/balanceTx/binary/testPParams/golden @@ -1 +1 @@ -97182c1a00025ef51a000186a01940001a000186a01a001e84801a1dcd6500021864d81e820001d81e820001d81e82000106001a01e848001910d6a2009f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff019f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c800ff82d81e82190241192710d81e821902d11a00989680821a00d59f801b00000002540be400821a00d59f801b00000002540be400190fa0189603 \ No newline at end of file +97182c1a00025ef51a000186a019400019044c1a001e84801a1dcd6500021864d81e820001d81e820001d81e82000106001a01e848001910d6a2009f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff019f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c800ff82d81e82190241192710d81e821902d11a00989680821a00d59f801b00000002540be400821a00d59f801b00000002540be400190fa0189603 \ No newline at end of file diff --git a/lib/balance-tx/test/data/balanceTx/delegate/golden b/lib/balance-tx/test/data/balanceTx/delegate/golden index c007e722648..093e985e25a 100644 --- a/lib/balance-tx/test/data/balanceTx/delegate/golden +++ b/lib/balance-tx/test/data/balanceTx/delegate/golden @@ -38,10 +38,10 @@ 1.850000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 1850000) (MultiAsset (fromList [])), required = MaryValue (Coin 2000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 150000) (MultiAsset (fromList []))}) 1.900000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 1900000) (MultiAsset (fromList [])), required = MaryValue (Coin 2000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 100000) (MultiAsset (fromList []))}) 1.950000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 1950000) (MultiAsset (fromList [])), required = MaryValue (Coin 2000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 50000) (MultiAsset (fromList []))}) - 2.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176457, shortfall = Coin 176457}) - 2.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176457, shortfall = Coin 126457}) - 2.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176457, shortfall = Coin 76457}) - 2.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176457, shortfall = Coin 26457}) + 2.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176633, shortfall = Coin 176633}) + 2.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176633, shortfall = Coin 126633}) + 2.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176633, shortfall = Coin 76633}) + 2.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 176633, shortfall = Coin 26633}) 2.200000,0.200000,0.170957 2.250000,0.250000,0.170957 2.300000,0.300000,0.170957 diff --git a/lib/balance-tx/test/data/balanceTx/pingPong_1/golden b/lib/balance-tx/test/data/balanceTx/pingPong_1/golden index cdf4d906659..ab70fc860c9 100644 --- a/lib/balance-tx/test/data/balanceTx/pingPong_1/golden +++ b/lib/balance-tx/test/data/balanceTx/pingPong_1/golden @@ -38,10 +38,10 @@ 1.850000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 1850000) (MultiAsset (fromList [])), required = MaryValue (Coin 2000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 150000) (MultiAsset (fromList []))}) 1.900000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 1900000) (MultiAsset (fromList [])), required = MaryValue (Coin 2000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 100000) (MultiAsset (fromList []))}) 1.950000,ErrBalanceTxAssetsInsufficient (ErrBalanceTxAssetsInsufficientError {available = MaryValue (Coin 1950000) (MultiAsset (fromList [])), required = MaryValue (Coin 2000000) (MultiAsset (fromList [])), shortfall = MaryValue (Coin 50000) (MultiAsset (fromList []))}) - 2.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170561, shortfall = Coin 170561}) - 2.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170561, shortfall = Coin 120561}) - 2.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170561, shortfall = Coin 70561}) - 2.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170561, shortfall = Coin 20561}) + 2.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170737, shortfall = Coin 170737}) + 2.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170737, shortfall = Coin 120737}) + 2.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170737, shortfall = Coin 70737}) + 2.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 170737, shortfall = Coin 20737}) 2.200000,0.200000,0.166997 2.250000,0.250000,0.166997 2.300000,0.300000,0.166997 diff --git a/lib/balance-tx/test/data/balanceTx/pingPong_2/golden b/lib/balance-tx/test/data/balanceTx/pingPong_2/golden index ed1b91397b7..537e0deb89b 100644 --- a/lib/balance-tx/test/data/balanceTx/pingPong_2/golden +++ b/lib/balance-tx/test/data/balanceTx/pingPong_2/golden @@ -1,44 +1,44 @@ - 0.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2022673, shortfall = Coin 2022673}) - 0.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1978877}) - 0.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1928877}) - 0.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1878877}) - 0.200000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1828877}) - 0.250000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1778877}) - 0.300000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1728877}) - 0.350000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1678877}) - 0.400000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1628877}) - 0.450000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1578877}) - 0.500000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1528877}) - 0.550000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1478877}) - 0.600000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1428877}) - 0.650000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1378877}) - 0.700000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1328877}) - 0.750000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1278877}) - 0.800000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1228877}) - 0.850000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1178877}) - 0.900000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1128877}) - 0.950000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1078877}) - 1.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 1028877}) - 1.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 978877}) - 1.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 928877}) - 1.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 878877}) - 1.200000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 828877}) - 1.250000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 778877}) - 1.300000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 728877}) - 1.350000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 678877}) - 1.400000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 628877}) - 1.450000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 578877}) - 1.500000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 528877}) - 1.550000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 478877}) - 1.600000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 428877}) - 1.650000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 378877}) - 1.700000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 328877}) - 1.750000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 278877}) - 1.800000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 228877}) - 1.850000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2028877, shortfall = Coin 178877}) - 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}) + 0.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2022849, shortfall = Coin 2022849}) + 0.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1979053}) + 0.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1929053}) + 0.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1879053}) + 0.200000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1829053}) + 0.250000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1779053}) + 0.300000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1729053}) + 0.350000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1679053}) + 0.400000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1629053}) + 0.450000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1579053}) + 0.500000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1529053}) + 0.550000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1479053}) + 0.600000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1429053}) + 0.650000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1379053}) + 0.700000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1329053}) + 0.750000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1279053}) + 0.800000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1229053}) + 0.850000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1179053}) + 0.900000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1129053}) + 0.950000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1079053}) + 1.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 1029053}) + 1.050000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 979053}) + 1.100000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 929053}) + 1.150000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 879053}) + 1.200000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 829053}) + 1.250000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 779053}) + 1.300000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 729053}) + 1.350000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 679053}) + 1.400000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 629053}) + 1.450000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 579053}) + 1.500000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 529053}) + 1.550000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 479053}) + 1.600000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 429053}) + 1.650000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 379053}) + 1.700000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 329053}) + 1.750000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 279053}) + 1.800000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 229053}) + 1.850000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 179053}) + 1.900000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 129053}) + 1.950000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 79053}) + 2.000000,ErrBalanceTxUnableToCreateChange (ErrBalanceTxUnableToCreateChangeError {requiredCost = Coin 2029053, shortfall = Coin 29053}) 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}) 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 82542298008..da79e055661 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 @@ -30,6 +30,9 @@ module Internal.Cardano.Write.Tx.BalanceSpec import Prelude +import Cardano.Api.Ledger + ( EpochInterval (..) + ) import Cardano.Binary ( ToCBOR , serialize' @@ -40,7 +43,7 @@ import Cardano.Crypto.Wallet , toXPub ) import Cardano.Ledger.Alonzo.Plutus.TxInfo - ( TranslationError (..) + ( AlonzoContextError (..) ) import Cardano.Ledger.Api ( AllegraEraTxBody (..) @@ -64,12 +67,21 @@ import Cardano.Ledger.Api , serialiseAddr , totalCollateralTxBodyL ) +import Cardano.Ledger.Babbage.TxInfo + ( BabbageContextError (..) + ) +import Cardano.Ledger.Conway.TxInfo + ( ConwayContextError (..) + ) import Cardano.Ledger.Era ( Era ) import Cardano.Ledger.Keys.Bootstrap ( makeBootstrapWitness ) +import Cardano.Ledger.Plutus + ( mkCostModels + ) import Cardano.Ledger.Plutus.Language ( Language (..) ) @@ -271,7 +283,7 @@ import Internal.Cardano.Write.Tx , serializeTx , toCardanoApiTx , toCardanoApiUTxO - , utxoFromTxOutsInRecentEra + , unsafeUtxoFromTxOutsInRecentEra ) import Internal.Cardano.Write.Tx.Balance ( ChangeAddressGen (..) @@ -706,8 +718,9 @@ spec_balanceTransaction = describe "balanceTransaction" $ do Left (ErrBalanceTxAssignRedeemers (ErrAssignRedeemersTranslationError + (AlonzoContextError (TimeTranslationPastHorizon - _pastHoriozon))) -> return () + _pastHoriozon)))) -> return () other -> expectationFailure $ "Expected pastHorizon failure; got " <> show other @@ -1183,7 +1196,7 @@ spec_estimateSignedTxSize = describe "estimateSignedTxSize" $ do -> Tx era -> UTxO era utxoPromisingInputsHaveAddress addr tx = - utxoFromTxOutsInRecentEra + unsafeUtxoFromTxOutsInRecentEra [ (i , TxOutInRecentEra (Convert.toLedger addr) @@ -1466,15 +1479,26 @@ prop_balanceTransactionValid counterexample counterexampleText $ property False Left (ErrBalanceTxAssignRedeemers - (ErrAssignRedeemersTranslationError - (ByronTxOutInContext _))) -> - label "failed with ByronTxOutInContext" $ property True - Left - (ErrBalanceTxAssignRedeemers - (ErrAssignRedeemersTranslationError - (ReferenceScriptsNotSupported _))) -> - -- Possible with PlutusV1 - label "ReferenceScriptsNotSupported" $ property True + (ErrAssignRedeemersTranslationError x)) -> + case recentEra @era of + RecentEraBabbage -> case x of + ByronTxOutInContext _ -> + label "failed with ByronTxOutInContext" + $ property True + ReferenceScriptsNotSupported _ -> + label "ReferenceScriptsNotSupported" + $ property True + _ -> property False + RecentEraConway -> case x of + BabbageContextError y -> case y of + ByronTxOutInContext _ -> + label "failed with ByronTxOutInContext" + $ property True + ReferenceScriptsNotSupported _ -> + label "ReferenceScriptsNotSupported" + $ property True + _ -> property False + _ -> property False Left ErrBalanceTxUnableToCreateChange {} -> label "unable to create change" $ property True Left ErrBalanceTxInputResolutionConflicts{} -> @@ -1535,7 +1559,7 @@ prop_balanceTransactionValid tx partialTx.timelockKeyWitnessCounts) tx - let limit = protocolParams ^. ppMaxTxSizeL + let limit = intCast $ protocolParams ^. ppMaxTxSizeL let msg = unwords [ "The tx size " , show size @@ -2379,11 +2403,7 @@ costModelsForTesting = either (error . show) id $ do , 43357, 32, 32247, 32, 38314, 32, 20000000000, 20000000000, 9462713 , 1021, 10, 20000000000, 0, 20000000000 ] - pure Alonzo.CostModels - { costModelsValid = Map.fromList [(PlutusV1, v1), (PlutusV2, v2)] - , costModelsErrors = Map.empty - , costModelsUnknown = Map.empty - } + pure $ mkCostModels $ Map.fromList [(PlutusV1, v1), (PlutusV2, v2)] dummyChangeAddrGen :: ChangeAddressGen DummyChangeState dummyChangeAddrGen = ChangeAddressGen @@ -2487,7 +2507,7 @@ mockCardanoApiPParamsForBalancing = CardanoApi.ProtocolParameters , CardanoApi.protocolParamProtocolVersion = (6, 0) , CardanoApi.protocolParamDecentralization = Just 0 , CardanoApi.protocolParamExtraPraosEntropy = Nothing - , CardanoApi.protocolParamMaxBlockHeaderSize = 100_000 -- Dummy value + , CardanoApi.protocolParamMaxBlockHeaderSize = 1_100 , CardanoApi.protocolParamMaxBlockBodySize = 100_000 , CardanoApi.protocolParamStakeAddressDeposit = CardanoApi.Lovelace 2_000_000 @@ -2495,7 +2515,7 @@ mockCardanoApiPParamsForBalancing = CardanoApi.ProtocolParameters CardanoApi.Lovelace 500_000_000 , CardanoApi.protocolParamMinPoolCost = CardanoApi.Lovelace 32_000_000 - , CardanoApi.protocolParamPoolRetireMaxEpoch = CardanoApi.EpochNo 2 + , CardanoApi.protocolParamPoolRetireMaxEpoch = EpochInterval 2 , CardanoApi.protocolParamStakePoolTargetNum = 100 , CardanoApi.protocolParamPoolPledgeInfluence = 0 , CardanoApi.protocolParamMonetaryExpansion = 0 @@ -2530,7 +2550,7 @@ pingPong_2 = PartialTx , unsafeFromHex "000d80018183581d714d72cf569a339a18a7d9302313983f56e0d96cd45bdcb1d6512dca6a1a001e848058208392f0c940435c06888f9bdb8c74a95dc69f156367d6a089cf008ae05caae01e02000e80a20381591b72591b6f01000033233332222333322223322332232323332223233322232333333332222222232333222323333222232323322323332223233322232323322332232323333322222332233223322332233223322223223223232533530333330083333573466e1d40192004204f23333573466e1d401d2002205123333573466e1d40212000205323504b35304c3357389201035054310004d49926499263333573466e1d40112004205323333573466e1d40152002205523333573466e1d40192000205723504b35304c3357389201035054310004d49926499263333573466e1cd55cea8012400046601664646464646464646464646666ae68cdc39aab9d500a480008cccccccccc064cd409c8c8c8cccd5cd19b8735573aa004900011980f981d1aba15002302c357426ae8940088d4164d4c168cd5ce2481035054310005b49926135573ca00226ea8004d5d0a80519a8138141aba150093335502e75ca05a6ae854020ccd540b9d728169aba1500733502704335742a00c66a04e66aa0a8098eb4d5d0a8029919191999ab9a3370e6aae754009200023350213232323333573466e1cd55cea80124000466a05266a084eb4d5d0a80118239aba135744a00446a0ba6a60bc66ae712401035054310005f49926135573ca00226ea8004d5d0a8011919191999ab9a3370e6aae7540092000233502733504275a6ae854008c11cd5d09aba2500223505d35305e3357389201035054310005f49926135573ca00226ea8004d5d09aba2500223505935305a3357389201035054310005b49926135573ca00226ea8004d5d0a80219a813bae35742a00666a04e66aa0a8eb88004d5d0a801181c9aba135744a00446a0aa6a60ac66ae71241035054310005749926135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135573ca00226ea8004d5d0a8011919191999ab9a3370ea00290031180f181d9aba135573ca00646666ae68cdc3a801240084603a608a6ae84d55cf280211999ab9a3370ea00690011180e98181aba135573ca00a46666ae68cdc3a80224000460406eb8d5d09aab9e50062350503530513357389201035054310005249926499264984d55cea80089baa001357426ae8940088d4124d4c128cd5ce249035054310004b49926104a1350483530493357389201035054350004a4984d55cf280089baa001135573a6ea80044d55ce9baa0012212330010030022001222222222212333333333300100b00a00900800700600500400300220012212330010030022001122123300100300212001122123300100300212001122123300100300212001212222300400521222230030052122223002005212222300100520011232230023758002640026aa078446666aae7c004940388cd4034c010d5d080118019aba200203323232323333573466e1cd55cea801a4000466600e6464646666ae68cdc39aab9d5002480008cc034c0c4d5d0a80119a8098169aba135744a00446a06c6a606e66ae71241035054310003849926135573ca00226ea8004d5d0a801999aa805bae500a35742a00466a01eeb8d5d09aba25002235032353033335738921035054310003449926135744a00226aae7940044dd50009110919980080200180110009109198008018011000899aa800bae75a224464460046eac004c8004d540d888c8cccd55cf80112804919a80419aa81898031aab9d5002300535573ca00460086ae8800c0b84d5d08008891001091091198008020018900089119191999ab9a3370ea002900011a80418029aba135573ca00646666ae68cdc3a801240044a01046a0526a605466ae712401035054310002b499264984d55cea80089baa001121223002003112200112001232323333573466e1cd55cea8012400046600c600e6ae854008dd69aba135744a00446a0466a604866ae71241035054310002549926135573ca00226ea80048848cc00400c00880048c8cccd5cd19b8735573aa002900011bae357426aae7940088d407cd4c080cd5ce24810350543100021499261375400224464646666ae68cdc3a800a40084a00e46666ae68cdc3a8012400446a014600c6ae84d55cf280211999ab9a3370ea00690001280511a8111a981199ab9c490103505431000244992649926135573aa00226ea8004484888c00c0104488800844888004480048c8cccd5cd19b8750014800880188cccd5cd19b8750024800080188d4068d4c06ccd5ce249035054310001c499264984d55ce9baa0011220021220012001232323232323333573466e1d4005200c200b23333573466e1d4009200a200d23333573466e1d400d200823300b375c6ae854014dd69aba135744a00a46666ae68cdc3a8022400c46601a6eb8d5d0a8039bae357426ae89401c8cccd5cd19b875005480108cc048c050d5d0a8049bae357426ae8940248cccd5cd19b875006480088c050c054d5d09aab9e500b23333573466e1d401d2000230133016357426aae7940308d407cd4c080cd5ce2481035054310002149926499264992649926135573aa00826aae79400c4d55cf280109aab9e500113754002424444444600e01044244444446600c012010424444444600a010244444440082444444400644244444446600401201044244444446600201201040024646464646666ae68cdc3a800a400446660106eb4d5d0a8021bad35742a0066eb4d5d09aba2500323333573466e1d400920002300a300b357426aae7940188d4040d4c044cd5ce2490350543100012499264984d55cea80189aba25001135573ca00226ea80048488c00800c888488ccc00401401000c80048c8c8cccd5cd19b875001480088c018dd71aba135573ca00646666ae68cdc3a80124000460106eb8d5d09aab9e500423500a35300b3357389201035054310000c499264984d55cea80089baa001212230020032122300100320011122232323333573466e1cd55cea80124000466aa016600c6ae854008c014d5d09aba25002235007353008335738921035054310000949926135573ca00226ea8004498480048004448848cc00400c008448004488800c488800848880048004488800c488800848880048004448c8c00400488cc00cc008008004c8c8cc88cc88c8ccc888c8c8c8c8c8ccc888ccc888ccc888c8cccc8888c8cc88c8cccc8888c8cc88c8cc88c8ccc888c8c8cc88c8c8cc88c8c8c8cccc8888c8c8c8c8c8cc88c8cc88cc88ccccccccccccc8888888888888c8c8c8c8c8cccccccc88888888cc88cc88cc88cc88c8ccccc88888c8cc88cc88cc88c8cc88cc88cc88c8cc88c8c8c8cccc8888cccc8888c8888d4d540400108888c8c8c94cd4c24004ccc0140280240205400454cd4c24004cd5ce249025331000910115001109101153353508101003215335309001333573466e1cccc109400cd4c07800488004c0580212002092010910115002153353090013357389201025332000910115002109101150011533535080013300533501b00833303e03f5001323355306012001235355096010012233550990100233553063120012353550990100122335509c0100233704900080080080099a809801180a003003909a9aa84a8080091911a9a80f00091299a984a0098050010a99a984a00999aa9837090009a835283491a9aa84d8080091199aa9838890009a836a83611a9aa84f0080091199ab9a3370e900000084e0084d808008008a8020a99a984a0099ab9c49102533300095011500410950113535501e00522253353097013333355027253335301400113374a90001bb14984cdd2a40046ec52613374a90021bb149800c008c8cd400541d141d4488cc008cd40ac01cccc124128018cd4078034c07c04400403c4264044cd5ce249025335000980113535501a0012225335309301333335502325301d00100300200100b109501133573892010253340009401133573892010253360008f0113530220052235302d002222222222253353508b013303000a00b2135303a0012235303e0012220021350a10135309d0133573892010253300009e01498cccd5403488d4d404c008894ccd4c02400c54ccd4c01400854ccd4c02400c541f04d41f4cd542400554034cd405801c004541f054ccd4c02400c4d41f4cd542400554034cd4058020004541f0541f0541f054ccd4c01400854ccd4c02400c541f04d41f4cd542400554034cd405801c004541f054ccd4c02400c4d41f4cd542400554034cd4058020004541f0541f0541f04d41f4cd542400554034cd4058019419894ccd4c008004421c04421c044220048882280541e0488800c488800848880048004488800c48880084888004800444ccd5401d416541654164494cd4d41b8004848cd4168cd5421404d4c03000888004cd4168cd54214040052002505b505b12505a235355081013530100012235301b00222222222225335350793301e00a00b213530280012235302c00122235303100322335308701002230930116253353508201004213355098010020011309301161308a01162200211222212333300100500400300211200120011122212333001004003002112001122123300100300212001221233001003002200111222225335307533355304f120013504b504a235300b002223301500200300415335307533355304f120013504b504a235300b002223530160022222222222353501500d22533530840133355305e120013505450562353025001223304b00200400c10860113357389201024c30000850100315335307533355304f120013504b504a235300b002223530160022222222222353501300d22533530840133355305e12001350545056235302700122253353507a00121533530890133305108501003006153353507b330623019007009213308501001002108a01108a011089015335350763301b00c00d2135302500122353029001222333553055120012235302e00222235303300822353035005225335309301333308401004003002001133506f0090081008506701113508c01353088013357389201024c6600089014984218044cd5ce2481024c3100085010021077150741507415074122123300100300212001122123300100300212001221233001003002200122533335300300121505f21505f21505f2133355304612001504a235300d001225335306f3303300200413506300315062003212222300400521222230030052122223002005212222300100520013200135506c22233333333333353019001235300500322222222225335307153353506333355304b12001504f253353072333573466e3c0300041d01cc4d41980045419400c841d041c841cc4cd5ce249024c340007222353006004222222222253353506453353506433355304c1200150502353550790012253353075333573466e3c00803c1dc1d84d41a400c541a000884d419cd4d541e40048800454194854cd4c1ccccd5cd19baf00100c0750741075150701506f235300500322222222225335307133355304b120013504150432333573466ebc0300041d01cccd54c108480048d4d541e00048800400841cc4cd5ce249024c320007222225335306a333573466e1cd4c0200188888888888ccc09801c0380300041b01ac41b04cd5ce2481024c390006b22235300700522222222225335307333355304d1200135043504523530160012225335350690012153353078333040074003010153353506a35301601422222222223305b01b0022153353079333573466e3c0040081ec1e84d4c07401488cccc1b0008004c1d005541b841e841e441e441e002441d44cd5ce249024c6200074225335306833303002f0013335530331200150175045353006004222222222233355303d120012235301600222235301b00322335307100225335307a333573466e3c0500041f01ec4cd415801401c401c801d413c02441a84cd5ce2481024c610006925335306733302f02e001353005003222222222233355304b12001501f235301400122200200910691335738921024c36000682533530673335530411200135037503923300500400100110691335738921024c640006825335306733302f02e001353005003222222222233355304b12001501f23530120012235301600122200200a106913357389201024c35000682353005003222222222253353506333355304b12001504f235301200122533530743303800200e1350680031506700a213530120012235301600122253353506900121507610791506f22353006004222222222253353506433355304c120015050235301300122533530753303900200f1350690031506800a2107513357389201024c380007323530050032222222222353503100b22353503500222353503500822353503900222533530793333333222222253335306d33350640070060031533530800100215335308001005133350610070010041081011333506100700100410810113335061007001004333333335064075225335307b333573466e1c0080041f41f041ac54cd4c1ecccd5cd19b8900200107d07c1069106a22333573466e200080041f41f010088ccd5cd19b8900200107c07d22333573466e200080041f01f4894cd4c1ecccd5cd19b8900200107d07c10011002225335307b333573466e240080041f41f04008400401801401c00800400c41ec4cd5ce249024c330007a222222222212333333333300100b00a009008007006005004003002200122123300100300220012221233300100400300220012212330010030022001212222222300700822122222223300600900821222222230050081222222200412222222003221222222233002009008221222222233001009008200113350325001502f13001002222335530241200123535505a00122335505d002335530271200123535505d001223355060002333535502500123300a4800000488cc02c0080048cc02800520000013301c00200122337000040024446464600200a640026aa0b64466a6a05e0029000111a9aa82e00111299a982c199ab9a3371e0040120b40b22600e0022600c006640026aa0b44466a6a05c0029000111a9aa82d80111299a982b999ab9a3371e00400e0b20b020022600c00642444444444444601801a4424444444444446601601c01a42444444444444601401a44442444444444444666601202001e01c01a444244444444444466601001e01c01a4424444444444446600e01c01a42444444444444600c01a42444444444444600a01a42444444444444600801a42444444444444600601a4424444444444446600401c01a42444444444444600201a400224424660020060042400224424660020060042400244a66a607c666ae68cdc79a9801801110011a98018009100102001f8999ab9a3370e6a6006004440026a60060024400208007e207e442466002006004400244666ae68cdc480100081e81e111199aa980a890009a808a80811a9aa82100091199aa980c090009a80a280991a9aa82280091199a9aa8068009198052400000244660160040024660140029000000998020010009119aa98050900091a9aa8200009119aa821801199a9aa804000919aa98070900091a9aa8220009119aa8238011aa80780080091199aaa80401c801000919aa98070900091a9aa8220009119aa8238011aa806800800999aaa80181a001000888911199aa980209000a80a99aa98050900091a9aa8200009119aa8218011aa805800999aa980209000911a9aa82080111299a981e999aa980b890009a806a80791a9aa82200091198050010028030801899a80c802001a80b00099aa98050900091a9aa820000911919aa8220019800802990009aa82291299a9a80c80089aa8058019109a9aa82300111299a982119806001004099aa80800380089803001801190009aa81f1108911299a9a80a800880111099802801199aa980389000802802000889091118018020891091119801002802089091118008020890008919a80891199a9a803001910010010009a9a80200091000990009aa81c110891299a9a8070008a80811099a808980200119aa980309000802000899a80111299a981800108190800817891091980080180109000899a80191299a9816801080088170168919a80591199a9a802001910010010009a9a8010009100089109198008018010900091299a9a80d999aa980189000a80391a9aa81800091299a9816199ab9a3375e00200a05c05a26a0400062a03e002426a03c6a6aa060002440042a038640026aa05e4422444a66a6a00c00226a6a01400644002442666a6a01800a440046008004666aa600e2400200a00800222440042442446600200800624002266a00444a66a6a02c004420062002a02a24424660020060042400224446a6a008004446a6a00c00644a666a6026666a01400e0080042a66a604c00620022050204e2050244246600200600424002244464646464a666a6a01000c42a666a6a01200c42a666a6a0140104260082c260062c2a666a6a01400e4260082c260062c202a20262a666a6a01200e4260082c260062c2a666a6a01200c4260082c260062c20282a666a6a01000a42024202620222a666a6a01000a42a666a6a01200e42600a2c260082c2a666a6a01200c42600a2c260082c202820242a666a6a01000c42600a2c260082c2a666a6a01000a42600a2c260082c20264a666a6a01000a42a666a6a01200e42a666a6a01400e42666a01e014004002260222c260222c260202c20262a666a6a01000c42a666a6a01200c42666a01c012004002260202c260202c2601e2c202420224a666a6a00e00842a666a6a01000c42a666a6a01200c42666a01c012004002260202c260202c2601e2c20242a666a6a00e00a42a666a6a01000a42666a01a0100040022601e2c2601e2c2601c2c202220204a666a6a00c00642a666a6a00e00a42a666a6a01000a42666a01a0100040022601e2c2601e2c2601c2c20222a666a6a00c00842a666a6a00e00842666a01800e0040022601c2c2601c2c2601a2c2020201e4a666a6a00a00442a666a6a00c00842a666a6a00e00842666a01800e0040022601c2c2601c2c2601a2c20202a666a6a00a00642a666a6a00c00642666a01600c0040022601a2c2601a2c260182c201e201c2424446006008224440042244400224002246a6a0040024444444400e244444444246666666600201201000e00c00a008006004240024c244400624440042444002400244446466a601800a466a601a0084a66a602c666ae68cdc780100080c00b8a801880b900b919a9806802100b9299a980b199ab9a3371e00400203002e2a006202e2a66a6a00a00642a66a6a00c0044266a6014004466a6016004466a601e004466a60200044660280040024034466a6020004403446602800400244403444466a601a0084034444a66a6036666ae68cdc380300180e80e0a99a980d999ab9a3370e00a00403a03826602e00800220382038202a2a66a6a00a0024202a202a2424460040062244002240024244600400644424466600200a00800640024244600400642446002006400244666ae68cdc780100080480411199ab9a3370e00400201000e266ae712401024c630000413357389201024c370000313357389201024c64000021220021220012001235006353002335738921024c6700003498480048004448848cc00400c008448004498448c8c00400488cc00cc0080080050482d87a80d87980f5f6" ] , inputs = - Write.utxoFromTxOutsInRecentEra + Write.unsafeUtxoFromTxOutsInRecentEra [ ( Write.unsafeMkTxIn tid 0 , TxOutInRecentEra (Write.unsafeAddressFromBytes $ unsafeFromHex $ mconcat From e84bff76aadbb60dd4093033bb9de688a2835ef8 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 21 Mar 2024 13:52:45 +0000 Subject: [PATCH 12/24] Fixes for `network-layer` package --- .../Network/Implementation/Ouroboros.hs | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/network-layer/src/Cardano/Wallet/Network/Implementation/Ouroboros.hs b/lib/network-layer/src/Cardano/Wallet/Network/Implementation/Ouroboros.hs index 48a42a6545b..115fefca1d6 100644 --- a/lib/network-layer/src/Cardano/Wallet/Network/Implementation/Ouroboros.hs +++ b/lib/network-layer/src/Cardano/Wallet/Network/Implementation/Ouroboros.hs @@ -151,6 +151,9 @@ import Ouroboros.Network.Protocol.LocalStateQuery.Client ( ClientStAcquiring (..) , LocalStateQueryClient (..) ) +import Ouroboros.Network.Protocol.LocalStateQuery.Type + ( Target (..) + ) import Ouroboros.Network.Protocol.LocalTxSubmission.Client ( LocalTxClientStIdle (..) , LocalTxSubmissionClient (..) @@ -180,15 +183,16 @@ chainSyncFollowTip -- ^ Callback for when the tip changes. -> ChainSyncClient block (Point block) (Tip block) m Void chainSyncFollowTip toCardanoEra onTipUpdate = - ChainSyncClient (clientStIdle False) + ChainSyncClient (pure $ clientStIdle False) where -- Client in the state 'Idle'. We immediately request the next block. clientStIdle :: Bool - -> m (ClientStIdle block (Point block) (Tip block) m Void) - clientStIdle synced = pure $ SendMsgRequestNext - (clientStNext synced) - (pure $ clientStNext synced) + -> ClientStIdle block (Point block) (Tip block) m Void + clientStIdle synced = + SendMsgRequestNext + (pure ()) + (clientStNext synced) -- In the CanAwait state, we take the tip point given by the node and -- ask for the intersection of that point. This fast-fowards us to the @@ -202,8 +206,9 @@ chainSyncFollowTip toCardanoEra onTipUpdate = , recvMsgRollForward = const findIntersect } where - findIntersect tip = ChainSyncClient $ - pure $ SendMsgFindIntersect [getTipPoint $ castTip tip] clientStIntersect + findIntersect tip = + ChainSyncClient . pure + $ SendMsgFindIntersect [getTipPoint $ castTip tip] clientStIntersect -- On tip update, we'll also propagate the era inferred from blocks we -- received. In case of rollback, we only have a 'Point' and they are @@ -221,7 +226,7 @@ chainSyncFollowTip toCardanoEra onTipUpdate = -> ChainSyncClient block (Point block) (Tip block) m Void doUpdate era tip = ChainSyncClient $ do onTipUpdate era (castTip tip) - clientStIdle True + pure $ clientStIdle True -- After an intersection is found, we return to idle with the sync flag -- set. @@ -229,9 +234,9 @@ chainSyncFollowTip toCardanoEra onTipUpdate = :: ClientStIntersect block (Point block) (Tip block) m Void clientStIntersect = ClientStIntersect { recvMsgIntersectFound = \_intersection _tip -> - ChainSyncClient $ clientStIdle True + ChainSyncClient . pure $ clientStIdle True , recvMsgIntersectNotFound = \_tip -> - ChainSyncClient $ clientStIdle False + ChainSyncClient . pure $ clientStIdle False } {----------------------------------------------------------------------------- @@ -279,7 +284,7 @@ chainSyncFetchNextBlock queue = clientRequestBlock :: point -> ClientStIdle block point tip m Void clientRequestBlock point = - SendMsgRequestNext (clientStNext point) (pure $ clientStNext point) + SendMsgRequestNext (pure ()) (clientStNext point) -- Fetch the block on rollforward. clientStNext @@ -504,9 +509,10 @@ chainSyncWithBlocks tr pipeliningStrategy chainFollower = -- Simple strategy that sends a request and waits for an answer. oneByOne :: RequestNextStrategy m 'Z block - oneByOne = P.SendMsgRequestNext - (collectResponses [] Zero) - (pure $ collectResponses [] Zero) + oneByOne = + P.SendMsgRequestNext + (pure ()) + (collectResponses [] Zero) -- We only pipeline requests when we are far from the tip. As soon as we -- reach the tip however, there's no point pipelining anymore, so we start @@ -522,7 +528,7 @@ chainSyncWithBlocks tr pipeliningStrategy chainFollower = pipeline goal (Succ n) | natToInt (Succ n) == goal = P.CollectResponse Nothing $ collectResponses [] n pipeline goal n = - P.SendMsgRequestNextPipelined $ pipeline goal (Succ n) + P.SendMsgRequestNextPipelined (pure ()) $ pipeline goal (Succ n) collectResponses :: [block] @@ -678,7 +684,7 @@ localStateQuery queue = clientStIdle :: m (LSQ.ClientStIdle block (Point block) (Query block) m Void) clientStIdle = - LSQ.SendMsgAcquire Nothing . clientStAcquiring <$> awaitNextCmd + LSQ.SendMsgAcquire VolatileTip . clientStAcquiring <$> awaitNextCmd clientStAcquiring :: LocalStateQueryCmd block m @@ -686,7 +692,7 @@ localStateQuery queue = clientStAcquiring qry = LSQ.ClientStAcquiring { recvMsgAcquired = clientStAcquired qry , recvMsgFailure = \_failure -> do - pure $ LSQ.SendMsgAcquire Nothing (clientStAcquiring qry) + pure $ LSQ.SendMsgAcquire VolatileTip (clientStAcquiring qry) } clientStAcquired From 9c76fb185386ea2603b80269acce9ca9d99b55a4 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 21 Mar 2024 15:13:18 +0000 Subject: [PATCH 13/24] Fixes for the `wallet` package --- lib/unit/cardano-wallet-unit.cabal | 1 + .../Cardano/Wallet/DummyTarget/Primitive/Types.hs | 5 +++-- lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/unit/cardano-wallet-unit.cabal b/lib/unit/cardano-wallet-unit.cabal index 601ffd00504..0985042420c 100644 --- a/lib/unit/cardano-wallet-unit.cabal +++ b/lib/unit/cardano-wallet-unit.cabal @@ -77,6 +77,7 @@ test-suite unit , cardano-balance-tx:{cardano-balance-tx, internal} , cardano-crypto , cardano-crypto-class + , cardano-ledger-core , cardano-ledger-alonzo , cardano-ledger-babbage , cardano-ledger-core diff --git a/lib/unit/test-common/Cardano/Wallet/DummyTarget/Primitive/Types.hs b/lib/unit/test-common/Cardano/Wallet/DummyTarget/Primitive/Types.hs index 252403def06..517d07a9410 100644 --- a/lib/unit/test-common/Cardano/Wallet/DummyTarget/Primitive/Types.hs +++ b/lib/unit/test-common/Cardano/Wallet/DummyTarget/Primitive/Types.hs @@ -96,6 +96,7 @@ import GHC.Stack ( HasCallStack ) +import qualified Cardano.Api.Ledger as C import qualified Cardano.Api.Shelley as C import qualified Data.ByteString.Char8 as B8 @@ -183,7 +184,7 @@ dummyNodeProtocolParameters = C.ProtocolParameters , C.protocolParamStakeAddressDeposit = C.Lovelace 0 , C.protocolParamStakePoolDeposit = C.Lovelace 500_000_000 , C.protocolParamMinPoolCost = C.Lovelace 340_000_000 - , C.protocolParamPoolRetireMaxEpoch = C.EpochNo 18 + , C.protocolParamPoolRetireMaxEpoch = C.EpochInterval 18 , C.protocolParamStakePoolTargetNum = 100 , C.protocolParamPoolPledgeInfluence = 0.3 -- a0 , C.protocolParamMonetaryExpansion = 0.003 -- rho @@ -288,7 +289,7 @@ babbageMainnetProtocolParameters = C.ProtocolParameters , C.protocolParamStakeAddressDeposit = C.Lovelace 2_000_000 , C.protocolParamStakePoolDeposit = C.Lovelace 500_000_000 , C.protocolParamMinPoolCost = C.Lovelace 340_000_000 - , C.protocolParamPoolRetireMaxEpoch = C.EpochNo 18 + , C.protocolParamPoolRetireMaxEpoch = C.EpochInterval 18 , C.protocolParamStakePoolTargetNum = 500 , C.protocolParamPoolPledgeInfluence = 0.3 -- a0 , C.protocolParamMonetaryExpansion = 0.003 -- rho diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs index 3a669acf17d..79c144f54c1 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs @@ -220,6 +220,9 @@ import Data.Generics.Internal.VL.Lens ) import Data.Generics.Labels () +import Data.IntCast + ( intCast + ) import Data.Map.Strict ( Map ) @@ -1215,7 +1218,7 @@ txConstraints protocolParams witnessTag = TxConstraints _txRewardWithdrawalSize (Right witnessTag) txMaximumSize = - TxSize $ protocolParams ^. Ledger.ppMaxTxSizeL + TxSize $ intCast $ protocolParams ^. Ledger.ppMaxTxSizeL empty :: TxSkeleton empty = TxSkeleton From 1c990aaf45851a3e23bc50c9e55723581fd93278 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 21 Mar 2024 16:58:38 +0000 Subject: [PATCH 14/24] Fixes for `cardano-wallet-api` package --- lib/api/cardano-wallet-api.cabal | 5 +- .../Cardano/Wallet/Api/Http/Server/Error.hs | 154 ++++------------ .../Api/Http/Server/Error/AssignReedemers.hs | 168 ++++++++++++++++++ .../Api/Http/Server/Error/IsServerError.hs | 85 +++++++++ .../Cardano/Wallet/Api/Http/Shelley/Server.hs | 14 +- lib/api/src/Cardano/Wallet/Api/Types/Error.hs | 3 + 6 files changed, 298 insertions(+), 131 deletions(-) create mode 100644 lib/api/src/Cardano/Wallet/Api/Http/Server/Error/AssignReedemers.hs create mode 100644 lib/api/src/Cardano/Wallet/Api/Http/Server/Error/IsServerError.hs diff --git a/lib/api/cardano-wallet-api.cabal b/lib/api/cardano-wallet-api.cabal index 93955cbd0f7..2e410f2c20f 100644 --- a/lib/api/cardano-wallet-api.cabal +++ b/lib/api/cardano-wallet-api.cabal @@ -40,7 +40,6 @@ flag release library import: language, opts-lib - visibility: public hs-source-dirs: src build-depends: , address-derivation-discovery @@ -59,6 +58,8 @@ library , cardano-binary , cardano-crypto , cardano-ledger-alonzo + , cardano-ledger-babbage + , cardano-ledger-conway , cardano-ledger-core , cardano-wallet , cardano-wallet-launcher @@ -129,6 +130,8 @@ library Cardano.Wallet.Api.Http.Logging Cardano.Wallet.Api.Http.Server Cardano.Wallet.Api.Http.Server.Error + Cardano.Wallet.Api.Http.Server.Error.AssignReedemers + Cardano.Wallet.Api.Http.Server.Error.IsServerError Cardano.Wallet.Api.Http.Server.Handlers.MintBurn Cardano.Wallet.Api.Http.Server.Handlers.TxCBOR Cardano.Wallet.Api.Http.Server.Tls diff --git a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs index d0a6bee072d..bbc64100bb1 100644 --- a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error.hs @@ -1,11 +1,15 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UndecidableInstances #-} +{-# OPTIONS_GHC -Wno-orphans #-} -- | -- Copyright: © 2018-2022 IOHK, 2023 Cardano Foundation @@ -29,9 +33,6 @@ import Prelude import Cardano.Address.Script ( Cosigner (..) ) -import Cardano.Ledger.Alonzo.Plutus.TxInfo - ( TranslationError (..) - ) import Cardano.Wallet ( ErrAddCosignerKey (..) , ErrCannotJoin (..) @@ -86,6 +87,17 @@ import Cardano.Wallet.Address.Discovery.Shared import Cardano.Wallet.Api.Hex ( hexText ) +import Cardano.Wallet.Api.Http.Server.Error.AssignReedemers + () +import Cardano.Wallet.Api.Http.Server.Error.IsServerError + ( IsServerError (..) + , apiError + , err425 + , handler + , liftE + , liftHandler + , showT + ) import Cardano.Wallet.Api.Types ( ApiCosignerIndex (..) , ApiCredentialType (..) @@ -93,10 +105,8 @@ import Cardano.Wallet.Api.Types , toApiEra ) import Cardano.Wallet.Api.Types.Error - ( ApiError (..) - , ApiErrorBalanceTxUnderestimatedFee (..) + ( ApiErrorBalanceTxUnderestimatedFee (..) , ApiErrorInfo (..) - , ApiErrorMessage (..) , ApiErrorNodeNotYetInRecentEra (..) , ApiErrorNotEnoughMoney (..) , ApiErrorNotEnoughMoneyShortfall (..) @@ -126,16 +136,6 @@ import Cardano.Write.Tx , ErrBalanceTxOutputError (..) , ErrBalanceTxOutputErrorInfo (..) ) -import Control.Monad.Except - ( ExceptT - , withExceptT - ) -import Control.Monad.IO.Class - ( liftIO - ) -import Control.Monad.Trans.Except - ( throwE - ) import Data.Generics.Internal.VL ( view , (^.) @@ -152,9 +152,6 @@ import Data.List import Data.Maybe ( isJust ) -import Data.Text - ( Text - ) import Data.Text.Class ( ToText (..) ) @@ -168,29 +165,15 @@ import Fmt , listF , pretty ) -import Internal.Cardano.Write.Tx.Sign - ( KeyWitnessCounts (..) - ) -import Network.HTTP.Media - ( renderHeader - ) -import Network.HTTP.Types - ( hContentType - ) +import Internal.Cardano.Write.Tx import Network.Wai ( Request (pathInfo) ) import Safe ( fromJustNote ) -import Servant - ( Accept (contentType) - , JSON - , Proxy (Proxy) - ) import Servant.Server - ( Handler (Handler) - , ServerError (..) + ( ServerError (..) , err400 , err403 , err404 @@ -218,44 +201,11 @@ import qualified Internal.Cardano.Write.Tx as Write , serializeTx , toAnyCardanoEra ) +import qualified Internal.Cardano.Write.Tx as WriteTx import qualified Internal.Cardano.Write.Tx.Balance as Write ( toWalletUTxO ) --- | Maps types to servant error responses. -class IsServerError e where - -- | A structured human-readable error code to return to API clients. - toServerError :: e -> ServerError - --- | Lift our wallet layer into servant 'Handler', by mapping each error to a --- corresponding servant error. -liftHandler :: IsServerError e => ExceptT e IO a -> Handler a -liftHandler action = Handler (withExceptT toServerError action) - -liftE :: IsServerError e => e -> Handler a -liftE = liftHandler . throwE - --- | Lift an IO action into servant 'Handler' -handler :: IO a -> Handler a -handler = Handler . liftIO - -apiError :: ServerError -> ApiErrorInfo -> Text -> ServerError -apiError err info messageUnformatted = err - { errBody = Aeson.encode ApiError {info, message} - , errHeaders = - (hContentType, renderHeader $ contentType $ Proxy @JSON) - : errHeaders err - } - where - message = ApiErrorMessage (T.replace "\n" " " messageUnformatted) - -err425 :: ServerError -err425 = ServerError 425 "Too early" "" [] - --- | Small helper to easy show things to Text -showT :: Show a => a -> Text -showT = T.pack . show - instance IsServerError WalletException where toServerError = \case ExceptionNoSuchWallet e -> toServerError e @@ -543,7 +493,8 @@ instance IsServerError ErrWriteTxEra where , "compatible with a recent era." ] -instance Write.IsRecentEra era => IsServerError (ErrBalanceTx era) where +instance (Write.IsRecentEra era, IsServerError (ErrAssignRedeemers era)) + => IsServerError (ErrBalanceTx era) where toServerError = \case ErrBalanceTxExistingKeyWitnesses n -> apiError err403 BalanceTxExistingKeyWitnesses $ mconcat @@ -633,15 +584,15 @@ instance Write.IsRecentEra era => IsServerError (ErrBalanceTxInternalError era) where toServerError = \case - ErrUnderestimatedFee coin candidateTx keyWitnessCounts -> + ErrUnderestimatedFee coin' candidateTx keyWitnessCounts -> apiError err500 (BalanceTxUnderestimatedFee info) $ T.unwords [ "I have somehow underestimated the fee of the transaction by" - , pretty (toWalletCoin coin), "and cannot finish balancing." + , pretty (toWalletCoin coin'), "and cannot finish balancing." ] where KeyWitnessCounts nWits nBootWits = keyWitnessCounts info = ApiErrorBalanceTxUnderestimatedFee - { underestimation = ApiAmount.fromCoin $ toWalletCoin coin + { underestimation = ApiAmount.fromCoin $ toWalletCoin coin' , candidateTxHex = hexText $ Write.serializeTx @era candidateTx , candidateTxReadable = T.pack (show candidateTx) , estimatedNumberOfKeyWits = intCast nWits @@ -1080,57 +1031,6 @@ instance IsServerError (ErrInvalidDerivationIndex 'Hardened level) where , "between 0H and ", pretty (Index $ maxIx - minIx), "H." ] -instance IsServerError ErrAssignRedeemers where - toServerError = \case - ErrAssignRedeemersScriptFailure r failure -> - apiError err400 RedeemerScriptFailure $ T.unwords - [ "I was unable to assign execution units to one of your" - , "redeemers:", pretty r <> ";" - , "Its execution is failing with the following error:" - , T.pack failure <> "." - ] - ErrAssignRedeemersTargetNotFound r -> - apiError err400 RedeemerTargetNotFound $ T.unwords - [ "I was unable to resolve one of your redeemers to the location" - , "indicated in the request payload:", pretty r <> ";" - , "Please double-check both your serialised transaction and" - , "the provided redeemers." - ] - ErrAssignRedeemersInvalidData r _ -> - apiError err400 RedeemerInvalidData $ T.unwords - [ "It looks like you have provided an invalid 'data' payload" - , "for one of your redeemers since I am unable to decode it" - , "into a valid Plutus data:", pretty r <> "." - ] - ErrAssignRedeemersTranslationError (TranslationLogicMissingInput inp) -> - -- Note that although this error is thrown from - -- '_assignScriptRedeemers', it's more related to balanceTransaction - -- in general than to assigning redeemers. Hence we don't mention - -- redeemers in the message. - 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 - ] - ErrAssignRedeemersTranslationError (TimeTranslationPastHorizon t) -> - -- We differentiate this from @TranslationError@ for partial API - -- backwards compatibility. - 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 - ] - ErrAssignRedeemersTranslationError e -> - apiError err400 TranslationError $ T.unwords - [ "The transaction I was given contains bits that cannot be" - , "translated in the current era. The following is wrong:\n\n" - , showT e - ] - instance IsServerError (Request, ServerError) where toServerError (req, err@(ServerError code _ body _)) | not (isJSON body) = case code of @@ -1188,3 +1088,9 @@ instance IsServerError (Request, ServerError) where where utf8 = T.replace "\"" "'" . T.decodeUtf8 . BL.toStrict isJSON = isJust . Aeson.decode @Aeson.Value + +instance IsServerError WriteTx.ErrInvalidTxOutInEra where + toServerError = \case + WriteTx.InlinePlutusV3ScriptNotSupportedInBabbage -> + apiError err400 BalanceTxInlinePlutusV3ScriptNotSupportedInBabbage + "Plutus V3 scripts are not supported in the Babbage era." 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 new file mode 100644 index 00000000000..5afb48bbe64 --- /dev/null +++ b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/AssignReedemers.hs @@ -0,0 +1,168 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE FlexibleInstances #-} +{-# 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 + ) +import Cardano.Wallet.Api.Types.Error + ( ApiErrorInfo (..) + ) +import Fmt + ( pretty + ) +import Internal.Cardano.Write.Tx + ( IsRecentEra (..) + , RecentEra (RecentEraBabbage, RecentEraConway) + ) +import Internal.Cardano.Write.Tx.Balance + ( ErrAssignRedeemers (..) + ) +import Servant.Server + ( ServerError + , err400 + ) + +import qualified Data.Text as T + +instance IsRecentEra era => IsServerError (ErrAssignRedeemers era) where + toServerError = \case + ErrAssignRedeemersScriptFailure r failure -> + apiError err400 RedeemerScriptFailure + $ T.unwords + [ "I was unable to assign execution units to one of your" + , "redeemers:" + , pretty r <> ";" + , "Its execution is failing with the following error:" + , T.pack failure <> "." + ] + ErrAssignRedeemersTargetNotFound r -> + apiError err400 RedeemerTargetNotFound + $ T.unwords + [ "I was unable to resolve one of your redeemers to the location" + , "indicated in the request payload:" + , pretty r <> ";" + , "Please double-check both your serialised transaction and" + , "the provided redeemers." + ] + ErrAssignRedeemersInvalidData r _ -> + apiError err400 RedeemerInvalidData + $ T.unwords + [ "It looks like you have provided an invalid 'data' payload" + , "for one of your redeemers since I am unable to decode it" + , "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 + ] diff --git a/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/IsServerError.hs b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/IsServerError.hs new file mode 100644 index 00000000000..cedd41b0269 --- /dev/null +++ b/lib/api/src/Cardano/Wallet/Api/Http/Server/Error/IsServerError.hs @@ -0,0 +1,85 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE TypeApplications #-} + +module Cardano.Wallet.Api.Http.Server.Error.IsServerError + ( IsServerError (..) + , liftHandler + , liftE + , handler + , apiError + , err425 + , showT + ) + where + +import Prelude + +import Cardano.Wallet.Api.Types.Error + ( ApiError (..) + , ApiErrorInfo + , ApiErrorMessage (ApiErrorMessage) + ) +import Control.Monad.Except + ( ExceptT + ) +import Control.Monad.IO.Class + ( liftIO + ) +import Control.Monad.Trans.Except + ( throwE + , withExceptT + ) +import Data.Text + ( Text + ) +import Network.HTTP.Media + ( RenderHeader (..) + ) +import Network.HTTP.Types + ( hContentType + ) +import Servant + ( Accept (..) + , Handler (..) + , JSON + , Proxy (..) + , ServerError (..) + ) + +import qualified Data.Aeson as Aeson +import qualified Data.Text as T + +-- | Maps types to servant error responses. +class IsServerError e where + -- | A structured human-readable error code to return to API clients. + toServerError :: e -> ServerError + +-- | Lift our wallet layer into servant 'Handler', by mapping each error to a +-- corresponding servant error. +liftHandler :: IsServerError e => ExceptT e IO a -> Handler a +liftHandler action = Handler (withExceptT toServerError action) + +liftE :: IsServerError e => e -> Handler a +liftE = liftHandler . throwE + +-- | Lift an IO action into servant 'Handler' +handler :: IO a -> Handler a +handler = Handler . liftIO + +apiError :: ServerError -> ApiErrorInfo -> Text -> ServerError +apiError err info messageUnformatted = + err + { errBody = Aeson.encode ApiError{info, message} + , errHeaders = + (hContentType, renderHeader $ contentType $ Proxy @JSON) + : errHeaders err + } + where + message = ApiErrorMessage (T.replace "\n" " " messageUnformatted) + +err425 :: ServerError +err425 = ServerError 425 "Too early" "" [] + +-- | Small helper to easy show things to Text +showT :: Show a => a -> Text +showT = T.pack . show diff --git a/lib/api/src/Cardano/Wallet/Api/Http/Shelley/Server.hs b/lib/api/src/Cardano/Wallet/Api/Http/Shelley/Server.hs index 1063ab82c33..ecd9cc0f877 100644 --- a/lib/api/src/Cardano/Wallet/Api/Http/Shelley/Server.hs +++ b/lib/api/src/Cardano/Wallet/Api/Http/Shelley/Server.hs @@ -3569,7 +3569,7 @@ balanceTransaction => Write.RecentEra era -> Handler (Write.PartialTx era) parsePartialTx era = do - let externalUTxO + let mExternalUTxO = Write.utxoFromTxOutsInRecentEra $ map fromExternalInput $ body ^. #inputs @@ -3584,11 +3584,13 @@ balanceTransaction . getApiT $ body ^. #transaction - pure $ Write.PartialTx - (Write.fromCardanoApiTx tx) - externalUTxO - (fromApiRedeemer <$> body ^. #redeemers) - timelockKeyWitnessCounts + case mExternalUTxO of + Right externalUTxO -> pure $ Write.PartialTx + (Write.fromCardanoApiTx tx) + externalUTxO + (fromApiRedeemer <$> body ^. #redeemers) + timelockKeyWitnessCounts + Left e -> liftHandler $ throwE e decodeTransaction :: forall s n diff --git a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs index 685111ade59..c9c41ac91b9 100644 --- a/lib/api/src/Cardano/Wallet/Api/Types/Error.hs +++ b/lib/api/src/Cardano/Wallet/Api/Types/Error.hs @@ -206,6 +206,9 @@ data ApiErrorInfo | WithdrawalNotPossibleWithoutVote | WrongMnemonic | BlockHeaderNotFound + | TranslationByronTxOutInContext + | BalanceTxInlinePlutusV3ScriptNotSupportedInBabbage + deriving (Eq, Generic, Show, Data, Typeable) deriving anyclass NFData From 1d7a152200ce0457d558203573739e082e987e25 Mon Sep 17 00:00:00 2001 From: paolino Date: Fri, 22 Mar 2024 16:00:54 +0000 Subject: [PATCH 15/24] Fixes for `cardano-wallet-unit` --- justfile | 2 +- .../test/unit/Cardano/Wallet/DB/LayerSpec.hs | 15 +- .../unit/Cardano/Wallet/DB/StateMachine.hs | 184 ++++++++---------- .../Wallet/Shelley/CompatibilitySpec.hs | 2 +- .../Cardano/Wallet/Shelley/TransactionSpec.hs | 3 +- 5 files changed, 89 insertions(+), 117 deletions(-) diff --git a/justfile b/justfile index 395ed1afc44..80131c6fed4 100644 --- a/justfile +++ b/justfile @@ -12,7 +12,7 @@ hlint: # build wallet build: - cabal build all --enable-benchmarks --enable-tests -O0 -v0 --ghc-options="-Werror" + cabal build all --enable-benchmarks --enable-tests --minimize-conflict-set -O0 -v0 --ghc-options="-Werror " # build after clean clean-build: diff --git a/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs b/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs index 96ffbdfbb10..59f10b19bb0 100644 --- a/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs @@ -20,6 +20,8 @@ {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE StandaloneDeriving #-} -- | -- Copyright: © 2018-2020 IOHK @@ -291,7 +293,8 @@ import Data.Time.Clock.POSIX ( posixSecondsToUTCTime ) import Data.Typeable - ( Typeable + ( Proxy (..) + , Typeable , typeOf ) import Data.Word @@ -434,8 +437,8 @@ stateMachineSpec , Typeable s , WalletFlavor s ) - => Spec -stateMachineSpec = describe ("State machine test (" ++ showState @s ++ ")") $ do + => Proxy s -> Spec +stateMachineSpec _ = describe ("State machine test (" ++ showState @s ++ ")") $ do validateGenerators @s it "Sequential" $ prop_sequential @s boot where @@ -450,11 +453,11 @@ stateMachineSpec = describe ("State machine test (" ++ showState @s ++ ")") $ do stateMachineSpecSeq, stateMachineSpecRnd, stateMachineSpecShared :: Spec stateMachineSpecSeq = - stateMachineSpec @TestState + stateMachineSpec (Proxy @TestState) stateMachineSpecRnd = - stateMachineSpec @(RndState 'Mainnet) + stateMachineSpec (Proxy @(RndState 'Mainnet)) stateMachineSpecShared = - stateMachineSpec @(SharedState 'Mainnet SharedKey) + stateMachineSpec (Proxy @(SharedState 'Mainnet SharedKey)) instance PaymentAddress SharedKey 'CredFromScriptK where paymentAddress _ = error diff --git a/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs b/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs index 2c7b77448f1..acbe9613366 100644 --- a/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs +++ b/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs @@ -8,7 +8,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} -{-# LANGUAGE KindSignatures #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE RankNTypes #-} @@ -17,6 +16,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} @@ -47,6 +47,7 @@ module Cardano.Wallet.DB.StateMachine ( prop_sequential , validateGenerators , TestConstraints + , Model ) where import Prelude @@ -128,6 +129,10 @@ import Cardano.Wallet.Primitive.Model import Cardano.Wallet.Primitive.NetworkId ( NetworkDiscriminant (..) ) +import Cardano.Wallet.Primitive.Passphrase + ( PassphraseScheme + , WalletPassphraseInfo + ) import Cardano.Wallet.Primitive.Types ( BlockHeader (..) , ChainPoint @@ -141,10 +146,12 @@ import Cardano.Wallet.Primitive.Types , SlotNo (..) , SortOrder (..) , StakeKeyCertificate + , StartTime , TokenBundleMaxSize , TxParameters (..) , WalletId (..) , WalletMetadata (..) + , WalletName ) import Cardano.Wallet.Primitive.Types.Address ( Address @@ -279,11 +286,6 @@ import Data.Time.Clock , diffUTCTime , getCurrentTime ) -import Data.TreeDiff - ( ToExpr (..) - , defaultExprViaShow - , genericToExpr - ) import Fmt ( Buildable ) @@ -332,6 +334,13 @@ import Test.StateMachine , runCommands , (.==) ) +import Test.StateMachine.Diffing + ( CanDiff + ) +import Test.StateMachine.TreeDiff + ( ToExpr (toExpr) + , defaultExprViaShow + ) import Test.StateMachine.Types ( Commands (..) ) @@ -354,8 +363,6 @@ import qualified Data.ByteString.Char8 as B8 import qualified Data.List as L import qualified Data.Map as Map import qualified Data.Set as Set -import qualified Data.TreeDiff as Expr -import qualified Data.TreeDiff.OMap as Expr import qualified Test.QuickCheck as QC import qualified Test.StateMachine.Types as QSM import qualified Test.StateMachine.Types.Rank2 as Rank2 @@ -754,58 +761,44 @@ instance Traversable t => Rank2.Traversable (At t) where -> f (QSM.Reference x r') lift f (QSM.Reference x) = QSM.Reference <$> f x -deriving instance ToExpr s => ToExpr (Model s Concrete) +deriving instance ToExpr SlotNo -instance ToExpr s => ToExpr (Mock s) where - toExpr = genericToExpr +deriving instance ToExpr s => ToExpr (Mock s) instance ToExpr WalletId where toExpr = defaultExprViaShow -instance ToExpr s => ToExpr (Wallet s) where - toExpr = genericToExpr +deriving instance ToExpr s => ToExpr (Wallet s) -instance ToExpr BlockHeader where - toExpr = genericToExpr +deriving instance ToExpr BlockHeader -instance ToExpr (Hash purpose) where - toExpr = genericToExpr +deriving instance ToExpr (Hash purpose) -instance ToExpr b => ToExpr (Quantity a b) where - toExpr = genericToExpr +deriving instance ToExpr b => ToExpr (Quantity a b) -instance ToExpr GenesisParameters where - toExpr = defaultExprViaShow +deriving instance ToExpr GenesisParameters + +deriving instance ToExpr StartTime instance ToExpr EpochNo where toExpr = defaultExprViaShow -instance ToExpr TxStatus where - toExpr = genericToExpr +deriving instance ToExpr TxStatus -instance ToExpr DRepKeyHash where - toExpr = genericToExpr +deriving instance ToExpr DRepKeyHash -instance ToExpr DRepScriptHash where - toExpr = genericToExpr +deriving instance ToExpr DRepScriptHash -instance ToExpr DRepID where - toExpr = genericToExpr +deriving instance ToExpr DRepID -instance ToExpr DRep where - toExpr = genericToExpr +deriving instance ToExpr DRep -instance ToExpr PoolId where - toExpr = defaultExprViaShow +deriving instance ToExpr PoolId -instance ToExpr AddressState where - toExpr = genericToExpr +deriving instance ToExpr AddressState -instance (ToExpr addr, ToExpr ix) => ToExpr (AddressPool.Pool addr ix) where - toExpr pool = Expr.Rec "Pool" $ Expr.fromList - [ ("gap", toExpr $ AddressPool.gap pool) - , ("addresses", toExpr $ AddressPool.addresses pool) - ] +instance (ToExpr addr, ToExpr ix, Show addr, Show ix) => ToExpr (AddressPool.Pool addr ix) where + toExpr = defaultExprViaShow instance ToExpr DerivationPrefix where toExpr = defaultExprViaShow @@ -819,14 +812,11 @@ instance ToExpr (SeqState 'Mainnet ShelleyKey) where instance ToExpr (RndState 'Mainnet) where toExpr = defaultExprViaShow -instance ToExpr a => ToExpr (Readiness a) where - toExpr = genericToExpr +deriving instance ToExpr a => ToExpr (Readiness a) -instance ToExpr AddressPoolGap where - toExpr = genericToExpr +deriving instance ToExpr AddressPoolGap -instance ToExpr ChangeAddressMode where - toExpr = genericToExpr +deriving instance ToExpr ChangeAddressMode instance ToExpr ScriptTemplate where toExpr = defaultExprViaShow @@ -837,110 +827,88 @@ instance ToExpr (SharedKey 'AccountK CC.XPub) where instance ToExpr (KeyFingerprint "payment" SharedKey) where toExpr = defaultExprViaShow -instance ToExpr (PendingIxs 'CredFromScriptK) where - toExpr = genericToExpr +deriving instance ToExpr (PendingIxs 'CredFromScriptK) -instance ToExpr (SharedAddressPool 'UtxoExternal SharedKey) where - toExpr = genericToExpr +deriving instance ToExpr (SharedAddressPool 'UtxoExternal SharedKey) -instance ToExpr (SharedAddressPool 'UtxoInternal SharedKey) where - toExpr = genericToExpr +deriving instance ToExpr (SharedAddressPool 'UtxoInternal SharedKey) -instance ToExpr (SharedAddressPools SharedKey) where - toExpr = genericToExpr +deriving instance ToExpr (SharedAddressPools SharedKey) -instance ToExpr (SharedState 'Mainnet SharedKey) where - toExpr = genericToExpr +deriving instance ToExpr (SharedState 'Mainnet SharedKey) -instance (ToExpr s, ToExpr xprv) => ToExpr (WalletDatabase s xprv) where - toExpr = genericToExpr +instance (ToExpr s, ToExpr xprv) => ToExpr (WalletDatabase s xprv) -instance ToExpr UTxO where - toExpr = genericToExpr +deriving instance ToExpr UTxO -instance ToExpr WalletMetadata where - toExpr = defaultExprViaShow +deriving instance ToExpr WalletMetadata + +deriving instance ToExpr WalletName + +deriving instance ToExpr WalletPassphraseInfo + +deriving instance ToExpr PassphraseScheme instance ToExpr TxCBOR where toExpr = toExpr . fst . build eraValueSerialize -instance ToExpr Tx where - toExpr = genericToExpr +deriving instance ToExpr Tx -instance ToExpr TxScriptValidity where - toExpr = genericToExpr +deriving instance ToExpr TxScriptValidity -instance ToExpr TxIn where - toExpr = genericToExpr +deriving instance ToExpr TxIn instance ToExpr TxMetadata where toExpr = defaultExprViaShow -instance ToExpr Coin where - toExpr = genericToExpr +deriving instance ToExpr Coin -instance ToExpr TxOut where - toExpr = genericToExpr +deriving instance ToExpr TxOut -instance ToExpr TokenBundle where - toExpr = genericToExpr +deriving instance ToExpr TokenBundle instance ToExpr TokenMap where - toExpr = genericToExpr . TokenMap.toNestedList + toExpr = toExpr . TokenMap.toNestedList -instance ToExpr AssetName where - toExpr = genericToExpr +deriving instance ToExpr AssetName -instance ToExpr TokenPolicyId where - toExpr = genericToExpr +deriving instance ToExpr TokenPolicyId -instance ToExpr TokenQuantity where - toExpr = genericToExpr +deriving instance ToExpr TokenQuantity -instance ToExpr Address where - toExpr = genericToExpr +deriving instance ToExpr Address -instance ToExpr TxMeta where - toExpr = genericToExpr +deriving instance ToExpr TxMeta instance ToExpr SealedTx where toExpr = defaultExprViaShow -instance ToExpr Percentage where - toExpr = genericToExpr +deriving instance ToExpr Percentage -instance ToExpr DecentralizationLevel where - toExpr = genericToExpr +deriving instance ToExpr DecentralizationLevel -instance ToExpr TxSize where - toExpr = genericToExpr +deriving instance ToExpr TxSize -instance ToExpr TokenBundleMaxSize where - toExpr = genericToExpr +deriving instance ToExpr TokenBundleMaxSize -instance ToExpr TxParameters where - toExpr = genericToExpr +deriving instance ToExpr TxParameters -instance ToExpr ExecutionUnits where - toExpr = genericToExpr +deriving instance ToExpr ExecutionUnits -instance ToExpr a => ToExpr (LinearFunction a) where - toExpr = genericToExpr +deriving instance ToExpr a => ToExpr (LinearFunction a) -instance ToExpr FeePolicy where - toExpr = genericToExpr +deriving instance ToExpr FeePolicy -instance ToExpr Direction where - toExpr = genericToExpr +deriving instance ToExpr Direction + +deriving instance ToExpr s => ToExpr (Model s Concrete) instance ToExpr MWid where toExpr = defaultExprViaShow -instance ToExpr StakeKeyCertificate where - toExpr = genericToExpr +deriving instance ToExpr StakeKeyCertificate -instance ToExpr RewardAccount where - toExpr = genericToExpr +deriving instance ToExpr RewardAccount {------------------------------------------------------------------------------- Tagging @@ -1079,7 +1047,7 @@ genDBParams = prop_sequential :: forall s - . TestConstraints s + . (CanDiff (Model s Concrete), TestConstraints s) => (WalletId -> DBLayerParams s -> (IO (IO (),DBLayer IO s))) -> Property prop_sequential newDB = diff --git a/lib/unit/test/unit/Cardano/Wallet/Shelley/CompatibilitySpec.hs b/lib/unit/test/unit/Cardano/Wallet/Shelley/CompatibilitySpec.hs index c3f500d085e..43d02078801 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Shelley/CompatibilitySpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Shelley/CompatibilitySpec.hs @@ -141,7 +141,7 @@ spec = do prop "(Mainnet) can be deserialised by shelley ledger spec" $ \k -> do let Address addr = paymentAddress @ShelleyKey @'CredFromKeyK SMainnet k - case SL.deserialiseAddr @StandardCrypto addr of + case SL.decodeAddr @StandardCrypto addr of Just _ -> property True Nothing -> property False diff --git a/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs index d6042405b29..65ad210ab47 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs @@ -339,6 +339,7 @@ import Test.Utils.Pretty import qualified Cardano.Api as Cardano import qualified Cardano.Api.Error as Cardano +import qualified Cardano.Api.Ledger as L import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Crypto.Hash.Blake2b as Crypto import qualified Cardano.Crypto.Hash.Class as Crypto @@ -1411,7 +1412,7 @@ mockTxConstraints = , Cardano.protocolParamStakeAddressDeposit = Cardano.Lovelace 2_000_000 , Cardano.protocolParamStakePoolDeposit = Cardano.Lovelace 500_000_000 , Cardano.protocolParamMinPoolCost = Cardano.Lovelace 32_000_000 - , Cardano.protocolParamPoolRetireMaxEpoch = Cardano.EpochNo 2 + , Cardano.protocolParamPoolRetireMaxEpoch = L.EpochInterval 2 , Cardano.protocolParamStakePoolTargetNum = 100 , Cardano.protocolParamPoolPledgeInfluence = 0 , Cardano.protocolParamMonetaryExpansion = 0 From 85808d315618b6620bc74c57f018a30d78373ac2 Mon Sep 17 00:00:00 2001 From: paolino Date: Fri, 22 Mar 2024 18:02:50 +0000 Subject: [PATCH 16/24] Bump cardano node runtime version to 8.9.0 --- flake.lock | 157 ++++++++++++++++++++++++++++++++++++++--------------- flake.nix | 2 +- 2 files changed, 115 insertions(+), 44 deletions(-) diff --git a/flake.lock b/flake.lock index 201a5cda926..7979f882c9d 100644 --- a/flake.lock +++ b/flake.lock @@ -20,15 +20,15 @@ "CHaP_2": { "flake": false, "locked": { - "lastModified": 1702593630, - "narHash": "sha256-IWu27+sfPtazjIZiWLUm8G4BKvjXmIL+/1XT/ETnfhg=", - "owner": "input-output-hk", + "lastModified": 1709731402, + "narHash": "sha256-7h4/ns3WRI3BtK1FbUEm6nMqW1ahNNehiHr7eQ03muk=", + "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "9783a177efcea5beb8808aab7513098bdab185ba", + "rev": "8e4f211a8e537c8c939b65e887556bd7441c774c", "type": "github" }, "original": { - "owner": "input-output-hk", + "owner": "intersectmbo", "ref": "repo", "repo": "cardano-haskell-packages", "type": "github" @@ -99,17 +99,17 @@ "blst": { "flake": false, "locked": { - "lastModified": 1656163412, - "narHash": "sha256-xero1aTe2v4IhWIJaEDUsVDOfE77dOV5zKeHWntHogY=", + "lastModified": 1691598027, + "narHash": "sha256-oqljy+ZXJAXEB/fJtmB8rlAr4UXM+Z2OkDa20gpILNA=", "owner": "supranational", "repo": "blst", - "rev": "03b5124029979755c752eec45f3c29674b558446", + "rev": "3dd0f804b1819e5d03fb22ca2e6fac105932043a", "type": "github" }, "original": { "owner": "supranational", + "ref": "v0.3.11", "repo": "blst", - "rev": "03b5124029979755c752eec45f3c29674b558446", "type": "github" } }, @@ -305,16 +305,16 @@ "utils": "utils_2" }, "locked": { - "lastModified": 1702654749, - "narHash": "sha256-fIzSNSKWC7qMRjHUMHfrMnEzHiFu7ac/UUgfofXqaFY=", + "lastModified": 1709733493, + "narHash": "sha256-chcwbks+HyImFk7FpbkC7FFmfpScMx5T7K0TzTkGAww=", "owner": "IntersectMBO", "repo": "cardano-node", - "rev": "a4a8119b59b1fbb9a69c79e1e6900e91292161e7", + "rev": "0d98405a60d57e1c8e13406d51cce0e34356bd64", "type": "github" }, "original": { "owner": "IntersectMBO", - "ref": "8.7.3", + "ref": "8.9.0", "repo": "cardano-node", "type": "github" } @@ -858,11 +858,11 @@ "ghc99": { "flake": false, "locked": { - "lastModified": 1697054644, - "narHash": "sha256-kKarOuXUaAH3QWv7ASx+gGFMHaHKe0pK5Zu37ky2AL4=", + "lastModified": 1701580282, + "narHash": "sha256-drA01r3JrXnkKyzI+owMZGxX0JameMzjK0W5jJE/+V4=", "ref": "refs/heads/master", - "rev": "f383a242c76f90bcca8a4d7ee001dcb49c172a9a", - "revCount": 62040, + "rev": "f5eb0f2982e9cf27515e892c4bdf634bcfb28459", + "revCount": 62197, "submodules": true, "type": "git", "url": "https://gitlab.haskell.org/ghc/ghc" @@ -929,11 +929,11 @@ "hackageNix": { "flake": false, "locked": { - "lastModified": 1701303758, - "narHash": "sha256-8XqVEQwmJBxRPFa7SizJuZxbG+NFEZKWdhtYPTQ7ZKM=", + "lastModified": 1709684582, + "narHash": "sha256-+rC8Vpaxdd4Nw2fJIn9wzAnzW5arILly5AkTG6chRAw=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "8a0e3ae9295b7ef8431b9be208dd06aa2789be53", + "rev": "c2ed9aa79252ed67a1fb694b3fffaf7dd7ead6d2", "type": "github" }, "original": { @@ -962,9 +962,12 @@ "hls-2.2": "hls-2.2", "hls-2.3": "hls-2.3", "hls-2.4": "hls-2.4", + "hls-2.5": "hls-2.5", + "hls-2.6": "hls-2.6", "hpc-coveralls": "hpc-coveralls", "hydra": "hydra", "iserv-proxy": "iserv-proxy", + "nix-tools-static": "nix-tools-static", "nixpkgs": [ "cardano-node-runtime", "nixpkgs" @@ -975,16 +978,17 @@ "nixpkgs-2205": "nixpkgs-2205", "nixpkgs-2211": "nixpkgs-2211", "nixpkgs-2305": "nixpkgs-2305", + "nixpkgs-2311": "nixpkgs-2311", "nixpkgs-unstable": "nixpkgs-unstable", "old-ghc-nix": "old-ghc-nix", "stackage": "stackage" }, "locked": { - "lastModified": 1700441391, - "narHash": "sha256-oJqP1AUskUvr3GNUH97eKwaIUHdYgENS2kQ7GI9RI+c=", + "lastModified": 1708911681, + "narHash": "sha256-QGkzPN1HUYxgMU2EwiwjMvR2gQF0ffUdxALq1+bOdcY=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "3b6056f3866f88d1d16eaeb2e810d3ac0df0e7cd", + "rev": "5031fa0b8346fcc533c33073530ca87b8390add3", "type": "github" }, "original": { @@ -1012,8 +1016,8 @@ "hls-2.2": "hls-2.2_2", "hls-2.3": "hls-2.3_2", "hls-2.4": "hls-2.4_2", - "hls-2.5": "hls-2.5", - "hls-2.6": "hls-2.6", + "hls-2.5": "hls-2.5_2", + "hls-2.6": "hls-2.6_2", "hpc-coveralls": "hpc-coveralls_2", "hydra": "hydra_2", "iserv-proxy": "iserv-proxy_2", @@ -1026,7 +1030,7 @@ "nixpkgs-2205": "nixpkgs-2205_2", "nixpkgs-2211": "nixpkgs-2211_2", "nixpkgs-2305": "nixpkgs-2305_2", - "nixpkgs-2311": "nixpkgs-2311", + "nixpkgs-2311": "nixpkgs-2311_2", "nixpkgs-unstable": "nixpkgs-unstable_2", "old-ghc-nix": "old-ghc-nix_2", "stackage": "stackage_2" @@ -1220,16 +1224,16 @@ "hls-2.4": { "flake": false, "locked": { - "lastModified": 1696939266, - "narHash": "sha256-VOMf5+kyOeOmfXTHlv4LNFJuDGa7G3pDnOxtzYR40IU=", + "lastModified": 1699862708, + "narHash": "sha256-YHXSkdz53zd0fYGIYOgLt6HrA0eaRJi9mXVqDgmvrjk=", "owner": "haskell", "repo": "haskell-language-server", - "rev": "362fdd1293efb4b82410b676ab1273479f6d17ee", + "rev": "54507ef7e85fa8e9d0eb9a669832a3287ffccd57", "type": "github" }, "original": { "owner": "haskell", - "ref": "2.4.0.0", + "ref": "2.4.0.1", "repo": "haskell-language-server", "type": "github" } @@ -1268,6 +1272,23 @@ "type": "github" } }, + "hls-2.5_2": { + "flake": false, + "locked": { + "lastModified": 1701080174, + "narHash": "sha256-fyiR9TaHGJIIR0UmcCb73Xv9TJq3ht2ioxQ2mT7kVdc=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "27f8c3d3892e38edaef5bea3870161815c4d014c", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.5.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, "hls-2.6": { "flake": false, "locked": { @@ -1285,6 +1306,23 @@ "type": "github" } }, + "hls-2.6_2": { + "flake": false, + "locked": { + "lastModified": 1705325287, + "narHash": "sha256-+P87oLdlPyMw8Mgoul7HMWdEvWP/fNlo8jyNtwME8E8=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "6e0b342fa0327e628610f2711f8c3e4eaaa08b1e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.6.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, "hpc-coveralls": { "flake": false, "locked": { @@ -1422,11 +1460,11 @@ "sodium": "sodium" }, "locked": { - "lastModified": 1698746924, - "narHash": "sha256-8og+vqQPEoB2KLUtN5esGMDymT+2bT/rCHZt1NAe7y0=", + "lastModified": 1709083850, + "narHash": "sha256-6DQ89ktt8rRVV1pXEyX2JwPjaqS0mQkelkmJmka04rg=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "af551ca93d969d9715fa9bf86691d9a0a19e89d9", + "rev": "1c793a53ac0bd99b795c2180eb23d37e8389a74b", "type": "github" }, "original": { @@ -1641,6 +1679,23 @@ "type": "github" } }, + "nix-tools-static": { + "flake": false, + "locked": { + "lastModified": 1706266250, + "narHash": "sha256-9t+GRk3eO9muCtKdNAwBtNBZ5dH1xHcnS17WaQyftwA=", + "owner": "input-output-hk", + "repo": "haskell-nix-example", + "rev": "580cb6db546a7777dad3b9c0fa487a366c045c4e", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "nix", + "repo": "haskell-nix-example", + "type": "github" + } + }, "nix2container": { "inputs": { "flake-utils": "flake-utils_2", @@ -1948,11 +2003,11 @@ }, "nixpkgs-2305": { "locked": { - "lastModified": 1695416179, - "narHash": "sha256-610o1+pwbSu+QuF3GE0NU5xQdTHM3t9wyYhB9l94Cd8=", + "lastModified": 1701362232, + "narHash": "sha256-GVdzxL0lhEadqs3hfRLuj+L1OJFGiL/L7gCcelgBlsw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "715d72e967ec1dd5ecc71290ee072bcaf5181ed6", + "rev": "d2332963662edffacfddfad59ff4f709dde80ffe", "type": "github" }, "original": { @@ -1994,6 +2049,22 @@ "type": "github" } }, + "nixpkgs-2311_2": { + "locked": { + "lastModified": 1701386440, + "narHash": "sha256-xI0uQ9E7JbmEy/v8kR9ZQan6389rHug+zOtZeZFiDJk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "293822e55ec1872f715a66d0eda9e592dc14419f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-23.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-regression": { "locked": { "lastModified": 1643052045, @@ -2028,17 +2099,17 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1695318763, - "narHash": "sha256-FHVPDRP2AfvsxAdc+AsgFJevMz5VBmnZglFUMlxBkcY=", + "lastModified": 1694822471, + "narHash": "sha256-6fSDCj++lZVMZlyqOe9SIOL8tYSBz1bI8acwovRwoX8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e12483116b3b51a185a33a272bf351e357ba9a99", + "rev": "47585496bcb13fb72e4a90daeea2f434e2501998", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", "repo": "nixpkgs", + "rev": "47585496bcb13fb72e4a90daeea2f434e2501998", "type": "github" } }, @@ -2602,11 +2673,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1700438989, - "narHash": "sha256-x+7Qtboko7ds8CU8pq2sIZiD45DauYoX9LxBfwQr/hs=", + "lastModified": 1708906175, + "narHash": "sha256-KJDF0CO077Jx4GjjPK6pNkx6NkY7p1x5RMPfaIe8nl4=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "9c2015334cc77837b8454b3b10ef4f711a256f6f", + "rev": "bfa4778050cf69fe50f91d39dcefbb9005d6d0d0", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5c0733ca0d8..e279fb7baaf 100644 --- a/flake.nix +++ b/flake.nix @@ -142,7 +142,7 @@ flake = false; }; customConfig.url = "github:input-output-hk/empty-flake"; - cardano-node-runtime.url = "github:IntersectMBO/cardano-node?ref=8.7.3"; + cardano-node-runtime.url = "github:IntersectMBO/cardano-node?ref=8.9.0"; hls = { url = "github:cardano-scaling/haskell-language-server?ref=2.6-patched"; flake = false; From bc7674d340a8cfe0a3fd461fa3ccee3ef6eb8e0f Mon Sep 17 00:00:00 2001 From: paolino Date: Mon, 25 Mar 2024 10:05:19 +0000 Subject: [PATCH 17/24] Refresh cardano-node config files --- configs/cardano/mainnet/config.json | 2 +- configs/cardano/mainnet/conway-genesis.json | 39 ++++++++++--------- configs/cardano/mainnet/download.sh | 4 +- configs/cardano/mainnet/topology.json | 28 +++++++------ configs/cardano/preprod/config.json | 2 +- configs/cardano/preprod/conway-genesis.json | 29 +++++++------- configs/cardano/preprod/topology.json | 16 ++++---- configs/cardano/sanchonet/config.json | 2 +- configs/cardano/sanchonet/conway-genesis.json | 29 +++++++------- configs/cardano/sanchonet/topology.json | 16 ++++---- 10 files changed, 86 insertions(+), 81 deletions(-) diff --git a/configs/cardano/mainnet/config.json b/configs/cardano/mainnet/config.json index eba6cd3511b..4d4a9745097 100644 --- a/configs/cardano/mainnet/config.json +++ b/configs/cardano/mainnet/config.json @@ -4,7 +4,7 @@ "ByronGenesisFile": "byron-genesis.json", "ByronGenesisHash": "5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb", "ConwayGenesisFile": "conway-genesis.json", - "ConwayGenesisHash": "f7d46bdd3b3c8caf38351c4eef3346a89241707270be0d6106e8a407db294cc6", + "ConwayGenesisHash": "de609b281cb3d8ae91a9d63a00c87092975612d603aa54c0f1c6a781e33d6e1e", "EnableP2P": true, "LastKnownBlockVersion-Alt": 0, "LastKnownBlockVersion-Major": 3, diff --git a/configs/cardano/mainnet/conway-genesis.json b/configs/cardano/mainnet/conway-genesis.json index 078d33b1814..5f1de84e6eb 100644 --- a/configs/cardano/mainnet/conway-genesis.json +++ b/configs/cardano/mainnet/conway-genesis.json @@ -1,28 +1,29 @@ { "poolVotingThresholds": { - "pvtCommitteeNormal": 0.51, - "pvtCommitteeNoConfidence": 0.51, - "pvtHardForkInitiation": 0.51, - "pvtMotionNoConfidence": 0.51 + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "hardForkInitiation": 0.51, + "motionNoConfidence": 0.51, + "ppSecurityGroup": 0.51 }, "dRepVotingThresholds": { - "dvtMotionNoConfidence": 0.51, - "dvtCommitteeNormal": 0.51, - "dvtCommitteeNoConfidence": 0.51, - "dvtUpdateToConstitution": 0.51, - "dvtHardForkInitiation": 0.51, - "dvtPPNetworkGroup": 0.51, - "dvtPPEconomicGroup": 0.51, - "dvtPPTechnicalGroup": 0.51, - "dvtPPGovGroup": 0.51, - "dvtTreasuryWithdrawal": 0.51 + "motionNoConfidence": 0.51, + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "updateToConstitution": 0.51, + "hardForkInitiation": 0.51, + "ppNetworkGroup": 0.51, + "ppEconomicGroup": 0.51, + "ppTechnicalGroup": 0.51, + "ppGovGroup": 0.51, + "treasuryWithdrawal": 0.51 }, "committeeMinSize": 0, - "committeeMaxTermLength": 60, - "govActionLifetime": 14, - "govActionDeposit": 0, - "dRepDeposit": 0, - "dRepActivity": 0, + "committeeMaxTermLength": 200, + "govActionLifetime": 10, + "govActionDeposit": 1000000000, + "dRepDeposit": 2000000, + "dRepActivity": 20, "constitution": { "anchor": { "url": "", diff --git a/configs/cardano/mainnet/download.sh b/configs/cardano/mainnet/download.sh index 8c0f9e6fb07..bc9df7b9a9d 100755 --- a/configs/cardano/mainnet/download.sh +++ b/configs/cardano/mainnet/download.sh @@ -4,8 +4,8 @@ set -euo pipefail curl https://book.play.dev.cardano.org/environments/mainnet/config.json \ > config.json -curl https://book.play.dev.cardano.org/environments/mainnet/genesis.json \ - > genesis.json +curl https://book.play.dev.cardano.org/environments/mainnet/conway-genesis.json \ + > conway-genesis.json curl https://book.play.dev.cardano.org/environments/mainnet/topology.json \ > topology.json curl https://book.play.dev.cardano.org/environments/mainnet/byron-genesis.json \ diff --git a/configs/cardano/mainnet/topology.json b/configs/cardano/mainnet/topology.json index 902d14376c5..5290fbeb035 100644 --- a/configs/cardano/mainnet/topology.json +++ b/configs/cardano/mainnet/topology.json @@ -1,29 +1,27 @@ { + "bootstrapPeers": [ + { + "address": "backbone.cardano.iog.io", + "port": 3001 + }, + { + "address": "backbone.mainnet.emurgornd.com", + "port": 3001 + } + ], "localRoots": [ { "accessPoints": [], "advertise": false, + "trustable": false, "valency": 1 } ], "publicRoots": [ { - "accessPoints": [ - { - "address": "backbone.cardano-mainnet.iohk.io", - "port": 3001 - }, - { - "address": "backbone.cardano.iog.io", - "port": 3001 - }, - { - "address": "backbone.mainnet.emurgornd.com", - "port": 3001 - } - ], + "accessPoints": [], "advertise": false } ], - "useLedgerAfterSlot": 110332824 + "useLedgerAfterSlot": 116812831 } diff --git a/configs/cardano/preprod/config.json b/configs/cardano/preprod/config.json index db78b243a1a..cd5b521baa9 100644 --- a/configs/cardano/preprod/config.json +++ b/configs/cardano/preprod/config.json @@ -4,7 +4,7 @@ "ByronGenesisFile": "byron-genesis.json", "ByronGenesisHash": "d4b8de7a11d929a323373cbab6c1a9bdc931beffff11db111cf9d57356ee1937", "ConwayGenesisFile": "conway-genesis.json", - "ConwayGenesisHash": "89dd23dc6a020afa0c7521fe52fe14e38d494129933a3604154a3acfa4ac16e4", + "ConwayGenesisHash": "de609b281cb3d8ae91a9d63a00c87092975612d603aa54c0f1c6a781e33d6e1e", "EnableP2P": true, "LastKnownBlockVersion-Alt": 0, "LastKnownBlockVersion-Major": 2, diff --git a/configs/cardano/preprod/conway-genesis.json b/configs/cardano/preprod/conway-genesis.json index 14d9c0f65c8..5f1de84e6eb 100644 --- a/configs/cardano/preprod/conway-genesis.json +++ b/configs/cardano/preprod/conway-genesis.json @@ -1,21 +1,22 @@ { "poolVotingThresholds": { - "pvtCommitteeNormal": 0.51, - "pvtCommitteeNoConfidence": 0.51, - "pvtHardForkInitiation": 0.51, - "pvtMotionNoConfidence": 0.51 + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "hardForkInitiation": 0.51, + "motionNoConfidence": 0.51, + "ppSecurityGroup": 0.51 }, "dRepVotingThresholds": { - "dvtMotionNoConfidence": 0.51, - "dvtCommitteeNormal": 0.51, - "dvtCommitteeNoConfidence": 0.51, - "dvtUpdateToConstitution": 0.51, - "dvtHardForkInitiation": 0.51, - "dvtPPNetworkGroup": 0.51, - "dvtPPEconomicGroup": 0.51, - "dvtPPTechnicalGroup": 0.51, - "dvtPPGovGroup": 0.51, - "dvtTreasuryWithdrawal": 0.51 + "motionNoConfidence": 0.51, + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "updateToConstitution": 0.51, + "hardForkInitiation": 0.51, + "ppNetworkGroup": 0.51, + "ppEconomicGroup": 0.51, + "ppTechnicalGroup": 0.51, + "ppGovGroup": 0.51, + "treasuryWithdrawal": 0.51 }, "committeeMinSize": 0, "committeeMaxTermLength": 200, diff --git a/configs/cardano/preprod/topology.json b/configs/cardano/preprod/topology.json index 0da741d8c88..9faac371406 100644 --- a/configs/cardano/preprod/topology.json +++ b/configs/cardano/preprod/topology.json @@ -1,21 +1,23 @@ { + "bootstrapPeers": [ + { + "address": "preprod-node.play.dev.cardano.org", + "port": 3001 + } + ], "localRoots": [ { "accessPoints": [], "advertise": false, + "trustable": false, "valency": 1 } ], "publicRoots": [ { - "accessPoints": [ - { - "address": "preprod-node.play.dev.cardano.org", - "port": 3001 - } - ], + "accessPoints": [], "advertise": false } ], - "useLedgerAfterSlot": 42855241 + "useLedgerAfterSlot": 52358331 } diff --git a/configs/cardano/sanchonet/config.json b/configs/cardano/sanchonet/config.json index 73dcd79eea0..70d8c26ea0d 100644 --- a/configs/cardano/sanchonet/config.json +++ b/configs/cardano/sanchonet/config.json @@ -4,7 +4,7 @@ "ByronGenesisFile": "byron-genesis.json", "ByronGenesisHash": "785eb88427e136378a15b0a152a8bfbeec7a611529ccda29c43a1e60ffb48eaa", "ConwayGenesisFile": "conway-genesis.json", - "ConwayGenesisHash": "89dd23dc6a020afa0c7521fe52fe14e38d494129933a3604154a3acfa4ac16e4", + "ConwayGenesisHash": "de609b281cb3d8ae91a9d63a00c87092975612d603aa54c0f1c6a781e33d6e1e", "EnableP2P": true, "ExperimentalHardForksEnabled": true, "ExperimentalProtocolsEnabled": true, diff --git a/configs/cardano/sanchonet/conway-genesis.json b/configs/cardano/sanchonet/conway-genesis.json index 14d9c0f65c8..5f1de84e6eb 100644 --- a/configs/cardano/sanchonet/conway-genesis.json +++ b/configs/cardano/sanchonet/conway-genesis.json @@ -1,21 +1,22 @@ { "poolVotingThresholds": { - "pvtCommitteeNormal": 0.51, - "pvtCommitteeNoConfidence": 0.51, - "pvtHardForkInitiation": 0.51, - "pvtMotionNoConfidence": 0.51 + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "hardForkInitiation": 0.51, + "motionNoConfidence": 0.51, + "ppSecurityGroup": 0.51 }, "dRepVotingThresholds": { - "dvtMotionNoConfidence": 0.51, - "dvtCommitteeNormal": 0.51, - "dvtCommitteeNoConfidence": 0.51, - "dvtUpdateToConstitution": 0.51, - "dvtHardForkInitiation": 0.51, - "dvtPPNetworkGroup": 0.51, - "dvtPPEconomicGroup": 0.51, - "dvtPPTechnicalGroup": 0.51, - "dvtPPGovGroup": 0.51, - "dvtTreasuryWithdrawal": 0.51 + "motionNoConfidence": 0.51, + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "updateToConstitution": 0.51, + "hardForkInitiation": 0.51, + "ppNetworkGroup": 0.51, + "ppEconomicGroup": 0.51, + "ppTechnicalGroup": 0.51, + "ppGovGroup": 0.51, + "treasuryWithdrawal": 0.51 }, "committeeMinSize": 0, "committeeMaxTermLength": 200, diff --git a/configs/cardano/sanchonet/topology.json b/configs/cardano/sanchonet/topology.json index a20dc7c832b..4e41c44e51f 100644 --- a/configs/cardano/sanchonet/topology.json +++ b/configs/cardano/sanchonet/topology.json @@ -1,21 +1,23 @@ { + "bootstrapPeers": [ + { + "address": "sanchonet-node.play.dev.cardano.org", + "port": 3001 + } + ], "localRoots": [ { "accessPoints": [], "advertise": false, + "trustable": false, "valency": 1 } ], "publicRoots": [ { - "accessPoints": [ - { - "address": "sanchonet-node.play.dev.cardano.org", - "port": 3001 - } - ], + "accessPoints": [], "advertise": false } ], - "useLedgerAfterSlot": 14601600 + "useLedgerAfterSlot": 21599922 } From 6289b56a4838126be6a1e2e7b0683f450cb48af6 Mon Sep 17 00:00:00 2001 From: paolino Date: Mon, 25 Mar 2024 10:28:15 +0000 Subject: [PATCH 18/24] Update local-cluster configs --- .../Wallet/Launch/Cluster/GenesisFiles.hs | 8 +- .../data/cluster-configs/alonzo-genesis.json | 188 ++++++++++++++++++ .../data/cluster-configs/byron-genesis.json | 46 +++++ .../data/cluster-configs/conway-genesis.json | 37 ++++ .../delegate-keys/byron.000.cert.json | 6 +- .../delegate-keys/byron.000.key | Bin 130 -> 130 bytes .../delegate-keys/shelley.000.counter.json | 2 +- .../delegate-keys/shelley.000.kes.skey | 2 +- .../delegate-keys/shelley.000.kes.vkey | 2 +- .../delegate-keys/shelley.000.opcert.json | 2 +- .../delegate-keys/shelley.000.skey | 2 +- .../delegate-keys/shelley.000.vkey | 2 +- .../delegate-keys/shelley.000.vrf.skey | 2 +- .../delegate-keys/shelley.000.vrf.vkey | 2 +- .../data/cluster-configs/genesis-alonzo.json | 188 ------------------ .../data/cluster-configs/genesis-byron.json | 46 ----- .../data/cluster-configs/genesis-conway.json | 36 ---- .../genesis-keys/byron.000.key | Bin 130 -> 130 bytes .../genesis-keys/shelley.000.skey | 2 +- .../genesis-keys/shelley.000.vkey | 2 +- .../data/cluster-configs/node-config.json | 8 +- .../data/cluster-configs/shelley-genesis.json | 48 +++++ .../data/cluster-configs/template/conway.json | 53 +++-- .../cluster-configs/utxo-keys/byron.000.key | Bin 130 -> 130 bytes .../utxo-keys/shelley.000.skey | 2 +- .../utxo-keys/shelley.000.vkey | 2 +- 26 files changed, 374 insertions(+), 314 deletions(-) create mode 100644 lib/local-cluster/test/data/cluster-configs/alonzo-genesis.json create mode 100644 lib/local-cluster/test/data/cluster-configs/byron-genesis.json create mode 100644 lib/local-cluster/test/data/cluster-configs/conway-genesis.json delete mode 100644 lib/local-cluster/test/data/cluster-configs/genesis-alonzo.json delete mode 100644 lib/local-cluster/test/data/cluster-configs/genesis-byron.json delete mode 100644 lib/local-cluster/test/data/cluster-configs/genesis-conway.json create mode 100644 lib/local-cluster/test/data/cluster-configs/shelley-genesis.json diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs index 35440a83d4a..57cd8549ddd 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/GenesisFiles.hs @@ -230,25 +230,25 @@ generateGenesis initialFunds genesisMods = do } genesisMods - let shelleyGenesis = pathOf cfgClusterDir "genesis-shelley.json" + let shelleyGenesis = pathOf cfgClusterDir "shelley-genesis.json" Aeson.encodeFile shelleyGenesis shelleyGenesisData let fileToAeson :: FilePath -> IO Aeson.Value fileToAeson f = Aeson.eitherDecodeFileStrict f >>= either fail pure let byronGenesis = pathOf cfgClusterDir "genesis-byron.json" - fileToAeson (pathOf cfgClusterConfigs "genesis-byron.json") + fileToAeson (pathOf cfgClusterConfigs "byron-genesis.json") >>= withAddedKey "startTime" (round @_ @Int $ utcTimeToPOSIXSeconds systemStart) >>= Aeson.encodeFile byronGenesis let alonzoGenesis = pathOf cfgClusterDir "genesis-alonzo.json" - fileToAeson (pathOf cfgClusterConfigs "genesis-alonzo.json") + fileToAeson (pathOf cfgClusterConfigs "alonzo-genesis.json") >>= Aeson.encodeFile alonzoGenesis let conwayGenesis = pathOf cfgClusterDir "genesis-conway.json" - copyFile (pathOf cfgClusterConfigs "genesis-conway.json") conwayGenesis + copyFile (pathOf cfgClusterConfigs "conway-genesis.json") conwayGenesis pure GenesisFiles diff --git a/lib/local-cluster/test/data/cluster-configs/alonzo-genesis.json b/lib/local-cluster/test/data/cluster-configs/alonzo-genesis.json new file mode 100644 index 00000000000..de05d3d9e46 --- /dev/null +++ b/lib/local-cluster/test/data/cluster-configs/alonzo-genesis.json @@ -0,0 +1,188 @@ +{ + "collateralPercentage": 150, + "costModels": { + "PlutusV1": [ + 197209, + 0, + 1, + 1, + 396231, + 621, + 0, + 1, + 150000, + 1000, + 0, + 1, + 150000, + 32, + 2477736, + 29175, + 4, + 29773, + 100, + 29773, + 100, + 29773, + 100, + 29773, + 100, + 29773, + 100, + 29773, + 100, + 100, + 100, + 29773, + 100, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 1000, + 0, + 1, + 150000, + 32, + 150000, + 1000, + 0, + 8, + 148000, + 425507, + 118, + 0, + 1, + 1, + 150000, + 1000, + 0, + 8, + 150000, + 112536, + 247, + 1, + 150000, + 10000, + 1, + 136542, + 1326, + 1, + 1000, + 150000, + 1000, + 1, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 1, + 1, + 150000, + 1, + 150000, + 4, + 103599, + 248, + 1, + 103599, + 248, + 1, + 145276, + 1366, + 1, + 179690, + 497, + 1, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 148000, + 425507, + 118, + 0, + 1, + 1, + 61516, + 11218, + 0, + 1, + 150000, + 32, + 148000, + 425507, + 118, + 0, + 1, + 1, + 148000, + 425507, + 118, + 0, + 1, + 1, + 2477736, + 29175, + 4, + 0, + 82363, + 4, + 150000, + 5000, + 0, + 1, + 150000, + 32, + 197209, + 0, + 1, + 1, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 150000, + 32, + 3345831, + 1, + 1 + ] + }, + "executionPrices": { + "prMem": 5.77e-2, + "prSteps": 7.21e-5 + }, + "lovelacePerUTxOWord": 34482, + "maxBlockExUnits": { + "exUnitsMem": 50000000, + "exUnitsSteps": 40000000000 + }, + "maxCollateralInputs": 3, + "maxTxExUnits": { + "exUnitsMem": 10000000, + "exUnitsSteps": 10000000000 + }, + "maxValueSize": 5000 +} \ No newline at end of file diff --git a/lib/local-cluster/test/data/cluster-configs/byron-genesis.json b/lib/local-cluster/test/data/cluster-configs/byron-genesis.json new file mode 100644 index 00000000000..70a4a07a43e --- /dev/null +++ b/lib/local-cluster/test/data/cluster-configs/byron-genesis.json @@ -0,0 +1,46 @@ +{ + "avvmDistr": {}, + "blockVersionData": { + "heavyDelThd": "300000000000", + "maxBlockSize": "2000000", + "maxHeaderSize": "2000000", + "maxProposalSize": "700", + "maxTxSize": "4096", + "mpcThd": "20000000000000", + "scriptVersion": 0, + "slotDuration": "20000", + "softforkRule": { + "initThd": "900000000000000", + "minThd": "600000000000000", + "thdDecrement": "50000000000000" + }, + "txFeePolicy": { + "multiplier": "43946000000", + "summand": "155381000000000" + }, + "unlockStakeEpoch": "18446744073709551615", + "updateImplicit": "10000", + "updateProposalThd": "100000000000000", + "updateVoteThd": "1000000000000" + }, + "bootStakeholders": { + "c230017636249d8de93da4f2076a2fa834bf9dd030b289ccfe801cd4": 1 + }, + "heavyDelegation": { + "c230017636249d8de93da4f2076a2fa834bf9dd030b289ccfe801cd4": { + "cert": "ccbf248174b180715e00f0c9cc4daaa8a65afcaa128df833b9c7a522b1589aa49899592e5a97c5ec89bcd70238e053a07b53df6c7b8132f1f60350de3feb3200", + "delegatePk": "ocgT7MrqFlzSrfOXt7aSnQApv5RoEgKACAG6+0Po/2kN7tLBO6FH9vpIZMQ+kOFT9fE2PeXV/DEGzbzR8SCq9w==", + "issuerPk": "KSXf8a+XFmSdcPcZ9u0feQRAil5qneli4I6buhYYFcoel/XTWCAzhH9yXLb9tU51MClINJ60t0YZ6bzpG4BP3w==", + "omega": 0 + } + }, + "nonAvvmBalances": { + "2657WMsDfac5jZj2WRVKCBit4jzkvt26xW9rbirmWmCQ2RMwrZWGGTBjVe91z3y9B": "45000000000000000", + "2657WMsDfac65858heSf4akU8adDY3co4VhEAmYjwV1vmSUc2pLqmVRQumHUsVkun": "0" + }, + "protocolConsts": { + "k": 108, + "protocolMagic": 42 + }, + "startTime": 1711362867 +} \ No newline at end of file diff --git a/lib/local-cluster/test/data/cluster-configs/conway-genesis.json b/lib/local-cluster/test/data/cluster-configs/conway-genesis.json new file mode 100644 index 00000000000..4e885627c4f --- /dev/null +++ b/lib/local-cluster/test/data/cluster-configs/conway-genesis.json @@ -0,0 +1,37 @@ +{ + "committee": { + "members": {}, + "quorum": 0.0 + }, + "committeeMaxTermLength": 200, + "committeeMinSize": 0, + "constitution": { + "anchor": { + "dataHash": "0000000000000000000000000000000000000000000000000000000000000000", + "url": "" + } + }, + "dRepActivity": 20, + "dRepDeposit": 2000000, + "dRepVotingThresholds": { + "committeeNoConfidence": 0.51, + "committeeNormal": 0.51, + "hardForkInitiation": 0.51, + "motionNoConfidence": 0.51, + "ppEconomicGroup": 0.51, + "ppGovGroup": 0.51, + "ppNetworkGroup": 0.51, + "ppTechnicalGroup": 0.51, + "treasuryWithdrawal": 0.51, + "updateToConstitution": 0.51 + }, + "govActionDeposit": 1000000000, + "govActionLifetime": 10, + "poolVotingThresholds": { + "committeeNoConfidence": 0.51, + "committeeNormal": 0.51, + "hardForkInitiation": 0.51, + "motionNoConfidence": 0.51, + "ppSecurityGroup": 0.51 + } +} \ No newline at end of file diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/byron.000.cert.json b/lib/local-cluster/test/data/cluster-configs/delegate-keys/byron.000.cert.json index 70e172312f3..cb9195d24f4 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/byron.000.cert.json +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/byron.000.cert.json @@ -1,8 +1,8 @@ { "omega": 0 , "issuerPk": - "siJZ1ewbKx9n3AxeFSegymNvyhhRuZd5B0CkbI8mlt6g6kFBqDtseUNOdp3CZorqPhiZdapS5eEOmHNneqWZOg==" + "KSXf8a+XFmSdcPcZ9u0feQRAil5qneli4I6buhYYFcoel/XTWCAzhH9yXLb9tU51MClINJ60t0YZ6bzpG4BP3w==" , "delegatePk": - "zmgaMKBfDDeex3Q99KG/24K7PwskBuKKw6/g/ssIVTmUaNK5R4l25YSkDHNTVOxwo7jawvwAGxe5RcbwwEULdw==" + "ocgT7MrqFlzSrfOXt7aSnQApv5RoEgKACAG6+0Po/2kN7tLBO6FH9vpIZMQ+kOFT9fE2PeXV/DEGzbzR8SCq9w==" , "cert": - "86fe8c7fd9d6475dceacdd7f50e0b428e176a643ede9d08a186e4817ffed4f12fd38e1c29b68f2af9bf9b89ab1545db88a769ccaa274f15d162ed1682268ac02" + "ccbf248174b180715e00f0c9cc4daaa8a65afcaa128df833b9c7a522b1589aa49899592e5a97c5ec89bcd70238e053a07b53df6c7b8132f1f60350de3feb3200" } \ No newline at end of file diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/byron.000.key b/lib/local-cluster/test/data/cluster-configs/delegate-keys/byron.000.key index 39e2e0d6fe1dc3f2378ee03ea9029cc7c88dda42..84dfaf9e8b733195cbfb40ddee7c9e8beb132544 100644 GIT binary patch literal 130 zcmV-|0Db>hfQY7s%0wAsr!x%!LCtH!NR*%Dwd;m7;5PanyjF0%tC7(LLN z$Euy-h1jB@UD*@xV{K`50RRR2&7sH>?8@pET+*%cm$$Z(od7AnlxPwHfCvG)`$Ope kX$|hu!8@Tx_WDR<#6FPWQ}yvSJ>}K>F$T@N(eWUv_ZY@SkpKVy literal 130 zcmV-|0Db>hfIvD}>liCd=Pc#~^V^`F2r8XFp-*$V95ujw!6tq{>une kIh1J9xkrh1<%FaRb5m68aHF`|!u$Xm7r8~o@W4e2cRNi$@&Et; diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.counter.json b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.counter.json index 1b1bf8903c5..4c8a80da85c 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.counter.json +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.counter.json @@ -1,5 +1,5 @@ { "type": "NodeOperationalCertificateIssueCounter", "description": "", - "cborHex": "82015820ce681a30a05f0c379ec7743df4a1bfdb82bb3f0b2406e28ac3afe0fecb085539" + "cborHex": "82015820a1c813eccaea165cd2adf397b7b6929d0029bf94681202800801bafb43e8ff69" } diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.skey b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.skey index da136a7b7e7..c6bdc4c08ce 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.skey +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.skey @@ -1,5 +1,5 @@ { "type": "KesSigningKey_ed25519_kes_2^6", "description": "", - "cborHex": "59026035a1d7480dbfe47e283cc612e730a5747e689a214024ab5cac111b2b0148bdd06717c635fb0f83da42b2796e6d7f770077944c92fe1b94818da3bf3cd29aac3bd8b2204aefccde065a787e110edf9023bbad541d22d01e5a1216c9f113776fe92105894b3e9968b0334870fb8e118d1259057967b24898c41f44a59b48a86dead2bfb92c7168d3fe5359ed02a6972a9814ff06bb512e5f4fe363ad9ea0b93deb44f7eaf60476853a9d79b3368b8497ac4af0fe1a77b4b49be20f87a0eaf25bdd87016c0eec3f9717ba655e00b0fe93092f79c4e0a012bdf0729c08b4128533d32bf05f92654b752883ab2085aa8f8b871a4fe651ceb20ec44173f2317172fa97978c66a238fecf6aef1bd112a1e40d4cdfb36100173feeb0bd5d06b20f9148f5fd0b8e5919cfb00ba72104403e4921db3629e8e9d3ebcf03a66ac712ae8428d2799eaca5c0c1c69b013c8bdc7cdea7af9ea8783e9f2e2c713be498e49d83ed82579ac46d141c63fa9a770d78cd3c14c5eefccdcf6f17b886a15e233fda5df3e8a41ba3273fcdc0ca94ceda1cc3bc35d68c851d44744e96ad8413740d628edaf3b6655e5e0cd3ff109a63828335a077cb9bb4f9c4b041d7a5b5ed17505e08b5bb18c0aa4c88aecd2e07d6f6854ed13f37797bcb522849a4c8327fffc324f1fb72c5b992cc2744991647f738dad956535c293a6944a306f22afc1c59eda5c754787489d0d2a50a6e5a26a11aad08ec9b5e153776f07017c1c0a66951fc1796c2f89373c97d1fc9f87237f2b801a0f8ff8bcfb59ca69149b8291530e32caae39699c425093eae9177df3d5db7b8590446e29a794e0b38275755564f4087faf71dcf" + "cborHex": "590260466d3e314283dca9371b7bcccdaed2cbeb1837994f41b149c8d0d5bb2868d54f078cf67766049fd0b5d4bd5b20699344a6ddd6bf7e7aa3e3b3e29a4ff9c509534d2d8d5ba3d19918857ada0b576ab1117d84db8fced61e3843005f4ee881fdb53b5dc3d52f3cc740ef75b3f34d8345696d07ffdcbdb4d4a85dd247c50255a2a42a5bf4ee3786f31f70e45016960359131c7f7bf8e1b9eef6a37ff32813325f010b8528d7597fc055d4baa937cf8c2574ec23710cbdefcfc90c21dfa6ec7b4ba04e258aa58512c15684f31c1651725690e98e55c9bca1885f53cd05329fb64a546a85cbd4e79e1b8337b588c9a8a8eb982ec8b3f7b8b91748105bf51d597aed717307d888707db129842ec9130638412c1df0e18200ab394b272c827d89a41d0f7257b23acaaddbe1a3c54f57c9a83aac7146884ac4dc71da62b048ffcce5998d5c62b9d4f5d4ae4047684e08fded246d4df6ef05c907bd06f33cd7cabdcaa02cdf8eea932da914755790ae205fc8549ca4480736c36ec410fa39638fec3d33330ac58c3c8dacbc7f22ae025d96ff6adf7a78271fbda6373c759a0e48530b2b71b3f9dff9b2156c81f60d149fbfa26b73ca950ec290a38f89c3a883c0be180bef64f997bd2b13823dda52fb2d763873d119c9662b0685da4d57aa79ab39cc4d01965917b60aa3133e1d0b4906e56d23cda311eccb4ad157c9b007a755bc4ad106a16ba4f7452a226d075465d2003d1081fadfab383ad731a3a10ccb7ce9e27d8ecb4c904d14fbc7c2d856dfb60c2ee74bd4d3a9ab7060b081729542f8aaa6c1980f2bc8b93614cc872062156ca121b3ef0fc2b7bc5fed813bd165802378b6bb2f" } diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.vkey b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.vkey index b6390f34b5f..d6da81420c4 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.vkey +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.kes.vkey @@ -1,5 +1,5 @@ { "type": "KesVerificationKey_ed25519_kes_2^6", "description": "", - "cborHex": "582076d738775942103b9902c108ec2ac4e2637892aa4c988c910ccc4c8ab82bd865" + "cborHex": "58209dd1c37d46c0dc75d66e29a67f345e566bcc89263db35f1f42f32569c239847a" } diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.opcert.json b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.opcert.json index a1acd7e0841..4c1ee3dc6e5 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.opcert.json +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.opcert.json @@ -1,5 +1,5 @@ { "type": "NodeOperationalCertificate", "description": "", - "cborHex": "8284582076d738775942103b9902c108ec2ac4e2637892aa4c988c910ccc4c8ab82bd86500005840d591246f17272414cf94e1b1fba116baa16d6888b06c7cf4f758427b010612de61aadad0f7fa71e5d1c86e6454e9380b09fddf922d45e9dd61c8b5185663d2045820ce681a30a05f0c379ec7743df4a1bfdb82bb3f0b2406e28ac3afe0fecb085539" + "cborHex": "828458209dd1c37d46c0dc75d66e29a67f345e566bcc89263db35f1f42f32569c239847a000058401718b472c90cba367da8ee058998ac76413deb46d2d65b2df4c46af4a5362b8ff1ac6ae270c40b5f4ce8c37c48f99c29885c59435bed1d883d3b664d4580940c5820a1c813eccaea165cd2adf397b7b6929d0029bf94681202800801bafb43e8ff69" } diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.skey b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.skey index af741f7de40..0d9456b2d4d 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.skey +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.skey @@ -1,5 +1,5 @@ { "type": "GenesisDelegateExtendedSigningKey_ed25519_bip32", "description": "", - "cborHex": "5880403a58eb182b4de72ce604f3dba09e082a9d3fa14f73ba1c35c07dc1286c445d7d2faaf92995e45f6d4dffa3a8777ac361d3c4d7eabd45e42ae881810402c002ce681a30a05f0c379ec7743df4a1bfdb82bb3f0b2406e28ac3afe0fecb0855399468d2b9478976e584a40c735354ec70a3b8dac2fc001b17b945c6f0c0450b77" + "cborHex": "588088a686ca441963a7330d0141cd6bc3e4ab608cf0dad128d9126030e1c7fbb44f1fc99f2eb30327183dd09bc7aa9de185d8a2a15dd913f0636d6975010005fbcda1c813eccaea165cd2adf397b7b6929d0029bf94681202800801bafb43e8ff690deed2c13ba147f6fa4864c43e90e153f5f1363de5d5fc3106cdbcd1f120aaf7" } diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vkey b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vkey index e904ea5bc08..eb2c82270a0 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vkey +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vkey @@ -1,5 +1,5 @@ { "type": "GenesisDelegateVerificationKey_ed25519", "description": "", - "cborHex": "5820ce681a30a05f0c379ec7743df4a1bfdb82bb3f0b2406e28ac3afe0fecb085539" + "cborHex": "5820a1c813eccaea165cd2adf397b7b6929d0029bf94681202800801bafb43e8ff69" } diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.skey b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.skey index 27216821d63..4dd8ab5e4e2 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.skey +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.skey @@ -1,5 +1,5 @@ { "type": "VrfSigningKey_PraosVRF", "description": "", - "cborHex": "5840ae3d267b9c09f881280bd486431eb6a05bd8a9dd15e236995c27e59c9e9ffce4b0ed54cbf15f4be47912b405981e7d8622c173094de91f9e3d47f50d1c631986" + "cborHex": "5840d2c94c322ba5e036e4459f9bf806f8df94348c1fe0be4db387af70507b483140c97e76502e2da737e2b07c9b1e893fd10d491b0710af79d849ca13cbd1e692af" } diff --git a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.vkey b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.vkey index c6a6b383702..d5021d051cc 100644 --- a/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.vkey +++ b/lib/local-cluster/test/data/cluster-configs/delegate-keys/shelley.000.vrf.vkey @@ -1,5 +1,5 @@ { "type": "VrfVerificationKey_PraosVRF", "description": "", - "cborHex": "5820b0ed54cbf15f4be47912b405981e7d8622c173094de91f9e3d47f50d1c631986" + "cborHex": "5820c97e76502e2da737e2b07c9b1e893fd10d491b0710af79d849ca13cbd1e692af" } diff --git a/lib/local-cluster/test/data/cluster-configs/genesis-alonzo.json b/lib/local-cluster/test/data/cluster-configs/genesis-alonzo.json deleted file mode 100644 index 3e603806f9d..00000000000 --- a/lib/local-cluster/test/data/cluster-configs/genesis-alonzo.json +++ /dev/null @@ -1,188 +0,0 @@ -{ - "collateralPercentage": 150, - "costModels": { - "PlutusV1": [ - 197209, - 0, - 1, - 1, - 396231, - 621, - 0, - 1, - 150000, - 1000, - 0, - 1, - 150000, - 32, - 2477736, - 29175, - 4, - 29773, - 100, - 29773, - 100, - 29773, - 100, - 29773, - 100, - 29773, - 100, - 29773, - 100, - 100, - 100, - 29773, - 100, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 1000, - 0, - 1, - 150000, - 32, - 150000, - 1000, - 0, - 8, - 148000, - 425507, - 118, - 0, - 1, - 1, - 150000, - 1000, - 0, - 8, - 150000, - 112536, - 247, - 1, - 150000, - 10000, - 1, - 136542, - 1326, - 1, - 1000, - 150000, - 1000, - 1, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 1, - 1, - 150000, - 1, - 150000, - 4, - 103599, - 248, - 1, - 103599, - 248, - 1, - 145276, - 1366, - 1, - 179690, - 497, - 1, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 148000, - 425507, - 118, - 0, - 1, - 1, - 61516, - 11218, - 0, - 1, - 150000, - 32, - 148000, - 425507, - 118, - 0, - 1, - 1, - 148000, - 425507, - 118, - 0, - 1, - 1, - 2477736, - 29175, - 4, - 0, - 82363, - 4, - 150000, - 5000, - 0, - 1, - 150000, - 32, - 197209, - 0, - 1, - 1, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 150000, - 32, - 3345831, - 1, - 1 - ] - }, - "executionPrices": { - "prMem": 5.77e-2, - "prSteps": 7.21e-5 - }, - "lovelacePerUTxOWord": 34482, - "maxBlockExUnits": { - "exUnitsMem": 50000000, - "exUnitsSteps": 40000000000 - }, - "maxCollateralInputs": 3, - "maxTxExUnits": { - "exUnitsMem": 10000000, - "exUnitsSteps": 10000000000 - }, - "maxValueSize": 5000 -} diff --git a/lib/local-cluster/test/data/cluster-configs/genesis-byron.json b/lib/local-cluster/test/data/cluster-configs/genesis-byron.json deleted file mode 100644 index 0218c82c596..00000000000 --- a/lib/local-cluster/test/data/cluster-configs/genesis-byron.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "avvmDistr": {}, - "blockVersionData": { - "heavyDelThd": "300000000000", - "maxBlockSize": "2000000", - "maxHeaderSize": "2000000", - "maxProposalSize": "700", - "maxTxSize": "4096", - "mpcThd": "20000000000000", - "scriptVersion": 0, - "slotDuration": "20000", - "softforkRule": { - "initThd": "900000000000000", - "minThd": "600000000000000", - "thdDecrement": "50000000000000" - }, - "txFeePolicy": { - "multiplier": "43946000000", - "summand": "155381000000000" - }, - "unlockStakeEpoch": "18446744073709551615", - "updateImplicit": "10000", - "updateProposalThd": "100000000000000", - "updateVoteThd": "1000000000000" - }, - "bootStakeholders": { - "dd4194236324c8d89b5f2877eb6b1d5abc23217ecc60076b583902bb": 1 - }, - "heavyDelegation": { - "dd4194236324c8d89b5f2877eb6b1d5abc23217ecc60076b583902bb": { - "cert": "86fe8c7fd9d6475dceacdd7f50e0b428e176a643ede9d08a186e4817ffed4f12fd38e1c29b68f2af9bf9b89ab1545db88a769ccaa274f15d162ed1682268ac02", - "delegatePk": "zmgaMKBfDDeex3Q99KG/24K7PwskBuKKw6/g/ssIVTmUaNK5R4l25YSkDHNTVOxwo7jawvwAGxe5RcbwwEULdw==", - "issuerPk": "siJZ1ewbKx9n3AxeFSegymNvyhhRuZd5B0CkbI8mlt6g6kFBqDtseUNOdp3CZorqPhiZdapS5eEOmHNneqWZOg==", - "omega": 0 - } - }, - "nonAvvmBalances": { - "2657WMsDfac5Gwc9G8G47uNRRWXRRBGHssq5SVy8BAGg3jUfFM8tEgvxdiKhDFwEV": "0", - "2657WMsDfac5djvSd1zzLx9Y3fBe81u6jFA85Ct65Qn5tLs8Z8AyWwGjwCLiEcS82": "45000000000000000" - }, - "protocolConsts": { - "k": 108, - "protocolMagic": 42 - }, - "startTime": 1696255178 -} diff --git a/lib/local-cluster/test/data/cluster-configs/genesis-conway.json b/lib/local-cluster/test/data/cluster-configs/genesis-conway.json deleted file mode 100644 index d9542cbd1a6..00000000000 --- a/lib/local-cluster/test/data/cluster-configs/genesis-conway.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "poolVotingThresholds": { - "pvtCommitteeNormal": 0.51, - "pvtCommitteeNoConfidence": 0.51, - "pvtHardForkInitiation": 0.51, - "pvtMotionNoConfidence": 0.51 - }, - "dRepVotingThresholds": { - "dvtMotionNoConfidence": 0.51, - "dvtCommitteeNormal": 0.51, - "dvtCommitteeNoConfidence": 0.51, - "dvtUpdateToConstitution": 0.51, - "dvtHardForkInitiation": 0.51, - "dvtPPNetworkGroup": 0.51, - "dvtPPEconomicGroup": 0.51, - "dvtPPTechnicalGroup": 0.51, - "dvtPPGovGroup": 0.51, - "dvtTreasuryWithdrawal": 0.51 - }, - "committeeMinSize": 0, - "committeeMaxTermLength": 200, - "govActionLifetime": 10, - "govActionDeposit": 1000000000, - "dRepDeposit": 2000000, - "dRepActivity": 20, - "constitution": { - "anchor": { - "url": "", - "dataHash": "0000000000000000000000000000000000000000000000000000000000000000" - } - }, - "committee": { - "members": {}, - "quorum": 0 - } -} \ No newline at end of file diff --git a/lib/local-cluster/test/data/cluster-configs/genesis-keys/byron.000.key b/lib/local-cluster/test/data/cluster-configs/genesis-keys/byron.000.key index ee52b2f3bda2d9364117d6b3c1067d4f36631b5a..f459c8590d7c73468f6d6f21d9bdfe8629aaa915 100644 GIT binary patch literal 130 zcmV-|0Db>hfWRt96EfqII18K=i;0)iPkh95O2Sv9K_408*jKX=Lmcw>6OQY`k?9AH z*!1B^ZO*=6E&J_al*7XZijh$vU@0Zv@voN_WSwyL8TRcTc?3X;UTU4`V&IOOx)vA} k${v^X(^w!ggnx2ew*9qEbucMNG@i7#Mj7e6=^KDg-&hfEbMuvJ$|_#7vIjuGSj=Zp$;jw65*rlkM^+`&JNkhXp?g0do6)$AK9A7|VQUKJ;x%42WJ7*V;Gc?UqGY>y_E k-k|D1L8v=yc|%Tiox)~{>OL5mb*fV3;SQK{XL_ZXI$KRY8~^|S diff --git a/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.skey b/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.skey index dd590995452..2b2d1b631f1 100644 --- a/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.skey +++ b/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.skey @@ -1,5 +1,5 @@ { "type": "GenesisExtendedSigningKey_ed25519_bip32", "description": "", - "cborHex": "5880188d12b212c0c9c44c8ee2aed61aff6f9577a683bf7a3c9d3f2a8435ef720a5d330df50e49c7fddcfed52ca7abfcf78e238013a6a50002dcc13f8e90b67e3182b22259d5ec1b2b1f67dc0c5e1527a0ca636fca1851b997790740a46c8f2696dea0ea4141a83b6c79434e769dc2668aea3e189975aa52e5e10e9873677aa5993a" + "cborHex": "5880c02a481332e393380b9c158b8997d44f7cc4744ac257a4411f19e3d857b311431cf2f8138eebc291e9078ed8f4e1496dcebe602dfbed6294c3c3078a915121602925dff1af9716649d70f719f6ed1f7904408a5e6a9de962e08e9bba161815ca1e97f5d3582033847f725cb6fdb54e75302948349eb4b74619e9bce91b804fdf" } diff --git a/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.vkey b/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.vkey index 64686288d03..2bc87c67584 100644 --- a/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.vkey +++ b/lib/local-cluster/test/data/cluster-configs/genesis-keys/shelley.000.vkey @@ -1,5 +1,5 @@ { "type": "GenesisExtendedVerificationKey_ed25519_bip32", "description": "", - "cborHex": "5840b22259d5ec1b2b1f67dc0c5e1527a0ca636fca1851b997790740a46c8f2696dea0ea4141a83b6c79434e769dc2668aea3e189975aa52e5e10e9873677aa5993a" + "cborHex": "58402925dff1af9716649d70f719f6ed1f7904408a5e6a9de962e08e9bba161815ca1e97f5d3582033847f725cb6fdb54e75302948349eb4b74619e9bce91b804fdf" } diff --git a/lib/local-cluster/test/data/cluster-configs/node-config.json b/lib/local-cluster/test/data/cluster-configs/node-config.json index 457b1bb45ed..e469b7bee0c 100644 --- a/lib/local-cluster/test/data/cluster-configs/node-config.json +++ b/lib/local-cluster/test/data/cluster-configs/node-config.json @@ -1,9 +1,9 @@ { - "AlonzoGenesisFile": "genesis-alonzo.json", + "AlonzoGenesisFile": "alonzo-genesis.json", "ApplicationName": "cardano-sl", "ApplicationVersion": 0, - "ByronGenesisFile": "genesis-byron.json", - "ConwayGenesisFile": "genesis-conway.json", + "ByronGenesisFile": "byron-genesis.json", + "ConwayGenesisFile": "conway-genesis.json", "EnableP2P": false, "ExperimentalHardForksEnabled": true, "ExperimentalProtocolsEnabled": true, @@ -15,7 +15,7 @@ "PBftSignatureThreshold": 1.1, "Protocol": "Cardano", "RequiresNetworkMagic": "RequiresMagic", - "ShelleyGenesisFile": "genesis-shelley.json", + "ShelleyGenesisFile": "shelley-genesis.json", "TargetNumberOfActivePeers": 20, "TargetNumberOfEstablishedPeers": 50, "TargetNumberOfKnownPeers": 100, diff --git a/lib/local-cluster/test/data/cluster-configs/shelley-genesis.json b/lib/local-cluster/test/data/cluster-configs/shelley-genesis.json new file mode 100644 index 00000000000..5682319fa2f --- /dev/null +++ b/lib/local-cluster/test/data/cluster-configs/shelley-genesis.json @@ -0,0 +1,48 @@ +{ + "activeSlotsCoeff": 5.0e-2, + "epochLength": 21600, + "genDelegs": { + "8a1cebc0df78b69ef71099de3867a78d85b93b57513fc0508b27bee6": { + "delegate": "2103d8279e759d7163d1422467cfb88c19e584adc9506d4b8484a397", + "vrf": "8d8f6e4c0685ca835d7dbe4ec4c240f4d71d0ceb2e4fe1d7bd97b7b3d30f435d" + } + }, + "initialFunds": {}, + "maxKESEvolutions": 62, + "maxLovelaceSupply": 45000000000000000, + "networkId": "Testnet", + "networkMagic": 42, + "protocolParams": { + "a0": 0.3, + "decentralisationParam": 1.0, + "eMax": 18, + "extraEntropy": { + "tag": "NeutralNonce" + }, + "keyDeposit": 2000000, + "maxBlockBodySize": 65536, + "maxBlockHeaderSize": 1100, + "maxTxSize": 16384, + "minFeeA": 44, + "minFeeB": 155381, + "minPoolCost": 340000000, + "minUTxOValue": 1000000, + "nOpt": 150, + "poolDeposit": 500000000, + "protocolVersion": { + "major": 6, + "minor": 0 + }, + "rho": 3.0e-3, + "tau": 0.2 + }, + "securityParam": 108, + "slotLength": 1, + "slotsPerKESPeriod": 129600, + "staking": { + "pools": {}, + "stake": {} + }, + "systemStart": "2024-03-25T10:34:26.544957596Z", + "updateQuorum": 1 +} \ No newline at end of file diff --git a/lib/local-cluster/test/data/cluster-configs/template/conway.json b/lib/local-cluster/test/data/cluster-configs/template/conway.json index 7861a55e19a..5f1de84e6eb 100644 --- a/lib/local-cluster/test/data/cluster-configs/template/conway.json +++ b/lib/local-cluster/test/data/cluster-configs/template/conway.json @@ -1,27 +1,38 @@ { "poolVotingThresholds": { - "pvtCommitteeNormal": 0, - "pvtCommitteeNoConfidence": 0, - "pvtHardForkInitiation": 0, - "pvtMotionNoConfidence": 0 + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "hardForkInitiation": 0.51, + "motionNoConfidence": 0.51, + "ppSecurityGroup": 0.51 }, "dRepVotingThresholds": { - "dvtCommitteeNormal": 0, - "dvtCommitteeNoConfidence": 0, - "dvtHardForkInitiation": 0, - "dvtMotionNoConfidence": 0, - "dvtPPEconomicGroup": 0, - "dvtPPGovGroup": 0, - "dvtPPNetworkGroup": 0, - "dvtPPTechnicalGroup": 0, - "dvtTreasuryWithdrawal": 0, - "dvtUpdateToConstitution": 0 + "motionNoConfidence": 0.51, + "committeeNormal": 0.51, + "committeeNoConfidence": 0.51, + "updateToConstitution": 0.51, + "hardForkInitiation": 0.51, + "ppNetworkGroup": 0.51, + "ppEconomicGroup": 0.51, + "ppTechnicalGroup": 0.51, + "ppGovGroup": 0.51, + "treasuryWithdrawal": 0.51 }, - "genDelegs": {}, - "minCommitteeSize": 0, - "committeeTermLimit": 0, - "govActionExpiration": 0, - "govActionDeposit": 0, - "dRepDeposit": 0, - "dRepActivity": 0 + "committeeMinSize": 0, + "committeeMaxTermLength": 200, + "govActionLifetime": 10, + "govActionDeposit": 1000000000, + "dRepDeposit": 2000000, + "dRepActivity": 20, + "constitution": { + "anchor": { + "url": "", + "dataHash": "0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "committee": { + "members": { + }, + "quorum": 0 + } } diff --git a/lib/local-cluster/test/data/cluster-configs/utxo-keys/byron.000.key b/lib/local-cluster/test/data/cluster-configs/utxo-keys/byron.000.key index a37ab06c51fba22da0915776866b4440729aadca..71b4a27d460dd1c647070ae0af3bc52163e85ca8 100644 GIT binary patch literal 130 zcmV-|0Db>hfNhfcPil(Y`vOse2)aEb Date: Mon, 25 Mar 2024 11:17:50 +0000 Subject: [PATCH 19/24] Add era option to `issuePoolRetirementCert` --- .../lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs index 9e1f1c9cd80..ed9e4bd8372 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs @@ -112,6 +112,7 @@ import Control.Monad.IO.Class ) import Control.Monad.Reader ( MonadReader (..) + , asks ) import Control.Tracer ( traceWith @@ -290,8 +291,10 @@ genStakeAddrKeyPair :: (FileOf "stake-prv", FileOf "stake-pub") -> ClusterM () genStakeAddrKeyPair (stakePrv, stakePub) = do + Config{..} <- ask cli - [ "stake-address" + [ clusterEraToString cfgLastHardFork + , "stake-address" , "key-gen" , "--verification-key-file" , pathOf stakePub @@ -398,10 +401,12 @@ issuePoolRetirementCert -> Word31 -> ClusterM (FileOf "retirement-cert") issuePoolRetirementCert nodeSegment opPub retirementEpoch = do + lastHardFork <- asks cfgLastHardFork poolDir <- askNodeDir nodeSegment let file = poolDir "pool-retirement.cert" cli - [ "stake-pool" + [ clusterEraToString lastHardFork + , "stake-pool" , "deregistration-certificate" , "--cold-verification-key-file" , pathOf opPub From 5523a2c46d26ef6dbae63a3d4c2e9d6b76750e37 Mon Sep 17 00:00:00 2001 From: paolino Date: Mon, 25 Mar 2024 11:56:03 +0000 Subject: [PATCH 20/24] Add deposit amount option and era option to `issueStakeVkCert` --- .../Launch/Cluster/StakeCertificates.hs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/StakeCertificates.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/StakeCertificates.hs index f5a7dbcbd13..6a2b550cf1f 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/StakeCertificates.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/StakeCertificates.hs @@ -11,11 +11,15 @@ import Prelude import Cardano.Wallet.Launch.Cluster.CardanoCLI ( cli ) +import Cardano.Wallet.Launch.Cluster.ClusterEra + ( ClusterEra (..) + , clusterEraToString + ) import Cardano.Wallet.Launch.Cluster.ClusterM ( ClusterM ) import Cardano.Wallet.Launch.Cluster.Config - ( Config (cfgClusterDir) + ( Config (..) ) import Cardano.Wallet.Launch.Cluster.FileOf ( FileOf (..) @@ -40,15 +44,22 @@ issueStakeVkCert -> ClusterM (FileOf "stake-vk-cert") issueStakeVkCert prefix stakePub = do outputDir <- asks cfgClusterDir + lastHardFork <- asks cfgLastHardFork let file = pathOf outputDir untag prefix <> "-stake.cert" - cli - [ "stake-address" + cli $ + [ clusterEraToString lastHardFork + , "stake-address" , "registration-certificate" , "--staking-verification-key-file" , pathOf stakePub , "--out-file" , file - ] + ] <> case lastHardFork of + BabbageHardFork -> [] + ConwayHardFork -> [ + "--key-reg-deposit-amt" + , "1000000" + ] pure $ FileOf file -- | Create a stake address registration certificate from a script From 8f313dd2aed5d86eb5151632acc491cc6a87c570 Mon Sep 17 00:00:00 2001 From: Johannes Lund Date: Mon, 25 Mar 2024 13:04:36 +0100 Subject: [PATCH 21/24] Fix cardano-wallet-unit `binaryCalculationsSpec` expectations --- .../unit/Cardano/Wallet/Shelley/TransactionSpec.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs index 65ad210ab47..6db0d54cc9c 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs @@ -1071,7 +1071,7 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do [ TxOut (dummyAddress 2) (coinToBundle amtChange) ] let binary = case era of - RecentEraConway -> "84a4008182582000000000000000000000000000000000000000000000000000000000000000000001828258390101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011a001e84808258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a0078175c021a0001faa403191e46a1028184582001000000000000000000000000000000000000000000000000000000000000005840d7af60ae33d2af351411c1445c79590526990bfa73cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb36bf38dfe034a9f04658e9f56197ab80f5820000000000000000000000000000000000000000000000000000000000000000041a0f5f6" + RecentEraConway -> "84a400d901028182582000000000000000000000000000000000000000000000000000000000000000000001828258390101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011a001e84808258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a0078175c021a0001faa403191e46a102d90102818458200100000000000000000000000000000000000000000000000000000000000000584005dacf0a9cbb4b5429ca2a31187c71d07c51b1151042076c536308c105069be7d099ed1e0b4be87303c03e8ae02586fb568ad8556cb108c00b8e63bc2adbc6065820000000000000000000000000000000000000000000000000000000000000000041a0f5f6" RecentEraBabbage -> "84a4008182582000000000000000000000000000000000000000000000000000000000000000000001828258390101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011a001e84808258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a0078175c021a0001faa403191e46a1028184582001000000000000000000000000000000000000000000000000000000000000005840d7af60ae33d2af351411c1445c79590526990bfa73cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb36bf38dfe034a9f04658e9f56197ab80f5820000000000000000000000000000000000000000000000000000000000000000041a0f5f6" calculateBinary net utxo outs chgs pairs `shouldBe` binary @@ -1097,7 +1097,7 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do [ TxOut (dummyAddress 4) (coinToBundle amtChange) ] let binary = case era of - RecentEraConway -> "84a4008282582000000000000000000000000000000000000000000000000000000000000000000082582000000000000000000000000000000000000000000000000000000000000000000101838258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a005b8d808258390103030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031a005b8d808258390104040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404041a007801e0021a0002102003191e46a1028284582001000000000000000000000000000000000000000000000000000000000000005840e8e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b81be9b78955728bffa7efa54297c6a5d73337bd6280205b1759c13f79d4c93f29871fc51b78aeba80e5820000000000000000000000000000000000000000000000000000000000000000041a0845820130ae82201d7072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f5158405835ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42ba360d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b4826608fdc5307025506c3075820010101010101010101010101010101010101010101010101010101010101010141a0f5f6" + RecentEraConway -> "84a400d901028282582000000000000000000000000000000000000000000000000000000000000000000082582000000000000000000000000000000000000000000000000000000000000000000101838258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a005b8d808258390103030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031a005b8d808258390104040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404041a007801e0021a0002102003191e46a102d9010282845820010000000000000000000000000000000000000000000000000000000000000058405257f6056570317ebd7a878f032932bdf7a0e9e43f27296a12e22dd5c92f1f08b27c95b182c68ce3b1ed6942f2a4cc63aac7a89530c6086aaa3913685f75060f5820000000000000000000000000000000000000000000000000000000000000000041a0845820130ae82201d7072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f515840b5b781d37d9a31dcbb000d92a461c3bc260e069c24d26d3996c6cadb03ae3ab518e8c7c19bd119fdcf112d4be101d20c7524065722ee0a25d97f31374fe9ef055820010101010101010101010101010101010101010101010101010101010101010141a0f5f6" RecentEraBabbage -> "84a4008282582000000000000000000000000000000000000000000000000000000000000000000082582000000000000000000000000000000000000000000000000000000000000000000101838258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a005b8d808258390103030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031a005b8d808258390104040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404041a007801e0021a0002102003191e46a1028284582001000000000000000000000000000000000000000000000000000000000000005840e8e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b81be9b78955728bffa7efa54297c6a5d73337bd6280205b1759c13f79d4c93f29871fc51b78aeba80e5820000000000000000000000000000000000000000000000000000000000000000041a0845820130ae82201d7072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f5158405835ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42ba360d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b4826608fdc5307025506c3075820010101010101010101010101010101010101010101010101010101010101010141a0f5f6" calculateBinary net utxo outs chgs pairs `shouldBe` binary @@ -1121,7 +1121,7 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do [ TxOut (dummyAddress 2) (coinToBundle amtChange) ] let binary = case era of - RecentEraConway -> "84a4008182582000000000000000000000000000000000000000000000000000000000000000000001828258390101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011a001e84808258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a0078175c021a0001faa403191e46a1028184582001000000000000000000000000000000000000000000000000000000000000005840d7af60ae33d2af351411c1445c79590526990bfa73cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb36bf38dfe034a9f04658e9f56197ab80f5820000000000000000000000000000000000000000000000000000000000000000044a1024100f5f6" + RecentEraConway -> "84a400d901028182582000000000000000000000000000000000000000000000000000000000000000000001828258390101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011a001e84808258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a0078175c021a0001faa403191e46a102d90102818458200100000000000000000000000000000000000000000000000000000000000000584005dacf0a9cbb4b5429ca2a31187c71d07c51b1151042076c536308c105069be7d099ed1e0b4be87303c03e8ae02586fb568ad8556cb108c00b8e63bc2adbc6065820000000000000000000000000000000000000000000000000000000000000000044a1024100f5f6" RecentEraBabbage -> "84a4008182582000000000000000000000000000000000000000000000000000000000000000000001828258390101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011a001e84808258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a0078175c021a0001faa403191e46a1028184582001000000000000000000000000000000000000000000000000000000000000005840d7af60ae33d2af351411c1445c79590526990bfa73cbb3732b54ef322daa142e6884023410f8be3c16e9bd52076f2bb36bf38dfe034a9f04658e9f56197ab80f5820000000000000000000000000000000000000000000000000000000000000000044a1024100f5f6" calculateBinary net utxo outs chgs pairs `shouldBe` binary @@ -1146,7 +1146,9 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do let chgs = [ TxOut (dummyAddress 4) (coinToBundle amtChange) ] - let binary = "84a4008282582000000000000000000000000000000000000000000000000000000000000000000082582000000000000000000000000000000000000000000000000000000000000000000101838258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a005b8d808258390103030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031a005b8d808258390104040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404041a007801e0021a0002102003191e46a10282845820130ae82201d7072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f5158405835ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42ba360d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b4826608fdc5307025506c3075820010101010101010101010101010101010101010101010101010101010101010144a102410084582001000000000000000000000000000000000000000000000000000000000000005840e8e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b81be9b78955728bffa7efa54297c6a5d73337bd6280205b1759c13f79d4c93f29871fc51b78aeba80e5820000000000000000000000000000000000000000000000000000000000000000044a1024100f5f6" + let binary = case era of + RecentEraConway -> "84a400d901028282582000000000000000000000000000000000000000000000000000000000000000000082582000000000000000000000000000000000000000000000000000000000000000000101838258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a005b8d808258390103030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031a005b8d808258390104040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404041a007801e0021a0002102003191e46a102d9010282845820130ae82201d7072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f515840b5b781d37d9a31dcbb000d92a461c3bc260e069c24d26d3996c6cadb03ae3ab518e8c7c19bd119fdcf112d4be101d20c7524065722ee0a25d97f31374fe9ef055820010101010101010101010101010101010101010101010101010101010101010144a1024100845820010000000000000000000000000000000000000000000000000000000000000058405257f6056570317ebd7a878f032932bdf7a0e9e43f27296a12e22dd5c92f1f08b27c95b182c68ce3b1ed6942f2a4cc63aac7a89530c6086aaa3913685f75060f5820000000000000000000000000000000000000000000000000000000000000000044a1024100f5f6" + RecentEraBabbage -> "84a4008282582000000000000000000000000000000000000000000000000000000000000000000082582000000000000000000000000000000000000000000000000000000000000000000101838258390102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021a005b8d808258390103030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031a005b8d808258390104040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404041a007801e0021a0002102003191e46a10282845820130ae82201d7072e6fbfc0a1884fb54636554d14945b799125cf7ce38d477f5158405835ff78c6fc5e4466a179ca659fa85c99b8a3fba083f3f3f42ba360d479c64ef169914b52ade49b19a7208fd63a6e67a19c406b4826608fdc5307025506c3075820010101010101010101010101010101010101010101010101010101010101010144a102410084582001000000000000000000000000000000000000000000000000000000000000005840e8e769ecd0f3c538f0a5a574a1c881775f086d6f4c845b81be9b78955728bffa7efa54297c6a5d73337bd6280205b1759c13f79d4c93f29871fc51b78aeba80e5820000000000000000000000000000000000000000000000000000000000000000044a1024100f5f6" calculateBinary net utxo outs chgs pairs `shouldBe` binary From 622f0e856f36eac52acd4c76239f1b728c1ab287 Mon Sep 17 00:00:00 2001 From: Johannes Lund Date: Mon, 25 Mar 2024 13:22:59 +0100 Subject: [PATCH 22/24] Add missing OpenAPI spec for `errBalanceTxInlinePlutusV3ScriptNotSupportedInBabbage` --- specifications/api/swagger.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index d0167b76445..0b21237b2f6 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -4990,6 +4990,18 @@ x-errBalanceTxConflictingNetworks: &errBalanceTxConflictingNetworks type: string enum: ["balance_tx_conflicting_networks"] +x-errBalanceTxInlinePlutusV3ScriptNotSupportedInBabbage: &errBalanceTxInlinePlutusV3ScriptNotSupportedInBabbage + <<: *responsesErr + title: balance_tx_inline_plutus_v3_script_not_supported_in_babbage + properties: + message: + type: string + description: | + Inline Plutus V3 scripts are not supported in Babbage. + code: + type: string + enum: ["balance_tx_inline_plutus_v3_script_not_supported_in_babbage"] + x-errBalanceTxExistingCollateral: &errBalanceTxExistingCollateral <<: *responsesErr title: balance_tx_existing_collateral @@ -6453,6 +6465,7 @@ x-responsesBalanceTransaction: &responsesBalanceTransaction - <<: *errTransactionIsTooBig - <<: *errUtxoTooSmall - <<: *errTxNotInNodeEra + - <<: *errBalanceTxInlinePlutusV3ScriptNotSupportedInBabbage <<: *responsesErr404WalletNotFound <<: *responsesErr406 From e2ea629c69b9bf2341dbec5c4256c336cb4261db Mon Sep 17 00:00:00 2001 From: Johannes Lund Date: Mon, 25 Mar 2024 13:26:13 +0100 Subject: [PATCH 23/24] Add missing OpenAPI spec for `errTranslationByronTxOutInContext` --- specifications/api/swagger.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index 0b21237b2f6..81511ed8658 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -4990,6 +4990,19 @@ x-errBalanceTxConflictingNetworks: &errBalanceTxConflictingNetworks type: string enum: ["balance_tx_conflicting_networks"] +x-errTranslationByronTxOutInContext: &errTranslationByronTxOutInContext + <<: *responsesErr + title: translation_byron_tx_out_in_context + properties: + message: + type: string + description: | + The given transaction contains a Byron-style TxOut which i not supported when executing + Plutus scripts. + code: + type: string + enum: ["translation_byron_tx_out_in_context"] + x-errBalanceTxInlinePlutusV3ScriptNotSupportedInBabbage: &errBalanceTxInlinePlutusV3ScriptNotSupportedInBabbage <<: *responsesErr title: balance_tx_inline_plutus_v3_script_not_supported_in_babbage @@ -6466,6 +6479,7 @@ x-responsesBalanceTransaction: &responsesBalanceTransaction - <<: *errUtxoTooSmall - <<: *errTxNotInNodeEra - <<: *errBalanceTxInlinePlutusV3ScriptNotSupportedInBabbage + - <<: *errTranslationByronTxOutInContext <<: *responsesErr404WalletNotFound <<: *responsesErr406 From 7ea184bc8a1ae5de38e661dcfdaaaebfc7eb3732 Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Mon, 25 Mar 2024 16:58:03 +0100 Subject: [PATCH 24/24] Fix preparation of stake key registration in `local-cluster` --- .../Cardano/Wallet/Launch/Cluster/Cluster.hs | 8 +++-- .../Cardano/Wallet/Launch/Cluster/Faucet.hs | 22 +++++++++----- .../Wallet/Launch/Cluster/KeyRegistration.hs | 29 +++++++++++++------ 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Cluster.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Cluster.hs index e056803de66..bd6abbf7377 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Cluster.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Cluster.hs @@ -49,7 +49,7 @@ import Cardano.Wallet.Launch.Cluster.GenesisFiles , generateGenesis ) import Cardano.Wallet.Launch.Cluster.KeyRegistration - ( prepareKeyRegistration + ( prepareStakeKeyRegistration ) import Cardano.Wallet.Launch.Cluster.Logging ( ClusterLog (..) @@ -263,11 +263,13 @@ withCluster config@Config{..} faucetFunds onClusterStart = runClusterM config sendFaucetAssetsTo conn 20 maryAllegraFunds -- Should ideally not be hard-coded in 'withCluster' - (rawTx, faucetPrv) <- prepareKeyRegistration + (rawTx, faucetPrv, stakePrv) <- prepareStakeKeyRegistration signAndSubmitTx conn (changeFileOf @"reg-tx" @"tx-body" rawTx) - [changeFileOf @"faucet-prv" @"signing-key" faucetPrv] + [ changeFileOf @"faucet-prv" @"signing-key" faucetPrv + , changeFileOf @"stake-prv" @"signing-key" stakePrv + ] "pre-registered stake key" -- Give the above txs a chance of getting included into the chain diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs index 5c066ad11ab..53c9acf39a9 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs @@ -8,7 +8,7 @@ module Cardano.Wallet.Launch.Cluster.Faucet , readFaucetAddresses , faucetAmt , depositAmt - , preRegisteredStakeKey + , preRegisteredStakeKeyPair , resetGlobals , sendFaucetFundsTo , sendFaucetAssetsTo @@ -201,23 +201,31 @@ resetGlobals :: IO () resetGlobals = do void $ swapMVar faucetIndex 1 --- | A public stake key associated with a mnemonic that we pre-registered for --- STAKE_POOLS_JOIN_05. +-- | A public stake key pair +-- associated with a mnemonic that we pre-registered for STAKE_POOLS_JOIN_05. -- -- ["over", "decorate", "flock", "badge", "beauty" -- , "stamp", "chest", "owner", "excess", "omit" -- , "bid", "raccoon", "spin", "reduce", "rival" -- ] -preRegisteredStakeKey - :: Aeson.Value -preRegisteredStakeKey = - Aeson.object +preRegisteredStakeKeyPair + :: (Aeson.Value, Aeson.Value) +preRegisteredStakeKeyPair = + ( Aeson.object [ "type" .= Aeson.String "StakeVerificationKeyShelley_ed25519" , "description" .= Aeson.String "Free form text" , "cborHex" .= Aeson.String "5820949fc9e6b7e1e12e933ac35de5a565c9264b0ac5b631b4f5a21548bc6d65616f" ] + , Aeson.object + [ "type" .= Aeson.String "StakeExtendedSigningKeyShelley_ed25519_bip32" + , "description" .= Aeson.String "Free form text" + , "cborHex" + .= Aeson.String + "5880784cda4d590b72c795792ec5d05b2a4216d153e36dad0b5376b6ea6308008d4e3cb0088852dce3b89577c7a4fb262ebf6a71f44f2c8ca45794ccfaa76bd95bcb949fc9e6b7e1e12e933ac35de5a565c9264b0ac5b631b4f5a21548bc6d65616f3042af27ce48e0fce0f88696b6ed3476f8c3412cce2f984931fb7658dee1872e" + ] + ) -- | Deposit amount required for registering certificates. depositAmt :: Integer diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/KeyRegistration.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/KeyRegistration.hs index 6b3fc77d335..538c3b787f5 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/KeyRegistration.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/KeyRegistration.hs @@ -4,7 +4,7 @@ {-# LANGUAGE TypeApplications #-} module Cardano.Wallet.Launch.Cluster.KeyRegistration - ( prepareKeyRegistration + ( prepareStakeKeyRegistration ) where @@ -25,7 +25,7 @@ import Cardano.Wallet.Launch.Cluster.Config import Cardano.Wallet.Launch.Cluster.Faucet ( depositAmt , faucetAmt - , preRegisteredStakeKey + , preRegisteredStakeKeyPair , takeFaucet ) import Cardano.Wallet.Launch.Cluster.FileOf @@ -53,17 +53,28 @@ import System.FilePath import qualified Data.Aeson as Aeson --- | Generate a raw transaction. We kill two birds one stone here by also +-- | Generate a raw transaction that registers a staking certificate. +-- We kill two birds one stone here by also -- automatically delegating 'pledge' amount to the given stake key. -prepareKeyRegistration - :: ClusterM (FileOf "reg-tx" , FileOf "faucet-prv") -prepareKeyRegistration = do +prepareStakeKeyRegistration + :: ClusterM + ( FileOf "reg-tx" + , FileOf "faucet-prv" + , FileOf "stake-prv" + ) +prepareStakeKeyRegistration = do Config{..} <- ask let file = pathOf cfgClusterDir "tx.raw" let stakePub = FileOf @"stake-pub" - $ pathOf cfgClusterDir "pre-registered-stake.pub" - liftIO $ Aeson.encodeFile (pathOf stakePub) preRegisteredStakeKey + $ pathOf cfgClusterDir "pre-registered-stake.vkey" + stakePrv = + FileOf @"stake-prv" + $ pathOf cfgClusterDir "pre-registered-stake.skey" + liftIO $ do + let (pub, prv) = preRegisteredStakeKeyPair + Aeson.encodeFile (pathOf stakePub) pub + Aeson.encodeFile (pathOf stakePrv) prv (faucetInput, faucetPrv) <- takeFaucet cert <- issueStakeVkCert @@ -87,4 +98,4 @@ prepareKeyRegistration = do , "--out-file" , file ] - pure (FileOf @"reg-tx" file, faucetPrv) + pure (FileOf @"reg-tx" file, faucetPrv, stakePrv)