Skip to content

Commit

Permalink
fixed timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 committed Jun 9, 2022
1 parent 0e142e3 commit 2ad8a77
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
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

0 comments on commit 2ad8a77

Please sign in to comment.