enable data column verification in block processor, other general fixes

This commit is contained in:
Agnish Ghosh 2024-08-20 12:19:54 +05:30
parent 70029545ea
commit fcdd7ee492
3 changed files with 34 additions and 34 deletions

View File

@ -635,39 +635,39 @@ proc storeBlock(
# TODO with v1.4.0, not sure this is still relevant
# Establish blob viability before calling addHeadBlock to avoid
# writing the block in case of blob error.
# when typeof(signedBlock).kind >= ConsensusFork.Deneb:
# if blobsOpt.isSome:
# let blobs = blobsOpt.get()
# let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
# if blobs.len > 0 or kzgCommits.len > 0:
# let r = validate_blobs(kzgCommits, blobs.mapIt(KzgBlob(bytes: it.blob)),
# blobs.mapIt(it.kzg_proof))
# if r.isErr():
# debug "blob validation failed",
# blockRoot = shortLog(signedBlock.root),
# blobs = shortLog(blobs),
# blck = shortLog(signedBlock.message),
# kzgCommits = mapIt(kzgCommits, shortLog(it)),
# signature = shortLog(signedBlock.signature),
# msg = r.error()
# return err((VerifierError.Invalid, ProcessingStatus.completed))
when typeof(signedBlock).kind >= ConsensusFork.Deneb:
# if blobsOpt.isSome:
# let blobs = blobsOpt.get()
# let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
# if blobs.len > 0 or kzgCommits.len > 0:
# let r = validate_blobs(kzgCommits, blobs.mapIt(KzgBlob(bytes: it.blob)),
# blobs.mapIt(it.kzg_proof))
# if r.isErr():
# debug "blob validation failed",
# blockRoot = shortLog(signedBlock.root),
# blobs = shortLog(blobs),
# blck = shortLog(signedBlock.message),
# kzgCommits = mapIt(kzgCommits, shortLog(it)),
# signature = shortLog(signedBlock.signature),
# msg = r.error()
# return err((VerifierError.Invalid, ProcessingStatus.completed))
# if dataColumnsOpt.isSome:
# let data_column_sidecars = dataColumnsOpt.get
# if data_column_sidecars.len > 0:
# for i in 0..<data_column_sidecars.len:
# let r = verify_data_column_sidecar_kzg_proofs(data_column_sidecars[i][])
if dataColumnsOpt.isSome:
let data_column_sidecars = dataColumnsOpt.get
if data_column_sidecars.len > 0:
for i in 0..<data_column_sidecars.len:
let r = verify_data_column_sidecar_kzg_proofs(data_column_sidecars[i][])
# if r.isErr():
# debug "data column sidecar verification failed",
# blockroot = shortLog(signedBlock.root),
# blck = shortLog(signedBlock.message),
# kzgCommits =
# mapIt(data_column_sidecars[i][].kzg_commitments,
# shortLog(it)),
# signature = shortLog(signedBlock.signature),
# msg = r.error
# return err((VerifierError.Invalid, ProcessingStatus.completed))
if r.isErr():
debug "data column sidecar verification failed",
blockroot = shortLog(signedBlock.root),
blck = shortLog(signedBlock.message),
kzgCommits =
mapIt(data_column_sidecars[i][].kzg_commitments,
shortLog(it)),
signature = shortLog(signedBlock.signature),
msg = r.error
return err((VerifierError.Invalid, ProcessingStatus.completed))
type Trusted = typeof signedBlock.asTrusted()

View File

@ -1520,7 +1520,7 @@ proc tryReconstructingDataColumns* (self: BeaconNode,
# storedColumn number is less than the NUMBER_OF_COLUMNS
# then reconstruction is not possible, and if all the data columns
# are already stored then we do not need to reconstruct at all
if not storedColumns.len < NUMBER_OF_COLUMNS div 2 or storedColumns.len != NUMBER_OF_COLUMNS:
if not storedColumns.len < NUMBER_OF_COLUMNS div 2 and storedColumns.len != NUMBER_OF_COLUMNS:
# Recover blobs from saved data column sidecars
let recovered_cps = recover_cells_and_proofs(data_column_sidecars, storedColumns.len, signed_block)

View File

@ -263,9 +263,9 @@ proc get_data_column_sidecars*(signed_block: deneb.TrustedSignedBeaconBlock |
column_proofs: KzgProofs
for i in 0..<cellsAndProofs.len:
let check1 = column_cells.add(cellsAndProofs[i].cells)
doAssert check1 == true, "Issue fetching cell from CellsAndProofs"
if not check1: debug "Issue fetching cell from CellsAndProofs"
let check2 = column_proofs.add(cellsAndProofs[i].proofs)
doAssert check2 == true, "Issue fetching proof from CellsAndProofs"
if not check2: debug "Issue fetching proof from CellsAndProofs"
var sidecar = DataColumnSidecar(
index: ColumnIndex(column_index),