Skip to content

Commit

Permalink
Fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Oct 25, 2023
1 parent 411f944 commit 1ba8a5e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pallet-fee-market = { git = "https://github.com/darwinia-network/darwinia
fc-consensus = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0" }
fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0" }
fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0", features = ["sql"] }
fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0", features = ["rpc-binary-search-estimate"] }
fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0", features = ["rpc-binary-search-estimate", "txpool"] }
fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0" }
fc-storage = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0" }
fp-account = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0", default-features = false, features = ["serde"] }
Expand Down
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 @@ sc-transaction-pool-api = { workspace = true }
sp-api = { workspace = true, features = ["std"] }
sp-block-builder = { workspace = true, features = ["std"] }
sp-blockchain = { workspace = true }
sp-inherents = { workspace = true, features = ["std"] }
sp-consensus-aura = { workspace = true, features = ["std"] }
sp-core = { workspace = true, features = ["std"] }
sp-io = { workspace = true, optional = true, features = ["std"] }
Expand Down
19 changes: 14 additions & 5 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use moonbeam_rpc_trace::{Trace, TraceServer};
pub type RpcExtension = jsonrpsee::RpcModule<()>;

/// Full client dependencies
pub struct FullDeps<C, P, A: sc_transaction_pool::ChainApi> {
pub struct FullDeps<C, P, A: sc_transaction_pool::ChainApi, CIDP> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
Expand Down Expand Up @@ -66,6 +66,8 @@ pub struct FullDeps<C, P, A: sc_transaction_pool::ChainApi> {
pub block_data_cache: Arc<fc_rpc::EthBlockDataCacheTask<Block>>,
/// Mandated parent hashes for a given block hash.
pub forced_parent_hashes: Option<BTreeMap<sp_core::H256, sp_core::H256>>,
/// Something that can create the inherent data providers for pending state
pub pending_create_inherent_data_providers: CIDP,
}

/// EVM tracing rpc server config
Expand All @@ -87,8 +89,8 @@ where
}

/// Instantiate all RPC extensions.
pub fn create_full<C, P, BE, A, EC>(
deps: FullDeps<C, P, A>,
pub fn create_full<C, P, BE, A, EC, CIDP>(
deps: FullDeps<C, P, A, CIDP>,
subscription_task_executor: sc_rpc::SubscriptionTaskExecutor,
pubsub_notification_sinks: Arc<
fc_mapping_sync::EthereumBlockNotificationSinks<
Expand All @@ -109,12 +111,16 @@ where
+ sp_api::CallApiAt<Block>
+ sp_api::ProvideRuntimeApi<Block>
+ sp_blockchain::HeaderBackend<Block>
+ sc_client_api::backend::AuxStore
+ sc_client_api::UsageProvider<Block>
+ sp_blockchain::HeaderMetadata<Block, Error = sp_blockchain::Error>,
C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>
+ fp_rpc::EthereumRuntimeRPCApi<Block>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ sp_block_builder::BlockBuilder<Block>
+ sp_consensus_aura::AuraApi<Block, sp_consensus_aura::sr25519::AuthorityId>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
CIDP: sp_inherents::CreateInherentDataProviders<Block, ()> + Send + 'static,
P: 'static + Sync + Send + sc_transaction_pool_api::TransactionPool<Block = Block>,
A: 'static + sc_transaction_pool::ChainApi<Block = Block>,
EC: fc_rpc::EthConfig<Block, C>,
Expand Down Expand Up @@ -146,6 +152,7 @@ where
overrides,
block_data_cache,
forced_parent_hashes,
pending_create_inherent_data_providers,
} = deps;

module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
Expand All @@ -166,18 +173,20 @@ where
fee_history_cache_limit,
10,
forced_parent_hashes,
pending_create_inherent_data_providers,
Some(Box::new(fc_rpc::pending::AuraConsensusDataProvider::new(client.clone()))),
)
.replace_config::<EC>()
.into_rpc(),
)?;

let tx_pool = TxPool::new(client.clone(), graph);
let tx_pool = TxPool::new(client.clone(), graph.clone());
if let Some(filter_pool) = filter_pool {
module.merge(
EthFilter::new(
client.clone(),
frontier_backend,
tx_pool.clone(),
graph,
filter_pool,
500_usize, // max stored filters
max_past_logs,
Expand Down
32 changes: 28 additions & 4 deletions node/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,17 @@ where
let collator = parachain_config.role.is_authority();
let eth_rpc_config = eth_rpc_config.clone();
let sync_service = sync_service.clone();
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let pending_create_inherent_data_providers = move |_, ()| async move {
let current = sp_timestamp::InherentDataProvider::from_system_time();
let next_slot = current.timestamp().as_millis() + slot_duration.as_millis();
let timestamp = sp_timestamp::InherentDataProvider::new(next_slot.into());
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
};

Box::new(move |deny_unsafe, subscription_task_executor| {
let deps = crate::rpc::FullDeps {
Expand All @@ -422,12 +433,13 @@ where
overrides: overrides.clone(),
block_data_cache: block_data_cache.clone(),
forced_parent_hashes: None,
pending_create_inherent_data_providers,
};

if eth_rpc_config.tracing_api.contains(&crate::cli::TracingApi::Debug)
|| eth_rpc_config.tracing_api.contains(&crate::cli::TracingApi::Trace)
{
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>>(
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>, _>(
deps,
subscription_task_executor,
pubsub_notification_sinks.clone(),
Expand All @@ -438,7 +450,7 @@ where
)
.map_err(Into::into)
} else {
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>>(
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>, _>(
deps,
subscription_task_executor,
pubsub_notification_sinks.clone(),
Expand Down Expand Up @@ -913,6 +925,17 @@ where
let collator = config.role.is_authority();
let eth_rpc_config = eth_rpc_config.clone();
let sync_service = sync_service.clone();
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let pending_create_inherent_data_providers = move |_, ()| async move {
let current = sp_timestamp::InherentDataProvider::from_system_time();
let next_slot = current.timestamp().as_millis() + slot_duration.as_millis();
let timestamp = sp_timestamp::InherentDataProvider::new(next_slot.into());
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
};

Box::new(move |deny_unsafe, subscription_task_executor| {
let deps = crate::rpc::FullDeps {
Expand All @@ -934,12 +957,13 @@ where
overrides: overrides.clone(),
block_data_cache: block_data_cache.clone(),
forced_parent_hashes: None,
pending_create_inherent_data_providers,
};

if eth_rpc_config.tracing_api.contains(&crate::cli::TracingApi::Debug)
|| eth_rpc_config.tracing_api.contains(&crate::cli::TracingApi::Trace)
{
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>>(
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>, _>(
deps,
subscription_task_executor,
pubsub_notification_sinks.clone(),
Expand All @@ -950,7 +974,7 @@ where
)
.map_err(Into::into)
} else {
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>>(
crate::rpc::create_full::<_, _, _, _, crate::rpc::DefaultEthConfig<_, _>, _>(
deps,
subscription_task_executor,
pubsub_notification_sinks.clone(),
Expand Down

0 comments on commit 1ba8a5e

Please sign in to comment.