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

feature: Add support for block validation (flashbots_validateBuilderSubmissionV3) #7335

Merged
merged 134 commits into from
Feb 17, 2025

Conversation

rjnrohit
Copy link
Contributor

@rjnrohit rjnrohit commented Aug 16, 2024

Closes #7462

This PR aims to implement flashbots endpoint (flashbots_validateBuilderSubmissionV3) ref: https://github.com/flashbots/builder/blob/df9c765067d57ab4b2d0ad39dbb156cbe4965778/eth/block-validation/api.go#L225-L246

  1. It validates the sent payload's block, blobs and verifies if the ParentHash, BlockHash, GasLimit, and GasUsed in the params.Message match the sent payload and produce an error otherwise.
  2. It tries to imitate block processing step and also process withdrawals
  3. It tries to validate proposer payment using Txns & receipts generated in the block processing step

Changes

It introduces a new JsonRpc plugin called Nethermind.Flashbots which implements a new endpoint called flashbots_validateBuilderSubmissionV3

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

I'll write the tests once I'm done with manual testing

@rjnrohit rjnrohit force-pushed the feature/flashbots_endpoints branch from cbd73ae to 9eb6f70 Compare August 16, 2024 07:51
@rjnrohit rjnrohit marked this pull request as ready for review September 5, 2024 12:36
@rjnrohit rjnrohit requested a review from rubo as a code owner September 5, 2024 12:36
src/Nethermind/Nethermind.Consensus/IGasLimitCalculator.cs Outdated Show resolved Hide resolved
Comment on lines 126 to 130
if (!_blockTree.IsBetterThanHead(block.Header))
{
error = $"Block {block.Header.Hash} is not better than head";
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

We can validate only on future blocks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 322 to 326
if (block is not null && !ValidateBlobsBundle(block.Transactions, blobsBundle, out string? blobsError))
{
if (_logger.IsWarn) _logger.Warn($"Invalid blobs bundle. Result of {payloadStr}. Error: {blobsError}");
return BlockValidationResult.Invalid(blobsError ?? "Blobs bundle validation failed");
}
Copy link
Member

Choose a reason for hiding this comment

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

A but weird that we do validations after processing a block, shouldn't we do it first? (It would be less costly)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/flashbots/builder/blob/df9c765067d57ab4b2d0ad39dbb156cbe4965778/eth/block-validation/api.go#L240

I followed the same order as they did, but yeah I agree doing this way would be costly

Copy link
Member

Choose a reason for hiding this comment

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

W should consider changing it later, maybe @Ruteri knows why this is the order of checks?

Copy link

Choose a reason for hiding this comment

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

I don't think there's any specific reason for the ordering. No comment on whether it'd be better either way (probably depends on workload — one way would be better under some circumstances, and the other way could be better in some other).

@rjnrohit rjnrohit requested a review from MarekM25 as a code owner September 12, 2024 16:36
@mralj
Copy link
Contributor

mralj commented Feb 8, 2025

Hey team, pushed small bugfix commit, which fixes error:

System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'RExecutionPa
yloadV3'.

I was getting when testing this using rbuilder

@rjnrohit rjnrohit force-pushed the feature/flashbots_endpoints branch from 68b9abc to ad62444 Compare February 17, 2025 07:51
@rjnrohit rjnrohit force-pushed the feature/flashbots_endpoints branch from 4ea211b to ef29584 Compare February 17, 2025 08:58
@rjnrohit rjnrohit merged commit 7768423 into master Feb 17, 2025
80 checks passed
@rjnrohit rjnrohit deleted the feature/flashbots_endpoints branch February 17, 2025 14:12
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.

Implement flashbots endpoint (flashbots_validateBuilderSubmissionV3)