Skip to content

Commit

Permalink
miner: use empty zero randomness for pending blocks after the merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Jan 21, 2022
1 parent 2221505 commit c9fd441
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
11 changes: 1 addition & 10 deletions miner/worker.go
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"fmt"
"math/big"
"math/rand"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 1 addition & 5 deletions miner/worker_test.go
Expand Up @@ -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")
}
Expand Down

0 comments on commit c9fd441

Please sign in to comment.