Skip to content
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat(vmsync): allow block enqueuing during batch execution
Enable blocks to be enqueued during StateExecutingBatch for processing
in the next batch, while preventing recursion by skipping sync target
updates during batch execution.

Block Enqueuing During Batch Execution:
- Update AddBlockOperation to allow enqueuing during both StateRunning
  and StateExecutingBatch states.
- Remove early return check in enqueueBlockOperation that prevented
  enqueuing during batch execution.
- Blocks enqueued during batch execution are automatically processed
  in the next batch (via dequeueBatch snapshot behavior).

Prevent Recursion:
- Skip UpdateSyncTarget in OnEngineAccept when state is StateExecutingBatch
- Blocks are still enqueued during batch execution, but sync target
  updates are deferred to prevent recursion.
- Add documentation explaining the behavior.

Code Simplification:
- Simplify finishSync cancellation checks from per-operation checks
  to single check at beginning.
- Operations are not cancellable mid-execution, so single check is
  sufficient and more efficient.

This change ensures blocks arriving during batch execution can be
queued for the next batch (solving dependency issues) while maintaining
fast consensus-critical paths and preventing recursion.
  • Loading branch information
powerslider committed Dec 3, 2025
commit 88c53c9da1beef6f53f73efe7fdc0c1d7a116087
13 changes: 9 additions & 4 deletions graft/coreth/plugin/evm/vmsync/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,16 @@ func (co *Coordinator) UpdateSyncTarget(newTarget message.Syncable) error {
return nil
}

// AddBlock appends the block to the queue only while in the Running state.
// Returns true if the block was queued, false if the queue was already sealed
// or the block is nil.
// AddBlockOperation appends the block to the queue while in the Running or
// StateExecutingBatch state. Blocks enqueued during batch execution will be
// processed in the next batch. Returns true if the block was queued, false
// if the queue was already sealed or the block is nil.
func (co *Coordinator) AddBlockOperation(b EthBlockWrapper, op BlockOperationType) bool {
if b == nil || co.CurrentState() != StateRunning {
if b == nil {
return false
}
state := co.CurrentState()
if state != StateRunning && state != StateExecutingBatch {
return false
}
return co.queue.enqueue(b, op)
Expand Down