diff --git a/crates/optimism/node/src/node.rs b/crates/optimism/node/src/node.rs index 68429bc290f0..4b5cbe9156e9 100644 --- a/crates/optimism/node/src/node.rs +++ b/crates/optimism/node/src/node.rs @@ -232,7 +232,7 @@ where let debug_ext = OpDebugWitnessApi::new( ctx.node.provider().clone(), ctx.node.evm_config().clone(), - Box::new(ctx.task_executor().clone()), + Box::new(ctx.node.task_executor().clone()), ); self.0 diff --git a/crates/optimism/rpc/src/witness.rs b/crates/optimism/rpc/src/witness.rs index 63bd45af9877..1d7b83bd4b45 100644 --- a/crates/optimism/rpc/src/witness.rs +++ b/crates/optimism/rpc/src/witness.rs @@ -68,10 +68,20 @@ where let _permit = self.inner.semaphore.acquire().await; let parent_header = self.parent_header(parent_block_hash).to_rpc_result()?; + + let provider = self.inner.provider.clone(); + let builder = self.inner.builder.clone(); + + // Spawn the CPU-intensive work on a blocking task self.inner - .builder - .payload_witness(&self.inner.provider, parent_header, attributes) - .map_err(|err| internal_rpc_err(err.to_string())) + .task_spawner + .spawn_blocking(move || { + builder + .payload_witness(&provider, parent_header, attributes) + .map_err(|err| internal_rpc_err(err.to_string())) + }) + .await + .map_err(|err| internal_rpc_err(err.to_string()))? } }