Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: relax on new head in validator #13352

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -110,25 +111,26 @@ js-tracer = [
"reth-node-builder/js-tracer"
]
test-utils = [
"reth-tasks",
"reth-e2e-test-utils",
"alloy-genesis",
"tokio",
"reth-node-builder/test-utils",
"reth-chainspec/test-utils",
"reth-consensus/test-utils",
"reth-evm/test-utils",
"reth-network/test-utils",
"reth-payload-builder/test-utils",
"reth-primitives/test-utils",
"reth-revm/test-utils",
"reth-db/test-utils",
"reth-provider/test-utils",
"reth-transaction-pool/test-utils",
"reth-trie-db/test-utils",
"revm/test-utils",
"reth-optimism-node/test-utils",
"reth-optimism-primitives/arbitrary",
"reth-tasks",
"reth-e2e-test-utils",
"alloy-genesis",
"tokio",
"reth-node-builder/test-utils",
"reth-chainspec/test-utils",
"reth-consensus/test-utils",
"reth-evm/test-utils",
"reth-network/test-utils",
"reth-payload-builder/test-utils",
"reth-primitives/test-utils",
"reth-revm/test-utils",
"reth-db/test-utils",
"reth-provider/test-utils",
"reth-transaction-pool/test-utils",
"reth-trie-db/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",
Expand Down
6 changes: 5 additions & 1 deletion crates/optimism/node/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 6 additions & 2 deletions crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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())
}
}
Expand Down
14 changes: 12 additions & 2 deletions crates/transaction-pool/src/validate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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),
Expand Down
7 changes: 6 additions & 1 deletion crates/transaction-pool/src/validate/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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)
}
}
Loading