From 6e950e43e16132d72775e0b4b36d44d73ae64873 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Fri, 21 Jan 2022 14:35:52 +0800 Subject: [PATCH] miner: use empty zero randomness for pending blocks after the merge --- miner/worker.go | 11 +---------- miner/worker_test.go | 6 +----- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index c147267f1157d..2b4c574da2420 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -20,7 +20,6 @@ import ( "errors" "fmt" "math/big" - "math/rand" "sync" "sync/atomic" "time" @@ -998,17 +997,9 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { if !genParams.noExtra && len(w.extra) != 0 { header.Extra = w.extra } - // Set the randomness field for post-merge blocks, either fed by beacon chain - // or generated locally. + // Set the randomness field from the beacon chain if it's available. if genParams.random != (common.Hash{}) { header.MixDigest = genParams.random - } else if w.isTTDReached(header) { - random := make([]byte, common.HashLength) - _, err := rand.Read(random) - if err != nil { - return nil, err - } - header.MixDigest = common.BytesToHash(random) } // Set baseFee and GasLimit if we are on an EIP-1559 chain if w.chainConfig.IsLondon(header.Number) { diff --git a/miner/worker_test.go b/miner/worker_test.go index 1afcc0d08786d..dbc8ebad69328 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -580,11 +580,7 @@ func testGetSealingWork(t *testing.T, chainConfig *params.ChainConfig, engine co t.Error("Unexpected coinbase") } } - if postMerge && random == (common.Hash{}) { - if block.MixDigest() == (common.Hash{}) { - t.Error("Unexpected mix digest") - } - } else if !isClique { + if !isClique { if block.MixDigest() != random { t.Error("Unexpected mix digest") }