Skip to content

Commit

Permalink
bugfix: SealHash should not include nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeguyy committed Jan 25, 2023
1 parent 940abaf commit 9d3cee0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions consensus/blake3pow/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (blake3pow *Blake3pow) HasCoincidentDifficulty(header *types.Header) bool {
if nodeCtx > common.PRIME_CTX {
domCtx := nodeCtx - 1
domTarget := new(big.Int).Div(big2e256, header.Difficulty(domCtx))
if new(big.Int).SetBytes(blake3pow.SealHash(header).Bytes()).Cmp(domTarget) <= 0 {
if new(big.Int).SetBytes(header.Hash().Bytes()).Cmp(domTarget) <= 0 {
return true
}
}
Expand Down Expand Up @@ -379,7 +379,7 @@ func (blake3pow *Blake3pow) verifySeal(chain consensus.ChainHeaderReader, header
}
// Check that SealHash meets the difficulty target
target := new(big.Int).Div(big2e256, header.Difficulty())
if new(big.Int).SetBytes(blake3pow.SealHash(header).Bytes()).Cmp(target) > 0 {
if new(big.Int).SetBytes(header.Hash().Bytes()).Cmp(target) > 0 {
return errInvalidPoW
}
return nil
Expand Down Expand Up @@ -451,7 +451,6 @@ func (blake3pow *Blake3pow) SealHash(header *types.Header) (hash common.Hash) {
Location: header.Location(),
Time: header.Time(),
Extra: header.Extra(),
Nonce: header.Nonce(),
}
for i := 0; i < common.HierarchyDepth; i++ {
hdata.ParentHash[i] = header.ParentHash(i)
Expand Down
2 changes: 1 addition & 1 deletion consensus/blake3pow/sealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ search:
// Compute the PoW value of this nonce
header = types.CopyHeader(header)
header.SetNonce(types.EncodeNonce(nonce))
hash := blake3pow.SealHash(header).Bytes()
hash := header.Hash().Bytes()
if powBuffer.SetBytes(hash).Cmp(target) <= 0 {
// Correct nonce found, create a new header with it

Expand Down
Binary file modified core/knot/ropsten_knot.rlp
Binary file not shown.

0 comments on commit 9d3cee0

Please sign in to comment.