-
Notifications
You must be signed in to change notification settings - Fork 249
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(relay): ExecutionRequestsV4 with eip7685::Requests conversion #1787
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EIP7742 will need to be removed here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits and qs
crates/eips/src/eip6110.rs
Outdated
#[cfg(feature = "serde")] | ||
use cfg_eval::cfg_eval; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?
can we do without? not familiar with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
crates/eips/src/eip6110.rs
Outdated
#[cfg(feature = "serde")] | ||
use cfg_eval::cfg_eval; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last pedantic nits
crates/serde/src/ssz.rs
Outdated
/// let deserialized: Container = serde_json::from_str(&s).unwrap(); | ||
/// assert_eq!(val, deserialized); | ||
/// ``` | ||
pub mod uint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't limited to uint
crates/serde/src/ssz.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename this entire module to displayfromstr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed in daf7703
impl ExecutionRequestsV4 { | ||
/// Convert the [ExecutionRequestsV4] into a [Requests]. | ||
pub fn to_requests(&self) -> Requests { | ||
self.into() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this top of mod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, moved in daf7703. Required some addiitonal #[cfg(feature = "ssz")
pragmas though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This is a further cleaned up version of #1786 which also includes the necessary
ExecutionRequestsV4 <-> Requests
conversions. However, theRequests -> ExecutionRequestsV4
conversion requires use of thessz_types
crate, 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
V4
relay 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
ExecutionRequestsV4
struct torpc-types-beacon
.A couple things to note:
eip
structs I removed the "EL-specific" encoding helpers in favor of the CL flavors, adding a newalloy_serde::ssz::json::uint
serde 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-beacon
or restore them with "EL-encoding" and add wrapper/custom serde functionality inrpc-types-beacon
.quantity
encoding onSignedBidSubmissionV4::target_blobs_per_block
withDisplayFromStr
as 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.json
is a bit of frankenstein, it's a payload I captured from my locally runningrbuilder
inside ourbuilder-playground
withexecution_requests
andtarget_blobs_per_block
manually edited, but it's the best I could find at the moment.ExecutionRequestsV4
objects that can be included in relay submissions, for example to close Pectra devnet-5:execution_requests
needs latest alloy and should have therequest_type
byte prefixed to each flashbots/rbuilder#267.PR Checklist