|
1 | 1 | #!/bin/bash |
2 | 2 |
|
| 3 | +# Determine the directory this script resides in. This allows invoking it from any location. |
| 4 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" |
| 5 | + |
| 6 | +# The base directory of the subtensor project |
| 7 | +BASE_DIR="$SCRIPT_DIR/.." |
| 8 | + |
3 | 9 | : "${CHAIN:=local}" |
4 | 10 | : "${BUILD_BINARY:=1}" |
5 | | -: "${SPEC_PATH:=specs/}" |
6 | 11 | : "${FEATURES:=pow-faucet}" |
7 | 12 |
|
| 13 | +SPEC_PATH="${SCRIPT_DIR}/specs/" |
8 | 14 | FULL_PATH="$SPEC_PATH$CHAIN.json" |
9 | 15 |
|
10 | 16 | if [ ! -d "$SPEC_PATH" ]; then |
11 | | - echo "*** Creating directory ${SPEC_PATH}..." |
12 | | - mkdir $SPEC_PATH |
| 17 | + echo "*** Creating directory ${SPEC_PATH}..." |
| 18 | + mkdir $SPEC_PATH |
13 | 19 | fi |
14 | 20 |
|
15 | 21 | if [[ $BUILD_BINARY == "1" ]]; then |
16 | | - echo "*** Building substrate binary..." |
17 | | - cargo build --release --features "$FEATURES" |
18 | | - echo "*** Binary compiled" |
| 22 | + echo "*** Building substrate binary..." |
| 23 | + cargo build --release --features "$FEATURES" --manifest-path "$BASE_DIR/node/Cargo.toml" |
| 24 | + echo "*** Binary compiled" |
19 | 25 | fi |
20 | 26 |
|
21 | 27 | echo "*** Building chainspec..." |
22 | | -./target/release/node-subtensor build-spec --disable-default-bootnode --raw --chain $CHAIN > $FULL_PATH |
| 28 | +"$BASE_DIR/target/release/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN >$FULL_PATH |
23 | 29 | echo "*** Chainspec built and output to file" |
24 | 30 |
|
25 | 31 | echo "*** Purging previous state..." |
26 | | -./target/release/node-subtensor purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1 |
27 | | -./target/release/node-subtensor purge-chain -y --base-path /tmp/alice --chain="$FULL_PATH" >/dev/null 2>&1 |
| 32 | +"$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1 |
| 33 | +"$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/alice --chain="$FULL_PATH" >/dev/null 2>&1 |
28 | 34 | echo "*** Previous chainstate purged" |
29 | 35 |
|
30 | 36 | echo "*** Starting localnet nodes..." |
31 | 37 | alice_start=( |
32 | | - ./target/release/node-subtensor |
33 | | - --base-path /tmp/alice |
34 | | - --chain="$FULL_PATH" |
35 | | - --alice |
36 | | - --port 30334 |
37 | | - --rpc-port 9946 |
38 | | - --validator |
39 | | - --rpc-cors=all |
40 | | - --allow-private-ipv4 |
41 | | - --discover-local |
| 38 | + "$BASE_DIR/target/release/node-subtensor" |
| 39 | + --base-path /tmp/alice |
| 40 | + --chain="$FULL_PATH" |
| 41 | + --alice |
| 42 | + --port 30334 |
| 43 | + --rpc-port 9946 |
| 44 | + --validator |
| 45 | + --rpc-cors=all |
| 46 | + --allow-private-ipv4 |
| 47 | + --discover-local |
42 | 48 | ) |
43 | 49 |
|
44 | 50 | bob_start=( |
45 | | - ./target/release/node-subtensor |
46 | | - --base-path /tmp/bob |
47 | | - --chain="$FULL_PATH" |
48 | | - --bob |
49 | | - --port 30335 |
50 | | - --rpc-port 9945 |
51 | | - --validator |
52 | | - --allow-private-ipv4 |
53 | | - --discover-local |
| 51 | + "$BASE_DIR"/target/release/node-subtensor |
| 52 | + --base-path /tmp/bob |
| 53 | + --chain="$FULL_PATH" |
| 54 | + --bob |
| 55 | + --port 30335 |
| 56 | + --rpc-port 9945 |
| 57 | + --validator |
| 58 | + --allow-private-ipv4 |
| 59 | + --discover-local |
54 | 60 | ) |
55 | 61 |
|
56 | | -(trap 'kill 0' SIGINT; ("${alice_start[@]}" 2>&1) & ("${bob_start[@]}" 2>&1)) |
| 62 | +( |
| 63 | + trap 'kill 0' SIGINT |
| 64 | + ("${alice_start[@]}" 2>&1) & |
| 65 | + ("${bob_start[@]}" 2>&1) |
| 66 | +) |
0 commit comments