fix enr advertising

This commit is contained in:
Agnish Ghosh 2024-09-23 14:06:33 +05:30
parent d08044f584
commit 2ff165d304
4 changed files with 10 additions and 12 deletions

View File

@ -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)})

View File

@ -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) =

View File

@ -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

View File

@ -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()