Skip to content

feat(node/engine): Disallow invalid EngineSyncState construction #3139

@op-will

Description

@op-will

Some Engine tasks have checks to make sure that the EngineSyncState they are working with is valid. Example:

// Sanity check if the head is behind the finalized head. If it is, this is a critical
// error.
if state.sync_state.unsafe_head().block_info.number <
state.sync_state.finalized_head().block_info.number
{
return Err(BuildTaskError::EngineBuildError(EngineBuildError::FinalizedAheadOfUnsafe(
state.sync_state.unsafe_head().block_info.number,
state.sync_state.finalized_head().block_info.number,
)));
}

This feels like a code smell because why would we allow invalid EngineSyncStates to get created only to cause problems downstream?

This task is to add error handling to the apply_update function as well as any other instantiations of EngineSyncState to

  1. Guarantee all cases of invalid EngineSyncState are caught
  2. Cause an error right when the problem occurs, instead of somewhere downstream
  3. Create and perform validation logic in a single place rather than its various uses

Metadata

Metadata

Assignees

Labels

A-engineArea: engineM-good-ai-issueMeta: This is a good task for an LLM or AI to tackle.M-good-first-issueMeta: Good for newcomers

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions