Skip to content

Commit

Permalink
add(exporter): sanity check for el payload exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
invis-bitfly committed Jan 13, 2025
1 parent 3b966bd commit 46122b5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion backend/pkg/exporter/modules/execution_payloads_exporter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package modules

import (
"bytes"
"context"
"database/sql"
"fmt"
Expand Down Expand Up @@ -154,9 +155,26 @@ func (d *executionPayloadsExporter) maintainTable() (err error) {
if err != nil {
return fmt.Errorf("error processing blocks: %w", err)
}
// sanity checks: check if any block hashes are 0x0000000000000000000000000000000000000000000000000000000000000000 or duplicate, check if count matches expected
if uint64(len(resData)) != maxBlock-minBlock+1 {
return fmt.Errorf("error processing blocks: expected %v blocks, got %v", maxBlock-minBlock+1, len(resData))
}
seen := make(map[string]bool)
emptyBlockHash := bytes.Repeat([]byte{0}, 32)
for _, r := range resData {
if len(r.BlockHash) == 0 {
return fmt.Errorf("error processing blocks: block hash is empty")
}
if bytes.Equal(r.BlockHash, emptyBlockHash) {
return fmt.Errorf("error processing blocks: block hash is all zeros")
}
if _, ok := seen[string(r.BlockHash)]; ok {
return fmt.Errorf("error processing blocks: duplicate block hash")
}
seen[string(r.BlockHash)] = true
}

// update the execution_payloads table

log.Infof("preparing copy update to temp table")

// load data into temp table
Expand Down

0 comments on commit 46122b5

Please sign in to comment.