From 8d3de1ea56373d77a7b9e97650f6aea25e5c93d3 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Fri, 20 May 2022 01:31:58 +0300 Subject: [PATCH 1/6] workbench: update, clean up and bring structure to profile definitions --- Makefile | 6 +- lib.mk | 2 +- nix.mk | 8 +- nix/workbench/profiles/adhoc.jq | 42 +--- nix/workbench/profiles/defaults.jq | 15 +- nix/workbench/profiles/genesis.jq | 13 +- nix/workbench/profiles/profiles.jq | 6 +- nix/workbench/profiles/variants.jq | 302 +++++++++++++++++------------ 8 files changed, 197 insertions(+), 197 deletions(-) diff --git a/Makefile b/Makefile index 29964da17e8..5fbd0694ee5 100644 --- a/Makefile +++ b/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 @@ -53,8 +53,8 @@ ps: ## Plain-text list of profiles ## ## Profile-based cluster shells (autogenerated targets) ## -SHELL_PROFILES += fixed -SHELL_PROFILES += quick quick-oldtracing +SHELL_PROFILES += startstop startstop-oldtracing +SHELL_PROFILES += smoke 10 plutus SHELL_PROFILES += forge-stress forge-stress-plutus forge-stress-oldtracing diff --git a/lib.mk b/lib.mk index f09bb64d249..98fc5596f1a 100644 --- a/lib.mk +++ b/lib.mk @@ -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 diff --git a/nix.mk b/nix.mk index 4ac423abb53..8217709156c 100644 --- a/nix.mk +++ b/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 @@ -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 diff --git a/nix/workbench/profiles/adhoc.jq b/nix/workbench/profiles/adhoc.jq index 131bec32481..9cf451c1d95 100644 --- a/nix/workbench/profiles/adhoc.jq +++ b/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 diff --git a/nix/workbench/profiles/defaults.jq b/nix/workbench/profiles/defaults.jq index cd5d4c9e4d7..bb404d1df3b 100644 --- a/nix/workbench/profiles/defaults.jq +++ b/nix/workbench/profiles/defaults.jq @@ -103,15 +103,8 @@ def era_defaults($era): } , alonzo: - { genesis: - { shelley: - { protocolParams: - { protocolVersion: - { major: 5 - , minor: 0 - } - } - } - } - } + (.genesis.shelley.protocolParams.protocolVersion = + { major: 5 + , minor: 0 + }) } | (.common * .[$era]); diff --git a/nix/workbench/profiles/genesis.jq b/nix/workbench/profiles/genesis.jq index ee2f30148aa..f3d9196b399 100644 --- a/nix/workbench/profiles/genesis.jq +++ b/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 @@ -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 @@ -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) ] } } diff --git a/nix/workbench/profiles/profiles.jq b/nix/workbench/profiles/profiles.jq index 1295a848c63..025f8f43d35 100644 --- a/nix/workbench/profiles/profiles.jq +++ b/nix/workbench/profiles/profiles.jq @@ -69,7 +69,6 @@ def compute_profiles($era; $mcompo; $topo; $extra_profiles): ## Profiles are variants + custom (or aux) profiles: | all_profile_variants + adhoc_profiles + $extra_profiles - | map (## Each profile extends defaults: era_defaults($era) * . @@ -83,10 +82,7 @@ def compute_profiles($era; $mcompo; $topo; $extra_profiles): def profiles($era; $mcompo; $topo; $extra_profiles): compute_profiles($era; $mcompo; $topo; $extra_profiles) | map (## Assemble into a dictionary.. - { "\(.name)": - ## ..and cleanup: - . - # | delpaths ([["generator", "epochs"]]) + { "\(.name)": . }) | add; diff --git a/nix/workbench/profiles/variants.jq b/nix/workbench/profiles/variants.jq index 963fce2b999..b13128276b4 100644 --- a/nix/workbench/profiles/variants.jq +++ b/nix/workbench/profiles/variants.jq @@ -1,66 +1,149 @@ ## Profile variants are defined as a cartesian product of ## variations of genesis/generator/node axes. -def genesis_profile_variants: - { scenario: "fixed-loaded" - , composition: - { n_singular_hosts: 2 - , n_dense_hosts: 0 +def all_profile_variants: + 1024 as $Ki + | 1000000 as $M + #################################################################################################### + ## + ### Record history + ## + | { genesis: + { utxo: (4 * $M) + , delegators: (1 * $M) } - , genesis: - { utxo: 6000 - , delegators: 1300 - , max_block_size: 80000 - , epoch_length: 600 - , parameter_k: 3 + } as $dataset_oct2021 + | + ({} | + .genesis.max_block_size = (72 * $Ki) + ) as $blocksize_dec2021 + | + { genesis: + ({} | + .max_block_size = (72 * $Ki) | ## ??? + .alonzo.maxTxExUnits.exUnitsMem = (12.5 * $M) ) ## RMT-54 CR.059 + } as $params_jan2022 + | + { genesis: + ({}| + .max_block_size = (80 * $Ki) | ## RMT-56 CAD-3891 CR.061 + .alonzo.maxTxExUnits.exUnitsMem = (14 * $M) | ## RMT-56 + .alonzo.maxBlockExUnits.exUnitsMem = (56 * $M)) ## CAD-3945 + } as $params_feb2022 + | + { genesis: + { utxo: (6 * $M) + , delegators: (1.3 * $M) } - , node: - { shutdown_on_slot_synced: 10 + } as $dataset_mar2022 + | + { genesis: + { max_block_size: (88 * $Ki) } ## CAD-4153 CR.068 + } as $blocksize_may2022 + | + { genesis: + { utxo: (8 * $M) + , delegators: (1.3 * $M) } - , generator: { tps: 15 } - , analysis: - { type: "standard" + } as $dataset_jun2022 + | + { genesis: + ({}| + .alonzo.maxBlockExUnits.exUnitsMem = (62 * $M)) ## CAD-3991 CR.064 + } as $plutus_next + | + # #################################################################################################### + # ## + # ### Status quo + # ## + $dataset_jun2022 + as $current_dataset + | + ({}| + .genesis.max_block_size = $params_feb2022.genesis.max_block_size + ) as $current_block_size + | + ({}| + .genesis.alonzo = $params_feb2022.genesis.alonzo + ) as $current_plutus + | + ($current_dataset * + $current_block_size * + $current_plutus + ) as $status_quo + | + # #################################################################################################### + # ## + # ### Definition vocabulary + # ## + ({}| + .generator.tps = 15 + ) as $saturation_tps_value + | + ({}| + .generator.tps = 0.2 + ) as $saturation_tps_plutus + | + { composition: + { n_singular_hosts: 1 + , n_dense_hosts: 0 } - } as $quick_base + } as $singleton | - { scenario: "fixed-loaded" - , composition: + { composition: { n_singular_hosts: 2 , n_dense_hosts: 0 } - , genesis: - { utxo: 6000000 - , delegators: 1300000 - , max_block_size: 80000 - , epoch_length: 600 - , parameter_k: 3 - } - , node: - { shutdown_on_slot_synced: 2400 - } - , generator: { tps: 15 } - } as $forge_stress_base + } as $doublet + | + ({}| + .node.tracing_backend = "iohk-monitoring" + ) as $old_tracing | { genesis: - { alonzo: - { maxTxExUnits: - { exUnitsMem: 12500000 - } - } + { epoch_length: 600 + , parameter_k: 3 } - , generator: + } as $compressed + | + ($compressed * $saturation_tps_value * + { scenario: "fixed-loaded" + , analysis: + { type: "standard" } + }) as $fixed_loaded + | + ($fixed_loaded * $saturation_tps_plutus * + { generator: { inputs_per_tx: 1 , outputs_per_tx: 1 , plutusMode: true , plutusAutoMode: true } , analysis: - { filters: ["base", "size-small"] + { type: "standard" + , filters: ["base", "size-small"] + } + }) as $plutus + | + ($fixed_loaded * $doublet * + { genesis: + { utxo: 6000 + , delegators: 1300 + , max_block_size: 80000 + } + , node: + { shutdown_on_slot_synced: 10 + } + }) as $startstop_base + | + ($status_quo * $fixed_loaded * $doublet * + { node: + { shutdown_on_slot_synced: 2400 } - } as $plutus_base + }) as $forge_stress_base | - { scenario: "chainsync" - , preset: "mainnet" + { scenario: "chainsync" + , preset: "mainnet" , composition: { n_singular_hosts: 0 , n_dense_hosts: 0 @@ -68,15 +151,10 @@ def genesis_profile_variants: , with_observer: true } , analysis: - { type: "performance" + { type: "performance" , filters: [] } } as $chainsync_base - | - { node: - { tracing_backend: "iohk-monitoring" - } - } as $old_tracing | { chaindb: { mainnet_chunks: @@ -95,6 +173,7 @@ def genesis_profile_variants: } } as $chaindb_early_byron | + ($dataset_oct2021 * { chaindb: { mainnet_chunks: { chaindb_server: 1800 @@ -110,95 +189,80 @@ def genesis_profile_variants: { observer: 38901589 } } - , genesis: - { utxo: 6000000 - , delegators: 1300000 - } - } as $chaindb_early_alonzo + }) as $chaindb_early_alonzo | + #################################################################################################### + ## + ### Actual profiles + ## ## Baseline: - [ { genesis: { utxo: 4000000, delegators: 1000000 } } + [ { name: "default" + , desc: "Default profile, as per nix/workbench/profiles/defaults.jq" + } - ## Baseline, tweaked for fast local repro: - , { genesis: { utxo: 4000000, delegators: 1000000 - , slot_duration: 0.2 } - , composition: { with_observer: false }} + ## Short slots: + , $status_quo * + ({}| + .genesis.slot_duration = 0.2 ) - ## Size-varied derivatives of baseline: - , { genesis: { utxo: 4000000, delegators: 1000000 } } - , { genesis: { utxo: 5000000, delegators: 1250000 } } - , { genesis: { utxo: 6000000, delegators: 1500000 } } - , { genesis: { utxo: 4000000, delegators: 1000000, dense_pool_density: 2 } } - , { genesis: { utxo: 4000000, delegators: 1000000, dense_pool_density: 3 } } - , { genesis: { utxo: 4000000, delegators: 1000000, dense_pool_density: 10 } } + ## Dense pool: + , $status_quo * + ({}| + .genesis.dense_pool_density = 10 ) - ## TPS-varied derivatives of baseline: - , { genesis: { utxo: 4000000, delegators: 1000000 } - , generator: { tps: 5 } } - , { genesis: { utxo: 4000000, delegators: 1000000 } - , generator: { tps: 10 } } + ## Sub-saturation TPS: + , ($status_quo | .generator.tps = 5 ) + , ($status_quo | .generator.tps = 10 ) - ## Calibration: - , { genesis: { utxo: 2000000, delegators: 1000000, max_block_size: 128000 } - , generator: { tps: 16 } } - , { genesis: { utxo: 2000000, delegators: 1000000, max_block_size: 256000 } - , generator: { tps: 32 } } - , { genesis: { utxo: 2000000, delegators: 500000, max_block_size: 512000 } - , generator: { tps: 64 } } - , { genesis: { utxo: 2000000, delegators: 500000, max_block_size: 1024000 } - , generator: { tps: 128 } } - , { genesis: { utxo: 2000000, delegators: 500000, max_block_size: 2048000 } - , generator: { tps: 256 } } + ## Block size: + , ($status_quo | .genesis.max_block_size = 128000 | .generator.tps = 16 ) + , ($status_quo | .genesis.max_block_size = 256000 | .generator.tps = 32 ) + , ($status_quo | .genesis.max_block_size = 512000 | .generator.tps = 64 ) + , ($status_quo | .genesis.max_block_size = 1024000 | .generator.tps = 128 ) + , ($status_quo | .genesis.max_block_size = 2048000 | .generator.tps = 256 ) ## Fixed - , { name: "fixed" - , scenario: "fixed" - , genesis: { utxo: 4000000, delegators: 1000000 } - , node: - { shutdown_on_slot_synced: 150 - } + , $startstop_base * + { name: "startstop" } - , { name: "smoke" - , scenario: "fixed-loaded" - , node: - { shutdown_on_slot_synced: 60 - } - , generator: { tps: 10 } + , $startstop_base * $old_tracing * + { name: "startstop-oldtracing" } - , { scenario: "fixed-loaded" - , genesis: { utxo: 1000000, delegators: 1000000 } + + , $fixed_loaded * $saturation_tps_value * + { name: "smoke" , node: - { shutdown_on_slot_synced: 600 + { shutdown_on_slot_synced: 80 } - , generator: { tps: 10 } } - , $forge_stress_base * - { name: "forge-stress" + , $compressed * + { name: "10" + , composition: + { n_singular_hosts: 10 + , n_dense_hosts: 0 + } } - , $forge_stress_base * $old_tracing * - { name: "forge-stress-oldtracing" + , $plutus * + { name: "plutus" + , generator: + { tx_count: 800 + } } , $forge_stress_base * - $plutus_base * + { name: "forge-stress" + } + , $forge_stress_base * $plutus * $singleton * { name: "forge-stress-plutus" - , composition: - { n_singular_hosts: 1 - } , generator: { tx_count: 800 } } - - , $quick_base * - { name: "quick" - } - - , $quick_base * $old_tracing * - { name: "quick-oldtracing" + , $forge_stress_base * $old_tracing * + { name: "forge-stress-oldtracing" } , $chainsync_base * $chaindb_early_byron * @@ -215,19 +279,3 @@ def genesis_profile_variants: { name: "chainsync-early-alonzo-oldtracing" } ]; - -def generator_profile_variants: - [ { generator: {} } - ]; - -def node_profile_variants: - [ { node: {} } - ]; - -def all_profile_variants: - [ genesis_profile_variants - , generator_profile_variants - , node_profile_variants - ] - | [combinations] - | map (reduce .[] as $item ({}; . * $item)); From 9437bb2176317b456b725deaf1f8b5c1c364db45 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Fri, 20 May 2022 01:35:41 +0300 Subject: [PATCH 2/6] tx-generator.service: allow float tps values --- nix/nixos/tx-generator-service.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nix/nixos/tx-generator-service.nix b/nix/nixos/tx-generator-service.nix index e49fda849e1..23f02687a61 100644 --- a/nix/nixos/tx-generator-service.nix +++ b/nix/nixos/tx-generator-service.nix @@ -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 From 9b462c7cb175c620e1cf976796cfe2d093ed45a5 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Fri, 20 May 2022 01:55:26 +0300 Subject: [PATCH 3/6] workbench: make the genesis cache less unnecessarily dependent on profile variance --- nix/workbench/profiles/derived.jq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/workbench/profiles/derived.jq b/nix/workbench/profiles/derived.jq index 1d7da946418..cb8c59e8f9e 100644 --- a/nix/workbench/profiles/derived.jq +++ b/nix/workbench/profiles/derived.jq @@ -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) From 431e9720f626a241566835dd69e5beb5f11cd2b0 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Fri, 20 May 2022 04:23:59 +0300 Subject: [PATCH 4/6] workbench: add & integrate cardano-tracer service --- Makefile | 10 +- nix/nixos/cardano-node-service.nix | 6 ++ nix/nixos/cardano-tracer-service.nix | 89 +++++++++++++++++ nix/workbench/profile.nix | 12 ++- nix/workbench/profiles/default.nix | 5 + nix/workbench/profiles/defaults.jq | 1 + nix/workbench/profiles/tracer-service.nix | 112 ++++++++++++++++++++++ nix/workbench/profiles/tracing.nix | 7 +- nix/workbench/profiles/variants.jq | 44 ++++++--- nix/workbench/run.sh | 8 ++ nix/workbench/supervisor-conf.nix | 11 +++ nix/workbench/supervisor.nix | 9 ++ 12 files changed, 292 insertions(+), 22 deletions(-) create mode 100644 nix/nixos/cardano-tracer-service.nix create mode 100644 nix/workbench/profiles/tracer-service.nix diff --git a/Makefile b/Makefile index 5fbd0694ee5..2205d8a8e10 100644 --- a/Makefile +++ b/Makefile @@ -53,13 +53,13 @@ ps: ## Plain-text list of profiles ## ## Profile-based cluster shells (autogenerated targets) ## -SHELL_PROFILES += startstop startstop-oldtracing -SHELL_PROFILES += smoke 10 plutus +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 diff --git a/nix/nixos/cardano-node-service.nix b/nix/nixos/cardano-node-service.nix index 874c41235de..c2d2b4c3ac3 100644 --- a/nix/nixos/cardano-node-service.nix +++ b/nix/nixos/cardano-node-service.nix @@ -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; diff --git a/nix/nixos/cardano-tracer-service.nix b/nix/nixos/cardano-tracer-service.nix new file mode 100644 index 00000000000..e853161cfdf --- /dev/null +++ b/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; + }; + }) diff --git a/nix/workbench/profile.nix b/nix/workbench/profile.nix index 326485589b4..90f620458fe 100644 --- a/nix/workbench/profile.nix +++ b/nix/workbench/profile.nix @@ -26,7 +26,16 @@ 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 @@ -34,6 +43,7 @@ pkgs.runCommand "workbench-profile-output-${profileNix.name}" 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 '' diff --git a/nix/workbench/profiles/default.nix b/nix/workbench/profiles/default.nix index cae5d0eadec..017493a63b7 100644 --- a/nix/workbench/profiles/default.nix +++ b/nix/workbench/profiles/default.nix @@ -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 diff --git a/nix/workbench/profiles/defaults.jq b/nix/workbench/profiles/defaults.jq index bb404d1df3b..e17956f6bfa 100644 --- a/nix/workbench/profiles/defaults.jq +++ b/nix/workbench/profiles/defaults.jq @@ -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: diff --git a/nix/workbench/profiles/tracer-service.nix b/nix/workbench/profiles/tracer-service.nix new file mode 100644 index 00000000000..e3c1fee5a53 --- /dev/null +++ b/nix/workbench/profiles/tracer-service.nix @@ -0,0 +1,112 @@ +{ pkgs +, runJq + +## The backend is an attrset of AWS/supervisord-specific methods and parameters. +, backend + +, profile +}: + +with pkgs.lib; + +let + # We're reusing configuration from a cluster node. + nodes = profile.node-services; + + ## + ## nodeSpecsTracerConfig :: Map NodeId NodeSpec -> TracerConfig + ## + nodeSpecsTracerConfig = + nodeSpecs: + let + in + backend.finaliseTracerService + { + ## In both the local and remote scenarios, it's most frequently convenient to act as an acceptor. + acceptingSocket = "tracer.socket"; + + ## logRoot = ## ..really depends on context -- available in backend.finaliseTracerService + + dsmPassthrough = { + # rtsOpts = ["-xc"]; + }; + }; + + ## Given an env config, evaluate it and produce the service. + ## + ## tracerConfigServiceConfig :: TracerConfig -> NixosServiceConfig + ## + tracerConfigServiceConfig = + tracerConfig: + let + systemdCompat.options = { + systemd.services = mkOption {}; + systemd.sockets = mkOption {}; + users = mkOption {}; + assertions = mkOption {}; + }; + eval = let + extra = { + services.cardano-tracer = { + enable = true; + } // tracerConfig; + }; + in evalModules { + prefix = []; + modules = import ../../nixos/module-list.nix ++ [ + (import ../../nixos/cardano-tracer-service.nix pkgs) + systemdCompat extra + ]; + args = { inherit pkgs; }; + }; + in eval.config.services.cardano-tracer; + + ## + ## generator-service :: (TracerConfig, NixosServiceConfig, Config, StartScript) + ## + tracer-service = + (nodeSpecs: + let + tracerConfig = nodeSpecsTracerConfig nodeSpecs; + nixosServiceConfig = tracerConfigServiceConfig tracerConfig; + nixosServiceConfigFns = ["configJSONfn"]; + execConfig = nixosServiceConfig.configJSONfn nixosServiceConfig; + in { + tracer-config = { + value = tracerConfig; + JSON = runJq "tracer-config.json" + ''--null-input --sort-keys + --argjson x '${__toJSON tracerConfig}' + '' "$x"; + }; + + nixos-service-config = { + ## XXX: service == appallingly bad name -- it's bona-fide NixOS service "config", not a service! + value = nixosServiceConfig; + JSON = runJq "nixos-service-config.json" + ''--null-input --sort-keys + --argjson x '${__toJSON (removeAttrs nixosServiceConfig nixosServiceConfigFns)}' + '' "$x"; + }; + + config = rec { + value = execConfig; + JSON = runJq "config.json" + ''--null-input + --argjson x '${__toJSON execConfig}' + '' "$x"; + }; + + startupScript = + pkgs.writeScript "startup-tracer.sh" + '' + #!${pkgs.stdenv.shell} + + ${nixosServiceConfig.script} + ''; + }) + profile.node-specs.value; +in +{ + inherit tracer-service; +} diff --git a/nix/workbench/profiles/tracing.nix b/nix/workbench/profiles/tracing.nix index 4d3fd610a29..dd030d0451e 100644 --- a/nix/workbench/profiles/tracing.nix +++ b/nix/workbench/profiles/tracing.nix @@ -7,7 +7,7 @@ backends = [ "Stdout MachineFormat" "EKGBackend" - # "Forwarder" + "Forwarder" ]; }; "Node.AcceptPolicy" = { severity = "Info"; }; @@ -44,9 +44,10 @@ }; TraceOptionForwarder = { - mode = "Responder"; + # mode = "Responder"; + mode = "Initiator"; address = { - filePath = "forwarder.sock"; + filePath = "../tracer/tracer.socket"; }; }; } diff --git a/nix/workbench/profiles/variants.jq b/nix/workbench/profiles/variants.jq index b13128276b4..7d9ae6cdc64 100644 --- a/nix/workbench/profiles/variants.jq +++ b/nix/workbench/profiles/variants.jq @@ -52,10 +52,10 @@ def all_profile_variants: .alonzo.maxBlockExUnits.exUnitsMem = (62 * $M)) ## CAD-3991 CR.064 } as $plutus_next | - # #################################################################################################### - # ## - # ### Status quo - # ## + #################################################################################################### + ## + ### Status quo + ## $dataset_jun2022 as $current_dataset | @@ -72,10 +72,10 @@ def all_profile_variants: $current_plutus ) as $status_quo | - # #################################################################################################### - # ## - # ### Definition vocabulary - # ## + #################################################################################################### + ## + ### Definition vocabulary + ## ({}| .generator.tps = 15 ) as $saturation_tps_value @@ -95,6 +95,16 @@ def all_profile_variants: , n_dense_hosts: 0 } } as $doublet + | + { composition: + { n_singular_hosts: 10 + , n_dense_hosts: 0 + } + } as $tenner + | + ({}| + .node.tracer = true + ) as $with_tracer | ({}| .node.tracing_backend = "iohk-monitoring" @@ -226,6 +236,9 @@ def all_profile_variants: , $startstop_base * { name: "startstop" } + , $startstop_base * $with_tracer * + { name: "startstop-tracer" + } , $startstop_base * $old_tracing * { name: "startstop-oldtracing" } @@ -237,12 +250,11 @@ def all_profile_variants: } } - , $compressed * + , $fixed_loaded * $tenner * { name: "10" - , composition: - { n_singular_hosts: 10 - , n_dense_hosts: 0 - } + } + , $fixed_loaded * $tenner * $with_tracer * + { name: "10-tracer" } , $plutus * @@ -261,6 +273,9 @@ def all_profile_variants: { tx_count: 800 } } + , $forge_stress_base * $old_tracing * $with_tracer * + { name: "forge-stress-tracer" + } , $forge_stress_base * $old_tracing * { name: "forge-stress-oldtracing" } @@ -268,6 +283,9 @@ def all_profile_variants: , $chainsync_base * $chaindb_early_byron * { name: "chainsync-early-byron" } + , $chainsync_base * $chaindb_early_byron * $with_tracer * + { name: "chainsync-early-byron-tracer" + } , $chainsync_base * $chaindb_early_byron * $old_tracing * { name: "chainsync-early-byron-oldtracing" } diff --git a/nix/workbench/run.sh b/nix/workbench/run.sh index 5ff49a2cfee..d5df75386ec 100644 --- a/nix/workbench/run.sh +++ b/nix/workbench/run.sh @@ -373,6 +373,14 @@ case "$op" in cp $(jq '."start"' -r $gtor) "$gen_dir"/start.sh ln -s ../node-0/config.json "$gen_dir" + local trac=$profile/tracer-service.json + trac_dir="$dir"/tracer + mkdir -p "$trac_dir" + cp $(jq '."tracer-config"' -r $trac) "$trac_dir"/tracer-config.json + cp $(jq '."nixos-service-config"' -r $trac) "$trac_dir"/nixos-service-config.json + cp $(jq '."config"' -r $trac) "$trac_dir"/config.json + cp $(jq '."start"' -r $trac) "$trac_dir"/start.sh + backend allocate-run "$dir" progress "run" "allocated $(with_color white $tag) @ $dir" diff --git a/nix/workbench/supervisor-conf.nix b/nix/workbench/supervisor-conf.nix index 4e64a5957ae..5cb33eb6dc4 100644 --- a/nix/workbench/supervisor-conf.nix +++ b/nix/workbench/supervisor-conf.nix @@ -46,6 +46,17 @@ let }; } // + { + "program:tracer" = { + directory = "${stateDir}/tracer"; + command = "sh start.sh"; + stdout_logfile = "${stateDir}/tracer/stdout"; + stderr_logfile = "${stateDir}/tracer/stderr"; + autostart = true; + startretries = 0; + }; + } + // extraSupervisorConfig; ## diff --git a/nix/workbench/supervisor.nix b/nix/workbench/supervisor.nix index 8e15568e2f7..e457c08ea39 100644 --- a/nix/workbench/supervisor.nix +++ b/nix/workbench/supervisor.nix @@ -102,6 +102,15 @@ let ByronGenesisFile = "../genesis/byron/genesis.json"; }); + finaliseTracerService = + svc: recursiveUpdate svc + ({ + configFile = "config.json"; + logRoot = "."; + } // optionalAttrs useCabalRun { + executable = "cabal run exe:cardano-tracer --"; + }); + materialise-profile = { profileNix }: pkgs.runCommand "workbench-profile-outputs-${profileNix.name}-supervisord" {} From dd30c4a3ba18ca4be46ad9b0b7d3787ae0bdb3f2 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Fri, 20 May 2022 15:44:19 +0300 Subject: [PATCH 5/6] flake.nix: disable workbench tests --- flake.nix | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index bf8e1a8264d..149dcce5f30 100644 --- a/flake.nix +++ b/flake.nix @@ -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 From 12cce26e0373f47def3ef4c246df7bada2a5b2c1 Mon Sep 17 00:00:00 2001 From: Denis Shevchenko Date: Mon, 23 May 2022 11:42:33 +0400 Subject: [PATCH 6/6] try to fix CI --- nix/workbench/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/workbench/default.nix b/nix/workbench/default.nix index ee58466f72b..da1f4eaec83 100644 --- a/nix/workbench/default.nix +++ b/nix/workbench/default.nix @@ -33,7 +33,7 @@ let dontStrip = true; }; - workbench = with cardanoNodePackages; with pkgs; workbench' + workbench = with cardanoNodePackages; with pkgs; workbench' ( [ git graphviz jq moreutils @@ -41,9 +41,9 @@ let cardano-cli cardano-topology - db-analyser + ] ++ lib.optional (!pkgs.stdenv.hostPlatform.isDarwin) db-analyser ++ [ locli - ]; + ]); runWorkbench = name: command: