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", debug "Could not decode the csc count ENR bitfield of peer",
peer = n.record.toURI(), exception = e.name, msg = e.msg peer = n.record.toURI(), exception = e.name, msg = e.msg
continue 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]) let attnetsBytes = n.record.get(enrAttestationSubnetsField, seq[byte])
if attnetsBytes.isOk(): if attnetsBytes.isOk():

View File

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

View File

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

View File

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