Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr committed Oct 29, 2024
1 parent 87c4614 commit a11dbb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 70 deletions.
18 changes: 0 additions & 18 deletions eth/catalyst/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/miner"
)

Expand Down Expand Up @@ -93,23 +92,6 @@ func (q *payloadQueue) get(id engine.PayloadID, full bool) *engine.ExecutionPayl
return nil
}

// getWithoutStatus retrieves a previously stored payload item or nil if it does not exist.
func (q *payloadQueue) getWithoutStatus(id engine.PayloadID) *miner.Payload {
q.lock.RLock()
defer q.lock.RUnlock()

for _, item := range q.payloads {
if item == nil {
log.Info("getting payload not found", "id", id)
return nil // no more items
}
if item.id == id {
return item.payload
}
}
return nil
}

// waitFull waits until the first full payload has been built for the specified payload id
// The method returns immediately if the payload is unknown.
func (q *payloadQueue) waitFull(id engine.PayloadID) error {
Expand Down
68 changes: 16 additions & 52 deletions miner/payload_building.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (w *worker) buildPayload(args *BuildPayloadArgs) (*Payload, error) {
}

//check state of parent block
_, err = w.retrieveParentState(w.chain.CurrentBlock())
_, err = w.retrieveParentState(fullParams)
if err != nil && strings.Contains(err.Error(), "missing trie node") {
log.Error("missing parent state when building block, try to fix...")
// fix state data
Expand Down Expand Up @@ -452,54 +452,6 @@ func (w *worker) buildPayload(args *BuildPayloadArgs) (*Payload, error) {
return payload, nil
}

// retryPayloadUpdate retries the payload update process after a fix operation.
//
// This function reconstructs the block using the provided BuildPayloadArgs and
// attempts to update the payload in the system. It performs validation of the
// block parameters and updates the payload if the block is successfully built.
func (w *worker) retryPayloadUpdate(args *BuildPayloadArgs, payload *Payload) error {
fullParams := &generateParams{
timestamp: args.Timestamp,
forceTime: true,
parentHash: args.Parent,
coinbase: args.FeeRecipient,
random: args.Random,
withdrawals: args.Withdrawals,
beaconRoot: args.BeaconRoot,
noTxs: false,
txs: args.Transactions,
gasLimit: args.GasLimit,
}

// Since we skip building the empty block when using the tx pool, we need to explicitly
// validate the BuildPayloadArgs here.
_, err := w.validateParams(fullParams)
if err != nil {
log.Error("Failed to validate payload parameters", "id", payload.id, "err", err)
return fmt.Errorf("failed to validate payload parameters: %w", err)
}

// set shared interrupt
fullParams.interrupt = payload.interrupt

r := w.getSealingBlock(fullParams)
if r.err != nil {
log.Error("Failed to build full payload after fix", "id", payload.id, "err", r.err)
return fmt.Errorf("failed to build full payload after fix: %w", r.err)
}

payload.update(r, 0, func() {
w.cacheMiningBlock(r.block, r.env)
})

if r.err == nil {
fullParams.isUpdate = true
}

log.Info("Successfully updated payload after fix", "id", payload.id)
return nil
}

func (w *worker) cacheMiningBlock(block *types.Block, env *environment) {
var (
start = time.Now()
Expand Down Expand Up @@ -537,9 +489,21 @@ func (w *worker) cacheMiningBlock(block *types.Block, env *environment) {
"elapsed", common.PrettyDuration(time.Since(start)))
}

func (w *worker) retrieveParentState(parent *types.Header) (state *state.StateDB, err error) {
// Retrieve the parent state to execute on top and start a prefetcher for
// the miner to speed block sealing up a bit.
func (w *worker) retrieveParentState(genParams *generateParams) (state *state.StateDB, err error) {
w.mu.RLock()
defer w.mu.RUnlock()

log.Info("retrieveParentState validate")
// Find the parent block for sealing task
parent := w.chain.CurrentBlock()
if genParams.parentHash != (common.Hash{}) {
block := w.chain.GetBlockByHash(genParams.parentHash)
if block == nil {
return nil, fmt.Errorf("missing parent")
}
parent = block.Header()
}

state, err = w.chain.StateAt(parent.Root)

// If there is an error and Optimism is enabled in the chainConfig, allow reorg
Expand Down

0 comments on commit a11dbb4

Please sign in to comment.