-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add support for eth/70 eip-7975 #20255
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?
Conversation
| /// The request id used to correlate the response. | ||
| pub request_id: 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.
I think we don't need this here because the request id is tracked in
reth/crates/net/eth-wire-types/src/message.rs
Line 581 in 2e62387
| pub struct RequestPair<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.
I think we can exclude all of this for this pr?
| EthMessageID::GetReceipts => EthMessage::GetReceipts(RequestPair::decode(buf)?), | ||
| EthMessageID::GetReceipts => { | ||
| if version >= EthVersion::Eth70 { | ||
| EthMessage::GetReceipts70(GetReceipts70::decode(buf)?) |
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 should also use RequestPair
| /// Index into the receipts of the first requested block hash. | ||
| pub first_block_receipt_index: u64, | ||
| /// The block hashes to request receipts for. | ||
| pub block_hashes: Vec<B256>, |
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.
then we need to adjust rlp encoding of this type so that this becomes:
firstBlockReceiptIndex: P, [blockhash₁: B_32, blockhash₂: B_32, ...]
and not
[firstBlockReceiptIndex: P, [blockhash₁: B_32, blockhash₂: B_32, ...]]]
like it would with the macro
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.
these changes we can also undo
mattsse
left a comment
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.
cool,
we can simplify a lot of things here, basically the session shouldnt have to deal with any response manipulation
this has some additional changes for the withdrawn eip that we can fully exclude from this pr
|
|
||
| /// `StatusMessage` can store either the Legacy version (with TD) or the | ||
| /// eth/69 version (omits TD). | ||
| /// Status message for `eth/70` including the block range as per EIP-7975. |
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 dont need this anymore, right? so we can undo all status changes I believe
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.
Yeah forgot to change the comment here
| /// | ||
| /// Note: The eth/70 encoding for `Receipts` in EIP-7975 inlines the | ||
| /// request id instead of using a generic [`RequestPair`]. | ||
| Receipts70(Receipts70<N::Receipt>), |
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 should also use RequestPair and we can implement encode manually for Receipts70
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.
I think we have used RequestPair here , but the comment isn't clear , i.e. :
pub type Receipts70<T = Receipt> = crate::message::RequestPair<Receipts70Payload>;
Will make others misunderstood that we don't use RequestPair here but i wil simplify it
| /// The last time we updated the remote block range information. | ||
| pub(crate) last_range_update: Option<Instant>, |
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 isnt needed for 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.
Have removed them
| request_id, | ||
| rx: PeerResponse::$resp_item { response }, | ||
| received: Instant::now(), | ||
| metadata: ReceivedRequestMetadata::None, |
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 can assume that we handle the request properly internally so we dont need to track this here
| fn handle_outgoing_response( | ||
| &mut self, | ||
| id: u64, | ||
| metadata: ReceivedRequestMetadata, | ||
| resp: PeerResponseResult<N>, | ||
| ) { | ||
| let msg_result = match metadata { | ||
| ReceivedRequestMetadata::Eth70Receipts { first_block_receipt_index } => { | ||
| // For eth/70 GetReceipts requests we construct a `Receipts70` | ||
| // message that respects `firstBlockReceiptIndex` but still | ||
| // reuses the existing receipts lookup path. | ||
| self.build_eth70_receipts_response(id, first_block_receipt_index, resp) | ||
| } | ||
| ReceivedRequestMetadata::None => resp.try_into_message(id), | ||
| }; | ||
|
|
||
| match msg_result { |
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 we dont need to change, we can instead introduce another variant for this so we can handle the v70 request internally properly
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.
makes sense
| fn build_eth70_receipts_response( | ||
| &self, | ||
| id: u64, | ||
| first_block_receipt_index: u64, | ||
| resp: PeerResponseResult<N>, | ||
| ) -> RequestResult<EthMessage<N>> { |
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 we can undo, this should be handled where we process the request
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.
Suspect so , but thanks for the confirm
This targets on issue #19805 , since eip-7542 has been withdrawn , this PR is implementing eip-7975 .
Scope of this PR:
cc @mattsse