mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: relax on new head in validator (#13352)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8530,6 +8530,7 @@ dependencies = [
|
||||
"reth-payload-util",
|
||||
"reth-payload-validator",
|
||||
"reth-primitives",
|
||||
"reth-primitives-traits",
|
||||
"reth-provider",
|
||||
"reth-revm",
|
||||
"reth-rpc-server-types",
|
||||
|
||||
@ -16,6 +16,7 @@ reth-chainspec.workspace = true
|
||||
reth-db.workspace = true
|
||||
reth-engine-local.workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-payload-builder.workspace = true
|
||||
reth-payload-util.workspace = true
|
||||
reth-payload-validator.workspace = true
|
||||
@ -129,6 +130,7 @@ test-utils = [
|
||||
"revm/test-utils",
|
||||
"reth-optimism-node/test-utils",
|
||||
"reth-optimism-primitives/arbitrary",
|
||||
"reth-primitives-traits/test-utils"
|
||||
]
|
||||
reth-codec = [
|
||||
"reth-primitives/reth-codec",
|
||||
|
||||
@ -222,7 +222,11 @@ where
|
||||
self.validate_all(transactions)
|
||||
}
|
||||
|
||||
fn on_new_head_block(&self, new_tip_block: &SealedBlock) {
|
||||
fn on_new_head_block<H, B>(&self, new_tip_block: &SealedBlock<H, B>)
|
||||
where
|
||||
H: reth_primitives_traits::BlockHeader,
|
||||
B: BlockBody,
|
||||
{
|
||||
self.inner.on_new_head_block(new_tip_block);
|
||||
self.update_l1_block_info(
|
||||
new_tip_block.header(),
|
||||
|
||||
@ -24,7 +24,7 @@ use alloy_eips::{
|
||||
};
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_primitives::{InvalidTransactionError, SealedBlock};
|
||||
use reth_primitives_traits::GotExpected;
|
||||
use reth_primitives_traits::{BlockBody, GotExpected};
|
||||
use reth_storage_api::{AccountReader, StateProviderFactory};
|
||||
use reth_tasks::TaskSpawner;
|
||||
use std::{
|
||||
@ -106,7 +106,11 @@ where
|
||||
self.validate_all(transactions)
|
||||
}
|
||||
|
||||
fn on_new_head_block(&self, new_tip_block: &SealedBlock) {
|
||||
fn on_new_head_block<H, B>(&self, new_tip_block: &SealedBlock<H, B>)
|
||||
where
|
||||
H: reth_primitives_traits::BlockHeader,
|
||||
B: BlockBody,
|
||||
{
|
||||
self.inner.on_new_head_block(new_tip_block.header())
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ pub use task::{TransactionValidationTaskExecutor, ValidationTask};
|
||||
pub use constants::{
|
||||
DEFAULT_MAX_TX_INPUT_BYTES, MAX_CODE_BYTE_SIZE, MAX_INIT_CODE_BYTE_SIZE, TX_SLOT_BYTE_SIZE,
|
||||
};
|
||||
use reth_primitives_traits::{BlockBody, BlockHeader};
|
||||
|
||||
/// A Result type returned after checking a transaction's validity.
|
||||
#[derive(Debug)]
|
||||
@ -206,7 +207,12 @@ pub trait TransactionValidator: Send + Sync {
|
||||
/// Invoked when the head block changes.
|
||||
///
|
||||
/// This can be used to update fork specific values (timestamp).
|
||||
fn on_new_head_block(&self, _new_tip_block: &SealedBlock) {}
|
||||
fn on_new_head_block<H, B>(&self, _new_tip_block: &SealedBlock<H, B>)
|
||||
where
|
||||
H: BlockHeader,
|
||||
B: BlockBody,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B> TransactionValidator for Either<A, B>
|
||||
@ -237,7 +243,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn on_new_head_block(&self, new_tip_block: &SealedBlock) {
|
||||
fn on_new_head_block<H, Body>(&self, new_tip_block: &SealedBlock<H, Body>)
|
||||
where
|
||||
H: BlockHeader,
|
||||
Body: BlockBody,
|
||||
{
|
||||
match self {
|
||||
Self::Left(v) => v.on_new_head_block(new_tip_block),
|
||||
Self::Right(v) => v.on_new_head_block(new_tip_block),
|
||||
|
||||
@ -9,6 +9,7 @@ use crate::{
|
||||
use futures_util::{lock::Mutex, StreamExt};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_primitives::SealedBlock;
|
||||
use reth_primitives_traits::{BlockBody, BlockHeader};
|
||||
use reth_tasks::TaskSpawner;
|
||||
use std::{future::Future, pin::Pin, sync::Arc};
|
||||
use tokio::{
|
||||
@ -205,7 +206,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn on_new_head_block(&self, new_tip_block: &SealedBlock) {
|
||||
fn on_new_head_block<H, B>(&self, new_tip_block: &SealedBlock<H, B>)
|
||||
where
|
||||
H: BlockHeader,
|
||||
B: BlockBody,
|
||||
{
|
||||
self.validator.on_new_head_block(new_tip_block)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user