Skip to content

Commit

Permalink
chore: relax PayloadBuilderService bound (#13456)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Dec 19, 2024
1 parent b271f0c commit 058cfe2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
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.

4 changes: 2 additions & 2 deletions crates/payload/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use reth_evm::state_change::post_block_withdrawals_balance_increments;
use reth_payload_builder::{KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJobGenerator};
use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind};
use reth_primitives::{proofs, SealedHeader};
use reth_primitives::{proofs, NodePrimitives, SealedHeader};
use reth_provider::{BlockReaderIdExt, CanonStateNotification, StateProviderFactory};
use reth_revm::cached::CachedReads;
use reth_tasks::TaskSpawner;
Expand Down Expand Up @@ -191,7 +191,7 @@ where
Ok(job)
}

fn on_new_state(&mut self, new_state: CanonStateNotification) {
fn on_new_state<N: NodePrimitives>(&mut self, new_state: CanonStateNotification<N>) {
let mut cached = CachedReads::default();

// extract the state from the notification and put it into the cache
Expand Down
10 changes: 6 additions & 4 deletions crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true
[dependencies]
# reth
reth-primitives = { workspace = true, optional = true }
reth-primitives-traits.workspace = true
reth-chain-state.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true
Expand Down Expand Up @@ -44,8 +45,9 @@ alloy-consensus.workspace = true

[features]
test-utils = [
"alloy-primitives",
"reth-chain-state/test-utils",
"reth-primitives/test-utils",
"revm/test-utils",
"alloy-primitives",
"reth-chain-state/test-utils",
"reth-primitives/test-utils",
"revm/test-utils",
"reth-primitives-traits/test-utils"
]
6 changes: 4 additions & 2 deletions crates/payload/builder/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use reth_payload_builder_primitives::{
Events, PayloadBuilder, PayloadBuilderError, PayloadEvents, PayloadStoreExt,
};
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind, PayloadTypes};
use reth_primitives_traits::NodePrimitives;
use std::{
fmt,
future::Future,
Expand Down Expand Up @@ -352,12 +353,13 @@ where
}
}

impl<Gen, St, T> Future for PayloadBuilderService<Gen, St, T>
impl<Gen, St, T, N> Future for PayloadBuilderService<Gen, St, T>
where
T: PayloadTypes,
N: NodePrimitives,
Gen: PayloadJobGenerator + Unpin + 'static,
<Gen as PayloadJobGenerator>::Job: Unpin + 'static,
St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static,
St: Stream<Item = CanonStateNotification<N>> + Send + Unpin + 'static,
Gen::Job: PayloadJob<PayloadAttributes = T::PayloadBuilderAttributes>,
<Gen::Job as PayloadJob>::BuiltPayload: Into<T::BuiltPayload>,
{
Expand Down
3 changes: 2 additions & 1 deletion crates/payload/builder/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use reth_chain_state::CanonStateNotification;
use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind};
use reth_primitives_traits::NodePrimitives;
use std::future::Future;

/// A type that can build a payload.
Expand Down Expand Up @@ -105,7 +106,7 @@ pub trait PayloadJobGenerator: Send + Sync {
///
/// This is intended for any logic that needs to be run when the chain state changes or used to
/// use the in memory state for the head block.
fn on_new_state(&mut self, new_state: CanonStateNotification) {
fn on_new_state<N: NodePrimitives>(&mut self, new_state: CanonStateNotification<N>) {
let _ = new_state;
}
}

0 comments on commit 058cfe2

Please sign in to comment.