Skip to content

Commit eaa060d

Browse files
agnxshtersec
authored andcommitted
attempt to solve columndb issue + fix cgc with non-validator issue (#7507)
* attempt to solve columndb issue + fix cgc with non-validator issue * some more changes * oops * Update beacon_chain/gossip_processing/block_processor.nim --------- Co-authored-by: tersec <[email protected]>
1 parent 3969523 commit eaa060d

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

beacon_chain/gossip_processing/block_processor.nim

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ proc storeBackfillBlock(
236236
self.consensusManager.quarantine[].missing.del(signedBlock.root)
237237
var
238238
columnsOk = true
239-
malformed_cols: HashSet[int]
240239

241240
when signedBlock is gloas.SignedBeaconBlock:
242241
# For Gloas, we still need to store the columns if they're provided
@@ -252,17 +251,14 @@ proc storeBackfillBlock(
252251
if columns.len > 0 and kzgCommits.len > 0:
253252
for i in 0..<columns.len:
254253
let r = verify_data_column_sidecar_kzg_proofs(columns[i][])
255-
if r.isErr:
256-
malformed_cols.incl(i)
254+
if r.isErr():
257255
debug "backfill data column validation failed",
258256
blockRoot = shortLog(signedBlock.root),
259257
column_sidecar = shortLog(columns[i][]),
260258
blck = shortLog(signedBlock.message),
261259
signature = shortLog(signedBlock.signature),
262260
msg = r.error()
263-
264-
columnsOk = (dataColumnsOpt.get.lenu64 - malformed_cols.lenu64) >=
265-
(self.consensusManager.dag.cfg.NUMBER_OF_COLUMNS div 2)
261+
columnsOk = r.isOk()
266262

267263
if not columnsOk:
268264
return err(VerifierError.Invalid)
@@ -286,9 +282,9 @@ proc storeBackfillBlock(
286282

287283
# Only store data columns after successfully establishing block viability.
288284
let columns = dataColumnsOpt.valueOr: DataColumnSidecars @[]
285+
debug "Inserting columns into database (backfill)",
286+
indices = columns.mapIt($it[].index)
289287
for i in 0..<columns.len:
290-
if i in malformed_cols:
291-
continue
292288
self.consensusManager.dag.db.putDataColumnSidecar(columns[i][])
293289

294290
res
@@ -758,6 +754,8 @@ proc storeBlock(
758754

759755
# write data columns now that block has been written
760756
let data_columns = dataColumnsOpt.valueOr: DataColumnSidecars @[]
757+
debug "Inserting columns into database",
758+
indices = data_columns.mapIt($it.index)
761759
for col in data_columns:
762760
self.consensusManager.dag.db.putDataColumnSidecar(col[])
763761

beacon_chain/nimbus_beacon_node.nim

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ proc initFullNode(
427427
dag.cfg.CUSTODY_REQUIREMENT
428428
custodyColumns =
429429
dag.cfg.resolve_columns_from_custody_groups(
430-
node.network.nodeId,
431-
max(dag.cfg.SAMPLES_PER_SLOT.uint64,
432-
localCustodyGroups))
430+
node.network.nodeId, localCustodyGroups)
433431

434432
var sortedColumns = custodyColumns.toSeq()
435433
sort(sortedColumns)
@@ -606,8 +604,7 @@ proc initFullNode(
606604
if node.config.peerdasSupernode:
607605
node.network.loadCgcnetMetadataAndEnr(dag.cfg.NUMBER_OF_CUSTODY_GROUPS.uint8)
608606
else:
609-
node.network.loadCgcnetMetadataAndEnr(max(dag.cfg.SAMPLES_PER_SLOT.uint8,
610-
dag.cfg.CUSTODY_REQUIREMENT.uint8))
607+
node.network.loadCgcnetMetadataAndEnr(dag.cfg.CUSTODY_REQUIREMENT.uint8)
611608

612609
if node.config.lightClientDataServe:
613610
proc scheduleSendingLightClientUpdates(slot: Slot) =
@@ -1345,7 +1342,7 @@ proc addFuluMessageHandlers(
13451342
targetSubnets = node.readCustodyGroupSubnets()
13461343
custody = node.dag.cfg.get_custody_groups(
13471344
node.network.nodeId,
1348-
max(node.dag.cfg.SAMPLES_PER_SLOT, targetSubnets.uint64))
1345+
targetSubnets.uint64)
13491346

13501347
for i in custody:
13511348
let topic = getDataColumnSidecarTopic(forkDigest, i)
@@ -1392,8 +1389,7 @@ proc removeFuluMessageHandlers(node: BeaconNode, forkDigest: ForkDigest) =
13921389
let
13931390
targetSubnets = node.readCustodyGroupSubnets()
13941391
custody = node.dag.cfg.get_custody_groups(
1395-
node.network.nodeId,
1396-
max(node.dag.cfg.SAMPLES_PER_SLOT, targetSubnets.uint64))
1392+
node.network.nodeId, targetSubnets.uint64)
13971393

13981394
for i in custody:
13991395
let topic = getDataColumnSidecarTopic(forkDigest, i)
@@ -1974,11 +1970,10 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} =
19741970
# Update CGC and metadata with respect to the new detected validator custody
19751971
let new_vcus = CgcCount node.validatorCustody.newer_column_set.lenu64
19761972

1977-
if new_vcus > node.dag.cfg.SAMPLES_PER_SLOT.uint8:
1973+
if new_vcus > node.dag.cfg.CUSTODY_REQUIREMENT.uint8:
19781974
node.network.loadCgcnetMetadataAndEnr(new_vcus)
19791975
else:
1980-
node.network.loadCgcnetMetadataAndEnr(max(node.dag.cfg.SAMPLES_PER_SLOT.uint8,
1981-
node.dag.cfg.CUSTODY_REQUIREMENT.uint8))
1976+
node.network.loadCgcnetMetadataAndEnr(node.dag.cfg.CUSTODY_REQUIREMENT.uint8)
19821977

19831978
info "New validator custody count detected",
19841979
custody_columns = node.dataColumnQuarantine.custodyColumns.len

beacon_chain/sync/validator_custody.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ proc detectNewValidatorCustody*(vcus: ValidatorCustodyRef,
7373
newer_columns =
7474
vcus.dag.cfg.resolve_columns_from_custody_groups(
7575
vcus.network.nodeId,
76-
max(vcus.dag.cfg.SAMPLES_PER_SLOT.uint64,
76+
max(vcus.dag.cfg.CUSTODY_REQUIREMENT.uint64,
7777
vcustody))
7878

7979
debug "New validator custody count detected",

beacon_chain/validators/message_router.nim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,9 @@ proc routeSignedBeaconBlock*(
178178
# Push only those columns to processor for which we custody
179179
let
180180
metadata = router[].network.metadata.custody_group_count
181-
samples_per_slot = router[].network.cfg.SAMPLES_PER_SLOT
182181
custody_columns =
183182
router[].network.cfg.resolve_columns_from_custody_groups(
184-
router[].network.nodeId,
185-
max(samples_per_slot, metadata))
183+
router[].network.nodeId, metadata)
186184

187185
var final_columns: seq[ref fulu.DataColumnSidecar]
188186
for dc in dataColumns:

0 commit comments

Comments
 (0)