Skip to content

Commit

Permalink
ethash/sealer: use epoch boundary + 1 (not block number) for seedHash…
Browse files Browse the repository at this point in the history
… in makeWork - fixes ethereum#234
  • Loading branch information
iquidus committed Nov 13, 2020
1 parent 3f91733 commit 5b14a73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion consensus/ethash/algorithm.go
Expand Up @@ -133,7 +133,8 @@ func makeHasher(h hash.Hash) hasher {
}

// seedHash is the seed to use for generating a verification cache and the mining
// dataset.
// dataset. The block number passed should be pre-rounded to an epoch boundary + 1
// e.g: epoch * epochLength + 1
func seedHash(block uint64) []byte {
seed := make([]byte, 32)
if block < epochLengthDefault {
Expand Down
4 changes: 3 additions & 1 deletion consensus/ethash/sealer.go
Expand Up @@ -344,8 +344,10 @@ func (s *remoteSealer) loop() {
// result[3], hex encoded block number
func (s *remoteSealer) makeWork(block *types.Block) {
hash := s.ethash.SealHash(block.Header())
epochLength := calcEpochLength(block.NumberU64(), s.ethash.config.ECIP1099Block)
epoch := calcEpoch(block.NumberU64(), epochLength)
s.currentWork[0] = hash.Hex()
s.currentWork[1] = common.BytesToHash(SeedHash(block.NumberU64())).Hex()
s.currentWork[1] = common.BytesToHash(SeedHash(epoch*epochLength + 1)).Hex()
s.currentWork[2] = common.BytesToHash(new(big.Int).Div(two256, block.Difficulty()).Bytes()).Hex()
s.currentWork[3] = hexutil.EncodeBig(block.Number())

Expand Down

0 comments on commit 5b14a73

Please sign in to comment.