mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Compare commits
1 Commits
32c4f92aec
...
4989808852
| Author | SHA1 | Date | |
|---|---|---|---|
| 4989808852 |
@ -4,7 +4,7 @@ use crate::{
|
|||||||
hardforks::HlHardforks,
|
hardforks::HlHardforks,
|
||||||
node::{
|
node::{
|
||||||
primitives::TransactionSigned,
|
primitives::TransactionSigned,
|
||||||
types::{HlExtras, ReadPrecompileInput, ReadPrecompileResult},
|
types::{ReadPrecompileInput, ReadPrecompileResult},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use alloy_consensus::{Transaction, TxReceipt};
|
use alloy_consensus::{Transaction, TxReceipt};
|
||||||
@ -102,7 +102,7 @@ where
|
|||||||
{
|
{
|
||||||
/// Creates a new HlBlockExecutor.
|
/// Creates a new HlBlockExecutor.
|
||||||
pub fn new(mut evm: EVM, ctx: HlBlockExecutionCtx<'a>, spec: Spec, receipt_builder: R) -> Self {
|
pub fn new(mut evm: EVM, ctx: HlBlockExecutionCtx<'a>, spec: Spec, receipt_builder: R) -> Self {
|
||||||
apply_precompiles(&mut evm, &ctx.extras);
|
apply_precompiles(&mut evm, &ctx);
|
||||||
Self { spec, evm, gas_used: 0, receipts: vec![], receipt_builder, ctx }
|
Self { spec, evm, gas_used: 0, receipts: vec![], receipt_builder, ctx }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ where
|
|||||||
type Evm = E;
|
type Evm = E;
|
||||||
|
|
||||||
fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError> {
|
fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError> {
|
||||||
apply_precompiles(&mut self.evm, &self.ctx.extras);
|
apply_precompiles(&mut self.evm, &self.ctx);
|
||||||
self.deploy_corewriter_contract()?;
|
self.deploy_corewriter_contract()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -240,9 +240,10 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_precompiles<EVM>(evm: &mut EVM, extras: &HlExtras)
|
fn apply_precompiles<'a, DB, EVM>(evm: &mut EVM, ctx: &HlBlockExecutionCtx<'a>)
|
||||||
where
|
where
|
||||||
EVM: Evm<Precompiles = PrecompilesMap>,
|
EVM: Evm<DB = &'a mut State<DB>, Precompiles = PrecompilesMap>,
|
||||||
|
DB: Database + 'a,
|
||||||
{
|
{
|
||||||
let block_number = evm.block().number;
|
let block_number = evm.block().number;
|
||||||
let precompiles_mut = evm.precompiles_mut();
|
let precompiles_mut = evm.precompiles_mut();
|
||||||
@ -254,7 +255,9 @@ where
|
|||||||
precompiles_mut.apply_precompile(&address, |_| None);
|
precompiles_mut.apply_precompile(&address, |_| None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (address, precompile) in extras.read_precompile_calls.clone().unwrap_or_default().0.iter() {
|
for (address, precompile) in
|
||||||
|
ctx.extras.read_precompile_calls.clone().unwrap_or_default().0.iter()
|
||||||
|
{
|
||||||
let precompile = precompile.clone();
|
let precompile = precompile.clone();
|
||||||
precompiles_mut.apply_precompile(address, |_| {
|
precompiles_mut.apply_precompile(address, |_| {
|
||||||
let precompiles_map: HashMap<ReadPrecompileInput, ReadPrecompileResult> =
|
let precompiles_map: HashMap<ReadPrecompileInput, ReadPrecompileResult> =
|
||||||
@ -268,7 +271,7 @@ where
|
|||||||
// NOTE: This is adapted from hyperliquid-dex/hyper-evm-sync#5
|
// NOTE: This is adapted from hyperliquid-dex/hyper-evm-sync#5
|
||||||
const WARM_PRECOMPILES_BLOCK_NUMBER: u64 = 8_197_684;
|
const WARM_PRECOMPILES_BLOCK_NUMBER: u64 = 8_197_684;
|
||||||
if block_number >= U256::from(WARM_PRECOMPILES_BLOCK_NUMBER) {
|
if block_number >= U256::from(WARM_PRECOMPILES_BLOCK_NUMBER) {
|
||||||
fill_all_precompiles(extras, precompiles_mut);
|
fill_all_precompiles(ctx, precompiles_mut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,9 +279,9 @@ fn address_to_u64(address: Address) -> u64 {
|
|||||||
address.into_u256().try_into().unwrap()
|
address.into_u256().try_into().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_all_precompiles(extras: &HlExtras, precompiles_mut: &mut PrecompilesMap) {
|
fn fill_all_precompiles<'a>(ctx: &HlBlockExecutionCtx<'a>, precompiles_mut: &mut PrecompilesMap) {
|
||||||
let lowest_address = 0x800;
|
let lowest_address = 0x800;
|
||||||
let highest_address = extras.highest_precompile_address.map_or(0x80D, address_to_u64);
|
let highest_address = ctx.extras.highest_precompile_address.map_or(0x80D, address_to_u64);
|
||||||
for address in lowest_address..=highest_address {
|
for address in lowest_address..=highest_address {
|
||||||
let address = Address::from(U160::from(address));
|
let address = Address::from(U160::from(address));
|
||||||
precompiles_mut.apply_precompile(&address, |f| {
|
precompiles_mut.apply_precompile(&address, |f| {
|
||||||
|
|||||||
@ -32,8 +32,6 @@ mod factory;
|
|||||||
mod patch;
|
mod patch;
|
||||||
pub mod receipt_builder;
|
pub mod receipt_builder;
|
||||||
|
|
||||||
pub use executor::apply_precompiles;
|
|
||||||
|
|
||||||
/// HL EVM implementation.
|
/// HL EVM implementation.
|
||||||
///
|
///
|
||||||
/// This is a wrapper type around the `revm` evm with optional [`Inspector`] (tracing)
|
/// This is a wrapper type around the `revm` evm with optional [`Inspector`] (tracing)
|
||||||
|
|||||||
@ -212,6 +212,10 @@ impl From<EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>
|
|||||||
impl Compress for TransactionSigned {
|
impl Compress for TransactionSigned {
|
||||||
type Compressed = Vec<u8>;
|
type Compressed = Vec<u8>;
|
||||||
|
|
||||||
|
fn compress(self) -> Self::Compressed {
|
||||||
|
self.into_inner().compress()
|
||||||
|
}
|
||||||
|
|
||||||
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(&self, buf: &mut B) {
|
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(&self, buf: &mut B) {
|
||||||
self.inner().compress_to_buf(buf);
|
self.inner().compress_to_buf(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::node::rpc::{HlEthApi, HlRpcNodeCore};
|
use crate::node::rpc::HlEthApi;
|
||||||
use reth::rpc::server_types::eth::{
|
use reth::rpc::server_types::eth::{
|
||||||
builder::config::PendingBlockKind, error::FromEvmError, EthApiError, PendingBlock,
|
builder::config::PendingBlockKind, error::FromEvmError, EthApiError, PendingBlock,
|
||||||
};
|
};
|
||||||
@ -6,12 +6,12 @@ use reth_rpc_eth_api::{
|
|||||||
helpers::{
|
helpers::{
|
||||||
pending_block::PendingEnvBuilder, EthBlocks, LoadBlock, LoadPendingBlock, LoadReceipt,
|
pending_block::PendingEnvBuilder, EthBlocks, LoadBlock, LoadPendingBlock, LoadReceipt,
|
||||||
},
|
},
|
||||||
RpcConvert,
|
RpcConvert, RpcNodeCore,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<N, Rpc> EthBlocks for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthBlocks for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadBlock for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadBlock for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadPendingBlock for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadPendingBlock for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadReceipt for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadReceipt for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,23 +1,14 @@
|
|||||||
use super::{HlEthApi, HlRpcNodeCore};
|
use super::HlEthApi;
|
||||||
use crate::{node::evm::apply_precompiles, HlBlock};
|
|
||||||
use alloy_evm::Evm;
|
|
||||||
use alloy_primitives::B256;
|
|
||||||
use reth::rpc::server_types::eth::EthApiError;
|
use reth::rpc::server_types::eth::EthApiError;
|
||||||
use reth_evm::{ConfigureEvm, Database, EvmEnvFor, TxEnvFor};
|
use reth_evm::TxEnvFor;
|
||||||
use reth_primitives::{NodePrimitives, Recovered};
|
|
||||||
use reth_primitives_traits::SignedTransaction;
|
|
||||||
use reth_provider::{ProviderError, ProviderTx};
|
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
helpers::{estimate::EstimateCall, Call, EthCall},
|
helpers::{estimate::EstimateCall, Call, EthCall},
|
||||||
FromEvmError, RpcConvert, RpcNodeCore,
|
FromEvmError, RpcConvert, RpcNodeCore,
|
||||||
};
|
};
|
||||||
use revm::DatabaseCommit;
|
|
||||||
|
|
||||||
impl<N> HlRpcNodeCore for N where N: RpcNodeCore<Primitives: NodePrimitives<Block = HlBlock>> {}
|
|
||||||
|
|
||||||
impl<N, Rpc> EthCall for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthCall for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
||||||
{
|
{
|
||||||
@ -25,7 +16,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> EstimateCall for HlEthApi<N, Rpc>
|
impl<N, Rpc> EstimateCall for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
||||||
{
|
{
|
||||||
@ -33,7 +24,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> Call for HlEthApi<N, Rpc>
|
impl<N, Rpc> Call for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
||||||
{
|
{
|
||||||
@ -46,35 +37,4 @@ where
|
|||||||
fn max_simulate_blocks(&self) -> u64 {
|
fn max_simulate_blocks(&self) -> u64 {
|
||||||
self.inner.eth_api.max_simulate_blocks()
|
self.inner.eth_api.max_simulate_blocks()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn replay_transactions_until<'a, DB, I>(
|
|
||||||
&self,
|
|
||||||
db: &mut DB,
|
|
||||||
evm_env: EvmEnvFor<Self::Evm>,
|
|
||||||
transactions: I,
|
|
||||||
target_tx_hash: B256,
|
|
||||||
) -> Result<usize, Self::Error>
|
|
||||||
where
|
|
||||||
DB: Database<Error = ProviderError> + DatabaseCommit + core::fmt::Debug,
|
|
||||||
I: IntoIterator<Item = Recovered<&'a ProviderTx<Self::Provider>>>,
|
|
||||||
{
|
|
||||||
let block_number = evm_env.block_env().number;
|
|
||||||
let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?;
|
|
||||||
|
|
||||||
let mut evm = self.evm_config().evm_with_env(db, evm_env);
|
|
||||||
apply_precompiles(&mut evm, &hl_extras);
|
|
||||||
|
|
||||||
let mut index = 0;
|
|
||||||
for tx in transactions {
|
|
||||||
if *tx.tx_hash() == target_tx_hash {
|
|
||||||
// reached the target transaction
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
let tx_env = self.evm_config().tx_env(tx);
|
|
||||||
evm.transact_commit(tx_env).map_err(Self::Error::from_evm_err)?;
|
|
||||||
index += 1;
|
|
||||||
}
|
|
||||||
Ok(index)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,3 @@
|
|||||||
use crate::{
|
|
||||||
chainspec::HlChainSpec,
|
|
||||||
node::{evm::apply_precompiles, types::HlExtras},
|
|
||||||
HlBlock, HlPrimitives,
|
|
||||||
};
|
|
||||||
use alloy_evm::Evm;
|
|
||||||
use alloy_network::Ethereum;
|
use alloy_network::Ethereum;
|
||||||
use alloy_primitives::U256;
|
use alloy_primitives::U256;
|
||||||
use reth::{
|
use reth::{
|
||||||
@ -24,9 +18,8 @@ use reth::{
|
|||||||
TaskSpawner,
|
TaskSpawner,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use reth_evm::{ConfigureEvm, Database, EvmEnvFor, HaltReasonFor, InspectorFor, TxEnvFor};
|
use reth_evm::ConfigureEvm;
|
||||||
use reth_primitives::NodePrimitives;
|
use reth_provider::{ChainSpecProvider, ProviderHeader, ProviderTx};
|
||||||
use reth_provider::{BlockReader, ChainSpecProvider, ProviderError, ProviderHeader, ProviderTx};
|
|
||||||
use reth_rpc::RpcTypes;
|
use reth_rpc::RpcTypes;
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
helpers::{
|
helpers::{
|
||||||
@ -36,18 +29,17 @@ use reth_rpc_eth_api::{
|
|||||||
EthApiTypes, FromEvmError, RpcConvert, RpcConverter, RpcNodeCore, RpcNodeCoreExt,
|
EthApiTypes, FromEvmError, RpcConvert, RpcConverter, RpcNodeCore, RpcNodeCoreExt,
|
||||||
SignableTxRequest,
|
SignableTxRequest,
|
||||||
};
|
};
|
||||||
use revm::context::result::ResultAndState;
|
|
||||||
use std::{fmt, marker::PhantomData, sync::Arc};
|
use std::{fmt, marker::PhantomData, sync::Arc};
|
||||||
|
|
||||||
|
use crate::chainspec::HlChainSpec;
|
||||||
|
|
||||||
mod block;
|
mod block;
|
||||||
mod call;
|
mod call;
|
||||||
pub mod engine_api;
|
pub mod engine_api;
|
||||||
mod transaction;
|
mod transaction;
|
||||||
|
|
||||||
pub trait HlRpcNodeCore: RpcNodeCore<Primitives: NodePrimitives<Block = HlBlock>> {}
|
|
||||||
|
|
||||||
/// Container type `HlEthApi`
|
/// Container type `HlEthApi`
|
||||||
pub(crate) struct HlEthApiInner<N: HlRpcNodeCore, Rpc: RpcConvert> {
|
pub(crate) struct HlEthApiInner<N: RpcNodeCore, Rpc: RpcConvert> {
|
||||||
/// Gateway to node's core components.
|
/// Gateway to node's core components.
|
||||||
pub(crate) eth_api: EthApiInner<N, Rpc>,
|
pub(crate) eth_api: EthApiInner<N, Rpc>,
|
||||||
}
|
}
|
||||||
@ -56,14 +48,14 @@ type HlRpcConvert<N, NetworkT> =
|
|||||||
RpcConverter<NetworkT, <N as FullNodeComponents>::Evm, EthReceiptConverter<HlChainSpec>>;
|
RpcConverter<NetworkT, <N as FullNodeComponents>::Evm, EthReceiptConverter<HlChainSpec>>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct HlEthApi<N: HlRpcNodeCore, Rpc: RpcConvert> {
|
pub struct HlEthApi<N: RpcNodeCore, Rpc: RpcConvert> {
|
||||||
/// Gateway to node's core components.
|
/// Gateway to node's core components.
|
||||||
pub(crate) inner: Arc<HlEthApiInner<N, Rpc>>,
|
pub(crate) inner: Arc<HlEthApiInner<N, Rpc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> fmt::Debug for HlEthApi<N, Rpc>
|
impl<N, Rpc> fmt::Debug for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
@ -73,7 +65,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> EthApiTypes for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthApiTypes for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
type Error = EthApiError;
|
type Error = EthApiError;
|
||||||
@ -87,7 +79,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> RpcNodeCore for HlEthApi<N, Rpc>
|
impl<N, Rpc> RpcNodeCore for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives>,
|
Rpc: RpcConvert<Primitives = N::Primitives>,
|
||||||
{
|
{
|
||||||
type Primitives = N::Primitives;
|
type Primitives = N::Primitives;
|
||||||
@ -119,7 +111,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> RpcNodeCoreExt for HlEthApi<N, Rpc>
|
impl<N, Rpc> RpcNodeCoreExt for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -130,7 +122,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> EthApiSpec for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthApiSpec for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
type Transaction = ProviderTx<Self::Provider>;
|
type Transaction = ProviderTx<Self::Provider>;
|
||||||
@ -149,7 +141,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> SpawnBlocking for HlEthApi<N, Rpc>
|
impl<N, Rpc> SpawnBlocking for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -170,7 +162,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadFee for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadFee for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -187,14 +179,14 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadState for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadState for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> EthState for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthState for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -205,7 +197,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> EthFees for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthFees for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -213,50 +205,15 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> Trace for HlEthApi<N, Rpc>
|
impl<N, Rpc> Trace for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
fn inspect<DB, I>(
|
|
||||||
&self,
|
|
||||||
db: DB,
|
|
||||||
evm_env: EvmEnvFor<Self::Evm>,
|
|
||||||
tx_env: TxEnvFor<Self::Evm>,
|
|
||||||
inspector: I,
|
|
||||||
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>
|
|
||||||
where
|
|
||||||
DB: Database<Error = ProviderError>,
|
|
||||||
I: InspectorFor<Self::Evm, DB>,
|
|
||||||
{
|
|
||||||
let block_number = evm_env.block_env().number;
|
|
||||||
let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?;
|
|
||||||
|
|
||||||
let mut evm = self.evm_config().evm_with_env_and_inspector(db, evm_env, inspector);
|
|
||||||
apply_precompiles(&mut evm, &hl_extras);
|
|
||||||
evm.transact(tx_env).map_err(Self::Error::from_evm_err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<N, Rpc> HlEthApi<N, Rpc>
|
|
||||||
where
|
|
||||||
N: HlRpcNodeCore,
|
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
|
||||||
{
|
|
||||||
fn get_hl_extras(&self, block_number: u64) -> Result<HlExtras, ProviderError> {
|
|
||||||
Ok(self
|
|
||||||
.provider()
|
|
||||||
.block_by_number(block_number)?
|
|
||||||
.map(|block| HlExtras {
|
|
||||||
read_precompile_calls: block.body.read_precompile_calls.clone(),
|
|
||||||
highest_precompile_address: block.body.highest_precompile_address,
|
|
||||||
})
|
|
||||||
.unwrap_or_default())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> AddDevSigners for HlEthApi<N, Rpc>
|
impl<N, Rpc> AddDevSigners for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<
|
Rpc: RpcConvert<
|
||||||
Network: RpcTypes<TransactionRequest: SignableTxRequest<ProviderTx<N::Provider>>>,
|
Network: RpcTypes<TransactionRequest: SignableTxRequest<ProviderTx<N::Provider>>>,
|
||||||
>,
|
>,
|
||||||
@ -282,7 +239,7 @@ impl<NetworkT> Default for HlEthApiBuilder<NetworkT> {
|
|||||||
|
|
||||||
impl<N, NetworkT> EthApiBuilder<N> for HlEthApiBuilder<NetworkT>
|
impl<N, NetworkT> EthApiBuilder<N> for HlEthApiBuilder<NetworkT>
|
||||||
where
|
where
|
||||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = HlChainSpec, Primitives = HlPrimitives>>
|
N: FullNodeComponents<Types: NodeTypes<ChainSpec = HlChainSpec>>
|
||||||
+ RpcNodeCore<
|
+ RpcNodeCore<
|
||||||
Primitives = PrimitivesTy<N::Types>,
|
Primitives = PrimitivesTy<N::Types>,
|
||||||
Evm: ConfigureEvm<NextBlockEnvCtx: BuildPendingEnv<HeaderTy<N::Types>>>,
|
Evm: ConfigureEvm<NextBlockEnvCtx: BuildPendingEnv<HeaderTy<N::Types>>>,
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
use crate::node::rpc::{HlEthApi, HlRpcNodeCore};
|
use crate::node::rpc::HlEthApi;
|
||||||
use alloy_primitives::{Bytes, B256};
|
use alloy_primitives::{Bytes, B256};
|
||||||
use reth::rpc::server_types::eth::EthApiError;
|
use reth::rpc::server_types::eth::EthApiError;
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
helpers::{spec::SignersForRpc, EthTransactions, LoadTransaction},
|
helpers::{spec::SignersForRpc, EthTransactions, LoadTransaction},
|
||||||
RpcConvert,
|
RpcConvert, RpcNodeCore,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<N, Rpc> LoadTransaction for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadTransaction for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> EthTransactions for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthTransactions for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: HlRpcNodeCore,
|
N: RpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
fn signers(&self) -> &SignersForRpc<Self::Provider, Self::NetworkTypes> {
|
fn signers(&self) -> &SignersForRpc<Self::Provider, Self::NetworkTypes> {
|
||||||
|
|||||||
Reference in New Issue
Block a user