Skip to content

feat(l1): backward cap compatibility#2823

Closed
Mechanix97 wants to merge 34 commits intomainfrom
feat/backward-cap-compatibility
Closed

feat(l1): backward cap compatibility#2823
Mechanix97 wants to merge 34 commits intomainfrom
feat/backward-cap-compatibility

Conversation

@Mechanix97
Copy link
Copy Markdown
Contributor

@Mechanix97 Mechanix97 commented May 16, 2025

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_bloom has 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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 16, 2025

Lines of code report

Total lines added: 323
Total lines removed: 26
Total lines changed: 349

Detailed view
+--------------------------------------------------------+-------+------+
| File                                                   | Lines | Diff |
+--------------------------------------------------------+-------+------+
| ethrex/crates/common/rlp/error.rs                      | 27    | +2   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/peer_handler.rs           | 579   | +1   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/connection.rs        | 546   | +3   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/error.rs             | 78    | +2   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/backend.rs       | 93    | -26  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth68/mod.rs     | 2     | +2   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth68/receipt.rs | 40    | +40  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth68/status.rs  | 59    | +59  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth69/mod.rs     | 1     | +1   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth69/receipt.rs | 40    | +40  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth69/status.rs  | 59    | +59  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/mod.rs           | 7     | +7   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/receipts.rs      | 189   | +77  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/status.rs        | 89    | +30  |
+--------------------------------------------------------+-------+------+

@Mechanix97 Mechanix97 self-assigned this May 19, 2025
@Mechanix97 Mechanix97 marked this pull request as ready for review May 20, 2025 19:56
@Mechanix97 Mechanix97 requested a review from a team as a code owner May 20, 2025 19:56
@Mechanix97 Mechanix97 added p2p Issues related to p2p network L1 Ethereum client labels May 21, 2025
@Mechanix97 Mechanix97 marked this pull request as draft May 23, 2025 21:04
@Mechanix97 Mechanix97 closed this May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client p2p Issues related to p2p network

Projects

None yet

Development

Successfully merging this pull request may close these issues.

L1: implement backward compatibility of eth capabilities

1 participant