Rust Cuckatoo for verifier and test-miner (#1558)

* cuck placeholder

* rustfmt

* cuckatoo, early days

* rustfmt

* data structures are in place, siphash key creation is consistent with @tromp

* solver in place, (not yet working)

* cuckatoo test solver working with test nonce

* rustfmt

* update solver to remove adjacency list removals

* verifier functioning

* rustfmt

* Proper error handing in Cuckatoo module, couple of tests

* modify cuckoo/cuckatoo solvers and verifiers to function identically, in advance of trait refactoring

* rustfmt

* refactor PoW context into trait, default to using cuckoo context

* rustfmt

* create macros for integer casting/unwraps

* don't instantiate structs when just verifying, add test validation vector for cuckatoo 29

* rustfmt

* don't init cuckoo structs if just validating

* test fix

* ensure BH hashing for POW is only done within miner/validators
This commit is contained in:
Yeastplume
2018-09-28 11:53:14 +01:00
committed by GitHub
parent a13c20ceb2
commit e64f4fbcd1
16 changed files with 1171 additions and 329 deletions
+1 -1
View File
@@ -529,7 +529,7 @@ impl StratumServer {
);
} else {
// Do some validation but dont submit
if !pow::verify_size(&b.header, global::min_sizeshift()) {
if !pow::verify_size(&b.header, global::min_sizeshift()).is_ok() {
// Return error status
error!(
LOGGER,
+10 -8
View File
@@ -26,7 +26,7 @@ use common::types::StratumServerConfig;
use core::core::hash::{Hash, Hashed};
use core::core::verifier_cache::VerifierCache;
use core::core::{Block, BlockHeader};
use core::pow::cuckoo;
use core::pow::PoWContext;
use core::{consensus, global};
use mining::mine_block;
use pool;
@@ -96,14 +96,16 @@ impl Miner {
let mut iter_count = 0;
while head.hash() == *latest_hash && Utc::now().timestamp() < deadline {
if let Ok(proof) = cuckoo::Miner::new(
&b.header,
consensus::EASINESS,
global::proofsize(),
let mut ctx = global::create_pow_context::<u32>(
global::min_sizeshift(),
).mine()
{
b.header.pow.proof = proof;
global::proofsize(),
consensus::EASINESS,
10,
).unwrap();
ctx.set_header_nonce(b.header.pre_pow(), None, true)
.unwrap();
if let Ok(proofs) = ctx.find_cycles() {
b.header.pow.proof = proofs[0].clone();
let proof_diff = b.header.pow.to_difficulty();
if proof_diff >= (b.header.total_difficulty() - head.total_difficulty()) {
return true;