Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workbench: changes needed to support a new backend #4457

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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