Skip to content

Commit

Permalink
CAD-2726 supervisord: genesis caching from 'cardano-ops'
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire authored and jutaro committed May 13, 2021
1 parent 2881c2a commit 0dd9b07
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 119 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -16,6 +16,7 @@ result*
/launch-*
stack.yaml.lock

/.cache
/db
/db-[0-9]
/logs
Expand Down
5 changes: 4 additions & 1 deletion nix/supervisord-cluster/default.nix
Expand Up @@ -3,6 +3,7 @@
, bech32
, basePort ? 30000
, stateDir ? "./state-cluster"
, cacheDir ? "./.cache"
, extraSupervisorConfig ? {}
, useCabalRun ? false
##
Expand Down Expand Up @@ -45,7 +46,7 @@ let
mkGenesisBash = pkgs.callPackage ./genesis.nix
{ inherit
lib
stateDir
cacheDir stateDir
baseEnvConfig
basePort
profile;
Expand Down Expand Up @@ -73,6 +74,8 @@ let
--trace | --debug ) set -x;;
* ) break;; esac; shift; done
mkdir -p ${cacheDir}
if [ -f ${stateDir}/supervisord.pid ]
then
echo "Cluster already running. Please run `stop-cluster` first!"
Expand Down
279 changes: 174 additions & 105 deletions nix/supervisord-cluster/genesis.nix

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions nix/supervisord-cluster/profiles.jq
Expand Up @@ -28,12 +28,10 @@
## profile_name() function in 'profiles/derived.jq'.
##
## Cluster composition must have the following structure:
## { n_hosts: INT
## , n_bft_hosts: INT
## { n_bft_hosts: INT
## , n_singular_hosts: INT
## , n_dense_hosts: INT
## }
## ..where n_hosts must be equal to a sum of the rest.
##
## Names of non-adhoc profiles are computed by the 'profile_name' function in
## profiles/derived.jq, with era suffix appended, and have the following structure:
Expand Down
1 change: 0 additions & 1 deletion nix/supervisord-cluster/profiles/defaults.jq
Expand Up @@ -9,7 +9,6 @@ def era_defaults($era):
## Cluster topology and composition:
, composition:
{ locations: ["LO"]
, n_hosts: 3
, n_bft_hosts: 1
, n_singular_hosts: 1
, n_dense_hosts: 1
Expand Down
3 changes: 1 addition & 2 deletions nix/supervisord-cluster/profiles/topology.jq
Expand Up @@ -17,8 +17,7 @@ def topology_composition($topo):
| ($pools | map (select (. == 1))) as $singular_pools
| ($pools | map (select (. > 1))) as $dense_pools
| ($singular_pools | length) as $n_singular_hosts
| { n_hosts: $n_hosts
, n_bft_hosts: ($bfts | length)
| { n_bft_hosts: ($bfts | length)
, n_singular_hosts: ($singular_pools | length)
, n_dense_hosts: ($dense_pools | length)
};
14 changes: 7 additions & 7 deletions nix/supervisord-cluster/supervisor.nix
Expand Up @@ -62,9 +62,9 @@ let
command = let
index = i - 1;
envConfig = baseEnvConfig // rec {
operationalCertificate = "${stateDir}/nodes/node-bft${toString i}/op.cert";
kesKey = "${stateDir}/nodes/node-bft${toString i}/kes.skey";
vrfKey = "${stateDir}/nodes/node-bft${toString i}/vrf.skey";
operationalCertificate = "${stateDir}/shelley/nodes/node-bft${toString i}/op.cert";
kesKey = "${stateDir}/shelley/nodes/node-bft${toString i}/kes.skey";
vrfKey = "${stateDir}/shelley/nodes/node-bft${toString i}/vrf.skey";
topology = "${stateDir}/topologies/node-${toString index}.json";
socketPath = "${stateDir}/bft${toString i}.socket";
dbPrefix = "db-bft${toString i}";
Expand All @@ -82,9 +82,9 @@ let
command = let
index = composition.n_bft_hosts + i - 1;
envConfig = baseEnvConfig // rec {
operationalCertificate = "${stateDir}/nodes/node-pool${toString i}/op.cert";
kesKey = "${stateDir}/nodes/node-pool${toString i}/kes.skey";
vrfKey = "${stateDir}/nodes/node-pool${toString i}/vrf.skey";
operationalCertificate = "${stateDir}/shelley/nodes/node-pool${toString i}/op.cert";
kesKey = "${stateDir}/shelley/nodes/node-pool${toString i}/kes.skey";
vrfKey = "${stateDir}/shelley/nodes/node-pool${toString i}/vrf.skey";
topology = "${stateDir}/topologies/node-${toString index}.json";
socketPath = "${stateDir}/pool${toString i}.socket";
dbPrefix = "db-pool${toString i}";
Expand Down Expand Up @@ -116,7 +116,7 @@ let
// {
"program:webserver" = {
command = "${pkgs.python3}/bin/python -m http.server ${toString basePort}";
directory = "${stateDir}/webserver";
directory = "${stateDir}/shelley/webserver";
};

} // extraSupervisorConfig));
Expand Down

0 comments on commit 0dd9b07

Please sign in to comment.