Skip to content

Commit f293e46

Browse files
authored
Merge pull request #1388 from opentensor/feat/roman/split-targets-for-fast-and-non-fast-blocks
Split target folders for fast and non-fast block's chain
2 parents 1b40d1d + a8d1596 commit f293e46

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

scripts/localnet.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,66 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
1515
# The base directory of the subtensor project
1616
BASE_DIR="$SCRIPT_DIR/.."
1717

18-
# get parameters
1918
# Get the value of fast_blocks from the first argument
2019
fast_blocks=${1:-"True"}
2120

22-
# Check the value of fast_blocks
21+
# Define the target directory for compilation
2322
if [ "$fast_blocks" == "False" ]; then
2423
# Block of code to execute if fast_blocks is False
2524
echo "fast_blocks is Off"
2625
: "${CHAIN:=local}"
2726
: "${BUILD_BINARY:=1}"
2827
: "${FEATURES:="pow-faucet"}"
28+
BUILD_DIR="$BASE_DIR/target/non-fast-blocks"
2929
else
3030
# Block of code to execute if fast_blocks is not False
3131
echo "fast_blocks is On"
3232
: "${CHAIN:=local}"
3333
: "${BUILD_BINARY:=1}"
3434
: "${FEATURES:="pow-faucet fast-blocks"}"
35+
BUILD_DIR="$BASE_DIR/target/fast-blocks"
3536
fi
3637

38+
# Ensure the build directory exists
39+
mkdir -p "$BUILD_DIR"
40+
3741
SPEC_PATH="${SCRIPT_DIR}/specs/"
3842
FULL_PATH="$SPEC_PATH$CHAIN.json"
3943

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.
4245
pkill -9 'node-subtensor'
4346

4447
if [ ! -d "$SPEC_PATH" ]; then
4548
echo "*** Creating directory ${SPEC_PATH}..."
46-
mkdir $SPEC_PATH
49+
mkdir -p "$SPEC_PATH"
4750
fi
4851

4952
if [[ $BUILD_BINARY == "1" ]]; then
5053
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"
5255
echo "*** Binary compiled"
5356
fi
5457

5558
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
5760
echo "*** Chainspec built and output to file"
5861

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
6265

6366
if [ $NO_PURGE -eq 1 ]; then
6467
echo "*** Purging previous state skipped..."
6568
else
6669
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
6972
echo "*** Previous chainstate purged"
7073
fi
7174

7275
echo "*** Starting localnet nodes..."
7376
alice_start=(
74-
"$BASE_DIR/target/release/node-subtensor"
77+
"$BUILD_DIR/release/node-subtensor"
7578
--base-path /tmp/alice
7679
--chain="$FULL_PATH"
7780
--alice
@@ -85,7 +88,7 @@ alice_start=(
8588
)
8689

8790
bob_start=(
88-
"$BASE_DIR"/target/release/node-subtensor
91+
"$BUILD_DIR/release/node-subtensor"
8992
--base-path /tmp/bob
9093
--chain="$FULL_PATH"
9194
--bob
@@ -96,7 +99,6 @@ bob_start=(
9699
--allow-private-ipv4
97100
--discover-local
98101
--unsafe-force-node-key-generation
99-
# --offchain-worker=Never
100102
)
101103

102104
trap 'pkill -P $$' EXIT SIGINT SIGTERM

0 commit comments

Comments
 (0)