Skip to content

Commit

Permalink
Merge pull request #772 from opentensor/feat/evm-devnet-ready
Browse files Browse the repository at this point in the history
Feat/evm devnet ready
  • Loading branch information
unconst authored Oct 31, 2024
2 parents 2ad1381 + d8eadf3 commit 3fb89ec
Show file tree
Hide file tree
Showing 26 changed files with 3,944 additions and 1,142 deletions.
2,003 changes: 1,294 additions & 709 deletions Cargo.lock

Large diffs are not rendered by default.

185 changes: 110 additions & 75 deletions Cargo.toml

Large diffs are not rendered by default.

44 changes: 43 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ targets = ["x86_64-unknown-linux-gnu"]
name = "node-subtensor"

[dependencies]
async-trait = { workspace = true }
clap = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["thread-pool"] }
scale-codec = { workspace = true }
serde = { workspace = true, features = ["derive"] }

# Storage import
Expand Down Expand Up @@ -52,8 +54,11 @@ sc-client-api = { workspace = true }
sp-runtime = { workspace = true }
sp-io = { workspace = true }
sp-timestamp = { workspace = true }
sp-transaction-pool = { workspace = true, features = ["default"] }
sp-inherents = { workspace = true }
sp-keyring = { workspace = true }
sp-offchain = { workspace = true }
sp-session = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-system = { workspace = true }
pallet-transaction-payment = { workspace = true }
Expand All @@ -69,11 +74,29 @@ sp-block-builder = { workspace = true }
sc-basic-authorship = { workspace = true }
substrate-frame-rpc-system = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }

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

# Needed for Frontier
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 }
fp-dynamic-fee = { workspace = true }
fc-api = { workspace = true }
fc-rpc = { workspace = true }
fc-rpc-core = { workspace = true }
fp-rpc = { workspace = true }
fc-mapping-sync = { workspace = true }

# Local Dependencies
node-subtensor-runtime = { path = "../runtime" }
subtensor-custom-rpc = { path = "../pallets/subtensor/rpc" }
Expand All @@ -83,7 +106,26 @@ subtensor-custom-rpc-runtime-api = { path = "../pallets/subtensor/runtime-api" }
substrate-build-script-utils = { workspace = true }

[features]
default = []
default = [
"rocksdb",
"sql",
"txpool",
]
sql = [
"fc-db/sql",
"fc-mapping-sync/sql",
]
rocksdb = [
"sc-service/rocksdb",
"fc-db/rocksdb",
"fc-mapping-sync/rocksdb",
"fc-rpc/rocksdb"
]
txpool = [
"fc-rpc/txpool",
"fc-rpc-core/txpool"
]

# Dependencies that are only required if runtime benchmarking should be build.
runtime-benchmarks = [
"node-subtensor-runtime/runtime-benchmarks",
Expand Down
12 changes: 6 additions & 6 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Should only be used for benchmarking as it may break in other contexts.
use crate::service::FullClient;
use crate::service::Client;

use node_subtensor_runtime as runtime;
use node_subtensor_runtime::check_nonce;
Expand All @@ -21,12 +21,12 @@ use std::{sync::Arc, time::Duration};
//
// Note: Should only be used for benchmarking.
pub struct RemarkBuilder {
client: Arc<FullClient>,
client: Arc<Client>,
}

impl RemarkBuilder {
// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<FullClient>) -> Self {
pub fn new(client: Arc<Client>) -> Self {
Self { client }
}
}
Expand Down Expand Up @@ -58,14 +58,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
//
// Note: Should only be used for benchmarking.
pub struct TransferKeepAliveBuilder {
client: Arc<FullClient>,
client: Arc<Client>,
dest: AccountId,
value: Balance,
}

impl TransferKeepAliveBuilder {
// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<FullClient>, dest: AccountId, value: Balance) -> Self {
pub fn new(client: Arc<Client>, dest: AccountId, value: Balance) -> Self {
Self {
client,
dest,
Expand Down Expand Up @@ -105,7 +105,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
//
// Note: Should only be used for benchmarking.
pub fn create_benchmark_extrinsic(
client: &FullClient,
client: &Client,
sender: sp_core::sr25519::Pair,
call: runtime::RuntimeCall,
nonce: u32,
Expand Down
18 changes: 18 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::ethereum::EthConfiguration;
use sc_cli::RunCmd;

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

#[clap(flatten)]
pub run: RunCmd,

/// Choose sealing method.
#[arg(long, value_enum, ignore_case = true)]
pub sealing: Option<Sealing>,

#[command(flatten)]
pub eth: EthConfiguration,
}

#[allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -45,3 +53,13 @@ pub enum Subcommand {
// Db meta columns information.
ChainInfo(sc_cli::ChainInfoCmd),
}

/// Available Sealing methods.
#[derive(Copy, Clone, Debug, Default, clap::ValueEnum)]
pub enum Sealing {
/// Seal using rpc method.
#[default]
Manual,
/// Seal when transaction is executed.
Instant,
}
76 changes: 76 additions & 0 deletions node/src/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
use scale_codec::Codec;
// Substrate
use sc_executor::WasmExecutor;
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};

use crate::ethereum::EthCompatRuntimeApiCollection;

/// Full backend.
pub type FullBackend<B> = sc_service::TFullBackend<B>;
/// Full client.
pub type FullClient<B, RA, HF> = sc_service::TFullClient<B, RA, WasmExecutor<HF>>;

/// A set of APIs that every runtime must implement.
pub trait BaseRuntimeApiCollection<Block: BlockT>:
sp_api::ApiExt<Block>
+ sp_api::Metadata<Block>
+ sp_block_builder::BlockBuilder<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
{
}

impl<Block, Api> BaseRuntimeApiCollection<Block> for Api
where
Block: BlockT,
Api: sp_api::ApiExt<Block>
+ sp_api::Metadata<Block>
+ sp_block_builder::BlockBuilder<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
{
}

/// A set of APIs that Subtensor runtime must implement.
pub trait RuntimeApiCollection<
Block: BlockT,
AuraId: Codec,
AccountId: Codec,
Nonce: Codec,
Balance: Codec + MaybeDisplay,
>:
BaseRuntimeApiCollection<Block>
+ EthCompatRuntimeApiCollection<Block>
+ sp_consensus_aura::AuraApi<Block, AuraId>
+ sp_consensus_grandpa::GrandpaApi<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>
{
}

impl<Block, AuraId, AccountId, Nonce, Balance, Api>
RuntimeApiCollection<Block, AuraId, AccountId, Nonce, Balance> for Api
where
Block: BlockT,
AuraId: Codec,
AccountId: Codec,
Nonce: Codec,
Balance: Codec + MaybeDisplay,
Api: BaseRuntimeApiCollection<Block>
+ EthCompatRuntimeApiCollection<Block>
+ sp_consensus_aura::AuraApi<Block, AuraId>
+ sp_consensus_grandpa::GrandpaApi<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>,
{
}
Loading

0 comments on commit 3fb89ec

Please sign in to comment.