From 876ca426218060b200a90b6f93aff46547c65343 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Wed, 9 Mar 2022 14:23:49 +0100 Subject: [PATCH] eth/catalyst: stop external miners on TTD reached --- eth/catalyst/api.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 72fa40f6771b5..6fcefa2075e7b 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -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" @@ -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 { @@ -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