git.delta.rocks / unique-network / refs/commits / 0b1e6ad66f4c

difftreelog

fix remove timestamp get from ethereum pending rpc

Yaroslav Bolyukin2023-11-02parent: #4f574e9.patch.diff
in: master
We have no use for aura digest in pending block.

1 file changed

modifiednode/cli/src/rpc.rsdiffbeforeafterboth
before · node/cli/src/rpc.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use std::sync::Arc;1819use fc_mapping_sync::{EthereumBlockNotification, EthereumBlockNotificationSinks};20use fc_rpc::{21	pending::AuraConsensusDataProvider, EthBlockDataCacheTask, EthConfig, OverrideHandle,22};23use fc_rpc_core::types::{FeeHistoryCache, FilterPool};24use fp_rpc::NoTransactionConverter;25use jsonrpsee::RpcModule;26use sc_client_api::{27	backend::{AuxStore, StorageProvider},28	client::BlockchainEvents,29	UsageProvider,30};31use sc_network::NetworkService;32use sc_network_sync::SyncingService;33use sc_rpc::SubscriptionTaskExecutor;34pub use sc_rpc_api::DenyUnsafe;35use sc_service::TransactionPool;36use sc_transaction_pool::{ChainApi, Pool};37use sp_api::ProvideRuntimeApi;38use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};39use sp_inherents::CreateInherentDataProviders;40use sp_runtime::traits::BlakeTwo256;41use up_common::types::opaque::*;4243use crate::service::RuntimeApiDep;4445#[cfg(feature = "pov-estimate")]46type FullBackend = sc_service::TFullBackend<Block>;4748/// Full client dependencies.49pub struct FullDeps<C, P, SC> {50	/// The client instance to use.51	pub client: Arc<C>,52	/// Transaction pool instance.53	pub pool: Arc<P>,54	/// The SelectChain Strategy55	pub select_chain: SC,56	/// Whether to deny unsafe calls57	pub deny_unsafe: DenyUnsafe,5859	/// Runtime identification (read from the chain spec)60	pub runtime_id: RuntimeId,61	/// Executor params for PoV estimating62	#[cfg(feature = "pov-estimate")]63	pub exec_params: uc_rpc::pov_estimate::ExecutorParams,64	/// Substrate Backend.65	#[cfg(feature = "pov-estimate")]66	pub backend: Arc<FullBackend>,67}6869/// Instantiate all Full RPC extensions.70pub fn create_full<C, P, SC, R, B>(71	io: &mut RpcModule<()>,72	deps: FullDeps<C, P, SC>,73) -> Result<(), Box<dyn std::error::Error + Send + Sync>>74where75	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,76	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,77	C: Send + Sync + 'static,78	C: BlockchainEvents<Block>,79	C::Api: RuntimeApiDep<R>,80	B: sc_client_api::Backend<Block> + Send + Sync + 'static,81	P: TransactionPool<Block = Block> + 'static,82	R: RuntimeInstance + Send + Sync + 'static,83	<R as RuntimeInstance>::CrossAccountId: serde::Serialize,84	C: sp_api::CallApiAt<85		sp_runtime::generic::Block<86			sp_runtime::generic::Header<u32, BlakeTwo256>,87			sp_runtime::OpaqueExtrinsic,88		>,89	>,90	for<'de> <R as RuntimeInstance>::CrossAccountId: serde::Deserialize<'de>,91{92	// use pallet_contracts_rpc::{Contracts, ContractsApi};93	use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};94	use substrate_frame_rpc_system::{System, SystemApiServer};95	#[cfg(feature = "pov-estimate")]96	use uc_rpc::pov_estimate::{PovEstimate, PovEstimateApiServer};97	use uc_rpc::{AppPromotion, AppPromotionApiServer, Unique, UniqueApiServer};9899	let FullDeps {100		client,101		pool,102		select_chain: _,103		deny_unsafe,104105		runtime_id: _,106107		#[cfg(feature = "pov-estimate")]108		exec_params,109110		#[cfg(feature = "pov-estimate")]111		backend,112	} = deps;113114	io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())?;115	io.merge(TransactionPayment::new(Arc::clone(&client)).into_rpc())?;116117	io.merge(Unique::new(client.clone()).into_rpc())?;118119	io.merge(AppPromotion::new(client).into_rpc())?;120121	#[cfg(feature = "pov-estimate")]122	io.merge(123		PovEstimate::new(124			client.clone(),125			backend,126			deny_unsafe,127			exec_params,128			runtime_id,129		)130		.into_rpc(),131	)?;132133	Ok(())134}135136pub struct EthDeps<C, P, CA: ChainApi, CIDP> {137	/// The client instance to use.138	pub client: Arc<C>,139	/// Transaction pool instance.140	pub pool: Arc<P>,141	/// Graph pool instance.142	pub graph: Arc<Pool<CA>>,143	/// Syncing service144	pub sync: Arc<SyncingService<Block>>,145	/// The Node authority flag146	pub is_authority: bool,147	/// Network service148	pub network: Arc<NetworkService<Block, Hash>>,149150	/// Ethereum Backend.151	pub eth_backend: Arc<dyn fc_api::Backend<Block> + Send + Sync>,152	/// Maximum number of logs in a query.153	pub max_past_logs: u32,154	/// Maximum fee history cache size.155	pub fee_history_limit: u64,156	/// Fee history cache.157	pub fee_history_cache: FeeHistoryCache,158	pub eth_block_data_cache: Arc<EthBlockDataCacheTask<Block>>,159	/// EthFilterApi pool.160	pub eth_filter_pool: Option<FilterPool>,161	pub eth_pubsub_notification_sinks:162		Arc<EthereumBlockNotificationSinks<EthereumBlockNotification<Block>>>,163	/// Whether to enable eth dev signer164	pub enable_dev_signer: bool,165166	pub overrides: Arc<OverrideHandle<Block>>,167	pub pending_create_inherent_data_providers: CIDP,168}169170pub fn create_eth<C, R, P, CA, B, CIDP, EC>(171	io: &mut RpcModule<()>,172	deps: EthDeps<C, P, CA, CIDP>,173	subscription_task_executor: SubscriptionTaskExecutor,174) -> Result<(), Box<dyn std::error::Error + Send + Sync>>175where176	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,177	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,178	C: Send + Sync + 'static,179	C: BlockchainEvents<Block>,180	C: UsageProvider<Block>,181	C::Api: RuntimeApiDep<R>,182	P: TransactionPool<Block = Block> + 'static,183	CA: ChainApi<Block = Block> + 'static,184	B: sc_client_api::Backend<Block> + Send + Sync + 'static,185	C: sp_api::CallApiAt<Block>,186	CIDP: CreateInherentDataProviders<Block, ()> + Send + 'static,187	EC: EthConfig<Block, C>,188	R: RuntimeInstance,189{190	use fc_rpc::{191		Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub,192		EthPubSubApiServer, EthSigner, Net, NetApiServer, Web3, Web3ApiServer,193	};194195	let EthDeps {196		client,197		pool,198		graph,199		eth_backend,200		max_past_logs,201		fee_history_limit,202		fee_history_cache,203		eth_block_data_cache,204		eth_filter_pool,205		eth_pubsub_notification_sinks,206		enable_dev_signer,207		sync,208		is_authority,209		network,210		overrides,211		pending_create_inherent_data_providers,212	} = deps;213214	let mut signers = Vec::new();215	if enable_dev_signer {216		signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);217	}218	let execute_gas_limit_multiplier = 10;219	io.merge(220		Eth::<_, _, _, _, _, _, _, EC>::new(221			client.clone(),222			pool.clone(),223			graph.clone(),224			// We have no runtimes old enough to only accept converted transactions225			None::<NoTransactionConverter>,226			sync.clone(),227			signers,228			overrides.clone(),229			eth_backend.clone(),230			is_authority,231			eth_block_data_cache.clone(),232			fee_history_cache,233			fee_history_limit,234			execute_gas_limit_multiplier,235			None,236			pending_create_inherent_data_providers,237			Some(Box::new(AuraConsensusDataProvider::new(client.clone()))),238		)239		.into_rpc(),240	)?;241242	if let Some(filter_pool) = eth_filter_pool {243		io.merge(244			EthFilter::new(245				client.clone(),246				eth_backend,247				graph,248				filter_pool,249				500_usize, // max stored filters250				max_past_logs,251				eth_block_data_cache,252			)253			.into_rpc(),254		)?;255	}256	io.merge(257		Net::new(258			client.clone(),259			network,260			// Whether to format the `peer_count` response as Hex (default) or not.261			true,262		)263		.into_rpc(),264	)?;265	io.merge(Web3::new(client.clone()).into_rpc())?;266	io.merge(267		EthPubSub::new(268			pool,269			client,270			sync,271			subscription_task_executor,272			overrides,273			eth_pubsub_notification_sinks,274		)275		.into_rpc(),276	)?;277278	Ok(())279}
after · node/cli/src/rpc.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use std::sync::Arc;1819use fc_mapping_sync::{EthereumBlockNotification, EthereumBlockNotificationSinks};20use fc_rpc::{EthBlockDataCacheTask, EthConfig, OverrideHandle};21use fc_rpc_core::types::{FeeHistoryCache, FilterPool};22use fp_rpc::NoTransactionConverter;23use jsonrpsee::RpcModule;24use sc_client_api::{25	backend::{AuxStore, StorageProvider},26	client::BlockchainEvents,27	UsageProvider,28};29use sc_network::NetworkService;30use sc_network_sync::SyncingService;31use sc_rpc::SubscriptionTaskExecutor;32pub use sc_rpc_api::DenyUnsafe;33use sc_service::TransactionPool;34use sc_transaction_pool::{ChainApi, Pool};35use sp_api::ProvideRuntimeApi;36use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};37use sp_inherents::CreateInherentDataProviders;38use sp_runtime::traits::BlakeTwo256;39use up_common::types::opaque::*;4041use crate::service::RuntimeApiDep;4243#[cfg(feature = "pov-estimate")]44type FullBackend = sc_service::TFullBackend<Block>;4546/// Full client dependencies.47pub struct FullDeps<C, P, SC> {48	/// The client instance to use.49	pub client: Arc<C>,50	/// Transaction pool instance.51	pub pool: Arc<P>,52	/// The SelectChain Strategy53	pub select_chain: SC,54	/// Whether to deny unsafe calls55	pub deny_unsafe: DenyUnsafe,5657	/// Runtime identification (read from the chain spec)58	pub runtime_id: RuntimeId,59	/// Executor params for PoV estimating60	#[cfg(feature = "pov-estimate")]61	pub exec_params: uc_rpc::pov_estimate::ExecutorParams,62	/// Substrate Backend.63	#[cfg(feature = "pov-estimate")]64	pub backend: Arc<FullBackend>,65}6667/// Instantiate all Full RPC extensions.68pub fn create_full<C, P, SC, R, B>(69	io: &mut RpcModule<()>,70	deps: FullDeps<C, P, SC>,71) -> Result<(), Box<dyn std::error::Error + Send + Sync>>72where73	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,74	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,75	C: Send + Sync + 'static,76	C: BlockchainEvents<Block>,77	C::Api: RuntimeApiDep<R>,78	B: sc_client_api::Backend<Block> + Send + Sync + 'static,79	P: TransactionPool<Block = Block> + 'static,80	R: RuntimeInstance + Send + Sync + 'static,81	<R as RuntimeInstance>::CrossAccountId: serde::Serialize,82	C: sp_api::CallApiAt<83		sp_runtime::generic::Block<84			sp_runtime::generic::Header<u32, BlakeTwo256>,85			sp_runtime::OpaqueExtrinsic,86		>,87	>,88	for<'de> <R as RuntimeInstance>::CrossAccountId: serde::Deserialize<'de>,89{90	// use pallet_contracts_rpc::{Contracts, ContractsApi};91	use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};92	use substrate_frame_rpc_system::{System, SystemApiServer};93	#[cfg(feature = "pov-estimate")]94	use uc_rpc::pov_estimate::{PovEstimate, PovEstimateApiServer};95	use uc_rpc::{AppPromotion, AppPromotionApiServer, Unique, UniqueApiServer};9697	let FullDeps {98		client,99		pool,100		select_chain: _,101		deny_unsafe,102103		runtime_id: _,104105		#[cfg(feature = "pov-estimate")]106		exec_params,107108		#[cfg(feature = "pov-estimate")]109		backend,110	} = deps;111112	io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())?;113	io.merge(TransactionPayment::new(Arc::clone(&client)).into_rpc())?;114115	io.merge(Unique::new(client.clone()).into_rpc())?;116117	io.merge(AppPromotion::new(client).into_rpc())?;118119	#[cfg(feature = "pov-estimate")]120	io.merge(121		PovEstimate::new(122			client.clone(),123			backend,124			deny_unsafe,125			exec_params,126			runtime_id,127		)128		.into_rpc(),129	)?;130131	Ok(())132}133134pub struct EthDeps<C, P, CA: ChainApi, CIDP> {135	/// The client instance to use.136	pub client: Arc<C>,137	/// Transaction pool instance.138	pub pool: Arc<P>,139	/// Graph pool instance.140	pub graph: Arc<Pool<CA>>,141	/// Syncing service142	pub sync: Arc<SyncingService<Block>>,143	/// The Node authority flag144	pub is_authority: bool,145	/// Network service146	pub network: Arc<NetworkService<Block, Hash>>,147148	/// Ethereum Backend.149	pub eth_backend: Arc<dyn fc_api::Backend<Block> + Send + Sync>,150	/// Maximum number of logs in a query.151	pub max_past_logs: u32,152	/// Maximum fee history cache size.153	pub fee_history_limit: u64,154	/// Fee history cache.155	pub fee_history_cache: FeeHistoryCache,156	pub eth_block_data_cache: Arc<EthBlockDataCacheTask<Block>>,157	/// EthFilterApi pool.158	pub eth_filter_pool: Option<FilterPool>,159	pub eth_pubsub_notification_sinks:160		Arc<EthereumBlockNotificationSinks<EthereumBlockNotification<Block>>>,161	/// Whether to enable eth dev signer162	pub enable_dev_signer: bool,163164	pub overrides: Arc<OverrideHandle<Block>>,165	pub pending_create_inherent_data_providers: CIDP,166}167168pub fn create_eth<C, R, P, CA, B, CIDP, EC>(169	io: &mut RpcModule<()>,170	deps: EthDeps<C, P, CA, CIDP>,171	subscription_task_executor: SubscriptionTaskExecutor,172) -> Result<(), Box<dyn std::error::Error + Send + Sync>>173where174	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,175	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,176	C: Send + Sync + 'static,177	C: BlockchainEvents<Block>,178	C: UsageProvider<Block>,179	C::Api: RuntimeApiDep<R>,180	P: TransactionPool<Block = Block> + 'static,181	CA: ChainApi<Block = Block> + 'static,182	B: sc_client_api::Backend<Block> + Send + Sync + 'static,183	C: sp_api::CallApiAt<Block>,184	CIDP: CreateInherentDataProviders<Block, ()> + Send + 'static,185	EC: EthConfig<Block, C>,186	R: RuntimeInstance,187{188	use fc_rpc::{189		Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub,190		EthPubSubApiServer, EthSigner, Net, NetApiServer, Web3, Web3ApiServer,191	};192193	let EthDeps {194		client,195		pool,196		graph,197		eth_backend,198		max_past_logs,199		fee_history_limit,200		fee_history_cache,201		eth_block_data_cache,202		eth_filter_pool,203		eth_pubsub_notification_sinks,204		enable_dev_signer,205		sync,206		is_authority,207		network,208		overrides,209		pending_create_inherent_data_providers,210	} = deps;211212	let mut signers = Vec::new();213	if enable_dev_signer {214		signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);215	}216	let execute_gas_limit_multiplier = 10;217	io.merge(218		Eth::<_, _, _, _, _, _, _, EC>::new(219			client.clone(),220			pool.clone(),221			graph.clone(),222			// We have no runtimes old enough to only accept converted transactions.223			None::<NoTransactionConverter>,224			sync.clone(),225			signers,226			overrides.clone(),227			eth_backend.clone(),228			is_authority,229			eth_block_data_cache.clone(),230			fee_history_cache,231			fee_history_limit,232			execute_gas_limit_multiplier,233			None,234			pending_create_inherent_data_providers,235			// Our extrinsics have nothing to do with consensus digest items yet.236			None,237		)238		.into_rpc(),239	)?;240241	if let Some(filter_pool) = eth_filter_pool {242		io.merge(243			EthFilter::new(244				client.clone(),245				eth_backend,246				graph,247				filter_pool,248				500_usize, // max stored filters249				max_past_logs,250				eth_block_data_cache,251			)252			.into_rpc(),253		)?;254	}255	io.merge(256		Net::new(257			client.clone(),258			network,259			// Whether to format the `peer_count` response as Hex (default) or not.260			true,261		)262		.into_rpc(),263	)?;264	io.merge(Web3::new(client.clone()).into_rpc())?;265	io.merge(266		EthPubSub::new(267			pool,268			client,269			sync,270			subscription_task_executor,271			overrides,272			eth_pubsub_notification_sinks,273		)274		.into_rpc(),275	)?;276277	Ok(())278}