all fixes related to enr

This commit is contained in:
Agnish Ghosh 2024-09-09 22:09:10 +05:30
parent d461d3f25f
commit c09d801fb2
4 changed files with 14 additions and 8 deletions

View File

@ -161,6 +161,12 @@ proc queryRandom*(
debug "Could not decode the csc count ENR bitfield of peer",
peer = n.record.toURI(), exception = e.name, msg = e.msg
continue
if wantedCscnets == cscnetsNode:
score += 1
else:
debug "Wanted csc count and decode csc from enr does not match!",
wantedCsc = wantedCscnets, cscNets = cscnetsNode
let attnetsBytes = n.record.get(enrAttestationSubnetsField, seq[byte])
if attnetsBytes.isOk():

View File

@ -1550,7 +1550,7 @@ proc getLowSubnets(node: Eth2Node, epoch: Epoch):
findLowSubnets(getSyncCommitteeTopic, SyncSubcommitteeIndex, SYNC_COMMITTEE_SUBNET_COUNT)
else:
default(SyncnetBits),
findLowSubnets(getDataColumnSidecarTopic, uint64, DATA_COLUMN_SIDECAR_SUBNET_COUNT.int)
findLowSubnets(getDataColumnSidecarTopic, uint64, (DATA_COLUMN_SIDECAR_SUBNET_COUNT div 2).int)
)
proc runDiscoveryLoop(node: Eth2Node) {.async.} =
@ -1581,7 +1581,7 @@ proc runDiscoveryLoop(node: Eth2Node) {.async.} =
node.discoveryForkId,
wantedAttnets,
wantedSyncnets,
uint64.fromBytesBE(wantedCscnetsBEBytes),
wantedCscnetsCount,
minScore)
let newPeers = block:
@ -2466,10 +2466,10 @@ proc lookupCscFromPeer*(peer: Peer): uint64 =
return csc
except SszError as e:
debug "Could not decide the csc field in the ENR"
return 0
return CUSTODY_REQUIREMENT
except SerializationError:
debug "Error in serializing the value"
return 0
return CUSTODY_REQUIREMENT
func shortForm*(id: NetKeyPair): string =
$PeerId.init(id.pubkey)

View File

@ -1167,13 +1167,13 @@ proc addDenebMessageHandlers(
node.network.subscribe(topic, basicParams)
if node.config.subscribeAllSubnets:
node.network.loadCscnetsMetadata(DATA_COLUMN_SIDECAR_SUBNET_COUNT)
node.network.loadCscnetsMetadata(DATA_COLUMN_SIDECAR_SUBNET_COUNT.uint64)
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)
node.network.loadCscnetsMetadata(csc.get.uint64)
else:
node.network.loadCscnetsMetadata(CUSTODY_REQUIREMENT)
node.network.loadCscnetsMetadata(CUSTODY_REQUIREMENT.uint64)
proc addElectraMessageHandlers(
node: BeaconNode, forkDigest: ForkDigest, slot: Slot) =

View File

@ -76,7 +76,7 @@ type
column_index*: ColumnIndex
row_index*: RowIndex
CscBits* = BitArray[DATA_COLUMN_SIDECAR_SUBNET_COUNT]
CscBits* = BitArray[DATA_COLUMN_SIDECAR_SUBNET_COUNT div 2]
CscCount* = uint64
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/_features/eip7594/p2p-interface.md#metadata