Skip to content

Commit 3fb89ec

Browse files
authored
Merge pull request #772 from opentensor/feat/evm-devnet-ready
Feat/evm devnet ready
2 parents 2ad1381 + d8eadf3 commit 3fb89ec

26 files changed

+3944
-1142
lines changed

Cargo.lock

+1,294-709
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+110-75
Large diffs are not rendered by default.

node/Cargo.toml

+43-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ targets = ["x86_64-unknown-linux-gnu"]
2020
name = "node-subtensor"
2121

2222
[dependencies]
23+
async-trait = { workspace = true }
2324
clap = { workspace = true, features = ["derive"] }
2425
futures = { workspace = true, features = ["thread-pool"] }
26+
scale-codec = { workspace = true }
2527
serde = { workspace = true, features = ["derive"] }
2628

2729
# Storage import
@@ -52,8 +54,11 @@ sc-client-api = { workspace = true }
5254
sp-runtime = { workspace = true }
5355
sp-io = { workspace = true }
5456
sp-timestamp = { workspace = true }
57+
sp-transaction-pool = { workspace = true, features = ["default"] }
5558
sp-inherents = { workspace = true }
5659
sp-keyring = { workspace = true }
60+
sp-offchain = { workspace = true }
61+
sp-session = { workspace = true }
5762
frame-metadata-hash-extension = { workspace = true }
5863
frame-system = { workspace = true }
5964
pallet-transaction-payment = { workspace = true }
@@ -69,11 +74,29 @@ sp-block-builder = { workspace = true }
6974
sc-basic-authorship = { workspace = true }
7075
substrate-frame-rpc-system = { workspace = true }
7176
pallet-transaction-payment-rpc = { workspace = true }
77+
frame-system-rpc-runtime-api = { workspace = true }
78+
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
7279

7380
# These dependencies are used for runtime benchmarking
7481
frame-benchmarking = { workspace = true }
7582
frame-benchmarking-cli = { workspace = true }
7683

84+
# Needed for Frontier
85+
sc-consensus-manual-seal = { workspace = true }
86+
sc-network-sync = { workspace = true }
87+
substrate-prometheus-endpoint = { workspace = true }
88+
89+
# Frontier
90+
fc-storage = { workspace = true }
91+
fc-db = { workspace = true }
92+
fc-consensus = { workspace = true }
93+
fp-dynamic-fee = { workspace = true }
94+
fc-api = { workspace = true }
95+
fc-rpc = { workspace = true }
96+
fc-rpc-core = { workspace = true }
97+
fp-rpc = { workspace = true }
98+
fc-mapping-sync = { workspace = true }
99+
77100
# Local Dependencies
78101
node-subtensor-runtime = { path = "../runtime" }
79102
subtensor-custom-rpc = { path = "../pallets/subtensor/rpc" }
@@ -83,7 +106,26 @@ subtensor-custom-rpc-runtime-api = { path = "../pallets/subtensor/runtime-api" }
83106
substrate-build-script-utils = { workspace = true }
84107

85108
[features]
86-
default = []
109+
default = [
110+
"rocksdb",
111+
"sql",
112+
"txpool",
113+
]
114+
sql = [
115+
"fc-db/sql",
116+
"fc-mapping-sync/sql",
117+
]
118+
rocksdb = [
119+
"sc-service/rocksdb",
120+
"fc-db/rocksdb",
121+
"fc-mapping-sync/rocksdb",
122+
"fc-rpc/rocksdb"
123+
]
124+
txpool = [
125+
"fc-rpc/txpool",
126+
"fc-rpc-core/txpool"
127+
]
128+
87129
# Dependencies that are only required if runtime benchmarking should be build.
88130
runtime-benchmarks = [
89131
"node-subtensor-runtime/runtime-benchmarks",

node/src/benchmarking.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Should only be used for benchmarking as it may break in other contexts.
44
5-
use crate::service::FullClient;
5+
use crate::service::Client;
66

77
use node_subtensor_runtime as runtime;
88
use node_subtensor_runtime::check_nonce;
@@ -21,12 +21,12 @@ use std::{sync::Arc, time::Duration};
2121
//
2222
// Note: Should only be used for benchmarking.
2323
pub struct RemarkBuilder {
24-
client: Arc<FullClient>,
24+
client: Arc<Client>,
2525
}
2626

2727
impl RemarkBuilder {
2828
// Creates a new [`Self`] from the given client.
29-
pub fn new(client: Arc<FullClient>) -> Self {
29+
pub fn new(client: Arc<Client>) -> Self {
3030
Self { client }
3131
}
3232
}
@@ -58,14 +58,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
5858
//
5959
// Note: Should only be used for benchmarking.
6060
pub struct TransferKeepAliveBuilder {
61-
client: Arc<FullClient>,
61+
client: Arc<Client>,
6262
dest: AccountId,
6363
value: Balance,
6464
}
6565

6666
impl TransferKeepAliveBuilder {
6767
// Creates a new [`Self`] from the given client.
68-
pub fn new(client: Arc<FullClient>, dest: AccountId, value: Balance) -> Self {
68+
pub fn new(client: Arc<Client>, dest: AccountId, value: Balance) -> Self {
6969
Self {
7070
client,
7171
dest,
@@ -105,7 +105,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
105105
//
106106
// Note: Should only be used for benchmarking.
107107
pub fn create_benchmark_extrinsic(
108-
client: &FullClient,
108+
client: &Client,
109109
sender: sp_core::sr25519::Pair,
110110
call: runtime::RuntimeCall,
111111
nonce: u32,

node/src/cli.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::ethereum::EthConfiguration;
12
use sc_cli::RunCmd;
23

34
#[derive(Debug, clap::Parser)]
@@ -7,6 +8,13 @@ pub struct Cli {
78

89
#[clap(flatten)]
910
pub run: RunCmd,
11+
12+
/// Choose sealing method.
13+
#[arg(long, value_enum, ignore_case = true)]
14+
pub sealing: Option<Sealing>,
15+
16+
#[command(flatten)]
17+
pub eth: EthConfiguration,
1018
}
1119

1220
#[allow(clippy::large_enum_variant)]
@@ -45,3 +53,13 @@ pub enum Subcommand {
4553
// Db meta columns information.
4654
ChainInfo(sc_cli::ChainInfoCmd),
4755
}
56+
57+
/// Available Sealing methods.
58+
#[derive(Copy, Clone, Debug, Default, clap::ValueEnum)]
59+
pub enum Sealing {
60+
/// Seal using rpc method.
61+
#[default]
62+
Manual,
63+
/// Seal when transaction is executed.
64+
Instant,
65+
}

node/src/client.rs

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
use scale_codec::Codec;
2+
// Substrate
3+
use sc_executor::WasmExecutor;
4+
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};
5+
6+
use crate::ethereum::EthCompatRuntimeApiCollection;
7+
8+
/// Full backend.
9+
pub type FullBackend<B> = sc_service::TFullBackend<B>;
10+
/// Full client.
11+
pub type FullClient<B, RA, HF> = sc_service::TFullClient<B, RA, WasmExecutor<HF>>;
12+
13+
/// A set of APIs that every runtime must implement.
14+
pub trait BaseRuntimeApiCollection<Block: BlockT>:
15+
sp_api::ApiExt<Block>
16+
+ sp_api::Metadata<Block>
17+
+ sp_block_builder::BlockBuilder<Block>
18+
+ sp_offchain::OffchainWorkerApi<Block>
19+
+ sp_session::SessionKeys<Block>
20+
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
21+
{
22+
}
23+
24+
impl<Block, Api> BaseRuntimeApiCollection<Block> for Api
25+
where
26+
Block: BlockT,
27+
Api: sp_api::ApiExt<Block>
28+
+ sp_api::Metadata<Block>
29+
+ sp_block_builder::BlockBuilder<Block>
30+
+ sp_offchain::OffchainWorkerApi<Block>
31+
+ sp_session::SessionKeys<Block>
32+
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
33+
{
34+
}
35+
36+
/// A set of APIs that Subtensor runtime must implement.
37+
pub trait RuntimeApiCollection<
38+
Block: BlockT,
39+
AuraId: Codec,
40+
AccountId: Codec,
41+
Nonce: Codec,
42+
Balance: Codec + MaybeDisplay,
43+
>:
44+
BaseRuntimeApiCollection<Block>
45+
+ EthCompatRuntimeApiCollection<Block>
46+
+ sp_consensus_aura::AuraApi<Block, AuraId>
47+
+ sp_consensus_grandpa::GrandpaApi<Block>
48+
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
49+
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
50+
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
51+
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
52+
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
53+
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>
54+
{
55+
}
56+
57+
impl<Block, AuraId, AccountId, Nonce, Balance, Api>
58+
RuntimeApiCollection<Block, AuraId, AccountId, Nonce, Balance> for Api
59+
where
60+
Block: BlockT,
61+
AuraId: Codec,
62+
AccountId: Codec,
63+
Nonce: Codec,
64+
Balance: Codec + MaybeDisplay,
65+
Api: BaseRuntimeApiCollection<Block>
66+
+ EthCompatRuntimeApiCollection<Block>
67+
+ sp_consensus_aura::AuraApi<Block, AuraId>
68+
+ sp_consensus_grandpa::GrandpaApi<Block>
69+
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
70+
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
71+
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
72+
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
73+
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
74+
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>,
75+
{
76+
}

0 commit comments

Comments
 (0)