Skip to content

Commit

Permalink
Add EGA for all impl blocks taking Eth struct (polkadot-evm#904)
Browse files Browse the repository at this point in the history
* Add EGA for all impl blocks taking Eth struct

* fix typo

* fix template

* better type inference by setting EGA with a dedicated function

* remove anotations

Co-authored-by: nanocryk <6422796+nanocryk@users.noreply.github.com>
  • Loading branch information
girazoki and nanocryk authored Jan 20, 2023
1 parent 239e040 commit 4afc9d4
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::{
frontier_backend_client, internal_err,
};

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA>
where
B: BlockT<Hash = H256> + Send + Sync + 'static,
C: StorageProvider<B, BE> + HeaderBackend<B> + Send + Sync + 'static,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use fp_rpc::EthereumRuntimeRPCApi;

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA>
where
B: BlockT<Hash = H256> + Send + Sync + 'static,
C: ProvideRuntimeApi<B> + StorageProvider<B, BE>,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use fp_rpc::EthereumRuntimeRPCApi;

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA>
where
B: BlockT<Hash = H256> + Send + Sync + 'static,
C: ProvideRuntimeApi<B> + StorageProvider<B, BE>,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use fc_rpc_core::types::*;

use crate::eth::Eth;

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A> {
impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA> {
pub fn is_mining(&self) -> Result<bool> {
Ok(self.is_authority)
}
Expand Down
45 changes: 43 additions & 2 deletions client/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct Eth<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA = ()> {
_marker: PhantomData<(B, BE, EGA)>,
}

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A> {
impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A, ()> {
pub fn new(
client: Arc<C>,
pool: Arc<P>,
Expand Down Expand Up @@ -114,8 +114,48 @@ impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A
}
}

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA> {
pub fn with_estimate_gas_adapter<EGA2: EstimateGasAdapter>(
self,
) -> Eth<B, C, P, CT, BE, H, A, EGA2> {
let Self {
client,
pool,
graph,
convert_transaction,
network,
is_authority,
signers,
overrides,
backend,
block_data_cache,
fee_history_cache,
fee_history_cache_limit,
execute_gas_limit_multiplier,
_marker: _,
} = self;

Eth {
client,
pool,
graph,
convert_transaction,
network,
is_authority,
signers,
overrides,
backend,
block_data_cache,
fee_history_cache,
fee_history_cache_limit,
execute_gas_limit_multiplier,
_marker: PhantomData,
}
}
}

#[async_trait]
impl<B, C, P, CT, BE, H: ExHashT, A> EthApiServer for Eth<B, C, P, CT, BE, H, A>
impl<B, C, P, CT, BE, H: ExHashT, A, EGA> EthApiServer for Eth<B, C, P, CT, BE, H, A, EGA>
where
B: BlockT<Hash = H256> + Send + Sync + 'static,
C: ProvideRuntimeApi<B> + StorageProvider<B, BE>,
Expand All @@ -126,6 +166,7 @@ where
BE: Backend<B> + 'static,
BE::State: StateBackend<BlakeTwo256>,
A: ChainApi<Block = B> + 'static,
EGA: EstimateGasAdapter + Send + Sync + 'static,
{
// ########################################################################
// Client
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::{
frontier_backend_client, internal_err,
};

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA>
where
B: BlockT<Hash = H256> + Send + Sync + 'static,
C: ProvideRuntimeApi<B> + StorageProvider<B, BE>,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::{
internal_err,
};

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA>
where
B: BlockT<Hash = H256> + Send + Sync + 'static,
C: ProvideRuntimeApi<B> + StorageProvider<B, BE>,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::{
frontier_backend_client, internal_err,
};

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi> Eth<B, C, P, CT, BE, H, A>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, EGA> Eth<B, C, P, CT, BE, H, A, EGA>
where
B: BlockT<Hash = H256> + Send + Sync + 'static,
C: ProvideRuntimeApi<B> + StorageProvider<B, BE> + HeaderBackend<B> + Send + Sync + 'static,
Expand Down

0 comments on commit 4afc9d4

Please sign in to comment.