Skip to content

Commit

Permalink
Merge pull request #2 from mdehoog/dp/v1.14.7-code-review
Browse files Browse the repository at this point in the history
Geth v1.14.7 update code review
  • Loading branch information
danyalprout authored Aug 8, 2024
2 parents a658353 + 7cee173 commit 6f9fab0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion consensus/beacon/oplegacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (o *OpLegacy) VerifyUncles(chain consensus.ChainReader, block *types.Block)
}

func (o *OpLegacy) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error {
return nil
return fmt.Errorf("cannot prepare for legacy block header: %s (num %d)", header.Hash(), header.Number)
}

func (o *OpLegacy) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) {
Expand Down
14 changes: 11 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ import (
"github.com/holiman/uint256"
)

const (
// minRecommitInterruptInterval is the minimum time interval used to interrupt filling a
// sealing block with pending transactions from the mempool
minRecommitInterruptInterval = 2 * time.Second
)

var (
errBlockInterruptedByNewHead = errors.New("new head arrived while building block")
errBlockInterruptedByRecommit = errors.New("recommit interrupt while building block")
Expand Down Expand Up @@ -128,7 +134,7 @@ func (miner *Miner) generateWork(params *generateParams) *newPayloadResult {
if interrupt == nil {
interrupt = new(atomic.Int32)
}
timer := time.AfterFunc(miner.config.Recommit, func() {
timer := time.AfterFunc(max(minRecommitInterruptInterval, miner.config.Recommit), func() {
interrupt.Store(commitInterruptTimeout)
})

Expand Down Expand Up @@ -260,8 +266,10 @@ func (miner *Miner) makeEnv(parent *types.Header, header *types.Header, coinbase
if historicalBackend, ok := miner.backend.(BackendWithHistoricalState); ok {
var release tracers.StateReleaseFunc
parentBlock := miner.backend.BlockChain().GetBlockByHash(parent.Hash())
state, release, _ = historicalBackend.StateAtBlock(context.Background(), parentBlock, ^uint64(0), nil, false, false)
// TODO: handle error returned by StateAtBlock
state, release, err = historicalBackend.StateAtBlock(context.Background(), parentBlock, ^uint64(0), nil, false, false)
if err != nil {
return nil, err
}
state = state.Copy()
release()
}
Expand Down

0 comments on commit 6f9fab0

Please sign in to comment.