diff --git a/bench/script/test-stand-alone.json b/bench/script/test-stand-alone.json index ed069874358..1a666f0d617 100644 --- a/bench/script/test-stand-alone.json +++ b/bench/script/test-stand-alone.json @@ -1,5 +1,5 @@ [ - { "SetProtocolParameters": { "UseLocalProtocolFile": "/tmp/t2.json" } }, + { "SetProtocolParameters": { "UseLocalProtocolFile": "/tmp/t2.json" } }, { "Set": { "SNumberOfInputsPerTx": 2 } }, { "Set": { "SNumberOfOutputsPerTx": 2 } }, { "Set": { "STxAdditionalSize": 39 } }, @@ -8,6 +8,7 @@ { "Set": { "STTL": 1000000 } }, { "Set": { "SEra": "Allegra" } }, { "Set": { "SNetworkId": { "Testnet": 42 } } }, + { "InitWallet": "test-wallet" }, { "DefineSigningKey": [ "pass-partout" , { @@ -16,50 +17,58 @@ "cborHex": "58200b6c317eb6c9762898fa41ca9d683003f86899ab0f2f6dbaf244e415b62826a2" } ] }, { "AddFund": - [ "900fc5da77a0747da53f7675cbb7d149d46779346dea2f879ab811ccc72a2162#0" + [ "test-wallet" + , "900fc5da77a0747da53f7675cbb7d149d46779346dea2f879ab811ccc72a2162#0" , 90000000000000 , "pass-partout" ] }, { "CreateChange": [ + "test-wallet", + "test-wallet", { "DumpToFile": "/tmp/script-txs.txt" }, { "PayToAddr": "pass-partout" }, 149200212345, 1 ] }, { "CreateChange": [ + "test-wallet", + "test-wallet", { "DumpToFile": "/tmp/script-txs.txt" }, { "PayToCollateral": "pass-partout" }, 149200000000, 1 ] }, { "CreateChange": [ + "test-wallet", + "test-wallet", { "DumpToFile": "/tmp/split-txs.txt" }, { "PayToAddr": "pass-partout" }, 2200000000000, 10 ] }, { "CreateChange": [ + "test-wallet", + "test-wallet", { "DumpToFile": "/tmp/split-txs.txt" }, { "PayToAddr": "pass-partout" }, 70000000000, 300 ] }, { "CreateChange": [ + "test-wallet", + "test-wallet", { "DumpToFile": "/tmp/script-txs.txt" }, - { "PayToScript": [ "bench/script/sum1ToN.plutus", 3 ] }, + { "PayToAddr": "pass-partout" }, 2300000000, 9000 - ] }, + ] }, { "RunBenchmark": [ + "test-wallet", { "DumpToFile": "/tmp/submit-txs.txt" }, - { "SpendScript": [ - "bench/script/sum1ToN.plutus", - { "PreExecuteScript": [] }, - 3, - 6 - ] }, + { "SpendOutput": []}, "walletBasedBenchmark", 4000, 10 ] } + ] diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Compiler.hs b/bench/tx-generator/src/Cardano/Benchmarking/Compiler.hs index b352c0f5c3c..53b7d2a6f0a 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Compiler.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Compiler.hs @@ -224,5 +224,3 @@ newWallet n = do name <- WalletName <$> newIdentifier n emit $ InitWallet name return name - - diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs index fb5f2c69124..f90b79ec29e 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs @@ -259,7 +259,6 @@ runBenchmarkInEra sourceWallet submitMode (ThreadName threadName) txCount tps er tracers <- get BenchTracers networkId <- getUser TNetworkId fundKey <- getName $ KeyName "pass-partout" -- should be walletkey - targets <- getUser TTargets (NumberOfInputsPerTx numInputs) <- getUser TNumberOfInputsPerTx (NumberOfOutputsPerTx numOutputs) <- getUser TNumberOfOutputsPerTx fee <- getUser TFee @@ -268,7 +267,6 @@ runBenchmarkInEra sourceWallet submitMode (ThreadName threadName) txCount tps er walletRefSrc <- getName sourceWallet let walletRefDst = walletRefSrc metadata <- makeMetadata - connectClient <- getConnectClient let (Quantity minValue) = lovelaceToQuantity $ fromIntegral numOutputs * minValuePerUTxO + fee @@ -302,11 +300,14 @@ runBenchmarkInEra sourceWallet submitMode (ThreadName threadName) txCount tps er walletScript :: FundSet.Target -> WalletScript era walletScript = benchmarkWalletScript walletRefSrc txGenerator txCount (const fundSource) inToOut toUTxO fundToStore - coreCall :: AsType era -> ExceptT TxGenError IO AsyncBenchmarkControl - coreCall eraProxy = GeneratorTx.walletBenchmark (btTxSubmit_ tracers) (btN2N_ tracers) connectClient - threadName targets tps LogErrors eraProxy txCount walletScript case submitMode of NodeToNode -> do + targets <- getUser TTargets + connectClient <- getConnectClient + let + coreCall :: AsType era -> ExceptT TxGenError IO AsyncBenchmarkControl + coreCall eraProxy = GeneratorTx.walletBenchmark (btTxSubmit_ tracers) (btN2N_ tracers) connectClient + threadName targets tps LogErrors eraProxy txCount walletScript ret <- liftIO $ runExceptT $ coreCall era case ret of Left err -> liftTxGenError err @@ -326,7 +327,6 @@ runPlutusBenchmark :: -> ActionM () runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData scriptRedeemer (ThreadName threadName) txCount tps = do tracers <- get BenchTracers - targets <- getUser TTargets (NumberOfInputsPerTx numInputs) <- getUser TNumberOfInputsPerTx (NumberOfOutputsPerTx numOutputs) <- getUser TNumberOfOutputsPerTx networkId <- getUser TNetworkId @@ -350,7 +350,6 @@ runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData sc baseFee <- getUser TFee _minValuePerUTxO <- getUser TMinValuePerUTxO -- TODO:Fix metadata <- makeMetadata - connectClient <- getConnectClient let costsPreRun = preExecuteScript protocolParameters script scriptData scriptRedeemer executionUnits <- case (scriptBudget, costsPreRun) of @@ -429,6 +428,8 @@ runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData sc case submitMode of NodeToNode -> do + targets <- getUser TTargets + connectClient <- getConnectClient ret <- liftIO $ runExceptT $ GeneratorTx.walletBenchmark (btTxSubmit_ tracers) (btN2N_ tracers) connectClient threadName targets tps LogErrors AsAlonzoEra txCount walletScript case ret of diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Selftest.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Selftest.hs new file mode 100644 index 00000000000..5181afef4b1 --- /dev/null +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Selftest.hs @@ -0,0 +1,46 @@ +module Cardano.Benchmarking.Script.Selftest +where +import Data.Dependent.Sum ( (==>) ) +import Data.String + +import Cardano.Api + +import Cardano.Benchmarking.Types +import Cardano.Benchmarking.Script.Setters +import Cardano.Benchmarking.Script.Store +import Cardano.Benchmarking.Script.Types + +testScript :: FilePath [Action] +testScript protocolFile = + [ SetProtocolParameters (UseLocalProtocolFile protocolFile) + , Set (TNumberOfInputsPerTx ==> 2) + , Set (TNumberOfOutputsPerTx ==> 2) + , Set (TTxAdditionalSize ==> 39) + , Set (TFee ==> (Lovelace 212345)) + , Set (TMinValuePerUTxO ==> (Lovelace 1000000)) + , Set (TTTL ==> (SlotNo 1000000)) + , Set (TEra ==> (AnyCardanoEra AllegraEra)) + , Set (TNetworkId ==> (Testnet (NetworkMagic {unNetworkMagic = 42}))) + , InitWallet wallet + , DefineSigningKey key + (TextEnvelope { teType = TextEnvelopeType "GenesisUTxOSigningKey_ed25519" + , teDescription = fromString "Genesis Initial UTxO Signing Key" + , teRawCBOR = "X \vl1~\182\201v(\152\250A\202\157h0\ETX\248h\153\171\SI/m\186\242D\228\NAK\182(&\162"}) + , AddFund wallet + (TxIn "900fc5da77a0747da53f7675cbb7d149d46779346dea2f879ab811ccc72a2162" (TxIx 0)) + (Lovelace 90000000000000) key + , createChange 2200000000000 10 + , createChange 70000000000 300 + , createChange 2300000000 9000 + , RunBenchmark wallet + output + SpendOutput + (ThreadName "walletBasedBenchmark") 4000 (TPSRate 10.0) + ] + where + wallet = WalletName "test-wallet" + key = KeyName "pass-partout" + output = DumpToFile "/tmp/txs.txt" + addr = PayToAddr key + createChange val count + = CreateChange wallet wallet output addr (Lovelace val) count diff --git a/bench/tx-generator/tx-generator.cabal b/bench/tx-generator/tx-generator.cabal index 61a6af1c0db..7af0c3fc0db 100644 --- a/bench/tx-generator/tx-generator.cabal +++ b/bench/tx-generator/tx-generator.cabal @@ -45,6 +45,7 @@ library Cardano.Benchmarking.Script.Core Cardano.Benchmarking.Script.Env Cardano.Benchmarking.Script.Example + Cardano.Benchmarking.Script.Selftest Cardano.Benchmarking.Script.Setters Cardano.Benchmarking.Script.Store Cardano.Benchmarking.Script.Types