diff --git a/eth/stagedsync/stage_headers.go b/eth/stagedsync/stage_headers.go index 3edc3ac2f3c..1153f2208b2 100644 --- a/eth/stagedsync/stage_headers.go +++ b/eth/stagedsync/stage_headers.go @@ -315,8 +315,9 @@ func startHandlingForkChoice( if header == nil { log.Info(fmt.Sprintf("[%s] Fork choice: need to download header with hash %x", s.LogPrefix(), headerHash)) - cfg.hd.BeaconRequestList.Remove(requestId) - if !test { + if test { + cfg.hd.BeaconRequestList.Remove(requestId) + } else { schedulePoSDownload(requestId, headerHash, 0 /* header height is unknown, setting to 0 */, headerHash, s, cfg) } return &engineapi.PayloadStatus{Status: remote.EngineStatus_SYNCING}, nil @@ -444,8 +445,8 @@ func handleNewPayload( } if parent == nil { log.Info(fmt.Sprintf("[%s] New payload: need to download parent", s.LogPrefix()), "height", headerNumber, "hash", headerHash, "parentHash", header.ParentHash) - cfg.hd.BeaconRequestList.Remove(requestId) if test { + cfg.hd.BeaconRequestList.Remove(requestId) return &engineapi.PayloadStatus{Status: remote.EngineStatus_SYNCING}, nil } if !schedulePoSDownload(requestId, header.ParentHash, headerNumber-1, headerHash /* downloaderTip */, s, cfg) { diff --git a/turbo/stages/sentry_mock_test.go b/turbo/stages/sentry_mock_test.go index 2ac5763525c..9f01dd904e5 100644 --- a/turbo/stages/sentry_mock_test.go +++ b/turbo/stages/sentry_mock_test.go @@ -601,17 +601,11 @@ func TestPoSDownloader(t *testing.T) { require.NoError(t, err) stages.SendPayloadStatus(m.HeaderDownload(), headBlockHash, err) - // Since we are removing the current request to avoid the deadlock, we need to send the new payload (or fcu) request again. - m.SendPayloadRequest(chain.TopBlock) // Second cycle: process the previous beacon request headBlockHash, err = stages.StageLoopStep(m.Ctx, m.DB, m.Sync, 0, m.Notifications, initialCycle, m.UpdateHead, nil) require.NoError(t, err) stages.SendPayloadStatus(m.HeaderDownload(), headBlockHash, err) assert.Equal(t, chain.TopBlock.Hash(), headBlockHash) - // Second cycle: checking the response - payloadStatus = m.ReceivePayloadStatus() - assert.Equal(t, remote.EngineStatus_VALID, payloadStatus.Status) - assert.Equal(t, chain.TopBlock.Hash(), headBlockHash) // Point forkChoice to the head forkChoiceMessage := engineapi.ForkChoiceMessage{