Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix shiden genesis sync #1242

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions bin/collator/src/local/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,10 @@ pub fn start_node(
enable_evm_rpc: true, // enable EVM RPC for dev node by default
};

let pending_consensus_data_provider = Box::new(
fc_rpc::pending::AuraConsensusDataProvider::new(client.clone()),
);

crate::rpc::create_full(
deps,
subscription,
pubsub_notification_sinks.clone(),
pending_consensus_data_provider,
rpc_config.clone(),
)
.map_err::<ServiceError, _>(Into::into)
Expand Down Expand Up @@ -656,17 +651,8 @@ pub fn start_node(config: Configuration) -> Result<TaskManager, ServiceError> {
enable_evm_rpc: true, // enable EVM RPC for dev node by default
};

let pending_consensus_data_provider = Box::new(
fc_rpc::pending::AuraConsensusDataProvider::new(client.clone()),
);

crate::rpc::create_full(
deps,
subscription,
pubsub_notification_sinks.clone(),
pending_consensus_data_provider,
)
.map_err::<ServiceError, _>(Into::into)
crate::rpc::create_full(deps, subscription, pubsub_notification_sinks.clone())
.map_err::<ServiceError, _>(Into::into)
})
};

Expand Down
18 changes: 2 additions & 16 deletions bin/collator/src/parachain/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,8 @@ where
enable_evm_rpc: additional_config.enable_evm_rpc,
};

let pending_consensus_data_provider = Box::new(
fc_rpc::pending::AuraConsensusDataProvider::new(client.clone()),
);

crate::rpc::create_full(
deps,
subscription,
pubsub_notification_sinks.clone(),
pending_consensus_data_provider,
)
.map_err(Into::into)
crate::rpc::create_full(deps, subscription, pubsub_notification_sinks.clone())
.map_err(Into::into)
})
};

Expand Down Expand Up @@ -845,15 +836,10 @@ where
enable_evm_rpc: additional_config.enable_evm_rpc,
};

let pending_consensus_data_provider = Box::new(
fc_rpc::pending::AuraConsensusDataProvider::new(client.clone()),
);

crate::rpc::create_full(
deps,
subscription,
pubsub_notification_sinks.clone(),
pending_consensus_data_provider,
rpc_config.clone(),
)
.map_err(Into::into)
Expand Down
36 changes: 16 additions & 20 deletions bin/collator/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
use cumulus_primitives_parachain_inherent::ParachainInherentData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use fc_rpc::{
pending::ConsensusDataProvider, Eth, EthApiServer, EthBlockDataCacheTask, EthFilter,
EthFilterApiServer, EthPubSub, EthPubSubApiServer, Net, NetApiServer, OverrideHandle, Web3,
Web3ApiServer,
Eth, EthApiServer, EthBlockDataCacheTask, EthFilter, EthFilterApiServer, EthPubSub,
EthPubSubApiServer, Net, NetApiServer, OverrideHandle, Web3, Web3ApiServer,
};
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
use jsonrpsee::RpcModule;
Expand All @@ -38,7 +37,7 @@ use sc_rpc::dev::DevApiServer;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::TransactionPool;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_api::{ApiExt, CallApiAt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder;
use sp_blockchain::{
Backend as BlockchainBackend, Error as BlockChainError, HeaderBackend, HeaderMetadata,
Expand Down Expand Up @@ -149,7 +148,6 @@ pub fn create_full<C, P, BE, A>(
fc_mapping_sync::EthereumBlockNotification<Block>,
>,
>,
pending_consenus_data_provider: Box<dyn ConsensusDataProvider<Block>>,
tracing_config: EvmTracingConfig,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
Expand Down Expand Up @@ -182,12 +180,7 @@ where
let client = Arc::clone(&deps.client);
let graph = Arc::clone(&deps.graph);

let mut io = create_full_rpc(
deps,
subscription_task_executor,
pubsub_notification_sinks,
pending_consenus_data_provider,
)?;
let mut io = create_full_rpc(deps, subscription_task_executor, pubsub_notification_sinks)?;

if tracing_config.enable_txpool {
io.merge(MoonbeamTxPool::new(Arc::clone(&client), graph).into_rpc())?;
Expand Down Expand Up @@ -221,7 +214,6 @@ pub fn create_full<C, P, BE, A>(
fc_mapping_sync::EthereumBlockNotification<Block>,
>,
>,
pending_consenus_data_provider: Box<dyn ConsensusDataProvider<Block>>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
Expand All @@ -248,12 +240,7 @@ where
BE::Blockchain: BlockchainBackend<Block>,
A: ChainApi<Block = Block> + 'static,
{
create_full_rpc(
deps,
subscription_task_executor,
pubsub_notification_sinks,
pending_consenus_data_provider,
)
create_full_rpc(deps, subscription_task_executor, pubsub_notification_sinks)
}

fn create_full_rpc<C, P, BE, A>(
Expand All @@ -264,7 +251,6 @@ fn create_full_rpc<C, P, BE, A>(
fc_mapping_sync::EthereumBlockNotification<Block>,
>,
>,
pending_consenus_data_provider: Box<dyn ConsensusDataProvider<Block>>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
Expand Down Expand Up @@ -319,6 +305,14 @@ where

let no_tx_converter: Option<fp_rpc::NoTransactionConverter> = None;

if !client
.runtime_api()
.has_api::<dyn AuraApi<Block, AuraId>>(client.info().best_hash)
.unwrap_or_default()
{
return Err("EVM RPC cannot be enable at the current state. Please sync at least 200K blocks before enabling it.".into());
}

ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved
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();
Expand Down Expand Up @@ -368,7 +362,9 @@ where
10,
None,
pending_create_inherent_data_providers,
Some(pending_consenus_data_provider),
Some(Box::new(fc_rpc::pending::AuraConsensusDataProvider::new(
ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved
client.clone(),
))),
)
.replace_config::<AstarEthConfig<C, BE>>()
.into_rpc(),
Expand Down
Loading