Skip to content

Commit

Permalink
Merge #3879
Browse files Browse the repository at this point in the history
3879: Workbench:  integrate cardano-tracer r=denisshevchenko a=deepfire

1. `cardano-node-service` -- a NixOS service
2. workbench integration -- with several profiles
3. a bunch of `Makefile` targets -- for the above profiles -- including the `-auto`, `-nix` and `-autonix` variants:
    - `startstop-tracer`
    - `10-tracer`
    - `forge-stress-tracer`
    - `chainsync-early-byron-tracer`
    - `chainsync-early-alonzo-tracer`

Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io>
Co-authored-by: Denis Shevchenko <denis.shevchenko@iohk.io>
  • Loading branch information
3 people committed May 23, 2022
2 parents d0b0fa1 + 12cce26 commit 0f6a20d
Show file tree
Hide file tree
Showing 21 changed files with 494 additions and 223 deletions.
12 changes: 6 additions & 6 deletions Makefile
@@ -1,5 +1,5 @@
help: ## Print documentation
@{ grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST); echo -e '$(EXTRA_HELP)'; } | sed 's/^ //' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@{ grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST); echo -e '$(EXTRA_HELP)'; } | sed 's/^ //' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-33s\033[0m %s\n", $$1, $$2}'

include lib.mk
include nix.mk
Expand Down Expand Up @@ -53,13 +53,13 @@ ps: ## Plain-text list of profiles
##
## Profile-based cluster shells (autogenerated targets)
##
SHELL_PROFILES += fixed
SHELL_PROFILES += quick quick-oldtracing
SHELL_PROFILES += startstop startstop-tracer startstop-oldtracing
SHELL_PROFILES += smoke 10 10-tracer plutus

SHELL_PROFILES += forge-stress forge-stress-plutus forge-stress-oldtracing
SHELL_PROFILES += forge-stress forge-stress-plutus forge-stress-tracer forge-stress-oldtracing

SHELL_PROFILES += chainsync-early-byron chainsync-early-byron-oldtracing
SHELL_PROFILES += chainsync-early-alonzo chainsync-early-alonzo-oldtracing
SHELL_PROFILES += chainsync-early-byron chainsync-early-byron-tracer chainsync-early-byron-oldtracing
SHELL_PROFILES += chainsync-early-alonzo chainsync-early-alonzo-tracer chainsync-early-alonzo-oldtracing

## Note: to enable a shell for a profile, just add its name (one of names from 'make ps') to SHELL_PROFILES

Expand Down
32 changes: 16 additions & 16 deletions flake.nix
Expand Up @@ -270,22 +270,22 @@
## TODO: drop external membench, once we bump 'node-snapshot'
# snapshot = membench.outputs.packages.x86_64-linux.snapshot;
membenches = pkgs.membench-node-this-5.batch-report;
workbench-smoke-test =
(pkgs.supervisord-workbench-for-profile
{
inherit supervisord-workbench;
profileName = "smoke-alzo";
}
).profile-run { trace = true; };
workbench-ci-test =
(pkgs.supervisord-workbench-for-profile
{
inherit supervisord-workbench;
profileName = "k6-600slots-1000kU-1000kD-64kbs-10tps-fixed-loaded-alzo";
}
).profile-run { };
workbench-smoke-analysis = workbench-smoke-test.analysis;
workbench-ci-analysis = workbench-ci-test.analysis;
# workbench-smoke-test =
# (pkgs.supervisord-workbench-for-profile
# {
# inherit supervisord-workbench;
# profileName = "smoke-alzo";
# }
# ).profile-run { trace = true; };
# workbench-ci-test =
# (pkgs.supervisord-workbench-for-profile
# {
# inherit supervisord-workbench;
# profileName = "k6-600slots-1000kU-1000kD-64kbs-10tps-fixed-loaded-alzo";
# }
# ).profile-run { };
# workbench-smoke-analysis = workbench-smoke-test.analysis;
# workbench-ci-analysis = workbench-ci-test.analysis;
all-profiles-json = pkgs.all-profiles-json;
}
# Add checks to be able to build them individually
Expand Down
2 changes: 1 addition & 1 deletion lib.mk
Expand Up @@ -10,7 +10,7 @@ $(1): CMD := start-cluster; exit
endif
ifeq ($(3)$(4),truefalse)
define EXTRA_HELP +=
$(1): ## Shell for profile $(2) (also -auto -nix -autonix)\n
$(1): ## Shell for profile \033[34m$(2)\033[0m (also: \033[34m-auto -nix -autonix\033[0m)\n
endef
endif

Expand Down
8 changes: 4 additions & 4 deletions nix.mk
@@ -1,6 +1,6 @@
bump-cardano-node-workbench: ## Update the cardano-node-workbench flake input
bump-cardano-node-workbench:
nix flake lock --update-input cardano-node-workbench
bump-node-measured: ## Update the node-measured flake input
bump-node-measured:
nix flake lock --update-input node-measured
bump-cardano-deployment: ## Sync the flake.lock to the CI check
nix run nixpkgs#nixUnstable -- build .#hydraJobs.cardano-deployment
Expand All @@ -13,11 +13,11 @@ membench-5: ## Membench: 5 iterations, current commit
membench-5-at: ## Membench: 5 iterations, set commit by: make membench-5-at REV=[master]
nix build .#membench-node-this-5.batch-report --out-link result-batch-5-report --override-input node-measured github:input-output-hk/cardano-node/${REV}

test-smoke: smoke ## Build the 'workbench-smoke-test', same as the Hydra job
test-smoke: smoke ## Build the 'workbench-smoke-test' flake attr, same as the Hydra job
smoke:
nix build -f 'default.nix' 'workbench-smoke-test' --out-link result-smoke-run --cores 0

test-analysis: smoke-analysis ## Build the 'workbench-smoke-analysis', same as the Hydra job
test-analysis: smoke-analysis ## Build the 'workbench-smoke-analysis' flake attr, same as the Hydra job
smoke-analysis:
nix build -f 'default.nix' 'workbench-smoke-analysis' --out-link result-smoke-analysis --cores 0 --show-trace

Expand Down
6 changes: 6 additions & 0 deletions nix/nixos/cardano-node-service.nix
Expand Up @@ -318,6 +318,12 @@ in {
description = ''Local communication socket path.'';
};

tracerSocketPath = mkOption {
type = types.nullOr types.str;
default = null;
description = ''Connect and forward traces to cardano-tracer's local socket.'';
};

systemdSocketActivation = mkOption {
type = types.bool;
default = false;
Expand Down
89 changes: 89 additions & 0 deletions nix/nixos/cardano-tracer-service.nix
@@ -0,0 +1,89 @@
pkgs:
let serviceConfigToJSON =
cfg:
{
networkMagic = 764824073; ## Mainnet
# loRequestNum = 100;
network =
if cfg.acceptingSocket != null
then {
tag = "AcceptAt";
contents = cfg.acceptingSocket;
} else if cfg.connectToSocket != null
then {
tag = "ConnectTo";
contents = cfg.connectToSocket;
} else
throw "cardano-tracer-service: either acceptingSocket or connectToSocket must be provided.";
logging = [{
inherit (cfg) logRoot;

logMode = "FileMode";
logFormat = "ForMachine";
}];
rotation = {
rpFrequencySecs = 15;
rpKeepFilesNum = 10;
rpLogLimitBytes = 500000000;
rpMaxAgeHours = 24;
};

hasEKG = [
{ epHost = "127.0.0.1";
epPort = 3100; ## supervisord.portShiftPrometheus
}
{ epHost = "127.0.0.1";
epPort = 3101; ## supervisord.portShiftPrometheus
}
];
ekgRequestFreq = 1;
hasPrometheus = {
epHost = "127.0.0.1";
epPort = 3200; ## supervisord.portShiftPrometheus
};
};
in pkgs.commonLib.defServiceModule
(lib: with lib;
{ svcName = "cardano-tracer";
svcDesc = "Cardano trace processor";

svcPackageSelector =
pkgs: ## Local:
pkgs.cardanoNodePackages.cardano-tracer
## Imported by another repo, that adds an overlay:
or pkgs.cardano-tracer;
## TODO: that's actually a bit ugly and could be improved.
## This exe has to be available in the selected package.
exeName = "cardano-tracer";

extraOptionDecls = {
### You can actually change those!
acceptingSocket = mayOpt str "Socket path: as acceptor.";
connectToSocket = mayOpt str "Socket path: connect to.";
logRoot = opt str null "Log storage root directory.";

### Here be dragons, on the other hand..
configFile = mayOpt str
"Config file path override -- only set if you know what you're doing. Shudder. Your 'eminence'..";
configJSONfn = opt (functionTo attrs) serviceConfigToJSON
"This is NOT meant to be overridden, at all -- we only expose it so it's externally accessible.";
};

configExeArgsFn = cfg: [
"--config" (if cfg.configFile != null then cfg.configFile
else "${pkgs.writeText "cardano-tracer-config.json"
(__toJSON (serviceConfigToJSON cfg))}")
];

configSystemdExtraConfig = _: {};

configSystemdExtraServiceConfig =
cfg: with cfg; {
Type = "exec";
User = "cardano-node";
Group = "cardano-node";
Restart = "yes";
# RuntimeDirectory = localNodeConf.runtimeDir;
# WorkingDirectory = localNodeConf.stateDir;
};
})
3 changes: 2 additions & 1 deletion nix/nixos/tx-generator-service.nix
Expand Up @@ -80,7 +80,8 @@ in pkgs.commonLib.defServiceModule
inputs_per_tx = opt int 4 "Inputs per Tx.";
outputs_per_tx = opt int 4 "Outputs per Tx.";
tx_fee = opt int 10000000 "Tx fee, in Lovelace.";
tps = opt int 100 "Strength of generated load, in TPS.";
tps = opt (either float int) 100
"Strength of generated load, in TPS.";
init_cooldown = opt int 50 "Delay between init and main submissions.";
min_utxo_value = opt int 10000000 "Minimum value allowed per UTxO entry";
runScriptFn = opt (functionTo attrs) defaultGeneratorScriptFn
Expand Down
6 changes: 3 additions & 3 deletions nix/workbench/default.nix
Expand Up @@ -33,17 +33,17 @@ let
dontStrip = true;
};

workbench = with cardanoNodePackages; with pkgs; workbench'
workbench = with cardanoNodePackages; with pkgs; workbench' (
[ git graphviz
jq
moreutils
procps

cardano-cli
cardano-topology
db-analyser
] ++ lib.optional (!pkgs.stdenv.hostPlatform.isDarwin) db-analyser ++ [
locli
];
]);

runWorkbench =
name: command:
Expand Down
12 changes: 11 additions & 1 deletion nix/workbench/profile.nix
Expand Up @@ -26,14 +26,24 @@ pkgs.runCommand "workbench-profile-output-${profileNix.name}"
start = startupScript;
run-script = runScript.JSON;
};
passAsFile = [ "nodeServices" "generatorService" ];
tracerService =
with profileNix.tracer-service;
__toJSON
{ name = "tracer";
tracer-config = tracer-config.JSON;
nixos-service-config = nixos-service-config.JSON;
config = config.JSON;
start = startupScript;
};
passAsFile = [ "nodeServices" "generatorService" "tracerService" ];
}
''
mkdir $out
cp ${profileNix.JSON} $out/profile.json
cp ${backendProfile}/* $out
cp $nodeServicesPath $out/node-services.json
cp $generatorServicePath $out/generator-service.json
cp $tracerServicePath $out/tracer-service.json
wb profile node-specs $out/profile.json > $out/node-specs.json
''
42 changes: 1 addition & 41 deletions nix/workbench/profiles/adhoc.jq
@@ -1,45 +1,5 @@
def adhoc_profiles:
[ { name: "default"
, desc: "Default profile, as per nix/workbench/profiles/defaults.jq"
}

, { name: "short"
, generator: { tx_count: 10000, inputs_per_tx: 1, outputs_per_tx: 1, tps: 100 }
, genesis: { genesis_future_offset: "3 minutes" }
}
, { name: "small"
, generator: { tx_count: 1000, inputs_per_tx: 1, outputs_per_tx: 1, tps: 100
, init_cooldown: 25 }
, analysis: { finish_patience: 4 }
, genesis: { genesis_future_offset: "3 minutes" }
}
# , { name: "smoke"
# , generator: { tx_count: 100, add_tx_size: 0, inputs_per_tx: 1, outputs_per_tx: 1, tps: 100
# , init_cooldown: 25 }
# , analysis: { finish_patience: 4 }
# , genesis: { genesis_future_offset: "3 minutes", delegators: 4 }
# }
, { name: "smoke-plutus"
, generator: { tx_count: 100, add_tx_size: 0, inputs_per_tx: 1, outputs_per_tx: 1, tps: 100
, init_cooldown: 25
, plutusMode: true
, plutusAutoMode: true
, debugMode: false }
, analysis: { finish_patience: 4 }
, genesis: { genesis_future_offset: "3 minutes" }
}
, { name: "10"
, composition:
{ n_singular_hosts: 10
, n_dense_hosts: 0
}
, genesis:
{ genesis_future_offset: "10 seconds"
, utxo: 0
}
}

, { name: "devops"
[ { name: "devops"
, genesis:
{ slot_duration: 0.2
, parameter_k: 10
Expand Down
5 changes: 5 additions & 0 deletions nix/workbench/profiles/default.nix
Expand Up @@ -54,6 +54,11 @@ let
./generator-service.nix
{ inherit runJq backend profile; })
generator-service;

inherit (pkgs.callPackage
./tracer-service.nix
{ inherit runJq backend profile; })
tracer-service;
};

in profile
16 changes: 5 additions & 11 deletions nix/workbench/profiles/defaults.jq
Expand Up @@ -74,6 +74,7 @@ def era_defaults($era):
{ rts_flags_override: []
, shutdown_on_slot_synced: null
, tracing_backend: "trace-dispatcher" ## or "iohk-monitoring"
, tracer: true
}

, analysis:
Expand Down Expand Up @@ -103,15 +104,8 @@ def era_defaults($era):
}

, alonzo:
{ genesis:
{ shelley:
{ protocolParams:
{ protocolVersion:
{ major: 5
, minor: 0
}
}
}
}
}
(.genesis.shelley.protocolParams.protocolVersion =
{ major: 5
, minor: 0
})
} | (.common * .[$era]);
2 changes: 1 addition & 1 deletion nix/workbench/profiles/derived.jq
Expand Up @@ -128,7 +128,7 @@ def add_derived_params:
, utxo_delegated: $effective_delegators
, utxo_generated: $utxo_generated
## Stuffed UTxO is what we need over requested-UTxO + delegators' UTxO:
, utxo_stuffed: ([ $gsis.utxo - $utxo_generated - $effective_delegators
, utxo_stuffed: ([ $gsis.utxo
, 0
] | max)

Expand Down
13 changes: 8 additions & 5 deletions nix/workbench/profiles/genesis.jq
@@ -1,9 +1,12 @@
## WARNING: keep in sync with 'profile-cache-key-input' below this one: vvv
##
def fmt_decimal_10_5($x):
($x / 100000 | tostring) + "00000";

def profile_cli_args($p):
{ common:
{ createSpec:
[ "--supply", $p.derived.supply_total
[ "--supply", fmt_decimal_10_5($p.derived.supply_total)
, "--testnet-magic", $p.genesis.network_magic
, "--gen-genesis-keys", $p.composition.n_bft_hosts
, "--gen-utxo-keys", 1
Expand All @@ -17,14 +20,14 @@ def profile_cli_args($p):
[ ]
else [] end)
, createFinalBulk:
([ "--supply", $p.genesis.funds_balance
([ "--supply", fmt_decimal_10_5($p.genesis.funds_balance)
, "--gen-utxo-keys", 1
, "--gen-genesis-keys", $p.composition.n_bft_hosts
, "--supply-delegated", $p.derived.supply_delegated
, "--supply-delegated", fmt_decimal_10_5($p.derived.supply_delegated)
, "--gen-pools", $p.composition.n_pools
, "--gen-stake-delegs", $p.derived.delegators_effective
, "--testnet-magic", $p.genesis.network_magic
, "--num-stuffed-utxo", $p.derived.utxo_stuffed
, "--num-stuffed-utxo", fmt_decimal_10_5($p.derived.utxo_stuffed)
] +
if $p.composition.dense_pool_density != 1
then
Expand All @@ -33,7 +36,7 @@ def profile_cli_args($p):
else [] end)
, pools:
[ "--argjson"
, "initialPoolCoin", $p.genesis.pool_coin
, "initialPoolCoin", fmt_decimal_10_5($p.genesis.pool_coin)
]
}
}
Expand Down

0 comments on commit 0f6a20d

Please sign in to comment.