Skip to content

Commit

Permalink
deps: update substrate to polkadot-v1.12.0 (#1437)
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro authored May 27, 2024
1 parent 5779b59 commit 0c63310
Show file tree
Hide file tree
Showing 14 changed files with 687 additions and 657 deletions.
790 changes: 407 additions & 383 deletions Cargo.lock

Large diffs are not rendered by default.

142 changes: 71 additions & 71 deletions Cargo.toml

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions client/db/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ use sqlx::{
ConnectOptions, Error, Execute, QueryBuilder, Row, Sqlite,
};
// Substrate
use sc_client_api::backend::{Backend as BackendT, StateBackend, StorageProvider};
use sc_client_api::backend::{Backend as BackendT, StorageProvider};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_core::{H160, H256};
use sp_runtime::{
generic::BlockId,
traits::{BlakeTwo256, Block as BlockT, Header as HeaderT, UniqueSaturatedInto, Zero},
traits::{Block as BlockT, Header as HeaderT, UniqueSaturatedInto, Zero},
};
// Frontier
use fc_api::{FilteredLog, TransactionMetadata};
Expand Down Expand Up @@ -203,7 +203,6 @@ where
Client: ProvideRuntimeApi<Block>,
Client::Api: EthereumRuntimeRPCApi<Block>,
BE: BackendT<Block> + 'static,
BE::State: StateBackend<BlakeTwo256>,
{
let id = BlockId::Number(Zero::zero());
let substrate_genesis_hash = client
Expand Down Expand Up @@ -272,7 +271,6 @@ where
where
Client: StorageProvider<Block, BE> + HeaderBackend<Block> + 'static,
BE: BackendT<Block> + 'static,
BE::State: StateBackend<BlakeTwo256>,
{
log::trace!(target: "frontier-sql", "🛠️ [Metadata] Retrieving digest data for block {hash:?}");
if let Ok(Some(header)) = client.header(hash) {
Expand Down Expand Up @@ -362,7 +360,6 @@ where
where
Client: StorageProvider<Block, BE> + HeaderBackend<Block> + 'static,
BE: BackendT<Block> + 'static,
BE::State: StateBackend<BlakeTwo256>,
{
// Spawn a blocking task to get block metadata from substrate backend.
let storage_override = self.storage_override.clone();
Expand Down
9 changes: 2 additions & 7 deletions client/mapping-sync/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ use std::{ops::DerefMut, sync::Arc, time::Duration};

use futures::prelude::*;
// Substrate
use sc_client_api::backend::{Backend as BackendT, StateBackend, StorageProvider};
use sc_client_api::backend::{Backend as BackendT, StorageProvider};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Backend, HeaderBackend};
use sp_consensus::SyncOracle;
use sp_core::H256;
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, Header as HeaderT, UniqueSaturatedInto};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, UniqueSaturatedInto};
// Frontier
use fp_rpc::EthereumRuntimeRPCApi;

Expand Down Expand Up @@ -70,7 +70,6 @@ where
Client::Api: EthereumRuntimeRPCApi<Block>,
Client: HeaderBackend<Block> + StorageProvider<Block, Backend> + 'static,
Backend: BackendT<Block> + 'static,
Backend::State: StateBackend<BlakeTwo256>,
{
/// Spawn the indexing worker. The worker can be given commands via the sender channel.
/// Once the buffer is full, attempts to send new messages will wait until a message is read from the channel.
Expand Down Expand Up @@ -278,7 +277,6 @@ async fn index_block_and_ancestors<Block, Backend, Client>(
Client::Api: EthereumRuntimeRPCApi<Block>,
Client: HeaderBackend<Block> + StorageProvider<Block, Backend> + 'static,
Backend: BackendT<Block> + 'static,
Backend::State: StateBackend<BlakeTwo256>,
{
let blockchain_backend = substrate_backend.blockchain();
let mut hashes = vec![hash];
Expand Down Expand Up @@ -326,7 +324,6 @@ async fn index_canonical_block_and_ancestors<Block, Backend, Client>(
Client::Api: EthereumRuntimeRPCApi<Block>,
Client: HeaderBackend<Block> + StorageProvider<Block, Backend> + 'static,
Backend: BackendT<Block> + 'static,
Backend::State: StateBackend<BlakeTwo256>,
{
let blockchain_backend = substrate_backend.blockchain();
let mut hashes = vec![hash];
Expand Down Expand Up @@ -411,7 +408,6 @@ async fn index_missing_blocks<Block, Client, Backend>(
Client::Api: EthereumRuntimeRPCApi<Block>,
Client: HeaderBackend<Block> + StorageProvider<Block, Backend> + 'static,
Backend: BackendT<Block> + 'static,
Backend::State: StateBackend<BlakeTwo256>,
{
if let Some(block_number) = indexer_backend.get_first_missing_canon_block().await {
log::debug!(target: "frontier-sql", "Missing {block_number:?}");
Expand Down Expand Up @@ -449,7 +445,6 @@ async fn index_genesis_block<Block, Client, Backend>(
Client::Api: EthereumRuntimeRPCApi<Block>,
Client: HeaderBackend<Block> + StorageProvider<Block, Backend> + 'static,
Backend: BackendT<Block> + 'static,
Backend::State: StateBackend<BlakeTwo256>,
{
log::info!(
target: "frontier-sql",
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ prometheus = { version = "0.13.4", default-features = false }
rand = "0.8"
rlp = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
schnellru = "0.2.1"
schnellru = "0.2.3"
serde = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/precompile/modexp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = { workspace = true }
repository = { workspace = true }

[dependencies]
num = { version = "0.4.2", default-features = false, features = ["alloc"] }
num = { version = "0.4.3", default-features = false, features = ["alloc"] }
# Frontier
fp-evm = { workspace = true }

Expand Down
1 change: 1 addition & 0 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ sp-consensus-aura = { workspace = true, features = ["default"] }
sp-consensus-grandpa = { workspace = true, features = ["default"] }
sp-core = { workspace = true, features = ["default"] }
sp-inherents = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
sp-offchain = { workspace = true, features = ["default"] }
sp-runtime = { workspace = true, features = ["default"] }
sp-session = { workspace = true, features = ["default"] }
Expand Down
2 changes: 1 addition & 1 deletion template/node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sp_runtime::{generic::Era, OpaqueExtrinsic, SaturatedConversion};
use fp_account::AccountId20;
use frontier_template_runtime::{self as runtime, AccountId, Balance, BalancesCall, SystemCall};

use crate::client::Client;
use crate::service::Client;

/// Generates extrinsics for the `benchmark overhead` command.
///
Expand Down
71 changes: 31 additions & 40 deletions template/node/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@
use scale_codec::Codec;
// Substrate
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch, NativeVersion};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
// Local
use frontier_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
use sc_executor::WasmExecutor;
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};

use crate::eth::EthCompatRuntimeApiCollection;

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

pub type Client = FullClient<frontier_template_runtime::RuntimeApi, TemplateRuntimeExecutor>;

/// Only enable the benchmarking host functions when we actually want to benchmark.
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions = frame_benchmarking::benchmarking::HostFunctions;
/// Otherwise we use empty host functions for ext host functions.
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions = ();

pub struct TemplateRuntimeExecutor;
impl NativeExecutionDispatch for TemplateRuntimeExecutor {
type ExtendHostFunctions = HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
frontier_template_runtime::api::dispatch(method, data)
}

fn native_version() -> NativeVersion {
frontier_template_runtime::native_version()
}
}

/// A set of APIs that every runtimes must implement.
pub trait BaseRuntimeApiCollection:
/// 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>
Expand All @@ -45,33 +21,48 @@ pub trait BaseRuntimeApiCollection:
{
}

impl<Api> BaseRuntimeApiCollection for Api where
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>
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
{
}

/// A set of APIs that template runtime must implement.
pub trait RuntimeApiCollection:
BaseRuntimeApiCollection
+ EthCompatRuntimeApiCollection
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>
{
}

impl<Api> RuntimeApiCollection for Api where
Api: BaseRuntimeApiCollection
+ EthCompatRuntimeApiCollection
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>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>,
{
}
43 changes: 23 additions & 20 deletions template/node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ use std::{
use futures::{future, prelude::*};
// Substrate
use sc_client_api::BlockchainEvents;
use sc_executor::NativeExecutionDispatch;
use sc_executor::HostFunctions;
use sc_network_sync::SyncingService;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_api::ConstructRuntimeApi;
use sp_core::H256;
use sp_runtime::traits::Block as BlockT;
// Frontier
pub use fc_consensus::FrontierBlockImport;
use fc_rpc::EthTask;
pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
pub use fc_storage::{StorageOverride, StorageOverrideHandler};
// Local
use frontier_template_runtime::opaque::Block;

use crate::client::{FullBackend, FullClient};

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

pub fn db_config_dir(config: &Configuration) -> PathBuf {
config.base_path.config_dir(config.chain_spec.id())
}

/// Avalailable frontier backend types.
/// Available frontier backend types.
#[derive(Debug, Copy, Clone, Default, clap::ValueEnum)]
pub enum BackendType {
/// Either RocksDb or ParityDb as per inherited from the global backend settings.
Expand Down Expand Up @@ -109,40 +109,43 @@ pub fn new_frontier_partial(
}

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

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

pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
pub async fn spawn_frontier_tasks<B, RA, HF>(
task_manager: &TaskManager,
client: Arc<FullClient<RuntimeApi, Executor>>,
backend: Arc<FullBackend>,
frontier_backend: Arc<FrontierBackend<FullClient<RuntimeApi, Executor>>>,
client: Arc<FullClient<B, RA, HF>>,
backend: Arc<FullBackend<B>>,
frontier_backend: Arc<FrontierBackend<B, FullClient<B, RA, HF>>>,
filter_pool: Option<FilterPool>,
storage_override: Arc<dyn StorageOverride<Block>>,
storage_override: Arc<dyn StorageOverride<B>>,
fee_history_cache: FeeHistoryCache,
fee_history_cache_limit: FeeHistoryCacheLimit,
sync: Arc<SyncingService<Block>>,
sync: Arc<SyncingService<B>>,
pubsub_notification_sinks: Arc<
fc_mapping_sync::EthereumBlockNotificationSinks<
fc_mapping_sync::EthereumBlockNotification<Block>,
fc_mapping_sync::EthereumBlockNotification<B>,
>,
>,
) where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>>,
RuntimeApi: Send + Sync + 'static,
RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection,
Executor: NativeExecutionDispatch + 'static,
B: BlockT<Hash = H256>,
RA: ConstructRuntimeApi<B, FullClient<B, RA, HF>>,
RA: Send + Sync + 'static,
RA::RuntimeApi: EthCompatRuntimeApiCollection<B>,
HF: HostFunctions + 'static,
{
// Spawn main mapping sync worker background task.
match &*frontier_backend {
Expand All @@ -158,7 +161,7 @@ pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
storage_override.clone(),
b.clone(),
3,
0,
0u32.into(),
fc_mapping_sync::SyncStrategy::Normal,
sync,
pubsub_notification_sinks,
Expand Down
2 changes: 1 addition & 1 deletion template/node/src/rpc/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn create_eth<B, C, BE, P, A, CT, CIDP, EC>(
>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
B: BlockT<Hash = H256>,
B: BlockT,
C: CallApiAt<B> + ProvideRuntimeApi<B>,
C::Api: AuraApi<B, AuraId>
+ BlockBuilderApi<B>
Expand Down
Loading

0 comments on commit 0c63310

Please sign in to comment.