diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index d4b3f499c27d3362f69bc9e10ee79e1853631130..a1d5c1e79615ab52a27154781f41e1040293456e 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -456,12 +456,17 @@ func (s *EthBackendServer) EngineForkChoiceUpdatedV1(ctx context.Context, req *r PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID_TERMINAL_BLOCK}, }, nil } - tx1.Rollback() // TODO(yperbasis): Client software MAY skip an update of the forkchoice state and // MUST NOT begin a payload build process if forkchoiceState.headBlockHash doesn't reference a leaf of the block tree // (i.e. it references an old block). // https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.6/src/engine/specification.md#specification-1 + if rawdb.ReadHeadBlockHash(tx1) == forkChoice.HeadBlockHash { + return &remote.EngineForkChoiceUpdatedReply{ + PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_VALID}, + }, nil + } + tx1.Rollback() if s.stageLoopIsBusy() { log.Trace("[ForkChoiceUpdated] stage loop is busy") @@ -470,20 +475,14 @@ func (s *EthBackendServer) EngineForkChoiceUpdatedV1(ctx context.Context, req *r }, nil } - payloadStatus := PayloadStatus{ - Status: remote.EngineStatus_VALID, - } + log.Trace("[ForkChoiceUpdated] sending forkChoiceMessage", "head", forkChoice.HeadBlockHash) + s.requestList.AddForkChoiceRequest(&forkChoice) - if (forkChoice.HeadBlockHash != common.Hash{} || forkChoice.HeadBlockHash != common.Hash{}) { - log.Trace("[ForkChoiceUpdated] sending forkChoiceMessage", "head", forkChoice.HeadBlockHash) - s.requestList.AddForkChoiceRequest(&forkChoice) - - payloadStatus = <-s.statusCh - log.Trace("[ForkChoiceUpdated] got reply", "payloadStatus", payloadStatus) + payloadStatus := <-s.statusCh + log.Trace("[ForkChoiceUpdated] got reply", "payloadStatus", payloadStatus) - if payloadStatus.CriticalError != nil { - return nil, payloadStatus.CriticalError - } + if payloadStatus.CriticalError != nil { + return nil, payloadStatus.CriticalError } // No need for payload building