From de6a113f843822165b7fb26eb4147e493ce5d8b2 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 29 Mar 2022 18:26:18 +0200 Subject: [PATCH] eth/catalyst: only apply block if we actually have the state (#24598) * eth/catalyst: only apply block if we actually have the state * add header to payload queue * Update cmd/geth/dbcmd.go Co-authored-by: Martin Holst Swende Co-authored-by: Martin Holst Swende --- cmd/geth/dbcmd.go | 3 +++ eth/catalyst/api.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/cmd/geth/dbcmd.go b/cmd/geth/dbcmd.go index f7bebf56f..33a7becfc 100644 --- a/cmd/geth/dbcmd.go +++ b/cmd/geth/dbcmd.go @@ -747,6 +747,9 @@ func showMetaData(ctx *cli.Context) error { data = append(data, []string{"headBlock.Root", fmt.Sprintf("%v", b.Root())}) data = append(data, []string{"headBlock.Number", fmt.Sprintf("%d (0x%x)", b.Number(), b.Number())}) } + if b := rawdb.ReadSkeletonSyncStatus(db); b != nil { + data = append(data, []string{"SkeletonSyncStatus", string(b)}) + } if h := rawdb.ReadHeadHeader(db); h != nil { data = append(data, []string{"headHeader.Hash", fmt.Sprintf("%v", h.Hash())}) data = append(data, []string{"headHeader.Root", fmt.Sprintf("%v", h.Root)}) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 9b60b4583..45f233df6 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -298,6 +298,11 @@ func (api *ConsensusAPI) NewPayloadV1(params beacon.ExecutableDataV1) (beacon.Pa log.Warn("Invalid timestamp", "parent", block.Time(), "block", block.Time()) return api.invalid(errors.New("invalid timestamp")), nil } + if !api.eth.BlockChain().HasBlockAndState(block.ParentHash(), block.NumberU64()-1) { + api.remoteBlocks.put(block.Hash(), block.Header()) + log.Warn("State not available, ignoring new payload") + return beacon.PayloadStatusV1{Status: beacon.ACCEPTED}, nil + } log.Trace("Inserting block without sethead", "hash", block.Hash(), "number", block.Number) if err := api.eth.BlockChain().InsertBlockWithoutSetHead(block); err != nil { log.Warn("NewPayloadV1: inserting block failed", "error", err)