Use Rust Equihash validator unconditionally
It correctly validates all blocks prior to Heartwood activation.
This commit is contained in:
parent
54180fbce5
commit
79846ac1f3
21
src/pow.cpp
21
src/pow.cpp
|
@ -14,7 +14,6 @@
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
|
||||||
#include <librustzcash.h>
|
#include <librustzcash.h>
|
||||||
#include "sodium.h"
|
|
||||||
|
|
||||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
|
@ -98,18 +97,12 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, int nHeight, const Consen
|
||||||
unsigned int n = params.nEquihashN;
|
unsigned int n = params.nEquihashN;
|
||||||
unsigned int k = params.nEquihashK;
|
unsigned int k = params.nEquihashK;
|
||||||
|
|
||||||
// Hash state
|
|
||||||
crypto_generichash_blake2b_state state;
|
|
||||||
EhInitialiseState(n, k, state);
|
|
||||||
|
|
||||||
// I = the block header minus nonce and solution.
|
// I = the block header minus nonce and solution.
|
||||||
CEquihashInput I{*pblock};
|
CEquihashInput I{*pblock};
|
||||||
// I||V
|
// I||V
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
ss << I;
|
ss << I;
|
||||||
|
|
||||||
// From Heartwood activation, check with the Rust validator
|
|
||||||
if (params.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
|
||||||
return librustzcash_eh_isvalid(
|
return librustzcash_eh_isvalid(
|
||||||
n, k,
|
n, k,
|
||||||
(unsigned char*)&ss[0], ss.size(),
|
(unsigned char*)&ss[0], ss.size(),
|
||||||
|
@ -117,20 +110,6 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, int nHeight, const Consen
|
||||||
pblock->nSolution.data(), pblock->nSolution.size());
|
pblock->nSolution.data(), pblock->nSolution.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before Heartwood activation, check with the C++ validator
|
|
||||||
ss << pblock->nNonce;
|
|
||||||
|
|
||||||
// H(I||V||...
|
|
||||||
crypto_generichash_blake2b_update(&state, (unsigned char*)&ss[0], ss.size());
|
|
||||||
|
|
||||||
bool isValid;
|
|
||||||
EhIsValidSolution(n, k, state, pblock->nSolution, isValid);
|
|
||||||
if (!isValid)
|
|
||||||
return error("CheckEquihashSolution(): invalid solution");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
bool fNegative;
|
bool fNegative;
|
||||||
|
|
Loading…
Reference in New Issue