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

Fix SYNCING Status in Hive tests #4605

Merged
merged 1 commit into from
Jul 2, 2022
Merged
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
14 changes: 13 additions & 1 deletion eth/stagedsync/stage_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func handleNewPayload(
}, nil
}

parent, err := cfg.blockReader.Header(ctx, tx, header.ParentHash, headerNumber-1)
parent, err := cfg.blockReader.HeaderByHash(ctx, tx, header.ParentHash)
if err != nil {
return nil, err
}
Expand All @@ -513,6 +513,14 @@ func handleNewPayload(
return &privateapi.PayloadStatus{Status: remote.EngineStatus_SYNCING}, nil
}

if header.Number.Uint64() != parent.Number.Uint64()+1 {
return &privateapi.PayloadStatus{
Status: remote.EngineStatus_INVALID,
LatestValidHash: header.ParentHash,
ValidationError: errors.New("invalid block number"),
}, nil
}

cfg.hd.BeaconRequestList.Remove(requestId)

for _, tx := range payloadMessage.Body.Transactions {
Expand Down Expand Up @@ -574,6 +582,10 @@ func verifyAndSaveNewPoSHeader(
}, false, nil
}

if err := rawdb.WriteHeaderNumber(tx, headerHash, headerNumber); err != nil {
return nil, false, err
}

err = headerInserter.FeedHeaderPoS(tx, header, headerHash)
if err != nil {
return nil, false, err
Expand Down