Skip to content

Commit

Permalink
remove impl of EstimateGasAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Roznovjak committed Oct 3, 2024
1 parent bf74970 commit 04e34c4
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use cumulus_primitives_parachain_inherent::ParachainInherentData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use fc_db::kv::Backend as FrontierBackend;
pub use fc_rpc::{EthBlockDataCacheTask, StorageOverride, StorageOverrideHandler};
use fc_rpc_core::types::TransactionRequest;
pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi};
use hydradx_runtime::{opaque::Block, AccountId, Balance, Index};
Expand All @@ -45,42 +44,14 @@ use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};

pub struct HydraDxEGA;

impl fc_rpc::EstimateGasAdapter for HydraDxEGA {
fn adapt_request(mut request: TransactionRequest) -> TransactionRequest {
// Redirect any call to batch precompile:
// force usage of batchAll method for estimation
use sp_core::H160;
const BATCH_PRECOMPILE_ADDRESS: H160 = H160(hex_literal::hex!("0000000000000000000000000000000000000808"));
const BATCH_PRECOMPILE_BATCH_ALL_SELECTOR: [u8; 4] = hex_literal::hex!("96e292b8");
if request.to == Some(BATCH_PRECOMPILE_ADDRESS) {
match (&mut request.data.input, &mut request.data.data) {
(Some(ref mut input), _) => {
if input.0.len() >= 4 {
input.0[..4].copy_from_slice(&BATCH_PRECOMPILE_BATCH_ALL_SELECTOR);
}
}
(None, Some(ref mut data)) => {
if data.0.len() >= 4 {
data.0[..4].copy_from_slice(&BATCH_PRECOMPILE_BATCH_ALL_SELECTOR);
}
}
(_, _) => {}
};
}
request
}
}

pub struct HydraDxEthConfig<C, BE>(std::marker::PhantomData<(C, BE)>);

impl<C, BE> fc_rpc::EthConfig<Block, C> for HydraDxEthConfig<C, BE>
where
C: sc_client_api::StorageProvider<Block, BE> + Sync + Send + 'static,
BE: Backend<Block> + 'static,
{
type EstimateGasAdapter = HydraDxEGA;
type EstimateGasAdapter = ();
type RuntimeStorageOverride = fc_rpc::frontier_backend_client::SystemAccountId20StorageOverride<Block, C, BE>;
}

Expand Down

0 comments on commit 04e34c4

Please sign in to comment.