Skip to content

Commit be2fd17

Browse files
committed
WIP: -nomadperf
1 parent 55b1f98 commit be2fd17

5 files changed

Lines changed: 67 additions & 31 deletions

File tree

bench/cardano-profile/src/Cardano/Benchmarking/Profile/Vocabulary.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ genesisVariantVoltaire = genesisVariantLatest
116116

117117
-- Defined in the "genesis" property and it's for the tx-generator.
118118
fundsDefault :: Types.Profile -> Types.Profile
119-
fundsDefault = P.poolBalance 1000000000000000 . P.funds 10000000000000 . P.utxoKeys (6*500*3)
119+
fundsDefault = P.poolBalance 1000000000000000 . P.funds 10000000000000 . P.utxoKeys (52*500*3)
120120

121121
-- Some profiles have a higher `funds_balance` in `Genesis`. Needed? Fix it?
122122
fundsDouble :: Types.Profile -> Types.Profile
123-
fundsDouble = P.poolBalance 1000000000000000 . P.funds 20000000000000 . P.utxoKeys 1
123+
fundsDouble = P.poolBalance 1000000000000000 . P.funds 20000000000000 . P.utxoKeys (52*500*3)
124124

125125
fundsVoting :: Types.Profile -> Types.Profile
126126
fundsVoting = P.poolBalance 1000000000000000 . P.funds 40000000000000 . P.utxoKeys 2

bench/tx-centrifuge/app/Main.hs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ import Control.Concurrent.STM qualified as STM
9595
------------------
9696
import Control.Monad.Trans.Except (runExceptT)
9797
------------------
98-
-- tx-generator --
99-
------------------
100-
import Cardano.TxGenerator.ProtocolParameters qualified as PP
101-
------------------
10298
-- pull-fiction --
10399
------------------
104100
import Cardano.Benchmarking.PullFiction.Config.Raw qualified as Raw
@@ -123,7 +119,7 @@ main = do
123119
-- Config.
124120
----------
125121

126-
(runtime, codecConfig, networkId, networkMagic, ledgerPP, tracers) <- loadConfig
122+
(runtime, codecConfig, networkId, networkMagic, tracers) <- loadConfig
127123

128124
-- Launch.
129125
----------
@@ -148,7 +144,7 @@ main = do
148144
replicateM
149145
(fromIntegral (inputsPerTx vb))
150146
(STM.readTQueue fundQueue)
151-
case Tx.buildTx ledgerPP signingAddr signingKey
147+
case Tx.buildTx signingAddr signingKey
152148
inputFunds (outputsPerTx vb) (L.Coin (fee vb)) of
153149
Left err -> die $ "Tx.buildTx: " ++ err
154150
Right ans@(tx, outputFunds) -> do
@@ -374,6 +370,23 @@ createSigningKeyAndAddress networkId n
374370
Api.NoStakeAddress
375371
in (signingKey, signingAddr)
376372

373+
--------------------------------------------------------------------------------
374+
-- Cardano parameters
375+
--------------------------------------------------------------------------------
376+
377+
{-- TODO: Construct a minimal protocol parameters, see Tx.hs last line.
378+
data ProtocolParameters = ProtocolParameters
379+
{ epochLength :: Integer
380+
, minFeeA :: Integer
381+
, minFeeB :: Integer
382+
}
383+
384+
instance Aeson.FromJSON ProtocolParameters where
385+
parseJSON = Aeson.withObject "ProtocolParameters" $ \o -> do
386+
pp <- o .: "params"
387+
ProtocolParameters <$> pp .: "epoch_length" <*> pp .: "min_fee_a" <*> pp .: "min_fee_b"
388+
--}
389+
377390
--------------------------------------------------------------------------------
378391
-- Initialization
379392
--------------------------------------------------------------------------------
@@ -392,8 +405,6 @@ loadConfig
392405
, Api.NetworkId
393406
-- | Network magic for the handshake with cardano-node.
394407
, Api.NetworkMagic
395-
-- | Ledger protocol parameters for transaction building.
396-
, Api.LedgerProtocolParameters Api.ConwayEra
397408
-- | Logging / metrics tracers.
398409
, Tracing.Tracers
399410
)
@@ -417,7 +428,6 @@ loadConfig = do
417428
Left err -> die $ "Config: " ++ err
418429
Right v -> pure v
419430
nodeConfigPath <- parseField "nodeConfig"
420-
ppPath <- parseField "protocolParametersFile"
421431
raw <- case Aeson.fromJSON rawValue of
422432
Aeson.Error err -> die $ "JSON: " ++ err
423433
Aeson.Success cfg -> pure cfg
@@ -450,19 +460,10 @@ loadConfig = do
450460
networkId = protocolToNetworkId protocol
451461
networkMagic = protocolToNetworkMagic protocol
452462

453-
-- Load protocol parameters.
454-
hPutStrLn stderr $ "Loading protocol parameters from: " ++ ppPath
455-
protocolParameters <-
456-
Aeson.eitherDecodeFileStrict' ppPath >>= either die pure
457-
ledgerPP <- case PP.convertToLedgerProtocolParameters
458-
Api.ShelleyBasedEraConway protocolParameters of
459-
Left err -> die $ "convertToLedgerProtocolParameters: " ++ show err
460-
Right pp -> pure pp
461-
462463
-- Tracers.
463464
tracers <- Tracing.setupTracers configFile
464465

465-
pure ( runtime, codecConfig, networkId, networkMagic, ledgerPP, tracers )
466+
pure ( runtime, codecConfig, networkId, networkMagic, tracers )
466467

467468
--------------------------------------------------------------------------------
468469
-- Protocol helpers (inlined from NodeConfig.hs and OuroborosImports.hs)

bench/tx-centrifuge/lib/tx-centrifuge/Cardano/Benchmarking/TxCentrifuge/Tx.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ import Cardano.Benchmarking.TxCentrifuge.Fund ( Fund(..) )
3939
--
4040
-- Fixed to ConwayEra. No Plutus, no metadata, fixed fee.
4141
buildTx
42-
-- | Ledger protocol parameters.
43-
:: Api.LedgerProtocolParameters Api.ConwayEra
4442
-- | Destination address for outputs (embeds the network identifier).
45-
-> Api.AddressInEra Api.ConwayEra
43+
:: Api.AddressInEra Api.ConwayEra
4644
-- | Signing key for recycled output funds.
4745
-> Api.SigningKey Api.PaymentKey
4846
-- | Input funds.
@@ -52,7 +50,7 @@ buildTx
5250
-- | Fee.
5351
-> L.Coin
5452
-> Either String (Api.Tx Api.ConwayEra, [Fund])
55-
buildTx ledgerPP destAddr outKey inFunds numOutputs fee
53+
buildTx destAddr outKey inFunds numOutputs fee
5654
| null inFunds = Left "buildTx: no input funds"
5755
| numOutputs == 0 = Left "buildTx: outputs_per_tx must be >= 1"
5856
| feeLovelace < 0 = Left "buildTx: fee must be >= 0"
@@ -165,4 +163,7 @@ buildTx ledgerPP destAddr outKey inFunds numOutputs fee
165163
Api.ShelleyBasedEraConway
166164
)
167165
& Api.setTxMetadata Api.TxMetadataNone
168-
& Api.setTxProtocolParams (Api.BuildTxWith (Just ledgerPP))
166+
-- We are using an explicit fee!
167+
-- Using `Nothing` instead of `ledgerPP :: Api.LedgerProtocolParameters Api.ConwayEra`.
168+
-- TODO: Will need something else for plutus scripts!
169+
& Api.setTxProtocolParams (Api.BuildTxWith Nothing)

nix/workbench/backend/nomad-job.nix

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ let
895895
in
896896
# Recreate the "run-script.json" with IPs and ports that are
897897
# nomad template variables.
898-
(runScriptToGoTemplate
898+
(runScriptToGoTemplate2
899899
runScript
900900
# Just the node names.
901901
(lib.attrsets.mapAttrsToList
@@ -1394,6 +1394,32 @@ let
13941394
''
13951395
;
13961396

1397+
runScriptToGoTemplate2 = runScript: _: builtins.replaceStrings
1398+
(
1399+
(builtins.genList
1400+
(i: ''__addr_${toString i}__'')
1401+
100
1402+
)
1403+
++
1404+
(builtins.genList
1405+
(i: ''"__port_${toString i}__"'')
1406+
100
1407+
)
1408+
)
1409+
(
1410+
(builtins.genList
1411+
(i: ''{{range nomadService "${(nodeNameToServicePortName "node-${toString i}")}"}}{{.Address}}{{end}}'')
1412+
100
1413+
)
1414+
++
1415+
(builtins.genList
1416+
(i: ''{{range nomadService "${(nodeNameToServicePortName "node-${toString i}")}"}}{{.Port}}{{end}}'')
1417+
100
1418+
)
1419+
)
1420+
(lib.generators.toJSON {} runScript)
1421+
;
1422+
13971423
# Convert from generator's "run-script.json" with all addresses being
13981424
# "127.0.0.01" to one with all addresses being a placeholder like
13991425
# "{{NOMAD_IP_node-X}}".

nix/workbench/service/generator.nix

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ __toJSON
191191
rate_limit =
192192
{ scope = "shared";
193193
type = "token_bucket";
194-
params = { tps = 15; };
194+
params = { tps = 12; };
195195
}
196196
;
197197
max_batch_size = 500;
@@ -205,8 +205,11 @@ __toJSON
205205
value =
206206
{ targets =
207207
{ "${toString i}" =
208-
{ addr = "127.0.0.1";
209-
port = (30000 + i);
208+
# { addr = "127.0.0.1";
209+
# port = (30000 + i);
210+
# }
211+
{ addr = "__addr_${toString i}__";
212+
port = "__port_${toString i}__";
210213
}
211214
;
212215
}
@@ -221,7 +224,12 @@ __toJSON
221224
# tx-centrifuge parameters.
222225
###########################
223226
nodeConfig = "../${runningNode}/config.json";
224-
protocolParametersFile = "/tmp/protocol-parameters-queried.json";
227+
protocol_parameters =
228+
{ epoch_length = profile.genesis.shelley.epochLength;
229+
min_fee_a = profile.genesis.shelley.protocolParams.minFeeA;
230+
min_fee_b = profile.genesis.shelley.protocolParams.minFeeB;
231+
}
232+
;
225233
# Tracing parameters.
226234
#####################
227235
TraceOptions =

0 commit comments

Comments
 (0)