fix(network): clear ENR nfd field when no next fork is scheduled during runtime transitions (#9131)

No. But related to #9009 and #8996


  - Change the `ForkContext::next_fork_digest()` to return `[u8; 4]` (returning `[0u8; 4]` for "no next fork").
- Update the initialization path and runtime fork transition path accordingly.

Added tests:
- [x] `test_next_fork_digest` — existing test passes with non-Option return type
- [x] `test_next_fork_digest_returns_zero_when_no_next_fork` — init at last BPO fork returns `[0u8; 4]`
- [x] `test_next_fork_digest_zero_after_runtime_transition_to_last_fork` — simulates `update_current_fork` to last fork, then verifies zero


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

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

Co-Authored-By: chonghe <44791194+chong-he@users.noreply.github.com>
This commit is contained in:
Alleysira
2026-06-06 04:16:28 +08:00
committed by GitHub
parent 42e678189c
commit abe7ca20a9
4 changed files with 46 additions and 13 deletions

View File

@@ -883,10 +883,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
fork_context.update_current_fork(*new_fork_name, new_fork_digest, current_epoch);
if self.beacon_chain.spec.is_peer_das_scheduled() {
let next_fork_digest = fork_context
.next_fork_digest()
.unwrap_or_else(|| fork_context.current_fork_digest());
self.libp2p.update_nfd(next_fork_digest);
self.libp2p.update_nfd(fork_context.next_fork_digest());
}
self.libp2p.update_fork_version(new_enr_fork_id);