Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sidecar): fallback block builder refactor #512

Merged
merged 10 commits into from
Dec 10, 2024

Conversation

merklefruit
Copy link
Collaborator

@merklefruit merklefruit commented Dec 3, 2024

This PR contains a refactor to the bolt-sidecar builder module to generalize over the EL client used for fallback block building. The refactor also comes with:

  • clients separated in their own client module: execution, beacon, engine and constraints
  • more documentation on the block building process

@merklefruit merklefruit force-pushed the feat/nethermind-fallback branch from a4b390a to 1b25ad4 Compare December 4, 2024 12:28
@merklefruit merklefruit force-pushed the feat/nethermind-fallback branch from d8e7713 to c878559 Compare December 9, 2024 10:26
@merklefruit merklefruit marked this pull request as ready for review December 9, 2024 13:39
Copy link
Contributor

@thedevbirb thedevbirb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor, looks good to me

let validation_error = match payload_status.status {
PayloadStatusEnum::Valid => return Ok(EngineApiHint::ValidPayload),
PayloadStatusEnum::Invalid { validation_error } => validation_error,
PayloadStatusEnum::Syncing | PayloadStatusEnum::Accepted => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Accepted an error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't want the EL to accept this block. According to the engine specs: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_newpayloadv1 the ACCEPTED code MUST be returned only if the following conditions are met:

  • all transactions have non-zero length
  • the blockHash of the payload is valid
  • the payload doesn't extend the canonical chain
  • the payload hasn't been fully validated
  • ancestors of a payload are known and comprise a well-formed chain

in our case our block extends the canonical chain so it will be marked as VALID.

// This should not happen, but in case it does, it doesn't break the flow.
EngineApiHint::BlockHash(hash) => self.block_hash = Some(hash),

// For regular hint types, set the value and reset the block hash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we reset the block hash hint here every time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on how the EL validation is structured, but me and @thedevbirb found that sometimes Geth would return a mismatching hash error after populating some extra field (e.g. state root) which means we can't get more information out of it (as it kept returning mismatching block hash and no other hints). So when this happens we set the block hash to the one hinted by Geth and then proceed with the next hints.

As the comment mentions, this shouldn't happen and it's more of an edge case

mempirate

This comment was marked as outdated.

Copy link
Contributor

@mempirate mempirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, just one req

bolt-sidecar/src/builder/fallback/payload_builder.rs Outdated Show resolved Hide resolved
@mempirate mempirate merged commit 17caf27 into unstable Dec 10, 2024
3 checks passed
@mempirate mempirate deleted the feat/nethermind-fallback branch December 10, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants