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

hotfix: bumps testnet total issuance #776

Merged
merged 1 commit into from
Sep 4, 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,4 @@ runtime-benchmarks = [
"node-subtensor-runtime/runtime-benchmarks",
]
metadata-hash = ["node-subtensor-runtime/metadata-hash"]
testnet = []
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ try-runtime = [
]

metadata-hash = ["node-subtensor-runtime/metadata-hash"]
testnet = []
9 changes: 6 additions & 3 deletions pallets/subtensor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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",
Expand All @@ -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 = []
14 changes: 12 additions & 2 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,18 @@ pub mod pallet {
/// ============================

#[pallet::type_value]
/// Total Rao in circulation.
/// Total TAO Cap.
pub fn TotalSupply<T: Config>() -> 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<T: Config>() -> u16 {
Expand Down Expand Up @@ -665,6 +673,8 @@ pub mod pallet {
/// separate accounting.
#[pallet::storage] // --- ITEM ( total_issuance )
pub type TotalIssuance<T> = StorageValue<_, u64, ValueQuery, DefaultTotalIssuance<T>>;
#[pallet::storage] // --- ITEM ( total_supply )
pub type TotalTaoSupplyCap<T> = StorageValue<_, u64, ValueQuery, TotalSupply<T>>;
#[pallet::storage] // --- ITEM ( total_stake )
pub type TotalStake<T> = StorageValue<_, u64, ValueQuery>;
#[pallet::storage] // --- ITEM ( default_delegate_take )
Expand Down
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,4 @@ try-runtime = [
"pallet-registry/try-runtime",
]
metadata-hash = ["substrate-wasm-builder/metadata-hash"]
testnet = []
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
98 changes: 53 additions & 45 deletions scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,86 +15,94 @@ 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..."
"$BASE_DIR/target/release/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN >$FULL_PATH
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
)
Loading