Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit e7d61de

Browse files
committed
[DEVOPS-978] Add demoClusterDaedalusDev attribute and documentation
1 parent 08eeecd commit e7d61de

File tree

6 files changed

+48
-15
lines changed

6 files changed

+48
-15
lines changed

default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ let
159159
other = rec {
160160
validateJson = pkgs.callPackage ./tools/src/validate-json {};
161161
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; };
162+
demoClusterDaedalusDev = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; disableClientAuth = true; numImportedWallets = 0; };
162163
shellcheckTests = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
163164
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };
164165
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev; };

docs/how-to/demo-cluster.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# How to launch a local demo cluster with nix
2+
3+
1. Make sure nix is installed and IOHK binary cache is configured [nix setup] (https://github.com/input-output-hk/cardano-sl/blob/develop/docs/how-to/build-cardano-sl-and-daedalus-from-source-code.md#nix-build-mode-recommended)
4+
2. To generate a script that will launch the demo cluster run `nix-build -A demoCluster -o launch_demo_cluster`
5+
3. To generate a script that will launch demo cluster suitable for Daedalus development, run `nix-build -A demoClusterDaedalusDev -o launch_demo_cluster`
6+
4. To launch cluster, run `./launch_demo_cluster`
7+
5. To stop, hit `ctrl-c` and it will terminate all the nodes.
8+
6. A `state-demo` state folder will be automatically created relative to your current
9+
working directory.
10+
* Logs will be found in `state-demo/logs`
11+
* TLS certs/keys will be found in `state-demo/tls`
12+
* 11 genesis wallets will be pre-loaded with 37 million Ada each

scripts/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mode, it will run in `dev` mode as well, and if you built it in `prod` mode, it
1313
## Launch
1414

1515
* `launch/demo.sh` - run nodes in `tmux`-session (3 nodes by default).
16+
* `launch/demo-nix.sh` - run demo cluster using nix with 4 core nodes, 1 relay, 1 wallet in background
1617
* `launch/demo-with-wallet-api.sh` - run nodes in `tmux`-session, with enabled wallet web API (3 nodes by default).
1718
* `launch/kill-demo.sh` - kill `tmux`-session with running nodes.
1819
* `launch/testnet-{public,staging}.sh` - connect one node to the cluster (testnet or testnet staging

scripts/launch/connect-to-cluster/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ in pkgs.writeScript "${executable}-connect-to-${environment}" ''
9999
fi
100100
''}
101101
102-
${executables.${executable}} \
102+
exec ${executables.${executable}} \
103103
--configuration-file ${configFiles}/lib/configuration.yaml \
104104
--configuration-key ${environments.${environment}.confKey} \
105105
${ ifWallet "--tlscert ${stateDir}/tls/server/server.crt"} \

scripts/launch/demo-cluster/default.nix

+20-14
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
, runExplorer ? false
66
, numCoreNodes ? 4
77
, numRelayNodes ? 1
8+
, numImportedWallets ? 11
89
, assetLockAddresses ? []
910
, system ? builtins.currentSystem
1011
, pkgs ? import localLib.fetchNixPkgs { inherit system config; }
1112
, gitrev ? localLib.commitIdFromGitRepo ./../../../.git
1213
, ghcRuntimeArgs ? "-N2 -qg -A1m -I0 -T"
1314
, additionalNodeArgs ? ""
1415
, keepAlive ? true
16+
, disableClientAuth ? false
1517
}:
1618

1719
with localLib;
@@ -26,10 +28,11 @@ let
2628
};
2729
demoClusterDeps = with pkgs; (with iohkPkgs; [ jq coreutils pkgs.curl gnused openssl cardano-sl-tools cardano-sl-wallet-new cardano-sl-node-static ]);
2830
walletConfig = {
29-
inherit stateDir;
31+
inherit stateDir disableClientAuth;
3032
topologyFile = walletTopologyFile;
33+
environment = "demo";
3134
};
32-
demoWallet = pkgs.callPackage ./../connect-to-cluster ({ inherit gitrev; debug = false; environment = "demo"; } // walletConfig);
35+
demoWallet = pkgs.callPackage ./../connect-to-cluster ({ inherit gitrev; } // walletConfig);
3336
ifWallet = localLib.optionalString (runWallet);
3437
ifKeepAlive = localLib.optionalString (keepAlive);
3538
iohkPkgs = import ./../../.. { inherit config system pkgs gitrev; };
@@ -137,19 +140,22 @@ in pkgs.writeScript "demo-cluster" ''
137140
done
138141
echo Blockchain Synced: $PERC%
139142
# import keys
140-
echo "Importing poor HD keys/wallet..."
141143
142-
for i in {0..11}
143-
do
144-
echo "Importing key$i.sk ..."
145-
curl https://localhost:8090/api/wallets/keys \
146-
--cacert ${stateDir}/tls/client/ca.crt \
147-
--cert ${stateDir}/tls/client/client.pem \
148-
-X POST \
149-
-H 'cache-control: no-cache' \
150-
-H 'content-type: application/json' \
151-
-d "\"${stateDir}/genesis-keys/generated-keys/poor/key$i.sk\"" | jq .
152-
done
144+
if [ ${builtins.toString numImportedWallets} -gt 0 ]
145+
then
146+
echo "Importing ${builtins.toString numImportedWallets} poor HD keys/wallet..."
147+
for i in {0..${builtins.toString numImportedWallets}}
148+
do
149+
echo "Importing key$i.sk ..."
150+
curl https://localhost:8090/api/wallets/keys \
151+
--cacert ${stateDir}/tls/client/ca.crt \
152+
--cert ${stateDir}/tls/client/client.pem \
153+
-X POST \
154+
-H 'cache-control: no-cache' \
155+
-H 'content-type: application/json' \
156+
-d "\"${stateDir}/genesis-keys/generated-keys/poor/key$i.sk\"" | jq .
157+
done
158+
fi
153159
${ifKeepAlive ''
154160
sleep infinity
155161
''}

scripts/launch/demo-nix.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
if ! [ -x "$(command -v nix-build)" ]; then
4+
echo 'Error: nix is not installed.' >&2
5+
# shellcheck disable=SC2016
6+
echo 'Run `curl https://nixos.org/nix/install | sh` and re-run this script' >&2
7+
exit 1
8+
fi
9+
10+
GITREV=$(git rev-parse HEAD)
11+
12+
nix-build -A demoClusterDaedalusDev --argstr gitrev "$GITREV" -o "launch_$GITREV"
13+
exec ./launch_"$GITREV"

0 commit comments

Comments
 (0)