From 787108ae0629b41a7d75ffa169f03b08ee502da2 Mon Sep 17 00:00:00 2001 From: shr1ftyy Date: Wed, 22 Jan 2025 10:23:44 +0600 Subject: [PATCH] chore: netuid should be uint256 --- runtime/src/precompiles/solidity/staking.sol | 2 +- scripts/dev.sh | 109 +++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100755 scripts/dev.sh diff --git a/runtime/src/precompiles/solidity/staking.sol b/runtime/src/precompiles/solidity/staking.sol index 67f57ff670..bd26530b03 100644 --- a/runtime/src/precompiles/solidity/staking.sol +++ b/runtime/src/precompiles/solidity/staking.sol @@ -40,7 +40,7 @@ interface IStaking { * correctly attributed. * - The existing stake amount must be not lower than specified amount */ - function removeStake(bytes32 hotkey, uint256 amount, uint16 netuid) external; + function removeStake(bytes32 hotkey, uint256 amount, uint256 netuid) external; /** * @dev Returns the amount of RAO staked by the coldkey. diff --git a/scripts/dev.sh b/scripts/dev.sh new file mode 100755 index 0000000000..8ccebbcb55 --- /dev/null +++ b/scripts/dev.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +# Check if `--no-purge` passed as a parameter +NO_PURGE=0 +for arg in "$@"; do + if [ "$arg" = "--no-purge" ]; then + NO_PURGE=1 + break + fi +done + +# Determine the directory this script resides in. This allows invoking it from any location. +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" + +# The base directory of the subtensor project +BASE_DIR="$SCRIPT_DIR/.." + +# get parameters +# Get the value of fast_blocks from the first argument +fast_blocks=${1:-"True"} + +# Check the value of fast_blocks +if [ "$fast_blocks" == "False" ]; then + # Block of code to execute if fast_blocks is False + echo "fast_blocks is Off" + : "${CHAIN:=local}" + : "${BUILD_BINARY:=1}" + : "${FEATURES:="pow-faucet"}" +else + # Block of code to execute if fast_blocks is not False + echo "fast_blocks is On" + : "${CHAIN:=local}" + : "${BUILD_BINARY:=1}" + : "${FEATURES:="pow-faucet fast-blocks"}" +fi + +SPEC_PATH="${SCRIPT_DIR}/specs/" +FULL_PATH="$SPEC_PATH$CHAIN.json" + +# Kill any existing nodes which may have not exited correctly after a previous +# run. +pkill -9 'node-subtensor' + +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 --profile=release --workspace --features "$FEATURES" --manifest-path "$BASE_DIR/Cargo.toml" + echo "*** Binary compiled" +fi + +echo "*** Building chainspec..." +"$BASE_DIR/target/release/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN >$FULL_PATH +echo "*** Chainspec built and output to file" + +# generate node keys +$BASE_DIR/target/release/node-subtensor key generate-node-key --chain="$FULL_PATH" --base-path ../chain-states/dev-state/alice +$BASE_DIR/target/release/node-subtensor key generate-node-key --chain="$FULL_PATH" --base-path ../chain-states/dev-state/bob + +if [ $NO_PURGE -eq 1 ]; then + echo "*** Purging previous state skipped..." +else + echo "*** Purging previous state..." + "$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path ../chain-states/dev-state/bob --chain="$FULL_PATH" >/dev/null 2>&1 + "$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path ../chain-states/dev-state/alice --chain="$FULL_PATH" >/dev/null 2>&1 + echo "*** Previous chainstate purged" +fi + +echo "*** Starting localnet nodes..." +alice_start=( + "$BASE_DIR/target/release/node-subtensor" + --dev + --base-path ../chain-states/dev-state/alice + # --chain="$FULL_PATH" + --alice + --port 30334 + --rpc-port 9944 + --validator + --rpc-cors=all + --allow-private-ipv4 + --discover-local + --unsafe-force-node-key-generation + --offchain-worker=Never +) + +bob_start=( + "$BASE_DIR"/target/release/node-subtensor + --base-path ../chain-states/dev-state/bob + --chain="$FULL_PATH" + --bob + --port 30335 + --rpc-port 9945 + --validator + --rpc-cors=all + --allow-private-ipv4 + --discover-local + --unsafe-force-node-key-generation +) + +trap 'pkill -P $$' EXIT SIGINT SIGTERM + +( + ("${alice_start[@]}" 2>&1) + # ("${bob_start[@]}" 2>&1) + wait +)