From 2ff165d304fb61800a433592fc290e786557840d Mon Sep 17 00:00:00 2001 From: Agnish Ghosh Date: Mon, 23 Sep 2024 14:06:33 +0530 Subject: [PATCH] fix enr advertising --- beacon_chain/networking/eth2_network.nim | 7 +++---- beacon_chain/nimbus_beacon_node.nim | 10 +++++----- beacon_chain/spec/datatypes/eip7594.nim | 4 ++-- beacon_chain/sync/request_manager.nim | 1 - 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/beacon_chain/networking/eth2_network.nim b/beacon_chain/networking/eth2_network.nim index 1037bae86..fd48409dd 100644 --- a/beacon_chain/networking/eth2_network.nim +++ b/beacon_chain/networking/eth2_network.nim @@ -1562,8 +1562,7 @@ proc runDiscoveryLoop(node: Eth2Node) {.async.} = (wantedAttnets, wantedSyncnets, wantedCscnets) = node.getLowSubnets(currentEpoch) wantedAttnetsCount = wantedAttnets.countOnes() wantedSyncnetsCount = wantedSyncnets.countOnes() - wantedCscnetsCount = wantedCscnets.countOnes().uint64() - wantedCscnetsBEBytes = wantedCscnetsCount.toBytesBE() + wantedCscnetsCount = wantedCscnets.countOnes().uint8() outgoingPeers = node.peerPool.lenCurrent({PeerType.Outgoing}) targetOutgoingPeers = max(node.wantedPeers div 10, 3) @@ -2635,10 +2634,10 @@ proc updateStabilitySubnetMetadata*(node: Eth2Node, attnets: AttnetBits) = debug "Stability subnets changed; updated ENR attnets", attnets proc loadCscnetsMetadata*(node: Eth2Node, cscnets: CscCount) = - if node.metadata.custody_subnet_count == cscnets: + if node.metadata.custody_subnet_count == cscnets.uint64: return - node.metadata.custody_subnet_count = cscnets + node.metadata.custody_subnet_count = cscnets.uint64 let res = node.discovery.updateRecord({ enrCustodySubnetCountField: SSZ.encode(node.metadata.custody_subnet_count)}) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 488e13183..ade97f26b 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -1152,8 +1152,8 @@ proc addDenebMessageHandlers( let targetSubnets = node.fetchCustodySubnetCount() custody_subnets = - node.network.nodeId.get_custody_column_subnets(max(SAMPLES_PER_SLOT.uint64, - targetSubnets)) + node.network.nodeId.get_custody_column_subnets(max(SAMPLES_PER_SLOT.uint8, + targetSubnets.uint8)) debugEcho "Target Subnets" debugEcho targetSubnets @@ -1169,13 +1169,13 @@ proc addDenebMessageHandlers( node.network.subscribe(topic, basicParams) if node.config.subscribeAllSubnets: - node.network.loadCscnetsMetadata(DATA_COLUMN_SIDECAR_SUBNET_COUNT.uint64) + node.network.loadCscnetsMetadata(DATA_COLUMN_SIDECAR_SUBNET_COUNT.uint8) elif not node.config.subscribeAllSubnets: let csc = node.config.custodySubnetCount if csc.isSome and csc.get < DATA_COLUMN_SIDECAR_SUBNET_COUNT: - node.network.loadCscnetsMetadata(csc.get.uint64) + node.network.loadCscnetsMetadata(csc.get.uint8) else: - node.network.loadCscnetsMetadata(CUSTODY_REQUIREMENT.uint64) + node.network.loadCscnetsMetadata(CUSTODY_REQUIREMENT.uint8) proc addElectraMessageHandlers( node: BeaconNode, forkDigest: ForkDigest, slot: Slot) = diff --git a/beacon_chain/spec/datatypes/eip7594.nim b/beacon_chain/spec/datatypes/eip7594.nim index 180fbabeb..70390ba2b 100644 --- a/beacon_chain/spec/datatypes/eip7594.nim +++ b/beacon_chain/spec/datatypes/eip7594.nim @@ -77,14 +77,14 @@ type row_index*: RowIndex CscBits* = BitArray[DATA_COLUMN_SIDECAR_SUBNET_COUNT] - CscCount* = uint64 + CscCount* = uint8 # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/_features/eip7594/p2p-interface.md#metadata MetaData* = object seq_number*: uint64 attnets*: AttnetBits syncnets*: SyncnetBits - custody_subnet_count*: CscCount + custody_subnet_count*: uint64 # func serializeDataColumn(data_column: DataColumn): auto = # var counter = 0 diff --git a/beacon_chain/sync/request_manager.nim b/beacon_chain/sync/request_manager.nim index f26bf139c..1f740f5d4 100644 --- a/beacon_chain/sync/request_manager.nim +++ b/beacon_chain/sync/request_manager.nim @@ -315,7 +315,6 @@ proc fetchDataColumnsFromNetwork(rman: RequestManager, colIdList: seq[DataColumnIdentifier]) {.async: (raises: [CancelledError]).} = var peer: Peer - var peers: seq[Peer] try: peer = await rman.network.peerPool.acquire()