Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tx-generator: make the used key/address explicit #3426

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bench/script/test-full-auto.ljson
Original file line number Diff line number Diff line change
Expand Up @@ -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": [] }
Expand Down
12 changes: 6 additions & 6 deletions bench/script/test-large.ljson
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
8 changes: 4 additions & 4 deletions bench/script/test-plutus-to-file.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
] },
Expand Down
10 changes: 5 additions & 5 deletions bench/script/test-plutus-to-file.ljson
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
10 changes: 5 additions & 5 deletions bench/script/test-plutus.ljson
Original file line number Diff line number Diff line change
Expand Up @@ -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": [] }
Expand Down
8 changes: 4 additions & 4 deletions bench/script/test-stand-alone.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
] },
Expand Down
10 changes: 5 additions & 5 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down
4 changes: 2 additions & 2 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions nix/nixos/tx-generator-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -109,7 +109,7 @@ let
[ { createChange = value;
count = count;
submitMode.LocalSocket = [];
payMode.PayToAddr = [];
payMode.PayToAddr = "pass-partout";
}
{ delay = cfg.init_cooldown; }
];
Expand Down