5
5
, runExplorer ? false
6
6
, numCoreNodes ? 4
7
7
, numRelayNodes ? 1
8
+ , numImportedWallets ? 11
8
9
, assetLockAddresses ? [ ]
9
10
, system ? builtins . currentSystem
10
11
, pkgs ? import localLib . fetchNixPkgs { inherit system config ; }
14
15
, keepAlive ? true
15
16
, launchGenesis ? false
16
17
, configurationKey ? "default"
18
+ , useStackBinaries ? false
19
+ , disableClientAuth ? false
17
20
} :
18
21
19
22
with localLib ;
20
23
21
24
let
22
- executables = {
23
- corenode = "${ iohkPkgs . cardano-sl-node-static } /bin/cardano-node-simple" ;
24
- wallet = "${ iohkPkgs . cardano-sl-wallet-new } /bin/cardano-node" ;
25
- integration-test = "${ iohkPkgs . cardano-sl-wallet-new } /bin/wal-integr-test" ;
26
- keygen = "${ iohkPkgs . cardano-sl-tools } /bin/cardano-keygen" ;
27
- explorer = "${ iohkPkgs . cardano-sl-explorer-static } /bin/cardano-explorer" ;
28
- } ;
29
- demoClusterDeps = with pkgs ; ( with iohkPkgs ; [ jq coreutils pkgs . curl gnused openssl cardano-sl-tools cardano-sl-wallet-new cardano-sl-node-static ] ) ;
25
+ stackExec = optionalString useStackBinaries "stack exec -- " ;
26
+ cardanoDeps = with iohkPkgs ; [ cardano-sl-tools cardano-sl-wallet-new cardano-sl-node-static ] ;
27
+ demoClusterDeps = with pkgs ; [ jq coreutils curl gnused openssl ] ;
28
+ allDeps = demoClusterDeps ++ ( optionals ( ! useStackBinaries ) cardanoDeps ) ;
30
29
walletConfig = {
31
- inherit stateDir ;
30
+ inherit stateDir disableClientAuth ;
32
31
topologyFile = walletTopologyFile ;
32
+ environment = "demo" ;
33
33
} ;
34
34
walletEnvironment = if launchGenesis then {
35
35
environment = "override" ;
39
39
} else {
40
40
environment = "demo" ;
41
41
} ;
42
- demoWallet = pkgs . callPackage ./../connect-to-cluster ( { inherit gitrev ; debug = false ; } // walletEnvironment // walletConfig ) ;
43
- ifWallet = localLib . optionalString ( runWallet ) ;
44
- ifKeepAlive = localLib . optionalString ( keepAlive ) ;
42
+ demoWallet = pkgs . callPackage ./../connect-to-cluster ( { inherit gitrev useStackBinaries ; debug = false ; } // walletEnvironment // walletConfig ) ;
43
+ ifWallet = optionalString ( runWallet ) ;
44
+ ifKeepAlive = optionalString ( keepAlive ) ;
45
45
iohkPkgs = import ./../../.. { inherit config system pkgs gitrev ; } ;
46
46
src = ./../../.. ;
47
47
topologyFile = import ./make-topology.nix { inherit ( pkgs ) lib ; cores = numCoreNodes ; relays = numRelayNodes ; } ;
52
52
fallbacks = 1 ;
53
53
} ;
54
54
} ) ;
55
- assetLockFile = pkgs . writeText "asset-lock-file" ( localLib . intersperse "\n " assetLockAddresses ) ;
56
- ifAssetLock = localLib . optionalString ( assetLockAddresses != [ ] ) ;
55
+ assetLockFile = pkgs . writeText "asset-lock-file" ( intersperse "\n " assetLockAddresses ) ;
56
+ ifAssetLock = optionalString ( assetLockAddresses != [ ] ) ;
57
57
configFiles = pkgs . runCommand "cardano-config" { } ''
58
58
mkdir -pv $out
59
59
cd $out
69
69
70
70
in pkgs . writeScript "demo-cluster" ''
71
71
#!${ pkgs . stdenv . shell }
72
- export PATH=${ pkgs . lib . makeBinPath demoClusterDeps }
72
+ export PATH=${ pkgs . lib . makeBinPath allDeps } :$PATH
73
73
# Set to 0 (passing) by default. Tests using this cluster can set this variable
74
74
# to force the `stop_cardano` function to exit with a different code.
75
75
EXIT_STATUS=0
@@ -111,7 +111,7 @@ in pkgs.writeScript "demo-cluster" ''
111
111
'' else ''
112
112
echo "Creating genesis keys..."
113
113
config_files=${ configFiles }
114
- cardano-keygen --system-start 0 generate-keys-by-spec --genesis-out-dir ${ stateDir } /genesis-keys --configuration-file $config_files/configuration.yaml --configuration-key ${ configurationKey }
114
+ ${ stackExec } cardano-keygen --system-start 0 generate-keys-by-spec --genesis-out-dir ${ stateDir } /genesis-keys --configuration-file $config_files/configuration.yaml --configuration-key ${ configurationKey }
115
115
'' }
116
116
117
117
trap "stop_cardano" INT TERM
@@ -120,15 +120,15 @@ in pkgs.writeScript "demo-cluster" ''
120
120
do
121
121
node_args="--db-path ${ stateDir } /core-db$i --rebuild-db ${ if launchGenesis then "--keyfile ${ stateDir } /genesis-keys/generated-keys/rich/key$((i - 1)).sk" else "--genesis-secret $i" } --listen 127.0.0.1:$((3000 + i)) --json-log ${ stateDir } /logs/core$i.json --logs-prefix ${ stateDir } /logs --system-start $system_start --metrics +RTS -N2 -qg -A1m -I0 -T -RTS --node-id core$i --topology ${ topologyFile } --configuration-file $config_files/configuration.yaml --configuration-key ${ configurationKey } ${ ifAssetLock "--asset-lock-file ${ assetLockFile } " } "
122
122
echo Launching core node $i: cardano-node-simple $node_args
123
- cardano-node-simple $node_args &> ${ stateDir } /logs/core$i.log &
123
+ ${ stackExec } cardano-node-simple $node_args &> ${ stateDir } /logs/core$i.log &
124
124
core_pid[$i]=$!
125
125
126
126
done
127
127
for i in {1..${ builtins . toString numRelayNodes } }
128
128
do
129
129
node_args="--db-path ${ stateDir } /relay-db$i --rebuild-db --listen 127.0.0.1:$((3100 + i)) --json-log ${ stateDir } /logs/relay$i.json --logs-prefix ${ stateDir } /logs --system-start $system_start --metrics +RTS -N2 -qg -A1m -I0 -T -RTS --node-id relay$i --topology ${ topologyFile } --configuration-file $config_files/configuration.yaml --configuration-key ${ configurationKey } "
130
130
echo Launching relay node $i: cardano-node-simple $node_args
131
- cardano-node-simple $node_args &> ${ stateDir } /logs/relay$i.log &
131
+ ${ stackExec } cardano-node-simple $node_args &> ${ stateDir } /logs/relay$i.log &
132
132
relay_pid[$i]=$!
133
133
134
134
done
@@ -161,23 +161,22 @@ in pkgs.writeScript "demo-cluster" ''
161
161
fi
162
162
done
163
163
echo Blockchain Synced: $PERC%
164
- # import keys
165
- echo "Importing poor HD keys/wallet..."
166
-
167
- for i in {0..11 }
168
- do
169
- echo "Importing key$i.sk ..."
170
- curl https://${ demoWallet . walletListen } /api/wallets/keys \
171
- --cacert ${ stateDir } /tls/client/ca.crt \
172
- --cert ${ stateDir } /tls/client/client.pem \
173
- -X POST \
174
- -H 'cache-control: no-cache' \
175
- -H 'content-type: application/json' \
176
- -d "\"${ stateDir } /genesis-keys/generated-keys/poor/key$i.sk\"" | jq .
177
- done
178
-
164
+ if [ ${ builtins . toString numImportedWallets } -gt 0 ]
165
+ then
166
+ echo "Importing ${ builtins . toString numImportedWallets } poor HD keys/wallet..."
167
+ for i in {0..${ builtins . toString numImportedWallets } }
168
+ do
169
+ echo "Importing key$i.sk ..."
170
+ curl https://${ demoWallet . walletListen } /api/wallets/keys \
171
+ --cacert ${ stateDir } /tls/client/ca.crt \
172
+ --cert ${ stateDir } /tls/client/client.pem \
173
+ -X POST \
174
+ -H 'cache-control: no-cache' \
175
+ -H 'content-type: application/json' \
176
+ -d "\"${ stateDir } /genesis-keys/generated-keys/poor/key$i.sk\"" | jq .
177
+ done
178
+ fi
179
179
'' }
180
-
181
180
${ ifKeepAlive ''
182
181
sleep infinity
183
182
'' }
0 commit comments