From ecb62213a1e1fb529cff6477d96b65e486bb703e Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 25 Jun 2024 14:49:52 +0300 Subject: [PATCH] update spec file usage --- docker-compose.yml | 10 +- docs/running-subtensor-locally.md | 8 +- scripts/run/subtensor.sh | 176 +++++++++++++++--------------- 3 files changed, 96 insertions(+), 98 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7b76cd053..09638c174 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.8' +version: "3.8" volumes: mainnet-lite-volume: @@ -38,7 +38,7 @@ services: - | node-subtensor \ --base-path /tmp/blockchain \ - --chain raw_spec.json \ + --chain raw_spec_finney.json \ --rpc-external --rpc-cors all \ --no-mdns \ --in-peers 500 --out-peers 500 \ @@ -56,7 +56,7 @@ services: - | node-subtensor \ --base-path /tmp/blockchain \ - --chain raw_spec.json \ + --chain raw_spec_finney.json \ --rpc-external --rpc-cors all \ --no-mdns \ --in-peers 500 --out-peers 500 \ @@ -74,7 +74,7 @@ services: - | node-subtensor \ --base-path /tmp/blockchain \ - --chain raw_testspec.json \ + --chain raw_spec_testfinney.json \ --rpc-external --rpc-cors all \ --no-mdns \ --in-peers 500 --out-peers 500 \ @@ -94,7 +94,7 @@ services: - | node-subtensor \ --base-path /tmp/blockchain \ - --chain raw_testspec.json \ + --chain raw_spec_testfinney.json \ --rpc-external --rpc-cors all \ --no-mdns \ --in-peers 500 --out-peers 500 \ diff --git a/docs/running-subtensor-locally.md b/docs/running-subtensor-locally.md index 089f4d30a..5f37e146f 100644 --- a/docs/running-subtensor-locally.md +++ b/docs/running-subtensor-locally.md @@ -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 --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/release/node-subtensor --chain raw_spec_finney.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 --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/release/node-subtensor --chain raw_spec_finney.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 --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/release/node-subtensor --chain raw_spec_testfinney.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,7 +198,7 @@ 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 --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/release/node-subtensor --chain raw_spec_testfinney.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 diff --git a/scripts/run/subtensor.sh b/scripts/run/subtensor.sh index e8fd3d58c..b28e8dd6f 100755 --- a/scripts/run/subtensor.sh +++ b/scripts/run/subtensor.sh @@ -4,52 +4,50 @@ # 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_finney.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" @@ -60,69 +58,69 @@ BIN_PATH="./target/release/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