fix(network): set ENR nfd to zero bytes when next fork is unknown (#9009)

Fixes #8996


  When no next fork is scheduled, the `nfd` field in the ENR was set to the current fork digest via
`.unwrap_or_else(|| ctx.fork_context.current_fork_digest())`.

According to the [spec](1baa05e711/specs/fulu/p2p-interface.md (L636-L637)), `nfd` should be zero-valued bytes when the next fork is unknown.


Co-Authored-By: Alleysira <1367108378@qq.com>

Co-Authored-By: Alleysira <56925051+Alleysira@users.noreply.github.com>

Co-Authored-By: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
Alleysira
2026-03-24 06:07:37 +08:00
committed by GitHub
parent b3d5185893
commit 7ffc637eef

View File

@@ -187,10 +187,9 @@ impl<E: EthSpec> Network<E> {
// set up a collection of variables accessible outside of the network crate
// Create an ENR or load from disk if appropriate
let next_fork_digest = ctx
.fork_context
.next_fork_digest()
.unwrap_or_else(|| ctx.fork_context.current_fork_digest());
// Per [spec](https://github.com/ethereum/consensus-specs/blob/1baa05e71148b0975e28918ac6022d2256b56f4a/specs/fulu/p2p-interface.md?plain=1#L636-L637)
// `nfd` must be zero-valued when no next fork is scheduled.
let next_fork_digest = ctx.fork_context.next_fork_digest().unwrap_or_default();
let advertised_cgc = config
.advertise_false_custody_group_count