Skip to content

feat(l1): add eth to enr #2654

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

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft

feat(l1): add eth to enr #2654

wants to merge 31 commits into from

Conversation

mechanix97
Copy link
Contributor

@mechanix97 mechanix97 commented Apr 30, 2025

Motivation

The eth pair was not implemented in the current node record struct.

Using this information when trying to connect to a new peer, allow us to discard incompatible nodes faster

Description

The fork_id struct is constructed only once before the handling process starts

The eth pair contains a single element list, which is a ForkId element. It's encoded/decoded using the default RLP procedure.

When exchanging the ENRrequest/ENRresponse messages the eth pair is included

It can be tested starting a new node with debug level:

cargo run --bin ethrex -- --network test_data/genesis-kurtosis.json --log.level=debug

And connecting a new peer using the following command:

cargo run --bin ethrex -- \
--network ./test_data/genesis-kurtosis.json \
--bootnodes=$(curl -s http://localhost:8545 \
-X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' \
| jq -r '.result.enode') \
--datadir=ethrex_c \
--authrpc.port=8553 \
--http.port=8547 \
--p2p.port=30388 \
--discovery.port=30310

A debug msg can be seen once the eth pair is validated

ETH enr entry
EIP-2124
Ethrex Docs

Closes #1799

@mechanix97 mechanix97 added p2p Issues related to p2p network L1 Ethereum client labels Apr 30, 2025
@mechanix97 mechanix97 changed the title feat(L1, P2P) add eth to enr feat(l1, p2p) add eth to enr Apr 30, 2025
Copy link

github-actions bot commented Apr 30, 2025

Lines of code report

Total lines added: 124
Total lines removed: 5
Total lines changed: 129

Detailed view
+--------------------------------------------------+-------+------+
| File                                             | Lines | Diff |
+--------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/ethrex.rs                      | 91    | +3   |
+--------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/initializers.rs                | 390   | +11  |
+--------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2.rs                          | 259   | +3   |
+--------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/utils.rs                       | 145   | +17  |
+--------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/discv4/server.rs    | 735   | +53  |
+--------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/network.rs          | 178   | +1   |
+--------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/backend.rs | 114   | -5   |
+--------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/types.rs            | 424   | +19  |
+--------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/utils.rs            | 414   | +1   |
+--------------------------------------------------+-------+------+
| ethrex/crates/storage/store.rs                   | 1241  | +16  |
+--------------------------------------------------+-------+------+

@mechanix97 mechanix97 linked an issue Apr 30, 2025 that may be closed by this pull request
@mechanix97 mechanix97 changed the title feat(l1, p2p) add eth to enr feat(l1, p2p): add eth to enr Apr 30, 2025
@mechanix97 mechanix97 changed the title feat(l1, p2p): add eth to enr feat(l1): add eth to enr May 5, 2025
@mechanix97 mechanix97 self-assigned this May 5, 2025
@mechanix97 mechanix97 marked this pull request as ready for review May 5, 2025 21:54
@mechanix97 mechanix97 requested a review from a team as a code owner May 5, 2025 21:54
@mechanix97 mechanix97 marked this pull request as draft May 7, 2025 14:18
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.

Read eth Entry from the Node ENR record
1 participant