Skip to content

Commit

Permalink
Merge branch 'devnet-ready' into fix-return_per_1000
Browse files Browse the repository at this point in the history
  • Loading branch information
open-junius committed Jan 10, 2025
2 parents fcd3220 + 12a0f71 commit 2016b12
Show file tree
Hide file tree
Showing 97 changed files with 12,151 additions and 10,628 deletions.
443 changes: 205 additions & 238 deletions Cargo.lock

Large diffs are not rendered by default.

48 changes: 25 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ members = [
"pallets/admin-utils",
"pallets/collective",
"pallets/registry",
"primitives/*",
"runtime",
"support/tools",
"support/macros",
Expand Down Expand Up @@ -82,6 +83,7 @@ quote = "1"
proc-macro2 = { version = "1", features = ["span-locations"] }
thiserror = "1.0"
walkdir = "2"
approx = "0.5"

subtensor-macros = { path = "support/macros" }

Expand Down Expand Up @@ -138,7 +140,7 @@ sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" }
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
Expand Down Expand Up @@ -166,32 +168,32 @@ sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }

# Frontier
fp-evm = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fp-rpc = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fp-self-contained = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false, features = [
fp-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = [
"serde",
] }
fp-account = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fc-storage = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fc-db = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fc-consensus = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fp-consensus = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fp-dynamic-fee = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fc-api = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fc-rpc = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fc-rpc-core = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fc-mapping-sync = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
fp-account = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fc-storage = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fc-db = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fc-api = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }

# Frontier FRAME
pallet-base-fee = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-dynamic-fee = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-ethereum = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-evm = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-evm-chain-id = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-evm-precompile-modexp = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-evm-precompile-sha3fips = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-evm-precompile-simple = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-hotfix-sufficients = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }

#DRAND
pallet-drand = { path = "pallets/drand", default-features = false }
Expand Down
9 changes: 2 additions & 7 deletions chainspecs/plain_spec_devnet.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion chainspecs/plain_spec_finney.json

Large diffs are not rendered by default.

138 changes: 85 additions & 53 deletions chainspecs/raw_spec_devnet.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion chainspecs/raw_spec_finney.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion nakamoto_gen.json

This file was deleted.

2 changes: 2 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ clap = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["thread-pool"] }
scale-codec = { workspace = true }
serde = { workspace = true, features = ["derive"] }
hex = { workspace = true }

# Storage import
memmap2 = { workspace = true }
Expand Down Expand Up @@ -102,6 +103,7 @@ fp-rpc = { workspace = true }
fc-mapping-sync = { workspace = true }
fp-consensus = { workspace = true }
thiserror = { workspace = true }
num-traits = { version = "0.2", features = ["std"] }

# Local Dependencies
node-subtensor-runtime = { path = "../runtime" }
Expand Down
1 change: 1 addition & 0 deletions node/src/chain_spec/code_substitute_2585476.txt

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions node/src/chain_spec/devnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ pub fn devnet_config() -> Result<ChainSpec, String> {
// Keys for debug
authority_keys_from_ss58(
"5D5ABUyMsdmJdH7xrsz9vREq5eGXr5pXhHxix2dENQR62dEo",
"5DLBJuPvyPYit5h5ZaYiF8NvCweXCozUs6pLx3fng1mdVcbw",
"5H3qMjQjoeZxZ98jzDmoCwbz2sugd5fDN1wrr8Phf49zemKL",
),
authority_keys_from_ss58(
"5GbRc5sNDdhcPAU9suV2g9P5zyK1hjAQ9JHeeadY1mb8kXoM",
"5ELAzpniRUzAtvydVLmfs5ogbjzoBVxfn6XrN91ahBeDukoY",
"5GbkysfaCjK3cprKPhi3CUwaB5xWpBwcfrkzs6FmqHxej8HZ",
),
authority_keys_from_ss58(
"5CoVWwBwXz2ndEChGcS46VfSTb3RMUZzZzAYdBKo263zDhEz",
"5EHVLDoMqjWrBnUrNtj8FAb1sFFg97vydLGydH8vz7BGs9Qf",
"5HTLp4BvPp99iXtd8YTBZA1sMfzo8pd4mZzBJf7HYdCn2boU",
),
authority_keys_from_ss58(
"5EekcbqupwbgWqF8hWGY4Pczsxp9sbarjDehqk7bdyLhDCwC",
"5CdFyer8NZ4m8QXAHkgZ7zQ8oM8U6N5XrMSDzcMWdDjbAwUg",
"5GAemcU4Pzyfe8DwLwDFx3aWzyg3FuqYUCCw2h4sdDZhyFvE",
),
authority_keys_from_ss58(
"5GgdEQyS5DZzUwKuyucEPEZLxFKGmasUFm1mqM3sx1MRC5RV",
"5FYgXyYc59s9c161swNEf4VEGezLd3q5ca6rSYWuJPjbBNKf",
"5EibpMomXmgekxcfs25SzFBpGWUsG9Lc8ALNjXN3TYH5Tube",
),
],
// Sudo account
Expand Down
23 changes: 21 additions & 2 deletions node/src/chain_spec/finney.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(clippy::unwrap_used)]

use super::*;
use hex::FromHex;

pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
let path: PathBuf = std::path::PathBuf::from("./snapshot.json");
Expand Down Expand Up @@ -69,7 +70,7 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
properties.insert("tokenDecimals".into(), 9.into());
properties.insert("ss58Format".into(), 42.into());

Ok(ChainSpec::builder(
let chain_spec = ChainSpec::builder(
wasm_binary,
Extensions {
bad_blocks: Some(HashSet::new()),
Expand Down Expand Up @@ -181,7 +182,25 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
balances_issuance,
))
.with_properties(properties)
.build())
.build();

// Load and set the code substitute to avoid archive node sync panic
// See <https://github.com/opentensor/subtensor/pull/1051>
//
// Need to do it in this hacky way because the ChainSpec builder doesn't support setting it
let code_substitute_2585476_hex = include_bytes!("code_substitute_2585476.txt");
let chain_spec_json = chain_spec.as_json(false).unwrap();
let mut chain_spec_json = serde_json::from_str(&chain_spec_json).unwrap();
sc_chain_spec::set_code_substitute_in_json_chain_spec(
&mut chain_spec_json,
Vec::from_hex(code_substitute_2585476_hex)
.unwrap()
.as_slice(),
2585476,
);
let chain_spec_bytes = chain_spec_json.to_string().into_bytes();
let chain_spec = ChainSpec::from_json_bytes(chain_spec_bytes).unwrap();
Ok(chain_spec)
}

// Configure initial storage state for FRAME modules.
Expand Down
3 changes: 3 additions & 0 deletions node/src/chain_spec/localnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,8 @@ fn localnet_genesis(
"senateMembers": {
"members": senate_members,
},
"evmChainId": {
"chainId": 42,
},
})
}
38 changes: 23 additions & 15 deletions pallets/admin-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
subtensor-macros.workspace = true
subtensor-macros = { workspace = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
] }
Expand All @@ -29,8 +29,9 @@ log = { workspace = true }
pallet-subtensor = { version = "4.0.0-dev", default-features = false, path = "../subtensor" }
sp-weights = { workspace = true }
substrate-fixed = { workspace = true }
pallet-evm-chain-id = { workspace = true }
pallet-drand = { workspace = true, default-features = false }

sp-consensus-grandpa = { workspace = true }

[dev-dependencies]
sp-core = { workspace = true }
Expand All @@ -39,6 +40,7 @@ sp-tracing = { workspace = true }
sp-consensus-aura = { workspace = true }
pallet-balances = { workspace = true, features = ["std"] }
pallet-scheduler = { workspace = true }
pallet-grandpa = { workspace = true }
sp-std = { workspace = true }

[features]
Expand All @@ -48,37 +50,43 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"pallet-subtensor/std",
"sp-consensus-aura/std",
"log/std",
"pallet-balances/std",
"pallet-drand/std",
"pallet-evm-chain-id/std",
"pallet-grandpa/std",
"pallet-scheduler/std",
"sp-runtime/std",
"sp-tracing/std",
"sp-weights/std",
"log/std",
"pallet-subtensor/std",
"scale-info/std",
"sp-consensus-aura/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"sp-tracing/std",
"sp-weights/std",
"substrate-fixed/std",
"pallet-drand/std"
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-subtensor/runtime-benchmarks",
"pallet-drand/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-drand/runtime-benchmarks"
"pallet-subtensor/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-drand/try-runtime",
"pallet-evm-chain-id/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-scheduler/try-runtime",
"sp-runtime/try-runtime",
"pallet-subtensor/try-runtime",
"pallet-drand/try-runtime"
"sp-runtime/try-runtime",
]
28 changes: 16 additions & 12 deletions pallets/admin-utils/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Benchmarking setup
#![cfg(feature = "runtime-benchmarks")]
#![allow(clippy::arithmetic_side_effects)]
use super::*;

extern crate alloc;
use alloc::vec::Vec;

#[allow(unused)]
use crate::Pallet as AdminUtils;
Expand All @@ -10,6 +12,8 @@ use frame_benchmarking::v2::*;
use frame_support::BoundedVec;
use frame_system::RawOrigin;

use super::*;

#[benchmarks]
mod benchmarks {
use super::*;
Expand All @@ -33,6 +37,17 @@ mod benchmarks {
_(RawOrigin::Root, value);
}

#[benchmark]
fn schedule_grandpa_change(a: Linear<0, 32>) {
let next_authorities = (1..=a)
.map(|idx| account("Authority", idx, 0u32))
.collect::<Vec<(sp_consensus_grandpa::AuthorityId, u64)>>();
let in_blocks = BlockNumberFor::<T>::from(42u32);

#[extrinsic_call]
_(RawOrigin::Root, next_authorities, in_blocks, None);
}

#[benchmark]
fn sudo_set_default_take() {
#[extrinsic_call]
Expand Down Expand Up @@ -249,17 +264,6 @@ mod benchmarks {
_(RawOrigin::Root, 1u16/*netuid*/, true/*enabled*/)/*set_commit_reveal_weights_enabled*/;
}

#[benchmark]
fn sudo_set_hotkey_emission_tempo() {
pallet_subtensor::Pallet::<T>::init_new_network(
1u16, /*netuid*/
1u16, /*sudo_tempo*/
);

#[extrinsic_call]
_(RawOrigin::Root, 1u64/*emission_tempo*/)/*set_hotkey_emission_tempo*/;
}

#[benchmark]
fn sudo_set_network_max_stake() {
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
Expand Down
Loading

0 comments on commit 2016b12

Please sign in to comment.