add: verify data column kzg proof during storeBlock, added serializeDataColumn for better logs

This commit is contained in:
Agnish Ghosh 2024-07-26 14:19:44 +05:30
parent 2e9750ba76
commit e80bd36f76
2 changed files with 34 additions and 3 deletions

View File

@ -644,6 +644,24 @@ proc storeBlock(
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 r.isErr():
debug "data column sidecar verification failed",
blockroot = shortLog(signedBlock.root),
column = shortLog(data_column_sidecars[i][].column),
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()
let

View File

@ -7,9 +7,11 @@
{.push raises: [].}
import
import
std/[sequtils],
"."/[base, deneb],
kzg4844
kzg4844,
stew/[byteutils]
from std/sequtils import mapIt
from std/strutils import join
@ -64,7 +66,7 @@ type
DataColumnSidecars* = seq[ref DataColumnSidecar]
DataColumnIdentifier* = object
DataColumnIdentifier* = object
block_root*: Eth2Digest
index*: ColumnIndex
@ -76,6 +78,17 @@ type
CscBits* = BitArray[DATA_COLUMN_SIDECAR_SUBNET_COUNT]
func serializeDataColumn(data_column: DataColumn): auto =
var counter = 0
var serd : array[MAX_BLOB_COMMITMENTS_PER_BLOCK * KzgCellSize, byte]
for i in 0..<MAX_BLOB_COMMITMENTS_PER_BLOCK:
for j in 0..<KzgCellSize:
serd[counter] = data_column[i][j]
inc(counter)
serd
func shortLog*(v: DataColumn): auto =
to0xHex(v.serializeDataColumn())
func shortLog*(v: DataColumnSidecar): auto =
(