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

Align with api format of flashbots builder #8

Merged
merged 25 commits into from
Oct 24, 2023

Conversation

ckoopmann
Copy link
Collaborator

@ckoopmann ckoopmann commented Sep 30, 2023

These changes should adjust the api format to be consistent with the one on the flashbots builder, thereby enabling drop in replacement / testing.

  1. Change namespace / method name to flashbots_validateBuilderSubmissionV2
  2. Adjust expected rpc payload to be of type ValidationRequestBody which includes the message, execution_payload and signature fields. (same as on flashbots endpoint.
  3. Add additional checks comparing field values such as block_hash parent_hash between message and the block generated from execution_payload. (analogous to flashbots logic here).

Error messages will not necessarily be the same since they are bubbled up from lower in the stack (geth vs. reth implementation).

This branch is not yet functionally complete / equivalent with flashbots. In particular the verification of the proposer payment is still missing. (see #7)

Additionally this PR:

  • Switches the dependency from our reth fork to the reth repo itself
  • Closes Add tests #4

@ckoopmann ckoopmann force-pushed the testing-and-aligning-api-format branch from f108cdc to f49c10a Compare September 30, 2023 13:04
Cargo.toml Outdated
jsonrpsee = "0.20.1"
reth = { git = "https://github.com/ultrasoundmoney/reth-block-validator", branch = "changes-to-enable-validation-api-extension" }
reth = { git = "https://github.com/paradigmxyz/reth" }
Copy link
Collaborator Author

@ckoopmann ckoopmann Oct 3, 2023

Choose a reason for hiding this comment

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

As you can see I just import the latest commit from reth. This could lead to it breaking when they push a breaking change. Should I instead pin a commit ? (Then we miss continous updates though unless we manually update).

Unfortunately there seems to be no releases on crates.io yet so we can't do any more advanced version patterns. (i think)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, let's pin a commit. Having the code we depend on change between builds is a no-go. Maybe a tag?

Let's try to summon @gakonst. What is the thinking here for projects to depend on Reth? Are published version numbers coming on crates, should we use tags?

Copy link
Member

Choose a reason for hiding this comment

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

Niclas pointed out the lockfile may keep things pinned already.

From the cargo book

Once a git dependency has been added, Cargo will lock that dependency to the latest commit at the time. New commits will not be pulled down automatically once the lock is in place. However, they can be pulled down manually with cargo update.

So not as necessary, still think it would be good to be explicit and not have to browse lockfiles to see what code we depend on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that I opened an issue in reth asking for more documentation on this:
paradigmxyz/reth#4898

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I explicitly fixed the commit hash to the one that I extracted from the Cargo.lock. (also started tracking the previously git-ignored lockfile)

Copy link
Member

@alextes alextes left a comment

Choose a reason for hiding this comment

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

Some questions, looks good otherwise.

Cargo.toml Outdated
jsonrpsee = "0.20.1"
reth = { git = "https://github.com/ultrasoundmoney/reth-block-validator", branch = "changes-to-enable-validation-api-extension" }
reth = { git = "https://github.com/paradigmxyz/reth" }
Copy link
Member

Choose a reason for hiding this comment

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

Yes, let's pin a commit. Having the code we depend on change between builds is a no-go. Maybe a tag?

Let's try to summon @gakonst. What is the thinking here for projects to depend on Reth? Are published version numbers coming on crates, should we use tags?

@@ -0,0 +1,12 @@
use std::sync::Arc;

pub mod cli_ext;
Copy link
Member

Choose a reason for hiding this comment

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

You wrote a CLI for this? Neat.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well it is really just an extension of the reth cli. I mostly just followed their example. But yes it is quite neat.

actual: T,
) -> RpcResult<()> {
if expected != actual {
Err(internal_rpc_err(format!(
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean for the return type? Is flashbots current code returning internal errors for block validation issues? I'd say the obvious return here is 400 not 500, but if their code does 500 let's stick with 500 for now.

Copy link
Collaborator Author

@ckoopmann ckoopmann Oct 23, 2023

Choose a reason for hiding this comment

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

On the http level those should still be successfull (200) requests afaik. However they will contain an error json rpc message with a detailed error code and reason. (which is different from http error codes).
See this SO discussion for reference. I think this is the same behaviour as on flashbots although the error reasons / messages might be different.

Does that answer your question ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can see an example of this by running the test script against an instance of the validator. (either new or flashbots)
image

src/rpc/result.rs Outdated Show resolved Hide resolved
"params":[],
"id":1
}' |\
jq --slurpfile payload crates/rpc/rpc-types/test_data/validation/execution_payload.json '.params += $payload'
Copy link
Member

Choose a reason for hiding this comment

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

Hm. Interesting use of jq. AI? 👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No AI, just good old stackoverflow + youtube tutorial + documentation😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think i tried using ai in between to debug my jq usage actually but had to revert to good old trial and error.

tests/it/main.rs Outdated Show resolved Hide resolved
Copy link

@blombern blombern left a comment

Choose a reason for hiding this comment

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

Nothing to add, looks good.

@ckoopmann ckoopmann merged commit 3def2f2 into main Oct 24, 2023
1 check passed
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.

Add tests
3 participants