Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better logging for invalid PoS headers #4703

Merged
merged 1 commit into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions eth/stagedsync/stage_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,15 @@ func handleNewPayload(
}

bad, lastValidHash := cfg.hd.IsBadHeaderPoS(headerHash)
if !bad {
if bad {
log.Warn(fmt.Sprintf("[%s] Previously known bad block", s.LogPrefix()), "height", headerNumber, "hash", headerHash)
} else {
bad, lastValidHash = cfg.hd.IsBadHeaderPoS(header.ParentHash)
if bad {
log.Warn(fmt.Sprintf("[%s] Previously known bad parent", s.LogPrefix()), "height", headerNumber, "hash", headerHash, "parentHash", header.ParentHash)
}
}
if bad {
log.Info(fmt.Sprintf("[%s] Previously known bad block", s.LogPrefix()), "height", headerNumber, "hash", headerHash)
cfg.hd.BeaconRequestList.Remove(requestId)
cfg.hd.ReportBadHeaderPoS(headerHash, lastValidHash)
return &privateapi.PayloadStatus{
Expand All @@ -508,7 +512,8 @@ func handleNewPayload(
return &privateapi.PayloadStatus{Status: remote.EngineStatus_SYNCING}, nil
}

if header.Number.Uint64() != parent.Number.Uint64()+1 {
if headerNumber != parent.Number.Uint64()+1 {
log.Warn(fmt.Sprintf("[%s] Invalid block number", s.LogPrefix()), "headerNumber", headerNumber, "parentNumber", parent.Number.Uint64())
cfg.hd.BeaconRequestList.Remove(requestId)
cfg.hd.ReportBadHeaderPoS(headerHash, header.ParentHash)
return &privateapi.PayloadStatus{
Expand All @@ -522,6 +527,7 @@ func handleNewPayload(

for _, tx := range payloadMessage.Body.Transactions {
if types.TypedTransactionMarshalledAsRlpString(tx) {
log.Warn(fmt.Sprintf("[%s] typed txn marshalled as RLP string", s.LogPrefix()), "tx", common.Bytes2Hex(tx))
cfg.hd.ReportBadHeaderPoS(headerHash, header.ParentHash)
return &privateapi.PayloadStatus{
Status: remote.EngineStatus_INVALID,
Expand All @@ -533,7 +539,7 @@ func handleNewPayload(

transactions, err := types.DecodeTransactions(payloadMessage.Body.Transactions)
if err != nil {
log.Warn("Error during Beacon transaction decoding", "err", err.Error())
log.Warn(fmt.Sprintf("[%s] Error during Beacon transaction decoding", s.LogPrefix()), "err", err.Error())
cfg.hd.ReportBadHeaderPoS(headerHash, header.ParentHash)
return &privateapi.PayloadStatus{
Status: remote.EngineStatus_INVALID,
Expand Down Expand Up @@ -590,6 +596,7 @@ func verifyAndSaveNewPoSHeader(
}
success = validationError == nil
if !success {
log.Warn("Verification failed for header", "hash", headerHash, "height", headerNumber, "err", validationError)
cfg.hd.ReportBadHeaderPoS(headerHash, latestValidHash)
} else if err := headerInserter.FeedHeaderPoS(tx, header, headerHash); err != nil {
return nil, false, err
Expand Down
1 change: 1 addition & 0 deletions turbo/stages/stageloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func SendPayloadStatus(hd *headerdownload.HeaderDownload, headBlockHash common.H
if headBlockHash == pendingPayloadHash {
status = remote.EngineStatus_VALID
} else {
log.Warn("Failed to execute pending payload", "pendingPayload", pendingPayloadHash, "headBlock", headBlockHash)
status = remote.EngineStatus_INVALID
}
hd.PayloadStatusCh <- privateapi.PayloadStatus{
Expand Down