Skip to content

Commit

Permalink
Merge pull request #779 from opentensor/revert-776-feat/bump_testnet_…
Browse files Browse the repository at this point in the history
…total_issuance

Revert "hotfix: bumps testnet total issuance"
  • Loading branch information
unconst authored Sep 5, 2024
2 parents 94256d5 + ffd8ed3 commit b1039b2
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 79 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,3 @@ runtime-benchmarks = [
"node-subtensor-runtime/runtime-benchmarks",
]
metadata-hash = ["node-subtensor-runtime/metadata-hash"]
testnet = []
4 changes: 0 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,3 @@ 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: 0 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,3 @@ try-runtime = [
]

metadata-hash = ["node-subtensor-runtime/metadata-hash"]
testnet = []
9 changes: 3 additions & 6 deletions pallets/subtensor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ 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 @@ -91,7 +89,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 @@ -115,7 +113,6 @@ 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: 2 additions & 12 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,10 @@ pub mod pallet {
/// ============================
#[pallet::type_value]
/// Total TAO Cap.
/// Total Rao in circulation.
pub fn TotalSupply<T: Config>() -> u64 {
#[cfg(feature = "testnet")]
{
15_000_000_000_000_000_000
}
#[cfg(not(feature = "testnet"))]
{
21_000_000_000_000_000
}
21_000_000_000_000_000
}

#[pallet::type_value]
/// Default Delegate Take.
pub fn DefaultDelegateTake<T: Config>() -> u16 {
Expand Down Expand Up @@ -673,8 +665,6 @@ 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: 0 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,3 @@ 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: 196,
spec_version: 195,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
98 changes: 45 additions & 53 deletions scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,94 +15,86 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
# The base directory of the subtensor project
BASE_DIR="$SCRIPT_DIR/.."

# Get parameters
# get parameters
# Get the value of fast_blocks from the first argument
fast_blocks=${1:-"True"}
testnet=${2:-"Fale"}

# Initialize FEATURES
FEATURES="pow-faucet runtime-benchmarks"

# Check the value of fast_blocks
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"
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"}"
else
echo "testnet is Off"
# 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"}"
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
)

0 comments on commit b1039b2

Please sign in to comment.