Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ sc-network = { workspace = true }
sc-network-sync = { workspace = true }
sc-rpc = { workspace = true }
sc-service = { workspace = true }
sc-transaction-pool = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sc-utils = { workspace = true }
sp-api = { workspace = true, features = ["default"] }
Expand Down
15 changes: 5 additions & 10 deletions client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use ethereum_types::{H256, U256};
use jsonrpsee::core::RpcResult;
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sc_transaction_pool_api::InPoolTransaction;
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::hashing::keccak_256;
Expand All @@ -37,14 +36,14 @@ use crate::{
frontier_backend_client, internal_err,
};

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
A: ChainApi<Block = B>,
P: TransactionPool<Block = B, Hash = B::Hash> + 'static,
{
pub async fn block_by_hash(&self, hash: H256, full: bool) -> RpcResult<Option<RichBlock>> {
let BlockInfo {
Expand Down Expand Up @@ -145,7 +144,6 @@ where
// ready validated pool
xts.extend(
graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
Expand All @@ -154,10 +152,9 @@ where
// future validated pool
xts.extend(
graph
.validated_pool()
.futures()
.iter()
.map(|(_hash, extrinsic)| extrinsic.as_ref().clone())
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
.collect::<Vec<<B as BlockT>::Extrinsic>>(),
);

Expand Down Expand Up @@ -197,9 +194,7 @@ where
) -> RpcResult<Option<U256>> {
if let BlockNumberOrHash::Pending = number_or_hash {
// get the pending transactions count
return Ok(Some(U256::from(
self.graph.validated_pool().ready().count(),
)));
return Ok(Some(U256::from(self.graph.ready().count())));
}

let block_info = self.block_info_by_number(number_or_hash).await?;
Expand Down
4 changes: 1 addition & 3 deletions client/rpc/src/eth/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use ethereum_types::{H160, U256, U64};
use jsonrpsee::core::RpcResult;
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::SyncOracle;
Expand All @@ -31,14 +30,13 @@ use fp_rpc::EthereumRuntimeRPCApi;

use crate::{eth::Eth, internal_err};

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B>,
A: ChainApi<Block = B>,
{
pub fn protocol_version(&self) -> RpcResult<u64> {
Ok(1)
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use jsonrpsee::{core::RpcResult, types::error::CALL_EXECUTION_FAILED_CODE};
use scale_codec::{Decode, Encode};
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sc_transaction_pool_api::TransactionPool;
use sp_api::{ApiExt, CallApiAt, CallApiAtParams, CallContext, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::HeaderBackend;
Expand Down Expand Up @@ -65,16 +65,16 @@ impl EstimateGasAdapter for () {
}
}

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: CallApiAt<B> + ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B> + EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
A: ChainApi<Block = B>,
CIDP: CreateInherentDataProviders<B, ()> + Send + 'static,
EC: EthConfig<B, C>,
P: TransactionPool<Block = B, Hash = B::Hash> + 'static,
{
pub async fn call(
&self,
Expand Down
4 changes: 1 addition & 3 deletions client/rpc/src/eth/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use ethereum_types::U256;
use jsonrpsee::core::RpcResult;
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::{
Expand All @@ -33,14 +32,13 @@ use fp_rpc::EthereumRuntimeRPCApi;

use crate::{eth::Eth, frontier_backend_client, internal_err};

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
A: ChainApi<Block = B>,
{
pub fn gas_price(&self) -> RpcResult<U256> {
let block_hash = self.client.info().best_hash;
Expand Down
21 changes: 9 additions & 12 deletions client/rpc/src/eth/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ use ethereum_types::{H256, U256};
use jsonrpsee::core::{async_trait, RpcResult};
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::InPoolTransaction;
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::hashing::keccak_256;
Expand All @@ -43,22 +42,22 @@ use fp_rpc::{EthereumRuntimeRPCApi, TransactionStatus};

use crate::{cache::EthBlockDataCacheTask, frontier_backend_client, internal_err};

pub struct EthFilter<B: BlockT, C, BE, A: ChainApi> {
pub struct EthFilter<B: BlockT, C, BE, P> {
client: Arc<C>,
backend: Arc<dyn fc_api::Backend<B>>,
graph: Arc<Pool<A>>,
graph: Arc<P>,
filter_pool: FilterPool,
max_stored_filters: usize,
max_past_logs: u32,
block_data_cache: Arc<EthBlockDataCacheTask<B>>,
_marker: PhantomData<BE>,
}

impl<B: BlockT, C, BE, A: ChainApi> EthFilter<B, C, BE, A> {
impl<B: BlockT, C, BE, P: TransactionPool> EthFilter<B, C, BE, P> {
pub fn new(
client: Arc<C>,
backend: Arc<dyn fc_api::Backend<B>>,
graph: Arc<Pool<A>>,
graph: Arc<P>,
filter_pool: FilterPool,
max_stored_filters: usize,
max_past_logs: u32,
Expand All @@ -77,13 +76,13 @@ impl<B: BlockT, C, BE, A: ChainApi> EthFilter<B, C, BE, A> {
}
}

impl<B, C, BE, A> EthFilter<B, C, BE, A>
impl<B, C, BE, P> EthFilter<B, C, BE, P>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + 'static,
A: ChainApi<Block = B> + 'static,
P: TransactionPool<Block = B, Hash = B::Hash> + 'static,
{
fn create_filter(&self, filter_type: FilterType) -> RpcResult<U256> {
let info = self.client.info();
Expand All @@ -109,7 +108,6 @@ where
let pending_transaction_hashes = if let FilterType::PendingTransaction = filter_type {
let txs_ready = self
.graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
.collect();
Expand Down Expand Up @@ -146,14 +144,14 @@ where
}

#[async_trait]
impl<B, C, BE, A> EthFilterApiServer for EthFilter<B, C, BE, A>
impl<B, C, BE, P> EthFilterApiServer for EthFilter<B, C, BE, P>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
A: ChainApi<Block = B> + 'static,
P: TransactionPool<Block = B, Hash = B::Hash> + 'static,
{
fn new_filter(&self, filter: Filter) -> RpcResult<U256> {
self.create_filter(FilterType::Log(filter))
Expand Down Expand Up @@ -223,7 +221,6 @@ where
let previous_hashes = pool_item.pending_transaction_hashes;
let txs_ready = self
.graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
.collect();
Expand Down
4 changes: 1 addition & 3 deletions client/rpc/src/eth/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
use ethereum_types::{H256, H64, U256};
use jsonrpsee::core::RpcResult;
// Substrate
use sc_transaction_pool::ChainApi;
use sp_runtime::traits::Block as BlockT;
// Frontier
use fc_rpc_core::types::*;

use crate::eth::Eth;

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
A: ChainApi<Block = B>,
{
pub fn is_mining(&self) -> RpcResult<bool> {
Ok(self.is_authority)
Expand Down
20 changes: 8 additions & 12 deletions client/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use jsonrpsee::core::{async_trait, RpcResult};
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_network_sync::SyncingService;
use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::TransactionPool;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
Expand Down Expand Up @@ -71,9 +70,9 @@ impl<B: BlockT, C> EthConfig<B, C> for () {
}

/// Eth API implementation.
pub struct Eth<B: BlockT, C, P, CT, BE, A: ChainApi, CIDP, EC> {
pub struct Eth<B: BlockT, C, P, CT, BE, CIDP, EC> {
pool: Arc<P>,
graph: Arc<Pool<A>>,
graph: Arc<P>,
client: Arc<C>,
convert_transaction: Option<CT>,
sync: Arc<SyncingService<B>>,
Expand All @@ -94,19 +93,18 @@ pub struct Eth<B: BlockT, C, P, CT, BE, A: ChainApi, CIDP, EC> {
_marker: PhantomData<(BE, EC)>,
}

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
A: ChainApi<Block = B>,
{
pub fn new(
client: Arc<C>,
pool: Arc<P>,
graph: Arc<Pool<A>>,
graph: Arc<P>,
convert_transaction: Option<CT>,
sync: Arc<SyncingService<B>>,
signers: Vec<Box<dyn EthSigner>>,
Expand Down Expand Up @@ -247,13 +245,12 @@ where
}
}

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
A: ChainApi<Block = B>,
EC: EthConfig<B, C>,
{
pub fn replace_config<EC2: EthConfig<B, C>>(self) -> Eth<B, C, P, CT, BE, A, CIDP, EC2> {
pub fn replace_config<EC2: EthConfig<B, C>>(self) -> Eth<B, C, P, CT, BE, CIDP, EC2> {
let Self {
client,
pool,
Expand Down Expand Up @@ -297,16 +294,15 @@ where
}

#[async_trait]
impl<B, C, P, CT, BE, A, CIDP, EC> EthApiServer for Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> EthApiServer for Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: CallApiAt<B> + ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B> + ConvertTransactionRuntimeApi<B> + EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
P: TransactionPool<Block = B> + 'static,
P: TransactionPool<Block = B, Hash = B::Hash> + 'static,
CT: ConvertTransaction<<B as BlockT>::Extrinsic> + Send + Sync + 'static,
A: ChainApi<Block = B> + 'static,
CIDP: CreateInherentDataProviders<B, ()> + Send + 'static,
EC: EthConfig<B, C>,
{
Expand Down
8 changes: 3 additions & 5 deletions client/rpc/src/eth/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sc_transaction_pool_api::InPoolTransaction;
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool};
use sp_api::{ApiExt, ApiRef, Core, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{ApplyExtrinsicFailed, HeaderBackend};
Expand Down Expand Up @@ -50,16 +49,16 @@ pub(crate) enum Error {
ApplyExtrinsicFailed(#[from] ApplyExtrinsicFailed),
}

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B>,
A: ChainApi<Block = B>,
CIDP: CreateInherentDataProviders<B, ()> + Send + 'static,
P: TransactionPool<Block = B, Hash = B::Hash> + 'static,
{
/// Creates a pending runtime API.
pub(crate) async fn pending_runtime_api(&self) -> Result<(B::Hash, ApiRef<C::Api>), Error> {
Expand Down Expand Up @@ -123,7 +122,6 @@ where
// Get all extrinsics from the ready queue.
let extrinsics: Vec<<B as BlockT>::Extrinsic> = self
.graph
.validated_pool()
.ready()
.map(|in_pool_tx| in_pool_tx.data().as_ref().clone())
.collect::<Vec<<B as BlockT>::Extrinsic>>();
Expand Down
6 changes: 2 additions & 4 deletions client/rpc/src/eth/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use jsonrpsee::core::RpcResult;
use scale_codec::Encode;
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool};
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder as BlockBuilderApi;
Expand All @@ -34,15 +33,14 @@ use fp_rpc::EthereumRuntimeRPCApi;

use crate::{eth::Eth, frontier_backend_client, internal_err};

impl<B, C, P, CT, BE, A, CIDP, EC> Eth<B, C, P, CT, BE, A, CIDP, EC>
impl<B, C, P, CT, BE, CIDP, EC> Eth<B, C, P, CT, BE, CIDP, EC>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B> + EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
P: TransactionPool<Block = B> + 'static,
A: ChainApi<Block = B>,
P: TransactionPool<Block = B, Hash = B::Hash> + 'static,
CIDP: CreateInherentDataProviders<B, ()> + Send + 'static,
{
pub async fn balance(
Expand Down
Loading
Loading