diff --git a/Dockerfile b/Dockerfile index b20dc2d3b..26a925f70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,7 +52,7 @@ RUN /subtensor/scripts/init.sh # Cargo build WORKDIR /subtensor -RUN cargo build --release --features runtime-benchmarks --locked +RUN cargo build --profile production --features runtime-benchmarks --locked EXPOSE 30333 9933 9944 @@ -61,4 +61,4 @@ FROM $BASE_IMAGE AS subtensor COPY --from=builder /subtensor/snapshot.json / COPY --from=builder /subtensor/raw_spec.json / COPY --from=builder /subtensor/raw_testspec.json / -COPY --from=builder /subtensor/target/release/node-subtensor /usr/local/bin +COPY --from=builder /subtensor/target/production/node-subtensor /usr/local/bin diff --git a/docs/running-subtensor-locally.md b/docs/running-subtensor-locally.md index 4d827d858..505fe2fb5 100644 --- a/docs/running-subtensor-locally.md +++ b/docs/running-subtensor-locally.md @@ -162,7 +162,7 @@ rm -rf /tmp/blockchain Install subtensor by compiling with `cargo`: ```bash -cargo build --release --features=runtime-benchmarks +cargo build --profile production --features=runtime-benchmarks ``` ## Run the subtensor node @@ -174,7 +174,7 @@ You can now run the public subtensor node either as a lite node or as an archive To run a lite node connected to the mainchain, execute the below command (note the `--sync=warp` flag which runs the subtensor node in lite mode): ```bash title="With --sync=warp setting, for lite node" -./target/release/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=warp --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external +./target/production/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external ``` ### Archive node on mainchain @@ -182,7 +182,7 @@ To run a lite node connected to the mainchain, execute the below command (note t To run an archive node connected to the mainchain, execute the below command (note the `--sync=full` which syncs the node to the full chain and `--pruning archive` flags, which disables the node's automatic pruning of older historical data): ```bash title="With --sync=full and --pruning archive setting, for archive node" -./target/release/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=full --pruning archive --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external +./target/production/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external ``` ### Lite node on testchain @@ -190,7 +190,7 @@ To run an archive node connected to the mainchain, execute the below command (no To run a lite node connected to the testchain, execute the below command: ```bash title="With bootnodes set to testnet and --sync=warp setting, for lite node." -./target/release/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=warp --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external +./target/production/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external ``` ### Archive node on testchain @@ -198,8 +198,9 @@ To run a lite node connected to the testchain, execute the below command: To run an archive node connected to the testchain, execute the below command: ```bash title="With bootnodes set to testnet and --sync=full and --pruning archive setting, for archive node" -./target/release/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=full --pruning archive --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external +./target/production/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external ``` ## Running on cloud + We have not tested these installation scripts on any cloud service. In addition, if you are using Runpod cloud service, then note that this service is already [containerized](https://docs.runpod.io/pods/overview). Hence, the only option available to you is to compile from the source, as described in the above [Method 2: Using Source Code](#method-2-using-source-code) section. Note that these scripts have not been tested on Runpod. diff --git a/docs/rust-setup.md b/docs/rust-setup.md index 2755966e3..1527d5b8b 100644 --- a/docs/rust-setup.md +++ b/docs/rust-setup.md @@ -1,8 +1,7 @@ --- title: Installation --- - -This guide is for reference only, please check the latest information on getting starting with Substrate +This guide is for reference only, please check the latest information on getting starting with Substrate [here](https://docs.substrate.io/main-docs/install/). This page will guide you through the **2 steps** needed to prepare a computer for **Substrate** development. @@ -207,7 +206,7 @@ Use the `WASM_BUILD_TOOLCHAIN` environment variable to specify the Rust nightly project should use for Wasm compilation: ```bash -WASM_BUILD_TOOLCHAIN=nightly- cargo build --release +WASM_BUILD_TOOLCHAIN=nightly- cargo build --profile production ``` > Note that this only builds _the runtime_ with the specified nightly. The rest of project will be @@ -223,3 +222,4 @@ rustup uninstall nightly rustup install nightly- rustup target add wasm32-unknown-unknown --toolchain nightly- ``` + diff --git a/pallets/admin-utils/scripts/benchmark.sh b/pallets/admin-utils/scripts/benchmark.sh index b299e8dcb..82d417ffd 100755 --- a/pallets/admin-utils/scripts/benchmark.sh +++ b/pallets/admin-utils/scripts/benchmark.sh @@ -1,11 +1,9 @@ -cargo build --release --features runtime-benchmarks -./target/release/node-subtensor benchmark pallet \ - --chain=local \ - --execution=wasm \ - --wasm-execution=compiled \ - --pallet=pallet_admin_utils \ - --extrinsic="*" \ - --steps 50 \ - --repeat 20 \ - --output=pallets/admin-utils/src/weights.rs \ - --template=./.maintain/frame-weight-template.hbs \ No newline at end of file +cargo build --profile production --features runtime-benchmarks +./target/production/node-subtensor benchmark pallet \ + --chain=local \ + --pallet=pallet_admin_utils \ + --extrinsic="*" \ + --steps 50 \ + --repeat 20 \ + --output=pallets/admin-utils/src/weights.rs \ + --template=./.maintain/frame-weight-template.hbs diff --git a/pallets/commitments/scripts/benchmark.sh b/pallets/commitments/scripts/benchmark.sh index bf189bd8f..8a87c5bdd 100755 --- a/pallets/commitments/scripts/benchmark.sh +++ b/pallets/commitments/scripts/benchmark.sh @@ -1,9 +1,7 @@ -cargo build --release --features runtime-benchmarks -./target/release/node-subtensor benchmark pallet \ - --chain=local \ - --execution=wasm \ - --wasm-execution=compiled \ - --pallet=pallet_commitments \ - --extrinsic="*" \ - --output=pallets/commitments/src/weights.rs \ - --template=./.maintain/frame-weight-template.hbs \ No newline at end of file +cargo build --profile production --features runtime-benchmarks +./target/production/node-subtensor benchmark pallet \ + --chain=local \ + --pallet=pallet_commitments \ + --extrinsic="*" \ + --output=pallets/commitments/src/weights.rs \ + --template=./.maintain/frame-weight-template.hbs diff --git a/pallets/registry/scripts/benchmark.sh b/pallets/registry/scripts/benchmark.sh index 2bb8fabc8..ed1b28ead 100755 --- a/pallets/registry/scripts/benchmark.sh +++ b/pallets/registry/scripts/benchmark.sh @@ -1,9 +1,7 @@ cargo build --release --features runtime-benchmarks -./target/release/node-subtensor benchmark pallet \ - --chain=local \ - --execution=wasm \ - --wasm-execution=compiled \ - --pallet=pallet_registry \ - --extrinsic="*" \ - --output=pallets/registry/src/weights.rs \ - --template=./.maintain/frame-weight-template.hbs \ No newline at end of file +./target/production/node-subtensor benchmark pallet \ + --chain=local \ + --pallet=pallet_registry \ + --extrinsic="*" \ + --output=pallets/registry/src/weights.rs \ + --template=./.maintain/frame-weight-template.hbs diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh index 52b74778a..52bdaf2c5 100755 --- a/scripts/benchmark.sh +++ b/scripts/benchmark.sh @@ -1,49 +1,46 @@ #!/usr/bin/env bash - -DEFAULT_BIN_PATH='./target/release/node-subtensor' +DEFAULT_BIN_PATH='./target/production/node-subtensor' BIN_PATH=$DEFAULT_BIN_PATH TMP_SPEC='temp.json' OUTPUT_FILE='benchmarking.txt' - # Getting arguments from user while [[ $# -gt 0 ]]; do case $1 in - -p|--bin-path) - BIN_PATH="$2" - shift - shift - ;; - -*|--*) - echo "Unknown option $1" - exit 1 - ;; - *) - POSITIONAL_ARGS+=("$1") - shift - ;; + -p | --bin-path) + BIN_PATH="$2" + shift + shift + ;; + -* | --*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") + shift + ;; esac done # Ensure binary exists before node-subtensor executions if [ ! -f $BIN_PATH ]; then - if [[ "$DEFAULT_BIN_PATH" == "$BIN_PATH" ]]; then - cargo build --release --features runtime-benchmarks - else - echo "Binary '$BIN_PATH' does not exist. You can use -p or --bin-path to specify a different location." - exit 1 - fi + if [[ "$DEFAULT_BIN_PATH" == "$BIN_PATH" ]]; then + cargo build --profile production --features runtime-benchmarks + else + echo "Binary '$BIN_PATH' does not exist. You can use -p or --bin-path to specify a different location." + exit 1 + fi fi # Build Temporary Spec -$BIN_PATH build-spec --disable-default-bootnode --raw --chain local > $TMP_SPEC +$BIN_PATH build-spec --disable-default-bootnode --raw --chain local >$TMP_SPEC # Run benchmark $BIN_PATH benchmark pallet \ - --chain=$TMP_SPEC \ - --execution=native --wasm-execution=compiled \ - --pallet pallet-subtensor --extrinsic 'benchmark_dissolve_network' \ - --output $OUTPUT_FILE + --chain=$TMP_SPEC \ + --pallet pallet-subtensor --extrinsic 'benchmark_dissolve_network' \ + --output $OUTPUT_FILE -rm $TMP_SPEC \ No newline at end of file +rm $TMP_SPEC diff --git a/scripts/build.sh b/scripts/build.sh index b3f63171b..548af664b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1 +1,2 @@ -cargo build --release --features runtime-benchmarks \ No newline at end of file +cargo build --profile production --features runtime-benchmarks + diff --git a/scripts/run/subtensor.sh b/scripts/run/subtensor.sh index e8fd3d58c..015196b29 100755 --- a/scripts/run/subtensor.sh +++ b/scripts/run/subtensor.sh @@ -4,125 +4,123 @@ # Helper functions # -function run_command() -{ - F_NETWORK=$1 - F_NODE_TYPE=$2 - F_BIN_PATH=$3 +function run_command() { + F_NETWORK=$1 + F_NODE_TYPE=$2 + F_BIN_PATH=$3 - # Different command options by network and node type - MAINNET_BOOTNODE='--bootnodes /dns/bootnode.finney.chain.opentensor.ai/tcp/30333/ws/p2p/12D3KooWRwbMb85RWnT8DSXSYMWQtuDwh4LJzndoRrTDotTR5gDC' - TESTNET_BOOTNODE='--bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/ws/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr' - NODE_TYPE_ARCHIVE='--pruning=archive' - NODE_TYPE_LITE='--sync warp' + # Different command options by network and node type + MAINNET_BOOTNODE='--bootnodes /dns/bootnode.finney.chain.opentensor.ai/tcp/30333/ws/p2p/12D3KooWRwbMb85RWnT8DSXSYMWQtuDwh4LJzndoRrTDotTR5gDC' + TESTNET_BOOTNODE='--bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/ws/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr' + NODE_TYPE_ARCHIVE='--pruning=archive' + NODE_TYPE_LITE='--sync warp' - # Options by the type of node we offer - MAINNET_ARCHIVE_OPTIONS="$MAINNET_BOOTNODE $NODE_TYPE_ARCHIVE" - MAINNET_LITE_OPTIONS="$MAINNET_BOOTNODE $NODE_TYPE_LITE" - TESTNET_ARCHIVE_OPTIONS="$TESTNET_BOOTNODE $NODE_TYPE_ARCHIVE" - TESTNET_LITE_OPTIONS="$TESTNET_BOOTNODE $NODE_TYPE_LITE" + # Options by the type of node we offer + MAINNET_ARCHIVE_OPTIONS="$MAINNET_BOOTNODE $NODE_TYPE_ARCHIVE" + MAINNET_LITE_OPTIONS="$MAINNET_BOOTNODE $NODE_TYPE_LITE" + TESTNET_ARCHIVE_OPTIONS="$TESTNET_BOOTNODE $NODE_TYPE_ARCHIVE" + TESTNET_LITE_OPTIONS="$TESTNET_BOOTNODE $NODE_TYPE_LITE" - # Checking options to use - if [[ "$F_NETWORK" == "mainnet" ]] && [[ "$F_NODE_TYPE" == "archive" ]]; then - SPECIFIC_OPTIONS=$MAINNET_ARCHIVE_OPTIONS - elif [[ "$F_NETWORK" == "mainnet" ]] && [[ "$F_NODE_TYPE" == "lite" ]]; then - SPECIFIC_OPTIONS=$MAINNET_LITE_OPTIONS - elif [[ "$F_NETWORK" == "testnet" ]] && [[ "$F_NODE_TYPE" == "archive" ]]; then - SPECIFIC_OPTIONS=$TESTNET_ARCHIVE_OPTIONS - elif [[ "$F_NETWORK" == "testnet" ]] && [[ "$F_NODE_TYPE" == "lite" ]]; then - SPECIFIC_OPTIONS=$TESTNET_LITE_OPTIONS - fi + # Checking options to use + if [[ "$F_NETWORK" == "mainnet" ]] && [[ "$F_NODE_TYPE" == "archive" ]]; then + SPECIFIC_OPTIONS=$MAINNET_ARCHIVE_OPTIONS + elif [[ "$F_NETWORK" == "mainnet" ]] && [[ "$F_NODE_TYPE" == "lite" ]]; then + SPECIFIC_OPTIONS=$MAINNET_LITE_OPTIONS + elif [[ "$F_NETWORK" == "testnet" ]] && [[ "$F_NODE_TYPE" == "archive" ]]; then + SPECIFIC_OPTIONS=$TESTNET_ARCHIVE_OPTIONS + elif [[ "$F_NETWORK" == "testnet" ]] && [[ "$F_NODE_TYPE" == "lite" ]]; then + SPECIFIC_OPTIONS=$TESTNET_LITE_OPTIONS + fi - if [ ! -f $F_BIN_PATH ]; then - echo "Binary '$F_BIN_PATH' does not exist. You can use -p or --bin-path to specify a different location." - echo "Please ensure you have compiled the binary first." - exit 1 - fi + if [ ! -f $F_BIN_PATH ]; then + echo "Binary '$F_BIN_PATH' does not exist. You can use -p or --bin-path to specify a different location." + echo "Please ensure you have compiled the binary first." + exit 1 + fi - # Command to run subtensor - $F_BIN_PATH \ - --base-path /tmp/blockchain \ - --chain ./raw_spec.json \ - --rpc-external --rpc-cors all \ - --no-mdns \ - --rpc-max-connections 10000 --in-peers 500 --out-peers 500 \ - $SPECIFIC_OPTIONS + # Command to run subtensor + $F_BIN_PATH \ + --base-path /tmp/blockchain \ + --chain ./raw_spec.json \ + --rpc-external --rpc-cors all \ + --no-mdns \ + --rpc-max-connections 10000 --in-peers 500 --out-peers 500 \ + $SPECIFIC_OPTIONS } - # Default values EXEC_TYPE="docker" NETWORK="mainnet" NODE_TYPE="lite" BUILD="" -BIN_PATH="./target/release/node-subtensor" +BIN_PATH="./target/production/node-subtensor" # Getting arguments from user while [[ $# -gt 0 ]]; do case $1 in - -h|--help) - help - exit 0 - ;; - -e|--execution) - EXEC_TYPE="$2" - shift # past argument - shift # past value - ;; - -b|--build) - BUILD="--build" - shift # past argument - ;; - -n|--network) - NETWORK="$2" - shift - shift - ;; - -t|--node-type) - NODE_TYPE="$2" - shift - shift - ;; - -p|--bin-path) - BIN_PATH="$2" - shift - shift - ;; - -*|--*) - echo "Unknown option $1" - exit 1 - ;; - *) - POSITIONAL_ARGS+=("$1") - shift - ;; + -h | --help) + help + exit 0 + ;; + -e | --execution) + EXEC_TYPE="$2" + shift # past argument + shift # past value + ;; + -b | --build) + BUILD="--build" + shift # past argument + ;; + -n | --network) + NETWORK="$2" + shift + shift + ;; + -t | --node-type) + NODE_TYPE="$2" + shift + shift + ;; + -p | --bin-path) + BIN_PATH="$2" + shift + shift + ;; + -* | --*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") + shift + ;; esac done # Verifying arguments values if ! [[ "$EXEC_TYPE" =~ ^(docker|binary)$ ]]; then - echo "Exec type not expected: $EXEC_TYPE" - exit 1 + echo "Exec type not expected: $EXEC_TYPE" + exit 1 fi if ! [[ "$NETWORK" =~ ^(mainnet|testnet)$ ]]; then - echo "Network not expected: $NETWORK" - exit 1 + echo "Network not expected: $NETWORK" + exit 1 fi if ! [[ "$NODE_TYPE" =~ ^(lite|archive)$ ]]; then - echo "Node type not expected: $NODE_TYPE" - exit 1 + echo "Node type not expected: $NODE_TYPE" + exit 1 fi # Running subtensor case $EXEC_TYPE in - docker) - docker compose down --remove-orphans - echo "Running docker compose up $BUILD --detach $NETWORK-$NODE_TYPE" - docker compose up $BUILD --detach $NETWORK-$NODE_TYPE - ;; - binary) - run_command $NETWORK $NODE_TYPE $BIN_PATH - ;; +docker) + docker compose down --remove-orphans + echo "Running docker compose up $BUILD --detach $NETWORK-$NODE_TYPE" + docker compose up $BUILD --detach $NETWORK-$NODE_TYPE + ;; +binary) + run_command $NETWORK $NODE_TYPE $BIN_PATH + ;; esac