mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Port to reth 1.6.0-dev
This commit is contained in:
@ -6,12 +6,13 @@ use crate::{
|
||||
node::{
|
||||
evm::{executor::is_system_transaction, receipt_builder::RethReceiptBuilder},
|
||||
primitives::{BlockBody, TransactionSigned},
|
||||
rpc::engine_api::validator::HlExecutionData,
|
||||
types::HlExtras,
|
||||
},
|
||||
HlBlock, HlBlockBody, HlPrimitives,
|
||||
};
|
||||
use alloy_consensus::{BlockHeader, Header, Transaction as _, TxReceipt, EMPTY_OMMER_ROOT_HASH};
|
||||
use alloy_eips::merge::BEACON_NONCE;
|
||||
use alloy_eips::{merge::BEACON_NONCE, Encodable2718};
|
||||
use alloy_primitives::{Log, U256};
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
|
||||
use reth_evm::{
|
||||
@ -19,12 +20,13 @@ use reth_evm::{
|
||||
eth::{receipt_builder::ReceiptBuilder, EthBlockExecutionCtx},
|
||||
execute::{BlockAssembler, BlockAssemblerInput},
|
||||
precompiles::PrecompilesMap,
|
||||
ConfigureEvm, EvmEnv, EvmFactory, ExecutionCtxFor, FromRecoveredTx, FromTxWithEncoded,
|
||||
IntoTxEnv, NextBlockEnvAttributes,
|
||||
ConfigureEngineEvm, ConfigureEvm, EvmEnv, EvmEnvFor, EvmFactory, ExecutableTxIterator,
|
||||
ExecutionCtxFor, FromRecoveredTx, FromTxWithEncoded, IntoTxEnv, NextBlockEnvAttributes,
|
||||
};
|
||||
use reth_evm_ethereum::EthBlockAssembler;
|
||||
use reth_payload_primitives::NewPayloadError;
|
||||
use reth_primitives::{logs_bloom, BlockTy, HeaderTy, Receipt, SealedBlock, SealedHeader};
|
||||
use reth_primitives_traits::proofs;
|
||||
use reth_primitives_traits::{proofs, SignerRecoverable, WithEncoded};
|
||||
use reth_provider::BlockExecutionResult;
|
||||
use reth_revm::State;
|
||||
use revm::{
|
||||
@ -407,6 +409,34 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl ConfigureEngineEvm<HlExecutionData> for HlEvmConfig {
|
||||
fn evm_env_for_payload(&self, payload: &HlExecutionData) -> EvmEnvFor<Self> {
|
||||
self.evm_env(&payload.0.header)
|
||||
}
|
||||
|
||||
fn context_for_payload<'a>(&self, payload: &'a HlExecutionData) -> ExecutionCtxFor<'a, Self> {
|
||||
HlBlockExecutionCtx {
|
||||
ctx: EthBlockExecutionCtx {
|
||||
parent_hash: payload.0.header.parent_hash,
|
||||
parent_beacon_block_root: payload.0.header.parent_beacon_block_root,
|
||||
ommers: &payload.0.body.ommers,
|
||||
withdrawals: payload.0.body.withdrawals.as_ref().map(Cow::Borrowed),
|
||||
},
|
||||
extras: HlExtras::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn tx_iterator_for_payload(
|
||||
&self,
|
||||
payload: &HlExecutionData,
|
||||
) -> impl ExecutableTxIterator<Self> {
|
||||
payload.0.body.transactions.clone().into_iter().map(move |tx| {
|
||||
let recovered = tx.try_into_recovered().map_err(NewPayloadError::other)?;
|
||||
Ok::<_, NewPayloadError>(WithEncoded::new(recovered.encoded_2718().into(), recovered))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Map the latest active hardfork at the given timestamp or block number to a [`HlSpecId`].
|
||||
pub fn revm_spec_by_timestamp_and_block_number(
|
||||
_chain_spec: impl HlHardforks,
|
||||
|
||||
@ -72,7 +72,7 @@ fn run_precompile(
|
||||
|
||||
match *get {
|
||||
ReadPrecompileResult::Ok { gas_used, ref bytes } => {
|
||||
Ok(PrecompileOutput { gas_used, bytes: bytes.clone() })
|
||||
Ok(PrecompileOutput { gas_used, bytes: bytes.clone(), reverted: false })
|
||||
}
|
||||
ReadPrecompileResult::OutOfGas => {
|
||||
// Use all the gas passed to this precompile
|
||||
@ -181,7 +181,7 @@ where
|
||||
// Execute transaction.
|
||||
let ResultAndState { result, mut state } = self
|
||||
.evm
|
||||
.transact(tx)
|
||||
.transact(&tx)
|
||||
.map_err(|err| BlockExecutionError::evm(err, tx.tx().trie_hash()))?;
|
||||
|
||||
if !f(&result).should_commit() {
|
||||
|
||||
@ -156,6 +156,22 @@ where
|
||||
fn inspector(&self) -> &Self::Inspector {
|
||||
&self.inner.0.inspector
|
||||
}
|
||||
|
||||
fn components(&self) -> (&Self::DB, &Self::Inspector, &Self::Precompiles) {
|
||||
(
|
||||
&self.inner.0.ctx.journaled_state.database,
|
||||
&self.inner.0.inspector,
|
||||
&self.inner.0.precompiles,
|
||||
)
|
||||
}
|
||||
|
||||
fn components_mut(&mut self) -> (&mut Self::DB, &mut Self::Inspector, &mut Self::Precompiles) {
|
||||
(
|
||||
&mut self.inner.0.ctx.journaled_state.database,
|
||||
&mut self.inner.0.inspector,
|
||||
&mut self.inner.0.precompiles,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// A regular hl evm and executor builder.
|
||||
|
||||
Reference in New Issue
Block a user