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

Fixed timeout on block proposing #4419

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
}
// proof-of-stake mining
assembleBlockPOS := func(param *core.BlockProposerParametersPOS) (*types.Block, error) {
miningStatePos := stagedsync.NewMiningState(&config.Miner)
miningStatePos := stagedsync.NewProposingState(&config.Miner)
miningStatePos.MiningConfig.Etherbase = param.SuggestedFeeRecipient
proposingSync := stagedsync.New(
stagedsync.MiningStages(backend.sentryCtx,
Expand Down
9 changes: 9 additions & 0 deletions eth/stagedsync/stage_mining_create_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ type MiningState struct {
}

func NewMiningState(cfg *params.MiningConfig) MiningState {
return MiningState{
MiningConfig: cfg,
PendingResultCh: make(chan *types.Block, 1),
MiningResultCh: make(chan *types.Block, 1),
MiningBlock: &MiningBlock{},
}
}

func NewProposingState(cfg *params.MiningConfig) MiningState {
return MiningState{
MiningConfig: cfg,
PendingResultCh: make(chan *types.Block, 1),
Expand Down
9 changes: 1 addition & 8 deletions eth/stagedsync/stage_mining_finish.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/log/v3"
Expand Down Expand Up @@ -55,13 +54,7 @@ func SpawnMiningFinishStage(s *StageState, tx kv.RwTx, cfg MiningFinishCfg, quit
//}
//prev = sealHash

// If we are on POS, we will send the result on the POS channel
isTrans, err := rawdb.Transitioned(tx, block.Header().Number.Uint64(), cfg.chainConfig.TerminalTotalDifficulty)
if err != nil {
return err
}

if isTrans {
if cfg.miningState.MiningResultPOSCh != nil {
cfg.miningState.MiningResultPOSCh <- block
return nil
}
Expand Down
17 changes: 8 additions & 9 deletions ethdb/privateapi/ethbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,6 @@ func (s *EthBackendServer) EngineNewPayloadV1(ctx context.Context, req *types2.E

// EngineGetPayloadV1 retrieves previously assembled payload (Validators only)
func (s *EthBackendServer) EngineGetPayloadV1(ctx context.Context, req *remote.EngineGetPayloadRequest) (*types2.ExecutionPayload, error) {
// TODO(yperbasis): getPayload should stop block assembly if that's currently in fly

log.Trace("[GetPayload] acquiring lock")
s.syncCond.L.Lock()
defer s.syncCond.L.Unlock()
log.Trace("[GetPayload] lock acquired")

if !s.proposing {
return nil, fmt.Errorf("execution layer not running as a proposer. enable proposer by taking out the --proposer.disable flag on startup")
}
Expand All @@ -387,8 +380,15 @@ func (s *EthBackendServer) EngineGetPayloadV1(ctx context.Context, req *remote.E
return nil, fmt.Errorf("not a proof-of-stake chain")
}

// TODO(yperbasis): getPayload should stop block assembly if that's currently in fly
log.Trace("[GetPayload] acquiring lock")
s.syncCond.L.Lock()
defer s.syncCond.L.Unlock()
log.Trace("[GetPayload] lock acquired")

payload, ok := s.pendingPayloads[req.PayloadId]
if !ok {
log.Warn("Payload not stored", "payloadId", req.PayloadId)
return nil, &UnknownPayloadErr
}

Expand All @@ -409,6 +409,7 @@ func (s *EthBackendServer) EngineGetPayloadV1(ctx context.Context, req *remote.E
if err != nil {
return nil, err
}
log.Info("Block request successful", "hash", block.Header().Hash(), "transactions count", len(encodedTransactions), "number", block.NumberU64())

return &types2.ExecutionPayload{
ParentHash: gointerfaces.ConvertHashToH256(block.Header().ParentHash),
Expand Down Expand Up @@ -593,9 +594,7 @@ func (s *EthBackendServer) StartProposer() {
}

log.Trace("[Proposer] starting assembling...")
s.syncCond.L.Unlock()
block, err := s.assemblePayloadPOS(&param)
s.syncCond.L.Lock()
log.Trace("[Proposer] payload assembled")

if err != nil {
Expand Down