Skip to content

[Engine] Batched L1 consolidation #175

Open
@frisitano

Description

@frisitano

Overview

Instead of consolidating a single L1 derived block at a time, we can sync them to the EN in batches.

async fn handle_payload_attributes<EC, P>(
client: Arc<EC>,
execution_payload_provider: P,
safe_block_info: BlockInfo,
mut fcs: AlloyForkchoiceState,
payload_attributes: ScrollPayloadAttributesWithBatchInfo,
) -> Result<(L2BlockInfoWithL1Messages, IsReorg, BatchInfo), EngineDriverError>
where
EC: ScrollEngineApi + Unpin + Send + Sync + 'static,
P: ExecutionPayloadProvider + Unpin + Send + Sync + 'static,
{
tracing::trace!(target: "scroll::engine::future", ?fcs, ?payload_attributes, "handling payload attributes");
let ScrollPayloadAttributesWithBatchInfo { mut payload_attributes, batch_info } =
payload_attributes;
let maybe_execution_payload = execution_payload_provider
.execution_payload_for_block((safe_block_info.number + 1).into())
.await
.map_err(|_| EngineDriverError::ExecutionPayloadProviderUnavailable)?
.filter(|ep| matching_payloads(&payload_attributes, ep, safe_block_info.hash));
if let Some(execution_payload) = maybe_execution_payload {
// if the payload attributes match the execution payload at block safe + 1,
// this payload has already been passed to the EN in the form of a P2P gossiped
// execution payload. We can advance the safe head by one by issuing a
// forkchoiceUpdated.
let safe_block_info: L2BlockInfoWithL1Messages = (&execution_payload).into();
fcs.safe_block_hash = safe_block_info.block_info.hash;
forkchoice_updated(client, fcs, None).await?;
Ok((safe_block_info, false, batch_info))
} else {

In the code above we would change the function input argument to payload_attributes: Vec<ScrollPayloadAttributesWithBatchInfo>. We would issue a single fcu following the successful consolidation of the batch. This would result in a reduction in fcu invocations by a factor of 1/(average blocks per batch), hopefully leading to higher consolidation speed. We need to think through the case of failing mid-batch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions