diff --git a/README.md b/README.md index a416ac8..4a94cfc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmd/core/check-payload-value.go b/cmd/core/check-payload-value.go index 0aef80c..c521dfb 100644 --- a/cmd/core/check-payload-value.go +++ b/cmd/core/check-payload-value.go @@ -2,7 +2,6 @@ package core import ( "context" - "database/sql" "fmt" "math/big" "strings" @@ -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 { @@ -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) @@ -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()) } @@ -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)