Skip to content

Commit 10169cf

Browse files
author
Joon-Mo Yang
committed
Fix cuckoo score verification
1 parent d1c0e08 commit 10169cf

File tree

1 file changed

+8
-4
lines changed
  • core/src/consensus/cuckoo

1 file changed

+8
-4
lines changed

core/src/consensus/cuckoo/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod params;
1919
use std::cmp::{max, min};
2020

2121
use byteorder::{ByteOrder, LittleEndian};
22+
use ccrypto::blake256;
2223
use ctypes::U256;
2324
use cuckoo::Cuckoo as CuckooVerifier;
2425
use rlp::UntrustedRlp;
@@ -126,11 +127,14 @@ impl ConsensusEngine<CodeChainMachine> for Cuckoo {
126127
if !self.verifier.verify(&message, &seal.proof) {
127128
return Err(From::from(BlockError::InvalidProofOfWork))
128129
}
129-
if U256::from(header.hash()) > self.score_to_target(header.score()) {
130+
131+
let target = self.score_to_target(header.score());
132+
let hash = blake256(::rlp::encode_list(&seal.proof));
133+
if U256::from(hash) > target {
130134
return Err(From::from(BlockError::InvalidScore(OutOfBounds {
131-
min: Some(*header.score()),
132-
max: Some(*header.score()),
133-
found: U256::from(header.hash()),
135+
min: Some(target),
136+
max: Some(target),
137+
found: U256::from(hash),
134138
})))
135139
}
136140
Ok(())

0 commit comments

Comments
 (0)