Skip to content

Commit

Permalink
eth/catalyst: stop external miners on TTD reached
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Mar 9, 2022
1 parent fb8ae93 commit f7b069e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions eth/catalyst/api.go
Expand Up @@ -26,6 +26,8 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
beaconEngine "github.com/ethereum/go-ethereum/consensus/beacon"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core/beacon"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -112,6 +114,12 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa
if merger := api.eth.Merger(); !merger.TDDReached() {
merger.ReachTTD()
api.eth.Downloader().Cancel()
// Shutdown gpu miner
if eng, ok := api.eth.Engine().(*beaconEngine.Beacon); ok {
if inner, ok := eng.InnerEngine().(*ethash.Ethash); ok {
inner.Close()
}
}
}
log.Info("Forkchoice requested sync to new head", "number", header.Number, "hash", header.Hash())
if err := api.eth.Downloader().BeaconSync(api.eth.SyncMode(), header); err != nil {
Expand Down Expand Up @@ -315,6 +323,12 @@ func (api *ConsensusAPI) NewPayloadV1(params beacon.ExecutableDataV1) (beacon.Pa
if merger := api.eth.Merger(); !merger.TDDReached() {
merger.ReachTTD()
api.eth.Downloader().Cancel()
// Shutdown gpu miner
if eng, ok := api.eth.Engine().(*beaconEngine.Beacon); ok {
if inner, ok := eng.InnerEngine().(*ethash.Ethash); ok {
inner.Close()
}
}
}
hash := block.Hash()
return beacon.PayloadStatusV1{Status: beacon.VALID, LatestValidHash: &hash}, nil
Expand Down

0 comments on commit f7b069e

Please sign in to comment.