generated from opentensor/bittensor-subnet-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
standardize entrypoint script name and location
ls
- Loading branch information
Showing
8 changed files
with
200 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Activate the virtual environment | ||
source /opt/bittensor-venv/bin/activate | ||
|
||
# Use environment variables for passwords | ||
COLDKEY_PASSWORD=${COLDKEY_PASSWORD:-'default_coldkey_password'} | ||
HOTKEY_PASSWORD=${HOTKEY_PASSWORD:-'default_hotkey_password'} | ||
|
||
# Import the shared functions | ||
source functions.sh | ||
|
||
# Create and fund miner wallets | ||
# | ||
# Create a new coldkey with the specified password | ||
echo -e "$COLDKEY_PASSWORD\n$COLDKEY_PASSWORD" | btcli wallet new_coldkey --wallet.name miner --wallet.password | ||
|
||
# Create a new hotkey with the specified password | ||
echo -e "$HOTKEY_PASSWORD\n$HOTKEY_PASSWORD" | btcli wallet new_hotkey --wallet.name miner --wallet.hotkey miner_hotkey --wallet.password | ||
|
||
# Use the faucet for the miner wallet | ||
run_faucet miner || { echo "Faucet failed for miner wallet"; exit 1; } | ||
|
||
echo "Wallets for miner created, and faucet used successfully." | ||
|
||
# Wait for subnet 1 to be created | ||
echo "Waiting for subnet 1 to be created..." | ||
while ! check_subnet_exists; do | ||
echo "Subnet 1 not found. Waiting 15 seconds before checking again..." | ||
sleep 15 | ||
done | ||
echo "Subnet 1 has been created. Proceeding with registration." | ||
|
||
# Attempt to register the validator and start it | ||
if register_node miner; then | ||
echo "Miner registration successful. Starting the miner..." | ||
# Start the miner | ||
python /app/neurons/miner.py --netuid 1 --subtensor.chain_endpoint ws://subtensor_machine:9946 --wallet.name miner --wallet.hotkey miner_hotkey --axon.port 8091 | ||
else | ||
echo "Miner registration failed. Not starting the validator." | ||
fi | ||
|
||
deactivate | ||
|
||
tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Import shared functions | ||
source functions.sh | ||
|
||
# Create and fund owner wallets | ||
# | ||
# Create a new coldkey with the specified password | ||
echo -e "$COLDKEY_PASSWORD\n$COLDKEY_PASSWORD" | btcli wallet new_coldkey --wallet.name owner --wallet.password | ||
|
||
# Create a new hotkey with the specified password | ||
echo -e "$HOTKEY_PASSWORD\n$HOTKEY_PASSWORD" | btcli wallet new_hotkey --wallet.name owner --wallet.hotkey miner_hotkey --wallet.password | ||
|
||
# Use the faucet for the owner wallet multiple times to get enough tTAO to register a subnet | ||
for i in {1..4}; do | ||
run_faucet owner || { echo "Faucet $i failed for owner wallet"; exit 1; } | ||
done | ||
|
||
echo -e "Owner faucet has run 4 times, now has 1200 τTAO" | ||
|
||
# Register / Create a Subnet using expect to handle the interactive prompt and password | ||
expect << EOF | ||
log_user 1 | ||
spawn btcli subnet create --wallet.name owner --subtensor.chain_endpoint ws://subtensor_machine:9945 | ||
expect { | ||
"Do you want to register a subnet for" { | ||
send "y\r" | ||
exp_continue | ||
} | ||
"Enter password to unlock key:" { | ||
send "$COLDKEY_PASSWORD\r" | ||
exp_continue | ||
} | ||
eof | ||
} | ||
EOF | ||
sleep 10 | ||
btcli subnet list --subtensor.chain_endpoint ws://subtensor_machine:9945 | ||
|
||
|
||
tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
: "${CHAIN:=local}" | ||
: "${BUILD_BINARY:=1}" | ||
: "${SPEC_PATH:=specs/}" | ||
: "${FEATURES:=pow-faucet}" | ||
|
||
FULL_PATH="$SPEC_PATH$CHAIN.json" | ||
|
||
if [ ! -d "$SPEC_PATH" ]; then | ||
echo "*** Creating directory ${SPEC_PATH}..." | ||
mkdir $SPEC_PATH | ||
fi | ||
|
||
if [[ $BUILD_BINARY == "1" ]]; then | ||
echo "*** Building substrate binary..." | ||
cargo build --release --features "$FEATURES" | ||
echo "*** Binary compiled" | ||
fi | ||
|
||
echo "*** Building chainspec..." | ||
./target/release/node-subtensor build-spec --disable-default-bootnode --raw --chain $CHAIN > $FULL_PATH | ||
echo "*** Chainspec built and output to file" | ||
|
||
echo "*** Starting localnet nodes..." | ||
alice_start=( | ||
./target/release/node-subtensor | ||
--base-path /tmp/alice | ||
--chain="$FULL_PATH" | ||
--alice | ||
--port 30334 | ||
--rpc-port 9946 | ||
--validator | ||
--rpc-cors=all | ||
--allow-private-ipv4 | ||
--unsafe-rpc-external | ||
--discover-local | ||
) | ||
|
||
bob_start=( | ||
./target/release/node-subtensor | ||
--base-path /tmp/bob | ||
--chain="$FULL_PATH" | ||
--bob | ||
--port 30335 | ||
--rpc-port 9945 | ||
--validator | ||
--allow-private-ipv4 | ||
--unsafe-rpc-external | ||
--rpc-cors=all | ||
--discover-local | ||
) | ||
|
||
(trap 'kill 0' SIGINT; ("${alice_start[@]}" 2>&1) & ("${bob_start[@]}" 2>&1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Activate the virtual environment | ||
source /opt/bittensor-venv/bin/activate | ||
|
||
# Use environment variables for passwords | ||
COLDKEY_PASSWORD=${COLDKEY_PASSWORD:-'default_coldkey_password'} | ||
HOTKEY_PASSWORD=${HOTKEY_PASSWORD:-'default_hotkey_password'} | ||
|
||
# Import shared functions | ||
source functions.sh | ||
|
||
# Create and fund validator wallets | ||
echo -e "$COLDKEY_PASSWORD\n$COLDKEY_PASSWORD" | btcli wallet new_coldkey --wallet.name validator --wallet.password | ||
echo -e "$HOTKEY_PASSWORD\n$HOTKEY_PASSWORD" | btcli wallet new_hotkey --wallet.name validator --wallet.hotkey validator_hotkey --wallet.password | ||
|
||
# Use the faucet for the validator wallet | ||
run_faucet validator || { echo "Faucet failed for validator wallet"; exit 1; } | ||
echo "Wallets for validator created, and faucet used successfully." | ||
|
||
# Wait for subnet 1 to be created | ||
echo "Waiting for subnet 1 to be created..." | ||
while ! check_subnet_exists; do | ||
echo "Subnet 1 not found. Waiting 15 seconds before checking again..." | ||
sleep 15 | ||
done | ||
echo "Subnet 1 has been created. Proceeding with registration." | ||
|
||
# Attempt to register the validator and start it | ||
if register_node validator; then | ||
echo "Validator registration successful. Starting the validator..." | ||
# Start the validator | ||
python /app/neurons/validator.py --netuid 1 --subtensor.chain_endpoint ws://subtensor_machine:9946 --wallet.name validator --wallet.hotkey validator_hotkey --axon.port 8092 | ||
else | ||
echo "Validator registration failed. Not starting the validator." | ||
fi | ||
|
||
# Keep the container running | ||
tail -f /dev/null |