git.delta.rocks / unique-network / refs/commits / e6ed5f4e38db

difftreelog

refactor use build_network from cumulus_client_service

Yaroslav Bolyukin2024-06-19parent: #72b9f19.patch.diff
in: master

2 files changed

modifiednode/cli/src/rpc.rsdiffbeforeafterboth
43type FullBackend = sc_service::TFullBackend<Block>;43type FullBackend = sc_service::TFullBackend<Block>;
4444
45/// Full client dependencies.45/// Full client dependencies.
46pub struct FullDeps<C, P, SC> {46pub struct FullDeps<C, P> {
47 /// The client instance to use.47 /// The client instance to use.
48 pub client: Arc<C>,48 pub client: Arc<C>,
49 /// Transaction pool instance.49 /// Transaction pool instance.
50 pub pool: Arc<P>,50 pub pool: Arc<P>,
51 /// The SelectChain Strategy
52 pub select_chain: SC,
53 /// Whether to deny unsafe calls51 /// Whether to deny unsafe calls
54 pub deny_unsafe: DenyUnsafe,52 pub deny_unsafe: DenyUnsafe,
55
56 /// Runtime identification (read from the chain spec)
57 pub runtime_id: RuntimeId,
58 /// Executor params for PoV estimating53 /// Executor params for PoV estimating
59 #[cfg(feature = "pov-estimate")]54 #[cfg(feature = "pov-estimate")]
60 pub exec_params: uc_rpc::pov_estimate::ExecutorParams,55 pub exec_params: uc_rpc::pov_estimate::ExecutorParams,
64}59}
6560
66/// Instantiate all Full RPC extensions.61/// Instantiate all Full RPC extensions.
67pub fn create_full<C, P, SC, R, B>(62pub fn create_full<C, P, R, B>(
68 io: &mut RpcModule<()>,63 io: &mut RpcModule<()>,
69 deps: FullDeps<C, P, SC>,64 deps: FullDeps<C, P>,
70) -> Result<(), Box<dyn std::error::Error + Send + Sync>>65) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
71where66where
72 C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,67 C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,
93 let FullDeps {88 let FullDeps {
94 client,89 client,
95 pool,90 pool,
96 select_chain: _,
97 deny_unsafe,91 deny_unsafe,
98
99 runtime_id: _,
10092
101 #[cfg(feature = "pov-estimate")]93 #[cfg(feature = "pov-estimate")]
102 exec_params,94 exec_params,
modifiednode/cli/src/service.rsdiffbeforeafterboth
37use cumulus_client_consensus_proposer::Proposer;37use cumulus_client_consensus_proposer::Proposer;
38use cumulus_client_service::{38use cumulus_client_service::{
39 build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, DARecoveryProfile,39 build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
40 StartRelayChainTasksParams,40 CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
41};41};
42use cumulus_primitives_core::ParaId;42use cumulus_primitives_core::ParaId;
43use cumulus_primitives_parachain_inherent::ParachainInherentData;43use cumulus_primitives_parachain_inherent::ParachainInherentData;
85use cumulus_primitives_core::PersistedValidationData;85use cumulus_primitives_core::PersistedValidationData;
86use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;86use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
8787
88use crate::{88use crate::rpc::{create_eth, create_full, EthDeps, FullDeps};
89 chain_spec::RuntimeIdentification,
90 rpc::{create_eth, create_full, EthDeps, FullDeps},
91};
9289
93/// Unique native executor instance.90/// Unique native executor instance.
94#[cfg(feature = "unique-runtime")]91#[cfg(feature = "unique-runtime")]
429 .await426 .await
430 .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;427 .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
431
432 // Aura is sybil-resistant, collator-selection is generally too.
433 let block_announce_validator =
434 cumulus_client_network::AssumeSybilResistance::allow_seconded_messages();
435428
436 let validator = parachain_config.role.is_authority();429 let validator = parachain_config.role.is_authority();
437 let prometheus_registry = parachain_config.prometheus_registry().cloned();430 let prometheus_registry = parachain_config.prometheus_registry().cloned();
438 let transaction_pool = params.transaction_pool.clone();431 let transaction_pool = params.transaction_pool.clone();
439 let import_queue_service = params.import_queue.service();432 let import_queue_service = params.import_queue.service();
440433
441 let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =434 let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
442 sc_service::build_network(sc_service::BuildNetworkParams {435 cumulus_client_service::build_network(cumulus_client_service::BuildNetworkParams {
443 config: &parachain_config,436 parachain_config: &parachain_config,
444 net_config,437 net_config,
445 client: client.clone(),438 client: client.clone(),
446 transaction_pool: transaction_pool.clone(),439 transaction_pool: transaction_pool.clone(),
440 para_id,
447 spawn_handle: task_manager.spawn_handle(),441 spawn_handle: task_manager.spawn_handle(),
442 relay_chain_interface: relay_chain_interface.clone(),
448 import_queue: params.import_queue,443 import_queue: params.import_queue,
444 // Aura is sybil-resistant, collator-selection is generally too.
449 block_announce_validator_builder: Some(Box::new(|_| {445 sybil_resistance_level: CollatorSybilResistance::Resistant,
450 Box::new(block_announce_validator)
451 })),
452 warp_sync_params: None,
453 block_relay: None,
454 })?;446 })
455447 .await?;
456 let select_chain = params.select_chain.clone();
457
458 let runtime_id = parachain_config.chain_spec.runtime_id();
459448
460 // Frontier449 // Frontier
461 let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));450 let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
508 fee_history_cache,497 fee_history_cache,
509 eth_block_data_cache,498 eth_block_data_cache,
510 network,499 network,
511 runtime_id,
512 transaction_pool,500 transaction_pool,
513 select_chain,
514 overrides,501 overrides,
515 );502 );
516503
521508
522 let full_deps = FullDeps {509 let full_deps = FullDeps {
523 client: client.clone(),510 client: client.clone(),
524 runtime_id,
525511
526 #[cfg(feature = "pov-estimate")]512 #[cfg(feature = "pov-estimate")]
527 exec_params: uc_rpc::pov_estimate::ExecutorParams {513 exec_params: uc_rpc::pov_estimate::ExecutorParams {
536522
537 deny_unsafe,523 deny_unsafe,
538 pool: transaction_pool.clone(),524 pool: transaction_pool.clone(),
539 select_chain,
540 };525 };
541526
542 create_full::<_, _, _, Runtime, _>(&mut rpc_handle, full_deps)?;527 create_full::<_, _, Runtime, _>(&mut rpc_handle, full_deps)?;
543528
544 let eth_deps = EthDeps {529 let eth_deps = EthDeps {
545 client,530 client,
1044 #[cfg(feature = "pov-estimate")]1029 #[cfg(feature = "pov-estimate")]
1045 let rpc_backend = backend.clone();1030 let rpc_backend = backend.clone();
1046
1047 let runtime_id = config.chain_spec.runtime_id();
10481031
1049 // Frontier1032 // Frontier
1050 let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));1033 let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
1097 fee_history_cache,1080 fee_history_cache,
1098 eth_block_data_cache,1081 eth_block_data_cache,
1099 network,1082 network,
1100 runtime_id,
1101 transaction_pool,1083 transaction_pool,
1102 select_chain,
1103 overrides,1084 overrides,
1104 );1085 );
11051086
1109 let mut rpc_module = RpcModule::new(());1090 let mut rpc_module = RpcModule::new(());
11101091
1111 let full_deps = FullDeps {1092 let full_deps = FullDeps {
1112 runtime_id,
1113
1114 #[cfg(feature = "pov-estimate")]1093 #[cfg(feature = "pov-estimate")]
1115 exec_params: uc_rpc::pov_estimate::ExecutorParams {1094 exec_params: uc_rpc::pov_estimate::ExecutorParams {
1125 deny_unsafe,1104 deny_unsafe,
1126 client: client.clone(),1105 client: client.clone(),
1127 pool: transaction_pool.clone(),1106 pool: transaction_pool.clone(),
1128 select_chain,
1129 };1107 };
11301108
1131 create_full::<_, _, _, Runtime, _>(&mut rpc_module, full_deps)?;1109 create_full::<_, _, Runtime, _>(&mut rpc_module, full_deps)?;
11321110
1133 let eth_deps = EthDeps {1111 let eth_deps = EthDeps {
1134 client,1112 client,