From 2826e90dffb4732ea53c0ebd2822b76a39242886 Mon Sep 17 00:00:00 2001 From: Manu NALEPA Date: Wed, 24 Apr 2024 16:04:12 +0200 Subject: [PATCH] Implement `custody_subnet_count` ENR field. (#13915) https://github.com/ethereum/consensus-specs/blob/dev/specs/_features/eip7594/p2p-interface.md#the-discovery-domain-discv5 --- beacon-chain/p2p/discovery.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/beacon-chain/p2p/discovery.go b/beacon-chain/p2p/discovery.go index 9949ade031af..33b749ee79f0 100644 --- a/beacon-chain/p2p/discovery.go +++ b/beacon-chain/p2p/discovery.go @@ -47,7 +47,10 @@ const ( udp6 ) -type quicProtocol uint16 +type ( + quicProtocol uint16 + custodySubnetCount uint64 +) // quicProtocol is the "quic" key, which holds the QUIC port of the node. func (quicProtocol) ENRKey() string { return "quic" } @@ -133,6 +136,9 @@ func (l *listenerWrapper) RebootListener() error { return nil } +// https://github.com/ethereum/consensus-specs/blob/dev/specs/_features/eip7594/p2p-interface.md#the-discovery-domain-discv5 +func (custodySubnetCount) ENRKey() string { return "custody_subnet_count" } + // RefreshPersistentSubnets checks that we are tracking our local persistent subnets for a variety of gossip topics. // This routine checks for our attestation, sync committee and data column subnets and updates them if they have // been rotated. @@ -371,6 +377,11 @@ func (s *Service) createLocalNode( localNode.Set(quicEntry) } + if features.Get().EnablePeerDAS { + custodySubnetEntry := custodySubnetCount(params.BeaconConfig().CustodyRequirement) + localNode.Set(custodySubnetEntry) + } + localNode.SetFallbackIP(ipAddr) localNode.SetFallbackUDP(udpPort)