Skip to content

Commit

Permalink
chore bump to latest stable polkadot version
Browse files Browse the repository at this point in the history
  • Loading branch information
saiintbrisson committed Oct 25, 2024
1 parent ab138d2 commit 93ad2f5
Show file tree
Hide file tree
Showing 13 changed files with 2,025 additions and 2,162 deletions.
2,960 changes: 1,448 additions & 1,512 deletions Cargo.lock

Large diffs are not rendered by default.

170 changes: 85 additions & 85 deletions Cargo.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ sp-transaction-pool.workspace = true
sp-api.workspace = true
sp-block-builder.workspace = true
sp-blockchain.workspace = true
sp-consensus.workspace = true
sp-consensus-aura.workspace = true
sp-consensus-grandpa.workspace = true
sp-core.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use node_subspace_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY};
use node_subspace_runtime::{AccountId, Signature, WASM_BINARY};
use pallet_subspace_genesis_config::{ConfigModule, ConfigSubnet};
use sc_service::ChainType;
use serde::Deserialize;
Expand All @@ -9,7 +9,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
use std::fs::File;

// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec;

// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down
54 changes: 3 additions & 51 deletions node/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,58 +1,10 @@
use crate::eth::EthCompatRuntimeApiCollection;
use node_subspace_runtime::{opaque::Block, AccountId, Balance, Nonce};
use node_subspace_runtime::opaque::Block;
use sc_executor::WasmExecutor;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;

/// Full backend.
pub type FullBackend = sc_service::TFullBackend<Block>;
pub type WasmClient<RuntimeApi> =
sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;

pub type Client = WasmClient<node_subspace_runtime::RuntimeApi>;

/// A set of APIs that every runtimes must implement.
pub trait BaseRuntimeApiCollection:
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<Api> BaseRuntimeApiCollection for Api where
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 template runtime must implement.
pub trait RuntimeApiCollection:
BaseRuntimeApiCollection
+ EthCompatRuntimeApiCollection
+ 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>
+ subspace_rpc::SubspaceRuntimeApi<Block>
{
}

impl<Api> RuntimeApiCollection for Api where
Api: BaseRuntimeApiCollection
+ EthCompatRuntimeApiCollection
+ 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>
+ subspace_rpc::SubspaceRuntimeApi<Block>
{
}
pub type Client =
sc_service::TFullClient<Block, node_subspace_runtime::RuntimeApi, WasmExecutor<HostFunctions>>;

/// Only enable the benchmarking host functions when we actually want to benchmark.
#[cfg(feature = "runtime-benchmarks")]
Expand Down
99 changes: 72 additions & 27 deletions node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use futures::TryFutureExt;
// Substrate
use sc_cli::SubstrateCli;
use sc_service::DatabaseSource;
use sc_service::{DatabaseSource, PartialComponents};
// Frontier
use fc_db::kv::frontier_database_dir;

use crate::{
chain_spec,
cli::{Cli, Subcommand},
service::{self, db_config_dir},
service::{self, db_config_dir, Other},
};

#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -66,9 +66,9 @@ pub fn run() -> sc_cli::Result<()> {
cli.run.shared_params.detailed_log_output = true;
cli.run.shared_params.log.extend([
"info".to_string(),
"pallet_subspace=debug".to_string(),
"pallet_governance=debug".to_string(),
"pallet_subnet_emission=debug".to_string(),
"pallet_subspace=info".to_string(),
"pallet_governance=info".to_string(),
"pallet_subnet_emission=info".to_string(),
]);

match &cli.subcommand {
Expand All @@ -79,33 +79,53 @@ pub fn run() -> sc_cli::Result<()> {
}
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|mut config| {
let (client, _, import_queue, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
runner.async_run(|config| {
let PartialComponents {
client,
import_queue,
task_manager,
..
} = service::new_chain_ops(config, cli.eth)?;

Ok((cmd.run(client, import_queue), task_manager))
})
}
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|mut config| {
let (client, _, _, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
other: Other { config, .. },
..
} = service::new_chain_ops(config, cli.eth)?;

Ok((cmd.run(client, config.database), task_manager))
})
}
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|mut config| {
let (client, _, _, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
other: Other { config, .. },
..
} = service::new_chain_ops(config, cli.eth)?;

Ok((cmd.run(client, config.chain_spec), task_manager))
})
}
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|mut config| {
let (client, _, import_queue, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
runner.async_run(|config| {
let PartialComponents {
client,
import_queue,
task_manager,
..
} = service::new_chain_ops(config, cli.eth)?;

Ok((cmd.run(client, import_queue), task_manager))
})
}
Expand Down Expand Up @@ -158,13 +178,19 @@ pub fn run() -> sc_cli::Result<()> {
}
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|mut config| {
let (client, backend, _, task_manager, _) =
service::new_chain_ops(&mut config, &cli.eth)?;
runner.async_run(|config| {
let PartialComponents {
client,
backend,
task_manager,
..
} = service::new_chain_ops(config, cli.eth)?;

let aux_revert = Box::new(move |client, _, blocks| {
sc_consensus_grandpa::revert(client, blocks)?;
Ok(())
});

Ok((cmd.run(client, backend, Some(aux_revert)), task_manager))
})
}
Expand All @@ -183,17 +209,28 @@ pub fn run() -> sc_cli::Result<()> {
BenchmarkCmd::Pallet(cmd) => runner
.sync_run(|config| cmd.run_with_spec::<Hashing, ()>(Some(config.chain_spec))),
BenchmarkCmd::Block(cmd) => runner.sync_run(|mut config| {
let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?;
let PartialComponents { client, .. } = service::new_chain_ops(config, cli.eth)?;
cmd.run(client)
}),
BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| {
let (client, backend, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?;
let PartialComponents {
client,
backend,
other: Other { config, .. },
..
} = service::new_chain_ops(config, cli.eth)?;

let db = backend.expose_db();
let storage = backend.expose_storage();
cmd.run(config, client, db, storage)
}),
BenchmarkCmd::Overhead(cmd) => runner.sync_run(|mut config| {
let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?;
let PartialComponents {
client,
other: Other { config, .. },
..
} = service::new_chain_ops(config, cli.eth)?;

let ext_builder = RemarkBuilder::new(client.clone());
cmd.run(
config,
Expand All @@ -204,7 +241,8 @@ pub fn run() -> sc_cli::Result<()> {
)
}),
BenchmarkCmd::Extrinsic(cmd) => runner.sync_run(|mut config| {
let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?;
let PartialComponents { client, .. } = service::new_chain_ops(config, cli.eth)?;

// Register the *Remark* and *TKA* builders.
let ext_factory = ExtrinsicFactory(vec![
Box::new(RemarkBuilder::new(client.clone())),
Expand All @@ -228,9 +266,16 @@ pub fn run() -> sc_cli::Result<()> {
.into()),
Some(Subcommand::FrontierDb(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|mut config| {
let (client, _, _, _, frontier_backend) =
service::new_chain_ops(&mut config, &cli.eth)?;
runner.sync_run(|config| {
let PartialComponents {
client,
other:
Other {
frontier_backend, ..
},
..
} = service::new_chain_ops(config, cli.eth)?;

let frontier_backend = match frontier_backend {
fc_db::Backend::KeyValue(kv) => kv,
_ => panic!("Only fc_db::Backend::KeyValue supported"),
Expand Down
31 changes: 6 additions & 25 deletions node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ use futures::{future, prelude::*};
use sc_client_api::BlockchainEvents;
use sc_network_sync::SyncingService;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_api::ConstructRuntimeApi;
// Frontier
use fc_rpc::EthTask;
pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
pub use fc_storage::{StorageOverride, StorageOverrideHandler};
// Local
use node_subspace_runtime::opaque::Block;

use crate::client::{FullBackend, WasmClient};
use crate::client::{Client, FullBackend};

/// Frontier DB backend type.
pub type FrontierBackend<C> = fc_db::Backend<Block, C>;
pub type FrontierBackend = fc_db::Backend<Block, Client>;

pub fn db_config_dir(config: &Configuration) -> PathBuf {
config.base_path.config_dir(config.chain_spec.id())
Expand Down Expand Up @@ -106,26 +105,11 @@ pub fn new_frontier_partial(
})
}

/// A set of APIs that ethereum-compatible runtimes must implement.
pub trait EthCompatRuntimeApiCollection:
sp_api::ApiExt<Block>
+ fp_rpc::ConvertTransactionRuntimeApi<Block>
+ fp_rpc::EthereumRuntimeRPCApi<Block>
{
}

impl<Api> EthCompatRuntimeApiCollection for Api where
Api: sp_api::ApiExt<Block>
+ fp_rpc::ConvertTransactionRuntimeApi<Block>
+ fp_rpc::EthereumRuntimeRPCApi<Block>
{
}

pub async fn spawn_frontier_tasks<RuntimeApi>(
pub async fn spawn_frontier_tasks(
task_manager: &TaskManager,
client: Arc<WasmClient<RuntimeApi>>,
client: Arc<Client>,
backend: Arc<FullBackend>,
frontier_backend: Arc<FrontierBackend<WasmClient<RuntimeApi>>>,
frontier_backend: Arc<FrontierBackend>,
filter_pool: Option<FilterPool>,
storage_override: Arc<dyn StorageOverride<Block>>,
fee_history_cache: FeeHistoryCache,
Expand All @@ -136,10 +120,7 @@ pub async fn spawn_frontier_tasks<RuntimeApi>(
fc_mapping_sync::EthereumBlockNotification<Block>,
>,
>,
) where
RuntimeApi: ConstructRuntimeApi<Block, WasmClient<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection,
{
) {
// Spawn main mapping sync worker background task.
match &*frontier_backend {
fc_db::Backend::KeyValue(b) => {
Expand Down
6 changes: 1 addition & 5 deletions node/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use sc_client_api::{
};
use sc_consensus_manual_seal::rpc::EngineCommand;
use sc_rpc::SubscriptionTaskExecutor;
use sc_rpc_api::DenyUnsafe;
use sc_service::TransactionPool;
use sc_transaction_pool::ChainApi;
use sp_api::{CallApiAt, ProvideRuntimeApi};
Expand All @@ -32,8 +31,6 @@ pub struct FullDeps<C, P, A: ChainApi, CT, CIDP> {
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// Manual seal command sink
pub command_sink: Option<mpsc::Sender<EngineCommand<Hash>>>,
/// Ethereum-compatibility specific dependencies.
Expand Down Expand Up @@ -88,12 +85,11 @@ where
let FullDeps {
client,
pool,
deny_unsafe,
command_sink,
eth,
} = deps;

io.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
io.merge(System::new(client.clone(), pool).into_rpc())?;
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
io.merge(SubspacePallet::new(client).into_rpc())?;

Expand Down
Loading

0 comments on commit 93ad2f5

Please sign in to comment.