Skip to content

Commit

Permalink
fix hash verificaiton
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed Nov 5, 2024
1 parent c52a55e commit e537241
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions go/enclave/components/rollup_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,20 @@ func (rc *rollupConsumerImpl) extractAndVerifyRollups(br *common.BlockAndReceipt
return rollups, nil
}

// given the blobHashes are extracted from the block and receipts, and the transactions are decoded to get the rollup hashes,
// we should always get an equal number of hashes to compare
func verifyBlobHashes(rollupHashes *ethadapter.L1RollupHashes, blobHashes []gethcommon.Hash) error {
minLength := len(blobHashes)
if len(rollupHashes.BlobHashes) < minLength {
minLength = len(rollupHashes.BlobHashes)
numBlobHashes := len(blobHashes)
numRollupHashes := len(rollupHashes.BlobHashes)
if numRollupHashes != numBlobHashes {
return fmt.Errorf(
"length mismatch: rollupHashes (%d) != blobHashes (%d)",
numRollupHashes,
numBlobHashes,
)
}

for i := 0; i < minLength; i++ {
for i := 0; i < numBlobHashes; i++ {
if rollupHashes.BlobHashes[i] != blobHashes[i] {
return fmt.Errorf(
"hash mismatch at index %d: rollupHash (%s) != blobHash (%s)",
Expand Down

0 comments on commit e537241

Please sign in to comment.