feat(l1): backward cap compatibility#2823
Closed
Mechanix97 wants to merge 34 commits intomainfrom
Closed
Conversation
…com:lambdaclass/ethrex into refactor/capability-struct-instead-of-tuple
…com:lambdaclass/ethrex into refactor/capability-struct-instead-of-tuple
Lines of code reportTotal lines added: Detailed view |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
A new version of the eth protocol has been released (eth/69) and some clients are supporting both eth/68 and eth/69 at the same time. We need a way of being able to encode/decode the msg from both versions of the protocol. Also, we need a way to remove easily the old version when it becomes deprecated.
Description
A new file structure was created to accommodate the new implementation:
crates/networking/p2p/rlpx/eth/
crates/networking/p2p/rlpx/eth/eth68/ -> (status.rs and receipt.rs)
crates/networking/p2p/rlpx/eth/eth69/ -> (status.rs and receipt.rs)
The implementation in the folder eth69 is the same as the one in eth68 for the moment. All the parts where it is going to be called are commented to illustrate the new implementation. It's going to be implemented in future PRs. Also, it's not activated as the SUPPORTED_ETH_CAPABILITIES is set to only support eth/68.
In the new eth/69 protocol the messages status and receipts have been changed. So a new intermediate structure was created. The encode for each version is decided by the type of the inner struct. But the decode is not that simple, as we don't know what kind of msg we received.
For the status msg was a little easier, as we received the eth version inside the msg we can decide which version of the protocol we are using.
For the receipt msg, the only difference is the bloom field. A new function
has_bloomhas been implemented to detect when a msg have the bloom field to process it as a eth/68. The newer eth/69 receipts msg won't have the bloom field (it can be calculated from the logs).Also, as the new structure is a proxy to the different version of the structure some new getters were needed.
Closes #2805
References:
EIP-7642
geth implementation
eth/69