Skip to content

Commit

Permalink
fix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jul 25, 2024
1 parent c41e7ef commit 20220ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ docker run -d --name relayscan-postgres -p 5432:5432 -e POSTGRES_USER=postgres -
# Query only a single relay, and for the shortest time possible
go run . core data-api-backfill --relay fb --min-slot -1

# Now the DB has data, check it (for only a single slot, the latest one, see logs for "latest received payload at slot N" in the backfill command)
# Now the DB has data, check it (and update in DB)
go run . core check-payload-value

# Can also check a single slot only:
go run . core check-payload-value --slot _N_

# Reset DB? Remove and restart the Docker container
Expand Down
27 changes: 17 additions & 10 deletions cmd/core/check-payload-value.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package core

import (
"context"
"database/sql"
"fmt"
"math/big"
"strings"
Expand Down Expand Up @@ -200,7 +199,8 @@ func startUpdateWorker(wg *sync.WaitGroup, db *database.DatabaseService, client,
coinbase_diff_wei=:coinbase_diff_wei,
coinbase_diff_eth=:coinbase_diff_eth,
found_onchain=:found_onchain, -- should rename field, because getBlockByHash might succeed even though this slot was missed
num_blob_txs=:num_blob_txs
num_blob_txs=:num_blob_txs,
num_blobs=:num_blobs
WHERE slot=:slot`
_, err := db.DB.NamedExec(query, entry)
if err != nil {
Expand All @@ -217,7 +217,7 @@ func startUpdateWorker(wg *sync.WaitGroup, db *database.DatabaseService, client,
"blockHash": entry.BlockHash,
"relay": entry.Relay,
})
_log.Infof("checking slot...")
_log.Infof("checking slot %d ...", entry.Slot)
claimedProposerValue, ok := new(big.Int).SetString(entry.ValueClaimedWei, 10)
if !ok {
_log.Fatalf("couldn't convert claimed value to big.Int: %s", entry.ValueClaimedWei)
Expand All @@ -241,15 +241,20 @@ func startUpdateWorker(wg *sync.WaitGroup, db *database.DatabaseService, client,
// query block by hash
block, err = getBlockByHash(entry.BlockHash)
if err != nil {
_log.WithError(err).Fatalf("couldn't get block %s", entry.BlockHash)
} else if block == nil {
_log.WithError(err).Warnf("block not found: %s", entry.BlockHash)
entry.FoundOnChain = database.NewNullBool(false)
saveEntry(_log, entry)
continue
if err.Error() == "not found" {
_log.WithError(err).Warnf("block by hash not found: %s", entry.BlockHash)
_log.WithError(err).Warnf("block not found: %s", entry.BlockHash)
entry.FoundOnChain = database.NewNullBool(false)
saveEntry(_log, entry)
continue
} else {
_log.WithError(err).Fatalf("error querying block by hash: %s", entry.BlockHash)
}
}

entry.FoundOnChain = sql.NullBool{} //nolint:exhaustruct
// We found this block by hash, it's on chain
entry.FoundOnChain = database.NewNullBool(true)

if !entry.BlockNumber.Valid {
entry.BlockNumber = database.NewNullInt64(block.Number().Int64())
}
Expand Down Expand Up @@ -332,6 +337,8 @@ func startUpdateWorker(wg *sync.WaitGroup, db *database.DatabaseService, client,
}
}
entry.NumBlobTxs = database.NewNullInt64(int64(numBlobTxs))
entry.NumBlobs = database.NewNullInt64(int64(numBlobs))

entry.ExtraData = database.ExtraDataToUtf8Str(block.Extra())
entry.ValueCheckOk = database.NewNullBool(proposerValueDiffFromClaim.String() == "0")
entry.ValueCheckMethod = database.NewNullString(checkMethod)
Expand Down

0 comments on commit 20220ff

Please sign in to comment.