Skip to content

Node Decentralization #1708

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

Draft
wants to merge 38 commits into
base: devnet-ready
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
12ab72b
merge devnet-ready
liamaharon Jun 2, 2025
755161d
remove redundant stuff
liamaharon Jun 2, 2025
2f8e514
implement EraPayout
liamaharon Jun 4, 2025
e17c60e
Merge branch 'devnet-ready' into node-decentralization
liamaharon Jun 4, 2025
2de795d
update cargo.lock
liamaharon Jun 4, 2025
292dca9
Merge branch 'devnet-ready' into node-decentralization
liamaharon Jun 4, 2025
9dfe601
remove unneeded reward curve stuff
liamaharon Jun 7, 2025
d670b53
cleanup
liamaharon Jun 7, 2025
5aaa7d2
producing blocks.
liamaharon Jun 9, 2025
ba2849a
simplify account structures
liamaharon Jun 9, 2025
2f2ed87
remove comment
liamaharon Jun 10, 2025
d9dfa2e
add bob
liamaharon Jun 10, 2025
b312983
remove unnecesarry authority discovery pallet
liamaharon Jun 10, 2025
4966614
faster fast runtime
liamaharon Jun 10, 2025
a44dbec
charlie localnet
liamaharon Jun 10, 2025
0828551
charlie
liamaharon Jun 10, 2025
0ec03b8
Merge branch 'devnet-ready' into node-decentralization
liamaharon Jun 10, 2025
f50b60b
fix benchmark file
liamaharon Jun 10, 2025
16aa027
merge devnet-ready
liamaharon Jun 11, 2025
9ac73bb
fix test compile
liamaharon Jun 11, 2025
eae653b
fix used_addresses
liamaharon Jun 11, 2025
16799d6
Merge branch 'devnet-ready' into node-decentralization
liamaharon Jun 12, 2025
d607d46
Merge branch 'devnet-ready' into node-decentralization
liamaharon Jun 13, 2025
6fe20e7
wip aura->babe runtime upgrade
liamaharon Jun 15, 2025
7f3c948
shuffle around
liamaharon Jun 15, 2025
9ba5dab
fix migration
liamaharon Jun 16, 2025
f404fad
current slot
liamaharon Jun 16, 2025
b85ea81
allow aura node to execute babe runtime upgrade
liamaharon Jun 16, 2025
d5387b9
comment
liamaharon Jun 16, 2025
8d6bcb7
wip
liamaharon Jun 17, 2025
63e6617
wip session pallet migration
liamaharon Jun 18, 2025
b10a6b3
merge
liamaharon Jun 20, 2025
6e97e3f
merge
liamaharon Jun 20, 2025
9b4eb66
fix polkadot-sdk double deps
liamaharon Jun 20, 2025
0f6ab37
wip merge
liamaharon Jun 20, 2025
1733720
wip
liamaharon Jun 20, 2025
9c2e154
fix runtime compile
liamaharon Jun 20, 2025
84a32ed
frontier and subtensor using p-sdk fork
liamaharon Jun 20, 2025
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,376 changes: 1,088 additions & 288 deletions Cargo.lock

Large diffs are not rendered by default.

248 changes: 142 additions & 106 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ frame-support = { workspace = true }
scale-info = { workspace = true }
serde = { workspace = true }
sp-core = { workspace = true }
runtime-common = { workspace = true }
sp-runtime = { workspace = true }
subtensor-macros = { workspace = true }

Expand All @@ -24,12 +25,13 @@ workspace = true

[features]
default = ["std"]
fast-blocks = []
fast-runtime = []
std = [
"codec/std",
"frame-support/std",
"scale-info/std",
"serde/std",
"sp-core/std",
"sp-runtime/std",
"runtime-common/std"
]
8 changes: 2 additions & 6 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use core::fmt::{self, Display, Formatter};

use codec::{Compact, CompactAs, Decode, Encode, Error as CodecError, MaxEncodedLen};
use frame_support::pallet_prelude::*;
use runtime_common::prod_or_fast;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_runtime::{
Expand Down Expand Up @@ -188,12 +189,7 @@ pub mod time {
/// slot_duration()`.
///
/// Change this to adjust the block time.
#[cfg(not(feature = "fast-blocks"))]
pub const MILLISECS_PER_BLOCK: u64 = 12000;

/// Fast blocks for development
#[cfg(feature = "fast-blocks")]
pub const MILLISECS_PER_BLOCK: u64 = 250;
pub const MILLISECS_PER_BLOCK: u64 = prod_or_fast!(12000, 250);

// NOTE: Currently it is not possible to change the slot duration after the chain has started.
// Attempting to do so will brick block production.
Expand Down
4 changes: 2 additions & 2 deletions evm-tests/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const ETH_LOCAL_URL = 'http://localhost:9944'
export const SUB_LOCAL_URL = 'ws://localhost:9944'
export const SS58_PREFIX = 42;
// set the tx timeout as 2 second when eable the fast-blocks feature.
// set the tx timeout as 2 second when eable the fast-runtime feature.
export const TX_TIMEOUT = 3000;

export const IED25519VERIFY_ADDRESS = "0x0000000000000000000000000000000000000402";
Expand Down Expand Up @@ -55,4 +55,4 @@ export const IBalanceTransferABI = [

export const IDISPATCH_ADDRESS = "0x0000000000000000000000000000000000000006";

export const ISTORAGE_QUERY_ADDRESS = "0x0000000000000000000000000000000000000807";
export const ISTORAGE_QUERY_ADDRESS = "0x0000000000000000000000000000000000000807";
21 changes: 17 additions & 4 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,24 @@ sc-transaction-pool = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sc-offchain = { workspace = true }
sc-network = { workspace = true }
sc-consensus-aura = { workspace = true }
sp-consensus-aura = { workspace = true }
sc-consensus-babe = { workspace = true }
babe-primitives = { workspace = true }
sp-consensus = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-consensus-grandpa-rpc = { workspace = true }
sp-consensus-grandpa = { workspace = true }
sp-authority-discovery = { workspace = true }
sc-chain-spec-derive = { workspace = true }
sc-chain-spec = { workspace = true }
sc-consensus-slots = { workspace = true }
sc-consensus-babe-rpc = { workspace = true, default-features = true }
sc-client-api = { workspace = true }
sp-runtime = { workspace = true }
sp-io = { workspace = true }
sp-timestamp = { workspace = true }
sp-transaction-storage-proof = { workspace = true }
sp-staking = { workspace = true }
sp-transaction-pool = { workspace = true, features = ["default"] }
sp-inherents = { workspace = true }
sp-keyring = { workspace = true }
Expand All @@ -64,6 +68,8 @@ frame-metadata-hash-extension = { workspace = true }
frame-system = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-commitments = { path = "../pallets/commitments" }
pallet-staking = { workspace = true }
polkadot-rpc = { workspace = true }
pallet-drand = { workspace = true }
sp-crypto-ec-utils = { workspace = true }
sp-keystore = { workspace = true, default-features = false }
Expand Down Expand Up @@ -100,7 +106,7 @@ fc-api = { workspace = true }
fc-rpc = { workspace = true }
fc-rpc-core = { workspace = true }
fp-rpc = { workspace = true }
fc-aura = { workspace = true }
fc-babe = { workspace = true }
fc-mapping-sync = { workspace = true }
fp-consensus = { workspace = true }
thiserror = { workspace = true }
Expand All @@ -119,13 +125,17 @@ substrate-build-script-utils = { workspace = true }

[features]
default = ["rocksdb", "sql", "txpool"]
fast-blocks = ["node-subtensor-runtime/fast-blocks"]
fast-runtime = [
"node-subtensor-runtime/fast-runtime",
"subtensor-runtime-common/fast-runtime"
]
sql = ["fc-db/sql", "fc-mapping-sync/sql"]
rocksdb = [
"sc-service/rocksdb",
"fc-db/rocksdb",
"fc-mapping-sync/rocksdb",
"fc-rpc/rocksdb",
"sc-cli/rocksdb"
]
txpool = ["fc-rpc/txpool", "fc-rpc-core/txpool"]

Expand All @@ -137,8 +147,10 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
"pallet-commitments/runtime-benchmarks",
"pallet-drand/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
]
pow-faucet = []
Expand All @@ -152,6 +164,7 @@ try-runtime = [
"sp-runtime/try-runtime",
"pallet-commitments/try-runtime",
"pallet-drand/try-runtime",
"pallet-staking/try-runtime",
]

metadata-hash = ["node-subtensor-runtime/metadata-hash"]
46 changes: 16 additions & 30 deletions node/src/chain_spec/devnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,10 @@ pub fn devnet_config() -> Result<ChainSpec, String> {
.with_id("bittensor")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(devnet_genesis(
// Initial PoA authorities (Validators)
// aura | grandpa
vec![
// Keys for debug
authority_keys_from_ss58(
"5D5ABUyMsdmJdH7xrsz9vREq5eGXr5pXhHxix2dENQR62dEo",
"5H3qMjQjoeZxZ98jzDmoCwbz2sugd5fDN1wrr8Phf49zemKL",
),
authority_keys_from_ss58(
"5GbRc5sNDdhcPAU9suV2g9P5zyK1hjAQ9JHeeadY1mb8kXoM",
"5GbkysfaCjK3cprKPhi3CUwaB5xWpBwcfrkzs6FmqHxej8HZ",
),
authority_keys_from_ss58(
"5CoVWwBwXz2ndEChGcS46VfSTb3RMUZzZzAYdBKo263zDhEz",
"5HTLp4BvPp99iXtd8YTBZA1sMfzo8pd4mZzBJf7HYdCn2boU",
),
authority_keys_from_ss58(
"5EekcbqupwbgWqF8hWGY4Pczsxp9sbarjDehqk7bdyLhDCwC",
"5GAemcU4Pzyfe8DwLwDFx3aWzyg3FuqYUCCw2h4sdDZhyFvE",
),
authority_keys_from_ss58(
"5GgdEQyS5DZzUwKuyucEPEZLxFKGmasUFm1mqM3sx1MRC5RV",
"5EibpMomXmgekxcfs25SzFBpGWUsG9Lc8ALNjXN3TYH5Tube",
),
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
get_authority_keys_from_seed("Charlie"),
],
// Sudo account
Ss58Codec::from_ss58check("5GpzQgpiAKHMWNSH3RN4GLf96GVTDct9QxYEFAY7LWcVzTbx").unwrap(),
Expand All @@ -65,7 +45,7 @@ pub fn devnet_config() -> Result<ChainSpec, String> {
// Configure initial storage state for FRAME modules.
#[allow(clippy::too_many_arguments)]
fn devnet_genesis(
initial_authorities: Vec<(AuraId, GrandpaId)>,
initial_authorities: Vec<AuthorityKeys>,
root_key: AccountId,
_endowed_accounts: Vec<AccountId>,
_enable_println: bool,
Expand All @@ -77,13 +57,19 @@ fn devnet_genesis(
"balances": {
"balances": vec![(root_key.clone(), 1_000_000_000_000u128)],
},
"aura": {
"authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::<Vec<_>>(),
},
"grandpa": {
"authorities": initial_authorities
"session": {
"keys": initial_authorities
.iter()
.map(|x| (x.1.clone(), 1))
.map(|x| {
(
x.account(),
x.account(),
node_subtensor_runtime::opaque::SessionKeys {
babe: x.babe().clone(),
grandpa: x.grandpa().clone(),
},
)
})
.collect::<Vec<_>>(),
},
"sudo": {
Expand Down
106 changes: 19 additions & 87 deletions node/src/chain_spec/finney.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,90 +87,13 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
.unwrap(),
])
.with_genesis_config_patch(finney_genesis(
// Initial PoA authorities (Validators)
// aura | grandpa
// Initial validators
// Obviously, these are just dummy values. Should be replaced with actual authority keys
// when running in prod.
vec![
// Keys for debug
authority_keys_from_ss58(
"5EJUcFbe74FDQwPsZDbRVpdDxVZQQxjoGZA9ayJqJTbcRrGf",
"5GRcfchgXZjkCfqgNvfjicjJw3vVGF4Ahqon2w8RfjXwyzy4",
), // key 1
authority_keys_from_ss58(
"5H5oVSbQxDSw1TohAvLvp9CTAua6PN4yHme19UrG4c1ojS8J",
"5FAEYaHLZmLRX4XFs2SBHbLhkysbSPrcTp51w6sQNaYLa7Tu",
), // key 2
authority_keys_from_ss58(
"5CfBazEwCAsmscGj1J9rhXess9ZXZ5qYcuZvFWii9sxT977v",
"5F6LgDAenzchE5tPmFHKGueYy1rj85oB2yxvm1xyKLVvk4gy",
), // key 3
authority_keys_from_ss58(
"5HZDvVFWH3ifx1Sx8Uaaa7oiT6U4fAKrR3LKy9r1zFnptc1z",
"5GJY6A1X8KNvqHcf42Cpr5HZzG95FZVJkTHJvnHSBGgshEWn",
), // key 4
authority_keys_from_ss58(
"5H3v2VfQmsAAgj63EDaB1ZWmruTHHkJ4kci5wkt6SwMi2VW1",
"5FXVk1gEsNweTB6AvS5jAWCivXQHTcyCWXs21wHvRU5UTZtb",
), // key 5
authority_keys_from_ss58(
"5CPhKdvHmMqRmMUrpFnvLc6GUcduVwpNHsPPEhnYQ7QXjPdz",
"5GAzG6PhVvpeoZVkKupa2uZDrhwsUmk5fCHgwq95cN9s3Dvi",
), // key 6
authority_keys_from_ss58(
"5DZTjVhqVjHyhXLhommE4jqY9w1hJEKNQWJ8p6QnUWghRYS1",
"5HmGN73kkcHaKNJrSPAxwiwAiiCkztDZ1AYi4gkpv6jaWaxi",
), // key 7
authority_keys_from_ss58(
"5ETyBUhi3uVCzsk4gyTmtf41nheH7wALqQQxbUkmRPNqEMGS",
"5Cq63ca5KM5qScJYmQi7PvFPhJ6Cxr6yw6Xg9dLYoRYg33rN",
), // key 8
authority_keys_from_ss58(
"5DUSt6KiZWxA3tsiFkv3xYSNuox6PCfhyvqqM9x7N5kuHV2S",
"5FF1kun4rb5B7C3tqh23XPVDDUJ3UchnaXxJeXu1i5n8KNHp",
), // key 9
authority_keys_from_ss58(
"5GgsDz9yixsdHxFu52SN37f6TrUtU2RwmGJejbHVmN1ERXL4",
"5EZiep2gMyV2cz9x54TQDb1cuyFYYcwGRGZ7J19Ua4YSAWCZ",
), // key 10
authority_keys_from_ss58(
"5HjhkCMa89QJbFULs8WPZBgVg8kMq5qdX1nx7CnQpZgoyKAN",
"5D5DL9sru2ep3AWoHvmEUbFLirVr7tJ6BxBWH5M8j3r9kUpe",
), // key 11
authority_keys_from_ss58(
"5F257gHitacwDGvYm2Xm7dBE882auTU8wraG6w4T3r63wh9V",
"5CovRCaioWENKejfaeccDQY4vCF8kTGtZ5fwagSCeDGmiSyh",
), // key 12
authority_keys_from_ss58(
"5CtGLbiHWs6XVgNi9nW7oqSP4D4JMot7yHYuFokidZzAP6ny",
"5DSxsR9aAiq33uSYXWt4zEibx6KT6xxtFGkT9S4GLaCavgDE",
), // key 13
authority_keys_from_ss58(
"5DeVtxyiniPzoHo4iQiLhGfhED6RP3V73B5nGSYWr5Mgt82c",
"5HaWL2AvLZHwyPXofWFTEZ6jHVmUG8U9cFATggKZonN1xZjm",
), // key 14
authority_keys_from_ss58(
"5GF4a6pQ8TQuPhdkKqugzrZSW7YnpQtB4ihouKGZsVMwoTn6",
"5DaEhFN8bWjvhDxavSWFBr962qoTAMB4b51QebdRZ75VA4h2",
), // key 15
authority_keys_from_ss58(
"5DAC8Did2NgeVfZeNmEfZuU6t7UseJNf9J68XTvhLf5yCsBZ",
"5G27pyXx9ieSRCTuDoqPgTvpCynH6yhum9HiQQ1iMj3rAeaP",
), // key 16
authority_keys_from_ss58(
"5FmxaYznqMqiorPHQgKoRQgEHN7ud4yKsJWr6FvXuS6FS6be",
"5Ch5XFMKETDiiPiuhUj9TumUtgsnVG1VzQRvBykP9bRdt4km",
), // key 17
authority_keys_from_ss58(
"5GNAkfKYmFbVRAYm1tPr1yG6bHCapaY7WKRmzkEdendDXj1j",
"5EC6JjwnE11qaRnjKM85eevQFV1EoaKPPtcBRmTp1XsR7Kx3",
), // key 18
authority_keys_from_ss58(
"5GYk3B38R9F2TEcWoqCLojqPwx6AA1TsD3EovoTgggyRdzki",
"5FjdhdAxujZVev6HYqQcTB6UBAKfKFKPoftgMLenoxbNWoe2",
), // key 19
authority_keys_from_ss58(
"5D7fthS7zBDhwi2u2JYd74t7FpQuseDkUkTuaLZoenXNpXPK",
"5DhAKQ4MFg39mQAYzndzbznLGqSV4VMUJUyRXe8QPDqD5G1D",
), // key 20
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
get_authority_keys_from_seed("Charlie"),
],
// Sudo account
Ss58Codec::from_ss58check("5FCM3DBXWiGcwYYQtT8z4ZD93TqYpYxjaAfgv6aMStV1FTCT").unwrap(),
Expand Down Expand Up @@ -206,7 +129,7 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
// Configure initial storage state for FRAME modules.
#[allow(clippy::too_many_arguments)]
fn finney_genesis(
initial_authorities: Vec<(AuraId, GrandpaId)>,
initial_authorities: Vec<AuthorityKeys>,
_root_key: AccountId,
_endowed_accounts: Vec<AccountId>,
_enable_println: bool,
Expand All @@ -216,10 +139,19 @@ fn finney_genesis(
) -> serde_json::Value {
serde_json::json!({
"balances": { "balances": balances.to_vec() },
"aura": { "authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::<Vec<_>>() },
"grandpa": { "authorities": initial_authorities
"session": {
"keys": initial_authorities
.iter()
.map(|x| (x.1.clone(), 1))
.map(|x| {
(
x.account(),
x.account(),
node_subtensor_runtime::opaque::SessionKeys {
babe: x.babe().clone(),
grandpa: x.grandpa().clone(),
},
)
})
.collect::<Vec<_>>(),
},
"sudo": { "key": Some(<AccountId32 as Ss58Codec>::from_ss58check("5FCM3DBXWiGcwYYQtT8z4ZD93TqYpYxjaAfgv6aMStV1FTCT").unwrap()) },
Expand Down
Loading
Loading