Skip to content

Commit

Permalink
Merge #4457
Browse files Browse the repository at this point in the history
4457: workbench: changes needed to support a new backend r=fmaste a=fmaste

- Reuse current directory structures
- Add `"shutdown_on_slot_synced"` and `"shutdown_on_block_synced"` to `node-specs.json`
- Environment variable `WB_SHELL_PROFILE_DIR` to the profile directory inside the shell

Co-authored-by: Federico Mastellone <fmaste@users.noreply.github.com>
  • Loading branch information
iohk-bors[bot] and fmaste authored Sep 22, 2022
2 parents ece659c + 2963388 commit 002e0ca
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
4 changes: 2 additions & 2 deletions nix/workbench/backend/services-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 --";
Expand Down
14 changes: 14 additions & 0 deletions nix/workbench/profile-run.jq
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
32 changes: 15 additions & 17 deletions nix/workbench/profiles/node-services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion nix/workbench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions nix/workbench/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ 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[]
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
Expand Down

0 comments on commit 002e0ca

Please sign in to comment.