Skip to content

Commit

Permalink
update docs to use production profile
Browse files Browse the repository at this point in the history
remove --execution and --wasm-execution
  • Loading branch information
orriin committed Jun 24, 2024
1 parent c097ff8 commit c5865b4
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 157 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
11 changes: 6 additions & 5 deletions docs/running-subtensor-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -174,32 +174,33 @@ 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

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

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

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.
6 changes: 3 additions & 3 deletions docs/rust-setup.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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-<yyyy-MM-dd> cargo build --release
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build --profile production
```

> Note that this only builds _the runtime_ with the specified nightly. The rest of project will be
Expand All @@ -223,3 +222,4 @@ rustup uninstall nightly
rustup install nightly-<yyyy-MM-dd>
rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
```

20 changes: 9 additions & 11 deletions pallets/admin-utils/scripts/benchmark.sh
Original file line number Diff line number Diff line change
@@ -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
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
16 changes: 7 additions & 9 deletions pallets/commitments/scripts/benchmark.sh
Original file line number Diff line number Diff line change
@@ -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
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
14 changes: 6 additions & 8 deletions pallets/registry/scripts/benchmark.sh
Original file line number Diff line number Diff line change
@@ -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
./target/production/node-subtensor benchmark pallet \
--chain=local \
--pallet=pallet_registry \
--extrinsic="*" \
--output=pallets/registry/src/weights.rs \
--template=./.maintain/frame-weight-template.hbs
53 changes: 25 additions & 28 deletions scripts/benchmark.sh
Original file line number Diff line number Diff line change
@@ -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
rm $TMP_SPEC
3 changes: 2 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cargo build --release --features runtime-benchmarks
cargo build --profile production --features runtime-benchmarks

Loading

0 comments on commit c5865b4

Please sign in to comment.