diff --git a/Cargo.toml b/Cargo.toml index f9a7968b9..d390177be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -176,3 +176,4 @@ runtime-benchmarks = [ "node-subtensor-runtime/runtime-benchmarks", ] metadata-hash = ["node-subtensor-runtime/metadata-hash"] +testnet = [] diff --git a/justfile b/justfile index f99f3913a..d20ae9afb 100644 --- a/justfile +++ b/justfile @@ -52,3 +52,7 @@ lint: production: @echo "Running cargo build with metadata-hash generation..." cargo +{{RUSTV}} build --profile production --features="runtime-benchmarks metadata-hash" + +testnet: + @echo "Running cargo build with testnet config..." + cargo +{{RUSTV}} build --profile production --features="runtime-benchmarks metadata-hash testnet" diff --git a/node/Cargo.toml b/node/Cargo.toml index 3c5c91b92..2e85897a4 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -107,3 +107,4 @@ try-runtime = [ ] metadata-hash = ["node-subtensor-runtime/metadata-hash"] +testnet = [] diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 3023d1e0d..ab50e89f2 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -45,7 +45,9 @@ hex = { workspace = true } pallet-collective = { version = "4.0.0-dev", default-features = false, path = "../collective" } pallet-membership = { workspace = true } hex-literal = { workspace = true } -num-traits = { version = "0.2.19", default-features = false, features = ["libm"] } +num-traits = { version = "0.2.19", default-features = false, features = [ + "libm", +] } [dev-dependencies] pallet-balances = { workspace = true, features = ["std"] } @@ -89,7 +91,7 @@ std = [ "serde_with/std", "substrate-fixed/std", "num-traits/std", - "serde_json/std" + "serde_json/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -113,6 +115,7 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-utility/try-runtime", "sp-runtime/try-runtime", - "pallet-collective/try-runtime" + "pallet-collective/try-runtime", ] pow-faucet = [] +testnet = [] diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 2985736c8..855704c0e 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -187,10 +187,18 @@ pub mod pallet { /// ============================ #[pallet::type_value] - /// Total Rao in circulation. + /// Total TAO Cap. pub fn TotalSupply() -> u64 { - 21_000_000_000_000_000 + #[cfg(feature = "testnet")] + { + 15_000_000_000_000_000_000 + } + #[cfg(not(feature = "testnet"))] + { + 21_000_000_000_000_000 + } } + #[pallet::type_value] /// Default Delegate Take. pub fn DefaultDelegateTake() -> u16 { @@ -665,6 +673,8 @@ pub mod pallet { /// separate accounting. #[pallet::storage] // --- ITEM ( total_issuance ) pub type TotalIssuance = StorageValue<_, u64, ValueQuery, DefaultTotalIssuance>; + #[pallet::storage] // --- ITEM ( total_supply ) + pub type TotalTaoSupplyCap = StorageValue<_, u64, ValueQuery, TotalSupply>; #[pallet::storage] // --- ITEM ( total_stake ) pub type TotalStake = StorageValue<_, u64, ValueQuery>; #[pallet::storage] // --- ITEM ( default_delegate_take ) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 8a2886eb1..6c5bf28c1 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -207,3 +207,4 @@ try-runtime = [ "pallet-registry/try-runtime", ] metadata-hash = ["substrate-wasm-builder/metadata-hash"] +testnet = [] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ca8f83911..5ffb0863a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -142,7 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 195, + spec_version: 196, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/scripts/localnet.sh b/scripts/localnet.sh index 850a314d8..e0e366a6a 100755 --- a/scripts/localnet.sh +++ b/scripts/localnet.sh @@ -15,41 +15,49 @@ 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 +# Get parameters fast_blocks=${1:-"True"} +testnet=${2:-"Fale"} + +# Initialize FEATURES +FEATURES="pow-faucet runtime-benchmarks" # 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 runtime-benchmarks"}" +if [ "$fast_blocks" == "True" ]; then + echo "fast_blocks is On" + FEATURES+=" fast-blocks" +else + echo "fast_blocks is Off" +fi + +# Check the value of testnet +if [ "$testnet" == "True" ]; then + echo "testnet is On" + FEATURES+=" testnet" 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 runtime-benchmarks fast-blocks"}" + echo "testnet is Off" fi +: "${CHAIN:=local}" +: "${BUILD_BINARY:=1}" + 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 + echo "*** Creating directory ${SPEC_PATH}..." + mkdir $SPEC_PATH fi if [[ $BUILD_BINARY == "1" ]]; then - echo "*** Building substrate binary..." - cargo build --workspace --profile=release --features "$FEATURES" --manifest-path "$BASE_DIR/Cargo.toml" - echo "*** Binary compiled" + echo "*** Building substrate binary..." + cargo build --workspace --profile=release --features "$FEATURES" --manifest-path "$BASE_DIR/Cargo.toml" + echo "*** Binary compiled" fi echo "*** Building chainspec..." @@ -57,44 +65,44 @@ echo "*** Building chainspec..." echo "*** Chainspec built and output to file" if [ $NO_PURGE -eq 1 ]; then - echo "*** Purging previous state skipped..." + echo "*** Purging previous state skipped..." else - echo "*** Purging previous state..." - "$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1 - "$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/alice --chain="$FULL_PATH" >/dev/null 2>&1 - echo "*** Previous chainstate purged" + echo "*** Purging previous state..." + "$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1 + "$BASE_DIR/target/release/node-subtensor" purge-chain -y --base-path /tmp/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" - --base-path /tmp/alice - --chain="$FULL_PATH" - --alice - --port 30334 - --rpc-port 9946 - --validator - --rpc-cors=all - --allow-private-ipv4 - --discover-local + "$BASE_DIR/target/release/node-subtensor" + --base-path /tmp/alice + --chain="$FULL_PATH" + --alice + --port 30334 + --rpc-port 9946 + --validator + --rpc-cors=all + --allow-private-ipv4 + --discover-local ) bob_start=( - "$BASE_DIR"/target/release/node-subtensor - --base-path /tmp/bob - --chain="$FULL_PATH" - --bob - --port 30335 - --rpc-port 9945 - --validator - --allow-private-ipv4 - --discover-local + "$BASE_DIR"/target/release/node-subtensor + --base-path /tmp/bob + --chain="$FULL_PATH" + --bob + --port 30335 + --rpc-port 9945 + --validator + --allow-private-ipv4 + --discover-local ) trap 'pkill -P $$' EXIT SIGINT SIGTERM ( - ("${alice_start[@]}" 2>&1) & - ("${bob_start[@]}" 2>&1) - wait + ("${alice_start[@]}" 2>&1) & + ("${bob_start[@]}" 2>&1) + wait )