Skip to content

Commit 635cdcf

Browse files
authored
Merge pull request #1941 from opentensor/add-back-liam-stuff
Add back liam consensus stuff
2 parents dfb1448 + 10ffe75 commit 635cdcf

File tree

22 files changed

+1708
-383
lines changed

22 files changed

+1708
-383
lines changed

Cargo.lock

Lines changed: 399 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ expander = "2"
113113
ahash = { version = "0.8", default-features = false }
114114
regex = { version = "1.11.1", default-features = false }
115115

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

128127
pallet-proxy = { path = "pallets/proxy", default-features = false }
129128
pallet-utility = { path = "pallets/utility", default-features = false }
129+
pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
130130
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
131131
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
132132
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
@@ -143,11 +143,29 @@ pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot
143143
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
144144
pallet-root-testing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
145145

146+
# NPoS
147+
frame-election-provider-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
148+
pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
149+
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
150+
pallet-bags-list = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
151+
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
152+
pallet-fast-unstake = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
153+
pallet-nomination-pools = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
154+
pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
155+
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
156+
pallet-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
157+
pallet-staking-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
158+
pallet-staking-reward-fn = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
159+
pallet-staking-reward-curve = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
160+
pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
161+
146162
sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
147163
sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
148164
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
149165
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
150166
sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
167+
sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
168+
sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
151169
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
152170
sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
153171
sc-chain-spec-derive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
@@ -167,11 +185,16 @@ sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.g
167185
sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
168186

169187
sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
188+
sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
170189
sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
171190
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
172191
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
192+
sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
173193
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
174194
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
195+
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
196+
sp-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
197+
sp-npos-elections = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
175198
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
176199
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
177200
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
@@ -200,34 +223,35 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-
200223
cumulus-primitives-proof-size-hostfunction = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false }
201224

202225
# Frontier
203-
fp-evm = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
204-
fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
205-
fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
206-
fp-account = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
207-
fc-storage = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
208-
fc-db = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
209-
fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
210-
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
211-
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
212-
fc-api = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
213-
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
214-
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
215-
fc-aura = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
216-
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
217-
precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
226+
fp-evm = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
227+
fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
228+
fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
229+
fp-account = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
230+
fc-storage = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
231+
fc-db = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
232+
fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
233+
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
234+
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
235+
fc-api = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
236+
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
237+
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
238+
fc-aura = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
239+
fc-babe = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
240+
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
241+
precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
218242

219243
# Frontier FRAME
220-
pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
221-
pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
222-
pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
223-
pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
224-
pallet-evm-precompile-dispatch = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
225-
pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
226-
pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
227-
pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
228-
pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
229-
pallet-evm-precompile-bn128 = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
230-
pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false }
244+
pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
245+
pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
246+
pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
247+
pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
248+
pallet-evm-precompile-dispatch = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
249+
pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
250+
pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
251+
pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
252+
pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
253+
pallet-evm-precompile-bn128 = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
254+
pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false }
231255

232256
#DRAND
233257
pallet-drand = { path = "pallets/drand", default-features = false }

node/Cargo.toml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"]
2020
name = "node-subtensor"
2121

2222
[dependencies]
23+
log.workspace = true
2324
async-trait.workspace = true
2425
clap = { workspace = true, features = ["derive"] }
2526
futures = { workspace = true, features = ["thread-pool"] }
@@ -30,7 +31,11 @@ hex.workspace = true
3031
memmap2.workspace = true
3132
serde_json.workspace = true
3233

34+
sc-chain-spec-derive.workspace = true
3335
sc-cli.workspace = true
36+
sc-consensus-babe.workspace = true
37+
sp-consensus.workspace = true
38+
sp-consensus-slots.workspace = true
3439
sp-core.workspace = true
3540
sc-executor.workspace = true
3641
sc-service.workspace = true
@@ -42,12 +47,12 @@ sc-offchain.workspace = true
4247
sc-network.workspace = true
4348
sc-consensus-aura.workspace = true
4449
sp-consensus-aura.workspace = true
45-
sp-consensus.workspace = true
50+
sp-consensus-babe.workspace = true
51+
sc-consensus-babe-rpc.workspace = true
4652
sc-consensus.workspace = true
4753
sc-consensus-grandpa.workspace = true
4854
sc-consensus-grandpa-rpc.workspace = true
4955
sp-consensus-grandpa.workspace = true
50-
sc-chain-spec-derive.workspace = true
5156
sc-chain-spec.workspace = true
5257
sc-consensus-slots.workspace = true
5358
sc-client-api.workspace = true
@@ -89,20 +94,21 @@ frame-benchmarking.workspace = true
8994
frame-benchmarking-cli.workspace = true
9095

9196
# Needed for Frontier
97+
fc-mapping-sync.workspace = true
98+
fc-storage.workspace = true
99+
fc-babe.workspace = true
92100
sc-consensus-manual-seal.workspace = true
93101
sc-network-sync.workspace = true
94102
substrate-prometheus-endpoint.workspace = true
95103

96104
# Frontier
97-
fc-storage.workspace = true
98105
fc-db.workspace = true
99106
fc-consensus.workspace = true
100107
fc-api.workspace = true
101108
fc-rpc = { workspace = true, features = ["rpc-binary-search-estimate"] }
102109
fc-rpc-core.workspace = true
103110
fp-rpc.workspace = true
104111
fc-aura.workspace = true
105-
fc-mapping-sync.workspace = true
106112
fp-consensus.workspace = true
107113
num-traits = { workspace = true, features = ["std"] }
108114

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

120126
[features]
121-
default = ["rocksdb", "sql", "txpool"]
122-
fast-blocks = ["node-subtensor-runtime/fast-blocks"]
123-
sql = ["fc-db/sql", "fc-mapping-sync/sql"]
124127
rocksdb = [
125128
"sc-service/rocksdb",
126129
"fc-db/rocksdb",
@@ -129,6 +132,12 @@ rocksdb = [
129132
"frame-benchmarking-cli/rocksdb",
130133
"sc-cli/rocksdb",
131134
]
135+
default = ["rocksdb", "sql", "txpool"]
136+
fast-blocks = [
137+
"node-subtensor-runtime/fast-blocks",
138+
"subtensor-runtime-common/fast-blocks"
139+
]
140+
sql = ["fc-db/sql", "fc-mapping-sync/sql"]
132141
txpool = ["fc-rpc/txpool", "fc-rpc-core/txpool"]
133142

134143
# Dependencies that are only required if runtime benchmarking should be build.

node/src/cli.rs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
use crate::ethereum::EthConfiguration;
1+
use crate::{
2+
client::{FullBackend, FullClient},
3+
consensus::{AuraConsensus, BabeConsensus},
4+
ethereum::{EthConfiguration, FrontierBackend},
5+
service::new_chain_ops,
6+
};
7+
use node_subtensor_runtime::opaque::Block;
28
use sc_cli::RunCmd;
9+
use sc_consensus::BasicQueue;
10+
use sc_service::{Configuration, TaskManager};
11+
use std::sync::Arc;
312

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

25+
/// Whether to try Aura or Babe consensus on first start.
26+
///
27+
/// After starting, the consensus used by the node will automatically
28+
/// switch to whatever is required to continue validating / syncing.
29+
///
30+
/// TODO: Remove this after the Babe transition has settled.
31+
#[arg(long, value_enum, ignore_case = true, default_value_t=SupportedConsensusMechanism::default())]
32+
pub initial_consensus: SupportedConsensusMechanism,
33+
1634
#[command(flatten)]
1735
pub eth: EthConfiguration,
1836
}
@@ -63,3 +81,37 @@ pub enum Sealing {
6381
/// Seal when transaction is executed.
6482
Instant,
6583
}
84+
85+
/// Supported consensus mechanisms.
86+
#[derive(Copy, Clone, Debug, Default, clap::ValueEnum)]
87+
pub enum SupportedConsensusMechanism {
88+
// Babe
89+
Babe,
90+
/// Aura
91+
#[default]
92+
Aura,
93+
}
94+
95+
// Convinience methods for static dispatch of different service methods with
96+
// different consensus mechanisms.
97+
impl SupportedConsensusMechanism {
98+
pub fn new_chain_ops(
99+
&self,
100+
config: &mut Configuration,
101+
eth_config: &EthConfiguration,
102+
) -> Result<
103+
(
104+
Arc<FullClient>,
105+
Arc<FullBackend>,
106+
BasicQueue<Block>,
107+
TaskManager,
108+
FrontierBackend,
109+
),
110+
sc_service::Error,
111+
> {
112+
match self {
113+
SupportedConsensusMechanism::Aura => new_chain_ops::<AuraConsensus>(config, eth_config),
114+
SupportedConsensusMechanism::Babe => new_chain_ops::<BabeConsensus>(config, eth_config),
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)