Skip to content

Commit a7cd80b

Browse files
committed
WIP
1 parent 177c7bd commit a7cd80b

File tree

4 files changed

+160
-2
lines changed

4 files changed

+160
-2
lines changed

bench/cardano-profile/cardano-profile.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ library
7171
, Cardano.Benchmarking.Profile.Vocabulary
7272
, Cardano.Benchmarking.Profile.Types
7373
, Cardano.Benchmarking.Profile.Workload.CGroupMemory
74+
, Cardano.Benchmarking.Profile.Workload.Hydra
7475
, Cardano.Benchmarking.Profile.Workload.Latency
7576
, Cardano.Benchmarking.Profile.Workload.Voting
7677
build-depends: base >=4.12 && <5

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import qualified Cardano.Benchmarking.Profile.Builtin.Miniature as M
2121
import qualified Cardano.Benchmarking.Profile.Primitives as P
2222
import qualified Cardano.Benchmarking.Profile.Types as Types
2323
import qualified Cardano.Benchmarking.Profile.Vocabulary as V
24-
import qualified Cardano.Benchmarking.Profile.Workload.Voting as W
24+
import qualified Cardano.Benchmarking.Profile.Workload.Hydra as WH
25+
import qualified Cardano.Benchmarking.Profile.Workload.Voting as WV
2526

2627
--------------------------------------------------------------------------------
2728

@@ -107,6 +108,21 @@ profilesNoEraPlayground =
107108
-- Voting profiles.
108109
, voting & P.name "development-voting"
109110
. P.dreps 1000
110-
. P.workloadAppend W.votingWorkloadx2
111+
. P.workloadAppend WV.votingWorkloadx2
111112
. P.traceForwardingOn . P.newTracing
113+
-- Hydra profiles.
114+
, P.empty & P.name "development-hydra"
115+
. P.idle -- No `tx-generator`.
116+
{-- For tx-generators use with a duration:
117+
. P.fixedLoaded . V.valueLocal
118+
--}
119+
. P.workloadAppend WH.hydraWorkload
120+
. P.uniCircle . V.hosts 2 . P.loopback
121+
. V.genesisVariantLatest . V.timescaleCompressed
122+
. V.datasetEmpty -- No UTxO.
123+
-- One for a future tx-generator plus one for each node.
124+
. P.poolBalance 1000000000000000 . P.funds 40000000000000 . P.utxoKeys 3
125+
. P.traceForwardingOn . P.newTracing
126+
. P.analysisOff -- Nothing to analyze.
112127
]
128+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{-# LANGUAGE Trustworthy #-}
2+
{-# LANGUAGE OverloadedStrings #-}
3+
4+
--------------------------------------------------------------------------------
5+
6+
module Cardano.Benchmarking.Profile.Workload.Hydra (
7+
hydraWorkload
8+
) where
9+
10+
--------------------------------------------------------------------------------
11+
12+
import Prelude
13+
-- Package: aeson.
14+
import qualified Data.Aeson as Aeson
15+
import qualified Data.Aeson.KeyMap as KeyMap
16+
-- Package: self.
17+
import qualified Cardano.Benchmarking.Profile.Types as Types
18+
19+
--------------------------------------------------------------------------------
20+
21+
hydraWorkload :: Types.Workload
22+
hydraWorkload = Types.Workload {
23+
Types.workloadName = "hydra"
24+
, Types.parameters = KeyMap.fromList [
25+
("baseport", Aeson.Number 31000)
26+
]
27+
, Types.entrypoints = Types.Entrypoints {
28+
Types.pre_generator = Nothing
29+
, Types.producers = "hydra"
30+
}
31+
, Types.before_nodes = False
32+
, Types.wait_pools = True
33+
}
34+

nix/workbench/workload/hydra.nix

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{ pkgs
2+
, profile
3+
, nodeSpecs
4+
, workload
5+
}:
6+
7+
let
8+
9+
# Packages
10+
##########
11+
12+
bashInteractive = pkgs.bashInteractive;
13+
coreutils = pkgs.coreutils;
14+
jq = pkgs.jq;
15+
# Avoid rebuilding on every commit because of `set-git-rev`.
16+
cardano-cli = pkgs.cardanoNodePackages.cardano-cli.passthru.noGitRev;
17+
# Hyra (Release 1.0.0).
18+
commit = "b5e33b55e9fba442c562f82cec6c36b1716d9847";
19+
flake = (__getFlake "github:cardano-scaling/hydra/${commit}");
20+
hydra = flake.packages.${builtins.currentSystem}.hydra-node;
21+
22+
# Parameters
23+
############
24+
25+
testnet_magic = 42;
26+
baseport = workload.parameters.baseport or 31000;
27+
# Filter producers from "node-specs.json".
28+
producers =
29+
builtins.filter
30+
(nodeSpec: nodeSpec.isProducer)
31+
(builtins.attrValues nodeSpecs)
32+
;
33+
# Construct an "array" with node producers to use in BASH `for` loops.
34+
producers_bash_array =
35+
"("
36+
+ (builtins.concatStringsSep
37+
" "
38+
(builtins.map
39+
(x: "\"" + x.name + "\"")
40+
producers
41+
)
42+
)
43+
+ ")"
44+
;
45+
46+
in ''
47+
######################################################################
48+
# Entrypoint #########################################################
49+
######################################################################
50+
51+
function hydra {
52+
# Run the producer workflow for each deployed producer.
53+
local producers=${toString producers_bash_array}
54+
for producer_name in ''${producers[*]}
55+
do
56+
if test -d "../../''${producer_name}"
57+
then
58+
hydra_deployed "''${producer_name}"
59+
fi
60+
done
61+
}
62+
63+
function hydra_deployed {
64+
# Function arguments.
65+
local producer_name=$1 # node name / folder to find the socket to use.
66+
67+
local producer_i
68+
producer_i="$( \
69+
${jq}/bin/jq --raw-output \
70+
--arg keyName "''${producer_name}" \
71+
'.[$keyName].i' \
72+
../../node-specs.json \
73+
)"
74+
75+
msg "Starting: \"''${producer_name}\" (''${producer_i})"
76+
77+
# Parameters for this node:
78+
# - Where to obtain the genesis funds from.
79+
genesis_funds_vkey="../../genesis/cache-entry/utxo-keys/utxo$((producer_i + 1)).vkey"
80+
genesis_funds_skey="../../genesis/cache-entry/utxo-keys/utxo$((producer_i + 1)).skey"
81+
# - IP address and port.
82+
producer_port="$((${toString baseport} + producer_i))"
83+
84+
msg "Params: ''${genesis_funds_vkey} - ''${genesis_funds_skey} - ''${baseport}"
85+
86+
${hydra}/bin/hydra-node \
87+
--node-id "''${producer_i}" \
88+
--listen "127.0.0.1:''${producer_port}" \
89+
--advertise "127.0.0.1:''${producer_port}" \
90+
--cardano-verification-key "''${genesis_funds_vkey}" \
91+
--cardano-signing-key "''${genesis_funds_skey}" \
92+
--testnet-magic ${toString testnet_magic} \
93+
--node-socket "../../''${node-str}/node.socket" \
94+
--config ./config.yaml
95+
}
96+
97+
######################################################################
98+
# Utils ##############################################################
99+
######################################################################
100+
101+
function msg {
102+
# Outputs to stdout, unbuffered if not the message may be lost!
103+
${coreutils}/bin/stdbuf -o0 \
104+
${bashInteractive}/bin/sh -c \
105+
"${coreutils}/bin/echo -e \"$(${coreutils}/bin/date --rfc-3339=seconds): $1\""
106+
}
107+
''

0 commit comments

Comments
 (0)