From 9d3cee078cfa18d261a2081474a4b0ce40efce22 Mon Sep 17 00:00:00 2001 From: wizeguyy Date: Tue, 29 Nov 2022 10:45:48 -0600 Subject: [PATCH] bugfix: SealHash should not include nonce --- consensus/blake3pow/consensus.go | 5 ++--- consensus/blake3pow/sealer.go | 2 +- core/knot/ropsten_knot.rlp | Bin 12726 -> 12726 bytes 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/consensus/blake3pow/consensus.go b/consensus/blake3pow/consensus.go index a64f524cf6..1aebb36936 100644 --- a/consensus/blake3pow/consensus.go +++ b/consensus/blake3pow/consensus.go @@ -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 } } @@ -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 @@ -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) diff --git a/consensus/blake3pow/sealer.go b/consensus/blake3pow/sealer.go index 9309f6c305..232977709b 100644 --- a/consensus/blake3pow/sealer.go +++ b/consensus/blake3pow/sealer.go @@ -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 diff --git a/core/knot/ropsten_knot.rlp b/core/knot/ropsten_knot.rlp index 21a79a937f143a6d257586b73a3a562f63d2ad46..6cda305cd26fdc5ce74d1565eff859b57721e2e6 100644 GIT binary patch delta 749 zcmdm%ye)Y{IcsEB*6fB3>xkT!r@pQ@dEmfL*5;qAbw839FfcGT7|y)c>-chIi?`Up zZ$@YItd1pCzJB7lrTMXIP&z>cn=i2Hf{b6<&>@uEG^OqAyA>$LGn7fUu;rhs;EFs` zyT#J!a`iuh1&K8RhZs+J{=XXyG#~~4)n|Axncc2N1lk*f$ZC)mr%mQ@i&V~-RcZwIM z=Wc(DVhW>z#?@^zzshd2KRc<`IA{B_>C03^eqEpWd1?8|q(4B1;#UB6sE#<;io*>Z z_B;o5vzvmAQLS)PsaKy+eI)ecKG|#2o1b3am>hq`A>~NbyW`rP8$edzRRFePlMFa4 z&Ng(2K3F=PRn%i6iWLmP?cv*+){BT&%v7v9tLpEhblEgeD6q@H_2^E4DWI^}oTmtm zu$|J&N9r{2w6x%%j#;`vY57}uw%o)Yz&cn;`D2D}Qu zj@+jX4u^*g9bP7H4E)=jLr|?)y~~^Z=Oz)xl2+wC=Cgg8vcIG)c)u=ls_zH;Z>vF8 e;8g&&!bLZkg}*E7bwh`i^na7OkD?0>8~^|?{%Vi_ delta 749 zcmdm%ye)Y{Icuch!AlJt4%<&K*S#{RK5*bCYx7Umx*y34X7Z%3_P_kh>!P@w#EGS+ zrI*~jwlMg>xAh`3c3vv~V`@%N!R8CBx*+54G<5I?==3Mf6x@zveEg{i+xDk@opoWw z>sM{3^71!*@woVXC8KJHi27BbzsbuM5K=Jt0_&;G3Ovay7KR6(HFTuhoN~kPX~Iz? zE4CLOzWVRCr8%F{+mijqzUlmX96a%OpiJ4}wHLl#Q@rd5G(mB4p5m#^%LJ2IfDZl8 z&=KOi;s0)?xJ)Edm^MUm6wcV9S5j_tYqDhe{32y*wTjG>N%M8&Gq9UAG#?2g|*dE;j_HGi(@2zpV8Yi zWkZBTB`7R5=P80B>=0i=hr#1Cr^5^NijhoMY#J