fix: message router

This commit is contained in:
Agnish Ghosh 2024-06-26 02:38:04 +05:30
parent 81b55faee2
commit 87bc91febe
No known key found for this signature in database
GPG Key ID: 7BDDA05D1B25E9F8
3 changed files with 26 additions and 27 deletions

View File

@ -1107,6 +1107,11 @@ proc addCapellaMessageHandlers(
node.addAltairMessageHandlers(forkDigest, slot)
node.network.subscribe(getBlsToExecutionChangeTopic(forkDigest), basicParams)
proc fetchCustodySubnetCount* (res: var uint64, node: BeaconNode) =
res = CUSTODY_REQUIREMENT
if node.config.subscribeAllSubnets:
res = DATA_COLUMN_SIDECAR_SUBNET_COUNT
proc addDenebMessageHandlers(
node: BeaconNode, forkDigest: ForkDigest, slot: Slot) =
node.addCapellaMessageHandlers(forkDigest, slot)

View File

@ -13,7 +13,6 @@ import
stew/results,
ssz_serialization/proofs,
chronicles,
../beacon_node,
./[beacon_time, crypto],
kzg4844/kzg_ex,
eth/p2p/discoveryv5/[node],
@ -30,11 +29,6 @@ proc sortedColumnIndices*(columnsPerSubnet: ColumnIndex, subnetIds: HashSet[uint
res.sort()
res
proc fetchCustodySubnetCount* (res: var uint64, conf: BeaconNode) =
res = CUSTODY_REQUIREMENT
if node.config.subscribeAllSubnets:
res = DATA_COLUMN_SIDECAR_SUBNET_COUNT
proc get_custody_column_subnet*(node_id: NodeId, custody_subnet_count: uint64): Result[HashSet[uint64], cstring] =
# fetches the subnets for custody column for the current node
# assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT

View File

@ -161,27 +161,27 @@ proc routeSignedBeaconBlock*(
notice "Blob sent", blob = shortLog(blobs[i])
blobRefs = Opt.some(blobs.mapIt(newClone(it)))
# var dataColumnRefs = Opt.none(DataColumnSidecars)
# when typeof(blck).kind >= ConsensusFork.Deneb:
# if blobsOpt.isSome():
# let blobs = blobsOpt.get()
# let data_columns = get_data_column_sidecars(blck, blobs.mapIt(it.blob)).get()
# var das_workers = newSeq[Future[SendResult]](len(data_columns))
# for i in 0..<data_columns.lenu64:
# let subnet_id = compute_subnet_for_data_column_sidecar(i)
# das_workers[i] =
# router[].network.broadcastDataColumnSidecar(subnet_id, data_columns[i])
# let allres = await allFinished(das_workers)
# for i in 0..<allres.len:
# let res = allres[i]
# doAssert res.finished()
# if res.failed():
# notice "Data Columns not sent",
# data_column = shortLog(data_columns[i]), error = res.error[]
# else:
# notice "Data columns sent", data_column = shortLog(data_columns[i])
# blobRefs = Opt.some(blobs.mapIt(newClone(it)))
# dataColumnRefs = Opt.some(data_columns.mapIt(newClone(it)))
var dataColumnRefs = Opt.none(DataColumnSidecars)
when typeof(blck).kind >= ConsensusFork.Deneb:
if blobsOpt.isSome():
let blobs = blobsOpt.get()
let data_columns = get_data_column_sidecars(blck, blobs.mapIt(it.blob)).get()
var das_workers = newSeq[Future[SendResult]](len(data_columns))
for i in 0..<data_columns.lenu64:
let subnet_id = compute_subnet_for_data_column_sidecar(i)
das_workers[i] =
router[].network.broadcastDataColumnSidecar(subnet_id, data_columns[i])
let allres = await allFinished(das_workers)
for i in 0..<allres.len:
let res = allres[i]
doAssert res.finished()
if res.failed():
notice "Data Columns not sent",
data_column = shortLog(data_columns[i]), error = res.error[]
else:
notice "Data columns sent", data_column = shortLog(data_columns[i])
blobRefs = Opt.some(blobs.mapIt(newClone(it)))
dataColumnRefs = Opt.some(data_columns.mapIt(newClone(it)))
let added = await router[].blockProcessor[].addBlock(
MsgSource.api, ForkedSignedBeaconBlock.init(blck), blobRefs, Opt.none(DataColumnSidecars))