Skip to content

Commit ce8e91b

Browse files
authored
Merge pull request #670 from opentensor/testnet_rebase
Testnet rebase
2 parents 09c146b + 59d9cbd commit ce8e91b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4268
-452
lines changed

Diff for: .github/workflows/e2e-bittensor-tests.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@ concurrency:
55
cancel-in-progress: true
66

77
on:
8-
## Run automatically for all PRs against main, regardless of what the changes are
9-
## to be safe and so we can more easily force re-run the CI when github is being
10-
## weird by using a blank commit
118
push:
12-
branches: [main, development, staging]
9+
branches: [main, devnet-ready, devnet, testnet, finney]
1310

14-
##
15-
# Run automatically for PRs against default/main branch if Rust files change
1611
pull_request:
17-
branches: [main, development, staging]
1812

1913
## Allow running workflow manually from the Actions tab
2014
workflow_dispatch:

Diff for: .gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ specs/*.json
4040
.idea
4141

4242
# Runtime upgrade snapshot
43-
bt.snap
43+
bt.snap
44+
45+
# localnet spec
46+
scripts/specs/local.json

Diff for: Dockerfile

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ COPY Cargo.lock Cargo.toml /subtensor/
3838

3939
# Specs
4040
COPY ./snapshot.json /subtensor/snapshot.json
41+
COPY ./raw_spec_testfinney.json /subtensor/raw_spec_testfinney.json
42+
COPY ./raw_spec_finney.json /subtensor/raw_spec_finney.json
4143

4244
# Copy our sources
4345
COPY ./node /subtensor/node
@@ -51,11 +53,13 @@ RUN /subtensor/scripts/init.sh
5153

5254
# Cargo build
5355
WORKDIR /subtensor
54-
RUN cargo build --release --features runtime-benchmarks --locked
56+
RUN cargo build --profile production --features runtime-benchmarks --locked
5557
EXPOSE 30333 9933 9944
5658

5759

5860
FROM $BASE_IMAGE AS subtensor
5961

6062
COPY --from=builder /subtensor/snapshot.json /
61-
COPY --from=builder /subtensor/target/release/node-subtensor /usr/local/bin
63+
COPY --from=builder /subtensor/raw_spec_testfinney.json /
64+
COPY --from=builder /subtensor/raw_spec_finney.json /
65+
COPY --from=builder /subtensor/target/production/node-subtensor /usr/local/bin

Diff for: docs/running-subtensor-locally.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ rm -rf /tmp/blockchain
162162
Install subtensor by compiling with `cargo`:
163163

164164
```bash
165-
cargo build --release --features=runtime-benchmarks
165+
cargo build --profile production --features=runtime-benchmarks
166166
```
167167

168168
## Run the subtensor node
@@ -174,31 +174,31 @@ You can now run the public subtensor node either as a lite node or as an archive
174174
To run a lite node connected to the mainchain, execute the below command (note the `--sync=warp` flag which runs the subtensor node in lite mode):
175175

176176
```bash title="With --sync=warp setting, for lite node"
177-
./target/release/node-subtensor --chain raw_spec_finney.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
177+
./target/production/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
178178
```
179179

180180
### Archive node on mainchain
181181

182182
To run an archive node connected to the mainchain, execute the below command (note the `--sync=full` which syncs the node to the full chain and `--pruning archive` flags, which disables the node's automatic pruning of older historical data):
183183

184184
```bash title="With --sync=full and --pruning archive setting, for archive node"
185-
./target/release/node-subtensor --chain raw_spec_finney.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
185+
./target/production/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
186186
```
187187

188188
### Lite node on testchain
189189

190190
To run a lite node connected to the testchain, execute the below command:
191191

192192
```bash title="With bootnodes set to testnet and --sync=warp setting, for lite node."
193-
./target/release/node-subtensor --chain raw_spec_testfinney.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
193+
./target/production/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
194194
```
195195

196196
### Archive node on testchain
197197

198198
To run an archive node connected to the testchain, execute the below command:
199199

200200
```bash title="With bootnodes set to testnet and --sync=full and --pruning archive setting, for archive node"
201-
./target/release/node-subtensor --chain raw_spec_testfinney.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
201+
./target/production/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
202202
```
203203

204204
## Running on cloud

Diff for: docs/rust-setup.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
title: Installation
33
---
4-
5-
This guide is for reference only, please check the latest information on getting starting with Substrate
4+
This guide is for reference only, please check the latest information on getting starting with Substrate
65
[here](https://docs.substrate.io/main-docs/install/).
76

87
This page will guide you through the **2 steps** needed to prepare a computer for **Substrate** development.
@@ -207,7 +206,7 @@ Use the `WASM_BUILD_TOOLCHAIN` environment variable to specify the Rust nightly
207206
project should use for Wasm compilation:
208207

209208
```bash
210-
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build --release
209+
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build --profile production
211210
```
212211

213212
> Note that this only builds _the runtime_ with the specified nightly. The rest of project will be
@@ -223,3 +222,4 @@ rustup uninstall nightly
223222
rustup install nightly-<yyyy-MM-dd>
224223
rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
225224
```
225+

Diff for: justfile

+6-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ clippy:
3030
-D clippy::unimplemented
3131

3232
clippy-fix:
33-
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
34-
cargo +{{RUSTV}} clippy --workspace --all-targets --fix --allow-dirty -- \
35-
-A clippy::todo \
36-
-A clippy::unimplemented \
37-
-A clippy::indexing_slicing
33+
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
34+
cargo +{{RUSTV}} clippy --fix --allow-dirty --allow-staged --workspace --all-targets -- \
35+
-A clippy::todo \
36+
-A clippy::unimplemented \
37+
-A clippy::indexing_slicing
38+
3839
fix:
3940
@echo "Running cargo fix..."
4041
cargo +{{RUSTV}} fix --workspace

Diff for: pallets/admin-utils/scripts/benchmark.sh

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
cargo build --release --features runtime-benchmarks
2-
./target/release/node-subtensor benchmark pallet \
3-
--chain=local \
4-
--execution=wasm \
5-
--wasm-execution=compiled \
6-
--pallet=pallet_admin_utils \
7-
--extrinsic="*" \
8-
--steps 50 \
9-
--repeat 20 \
10-
--output=pallets/admin-utils/src/weights.rs \
11-
--template=./.maintain/frame-weight-template.hbs
1+
cargo build --profile production --features runtime-benchmarks
2+
./target/production/node-subtensor benchmark pallet \
3+
--chain=local \
4+
--pallet=pallet_admin_utils \
5+
--extrinsic="*" \
6+
--steps 50 \
7+
--repeat 20 \
8+
--output=pallets/admin-utils/src/weights.rs \
9+
--template=./.maintain/frame-weight-template.hbs

Diff for: pallets/admin-utils/tests/mock.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ parameter_types! {
110110
pub const InitialSubnetLimit: u16 = 10; // Max 10 subnets.
111111
pub const InitialNetworkRateLimit: u64 = 0;
112112
pub const InitialTargetStakesPerInterval: u16 = 1;
113-
pub const InitialHotkeySwapCost: u64 = 1_000_000_000;
113+
pub const InitialKeySwapCost: u64 = 1_000_000_000;
114114
pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default
115115
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
116116
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
117+
pub const InitialBaseDifficulty: u64 = 10_000; // Base difficulty
117118
}
118119

119120
impl pallet_subtensor::Config for Test {
@@ -165,10 +166,11 @@ impl pallet_subtensor::Config for Test {
165166
type InitialSubnetLimit = InitialSubnetLimit;
166167
type InitialNetworkRateLimit = InitialNetworkRateLimit;
167168
type InitialTargetStakesPerInterval = InitialTargetStakesPerInterval;
168-
type HotkeySwapCost = InitialHotkeySwapCost;
169+
type KeySwapCost = InitialKeySwapCost;
169170
type AlphaHigh = InitialAlphaHigh;
170171
type AlphaLow = InitialAlphaLow;
171172
type LiquidAlphaOn = InitialLiquidAlphaOn;
173+
type InitialBaseDifficulty = InitialBaseDifficulty;
172174
}
173175

174176
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]

Diff for: pallets/collective/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<AccountId, I> GetBacking for RawOrigin<AccountId, I> {
151151
}
152152

153153
/// Info for keeping track of a motion being voted on.
154-
#[freeze_struct("5959418cdb31993b")]
154+
#[freeze_struct("a8e7b0b34ad52b17")]
155155
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
156156
pub struct Votes<AccountId, BlockNumber> {
157157
/// The proposal's unique index.

Diff for: pallets/commitments/scripts/benchmark.sh

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
cargo build --release --features runtime-benchmarks
2-
./target/release/node-subtensor benchmark pallet \
3-
--chain=local \
4-
--execution=wasm \
5-
--wasm-execution=compiled \
6-
--pallet=pallet_commitments \
7-
--extrinsic="*" \
8-
--output=pallets/commitments/src/weights.rs \
9-
--template=./.maintain/frame-weight-template.hbs
1+
cargo build --profile production --features runtime-benchmarks
2+
./target/production/node-subtensor benchmark pallet \
3+
--chain=local \
4+
--pallet=pallet_commitments \
5+
--extrinsic="*" \
6+
--output=pallets/commitments/src/weights.rs \
7+
--template=./.maintain/frame-weight-template.hbs

Diff for: pallets/registry/scripts/benchmark.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
cargo build --release --features runtime-benchmarks
2-
./target/release/node-subtensor benchmark pallet \
3-
--chain=local \
4-
--execution=wasm \
5-
--wasm-execution=compiled \
6-
--pallet=pallet_registry \
7-
--extrinsic="*" \
8-
--output=pallets/registry/src/weights.rs \
9-
--template=./.maintain/frame-weight-template.hbs
2+
./target/production/node-subtensor benchmark pallet \
3+
--chain=local \
4+
--pallet=pallet_registry \
5+
--extrinsic="*" \
6+
--output=pallets/registry/src/weights.rs \
7+
--template=./.maintain/frame-weight-template.hbs

Diff for: pallets/registry/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl TypeInfo for IdentityFields {
279279
///
280280
/// NOTE: This should be stored at the end of the storage item to facilitate the addition of extra
281281
/// fields in a backwards compatible way through a specialized `Decode` impl.
282-
#[freeze_struct("9d47309f8e379957")]
282+
#[freeze_struct("98e2d7fc7536226b")]
283283
#[derive(
284284
CloneNoBound, Encode, Decode, Eq, MaxEncodedLen, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo,
285285
)]

Diff for: pallets/subtensor/src/benchmarks.rs

+28-52
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ benchmarks! {
8080
// This is a whitelisted caller who can make transaction without weights.
8181
let caller: T::AccountId = whitelisted_caller::<AccountIdOf<T>>();
8282
let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));
83-
let netuid: u16 = 0;
83+
let netuid: u16 = 1;
8484
let version_key: u64 = 1;
8585
let tempo: u16 = 1;
8686
let modality: u16 = 0;
@@ -314,33 +314,33 @@ benchmarks! {
314314
assert_ok!(Subtensor::<T>::register_network(RawOrigin::Signed(coldkey.clone()).into()));
315315
}: dissolve_network(RawOrigin::Signed(coldkey), 1)
316316

317-
swap_hotkey {
318-
let seed: u32 = 1;
319-
let coldkey: T::AccountId = account("Alice", 0, seed);
320-
let old_hotkey: T::AccountId = account("Bob", 0, seed);
321-
let new_hotkey: T::AccountId = account("Charlie", 0, seed);
322-
323-
let netuid = 1u16;
324-
Subtensor::<T>::init_new_network(netuid, 100);
325-
Subtensor::<T>::set_min_burn(netuid, 1);
326-
Subtensor::<T>::set_max_burn(netuid, 1);
327-
Subtensor::<T>::set_target_registrations_per_interval(netuid, 256);
328-
Subtensor::<T>::set_max_registrations_per_block(netuid, 256);
329-
330-
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), 10_000_000_000u64);
331-
assert_ok!(Subtensor::<T>::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, old_hotkey.clone()));
332-
assert_ok!(Subtensor::<T>::become_delegate(RawOrigin::Signed(coldkey.clone()).into(), old_hotkey.clone()));
333-
334-
let max_uids = Subtensor::<T>::get_max_allowed_uids(netuid) as u32;
335-
for i in 0..max_uids - 1 {
336-
let coldkey: T::AccountId = account("Axon", 0, i);
337-
let hotkey: T::AccountId = account("Hotkey", 0, i);
338-
339-
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), 10_000_000_000u64);
340-
assert_ok!(Subtensor::<T>::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey));
341-
assert_ok!(Subtensor::<T>::add_stake(RawOrigin::Signed(coldkey).into(), old_hotkey.clone(), 1_000_000_000));
342-
}
343-
}: _(RawOrigin::Signed(coldkey), old_hotkey, new_hotkey)
317+
// swap_hotkey {
318+
// let seed: u32 = 1;
319+
// let coldkey: T::AccountId = account("Alice", 0, seed);
320+
// let old_hotkey: T::AccountId = account("Bob", 0, seed);
321+
// let new_hotkey: T::AccountId = account("Charlie", 0, seed);
322+
323+
// let netuid = 1u16;
324+
// Subtensor::<T>::init_new_network(netuid, 100);
325+
// Subtensor::<T>::set_min_burn(netuid, 1);
326+
// Subtensor::<T>::set_max_burn(netuid, 1);
327+
// Subtensor::<T>::set_target_registrations_per_interval(netuid, 256);
328+
// Subtensor::<T>::set_max_registrations_per_block(netuid, 256);
329+
330+
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), 10_000_000_000u64);
331+
// assert_ok!(Subtensor::<T>::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, old_hotkey.clone()));
332+
// assert_ok!(Subtensor::<T>::become_delegate(RawOrigin::Signed(coldkey.clone()).into(), old_hotkey.clone()));
333+
334+
// let max_uids = Subtensor::<T>::get_max_allowed_uids(netuid) as u32;
335+
// for i in 0..max_uids - 1 {
336+
// let coldkey: T::AccountId = account("Axon", 0, i);
337+
// let hotkey: T::AccountId = account("Hotkey", 0, i);
338+
339+
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), 10_000_000_000u64);
340+
// assert_ok!(Subtensor::<T>::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey));
341+
// assert_ok!(Subtensor::<T>::add_stake(RawOrigin::Signed(coldkey).into(), old_hotkey.clone(), 1_000_000_000));
342+
// }
343+
// }: _(RawOrigin::Signed(coldkey), old_hotkey, new_hotkey)
344344

345345
commit_weights {
346346
let tempo: u16 = 1;
@@ -429,28 +429,4 @@ reveal_weights {
429429

430430
}: reveal_weights(RawOrigin::Signed(hotkey.clone()), netuid, uids, weight_values, salt, version_key)
431431

432-
433-
adjust_senate {
434-
migration::migrate_create_root_network::<T>();
435-
let netuid: u16 = 1;
436-
let tempo: u16 = 13;
437-
let burn_cost = 1000;
438-
let hotkey: T::AccountId = account("hot", 0, 1);
439-
let coldkey: T::AccountId = account("cold", 0, 2);
440-
441-
Subtensor::<T>::init_new_network(netuid, 100);
442-
Subtensor::<T>::set_burn(netuid, 1);
443-
Subtensor::<T>::set_max_allowed_uids( netuid, 4096 );
444-
assert_eq!(Subtensor::<T>::get_max_allowed_uids(netuid), 4096);
445-
Subtensor::<T>::set_burn(netuid, burn_cost);
446-
447-
let amount_to_be_staked = 100_000_000_000;
448-
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked);
449-
450-
assert_ok!(Subtensor::<T>::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone()));
451-
assert_ok!(Subtensor::<T>::become_delegate(RawOrigin::Signed(coldkey.clone()).into(), hotkey.clone()));
452-
assert_ok!(Subtensor::<T>::root_register(RawOrigin::Signed(coldkey.clone()).into(), hotkey.clone()));
453-
T::SenateMembers::remove_member(&hotkey).map_err(|_| "Failed to remove member")?;
454-
455-
}: adjust_senate(RawOrigin::Signed(coldkey.clone()), hotkey.clone())
456432
}

Diff for: pallets/subtensor/src/block_step.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ impl<T: Config> Pallet<T> {
118118
// --- 1. Iterate across each network and add pending emission into stash.
119119
for (netuid, tempo) in <Tempo<T> as IterableStorageMap<u16, u16>>::iter() {
120120
// Skip the root network or subnets with registrations turned off
121-
if netuid == Self::get_root_netuid() || !Self::is_registration_allowed(netuid) {
121+
if netuid == Self::get_root_netuid() {
122122
// Root emission or subnet emission is burned
123123
continue;
124124
}
125125

126126
// --- 2. Queue the emission due to this network.
127-
let new_queued_emission: u64 = Self::get_subnet_emission_value(netuid);
127+
let mut new_queued_emission: u64 = Self::get_subnet_emission_value(netuid);
128+
if !Self::is_registration_allowed(netuid) {
129+
new_queued_emission = 0; // No emission for this network if registration is off.
130+
}
131+
128132
log::debug!(
129133
"generate_emission for netuid: {:?} with tempo: {:?} and emission: {:?}",
130134
netuid,

0 commit comments

Comments
 (0)