feat(relay): ExecutionRequestsV4 with eip7685::Requests conversion#1787
Conversation
a3e9bb9 to
c930f1d
Compare
c930f1d to
4e5eae5
Compare
a56d2e9 to
4e8d5bd
Compare
| /// The EIP-7742 blobs per block for this bid. | ||
| #[serde(with = "alloy_serde::quantity")] | ||
| #[serde_as(as = "DisplayFromStr")] | ||
| pub target_blobs_per_block: u64, |
There was a problem hiding this comment.
Aside: I saw today that EIP-7742 was pulled from Pectra, my PR might conflict with removing that since I changed SignedBidSubmissionV4::target_blobs_per_block to DisplayFromStr as well.
https://ethereum-magicians.org/t/all-core-devs-consensus-acdc-147-december-12-2024/22161/2
| } | ||
| ] | ||
| }, | ||
| "target_blobs_per_block": "6", |
There was a problem hiding this comment.
EIP7742 will need to be removed here as well.
| #[cfg(feature = "serde")] | ||
| use cfg_eval::cfg_eval; |
There was a problem hiding this comment.
why do we need this?
can we do without? not familiar with this
There was a problem hiding this comment.
iiuc we need this because of how serde_as works. we could solve this with a helper like serde(with = "from_str") I guess
similarly to https://github.com/foundry-rs/foundry/blob/b4a47336038cd4d1342eedb3f9555772585e745f/crates/config/src/lib.rs#L2514-L2534 but without lowercase
There was a problem hiding this comment.
Its necessary to make #[serde_as] conditional on the serde feature: https://docs.rs/serde_with/latest/serde_with/guide/serde_as/index.html#gating-serde_as-on-features
Without it we get compilation failures running e.g. cargo +nightly check --no-default-features --target riscv32imac-unknown-none-elf --manifest-path crates/consensus/Cargo.toml in the no_std GHA.
There was a problem hiding this comment.
FWIW @klkvr mentioned in telegram that we could move from serde_as to serde_with to remove the dep but IMO thats outside the scope of this PR.
There was a problem hiding this comment.
Ah we cross-posted so I didn't see the foundry link, I'll take a stab at this later this afternoon, thanks!
There was a problem hiding this comment.
Ok, I added a new alloy_serde::ssz::json::uint (de)serializer that if we're happy with I can switch other places to start using as well (in a follow-on PR). This let me get rid of cfg_eval and stop using serde_with in alloy-eips.
use alloy_serde;
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Container {
#[serde(with = "alloy_serde::ssz::json::uint")]
value: u64,
}
let val = Container { value: 18112749083033600 };
let s = serde_json::to_string(&val).unwrap();
assert_eq!(s, "{\"value\":\"18112749083033600\"}");
let deserialized: Container = serde_json::from_str(&s).unwrap();
assert_eq!(val, deserialized);| #[cfg(feature = "serde")] | ||
| use cfg_eval::cfg_eval; |
There was a problem hiding this comment.
iiuc we need this because of how serde_as works. we could solve this with a helper like serde(with = "from_str") I guess
similarly to https://github.com/foundry-rs/foundry/blob/b4a47336038cd4d1342eedb3f9555772585e745f/crates/config/src/lib.rs#L2514-L2534 but without lowercase
|
Thanks for the latest feedback, I got caught in some other tasks but will address this round later this afternoon. |
Re-add {Deposit,Withdrawal,Consolidation}Request structs to relevant EIPs.
01d222f to
03ff69e
Compare
|
Ok, I think all new feedback has been addressed, let me know what you think, especially around #1787 (comment). edit: forgot to say rebased against latest master, so using |
|
Also Claude recommended a pretty good refactor on the edit: after some more back-and-forth with it I was also able to remove some of the vector copying (e.g. calling |
|
^ Actually I went ahead and nerd sniped myself into integrating it. 😊 |
| /// let deserialized: Container = serde_json::from_str(&s).unwrap(); | ||
| /// assert_eq!(val, deserialized); | ||
| /// ``` | ||
| pub mod uint { |
There was a problem hiding this comment.
can we rename this entire module to displayfromstr ?
There was a problem hiding this comment.
Ya will do, personally I have a slight preference for the current naming since it says why the encoding is used instead instead of how the encoding works, but I'll defer to you all.
| impl ExecutionRequestsV4 { | ||
| /// Convert the [ExecutionRequestsV4] into a [Requests]. | ||
| pub fn to_requests(&self) -> Requests { | ||
| self.into() | ||
| } | ||
| } |
There was a problem hiding this comment.
Yup, moved in daf7703. Required some addiitonal #[cfg(feature = "ssz") pragmas though.
This is a further cleaned up version of #1786 which also includes the necessary
ExecutionRequestsV4 <-> Requestsconversions. However, theRequests -> ExecutionRequestsV4conversion requires use of thessz_typescrate, which was added as a feature.Fixes #1763.
Motivation
As reviewing the builder-specs (and unsuccessfully attempting to change them with ethereum/builder-specs#107) I determined that the
V4relay submission actually needs to include the requests in their JSON "object" form rather than the encoded EIP-7865Vec<Bytes>.Solution
So, this restores some of the structs removed in #1515 and adds a new
ExecutionRequestsV4struct torpc-types-beacon.A couple things to note:
eipstructs I removed the "EL-specific" encoding helpers in favor of the CL flavors, adding a newalloy_serde::ssz::json::uintserde helper for encoing integers in SSZ "canonical JSON" format. I think this makes sense since these structs are no longer used by the EL/engine API, but I could be convinced to either move these structs inrpc-types-beaconor restore them with "EL-encoding" and add wrapper/custom serde functionality inrpc-types-beacon.quantityencoding onSignedBidSubmissionV4::target_blobs_per_blockwithDisplayFromStras I'm pretty sure this should be "decimal" encoded. NOTE: With 7742 pulled from PEctra I think this can be fully removed instead.crates/rpc-types-beacon/src/examples/relay_builder_block_validation_request_v4.jsonis a bit of frankenstein, it's a payload I captured from my locally runningrbuilderinside ourbuilder-playgroundwithexecution_requestsandtarget_blobs_per_blockmanually edited, but it's the best I could find at the moment.ExecutionRequestsV4objects that can be included in relay submissions, for example to close Pectra devnet-5:execution_requestsneeds latest alloy and should have therequest_typebyte prefixed to each flashbots/rbuilder#267.PR Checklist