From 3b51fa5d2e32ad30ad3c42aef66f7e2b26cba4ba Mon Sep 17 00:00:00 2001 From: MarcFontaine Date: Wed, 8 Dec 2021 15:37:43 +0100 Subject: [PATCH] tx-generator: make the used key/address explicit --- bench/script/test-full-auto.ljson | 10 +++++----- bench/script/test-large.ljson | 12 ++++++------ bench/script/test-plutus-to-file.json | 8 ++++---- bench/script/test-plutus-to-file.ljson | 10 +++++----- bench/script/test-plutus.ljson | 10 +++++----- bench/script/test-stand-alone.json | 8 ++++---- .../src/Cardano/Benchmarking/Script/Core.hs | 10 +++++----- .../src/Cardano/Benchmarking/Script/Example.hs | 2 +- .../src/Cardano/Benchmarking/Script/Types.hs | 4 ++-- nix/nixos/tx-generator-service.nix | 6 +++--- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/bench/script/test-full-auto.ljson b/bench/script/test-full-auto.ljson index ccb313f395d..1c12e46f2e0 100644 --- a/bench/script/test-full-auto.ljson +++ b/bench/script/test-full-auto.ljson @@ -18,23 +18,23 @@ { "readSigningKey": "pass-partout", "filePath": "run/current/genesis/utxo-keys/utxo1.skey" }, { "importGenesisFund": "pass-partout", "fundKey": "pass-partout" , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 149200212345, "count" : 1 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 149200000000, "count" : 1 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToCollateral": [] } + , "payMode": { "PayToCollateral": "pass-partout" } }, { "createChange" : 2200000000000, "count" : 10 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 70000000000, "count" : 300 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 2300000000, "count" : 1000 , "submitMode": { "LocalSocket": [] } diff --git a/bench/script/test-large.ljson b/bench/script/test-large.ljson index 944ab7335b8..4593144fc73 100644 --- a/bench/script/test-large.ljson +++ b/bench/script/test-large.ljson @@ -18,27 +18,27 @@ { "readSigningKey": "pass-partout", "filePath": "run/current/genesis/utxo-keys/utxo1.skey" }, { "importGenesisFund": "pass-partout", "fundKey": "pass-partout" , "submitMode": { "DumpToFile": "/tmp/tx-list.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 2200000000000, "count" : 10 , "submitMode": { "DumpToFile": "/tmp/tx-list.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 70000000000, "count" : 300 , "submitMode": { "DumpToFile": "/tmp/tx-list.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 2200000000, "count" : 9000 , "submitMode": { "DumpToFile": "/tmp/tx-list.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 70000000, "count" : 270000 , "submitMode": { "DumpToFile": "/tmp/tx-list.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 2300000, "count" : 8100000 , "submitMode": { "DumpToFile": "/tmp/tx-list.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "runBenchmark": "walletBasedBenchmark", "txCount": 1000000, "tps": 100 , "submitMode": { "DumpToFile": "/tmp/submit-list.txt" } diff --git a/bench/script/test-plutus-to-file.json b/bench/script/test-plutus-to-file.json index 69f3f48fc32..34d96123da7 100644 --- a/bench/script/test-plutus-to-file.json +++ b/bench/script/test-plutus-to-file.json @@ -22,25 +22,25 @@ ] }, { "CreateChange": [ { "DumpToFile": "/tmp/script-txs.txt" }, - { "PayToAddr": [] }, + { "PayToAddr": "pass-partout" }, 149200212345, 1 ] }, { "CreateChange": [ { "DumpToFile": "/tmp/script-txs.txt" }, - { "PayToCollateral": [] }, + { "PayToCollateral": "pass-partout" }, 149200000000, 1 ] }, { "CreateChange": [ { "DumpToFile": "/tmp/split-txs.txt" }, - { "PayToAddr": [] }, + { "PayToAddr": "pass-partout" }, 2200000000000, 10 ] }, { "CreateChange": [ { "DumpToFile": "/tmp/split-txs.txt" }, - { "PayToAddr": [] }, + { "PayToAddr": "pass-partout" }, 70000000000, 300 ] }, diff --git a/bench/script/test-plutus-to-file.ljson b/bench/script/test-plutus-to-file.ljson index b088e31735c..a1a89db72b2 100644 --- a/bench/script/test-plutus-to-file.ljson +++ b/bench/script/test-plutus-to-file.ljson @@ -18,23 +18,23 @@ { "readSigningKey": "pass-partout", "filePath": "run/current/genesis/utxo-keys/utxo1.skey" }, { "importGenesisFund": "pass-partout", "fundKey": "pass-partout" , "submitMode": { "DumpToFile": "/tmp/split-txs.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 149200212345, "count" : 1 , "submitMode": { "DumpToFile": "/tmp/script-txs.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 149200000000, "count" : 1 , "submitMode": { "DumpToFile": "/tmp/script-txs.txt" } - , "payMode": { "PayToCollateral": [] } + , "payMode": { "PayToCollateral": "pass-partout" } }, { "createChange" : 2200000000000, "count" : 10 , "submitMode": { "DumpToFile": "/tmp/split-txs.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 70000000000, "count" : 300 , "submitMode": { "DumpToFile": "/tmp/split-txs.txt" } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 2300000000, "count" : 9000 , "submitMode": { "DumpToFile": "/tmp/script-txs.txt" } diff --git a/bench/script/test-plutus.ljson b/bench/script/test-plutus.ljson index f2f7dfdd515..d3c268a37b8 100644 --- a/bench/script/test-plutus.ljson +++ b/bench/script/test-plutus.ljson @@ -18,23 +18,23 @@ { "readSigningKey": "pass-partout", "filePath": "run/current/genesis/utxo-keys/utxo1.skey" }, { "importGenesisFund": "pass-partout", "fundKey": "pass-partout" , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 149200212345, "count" : 1 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 149200000000, "count" : 1 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToCollateral": [] } + , "payMode": { "PayToCollateral": "pass-partout" } }, { "createChange" : 2200000000000, "count" : 10 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 70000000000, "count" : 300 , "submitMode": { "LocalSocket": [] } - , "payMode": { "PayToAddr": [] } + , "payMode": { "PayToAddr": "pass-partout" } }, { "createChange" : 2300000000, "count" : 1000 , "submitMode": { "LocalSocket": [] } diff --git a/bench/script/test-stand-alone.json b/bench/script/test-stand-alone.json index e3e8f532bf3..350c628d22d 100644 --- a/bench/script/test-stand-alone.json +++ b/bench/script/test-stand-alone.json @@ -11,25 +11,25 @@ { "ReadSigningKey": [ "pass-partout", "run/current/genesis/utxo-keys/utxo1.skey" ] }, { "CreateChange": [ { "DumpToFile": "/tmp/script-txs.txt" }, - { "PayToAddr": [] }, + { "PayToAddr": "pass-partout" }, 149200212345, 1 ] }, { "CreateChange": [ { "DumpToFile": "/tmp/script-txs.txt" }, - { "PayToCollateral": [] }, + { "PayToCollateral": "pass-partout" }, 149200000000, 1 ] }, { "CreateChange": [ { "DumpToFile": "/tmp/split-txs.txt" }, - { "PayToAddr": [] }, + { "PayToAddr": "pass-partout" }, 2200000000000, 10 ] }, { "CreateChange": [ { "DumpToFile": "/tmp/split-txs.txt" }, - { "PayToAddr": [] }, + { "PayToAddr": "pass-partout" }, 70000000000, 300 ] }, diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs index d5a6c83c475..9272b3bf476 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs @@ -555,10 +555,10 @@ initGlobalWallet = liftIO initWallet >>= set GlobalWallet createChange :: SubmitMode -> PayMode -> Lovelace -> Int -> ActionM () createChange submitMode payMode value count = case payMode of - PayToAddr -> withEra $ createChangeInEra submitMode PlainOldFund value count + PayToAddr keyName -> withEra $ createChangeInEra submitMode PlainOldFund keyName value count -- Problem here: PayToCollateral will create an output marked as collateral -- and also return any change to a collateral, which makes the returned change unusable. - PayToCollateral -> withEra $ createChangeInEra submitMode CollateralFund value count + PayToCollateral keyName -> withEra $ createChangeInEra submitMode CollateralFund keyName value count PayToScript scriptFile scriptData -> createChangeScriptFunds submitMode scriptFile scriptData value count createChangeScriptFunds :: SubmitMode -> FilePath -> ScriptData -> Lovelace -> Int -> ActionM () @@ -587,13 +587,13 @@ createChangeScriptFunds submitMode scriptFile scriptData value count = do addressMsg = Text.unpack $ serialiseAddress $ makeShelleyAddress networkId (PaymentCredentialByScript $ hashScript script) NoStakeAddress createChangeGeneric submitMode createCoins addressMsg value count -createChangeInEra :: forall era. IsShelleyBasedEra era => SubmitMode -> Variant -> Lovelace -> Int -> AsType era -> ActionM () -createChangeInEra submitMode variant value count _proxy = do +createChangeInEra :: forall era. IsShelleyBasedEra era => SubmitMode -> Variant -> KeyName -> Lovelace -> Int -> AsType era -> ActionM () +createChangeInEra submitMode variant keyName value count _proxy = do networkId <- getUser TNetworkId fee <- getUser TFee walletRef <- get GlobalWallet protocolParameters <- getProtocolParameters - fundKey <- getName $ KeyName "pass-partout" + fundKey <- getName keyName let createCoins :: FundSet.FundSource -> [Lovelace] -> ActionM (Either String (TxInMode CardanoMode)) createCoins fundSource coins = do diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Example.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Example.hs index 421d749f1b1..0d277d66a57 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Example.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Example.hs @@ -57,7 +57,7 @@ testScript = , WaitForEra $ AnyCardanoEra ByronEra , CancelBenchmark threadName , ImportGenesisFund DiscardTX passPartout passPartout - , CreateChange LocalSocket PayToAddr (quantityToLovelace 10000) 1000 + , CreateChange LocalSocket (PayToAddr passPartout) (quantityToLovelace 10000) 1000 , RunBenchmark (DumpToFile "/tmp/tx-list.txt") SpendOutput (ThreadName "walletThread") (NumberOfTxs 1000) (TPSRate 10) , RunBenchmark (DumpToFile "/tmp/tx-list.txt") scriptDef (ThreadName "walletThread") (NumberOfTxs 1000) (TPSRate 10) , Reserved [] diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Types.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Types.hs index 5c44bb869e8..3c01a1667f6 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Types.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Types.hs @@ -58,8 +58,8 @@ data SubmitMode where deriving instance Generic SubmitMode data PayMode where - PayToAddr :: PayMode - PayToCollateral :: PayMode + PayToAddr :: !KeyName -> PayMode + PayToCollateral :: !KeyName -> PayMode PayToScript :: !FilePath -> !ScriptData -> PayMode deriving (Show, Eq) deriving instance Generic PayMode diff --git a/nix/nixos/tx-generator-service.nix b/nix/nixos/tx-generator-service.nix index de4e94c2c08..9cce27b7e24 100644 --- a/nix/nixos/tx-generator-service.nix +++ b/nix/nixos/tx-generator-service.nix @@ -51,10 +51,10 @@ let # Therefor this first creates a matching regular output # and turns that into a collateral right in the next step. { createChange = safeCollateral + tx_fee; count = 1; - submitMode.LocalSocket = []; payMode.PayToAddr = []; + submitMode.LocalSocket = []; payMode.PayToAddr = "pass-partout"; } { createChange = safeCollateral; count = 1; - submitMode.LocalSocket = []; payMode.PayToCollateral = []; + submitMode.LocalSocket = []; payMode.PayToCollateral = "pass-partout"; } ] ++ createChangePlutus cfg minValuePerInput (tx_count * inputs_per_tx) @@ -109,7 +109,7 @@ let [ { createChange = value; count = count; submitMode.LocalSocket = []; - payMode.PayToAddr = []; + payMode.PayToAddr = "pass-partout"; } { delay = cfg.init_cooldown; } ];