feat: make more block types generic (#12812)

This commit is contained in:
Arsenii Kulikov
2024-11-25 14:50:10 +04:00
committed by GitHub
parent 02824da4fc
commit dcaa06a01a
62 changed files with 534 additions and 333 deletions

View File

@ -5,7 +5,7 @@ use alloy_primitives::U64;
use alloy_rpc_types_engine::{ForkchoiceState, PayloadId, TransitionConfiguration};
use jsonrpsee::core::client::{ClientT, SubscriptionClientT};
use reth_ethereum_engine_primitives::EthEngineTypes;
use reth_primitives::Block;
use reth_primitives::{Block, BlockExt};
use reth_rpc_api::clients::EngineApiClient;
use reth_rpc_layer::JwtSecret;
use reth_rpc_types_compat::engine::payload::{

View File

@ -17,8 +17,8 @@ use reth_evm::{
};
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{
proofs::calculate_transaction_root, Block, BlockBody, Receipt, SealedBlockWithSenders,
SealedHeader, TransactionSignedEcRecovered,
proofs::calculate_transaction_root, Block, BlockBody, BlockExt, Receipt,
SealedBlockWithSenders, SealedHeader, TransactionSignedEcRecovered,
};
use reth_provider::{
BlockReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ProviderError,

View File

@ -315,7 +315,7 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
{
async move {
if let Some(block) = self.block_with_senders(block_id).await? {
if let Some(tx) = block.transactions().nth(index) {
if let Some(tx) = block.transactions().get(index) {
return Ok(Some(tx.encoded_2718().into()))
}
}

View File

@ -43,7 +43,7 @@ pub fn from_block_with_tx_hashes<T>(
block_hash: Option<B256>,
) -> Block<T> {
let block_hash = block_hash.unwrap_or_else(|| block.header.hash_slow());
let transactions = block.body.transactions().map(|tx| tx.hash()).collect();
let transactions = block.body.transactions.iter().map(|tx| tx.hash()).collect();
from_block_with_transactions(
block.length(),

View File

@ -15,7 +15,7 @@ use alloy_rpc_types_engine::{
};
use reth_primitives::{
proofs::{self},
Block, BlockBody, SealedBlock, TransactionSigned,
Block, BlockBody, BlockExt, SealedBlock, TransactionSigned,
};
/// Converts [`ExecutionPayloadV1`] to [`Block`]
@ -363,6 +363,7 @@ mod tests {
CancunPayloadFields, ExecutionPayload, ExecutionPayloadSidecar, ExecutionPayloadV1,
ExecutionPayloadV2, ExecutionPayloadV3,
};
use reth_primitives::BlockExt;
#[test]
fn roundtrip_payload_to_block() {

View File

@ -18,7 +18,7 @@ use reth_evm::{
execute::{BlockExecutorProvider, Executor},
ConfigureEvmEnv,
};
use reth_primitives::{Block, SealedBlockWithSenders};
use reth_primitives::{Block, BlockExt, SealedBlockWithSenders};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, HeaderProvider, StateProofProvider, StateProviderFactory,
TransactionVariant,