Skip to content

Commit

Permalink
name refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec committed Mar 25, 2023
1 parent 56f74c9 commit 7f57f01
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 39 deletions.
4 changes: 2 additions & 2 deletions client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ use sp_core::hashing::keccak_256;
use sp_runtime::traits::Block as BlockT;
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::{EthereumRuntimeAddressMapping, EthereumRuntimeRPCApi};
use fp_rpc::{EthereumRuntimeRPCApi, EvmRuntimeAddressMapping};

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
where
B: BlockT,
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ use sp_consensus::SyncOracle;
use sp_runtime::traits::{Block as BlockT, UniqueSaturatedInto};
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::{EthereumRuntimeAddressMapping, EthereumRuntimeRPCApi};
use fp_rpc::{EthereumRuntimeRPCApi, EvmRuntimeAddressMapping};

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
where
B: BlockT,
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use sp_io::hashing::{blake2_128, twox_128};
use sp_runtime::{traits::Block as BlockT, SaturatedConversion};
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::{EthereumRuntimeAddressMapping, EthereumRuntimeRPCApi};
use fp_rpc::{EthereumRuntimeRPCApi, EvmRuntimeAddressMapping};
use fp_storage::{EVM_ACCOUNT_CODES, PALLET_EVM};

use crate::{
Expand Down Expand Up @@ -62,7 +62,7 @@ impl EstimateGasAdapter for () {
}
}

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
where
B: BlockT,
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ use sp_blockchain::HeaderBackend;
use sp_runtime::traits::{Block as BlockT, UniqueSaturatedInto};
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::{EthereumRuntimeAddressMapping, EthereumRuntimeRPCApi};
use fp_rpc::{EthereumRuntimeRPCApi, EvmRuntimeAddressMapping};

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
where
B: BlockT,
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ use sc_transaction_pool::ChainApi;
use sp_runtime::traits::Block as BlockT;
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::EthereumRuntimeAddressMapping;
use fp_rpc::EvmRuntimeAddressMapping;

use crate::eth::Eth;

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
{
pub fn is_mining(&self) -> Result<bool> {
Expand Down
17 changes: 8 additions & 9 deletions client/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ use sp_runtime::traits::{Block as BlockT, UniqueSaturatedInto};
use fc_rpc_core::{types::*, EthApiServer};
use fc_storage::OverrideHandle;
use fp_rpc::{
ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeAddressMapping,
EthereumRuntimeRPCApi, EthereumRuntimeStorageOverride, TransactionStatus,
ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi,
EvmRuntimeAddressMapping, EvmRuntimeStorageOverride, TransactionStatus,
};

use crate::{internal_err, public_key, signer::EthSigner};
Expand All @@ -69,7 +69,7 @@ pub struct Eth<
BE,
H: ExHashT,
A: ChainApi,
M: EthereumRuntimeAddressMapping,
M: EvmRuntimeAddressMapping,
EGA = (),
> {
pool: Arc<P>,
Expand All @@ -87,12 +87,11 @@ pub struct Eth<
/// When using eth_call/eth_estimateGas, the maximum allowed gas limit will be
/// block.gas_limit * execute_gas_limit_multiplier
execute_gas_limit_multiplier: u64,
runtime_state_override:
Option<Arc<dyn EthereumRuntimeStorageOverride<B, C, AddressMapping = M>>>,
runtime_state_override: Option<Arc<dyn EvmRuntimeStorageOverride<B, C, AddressMapping = M>>>,
_marker: PhantomData<(B, BE, EGA)>,
}

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping>
impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping>
Eth<B, C, P, CT, BE, H, A, M, ()>
{
pub fn new(
Expand All @@ -110,7 +109,7 @@ impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddress
fee_history_cache_limit: FeeHistoryCacheLimit,
execute_gas_limit_multiplier: u64,
runtime_state_override: Option<
Arc<dyn EthereumRuntimeStorageOverride<B, C, AddressMapping = M>>,
Arc<dyn EvmRuntimeStorageOverride<B, C, AddressMapping = M>>,
>,
) -> Self {
Self {
Expand All @@ -133,7 +132,7 @@ impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddress
}
}

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
{
pub fn with_estimate_gas_adapter<EGA2: EstimateGasAdapter>(
Expand Down Expand Up @@ -188,7 +187,7 @@ where
P: TransactionPool<Block = B> + 'static,
CT: ConvertTransaction<<B as BlockT>::Extrinsic> + Send + Sync + 'static,
A: ChainApi<Block = B> + 'static,
M: EthereumRuntimeAddressMapping + 'static,
M: EvmRuntimeAddressMapping + 'static,
EGA: EstimateGasAdapter + Send + Sync + 'static,
{
// ########################################################################
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::{EthereumRuntimeAddressMapping, EthereumRuntimeRPCApi};
use fp_rpc::{EthereumRuntimeRPCApi, EvmRuntimeAddressMapping};

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
where
B: BlockT,
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/eth/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ use sp_runtime::{
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::{
ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeAddressMapping,
EthereumRuntimeRPCApi,
ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi,
EvmRuntimeAddressMapping,
};

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
where
B: BlockT,
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ use sp_core::hashing::keccak_256;
use sp_runtime::traits::Block as BlockT;
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::{EthereumRuntimeAddressMapping, EthereumRuntimeRPCApi};
use fp_rpc::{EthereumRuntimeRPCApi, EvmRuntimeAddressMapping};

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

impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EthereumRuntimeAddressMapping, EGA>
impl<B, C, P, CT, BE, H: ExHashT, A: ChainApi, M: EvmRuntimeAddressMapping, EGA>
Eth<B, C, P, CT, BE, H, A, M, EGA>
where
B: BlockT,
Expand Down
7 changes: 3 additions & 4 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ pub mod frontier_backend_client {
/// Implements a default runtime storage override.
/// It assumes that the balances and nonces are stored in pallet `system.account`, and
/// have `nonce: Index` = `u32` for and `free: Balance` = `u128`.
pub struct DefaultEthereumRuntimeStorageOverride<M>(pub std::marker::PhantomData<M>);
impl<M, B, C> fp_rpc::EthereumRuntimeStorageOverride<B, C>
for DefaultEthereumRuntimeStorageOverride<M>
pub struct DefaultEvmRuntimeStorageOverride<M>(pub std::marker::PhantomData<M>);
impl<M, B, C> fp_rpc::EvmRuntimeStorageOverride<B, C> for DefaultEvmRuntimeStorageOverride<M>
where
M: fp_rpc::EthereumRuntimeAddressMapping + Sync + Send,
M: fp_rpc::EvmRuntimeAddressMapping + Sync + Send,
B: BlockT,
C: StorageProvider<B, sc_service::TFullBackend<B>>,
{
Expand Down
6 changes: 3 additions & 3 deletions primitives/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ pub struct TransactionStatus {
pub logs_bloom: Bloom,
}

pub trait EthereumRuntimeAddressMapping {
pub trait EvmRuntimeAddressMapping {
fn into_account_id_bytes(address: H160) -> Vec<u8>;
}

pub trait EthereumRuntimeStorageOverride<B, C>: Send + Sync
pub trait EvmRuntimeStorageOverride<B, C>: Send + Sync
where
B: BlockT,
{
type AddressMapping: EthereumRuntimeAddressMapping;
type AddressMapping: EvmRuntimeAddressMapping;

fn set_overlayed_changes(
&self,
Expand Down
7 changes: 3 additions & 4 deletions template/node/src/rpc/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
pub use fc_storage::overrides_handle;
use fp_rpc::{
ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi,
EthereumRuntimeStorageOverride,
EvmRuntimeStorageOverride,
};

/// Extra dependencies for Ethereum compatibility.
Expand Down Expand Up @@ -59,9 +59,8 @@ pub struct EthDeps<C, P, A: ChainApi, CT, B: BlockT> {
/// using eth_call/eth_estimateGas.
pub execute_gas_limit_multiplier: u64,
/// Ethereum runtime storage overrider impl.
pub runtime_storage_override: Option<
Arc<dyn EthereumRuntimeStorageOverride<B, C, AddressMapping = DefaultAddressMapping>>,
>,
pub runtime_storage_override:
Option<Arc<dyn EvmRuntimeStorageOverride<B, C, AddressMapping = DefaultAddressMapping>>>,
}

impl<C, P, A: ChainApi, CT: Clone, B: BlockT> Clone for EthDeps<C, P, A, CT, B> {
Expand Down
2 changes: 1 addition & 1 deletion template/node/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod eth;
pub use self::eth::{create_eth, overrides_handle, EthDeps};

pub struct DefaultAddressMapping;
impl fp_rpc::EthereumRuntimeAddressMapping for DefaultAddressMapping {
impl fp_rpc::EvmRuntimeAddressMapping for DefaultAddressMapping {
fn into_account_id_bytes(address: sp_core::H160) -> Vec<u8> {
let account_id: sp_core::H160 =
pallet_evm::IdentityAddressMapping::into_account_id(address);
Expand Down
2 changes: 1 addition & 1 deletion template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ where
fee_history_cache_limit,
execute_gas_limit_multiplier: eth_config.execute_gas_limit_multiplier,
runtime_storage_override: Some(Arc::new(
fc_rpc::frontier_backend_client::DefaultEthereumRuntimeStorageOverride(
fc_rpc::frontier_backend_client::DefaultEvmRuntimeStorageOverride(
std::marker::PhantomData::<crate::rpc::DefaultAddressMapping>::default(),
),
)),
Expand Down

0 comments on commit 7f57f01

Please sign in to comment.