-
Notifications
You must be signed in to change notification settings - Fork 56
Add SSZ to PBS #372
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
base: main
Are you sure you want to change the base?
Add SSZ to PBS #372
Conversation
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.
We should ideally also test this with kurtosis
|
||
/// Parse CONSENSUS_VERSION header | ||
pub fn get_consensus_version_header(req_headers: &HeaderMap) -> Option<ForkName> { | ||
ForkName::from_str( |
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.
woth double checking this is not case sensitive
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.
just realized we have our own ForkName
, we could also import it from lighthouse
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.
For case sensitivity, it's defined the way the spec defines it (https://github.com/ethereum/beacon-APIs/blob/672e03e25ace85a3bacaea553fbf374f4f844435/apis/beacon/blocks/blocks.yaml#L21) but Rust will convert everything to lower case regardless.
For ForkName, done in 86fa858.
crates/common/src/utils.rs
Outdated
} | ||
} | ||
|
||
impl FromStr for Accept { |
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.
would it be easier to use crate for this for easier maintainability? eg https://github.com/bltavares/axum-content-negotiation or https://docs.rs/headers-accept/latest/headers_accept/
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.
Done in e7335f6.
crates/common/src/utils.rs
Outdated
|
||
#[must_use] | ||
#[derive(Debug, Clone, Copy, Default)] | ||
pub struct JsonOrSsz<T>(pub T); |
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.
thinking about what we'll have to do with: #326, i 'd rather just do this in a function and use a simple "Bytes" extractor on the axum body. Can just pass headers and body and get back T
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, refactored a bunch of the setup in e7335f6 to provide exactly this.
crates/pbs/src/routes/get_header.rs
Outdated
|
||
BEACON_NODE_STATUS.with_label_values(&["200", GET_HEADER_ENDPOINT_TAG]).inc(); | ||
Ok((StatusCode::OK, axum::Json(max_bid)).into_response()) | ||
let response = match accept_header { |
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.
here we just asssume the relay just support both? probably fine but ok double checking
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.
We do, if we want to add support for relays that only allow JSON for example, we'll have to probably figure that out on startup and flag them accordingly so we don't ping them to negotiate encoding with every request (assuming they never change it down the line). Do we have stats on how many support SSZ and how many don't?
This is a modernization of #252 since that's been dormant for a while, but was re-raised in #364. Just about everything was ported over cleanly.