mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: make more block types generic (#12812)
This commit is contained in:
@ -8,7 +8,7 @@ use alloy_primitives::BlockNumber;
|
||||
use reth_evm::execute::{
|
||||
BatchExecutor, BlockExecutionError, BlockExecutionOutput, BlockExecutorProvider, Executor,
|
||||
};
|
||||
use reth_primitives::{Block, BlockWithSenders, Receipt};
|
||||
use reth_primitives::{Block, BlockExt, BlockWithSenders, Receipt};
|
||||
use reth_primitives_traits::format_gas_throughput;
|
||||
use reth_provider::{
|
||||
BlockReader, Chain, HeaderProvider, ProviderError, StateProviderFactory, TransactionVariant,
|
||||
|
||||
@ -11,7 +11,7 @@ use reth_evm::execute::{
|
||||
use reth_evm_ethereum::execute::EthExecutorProvider;
|
||||
use reth_node_api::FullNodePrimitives;
|
||||
use reth_primitives::{
|
||||
Block, BlockBody, BlockWithSenders, Receipt, SealedBlockWithSenders, Transaction,
|
||||
Block, BlockBody, BlockExt, BlockWithSenders, Receipt, SealedBlockWithSenders, Transaction,
|
||||
};
|
||||
use reth_provider::{
|
||||
providers::ProviderNodeTypes, BlockWriter as _, ExecutionOutcome, LatestStateProviderRef,
|
||||
@ -58,7 +58,12 @@ pub(crate) fn execute_block_and_commit_to_database<N>(
|
||||
block: &BlockWithSenders,
|
||||
) -> eyre::Result<BlockExecutionOutput<Receipt>>
|
||||
where
|
||||
N: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>,
|
||||
N: ProviderNodeTypes<
|
||||
Primitives: FullNodePrimitives<
|
||||
Block = reth_primitives::Block,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
>,
|
||||
>,
|
||||
{
|
||||
let provider = provider_factory.provider()?;
|
||||
|
||||
@ -162,7 +167,12 @@ pub(crate) fn blocks_and_execution_outputs<N>(
|
||||
key_pair: Keypair,
|
||||
) -> eyre::Result<Vec<(SealedBlockWithSenders, BlockExecutionOutput<Receipt>)>>
|
||||
where
|
||||
N: ProviderNodeTypes<Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>>,
|
||||
N: ProviderNodeTypes<
|
||||
Primitives: FullNodePrimitives<
|
||||
Block = reth_primitives::Block,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
>,
|
||||
>,
|
||||
{
|
||||
let (block1, block2) = blocks(chain_spec.clone(), key_pair)?;
|
||||
|
||||
@ -184,7 +194,7 @@ pub(crate) fn blocks_and_execution_outcome<N>(
|
||||
) -> eyre::Result<(Vec<SealedBlockWithSenders>, ExecutionOutcome)>
|
||||
where
|
||||
N: ProviderNodeTypes,
|
||||
N::Primitives: FullNodePrimitives<BlockBody = reth_primitives::BlockBody>,
|
||||
N::Primitives: FullNodePrimitives<Block = reth_primitives::Block>,
|
||||
{
|
||||
let (block1, block2) = blocks(chain_spec.clone(), key_pair)?;
|
||||
|
||||
|
||||
@ -1235,7 +1235,7 @@ mod tests {
|
||||
genesis_block.number + 1,
|
||||
BlockParams { parent: Some(genesis_hash), ..Default::default() },
|
||||
)
|
||||
.seal_with_senders()
|
||||
.seal_with_senders::<reth_primitives::Block>()
|
||||
.unwrap();
|
||||
let provider_rw = provider_factory.database_provider_rw().unwrap();
|
||||
provider_rw.insert_block(block.clone(), StorageLocation::Database).unwrap();
|
||||
|
||||
@ -400,7 +400,7 @@ mod tests {
|
||||
use futures::StreamExt;
|
||||
use reth_db_common::init::init_genesis;
|
||||
use reth_evm_ethereum::execute::EthExecutorProvider;
|
||||
use reth_primitives::Block;
|
||||
use reth_primitives::{Block, BlockExt};
|
||||
use reth_provider::{
|
||||
providers::BlockchainProvider2, test_utils::create_test_provider_factory, BlockWriter,
|
||||
Chain, DatabaseProviderFactory, StorageLocation,
|
||||
@ -567,7 +567,7 @@ mod tests {
|
||||
genesis_block.number + 1,
|
||||
BlockParams { parent: Some(genesis_hash), tx_count: Some(0), ..Default::default() },
|
||||
)
|
||||
.seal_with_senders()
|
||||
.seal_with_senders::<reth_primitives::Block>()
|
||||
.ok_or_eyre("failed to recover senders")?;
|
||||
let node_head = Head {
|
||||
number: node_head_block.number,
|
||||
|
||||
@ -268,21 +268,25 @@ mod tests {
|
||||
// Create 4 canonical blocks and one reorged block with number 2
|
||||
let blocks = random_block_range(&mut rng, 0..=3, BlockRangeParams::default())
|
||||
.into_iter()
|
||||
.map(|block| block.seal_with_senders().ok_or_eyre("failed to recover senders"))
|
||||
.map(|block| {
|
||||
block
|
||||
.seal_with_senders::<reth_primitives::Block>()
|
||||
.ok_or_eyre("failed to recover senders")
|
||||
})
|
||||
.collect::<eyre::Result<Vec<_>>>()?;
|
||||
let block_1_reorged = random_block(
|
||||
&mut rng,
|
||||
1,
|
||||
BlockParams { parent: Some(blocks[0].hash()), ..Default::default() },
|
||||
)
|
||||
.seal_with_senders()
|
||||
.seal_with_senders::<reth_primitives::Block>()
|
||||
.ok_or_eyre("failed to recover senders")?;
|
||||
let block_2_reorged = random_block(
|
||||
&mut rng,
|
||||
2,
|
||||
BlockParams { parent: Some(blocks[1].hash()), ..Default::default() },
|
||||
)
|
||||
.seal_with_senders()
|
||||
.seal_with_senders::<reth_primitives::Block>()
|
||||
.ok_or_eyre("failed to recover senders")?;
|
||||
|
||||
// Create notifications for the above blocks.
|
||||
|
||||
@ -45,7 +45,7 @@ use reth_node_ethereum::{
|
||||
EthEngineTypes, EthEvmConfig,
|
||||
};
|
||||
use reth_payload_builder::noop::NoopPayloadBuilderService;
|
||||
use reth_primitives::{EthPrimitives, Head, SealedBlockWithSenders};
|
||||
use reth_primitives::{BlockExt, EthPrimitives, Head, SealedBlockWithSenders};
|
||||
use reth_provider::{
|
||||
providers::{BlockchainProvider, StaticFileProvider},
|
||||
BlockReader, EthStorage, ProviderFactory,
|
||||
@ -306,7 +306,7 @@ pub async fn test_exex_context_with_chain_spec(
|
||||
.block_by_hash(genesis_hash)?
|
||||
.ok_or_else(|| eyre::eyre!("genesis block not found"))?
|
||||
.seal_slow()
|
||||
.seal_with_senders()
|
||||
.seal_with_senders::<reth_primitives::Block>()
|
||||
.ok_or_else(|| eyre::eyre!("failed to recover senders"))?;
|
||||
|
||||
let head = Head {
|
||||
|
||||
Reference in New Issue
Block a user