mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: relax BasicPayloadJobGenerator bounds (#14254)
This commit is contained in:
@ -20,7 +20,7 @@ use reth_payload_builder::{KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJo
|
|||||||
use reth_payload_builder_primitives::PayloadBuilderError;
|
use reth_payload_builder_primitives::PayloadBuilderError;
|
||||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind};
|
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind};
|
||||||
use reth_primitives::{NodePrimitives, SealedHeader};
|
use reth_primitives::{NodePrimitives, SealedHeader};
|
||||||
use reth_primitives_traits::proofs;
|
use reth_primitives_traits::{proofs, HeaderTy};
|
||||||
use reth_provider::{BlockReaderIdExt, CanonStateNotification, StateProviderFactory};
|
use reth_provider::{BlockReaderIdExt, CanonStateNotification, StateProviderFactory};
|
||||||
use reth_revm::{cached::CachedReads, cancelled::CancelOnDrop};
|
use reth_revm::{cached::CachedReads, cancelled::CancelOnDrop};
|
||||||
use reth_tasks::TaskSpawner;
|
use reth_tasks::TaskSpawner;
|
||||||
@ -45,6 +45,9 @@ mod stack;
|
|||||||
|
|
||||||
pub use stack::PayloadBuilderStack;
|
pub use stack::PayloadBuilderStack;
|
||||||
|
|
||||||
|
/// Helper to access [`NodePrimitives::BlockHeader`] from [`PayloadBuilder::BuiltPayload`].
|
||||||
|
pub type HeaderForPayload<P> = <<P as BuiltPayload>::Primitives as NodePrimitives>::BlockHeader;
|
||||||
|
|
||||||
/// The [`PayloadJobGenerator`] that creates [`BasicPayloadJob`]s.
|
/// The [`PayloadJobGenerator`] that creates [`BasicPayloadJob`]s.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BasicPayloadJobGenerator<Client, Tasks, Builder> {
|
pub struct BasicPayloadJobGenerator<Client, Tasks, Builder> {
|
||||||
@ -128,7 +131,7 @@ impl<Client, Tasks, Builder> PayloadJobGenerator
|
|||||||
for BasicPayloadJobGenerator<Client, Tasks, Builder>
|
for BasicPayloadJobGenerator<Client, Tasks, Builder>
|
||||||
where
|
where
|
||||||
Client: StateProviderFactory
|
Client: StateProviderFactory
|
||||||
+ BlockReaderIdExt<Header = alloy_consensus::Header>
|
+ BlockReaderIdExt<Header = HeaderForPayload<Builder::BuiltPayload>>
|
||||||
+ Clone
|
+ Clone
|
||||||
+ Unpin
|
+ Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
@ -303,7 +306,7 @@ where
|
|||||||
Builder: PayloadBuilder,
|
Builder: PayloadBuilder,
|
||||||
{
|
{
|
||||||
/// The configuration for how the payload will be created.
|
/// The configuration for how the payload will be created.
|
||||||
config: PayloadConfig<Builder::Attributes>,
|
config: PayloadConfig<Builder::Attributes, HeaderForPayload<Builder::BuiltPayload>>,
|
||||||
/// How to spawn building tasks
|
/// How to spawn building tasks
|
||||||
executor: Tasks,
|
executor: Tasks,
|
||||||
/// The deadline when this job should resolve.
|
/// The deadline when this job should resolve.
|
||||||
@ -654,19 +657,19 @@ impl<P> Future for PendingPayload<P> {
|
|||||||
|
|
||||||
/// Static config for how to build a payload.
|
/// Static config for how to build a payload.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PayloadConfig<Attributes> {
|
pub struct PayloadConfig<Attributes, Header = alloy_consensus::Header> {
|
||||||
/// The parent header.
|
/// The parent header.
|
||||||
pub parent_header: Arc<SealedHeader>,
|
pub parent_header: Arc<SealedHeader<Header>>,
|
||||||
/// Requested attributes for the payload.
|
/// Requested attributes for the payload.
|
||||||
pub attributes: Attributes,
|
pub attributes: Attributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Attributes> PayloadConfig<Attributes>
|
impl<Attributes, Header> PayloadConfig<Attributes, Header>
|
||||||
where
|
where
|
||||||
Attributes: PayloadBuilderAttributes,
|
Attributes: PayloadBuilderAttributes,
|
||||||
{
|
{
|
||||||
/// Create new payload config.
|
/// Create new payload config.
|
||||||
pub const fn new(parent_header: Arc<SealedHeader>, attributes: Attributes) -> Self {
|
pub const fn new(parent_header: Arc<SealedHeader<Header>>, attributes: Attributes) -> Self {
|
||||||
Self { parent_header, attributes }
|
Self { parent_header, attributes }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,22 +780,22 @@ impl<Payload> BuildOutcomeKind<Payload> {
|
|||||||
/// building process. It holds references to the Ethereum client, transaction pool, cached reads,
|
/// building process. It holds references to the Ethereum client, transaction pool, cached reads,
|
||||||
/// payload configuration, cancellation status, and the best payload achieved so far.
|
/// payload configuration, cancellation status, and the best payload achieved so far.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BuildArguments<Attributes, Payload> {
|
pub struct BuildArguments<Attributes, Payload: BuiltPayload> {
|
||||||
/// Previously cached disk reads
|
/// Previously cached disk reads
|
||||||
pub cached_reads: CachedReads,
|
pub cached_reads: CachedReads,
|
||||||
/// How to configure the payload.
|
/// How to configure the payload.
|
||||||
pub config: PayloadConfig<Attributes>,
|
pub config: PayloadConfig<Attributes, HeaderTy<Payload::Primitives>>,
|
||||||
/// A marker that can be used to cancel the job.
|
/// A marker that can be used to cancel the job.
|
||||||
pub cancel: CancelOnDrop,
|
pub cancel: CancelOnDrop,
|
||||||
/// The best payload achieved so far.
|
/// The best payload achieved so far.
|
||||||
pub best_payload: Option<Payload>,
|
pub best_payload: Option<Payload>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Attributes, Payload> BuildArguments<Attributes, Payload> {
|
impl<Attributes, Payload: BuiltPayload> BuildArguments<Attributes, Payload> {
|
||||||
/// Create new build arguments.
|
/// Create new build arguments.
|
||||||
pub const fn new(
|
pub const fn new(
|
||||||
cached_reads: CachedReads,
|
cached_reads: CachedReads,
|
||||||
config: PayloadConfig<Attributes>,
|
config: PayloadConfig<Attributes, HeaderTy<Payload::Primitives>>,
|
||||||
cancel: CancelOnDrop,
|
cancel: CancelOnDrop,
|
||||||
best_payload: Option<Payload>,
|
best_payload: Option<Payload>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -844,7 +847,7 @@ pub trait PayloadBuilder: Send + Sync + Clone {
|
|||||||
/// Builds an empty payload without any transaction.
|
/// Builds an empty payload without any transaction.
|
||||||
fn build_empty_payload(
|
fn build_empty_payload(
|
||||||
&self,
|
&self,
|
||||||
config: PayloadConfig<Self::Attributes>,
|
config: PayloadConfig<Self::Attributes, HeaderForPayload<Self::BuiltPayload>>,
|
||||||
) -> Result<Self::BuiltPayload, PayloadBuilderError>;
|
) -> Result<Self::BuiltPayload, PayloadBuilderError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
BuildArguments, BuildOutcome, PayloadBuilder, PayloadBuilderAttributes, PayloadBuilderError,
|
BuildArguments, BuildOutcome, HeaderForPayload, PayloadBuilder, PayloadBuilderAttributes,
|
||||||
PayloadConfig,
|
PayloadBuilderError, PayloadConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
use alloy_eips::eip4895::Withdrawals;
|
use alloy_eips::eip4895::Withdrawals;
|
||||||
@ -238,7 +238,7 @@ where
|
|||||||
|
|
||||||
fn build_empty_payload(
|
fn build_empty_payload(
|
||||||
&self,
|
&self,
|
||||||
config: PayloadConfig<Self::Attributes>,
|
config: PayloadConfig<Self::Attributes, HeaderForPayload<Self::BuiltPayload>>,
|
||||||
) -> Result<Self::BuiltPayload, PayloadBuilderError> {
|
) -> Result<Self::BuiltPayload, PayloadBuilderError> {
|
||||||
match config.attributes {
|
match config.attributes {
|
||||||
Either::Left(left_attr) => {
|
Either::Left(left_attr) => {
|
||||||
|
|||||||
@ -5,7 +5,9 @@ use reth::{
|
|||||||
providers::{BlockReaderIdExt, BlockSource, StateProviderFactory},
|
providers::{BlockReaderIdExt, BlockSource, StateProviderFactory},
|
||||||
tasks::TaskSpawner,
|
tasks::TaskSpawner,
|
||||||
};
|
};
|
||||||
use reth_basic_payload_builder::{BasicPayloadJobGeneratorConfig, PayloadBuilder, PayloadConfig};
|
use reth_basic_payload_builder::{
|
||||||
|
BasicPayloadJobGeneratorConfig, HeaderForPayload, PayloadBuilder, PayloadConfig,
|
||||||
|
};
|
||||||
use reth_node_api::PayloadBuilderAttributes;
|
use reth_node_api::PayloadBuilderAttributes;
|
||||||
use reth_payload_builder::{PayloadBuilderError, PayloadJobGenerator};
|
use reth_payload_builder::{PayloadBuilderError, PayloadJobGenerator};
|
||||||
use reth_primitives::SealedHeader;
|
use reth_primitives::SealedHeader;
|
||||||
@ -45,7 +47,7 @@ impl<Client, Tasks, Builder> PayloadJobGenerator
|
|||||||
for EmptyBlockPayloadJobGenerator<Client, Tasks, Builder>
|
for EmptyBlockPayloadJobGenerator<Client, Tasks, Builder>
|
||||||
where
|
where
|
||||||
Client: StateProviderFactory
|
Client: StateProviderFactory
|
||||||
+ BlockReaderIdExt<Block = reth_primitives::Block>
|
+ BlockReaderIdExt<Header = HeaderForPayload<Builder::BuiltPayload>>
|
||||||
+ Clone
|
+ Clone
|
||||||
+ Unpin
|
+ Unpin
|
||||||
+ 'static,
|
+ 'static,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use futures_util::Future;
|
use futures_util::Future;
|
||||||
use reth::tasks::TaskSpawner;
|
use reth::tasks::TaskSpawner;
|
||||||
use reth_basic_payload_builder::{PayloadBuilder, PayloadConfig};
|
use reth_basic_payload_builder::{HeaderForPayload, PayloadBuilder, PayloadConfig};
|
||||||
use reth_node_api::PayloadKind;
|
use reth_node_api::PayloadKind;
|
||||||
use reth_payload_builder::{KeepPayloadJobAlive, PayloadBuilderError, PayloadJob};
|
use reth_payload_builder::{KeepPayloadJobAlive, PayloadBuilderError, PayloadJob};
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ where
|
|||||||
Builder: PayloadBuilder,
|
Builder: PayloadBuilder,
|
||||||
{
|
{
|
||||||
/// The configuration for how the payload will be created.
|
/// The configuration for how the payload will be created.
|
||||||
pub(crate) config: PayloadConfig<Builder::Attributes>,
|
pub(crate) config: PayloadConfig<Builder::Attributes, HeaderForPayload<Builder::BuiltPayload>>,
|
||||||
/// How to spawn building tasks
|
/// How to spawn building tasks
|
||||||
pub(crate) _executor: Tasks,
|
pub(crate) _executor: Tasks,
|
||||||
/// The type responsible for building payloads.
|
/// The type responsible for building payloads.
|
||||||
|
|||||||
Reference in New Issue
Block a user