-
Notifications
You must be signed in to change notification settings - Fork 236
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: embed consensus header into RPC #1573
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.
this will unlock a ton of simplifications
/// Block header representation with certain fields made optional to account for possible | ||
/// differencies in network implementations. | ||
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] | ||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] | ||
pub struct AnyHeader { |
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 yeah we def need this for foundry
|
||
type TransactionRequest = WithOtherFields<TransactionRequest>; | ||
|
||
type TransactionResponse = WithOtherFields<Transaction>; | ||
|
||
type ReceiptResponse = AnyTransactionReceipt; | ||
|
||
type HeaderResponse = Header; | ||
type HeaderResponse = alloy_rpc_types_eth::Header<Self::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.
nice
Changes in this PR:
size
is moved from block body to header. we don't have a way to distinct which fields in RPC belong to block body vs header but moving size to header leaves RPC block fields as header + flattened body which makes sense imorpc_types_eth::Header
now wraps an inner consensus header and additionaly storeshash
,totalDifficulty
andsize
which are RPC-specificAnyHeader
in alloy-consensus crate which is the same asalloy_consensus::Header
withmixHash
andnonce
being optional.HeaderResponse
trait is removed andNetwork::HeaderResponse
is now required to implementAsRef<Network::Header>
making it possible to simply use methods from consensusBlockHeader
trait everywhere