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

added sleep for NewPayloadV1 and Forkchoice #3561

Merged
merged 1 commit into from
Feb 21, 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
6 changes: 4 additions & 2 deletions ethdb/privateapi/ethbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sort"
"sync"
"sync/atomic"
"time"

"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to sleep only if atomic.LoadUint32(s.waitingForBeaconChain) == 0

// 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
Expand Down Expand Up @@ -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},
Expand Down