@@ -15,63 +15,66 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
15
15
# The base directory of the subtensor project
16
16
BASE_DIR=" $SCRIPT_DIR /.."
17
17
18
- # get parameters
19
18
# Get the value of fast_blocks from the first argument
20
19
fast_blocks=${1:- " True" }
21
20
22
- # Check the value of fast_blocks
21
+ # Define the target directory for compilation
23
22
if [ " $fast_blocks " == " False" ]; then
24
23
# Block of code to execute if fast_blocks is False
25
24
echo " fast_blocks is Off"
26
25
: " ${CHAIN:= local} "
27
26
: " ${BUILD_BINARY:= 1} "
28
27
: " ${FEATURES:= " pow-faucet" } "
28
+ BUILD_DIR=" $BASE_DIR /target/non-fast-blocks"
29
29
else
30
30
# Block of code to execute if fast_blocks is not False
31
31
echo " fast_blocks is On"
32
32
: " ${CHAIN:= local} "
33
33
: " ${BUILD_BINARY:= 1} "
34
34
: " ${FEATURES:= " pow-faucet fast-blocks" } "
35
+ BUILD_DIR=" $BASE_DIR /target/fast-blocks"
35
36
fi
36
37
38
+ # Ensure the build directory exists
39
+ mkdir -p " $BUILD_DIR "
40
+
37
41
SPEC_PATH=" ${SCRIPT_DIR} /specs/"
38
42
FULL_PATH=" $SPEC_PATH$CHAIN .json"
39
43
40
- # Kill any existing nodes which may have not exited correctly after a previous
41
- # run.
44
+ # Kill any existing nodes which may have not exited correctly after a previous run.
42
45
pkill -9 ' node-subtensor'
43
46
44
47
if [ ! -d " $SPEC_PATH " ]; then
45
48
echo " *** Creating directory ${SPEC_PATH} ..."
46
- mkdir $SPEC_PATH
49
+ mkdir -p " $SPEC_PATH "
47
50
fi
48
51
49
52
if [[ $BUILD_BINARY == " 1" ]]; then
50
53
echo " *** Building substrate binary..."
51
- cargo build --workspace --profile=release --features " $FEATURES " --manifest-path " $BASE_DIR /Cargo.toml"
54
+ CARGO_TARGET_DIR= " $BUILD_DIR " cargo build --workspace --profile=release --features " $FEATURES " --manifest-path " $BASE_DIR /Cargo.toml"
52
55
echo " *** Binary compiled"
53
56
fi
54
57
55
58
echo " *** Building chainspec..."
56
- " $BASE_DIR /target /release/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN > $FULL_PATH
59
+ " $BUILD_DIR /release/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN > $FULL_PATH
57
60
echo " *** Chainspec built and output to file"
58
61
59
- # generate node keys
60
- $BASE_DIR /target/ release/node-subtensor key generate-node-key --chain=" $FULL_PATH " --base-path /tmp/alice
61
- $BASE_DIR /target/ release/node-subtensor key generate-node-key --chain=" $FULL_PATH " --base-path /tmp/bob
62
+ # Generate node keys
63
+ " $BUILD_DIR / release/node-subtensor" key generate-node-key --chain=" $FULL_PATH " --base-path /tmp/alice
64
+ " $BUILD_DIR / release/node-subtensor" key generate-node-key --chain=" $FULL_PATH " --base-path /tmp/bob
62
65
63
66
if [ $NO_PURGE -eq 1 ]; then
64
67
echo " *** Purging previous state skipped..."
65
68
else
66
69
echo " *** Purging previous state..."
67
- " $BASE_DIR /target /release/node-subtensor" purge-chain -y --base-path /tmp/bob --chain=" $FULL_PATH " > /dev/null 2>&1
68
- " $BASE_DIR /target /release/node-subtensor" purge-chain -y --base-path /tmp/alice --chain=" $FULL_PATH " > /dev/null 2>&1
70
+ " $BUILD_DIR /release/node-subtensor" purge-chain -y --base-path /tmp/bob --chain=" $FULL_PATH " > /dev/null 2>&1
71
+ " $BUILD_DIR /release/node-subtensor" purge-chain -y --base-path /tmp/alice --chain=" $FULL_PATH " > /dev/null 2>&1
69
72
echo " *** Previous chainstate purged"
70
73
fi
71
74
72
75
echo " *** Starting localnet nodes..."
73
76
alice_start=(
74
- " $BASE_DIR /target /release/node-subtensor"
77
+ " $BUILD_DIR /release/node-subtensor"
75
78
--base-path /tmp/alice
76
79
--chain=" $FULL_PATH "
77
80
--alice
@@ -85,7 +88,7 @@ alice_start=(
85
88
)
86
89
87
90
bob_start=(
88
- " $BASE_DIR " /target/ release/node-subtensor
91
+ " $BUILD_DIR / release/node-subtensor"
89
92
--base-path /tmp/bob
90
93
--chain=" $FULL_PATH "
91
94
--bob
@@ -96,7 +99,6 @@ bob_start=(
96
99
--allow-private-ipv4
97
100
--discover-local
98
101
--unsafe-force-node-key-generation
99
- # --offchain-worker=Never
100
102
)
101
103
102
104
trap ' pkill -P $$' EXIT SIGINT SIGTERM
0 commit comments