From 296338864340e11635aeec53960e51487664922b Mon Sep 17 00:00:00 2001 From: Federico Mastellone Date: Tue, 20 Sep 2022 16:20:15 +0000 Subject: [PATCH] workbench: changes needed to support a new backend --- nix/workbench/backend/services-config.nix | 4 +-- nix/workbench/profile-run.jq | 14 ++++++++++ nix/workbench/profiles/node-services.nix | 32 +++++++++++------------ nix/workbench/run.sh | 1 - nix/workbench/shell.nix | 3 +++ 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/nix/workbench/backend/services-config.nix b/nix/workbench/backend/services-config.nix index 8bdb2bcc8d0..5c4a530262a 100644 --- a/nix/workbench/backend/services-config.nix +++ b/nix/workbench/backend/services-config.nix @@ -87,9 +87,9 @@ with lib; svc: recursiveUpdate svc ({ sigKey = "./genesis/utxo-keys/utxo1.skey"; - nodeConfigFile = "config.json"; runScriptFile = "run-script.json"; - ## path to the socket of the locally running node. + ## path to the config and socket of the locally running node. + nodeConfigFile = "./node-0/config.json"; localNodeSocketPath = "./node-0/node.socket"; } // optionalAttrs useCabalRun { executable = "cabal run exe:tx-generator --"; diff --git a/nix/workbench/profile-run.jq b/nix/workbench/profile-run.jq index b1e97bdc11f..4578af60ea0 100644 --- a/nix/workbench/profile-run.jq +++ b/nix/workbench/profile-run.jq @@ -44,6 +44,8 @@ def profile_node_specs($env; $prof): , kind: "bft" , pools: 0 , autostart: true + # Currently only then "observer" kind honors this property. + , shutdown_on_slot_synced: null })) as $bfts | ([range($n_bfts; @@ -54,6 +56,8 @@ def profile_node_specs($env; $prof): then 1 else $prof.composition.dense_pool_density end) , autostart: true + # Currently only then "observer" kind honors this property. + , shutdown_on_slot_synced: null })) as $pools | ([range($n_bfts + $n_pools; @@ -63,6 +67,8 @@ def profile_node_specs($env; $prof): , kind: "proxy" , pools: 0 , autostart: true + # Currently only then "observer" kind honors this property. + , shutdown_on_slot_synced: null })) as $proxies | ([range($n_bfts + $n_pools @@ -74,6 +80,8 @@ def profile_node_specs($env; $prof): , kind: "chaindb-server" , pools: 0 , autostart: true + # Currently only then "observer" kind honors this property. + , shutdown_on_slot_synced: null })) as $chaindbs | ([range($n_bfts + $n_pools @@ -87,6 +95,11 @@ def profile_node_specs($env; $prof): , kind: "observer" , pools: 0 , autostart: false + , shutdown_on_slot_synced: + (if $prof.node.shutdown_on_slot_synced != null + then $prof.node.shutdown_on_slot_synced.observer + else null + end) })) as $observers | ($bfts + $pools + $proxies + $chaindbs + $observers @@ -98,6 +111,7 @@ def profile_node_specs($env; $prof): then $env.basePort + .i else $env.basePort end) + , shutdown_on_block_synced: $prof.node.shutdown_on_block_synced })) | map({ key: .name, value: .}) | from_entries; diff --git a/nix/workbench/profiles/node-services.nix b/nix/workbench/profiles/node-services.nix index 5cf48017572..a98c2efbef7 100644 --- a/nix/workbench/profiles/node-services.nix +++ b/nix/workbench/profiles/node-services.nix @@ -181,23 +181,21 @@ let profile.value.node.verbatim; extraArgs = - let shutdownSlot = profile.value.node.shutdown_on_slot_synced; - shutdownBlock = profile.value.node.shutdown_on_block_synced; - mayKindArgs = - val: kind: flag: - if val != null - then if isAttrs val - then if val.${kind} or null != null - then [flag (toString val.${kind})] - else [] - else [flag (toString val)] - else []; - shutBlockArgs = mayKindArgs shutdownBlock nodeSpec.kind "--shutdown-on-block-synced"; - shutSlotArgs = mayKindArgs shutdownSlot nodeSpec.kind "--shutdown-on-slot-synced"; - in services-config.finaliseNodeArgs profile nodeSpec - (if shutBlockArgs != [] - then shutBlockArgs - else shutSlotArgs); + (if nodeSpec.shutdown_on_block_synced != null + then [ + "--shutdown-on-block-synced" + (toString nodeSpec.shutdown_on_block_synced) + ] + else [] + ) + ++ + (if nodeSpec.shutdown_on_slot_synced != null + then [ + "--shutdown-on-slot-synced" + (toString nodeSpec.shutdown_on_slot_synced) + ] + else [] + ); }; ## Given an env config, evaluate it and produce the node service. diff --git a/nix/workbench/run.sh b/nix/workbench/run.sh index c4aa314cb4d..fb2d547c6a8 100644 --- a/nix/workbench/run.sh +++ b/nix/workbench/run.sh @@ -333,7 +333,6 @@ case "$op" in cp $(jq '."run-script"' -r $gtor) "$gen_dir"/run-script.json cp $(jq '."service-config"' -r $gtor) "$gen_dir"/service-config.json 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 diff --git a/nix/workbench/shell.nix b/nix/workbench/shell.nix index b59cca5432e..2c8e17f1a42 100644 --- a/nix/workbench/shell.nix +++ b/nix/workbench/shell.nix @@ -22,6 +22,8 @@ let cluster = pkgs.supervisord-workbench-for-profile { inherit profileName useCabalRun profiled; }; + inherit (cluster) profile; + shellHook = { workbenchDevMode, useCabalRun, profiled, profileName, withMainnet }: '' while test $# -gt 0 do shift; done ## Flush argv[] @@ -29,6 +31,7 @@ let cluster = pkgs.supervisord-workbench-for-profile { echo 'workbench shellHook: workbenchDevMode=${toString workbenchDevMode} useCabalRun=${toString useCabalRun} profiled=${toString profiled} profileName=${profileName}' export WB_BACKEND=supervisor export WB_SHELL_PROFILE=${profileName} + export WB_SHELL_PROFILE_DIR=${profile} ${optionalString workbenchDevMode