added support for customisable custody subnet count on boot, from bn startup flags

This commit is contained in:
Agnish Ghosh 2024-08-20 03:58:27 +05:30
parent f142dcd36f
commit 70029545ea
2 changed files with 28 additions and 1 deletions

View File

@ -2598,6 +2598,22 @@ proc updateStabilitySubnetMetadata*(node: Eth2Node, attnets: AttnetBits) =
else:
debug "Stability subnets changed; updated ENR attnets", attnets
proc loadCscnetsMetadata*(node: Eth2Node, cscnets: uint64) =
if node.metadata.custody_subnet_count == cscnets:
return
node.metadata.custody_subnet_count = cscnets
let res = node.discovery.updateRecord({
enrCustodySubnetCountField: SSZ.encode(node.metadata.custody_subnet_count)})
if res.isErr:
# This should not occur in this scenario as the private key would always
# be the correct one and the ENR will not increase in size.
warn "Failed to update the ENR syncnets field", error = res.error
else:
debug "Sync committees changed; updated ENR syncnets", cscnets
proc updateSyncnetsMetadata*(node: Eth2Node, syncnets: SyncnetBits) =
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/altair/validator.md#sync-committee-subnet-stability
if node.metadata.syncnets == syncnets:

View File

@ -1153,6 +1153,15 @@ proc addDenebMessageHandlers(
for topic in dataColumnSidecarTopics(forkDigest, targetSubnets):
node.network.subscribe(topic, basicParams)
if node.config.subscribeAllSubnets:
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.uint64)
else:
node.network.loadCscnetsMetadata(CUSTODY_REQUIREMENT.uint64)
proc addElectraMessageHandlers(
node: BeaconNode, forkDigest: ForkDigest, slot: Slot) =
node.addDenebMessageHandlers(forkDigest, slot)
@ -1544,7 +1553,9 @@ proc reconstructAndSendDataColumns*(node: BeaconNode) {.async.} =
return
notice "Data Column Reconstructed and Saved Successfully"
let dc = data_column_sidecars.get
var das_workers = newSeq[Future[SendResult]](len(dc))
var
worker_count = len(dc)
das_workers = newSeq[Future[SendResult]](worker_count)
for i in 0..<dc.lenu64:
let subnet_id = compute_subnet_for_data_column_sidecar(i)
das_workers[i] =