mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
feat(breaking): Use HlHeader for storing header
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
use crate::{HlBlock, HlBlockBody, HlPrimitives, hardforks::HlHardforks, node::HlNode};
|
||||
use alloy_consensus::Header;
|
||||
use crate::{hardforks::HlHardforks, node::{primitives::HlHeader, HlNode}, HlBlock, HlBlockBody, HlPrimitives};
|
||||
use reth::{
|
||||
api::{FullNodeTypes, NodeTypes},
|
||||
beacon_consensus::EthBeaconConsensus,
|
||||
@ -101,14 +100,14 @@ where
|
||||
|
||||
impl<ChainSpec> Consensus<HlBlock> for HlConsensus<ChainSpec>
|
||||
where
|
||||
ChainSpec: EthChainSpec<Header = Header> + HlHardforks,
|
||||
ChainSpec: EthChainSpec<Header = HlHeader> + HlHardforks,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
|
||||
fn validate_body_against_header(
|
||||
&self,
|
||||
body: &HlBlockBody,
|
||||
header: &SealedHeader,
|
||||
header: &SealedHeader<HlHeader>,
|
||||
) -> Result<(), ConsensusError> {
|
||||
Consensus::<HlBlock>::validate_body_against_header(&self.inner, body, header)
|
||||
}
|
||||
@ -148,7 +147,7 @@ mod reth_copy;
|
||||
|
||||
impl<ChainSpec> FullConsensus<HlPrimitives> for HlConsensus<ChainSpec>
|
||||
where
|
||||
ChainSpec: EthChainSpec<Header = Header> + HlHardforks,
|
||||
ChainSpec: EthChainSpec<Header = HlHeader> + HlHardforks,
|
||||
{
|
||||
fn validate_block_post_execution(
|
||||
&self,
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
use crate::{
|
||||
HlBlock,
|
||||
node::evm::config::{HlBlockExecutorFactory, HlEvmConfig},
|
||||
node::evm::config::{HlBlockExecutorFactory, HlEvmConfig}, HlBlock, HlHeader
|
||||
};
|
||||
use alloy_consensus::Header;
|
||||
use reth_evm::{
|
||||
block::BlockExecutionError,
|
||||
execute::{BlockAssembler, BlockAssemblerInput},
|
||||
@ -13,7 +11,7 @@ impl BlockAssembler<HlBlockExecutorFactory> for HlEvmConfig {
|
||||
|
||||
fn assemble_block(
|
||||
&self,
|
||||
input: BlockAssemblerInput<'_, '_, HlBlockExecutorFactory, Header>,
|
||||
input: BlockAssemblerInput<'_, '_, HlBlockExecutorFactory, HlHeader>,
|
||||
) -> Result<Self::Block, BlockExecutionError> {
|
||||
let HlBlock { header, body } = self.block_assembler.assemble_block(input)?;
|
||||
Ok(HlBlock { header, body })
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
use super::{executor::HlBlockExecutor, factory::HlEvmFactory};
|
||||
use crate::{
|
||||
HlBlock, HlBlockBody, HlPrimitives,
|
||||
chainspec::HlChainSpec,
|
||||
evm::{spec::HlSpecId, transaction::HlTxEnv},
|
||||
hardforks::HlHardforks,
|
||||
node::{
|
||||
chainspec::HlChainSpec, evm::{spec::HlSpecId, transaction::HlTxEnv}, hardforks::HlHardforks, node::{
|
||||
evm::{executor::is_system_transaction, receipt_builder::RethReceiptBuilder},
|
||||
primitives::{BlockBody, TransactionSigned},
|
||||
rpc::engine_api::validator::HlExecutionData,
|
||||
types::HlExtras,
|
||||
},
|
||||
}, HlBlock, HlBlockBody, HlHeader, HlPrimitives
|
||||
};
|
||||
use alloy_consensus::{BlockHeader, EMPTY_OMMER_ROOT_HASH, Header, Transaction as _, TxReceipt};
|
||||
use alloy_eips::{Encodable2718, merge::BEACON_NONCE};
|
||||
@ -54,7 +50,7 @@ where
|
||||
|
||||
fn assemble_block(
|
||||
&self,
|
||||
input: BlockAssemblerInput<'_, '_, F>,
|
||||
input: BlockAssemblerInput<'_, '_, F, HlHeader>,
|
||||
) -> Result<Self::Block, BlockExecutionError> {
|
||||
// TODO: Copy of EthBlockAssembler::assemble_block
|
||||
let inner = &self.inner;
|
||||
@ -136,6 +132,7 @@ where
|
||||
excess_blob_gas,
|
||||
requests_hash,
|
||||
};
|
||||
let header = HlHeader::from_ethereum_header(header, receipts);
|
||||
|
||||
Ok(Self::Block {
|
||||
header,
|
||||
@ -269,6 +266,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
static EMPTY_OMMERS: [Header; 0] = [];
|
||||
|
||||
impl ConfigureEvm for HlEvmConfig
|
||||
where
|
||||
Self: Send + Sync + Unpin + Clone + 'static,
|
||||
@ -287,7 +286,7 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
fn evm_env(&self, header: &Header) -> Result<EvmEnv<HlSpecId>, Self::Error> {
|
||||
fn evm_env(&self, header: &HlHeader) -> Result<EvmEnv<HlSpecId>, Self::Error> {
|
||||
let blob_params = self.chain_spec().blob_params_at_timestamp(header.timestamp);
|
||||
let spec = revm_spec_by_timestamp_and_block_number(
|
||||
self.chain_spec().clone(),
|
||||
@ -332,7 +331,7 @@ where
|
||||
|
||||
fn next_evm_env(
|
||||
&self,
|
||||
parent: &Header,
|
||||
parent: &HlHeader,
|
||||
attributes: &Self::NextBlockEnvCtx,
|
||||
) -> Result<EvmEnv<HlSpecId>, Self::Error> {
|
||||
// ensure we're not missing any timestamp based hardforks
|
||||
@ -382,7 +381,7 @@ where
|
||||
ctx: EthBlockExecutionCtx {
|
||||
parent_hash: block.header().parent_hash,
|
||||
parent_beacon_block_root: block.header().parent_beacon_block_root,
|
||||
ommers: &block.body().ommers,
|
||||
ommers: &EMPTY_OMMERS,
|
||||
withdrawals: block.body().withdrawals.as_ref().map(Cow::Borrowed),
|
||||
},
|
||||
extras: HlExtras {
|
||||
@ -420,7 +419,7 @@ impl ConfigureEngineEvm<HlExecutionData> for HlEvmConfig {
|
||||
ctx: EthBlockExecutionCtx {
|
||||
parent_hash: block.header.parent_hash,
|
||||
parent_beacon_block_root: block.header.parent_beacon_block_root,
|
||||
ommers: &block.body.ommers,
|
||||
ommers: &EMPTY_OMMERS,
|
||||
withdrawals: block.body.withdrawals.as_ref().map(Cow::Borrowed),
|
||||
},
|
||||
extras: HlExtras {
|
||||
|
||||
@ -179,7 +179,7 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::chainspec::hl::hl_mainnet;
|
||||
use crate::{chainspec::hl::hl_mainnet, HlHeader};
|
||||
|
||||
use super::*;
|
||||
use alloy_primitives::{B256, U128};
|
||||
@ -355,7 +355,7 @@ mod tests {
|
||||
/// Creates a test block message
|
||||
fn create_test_block() -> NewBlockMessage<HlNewBlock> {
|
||||
let block = HlBlock {
|
||||
header: Header::default(),
|
||||
header: HlHeader::default(),
|
||||
body: HlBlockBody {
|
||||
inner: BlockBody {
|
||||
transactions: Vec::new(),
|
||||
|
||||
@ -38,10 +38,10 @@ pub struct HlNewBlock(pub NewBlock<HlBlock>);
|
||||
mod rlp {
|
||||
use super::*;
|
||||
use crate::{
|
||||
HlBlockBody,
|
||||
HlBlockBody, HlHeader,
|
||||
node::primitives::{BlockBody, TransactionSigned},
|
||||
};
|
||||
use alloy_consensus::{BlobTransactionSidecar, Header};
|
||||
use alloy_consensus::BlobTransactionSidecar;
|
||||
use alloy_primitives::{Address, U128};
|
||||
use alloy_rlp::{RlpDecodable, RlpEncodable};
|
||||
use alloy_rpc_types::Withdrawals;
|
||||
@ -50,9 +50,9 @@ mod rlp {
|
||||
#[derive(RlpEncodable, RlpDecodable)]
|
||||
#[rlp(trailing)]
|
||||
struct BlockHelper<'a> {
|
||||
header: Cow<'a, Header>,
|
||||
header: Cow<'a, HlHeader>,
|
||||
transactions: Cow<'a, Vec<TransactionSigned>>,
|
||||
ommers: Cow<'a, Vec<Header>>,
|
||||
ommers: Cow<'a, Vec<HlHeader>>,
|
||||
withdrawals: Option<Cow<'a, Withdrawals>>,
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,13 @@
|
||||
use crate::node::primitives::HlBlockBody;
|
||||
use alloy_consensus::Header;
|
||||
use super::{HlBlockBody, HlHeader, rlp};
|
||||
use alloy_rlp::Encodable;
|
||||
use reth_primitives_traits::{Block, InMemorySize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::node::primitives::rlp;
|
||||
|
||||
/// Block for HL
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct HlBlock {
|
||||
pub header: Header,
|
||||
pub header: HlHeader,
|
||||
pub body: HlBlockBody,
|
||||
}
|
||||
|
||||
@ -21,7 +18,7 @@ impl InMemorySize for HlBlock {
|
||||
}
|
||||
|
||||
impl Block for HlBlock {
|
||||
type Header = Header;
|
||||
type Header = HlHeader;
|
||||
type Body = HlBlockBody;
|
||||
|
||||
fn new(header: Self::Header, body: Self::Body) -> Self {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use alloy_consensus::{BlobTransactionSidecar, Header};
|
||||
use alloy_consensus::BlobTransactionSidecar;
|
||||
use alloy_primitives::Address;
|
||||
use reth_primitives_traits::{BlockBody as BlockBodyTrait, InMemorySize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -43,7 +43,7 @@ impl InMemorySize for HlBlockBody {
|
||||
|
||||
impl BlockBodyTrait for HlBlockBody {
|
||||
type Transaction = TransactionSigned;
|
||||
type OmmerHeader = Header;
|
||||
type OmmerHeader = super::HlHeader;
|
||||
|
||||
fn transactions(&self) -> &[Self::Transaction] {
|
||||
BlockBodyTrait::transactions(&self.inner)
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
use alloy_consensus::Header;
|
||||
use alloy_primitives::{Address, B64, B256, BlockNumber, Bloom, Bytes, Sealable, U256};
|
||||
use alloy_rlp::{RlpDecodable, RlpEncodable};
|
||||
use reth_cli_commands::common::CliHeader;
|
||||
use reth_codecs::Compact;
|
||||
use reth_ethereum_primitives::EthereumReceipt;
|
||||
use reth_primitives::{SealedHeader, logs_bloom};
|
||||
use reth_primitives_traits::{BlockHeader, InMemorySize, serde_bincode_compat::RlpBincode};
|
||||
use reth_rpc_convert::transaction::FromConsensusHeader;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::node::types::HlExtras;
|
||||
@ -36,6 +40,18 @@ pub struct HlHeader {
|
||||
pub system_tx_count: u64,
|
||||
pub read_precompile_calls: HlExtras,
|
||||
}
|
||||
impl HlHeader {
|
||||
pub(crate) fn from_ethereum_header(header: Header, receipts: &[EthereumReceipt]) -> HlHeader {
|
||||
let logs_bloom = logs_bloom(receipts.iter().flat_map(|r| &r.logs));
|
||||
let system_tx_count = receipts.iter().filter(|r| r.cumulative_gas_used == 0).count() as u64;
|
||||
HlHeader {
|
||||
inner: header,
|
||||
logs_bloom_with_system_txs: logs_bloom,
|
||||
system_tx_count,
|
||||
read_precompile_calls: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Header> for HlHeader {
|
||||
fn from(_value: Header) -> Self {
|
||||
@ -185,3 +201,28 @@ impl reth_db_api::table::Decompress for HlHeader {
|
||||
impl BlockHeader for HlHeader {}
|
||||
|
||||
impl RlpBincode for HlHeader {}
|
||||
|
||||
impl CliHeader for HlHeader {
|
||||
fn set_number(&mut self, number: u64) {
|
||||
self.inner.set_number(number);
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HlHeader> for Header {
|
||||
fn from(value: HlHeader) -> Self {
|
||||
value.inner
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_ethereum_ommers(ommers: &[HlHeader]) -> Vec<Header> {
|
||||
ommers.iter().map(|ommer| ommer.clone().into()).collect()
|
||||
}
|
||||
|
||||
impl FromConsensusHeader<HlHeader> for alloy_rpc_types::Header {
|
||||
fn from_consensus_header(header: SealedHeader<HlHeader>, block_size: usize) -> Self {
|
||||
FromConsensusHeader::<Header>::from_consensus_header(
|
||||
SealedHeader::<Header>::new(header.inner.clone(), header.hash()),
|
||||
block_size,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
use alloy_consensus::Header;
|
||||
use reth_ethereum_primitives::Receipt;
|
||||
use reth_primitives::NodePrimitives;
|
||||
|
||||
@ -10,6 +9,7 @@ pub use block::HlBlock;
|
||||
pub mod body;
|
||||
pub use body::HlBlockBody;
|
||||
pub mod header;
|
||||
pub use header::HlHeader;
|
||||
|
||||
pub mod rlp;
|
||||
pub mod serde_bincode_compat;
|
||||
@ -21,7 +21,7 @@ pub struct HlPrimitives;
|
||||
|
||||
impl NodePrimitives for HlPrimitives {
|
||||
type Block = HlBlock;
|
||||
type BlockHeader = Header;
|
||||
type BlockHeader = HlHeader;
|
||||
type BlockBody = HlBlockBody;
|
||||
type SignedTx = TransactionSigned;
|
||||
type Receipt = Receipt;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#![allow(clippy::owned_cow)]
|
||||
use super::{HlBlock, HlBlockBody, TransactionSigned};
|
||||
use crate::node::types::ReadPrecompileCalls;
|
||||
use alloy_consensus::{BlobTransactionSidecar, BlockBody, Header};
|
||||
use crate::{node::types::ReadPrecompileCalls, HlHeader};
|
||||
use alloy_consensus::{BlobTransactionSidecar, BlockBody};
|
||||
use alloy_eips::eip4895::Withdrawals;
|
||||
use alloy_primitives::Address;
|
||||
use alloy_rlp::{Decodable, Encodable, RlpDecodable, RlpEncodable};
|
||||
@ -11,7 +11,7 @@ use std::borrow::Cow;
|
||||
#[rlp(trailing)]
|
||||
struct BlockBodyHelper<'a> {
|
||||
transactions: Cow<'a, Vec<TransactionSigned>>,
|
||||
ommers: Cow<'a, Vec<Header>>,
|
||||
ommers: Cow<'a, Vec<HlHeader>>,
|
||||
withdrawals: Option<Cow<'a, Withdrawals>>,
|
||||
sidecars: Option<Cow<'a, Vec<BlobTransactionSidecar>>>,
|
||||
read_precompile_calls: Option<Cow<'a, ReadPrecompileCalls>>,
|
||||
@ -21,9 +21,9 @@ struct BlockBodyHelper<'a> {
|
||||
#[derive(RlpEncodable, RlpDecodable)]
|
||||
#[rlp(trailing)]
|
||||
pub(crate) struct BlockHelper<'a> {
|
||||
pub(crate) header: Cow<'a, Header>,
|
||||
pub(crate) header: Cow<'a, HlHeader>,
|
||||
pub(crate) transactions: Cow<'a, Vec<TransactionSigned>>,
|
||||
pub(crate) ommers: Cow<'a, Vec<Header>>,
|
||||
pub(crate) ommers: Cow<'a, Vec<HlHeader>>,
|
||||
pub(crate) withdrawals: Option<Cow<'a, Withdrawals>>,
|
||||
pub(crate) sidecars: Option<Cow<'a, Vec<BlobTransactionSidecar>>>,
|
||||
pub(crate) read_precompile_calls: Option<Cow<'a, ReadPrecompileCalls>>,
|
||||
@ -95,7 +95,7 @@ impl Decodable for HlBlockBody {
|
||||
Ok(Self {
|
||||
inner: BlockBody {
|
||||
transactions: transactions.into_owned(),
|
||||
ommers: ommers.into_owned(),
|
||||
ommers: ommers.into_owned().into_iter().map(Into::into).collect(),
|
||||
withdrawals: withdrawals.map(|w| w.into_owned()),
|
||||
},
|
||||
sidecars: sidecars.map(|s| s.into_owned()),
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
#![allow(clippy::owned_cow)]
|
||||
use alloy_consensus::{BlobTransactionSidecar, Header};
|
||||
use alloy_consensus::BlobTransactionSidecar;
|
||||
use alloy_primitives::Address;
|
||||
use reth_primitives_traits::serde_bincode_compat::{BincodeReprFor, SerdeBincodeCompat};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use super::{HlBlock, HlBlockBody};
|
||||
use crate::node::{primitives::BlockBody, types::ReadPrecompileCalls};
|
||||
use crate::{node::{primitives::BlockBody, types::ReadPrecompileCalls}, HlHeader};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct HlBlockBodyBincode<'a> {
|
||||
@ -18,7 +18,7 @@ pub struct HlBlockBodyBincode<'a> {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct HlBlockBincode<'a> {
|
||||
header: BincodeReprFor<'a, Header>,
|
||||
header: BincodeReprFor<'a, HlHeader>,
|
||||
body: BincodeReprFor<'a, HlBlockBody>,
|
||||
}
|
||||
|
||||
@ -59,6 +59,6 @@ impl SerdeBincodeCompat for HlBlock {
|
||||
|
||||
fn from_repr(repr: Self::BincodeRepr<'_>) -> Self {
|
||||
let HlBlockBincode { header, body } = repr;
|
||||
Self { header: Header::from_repr(header), body: HlBlockBody::from_repr(body) }
|
||||
Self { header: HlHeader::from_repr(header), body: HlBlockBody::from_repr(body) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
//! except that it supports pseudo signer for system transactions.
|
||||
use std::convert::Infallible;
|
||||
|
||||
use crate::evm::transaction::HlTxEnv;
|
||||
use crate::{evm::transaction::HlTxEnv, HlHeader};
|
||||
use alloy_consensus::{
|
||||
SignableTransaction, Signed, Transaction as TransactionTrait, TransactionEnvelope, TxEip1559,
|
||||
TxEip2930, TxEip4844, TxEip7702, TxLegacy, TxType, TypedTransaction, crypto::RecoveryError,
|
||||
@ -181,7 +181,7 @@ impl SerdeBincodeCompat for TransactionSigned {
|
||||
}
|
||||
}
|
||||
|
||||
pub type BlockBody = alloy_consensus::BlockBody<TransactionSigned>;
|
||||
pub type BlockBody = alloy_consensus::BlockBody<TransactionSigned, HlHeader>;
|
||||
|
||||
impl TryFrom<TransactionSigned> for PooledTransactionVariant {
|
||||
type Error = <InnerType as TryInto<PooledTransactionVariant>>::Error;
|
||||
@ -211,15 +211,15 @@ impl Decompress for TransactionSigned {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn convert_to_eth_block_body(value: BlockBody) -> alloy_consensus::BlockBody<InnerType> {
|
||||
pub fn convert_to_eth_block_body(value: BlockBody) -> alloy_consensus::BlockBody<InnerType, HlHeader> {
|
||||
alloy_consensus::BlockBody {
|
||||
transactions: value.transactions.into_iter().map(|tx| tx.into_inner()).collect(),
|
||||
ommers: value.ommers,
|
||||
ommers: value.ommers.into_iter().map(|ommer| ommer.into()).collect(),
|
||||
withdrawals: value.withdrawals,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn convert_to_hl_block_body(value: alloy_consensus::BlockBody<InnerType>) -> BlockBody {
|
||||
pub fn convert_to_hl_block_body(value: alloy_consensus::BlockBody<InnerType, HlHeader>) -> BlockBody {
|
||||
BlockBody {
|
||||
transactions: value.transactions.into_iter().map(TransactionSigned::Default).collect(),
|
||||
ommers: value.ommers,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
HlBlock, HlBlockBody, HlPrimitives,
|
||||
HlBlock, HlBlockBody, HlHeader, HlPrimitives,
|
||||
node::{
|
||||
primitives::transaction::{convert_to_eth_block_body, convert_to_hl_block_body},
|
||||
types::HlExtras,
|
||||
@ -13,6 +13,8 @@ use reth_db::{
|
||||
cursor::{DbCursorRO, DbCursorRW},
|
||||
transaction::{DbTx, DbTxMut},
|
||||
};
|
||||
use reth_primitives::TransactionSigned;
|
||||
use reth_primitives_traits::Block;
|
||||
use reth_provider::{
|
||||
BlockBodyReader, BlockBodyWriter, ChainSpecProvider, ChainStorageReader, ChainStorageWriter,
|
||||
DBProvider, DatabaseProvider, EthStorage, ProviderResult, ReadBodyInput, StorageLocation,
|
||||
@ -23,7 +25,7 @@ pub mod tables;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct HlStorage(EthStorage);
|
||||
pub struct HlStorage(EthStorage<TransactionSigned, HlHeader>);
|
||||
|
||||
impl HlStorage {
|
||||
fn write_precompile_calls<Provider>(
|
||||
@ -146,15 +148,15 @@ where
|
||||
inputs: Vec<ReadBodyInput<'_, Self::Block>>,
|
||||
) -> ProviderResult<Vec<HlBlockBody>> {
|
||||
let read_precompile_calls = self.read_precompile_calls(provider, &inputs)?;
|
||||
let eth_bodies = self.0.read_block_bodies(
|
||||
provider,
|
||||
inputs
|
||||
.into_iter()
|
||||
.map(|(header, transactions)| {
|
||||
(header, transactions.into_iter().map(|tx| tx.into_inner()).collect())
|
||||
})
|
||||
.collect(),
|
||||
)?;
|
||||
let inputs: Vec<(&HlHeader, _)> = inputs
|
||||
.into_iter()
|
||||
.map(|(header, transactions)| {
|
||||
(header, transactions.into_iter().map(|tx| tx.into_inner()).collect())
|
||||
})
|
||||
.collect();
|
||||
let inputs: Vec<(&<Self::Block as Block>::Header, _)> = inputs;
|
||||
let eth_bodies = self.0.read_block_bodies(provider, inputs)?;
|
||||
let eth_bodies: Vec<alloy_consensus::BlockBody<_, HlHeader>> = eth_bodies;
|
||||
|
||||
// NOTE: sidecars are not used in HyperEVM yet.
|
||||
Ok(eth_bodies
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
//!
|
||||
//! Changes:
|
||||
//! - ReadPrecompileCalls supports RLP encoding / decoding
|
||||
use alloy_consensus::TxType;
|
||||
use alloy_primitives::{Address, B256, Bytes, Log};
|
||||
use alloy_rlp::{Decodable, Encodable, RlpDecodable, RlpEncodable};
|
||||
use bytes::BufMut;
|
||||
use reth_ethereum_primitives::EthereumReceipt;
|
||||
use reth_primitives_traits::InMemorySize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -67,6 +69,7 @@ impl BlockAndReceipts {
|
||||
self.read_precompile_calls.clone(),
|
||||
self.highest_precompile_address,
|
||||
self.system_txs.clone(),
|
||||
self.receipts.clone(),
|
||||
chain_id,
|
||||
)
|
||||
}
|
||||
@ -95,6 +98,23 @@ pub struct LegacyReceipt {
|
||||
logs: Vec<Log>,
|
||||
}
|
||||
|
||||
impl From<LegacyReceipt> for EthereumReceipt {
|
||||
fn from(r: LegacyReceipt) -> Self {
|
||||
EthereumReceipt {
|
||||
tx_type: match r.tx_type {
|
||||
LegacyTxType::Legacy => TxType::Legacy,
|
||||
LegacyTxType::Eip2930 => TxType::Eip2930,
|
||||
LegacyTxType::Eip1559 => TxType::Eip1559,
|
||||
LegacyTxType::Eip4844 => TxType::Eip4844,
|
||||
LegacyTxType::Eip7702 => TxType::Eip7702,
|
||||
},
|
||||
success: r.success,
|
||||
cumulative_gas_used: r.cumulative_gas_used,
|
||||
logs: r.logs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||
enum LegacyTxType {
|
||||
Legacy = 0,
|
||||
|
||||
@ -10,11 +10,11 @@ use std::{
|
||||
use tracing::info;
|
||||
|
||||
use crate::{
|
||||
HlBlock, HlBlockBody,
|
||||
HlBlock, HlBlockBody, HlHeader,
|
||||
node::{
|
||||
primitives::TransactionSigned as TxSigned,
|
||||
spot_meta::{SpotId, erc20_contract_to_spot_token},
|
||||
types::{ReadPrecompileCalls, SystemTx},
|
||||
types::{LegacyReceipt, ReadPrecompileCalls, SystemTx},
|
||||
},
|
||||
};
|
||||
|
||||
@ -114,6 +114,7 @@ impl SealedBlock {
|
||||
read_precompile_calls: ReadPrecompileCalls,
|
||||
highest_precompile_address: Option<Address>,
|
||||
system_txs: Vec<super::SystemTx>,
|
||||
receipts: Vec<LegacyReceipt>,
|
||||
chain_id: u64,
|
||||
) -> HlBlock {
|
||||
let mut merged_txs = vec![];
|
||||
@ -123,13 +124,19 @@ impl SealedBlock {
|
||||
inner: reth_primitives::BlockBody {
|
||||
transactions: merged_txs,
|
||||
withdrawals: self.body.withdrawals.clone(),
|
||||
ommers: self.body.ommers.clone(),
|
||||
ommers: vec![],
|
||||
},
|
||||
sidecars: None,
|
||||
read_precompile_calls: Some(read_precompile_calls),
|
||||
highest_precompile_address,
|
||||
};
|
||||
|
||||
HlBlock { header: self.header.header.clone(), body: block_body }
|
||||
HlBlock {
|
||||
header: HlHeader::from_ethereum_header(
|
||||
self.header.header.clone(),
|
||||
&receipts.into_iter().map(From::from).collect::<Vec<_>>(),
|
||||
),
|
||||
body: block_body,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user