Skip to content
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
17 changes: 13 additions & 4 deletions crates/op-rbuilder/src/builders/flashblocks/payload_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use alloy_primitives::B64;
use eyre::{WrapErr as _, bail};
use op_alloy_rpc_types_engine::OpFlashblockPayload;
use op_revm::L1BlockInfo;
use reth::revm::{State, database::StateProviderDatabase};
use reth::{
revm::{State, database::StateProviderDatabase},
tasks::TaskSpawner,
};
use reth_basic_payload_builder::PayloadConfig;
use reth_node_builder::Events;
use reth_optimism_chainspec::OpChainSpec;
Expand Down Expand Up @@ -48,15 +51,18 @@ pub(crate) struct PayloadHandler<Client> {
ctx: OpPayloadSyncerCtx,
// chain client
client: Client,
// task executor
task_executor: Tasks,
cancel: tokio_util::sync::CancellationToken,
// For X Layer
p2p_send_full_payload_flag: bool,
p2p_process_full_payload_flag: bool,
}

impl<Client> PayloadHandler<Client>
impl<Client, Tasks> PayloadHandler<Client, Tasks>
where
Client: ClientBounds + 'static,
Tasks: TaskSpawner + Clone + Unpin + 'static,
{
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
Expand All @@ -68,6 +74,7 @@ where
ws_pub: Arc<WebSocketPublisher>,
ctx: OpPayloadSyncerCtx,
client: Client,
task_executor: Tasks,
cancel: tokio_util::sync::CancellationToken,
// For X Layer
p2p_send_full_payload_flag: bool,
Expand All @@ -82,6 +89,7 @@ where
ws_pub,
ctx,
client,
task_executor,
cancel,
p2p_send_full_payload_flag,
p2p_process_full_payload_flag,
Expand All @@ -98,6 +106,7 @@ where
ws_pub,
ctx,
client,
task_executor,
cancel,
p2p_send_full_payload_flag,
p2p_process_full_payload_flag,
Expand Down Expand Up @@ -150,7 +159,7 @@ where

// execute the built full payload on a thread where blocking is acceptable,
// as it's potentially a heavy operation
tokio::task::spawn_blocking(move || {
task_executor.spawn(Box::pin(async move {
let res = execute_flashblock(
payload,
ctx,
Expand All @@ -168,7 +177,7 @@ where
tracing::error!(target: "payload_builder", error = ?e, "failed to execute external received flashblock");
}
}
});
}));
}
Message::OpFlashblockPayload(fb_payload) => {
if let Err(e) = ws_pub.publish(&fb_payload) {
Expand Down
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/builders/flashblocks/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl FlashblocksServiceBuilder {
ws_pub.clone(),
syncer_ctx,
ctx.provider().clone(),
ctx.task_executor().clone(),
cancel,
self.0.specific.p2p_send_full_payload,
self.0.specific.p2p_process_full_payload,
Expand Down