From c90d7f6831f32cde42e5911394c2455c40ea8f75 Mon Sep 17 00:00:00 2001 From: John Ky Date: Wed, 29 Nov 2023 00:43:56 +1100 Subject: [PATCH 1/5] Transaction integration test --- cardano-testnet/cardano-testnet.cabal | 2 + .../Testnet/Test/Cli/Babbage/Transaction.hs | 137 ++++++++++++++++++ .../cardano-testnet-test.hs | 2 + 3 files changed, 141 insertions(+) create mode 100644 cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index 0c63020eacb..c1a6bcd0acc 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -160,6 +160,7 @@ test-suite cardano-testnet-test other-modules: Cardano.Testnet.Test.Cli.Alonzo.LeadershipSchedule Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot + Cardano.Testnet.Test.Cli.Babbage.Transaction Cardano.Testnet.Test.Cli.Conway.StakeSnapshot Cardano.Testnet.Test.Cli.KesPeriodInfo Cardano.Testnet.Test.Cli.QuerySlotNumber @@ -182,6 +183,7 @@ test-suite cardano-testnet-test , filepath , hedgehog , hedgehog-extras + , microlens , process , tasty , text diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs new file mode 100644 index 00000000000..a672f5f4a27 --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs @@ -0,0 +1,137 @@ +{-# LANGUAGE DisambiguateRecordFields #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} +{-# LANGUAGE LambdaCase #-} + +{- HLINT ignore "Redundant id" -} +{- HLINT ignore "Redundant return" -} +{- HLINT ignore "Use head" -} +{- HLINT ignore "Use let" -} + +module Cardano.Testnet.Test.Cli.Babbage.Transaction + ( hprop_transaction + ) where + +import Cardano.Api + +import Cardano.Testnet + +import Prelude + +import Control.Monad (void) +import qualified Data.Text as Text +import System.FilePath (()) +import qualified System.Info as SYS + +import Hedgehog (Property) +import qualified Hedgehog as H +import qualified Hedgehog.Extras.Test.Base as H +import qualified Hedgehog.Extras.Test.File as H + +import qualified Cardano.Api.Ledger.Lens as A +import qualified Data.Map as Map +import Testnet.Components.SPO +import qualified Testnet.Process.Run as H +import Testnet.Process.Run +import qualified Testnet.Property.Utils as H +import Testnet.Runtime + +import qualified Cardano.Api.Ledger as L +import qualified Data.List as List +import Lens.Micro + +hprop_transaction :: Property +hprop_transaction = H.integrationRetryWorkspace 0 "babbage-transaction" $ \tempAbsBasePath' -> do + H.note_ SYS.os + conf@Conf { tempAbsPath } <- H.noteShowM $ mkConf tempAbsBasePath' + let tempAbsPath' = unTmpAbsPath tempAbsPath + work <- H.createDirectoryIfMissing $ tempAbsPath' "work" + + let + sbe = ShelleyBasedEraBabbage + era = toCardanoEra sbe + tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' + options = cardanoDefaultTestnetOptions + { cardanoNodes = cardanoDefaultTestnetNodeOptions + , cardanoSlotLength = 0.1 + , cardanoNodeEra = AnyCardanoEra era -- TODO: We should only support the latest era and the upcoming era + } + + TestnetRuntime + { testnetMagic + , poolNodes + , wallets + } <- cardanoTestnet options conf + + poolNode1 <- H.headM poolNodes + + poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 + + execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 + + + txbodyFp <- H.note $ work "tx.body" + txbodySignedFp <- H.note $ work "tx.body.signed" + + void $ execCli' execConfig + [ "babbage", "query", "utxo" + , "--address", Text.unpack $ paymentKeyInfoAddr $ head wallets + , "--cardano-mode" + , "--testnet-magic", show @Int testnetMagic + , "--out-file", work "utxo-1.json" + ] + + utxo1Json <- H.leftFailM . H.readJsonFile $ work "utxo-1.json" + UTxO utxo1 <- H.noteShowM $ H.noteShowM $ decodeEraUTxO sbe utxo1Json + txin1 <- H.noteShow =<< H.headM (Map.keys utxo1) + + void $ execCli' execConfig + [ "babbage", "transaction", "build" + , "--testnet-magic", show @Int testnetMagic + , "--change-address", Text.unpack $ paymentKeyInfoAddr $ head wallets + , "--tx-in", Text.unpack $ renderTxIn txin1 + , "--tx-out", Text.unpack (paymentKeyInfoAddr (head wallets)) <> "+" <> show @Int 5_000_001 + , "--out-file", txbodyFp + ] + + void $ execCli' execConfig + [ "babbage", "transaction", "sign" + , "--testnet-magic", show @Int testnetMagic + , "--tx-body-file", txbodyFp + , "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 0 + , "--out-file", txbodySignedFp + ] + + void $ execCli' execConfig + [ "babbage", "transaction", "submit" + , "--testnet-magic", show @Int testnetMagic + , "--tx-file", txbodySignedFp + ] + + H.byDurationM 1 10 "Expected UTxO found" $ do + void $ execCli' execConfig + [ "babbage", "query", "utxo" + , "--address", Text.unpack $ paymentKeyInfoAddr $ head wallets + , "--cardano-mode" + , "--testnet-magic", show @Int testnetMagic + , "--out-file", work "utxo-2.json" + ] + + utxo2Json <- H.leftFailM . H.readJsonFile $ work "utxo-2.json" + UTxO utxo2 <- H.noteShowM $ H.noteShowM $ decodeEraUTxO sbe utxo2Json + txouts2 <- H.noteShow $ L.unCoin . txOutValueLovelace . txOutValue . snd <$> Map.toList utxo2 + + H.assert $ 5_000_001 `List.elem` txouts2 + +txOutValue :: TxOut ctx era -> TxOutValue era +txOutValue (TxOut _ v _ _) = v + +txOutValueLovelace ::TxOutValue era -> L.Coin +txOutValueLovelace = \case + TxOutValueShelleyBased sbe v -> v ^. A.adaAssetL sbe + TxOutValueByron (Lovelace v) -> L.Coin v diff --git a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs index 86eda6adebf..7b234f26d71 100644 --- a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs +++ b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs @@ -7,6 +7,7 @@ module Main import qualified Cardano.Crypto.Init as Crypto import qualified Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule import qualified Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot +import qualified Cardano.Testnet.Test.Cli.Babbage.Transaction import qualified Cardano.Testnet.Test.Cli.KesPeriodInfo import qualified Cardano.Testnet.Test.Cli.QuerySlotNumber import qualified Cardano.Testnet.Test.FoldBlocks @@ -37,6 +38,7 @@ tests = pure $ T.testGroup "test/Spec.hs" -- this should remedy. Double check and make sure we have re-enabled it and remove this comment. [ H.ignoreOnMacAndWindows "leadership-schedule" Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule.hprop_leadershipSchedule -- FAILS , H.ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot.hprop_stakeSnapshot + , H.ignoreOnWindows "transaction" Cardano.Testnet.Test.Cli.Babbage.Transaction.hprop_transaction ] -- TODO: Conway - Re-enable when create-staked is working in conway again --, T.testGroup "Conway" From dece62aeadb1919996704b910b838622e2e6d20d Mon Sep 17 00:00:00 2001 From: Nadia Yvette Chambers Date: Thu, 2 Nov 2023 14:16:17 -0400 Subject: [PATCH 2/5] plutus-scripts-bench: Add PlutusV3 PlutusV3 support for the tx-generator is added and exercised via a testcase. The fallback script in LoopV3.plutus is for ghc versions before 9.x; more recent ones generate it via TH from LoopV3.hs. The ApiTest is invoked in a manner exercising PlutusV3 via cabal run tx-generator-apitest -- \ --nix-json ./bench/tx-generator/data/run-script.json \ --run ./run/current/generator/ \ --param data/protocol-parameters-conway.json --- .../plutus-scripts-bench.cabal | 3 +- .../src/Cardano/Benchmarking/PlutusScripts.hs | 9 +- .../Benchmarking/PlutusScripts/LoopV3.hs | 46 ++ .../data/protocol-parameters-conway.json | 612 ++++++++++++++++++ bench/tx-generator/data/run-script.json | 32 + .../scripts-fallback/LoopV3.plutus | 5 + .../src/Cardano/TxGenerator/Fund.hs | 1 + .../src/Cardano/TxGenerator/Setup/Plutus.hs | 86 ++- bench/tx-generator/test/ApiTest.hs | 80 ++- 9 files changed, 846 insertions(+), 28 deletions(-) create mode 100644 bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/LoopV3.hs create mode 100644 bench/tx-generator/data/protocol-parameters-conway.json create mode 100644 bench/tx-generator/data/run-script.json create mode 100644 bench/tx-generator/scripts-fallback/LoopV3.plutus diff --git a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal index 874988ecf7b..23efd8e1c44 100644 --- a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal +++ b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: plutus-scripts-bench -version: 1.0.0.6 +version: 1.0.1.0 synopsis: Plutus scripts used for benchmarking description: Plutus scripts used for benchmarking. category: Cardano, @@ -66,6 +66,7 @@ library Cardano.Benchmarking.PlutusScripts.CustomCall Cardano.Benchmarking.PlutusScripts.EcdsaSecp256k1Loop Cardano.Benchmarking.PlutusScripts.Loop + Cardano.Benchmarking.PlutusScripts.LoopV3 Cardano.Benchmarking.PlutusScripts.SchnorrSecp256k1Loop -------------------------- diff --git a/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts.hs b/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts.hs index 9b4769e7f2a..bf06198c636 100644 --- a/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts.hs +++ b/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts.hs @@ -17,15 +17,16 @@ module Cardano.Benchmarking.PlutusScripts import Prelude import Data.ByteString.Lazy as LBS (ByteString) -import Data.Text(split, pack) -import Data.List(find) -import System.FilePath(takeBaseName) +import Data.List (find) +import Data.Text (pack, split) +import System.FilePath (takeBaseName) import Cardano.Api import qualified Cardano.Benchmarking.PlutusScripts.CustomCall as CustomCall import qualified Cardano.Benchmarking.PlutusScripts.EcdsaSecp256k1Loop as ECDSA import qualified Cardano.Benchmarking.PlutusScripts.Loop as Loop +import qualified Cardano.Benchmarking.PlutusScripts.LoopV3 as LoopV3 import qualified Cardano.Benchmarking.PlutusScripts.SchnorrSecp256k1Loop as Schnorr import Cardano.Benchmarking.ScriptAPI @@ -35,6 +36,7 @@ getAllScripts = [ CustomCall.script , ECDSA.script , Loop.script + , LoopV3.script , Schnorr.script ] @@ -59,6 +61,7 @@ encodePlutusScript = \case ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV1) s -> textEnvelopeToJSON Nothing s ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2) s -> textEnvelopeToJSON Nothing s + ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV3) s -> textEnvelopeToJSON Nothing s _ -> "{}" diff --git a/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/LoopV3.hs b/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/LoopV3.hs new file mode 100644 index 00000000000..a84b5a87e12 --- /dev/null +++ b/bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/LoopV3.hs @@ -0,0 +1,46 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} + +module Cardano.Benchmarking.PlutusScripts.LoopV3 (script) where + +import Language.Haskell.TH +import Language.Haskell.TH.Syntax +import Prelude hiding (pred, ($), (&&), (<), (==)) + +import Cardano.Api.Shelley (PlutusScript (..), PlutusScriptV3, PlutusScriptVersion (..), + Script (..), toScriptInAnyLang) +import Cardano.Benchmarking.ScriptAPI +import qualified Data.ByteString.Short as SBS + +import qualified PlutusLedgerApi.V3 as PlutusV3 +import PlutusTx +import PlutusTx.Builtins (unsafeDataAsI) +import PlutusTx.Prelude hiding (Semigroup (..), unless, (.), (<$>)) + + +scriptName :: String +scriptName + = prepareScriptName $(LitE . StringL . loc_module <$> qLocation) + +script :: PlutusBenchScript +script = mkPlutusBenchScript scriptName (toScriptInAnyLang (PlutusScript PlutusScriptV3 scriptSerialized)) + + +{-# INLINABLE mkValidator #-} +mkValidator :: BuiltinData -> BuiltinData -> BuiltinData -> () +mkValidator _datum redeemer _txContext + = if n < 1000000 + then traceError "redeemer is < 1000000" + else loop n + where + n = unsafeDataAsI redeemer + loop i = if i == 1000000 then () else loop $ pred i + +loopScriptShortBs :: SBS.ShortByteString +loopScriptShortBs = PlutusV3.serialiseCompiledCode $$(PlutusTx.compile [|| mkValidator ||]) + +scriptSerialized :: PlutusScript PlutusScriptV3 +scriptSerialized = PlutusScriptSerialised loopScriptShortBs diff --git a/bench/tx-generator/data/protocol-parameters-conway.json b/bench/tx-generator/data/protocol-parameters-conway.json new file mode 100644 index 00000000000..47166173e73 --- /dev/null +++ b/bench/tx-generator/data/protocol-parameters-conway.json @@ -0,0 +1,612 @@ +{ + "collateralPercentage": 150, + "costModels": { + "PlutusV1": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 3345831, + 1, + 1 + ], + "PlutusV2": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10 + ], + "PlutusV3": + { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b_224-cpu-arguments-intercept": 117366, + "blake2b_224-cpu-arguments-slope": 10475, + "blake2b_224-memory-arguments": 4, + "blake2b_256-cpu-arguments-intercept": 117366, + "blake2b_256-cpu-arguments-slope": 10475, + "blake2b_256-memory-arguments": 4, + "bls12_381_G1_add-cpu-arguments": 1046420, + "bls12_381_G1_add-memory-arguments": 18, + "bls12_381_G1_compress-cpu-arguments": 3387741, + "bls12_381_G1_compress-memory-arguments": 6, + "bls12_381_G1_equal-cpu-arguments": 545063, + "bls12_381_G1_equal-memory-arguments": 1, + "bls12_381_G1_hashToGroup-cpu-arguments-intercept": 66311195, + "bls12_381_G1_hashToGroup-cpu-arguments-slope": 23097, + "bls12_381_G1_hashToGroup-memory-arguments": 18, + "bls12_381_G1_neg-cpu-arguments": 292890, + "bls12_381_G1_neg-memory-arguments": 18, + "bls12_381_G1_scalarMul-cpu-arguments-intercept": 94607019, + "bls12_381_G1_scalarMul-cpu-arguments-slope": 87060, + "bls12_381_G1_scalarMul-memory-arguments": 18, + "bls12_381_G1_uncompress-cpu-arguments": 16598737, + "bls12_381_G1_uncompress-memory-arguments": 18, + "bls12_381_G2_add-cpu-arguments": 2359410, + "bls12_381_G2_add-memory-arguments": 36, + "bls12_381_G2_compress-cpu-arguments": 3973992, + "bls12_381_G2_compress-memory-arguments": 12, + "bls12_381_G2_equal-cpu-arguments": 1102635, + "bls12_381_G2_equal-memory-arguments": 1, + "bls12_381_G2_hashToGroup-cpu-arguments-intercept": 204557793, + "bls12_381_G2_hashToGroup-cpu-arguments-slope": 23271, + "bls12_381_G2_hashToGroup-memory-arguments": 36, + "bls12_381_G2_neg-cpu-arguments": 307813, + "bls12_381_G2_neg-memory-arguments": 36, + "bls12_381_G2_scalarMul-cpu-arguments-intercept": 190191402, + "bls12_381_G2_scalarMul-cpu-arguments-slope": 85902, + "bls12_381_G2_scalarMul-memory-arguments": 36, + "bls12_381_G2_uncompress-cpu-arguments": 33191512, + "bls12_381_G2_uncompress-memory-arguments": 36, + "bls12_381_finalVerify-cpu-arguments": 388656972, + "bls12_381_finalVerify-memory-arguments": 1, + "bls12_381_millerLoop-cpu-arguments": 402099373, + "bls12_381_millerLoop-memory-arguments": 72, + "bls12_381_mulMlResult-cpu-arguments": 2544991, + "bls12_381_mulMlResult-memory-arguments": 72, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekCaseCost-exBudgetCPU": 23000, + "cekCaseCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekConstrCost-exBudgetCPU": 23000, + "cekConstrCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "keccak_256-cpu-arguments-intercept": 1927926, + "keccak_256-cpu-arguments-slope": 82523, + "keccak_256-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "serialiseData-cpu-arguments-intercept": 1159724, + "serialiseData-cpu-arguments-slope": 392670, + "serialiseData-memory-arguments-intercept": 0, + "serialiseData-memory-arguments-slope": 2, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 35190005, + "verifyEcdsaSecp256k1Signature-memory-arguments": 10, + "verifyEd25519Signature-cpu-arguments-intercept": 57996947, + "verifyEd25519Signature-cpu-arguments-slope": 18975, + "verifyEd25519Signature-memory-arguments": 10, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 39121781, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32260, + "verifySchnorrSecp256k1Signature-memory-arguments": 10 + } + }, + "decentralization": null, + "executionUnitPrices": { + "priceMemory": 0.0577, + "priceSteps": 7.21e-05 + }, + "extraPraosEntropy": null, + "maxBlockBodySize": 90112, + "maxBlockExecutionUnits": { + "memory": 62000000, + "steps": 40000000000 + }, + "maxBlockHeaderSize": 1100, + "maxCollateralInputs": 3, + "maxTxExecutionUnits": { + "memory": 14000000, + "steps": 10000000000 + }, + "maxTxSize": 16384, + "maxValueSize": 5000, + "minPoolCost": 340000000, + "minUTxOValue": null, + "monetaryExpansion": 0.003, + "poolPledgeInfluence": 0.3, + "poolRetireMaxEpoch": 18, + "protocolVersion": { + "major": 8, + "minor": 0 + }, + "stakeAddressDeposit": 2000000, + "stakePoolDeposit": 500000000, + "stakePoolTargetNum": 500, + "treasuryCut": 0.2, + "txFeeFixed": 155381, + "txFeePerByte": 44, + "utxoCostPerByte": 538, + "utxoCostPerWord": null +} diff --git a/bench/tx-generator/data/run-script.json b/bench/tx-generator/data/run-script.json new file mode 100644 index 00000000000..e63421f5ef3 --- /dev/null +++ b/bench/tx-generator/data/run-script.json @@ -0,0 +1,32 @@ +{ + "add_tx_size": 100, + "debugMode": false, + "era": "Conway", + "init_cooldown": 5, + "inputs_per_tx": 2, + "localNodeSocketPath": "../node-0/node.socket", + "min_utxo_value": 10000000, + "nodeConfigFile": "../node-0/config.json", + "outputs_per_tx": 2, + "plutus": { + "type": "LimitSaturationLoop", + "script": { + "Left": "LoopV3" + } + }, + "sigKey": "../genesis/utxo-keys/utxo1.skey", + "targetNodes": [ + { + "addr": "127.0.0.1", + "port": 30000 + }, + { + "addr": "127.0.0.1", + "port": 30001 + } + ], + "tps": 15, + "tx_count": 9000, + "tx_fee": 1000000, + "pools": [] +} diff --git a/bench/tx-generator/scripts-fallback/LoopV3.plutus b/bench/tx-generator/scripts-fallback/LoopV3.plutus new file mode 100644 index 00000000000..75cc7003f90 --- /dev/null +++ b/bench/tx-generator/scripts-fallback/LoopV3.plutus @@ -0,0 +1,5 @@ +{ + "type": "PlutusScriptV3", + "description": "", + "cborHex": "583e583c010100322225333573466e20dd68012410112f42c260086eb4008c8c00400488c94ccd5cd19b874820225e800860002600266e040092002300200201" +} diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs b/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs index 74131f74984..dbf23f36742 100644 --- a/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs +++ b/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs @@ -83,6 +83,7 @@ getFundWitness fund = case (cardanoEra @era, fund) of (MaryEra , Fund (InAnyCardanoEra MaryEra a)) -> _fundWitness a (AlonzoEra , Fund (InAnyCardanoEra AlonzoEra a)) -> _fundWitness a (BabbageEra , Fund (InAnyCardanoEra BabbageEra a)) -> _fundWitness a + (ConwayEra , Fund (InAnyCardanoEra ConwayEra a)) -> _fundWitness a _ -> error "getFundWitness: era mismatch" {- diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs b/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs index c9a7ccc41cc..cfd21e6b4d9 100644 --- a/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs +++ b/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs @@ -4,7 +4,10 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} --- | This module provides convenience functions when dealing with Plutus scripts. +{-| +Module : Cardano.TxGenerator.Setup.Plutus +Description : Convenience functions for dealing with Plutus scripts + -} module Cardano.TxGenerator.Setup.Plutus ( readPlutusScript , preExecutePlutusScript @@ -12,6 +15,7 @@ module Cardano.TxGenerator.Setup.Plutus where import Data.Bifunctor +import Data.ByteString.Short (ShortByteString) import Data.Map.Strict as Map (lookup) import Control.Monad.Trans.Except @@ -27,27 +31,35 @@ import Cardano.Ledger.Alonzo.Plutus.TxInfo (exBudgetToExUnits) import qualified PlutusLedgerApi.V1 as PlutusV1 import qualified PlutusLedgerApi.V2 as PlutusV2 +import qualified PlutusLedgerApi.V3 as PlutusV3 +import qualified PlutusTx.AssocMap as AssocMap (empty) -import Cardano.TxGenerator.Types +import Cardano.TxGenerator.Types (TxGenError (..)) #ifdef WITH_LIBRARY import Cardano.Benchmarking.PlutusScripts (findPlutusScript) #else -import Control.Exception (SomeException(..), try) +import Control.Exception (SomeException (..), try) import Paths_tx_generator #endif type ProtocolVersion = (Int, Int) - +-- | 'readPlutusScript' accepts a string for the name of a script that +-- may be known in the 'Left' case and a filepath to read as a script +-- in the 'Right' case. API errors are signalled via an 'Either'. +-- What the @WITH_LIBRARY@ flag signifies is to use a set of statically- +-- defined (via TH) scripts for the script name lookups instead of a +-- set of library files. readPlutusScript :: Either String FilePath -> IO (Either TxGenError ScriptInAnyLang) -readPlutusScript (Left s) #ifdef WITH_LIBRARY +readPlutusScript (Left s) = pure $ maybe (Left . TxGenError $ "readPlutusScript: " ++ s ++ " not found.") Right (findPlutusScript s) #else +readPlutusScript (Left s) = try (getDataFileName $ "scripts-fallback/" ++ s ++ ".plutus") >>= either (\(SomeException e) -> pure $ Left $ TxGenError $ show e) (readPlutusScript . Right) @@ -61,6 +73,13 @@ readPlutusScript (Right fp) ScriptInAnyLang (PlutusScriptLanguage _) _ -> pure script ScriptInAnyLang lang _ -> throwE $ TxGenError $ "readPlutusScript: only PlutusScript supported, found: " ++ show lang +-- | 'preExecutePlutusScript' is a front end for the internal +-- @preExecutePlutusVn@ functions used to calculate 'ExecutionUnits' +-- that switches on Plutus versions. The +-- 'PlutusV1.evaluateScriptCounting', 'PlutusV2.evaluateScriptCounting' +-- and 'PlutusV3.evaluateScriptCounting' functions do the actual work on +-- the script's binary representation to count the number of execution +-- units needed. preExecutePlutusScript :: ProtocolParameters -> ScriptInAnyLang @@ -85,6 +104,8 @@ preExecutePlutusScript hoistEither $ preExecutePlutusV1 protocolVersion script' datum redeemer costModel ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2) script' -> hoistEither $ preExecutePlutusV2 protocolVersion script' datum redeemer costModel + ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV3) script' -> + hoistEither $ preExecutePlutusV3 protocolVersion script' datum redeemer costModel _ -> throwE $ TxGenError $ "preExecutePlutusScript: script not supported: " ++ show scriptLang where @@ -192,5 +213,60 @@ preExecutePlutusV2 (major, _minor) (PlutusScript _ (PlutusScriptSerialised scrip , PlutusV2.txInfoRedeemers = PlutusV2.fromList [] } +preExecutePlutusV3 :: + ProtocolVersion + -> Script PlutusScriptV3 + -> ScriptData + -> ScriptRedeemer + -> CostModel + -> Either TxGenError ExecutionUnits +preExecutePlutusV3 (major, _minor) (PlutusScript _ (PlutusScriptSerialised (script :: ShortByteString {- a.k.a. SerialisedScript -}))) datum redeemer costModel + = fst $ runWriter $ runExceptT go -- for now, we discard warnings (:: PlutusCore.Evaluation.Machine.CostModelInterface.CostModelApplyWarn) + where + protocolVersion = PlutusV3.MajorProtocolVersion major + go + = do + evaluationContext <- firstExceptT PlutusError $ + PlutusV3.mkEvaluationContext (flattenCostModel costModel) + + scriptForEval <- withExceptT PlutusError $ PlutusV3.deserialiseScript protocolVersion script + exBudget <- firstExceptT PlutusError $ + hoistEither . + snd $ PlutusV3.evaluateScriptCounting protocolVersion PlutusV3.Verbose evaluationContext scriptForEval + [ toPlutusData datum + , toPlutusData (getScriptData redeemer) + , PlutusV3.toData dummyContext + ] + + x <- hoistMaybe (TxGenError "preExecutePlutusV3: could not convert to execution units") $ + exBudgetToExUnits exBudget + return $ fromAlonzoExUnits x + + dummyContext :: PlutusV3.ScriptContext + dummyContext = PlutusV3.ScriptContext dummyTxInfo (PlutusV3.Spending dummyOutRef) + + dummyOutRef :: PlutusV3.TxOutRef + dummyOutRef = PlutusV3.TxOutRef (PlutusV3.TxId "") 0 + + dummyTxInfo :: PlutusV3.TxInfo + dummyTxInfo = PlutusV3.TxInfo + { PlutusV3.txInfoInputs = [] + , PlutusV3.txInfoOutputs = [] + , PlutusV3.txInfoFee = mempty + , PlutusV3.txInfoMint = mempty + , PlutusV3.txInfoTxCerts = [] + , PlutusV3.txInfoWdrl = PlutusV3.fromList [] + , PlutusV3.txInfoValidRange = PlutusV3.always + , PlutusV3.txInfoSignatories = [] + , PlutusV3.txInfoData = PlutusV3.fromList [] + , PlutusV3.txInfoId = PlutusV3.TxId "" + , PlutusV3.txInfoReferenceInputs = [] + , PlutusV3.txInfoRedeemers = PlutusV3.fromList [] + , PlutusV3.txInfoVotes = AssocMap.empty + , PlutusV3.txInfoProposalProcedures = [] + , PlutusV3.txInfoCurrentTreasuryAmount = Nothing + , PlutusV3.txInfoTreasuryDonation = Nothing + } + flattenCostModel :: CostModel -> [Integer] flattenCostModel (CostModel cm) = cm diff --git a/bench/tx-generator/test/ApiTest.hs b/bench/tx-generator/test/ApiTest.hs index 887e78aeff0..540123943e9 100644 --- a/bench/tx-generator/test/ApiTest.hs +++ b/bench/tx-generator/test/ApiTest.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} @@ -13,6 +14,7 @@ module Main (main) where import Control.Arrow import Control.Monad +import Control.Monad.IO.Class import Control.Monad.Trans.Except import Control.Monad.Trans.Except.Extra import Data.Aeson (FromJSON, eitherDecodeFileStrict', encode) @@ -60,6 +62,7 @@ import Paths_tx_generator data CommandLine = CommandLine { runPath :: FilePath , nixServiceJson :: FilePath + , protoParamPath :: FilePath } deriving Show @@ -107,28 +110,56 @@ main case setup of Left err -> die (show err) Right (nixService, _nc, genesis, sigKey) -> do - putStrLn $ "* Did I manage to extract a genesis fund?\n--> " ++ show (checkFund genesis sigKey) + putStrLn $ "* Did I manage to extract a genesis fund?\n--> " ++ checkFund nixService genesis sigKey putStrLn "* Can I pre-execute a plutus script?" let plutus = _nix_plutus nixService case plutusType <$> plutus of - Just LimitSaturationLoop -> checkPlutusLoop plutus - Just BenchCustomCall -> checkPlutusBuiltin - _ -> pure () + Just LimitSaturationLoop -> checkPlutusLoop protoParamPath plutus + Just BenchCustomCall -> checkPlutusBuiltin protoParamPath + _ -> putStrLn $ "plutusType " + ++ show plutus + ++ " unrecognised" exitSuccess +-- The type annotations within patterns or expressions that would be +-- the alternatives would make lines exceed 80 columns, so these +-- helper functions move them out-of-line, with an extra helper to +-- avoid repeating the failure message. +showFundCore :: IsShelleyBasedEra era => Maybe (AddressInEra era, Lovelace) -> String +showFundCore = maybe "fund check failed" show + +showBabbage :: Maybe (AddressInEra BabbageEra, Lovelace) -> String +showBabbage = ("Babbage: " ++) . showFundCore + +showConway :: Maybe (AddressInEra ConwayEra, Lovelace) -> String +showConway = ("Conway: " ++) . showFundCore + checkFund :: - ShelleyGenesis + NixServiceOptions + -> ShelleyGenesis -> SigningKey PaymentKey - -> Maybe (AddressInEra BabbageEra, Lovelace) -checkFund = genesisInitialFundForKey Mainnet + -> String +checkFund nixService shelleyGenesis signingKey + | AnyCardanoEra BabbageEra <- _nix_era nixService + = showBabbage $ checkFundCore shelleyGenesis signingKey + | AnyCardanoEra ConwayEra <- _nix_era nixService + = showConway $ checkFundCore shelleyGenesis signingKey + | otherwise + = "ApiTest: unrecognized era" + +checkFundCore :: + IsShelleyBasedEra era + => ShelleyGenesis + -> SigningKey PaymentKey + -> Maybe (AddressInEra era, Lovelace) +checkFundCore = genesisInitialFundForKey Mainnet -checkPlutusBuiltin :: - IO () +checkPlutusBuiltin :: FilePath -> IO () #ifndef WITH_LIBRARY -checkPlutusBuiltin +checkPlutusBuiltin _protoParamFile = putStrLn "* checkPlutusBuiltin: skipped - no library available" #else -checkPlutusBuiltin +checkPlutusBuiltin protoParamFile = do let script = case findPlutusScript "CustomCall.hs" of Just x -> x @@ -137,7 +168,9 @@ checkPlutusBuiltin putStrLn "* serialisation of built-in Plutus script:" BSL.putStrLn $ encodePlutusScript script - protocolParameters <- readProtocolParametersOrDie + putStrLn "* reading protocol parameters" + protocolParameters <- readProtocolParametersOrDie protoParamFile + putStrLn "* done reading protocol parameters" forM_ bArgs $ \bArg -> do let apiData = unsafeHashableScriptData $ toApiData bArg putStrLn $ "* executing with mode: " ++ show (fst bArg) @@ -159,13 +192,14 @@ checkPlutusBuiltin #endif checkPlutusLoop :: - Maybe TxGenPlutusParams + FilePath + -> Maybe TxGenPlutusParams -> IO () -checkPlutusLoop (Just PlutusOn{..}) +checkPlutusLoop protoParamFile (Just PlutusOn{..}) = do script <- either (die . show) pure =<< readPlutusScript plutusScript putStrLn $ "--> Read plutus script: " ++ (id ||| id) plutusScript - protocolParameters <- readProtocolParametersOrDie + protocolParameters <- readProtocolParametersOrDie protoParamFile let count = 1_792 -- arbitrary counter for a loop script; should respect mainnet limits @@ -216,7 +250,7 @@ checkPlutusLoop (Just PlutusOn{..}) Right file -> let redeemerPath = (<.> ".redeemer.json") $ dropExtension $ takeFileName file in getDataFileName $ "data" redeemerPath Left _ -> getDataFileName "data/loop.redeemer.json" -checkPlutusLoop _ +checkPlutusLoop _ _ = putStrLn "--> No plutus script defined." @@ -227,10 +261,10 @@ checkPlutusLoop _ readFileJson :: FromJSON a => FilePath -> ExceptT TxGenError IO a readFileJson f = handleIOExceptT (TxGenError . show) (eitherDecodeFileStrict' f) >>= firstExceptT TxGenError . hoistEither -readProtocolParametersOrDie :: IO ProtocolParameters -readProtocolParametersOrDie +readProtocolParametersOrDie :: FilePath -> IO ProtocolParameters +readProtocolParametersOrDie filePath = do - parametersFile <- getDataFileName "data/protocol-parameters-v8.json" + parametersFile <- getDataFileName filePath either die pure =<< eitherDecodeFileStrict' parametersFile @@ -254,7 +288,15 @@ parserCommandLine = CommandLine <$> parseRunPath <*> parseJsonLocation + <*> parseParamPath where + parseParamPath = strOption + ( long "param" + <> metavar "PARAM" + <> help "Path to protocol parameter file" + <> completer (bashCompleter "file") + <> value "data/protocol-parameters-v8.json" + ) parseRunPath = strOption ( long "run" <> metavar "PATH" From ca99eaaa1b93fb4d5f850a373c58d407df3948c9 Mon Sep 17 00:00:00 2001 From: Nadia Yvette Chambers Date: Mon, 27 Nov 2023 17:26:26 +0000 Subject: [PATCH 3/5] plutus-scripts-bench: Bump protocol version number --- bench/tx-generator/data/protocol-parameters-conway.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/tx-generator/data/protocol-parameters-conway.json b/bench/tx-generator/data/protocol-parameters-conway.json index 47166173e73..e7c1f6633ae 100644 --- a/bench/tx-generator/data/protocol-parameters-conway.json +++ b/bench/tx-generator/data/protocol-parameters-conway.json @@ -598,7 +598,7 @@ "poolPledgeInfluence": 0.3, "poolRetireMaxEpoch": 18, "protocolVersion": { - "major": 8, + "major": 9, "minor": 0 }, "stakeAddressDeposit": 2000000, From eb41e4594773899bcc519904fc2ec7a0c1faa204 Mon Sep 17 00:00:00 2001 From: Nadia Yvette Chambers Date: Mon, 27 Nov 2023 17:28:46 +0000 Subject: [PATCH 4/5] plutus-scripts-bench: fixup missing Conway case --- .../src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs index 9a41476b04d..3cb3aedf8b5 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs @@ -47,7 +47,7 @@ import qualified Ouroboros.Consensus.Ledger.SupportsMempool as Mempool import qualified Ouroboros.Consensus.Shelley.Ledger.Mempool as Mempool (TxId(ShelleyTxId)) import Ouroboros.Consensus.Shelley.Eras (StandardCrypto) -import qualified Ouroboros.Consensus.Cardano.Block as Block (TxId(GenTxIdShelley, GenTxIdAllegra, GenTxIdAlonzo, GenTxIdMary,GenTxIdBabbage )) +import qualified Ouroboros.Consensus.Cardano.Block as Block (TxId(GenTxIdShelley, GenTxIdAllegra, GenTxIdAlonzo, GenTxIdMary,GenTxIdBabbage, GenTxIdConway)) import Ouroboros.Network.Protocol.TxSubmission2.Client (ClientStIdle (..), ClientStTxIds (..), @@ -201,6 +201,7 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback = fromGenTxId (Block.GenTxIdMary (Mempool.ShelleyTxId i)) = fromShelleyTxId i fromGenTxId (Block.GenTxIdAlonzo (Mempool.ShelleyTxId i)) = fromShelleyTxId i fromGenTxId (Block.GenTxIdBabbage (Mempool.ShelleyTxId i)) = fromShelleyTxId i + fromGenTxId (Block.GenTxIdConway (Mempool.ShelleyTxId i)) = fromShelleyTxId i fromGenTxId _ = error "TODO: fix incomplete match" tokIsBlocking :: TokBlockingStyle a -> Bool From a7529f585206b3c1db24bfeff693df3ca6c7772c Mon Sep 17 00:00:00 2001 From: Nadia Yvette Chambers Date: Mon, 27 Nov 2023 21:48:12 +0000 Subject: [PATCH 5/5] plutus-scripts-bench: Enable v12 for Conway Babbage is the latest supported from v10-11 of the NodeToNode protocol. This needs testing to be sure it's sufficient. --- .../src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs index 5e50d2e56c5..8587bdb6866 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs @@ -100,7 +100,7 @@ benchmarkConnectTxSubmit ioManager handshakeTracer submissionTracer codecConfig OuroborosApplication $ fold bundle n2nVer :: NodeToNodeVersion - n2nVer = NodeToNodeV_10 + n2nVer = NodeToNodeV_12 blkN2nVer :: BlockNodeToNodeVersion blk blkN2nVer = supportedVers Map.! n2nVer supportedVers :: Map.Map NodeToNodeVersion (BlockNodeToNodeVersion blk)