Skip to content

feat: add QUIC port#835

Merged
kdeme merged 1 commit into
masterfrom
feat/quic
Jan 12, 2026
Merged

feat: add QUIC port#835
kdeme merged 1 commit into
masterfrom
feat/quic

Conversation

@richard-ramos
Copy link
Copy Markdown
Member

Adds an optional quic port to ENRs

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds optional QUIC port support to Ethereum Node Records (ENRs) by extending the existing port infrastructure (TCP, UDP) to include QUIC ports. The implementation follows the same pattern as TCP/UDP ports, including both IPv4 (quic) and IPv6 (quic6) variants in the TypedRecord structure, though the current insertAddress logic only sets the IPv4 variant regardless of IP family (consistent with existing TCP/UDP behavior).

Key Changes:

  • Added quic and quic6 fields to the TypedRecord structure for storing QUIC port information
  • Extended all ENR initialization and update functions to accept an optional quicPort parameter with backward-compatible overloads
  • Updated Discovery v5 protocol to support QUIC port in node record creation and logging

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
eth/enr/enr.nim Added quic/quic6 fields to TypedRecord, extended insertAddress/init/update functions with quicPort parameter and backward-compatible overloads, added "quic"/"quic6" to RLP parser
eth/p2p/discoveryv5/protocol.nim Extended all newProtocol function signatures with enrQuicPort parameter, added multiple backward-compatible overloads, updated logging to include quicPort
eth/p2p/discoveryv5/node.nim Extended node update function with quicPort parameter and backward-compatible overload
tests/test_enr.nim Updated all Record.init and update calls with quicPort parameter, added assertions to verify quic field behavior for IPv4/IPv6 scenarios
tests/p2p/test_discoveryv5.nim Updated newProtocol calls to include quicPort parameter
tests/p2p/discv5_test_helper.nim Updated helper functions to pass quicPort parameter in Record.init and newProtocol calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@richard-ramos richard-ramos force-pushed the feat/quic branch 3 times, most recently from d2506d0 to c26fdf9 Compare December 9, 2025 14:30
Copy link
Copy Markdown
Contributor

@kdeme kdeme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in the process of adding IPv6 support (#837), which adds parameters similarly like this quic one.

So ideally I get that added together, not to have too many versions of these inits (and having to deprecate them then after).
But at the same time, it also become a bit much as function signature so I will look into different ways of initializing this.

What is that status of the quic usage / addition of CL clients?

Asking this because the quic field in ENR is also not a field with pre-defined meaning in the spec. But it makes sense to add of course.

But for now extraFields could also be used to add this.

Comment thread eth/enr/enr.nim
ip: Opt[IpAddress] = Opt.none(IpAddress),
tcpPort: Opt[Port] = Opt.none(Port),
udpPort: Opt[Port] = Opt.none(Port),
quicPort: Opt[Port] = Opt.none(Port),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of adding a parameter does have the potential of breaking current usages. E.g. when extraFields is passed as parameter but not specifically set with extraFields = ....

But perhaps fine as we control most/all of its usage? Not sure.

Comment thread eth/enr/enr.nim
ip: Opt[IpAddress] = Opt.none(IpAddress),
tcpPort: Opt[Port] = Opt.none(Port),
udpPort: Opt[Port] = Opt.none(Port),
quicPort: Opt[Port] = Opt.none(Port),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem ^

@arnetheduck
Copy link
Copy Markdown
Member

What is that status of the quic usage / addition of CL clients?

we're among the last to implement it

@kdeme
Copy link
Copy Markdown
Contributor

kdeme commented Dec 11, 2025

we're among the last to implement it

ok, I meant more regarding its deployment.
Is it being tested somewhere with clients that have support? Some devnet or so?
I just ran the discv5 crawler and I could not find one node that has this quic field in their ENR (mainnet + official testnets). So I assume that it is not default enabled on any client atm.

I know it is rather trivial, but is the quic field specced somewhere?

@arnetheduck
Copy link
Copy Markdown
Member

ethereum/consensus-specs#3644
ethereum/consensus-specs#3874

It's out there and used by the majority of clients, so it's maybe a crawler issue?

@kdeme
Copy link
Copy Markdown
Contributor

kdeme commented Dec 11, 2025

It's out there and used by the majority of clients, so it's maybe a crawler issue?

Could be, I added it rather quickly and test ran it. I'll verify later.

edit: Can confirm it was a mistake on my end. There are indeed a lot of nodes with the quic field in their ENR.

@arnetheduck
Copy link
Copy Markdown
Member

any blockers remaining here? cc @kdeme

banNodes, config, rng
)

proc newProtocol*(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the diff between the two newProtocol procs? Maybe we could have a comment there, or maybe one can be private. Or maybe we could have different proc names for the brand new procs, e.g., newProtocolABC so that we have simpler lookups.

Copy link
Copy Markdown
Contributor

@kdeme kdeme Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference is the bindIp parameter.

One accepts an IpAddress, the other (newer) one an Opt[IpAddress].
Functionally mostly the same, but with the important (and rather hidden) difference that passing a None there has the effect that this also gets passed down to the newDatagramTransport which underneath looks up for the appropriate "AnyAddress" (:: when dual stack, 0.0.0.0 when IPv4 only).

I want to deprecate the original one, and keep just the newer one with proper comment explaining this.

@kdeme
Copy link
Copy Markdown
Contributor

kdeme commented Jan 8, 2026

any blockers remaining here? cc @kdeme

Nothing really functional no.
Things get a bit ugly on the init side (but not a fault of this PR, more an indication), and I want to rework some of those inits and deprecate some, including some new ones that would get added here (the default IPv4 any address setting one should just get deprecated imo, the other one that got added for dual stack makes things confusing, we should have 1 way). So maybe we should not add those here in the first place, but I can also just deprecate them later if its urgent to merge this.

And also, as I mentioned in the review, it does break the ENR API a bit, but its not too bad as this is mostly (only?) directly used inside discv5 I think.

privKey: PrivateKey,
enrIp: Opt[IpAddress],
enrTcpPort, enrUdpPort: Opt[Port],
enrTcpPort, enrUdpPort, enrQuicPort: Opt[Port],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also do without altering this one (afaik it is not needed for nimbus-eth2 and I'd like to deprecate it).

proc newProtocol*(
privKey: PrivateKey,
enrIp: Opt[IpAddress],
enrTcpPort, enrUdpPort, enrQuicPort: Opt[Port],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem for this one

@kdeme
Copy link
Copy Markdown
Contributor

kdeme commented Jan 12, 2026

ok, I'll merge this PR and then apply changes similar as in #843

And look into deprecating some of it.

@kdeme kdeme merged commit 01193c8 into master Jan 12, 2026
20 checks passed
@kdeme kdeme deleted the feat/quic branch January 12, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants