Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update spec file usage #571

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
version: "3.8"

volumes:
mainnet-lite-volume:
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
8 changes: 4 additions & 4 deletions docs/running-subtensor-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,31 +174,31 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WE need to be careful with the merge , as this is ./target/production/node-subtensor in the archive node fix branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there will be a merge conflict. I will handle it.

```

### 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 --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

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

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
Expand Down
176 changes: 87 additions & 89 deletions scripts/run/subtensor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Loading