added sleep (#3561)

This commit is contained in:
Giulio rebuffo 2022-02-21 14:45:10 +01:00 committed by GitHub
parent 78974d7844
commit 7f596e16b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ import (
"sort"
"sync"
"sync/atomic"
"time"
"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
@ -35,6 +36,7 @@ type assemblePayloadPOSFunc func(random common.Hash, suggestedFeeRecipient commo
var EthBackendAPIVersion = &types2.VersionReply{Major: 3, Minor: 0, Patch: 0}
const MaxPendingPayloads = 128
const payloadWaitTime = time.Millisecond
type EthBackendServer struct {
remote.UnimplementedETHBACKENDServer // must be embedded to have forward compatible implementations.
@ -269,7 +271,7 @@ func (s *EthBackendServer) EngineNewPayloadV1(ctx context.Context, req *types2.E
if header.Hash() != blockHash {
return &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID_BLOCK_HASH}, nil
}
time.Sleep(payloadWaitTime)
// If another payload is already commissioned then we just reply with syncing
if atomic.LoadUint32(s.waitingForBeaconChain) == 0 {
// We are still syncing a commissioned payload
@ -340,7 +342,7 @@ func (s *EthBackendServer) EngineForkChoiceUpdatedV1(ctx context.Context, req *r
// 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
time.Sleep(payloadWaitTime)
if atomic.LoadUint32(s.waitingForBeaconChain) == 0 {
return &remote.EngineForkChoiceUpdatedReply{
PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_SYNCING},