mev-boost-relay icon indicating copy to clipboard operation
mev-boost-relay copied to clipboard

[feature] Optimistic v2 submission flow

Open michaelneuder opened this issue 2 years ago β€’ 2 comments

πŸ“ Summary

Spiritual successor to https://github.com/flashbots/mev-boost-relay/pull/466.

This follows up on the series: https://github.com/flashbots/mev-boost-relay/pull/479, https://github.com/flashbots/mev-boost-relay/pull/491, https://github.com/flashbots/mev-boost-relay/pull/494, https://github.com/flashbots/mev-boost-relay/pull/498, https://github.com/flashbots/mev-boost-relay/pull/513, https://github.com/flashbots/mev-boost-relay/pull/514, https://github.com/flashbots/mev-boost-relay/pull/518, which aim at reducing the diff and productionizing https://github.com/flashbots/mev-boost-relay/pull/466.

β›± Motivation and Context

This PR implements the handleSubmitNewBlockV2 and the surrounding test infrastructure. The general flow is:

  • use the SubmitBlockRequestV2Optimistic SSZ type from https://github.com/flashbots/mev-boost-relay/pull/518 to decode the header only from the stream.
  • use checkSubmissionSlotDetails, checkBuilderEntry, checkSubmissionPayloadAttrs, and checkBidFloorValue to run prechecks against the submission. each of these functions was part of the refactor set of the original handleSubmitNewBlock function.
  • calls SaveBidAndUpdateTopBid with just the getHeaderResponse because the getPayloadResponse is not yet available.
  • calls optimisticV2SlowPath, which currently just does nothing. The logic from the slow path will come in a follow up PR.

In an effort to increase review-ability of this PR, I stopped here. the slow path logic is quite simple in that it just decodes the full block and simulates it before updating redis with the getPayloadResponse.

Also have nearly 100% coverage of the new lines!

πŸ“š References

https://notes.ethereum.org/@mikeneuder/optimistic-v2

https://github.com/michaelneuder/optimistic-relay-documentation/blob/main/towards-epbs.md#optimistic-relay-v2-header-only-parsing


βœ… I have run these commands

  • [x] make lint
  • [x] make test-race
  • [x] go mod tidy
  • [x] I have seen and agree to CONTRIBUTING.md

michaelneuder avatar Sep 08 '23 19:09 michaelneuder

Codecov Report

Merging #524 (6bab6ac) into main (e0d1248) will increase coverage by 2.41%. Report is 7 commits behind head on main. The diff coverage is 76.13%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main     #524      +/-   ##
==========================================
+ Coverage   33.23%   35.64%   +2.41%     
==========================================
  Files          24       24              
  Lines        5079     5397     +318     
==========================================
+ Hits         1688     1924     +236     
- Misses       3173     3248      +75     
- Partials      218      225       +7     
Flag Coverage Ξ”
unittests 35.64% <76.13%> (+2.41%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Ξ”
common/test_utils.go 26.25% <0.00%> (-11.25%) :arrow_down:
common/types_spec.go 0.00% <0.00%> (ΓΈ)
datastore/redis.go 59.87% <62.50%> (+0.16%) :arrow_up:
services/api/service.go 46.34% <89.81%> (+6.58%) :arrow_up:

... and 2 files with indirect coverage changes

codecov-commenter avatar Sep 21 '23 20:09 codecov-commenter

A new API should be proposed and merged in the relay specs first: https://github.com/flashbots/relay-specs

Would it be good if v2 also supports non-optimistic submissions?

metachris avatar Oct 19 '23 15:10 metachris