Skip to content

Conversation

@ElFantasma
Copy link
Contributor

Motivation
We need to support DiscV5

Description

This is a WIP that adds a discv5::server and discv5::peer_table to support the protocol.
It is an unfinished set of features, but I pretend to merge this big PR to be able to work in sub-features separately. All this functionality is still behind an experimental-discv5 feature flag, so none of this code is run if the feature is not enabled. Discv4 still is the only supported protocol.

Currently this performs:

  • Outgoing handshake (including secret sharing and encryption)
  • FindNode requests
  • handles Nodes responses
  • Populates the PeerTable with these responses
    With this functionality it is enough to start testing and even finding some useful peers, but this does not complete the spec:

I will start issuing in a set of tickets the missing functionality. But mostly:

  • It does not handle incoming FindNode or handshake requests
  • It does not filter peers using the ENR information
  • It does not revalidate or clean up discarded peers
  • Several other validations need to be done
  • It lacks some encoding/decoding tests

ElFantasma and others added 30 commits December 9, 2025 10:31
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5574 and #5575.

Co-authored-by: Esteban Dimitroff Hodi <[email protected]>
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5580 and #5581
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5578 and #5579
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5576 and closes #5577
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #issue_number
**Motivation**
I saw current new_nonce impl allocated a vector when it can just return
a fixed size array.

**Description**

Removes the needless vec

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.
**Motivation**

In order to start merging discv5 code into main, to avoid having a huge
PR at the end of the development, we should create a feature flag
disabled by default.

Closes #5639
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5586
Closes #5587
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5570
Closes #5571
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5566
Closes #5567
@ElFantasma ElFantasma requested a review from a team as a code owner January 7, 2026 22:57
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Lines of code report

Total lines added: 1968
Total lines removed: 82
Total lines changed: 2050

Detailed view
+---------------------------------------------------+-------+-------+
| File                                              | Lines | Diff  |
+---------------------------------------------------+-------+-------+
| ethrex/cmd/ethrex/cli.rs                          | 800   | -2    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/common/rlp/structs.rs               | 167   | +3    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/codec.rs      | 33    | -39   |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/messages.rs   | 1295  | +304  |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/mod.rs        | 5     | +2    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/peer_table.rs | 1139  | +1139 |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/server.rs     | 504   | +504  |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/session.rs    | 124   | -33   |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/network.rs           | 362   | -4    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/p2p.rs               | 23    | +8    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/rlpx/initiator.rs    | 101   | -4    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/types.rs             | 542   | +3    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/utils.rs             | 194   | +5    |
+---------------------------------------------------+-------+-------+

@ElFantasma ElFantasma changed the title Discv5 server - WIP feat(l1): Discv5 server - WIP Jan 8, 2026
@github-actions github-actions bot added the L1 Ethereum client label Jan 8, 2026
@ElFantasma ElFantasma changed the title feat(l1): Discv5 server - WIP feat(l1): discv5 server - WIP Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants