Skip to content

Commit 4f069fc

Browse files
authored
column serving issue and other fixes (#7528)
* column serving issue and other fixes * another change * remove downscore * fixes
1 parent 62ba6e9 commit 4f069fc

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

beacon_chain/gossip_processing/block_processor.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ proc storeBackfillBlock(
285285
# Only store data columns after successfully establishing block viability.
286286
let columns = dataColumnsOpt.valueOr: DataColumnSidecars @[]
287287
debug "Inserting columns into database (backfill)",
288-
indices = columns.mapIt($it[].index)
288+
indices = columns.mapIt($it[].index).len
289289
for i in 0..<columns.len:
290290
self.consensusManager.dag.db.putDataColumnSidecar(columns[i][])
291291

@@ -757,7 +757,7 @@ proc storeBlock(
757757
# write data columns now that block has been written
758758
let data_columns = dataColumnsOpt.valueOr: DataColumnSidecars @[]
759759
debug "Inserting columns into database",
760-
indices = data_columns.mapIt($it.index)
760+
indices = data_columns.mapIt($it.index).len
761761
for col in data_columns:
762762
self.consensusManager.dag.db.putDataColumnSidecar(col[])
763763

beacon_chain/networking/eth2_network.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,8 +2511,10 @@ proc lookupCgcFromPeer*(peer: Peer): uint64 =
25112511

25122512
let metadata = peer.metadata
25132513
if metadata.isOk:
2514-
return metadata.get.custody_group_count
2515-
2514+
return (if metadata.get.custody_group_count > NUMBER_OF_COLUMNS:
2515+
0'u64
2516+
else:
2517+
metadata.get.custody_group_count)
25162518
# Try getting the custody count from ENR if metadata fetch fails.
25172519
debug "Could not get cgc from metadata, trying from ENR",
25182520
peer_id = peer.peerId
@@ -2523,6 +2525,8 @@ proc lookupCgcFromPeer*(peer: Peer): uint64 =
25232525
if enrFieldOpt.isOk:
25242526
try:
25252527
let cgc = SSZ.decode(enrFieldOpt.get, uint8)
2528+
if cgc > NUMBER_OF_COLUMNS:
2529+
return 0'u64
25262530
return cgc.uint64
25272531
except SszError, SerializationError:
25282532
discard # Ignore decoding errors and fallback to default

beacon_chain/nimbus_beacon_node.nim

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ proc reconstructDataColumns(node: BeaconNode, slot: Slot) =
17131713
logScope:
17141714
slot = slot
17151715

1716-
let blck = node.dag.getForkedBlock(node.dag.finalizedHead.blck.bid).valueOr:
1716+
let blck = node.dag.getForkedBlock(node.dag.head.bid).valueOr:
17171717
warn "Failed to get the current slot head"
17181718
return
17191719

@@ -1730,7 +1730,7 @@ proc reconstructDataColumns(node: BeaconNode, slot: Slot) =
17301730
if node.dag.db.getDataColumnSidecar(forkyBlck.root, i, colData):
17311731
columns.add(newClone(colData))
17321732
indices.incl(i)
1733-
debug "Stored data columns", indices
1733+
debug "Stored data columns", columns = indices.len
17341734

17351735
# Make sure the node has obtained 50%+ of all the columns
17361736
if columns.lenu64 < (maxColCount div 2):
@@ -1747,6 +1747,7 @@ proc reconstructDataColumns(node: BeaconNode, slot: Slot) =
17471747
error "Error in data column reconstruction"
17481748
return
17491749
let rowCount = recovered.len
1750+
var reconCounter = 0
17501751
for i in 0 ..< maxColCount:
17511752
if i in indices:
17521753
continue
@@ -1758,13 +1759,17 @@ proc reconstructDataColumns(node: BeaconNode, slot: Slot) =
17581759
proofs[j] = recovered[j].proofs[i]
17591760
let dataColumn = fulu.DataColumnSidecar(
17601761
index: ColumnIndex(i),
1761-
column: DataColumn(cells),
1762-
kzg_proofs: deneb.KzgProofs(proofs),
1763-
signed_block_header: forkyBlck.asSigned().toSignedBeaconBlockHeader())
1762+
column: DataColumn.init(cells),
1763+
kzg_commitments: columns[0].kzg_commitments,
1764+
kzg_proofs: deneb.KzgProofs.init(proofs),
1765+
signed_block_header: forkyBlck.asSigned().toSignedBeaconBlockHeader(),
1766+
kzg_commitments_inclusion_proof:
1767+
columns[0].kzg_commitments_inclusion_proof)
17641768
node.dag.db.putDataColumnSidecar(dataColumn)
1769+
inc reconCounter
17651770

1766-
debug "Column reconstructed",
1767-
len = maxColCount - indices.lenu64
1771+
debug "Columns reconstructed",
1772+
columns = reconCounter
17681773

17691774
proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} =
17701775
# Things we do when slot processing has ended and we're about to wait for the

beacon_chain/spec/peerdas_helpers.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ func handle_custody_groups(cfg: RuntimeConfig, node_id: NodeId,
4747
custody_groups: HashSet[CustodyIndex]
4848
current_id = node_id
4949

50-
while custody_groups.lenu64 < custody_group_count:
50+
let safe_count = min(custody_group_count, cfg.NUMBER_OF_CUSTODY_GROUPS)
51+
while custody_groups.lenu64 < safe_count:
5152
var hashed_bytes: array[8, byte]
5253

5354
let

0 commit comments

Comments
 (0)