Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
348626f
hybrid node
liamaharon Jul 22, 2025
1a20aab
comment
liamaharon Jul 22, 2025
c1e1fbe
fix runtime-benchmark compile
liamaharon Jul 22, 2025
371761d
update ConditionalEVMBlockImport
liamaharon Jul 22, 2025
35f7ff2
clippy
liamaharon Jul 22, 2025
4789a88
fix runtime-benchmark compile again
liamaharon Jul 22, 2025
db92646
prefer matches!
liamaharon Jul 25, 2025
4b3beab
cleanup unused file
liamaharon Jul 25, 2025
aec6b29
prefer matches!
liamaharon Jul 26, 2025
5fd36bb
prefer matches!
liamaharon Jul 26, 2025
adb9648
patch vulnerability in meantime while wait for psdk fork
liamaharon Jul 26, 2025
1359f3e
Merge branch 'devnet-ready' into hybrid-node
liamaharon Jul 28, 2025
f055227
add todo to remove initial_consensus flag.
liamaharon Jul 31, 2025
5a63327
better fn names
liamaharon Jul 31, 2025
21e492f
Merge branch 'devnet-ready' into hybrid-node
liamaharon Jul 31, 2025
f8b783e
Return default values in BabeApi instead of panic prior to Babe upgrade
liamaharon Aug 4, 2025
d900522
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 4, 2025
e886766
Bump spec version
liamaharon Aug 4, 2025
969a23e
merge devnet-ready
liamaharon Aug 5, 2025
bda2df5
merge
liamaharon Aug 5, 2025
f88f162
cleanup
liamaharon Aug 5, 2025
7a00604
run zepter
liamaharon Aug 5, 2025
43dea13
cargo +nightly fmt
liamaharon Aug 6, 2025
8febe38
Merge pull request #1876 from opentensor/hybrid-node
liamaharon Aug 7, 2025
89d7fd0
Merge remote-tracking branch 'origin/devnet-ready' into add-back-liam…
sam0x17 Aug 12, 2025
7ecae95
commit Cargo.lock
sam0x17 Aug 12, 2025
882292d
bump CI
sam0x17 Aug 12, 2025
10ffe75
auto-update benchmark weights
github-actions[bot] Aug 12, 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
470 changes: 399 additions & 71 deletions Cargo.lock

Large diffs are not rendered by default.

78 changes: 51 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ expander = "2"
ahash = { version = "0.8", default-features = false }
regex = { version = "1.11.1", default-features = false }


frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
Expand All @@ -127,6 +126,7 @@ frame-metadata = { version = "20.0.0", default-features = false }

pallet-proxy = { path = "pallets/proxy", default-features = false }
pallet-utility = { path = "pallets/utility", default-features = false }
pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
Expand All @@ -143,11 +143,29 @@ pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-root-testing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }

# NPoS
frame-election-provider-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-bags-list = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-fast-unstake = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-nomination-pools = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-staking-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-staking-reward-fn = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }

sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sc-chain-spec-derive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
Expand All @@ -167,11 +185,16 @@ sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.g
sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }

sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-npos-elections = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
Expand Down Expand Up @@ -200,34 +223,35 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-
cumulus-primitives-proof-size-hostfunction = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }

# Frontier
fp-evm = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fp-account = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-storage = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-db = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-api = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-aura = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
fp-evm = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fp-account = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-storage = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-db = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-api = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-aura = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-babe = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }

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

#DRAND
pallet-drand = { path = "pallets/drand", default-features = false }
Expand Down
23 changes: 16 additions & 7 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"]
name = "node-subtensor"

[dependencies]
log.workspace = true
async-trait.workspace = true
clap = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["thread-pool"] }
Expand All @@ -30,7 +31,11 @@ hex.workspace = true
memmap2.workspace = true
serde_json.workspace = true

sc-chain-spec-derive.workspace = true
sc-cli.workspace = true
sc-consensus-babe.workspace = true
sp-consensus.workspace = true
sp-consensus-slots.workspace = true
sp-core.workspace = true
sc-executor.workspace = true
sc-service.workspace = true
Expand All @@ -42,12 +47,12 @@ sc-offchain.workspace = true
sc-network.workspace = true
sc-consensus-aura.workspace = true
sp-consensus-aura.workspace = true
sp-consensus.workspace = true
sp-consensus-babe.workspace = true
sc-consensus-babe-rpc.workspace = true
sc-consensus.workspace = true
sc-consensus-grandpa.workspace = true
sc-consensus-grandpa-rpc.workspace = true
sp-consensus-grandpa.workspace = true
sc-chain-spec-derive.workspace = true
sc-chain-spec.workspace = true
sc-consensus-slots.workspace = true
sc-client-api.workspace = true
Expand Down Expand Up @@ -89,20 +94,21 @@ frame-benchmarking.workspace = true
frame-benchmarking-cli.workspace = true

# Needed for Frontier
fc-mapping-sync.workspace = true
fc-storage.workspace = true
fc-babe.workspace = true
sc-consensus-manual-seal.workspace = true
sc-network-sync.workspace = true
substrate-prometheus-endpoint.workspace = true

# Frontier
fc-storage.workspace = true
fc-db.workspace = true
fc-consensus.workspace = true
fc-api.workspace = true
fc-rpc = { workspace = true, features = ["rpc-binary-search-estimate"] }
fc-rpc-core.workspace = true
fp-rpc.workspace = true
fc-aura.workspace = true
fc-mapping-sync.workspace = true
fp-consensus.workspace = true
num-traits = { workspace = true, features = ["std"] }

Expand All @@ -118,9 +124,6 @@ pallet-subtensor-swap-runtime-api = { workspace = true, features = ["std"] }
substrate-build-script-utils.workspace = true

[features]
default = ["rocksdb", "sql", "txpool"]
fast-blocks = ["node-subtensor-runtime/fast-blocks"]
sql = ["fc-db/sql", "fc-mapping-sync/sql"]
rocksdb = [
"sc-service/rocksdb",
"fc-db/rocksdb",
Expand All @@ -129,6 +132,12 @@ rocksdb = [
"frame-benchmarking-cli/rocksdb",
"sc-cli/rocksdb",
]
default = ["rocksdb", "sql", "txpool"]
fast-blocks = [
"node-subtensor-runtime/fast-blocks",
"subtensor-runtime-common/fast-blocks"
]
sql = ["fc-db/sql", "fc-mapping-sync/sql"]
txpool = ["fc-rpc/txpool", "fc-rpc-core/txpool"]

# Dependencies that are only required if runtime benchmarking should be build.
Expand Down
54 changes: 53 additions & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
use crate::ethereum::EthConfiguration;
use crate::{
client::{FullBackend, FullClient},
consensus::{AuraConsensus, BabeConsensus},
ethereum::{EthConfiguration, FrontierBackend},
service::new_chain_ops,
};
use node_subtensor_runtime::opaque::Block;
use sc_cli::RunCmd;
use sc_consensus::BasicQueue;
use sc_service::{Configuration, TaskManager};
use std::sync::Arc;

#[derive(Debug, clap::Parser)]
pub struct Cli {
Expand All @@ -13,6 +22,15 @@ pub struct Cli {
#[arg(long, value_enum, ignore_case = true)]
pub sealing: Option<Sealing>,

/// Whether to try Aura or Babe consensus on first start.
///
/// After starting, the consensus used by the node will automatically
/// switch to whatever is required to continue validating / syncing.
///
/// TODO: Remove this after the Babe transition has settled.
#[arg(long, value_enum, ignore_case = true, default_value_t=SupportedConsensusMechanism::default())]
pub initial_consensus: SupportedConsensusMechanism,

#[command(flatten)]
pub eth: EthConfiguration,
}
Expand Down Expand Up @@ -63,3 +81,37 @@ pub enum Sealing {
/// Seal when transaction is executed.
Instant,
}

/// Supported consensus mechanisms.
#[derive(Copy, Clone, Debug, Default, clap::ValueEnum)]
pub enum SupportedConsensusMechanism {
// Babe
Babe,
/// Aura
#[default]
Aura,
}

// Convinience methods for static dispatch of different service methods with
// different consensus mechanisms.
impl SupportedConsensusMechanism {
pub fn new_chain_ops(
&self,
config: &mut Configuration,
eth_config: &EthConfiguration,
) -> Result<
(
Arc<FullClient>,
Arc<FullBackend>,
BasicQueue<Block>,
TaskManager,
FrontierBackend,
),
sc_service::Error,
> {
match self {
SupportedConsensusMechanism::Aura => new_chain_ops::<AuraConsensus>(config, eth_config),
SupportedConsensusMechanism::Babe => new_chain_ops::<BabeConsensus>(config, eth_config),
}
}
}
Loading