consensus: From Heartwood activation, use Rust Equihash validator
The C++ and Rust Equihash validators are intended to have an identical set of valid Equihash solutions, so this should merely be an implementation detail. However, deploying the Rust validator at the same time as a network upgrade reduces the risk of an unintentional consensus divergence due to undocumented behaviour in either implementation. Once Heartwood has activated on mainnet, we can verify that all pre-Heartwood blocks satisfy the Rust validator, and then remove the C++ validator and make Equihash-checking non-contextual again.
This commit is contained in:
parent
49f9584613
commit
655f0c9802
12
src/pow.cpp
12
src/pow.cpp
|
@ -13,6 +13,7 @@
|
|||
#include "streams.h"
|
||||
#include "uint256.h"
|
||||
|
||||
#include <librustzcash.h>
|
||||
#include "sodium.h"
|
||||
|
||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||
|
@ -106,6 +107,17 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, int nHeight, const Consen
|
|||
// I||V
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << I;
|
||||
|
||||
// From Heartwood activation, check with the Rust validator
|
||||
if (params.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
||||
return librustzcash_eh_isvalid(
|
||||
n, k,
|
||||
(unsigned char*)&ss[0], ss.size(),
|
||||
pblock->nNonce.begin(), pblock->nNonce.size(),
|
||||
pblock->nSolution.data(), pblock->nSolution.size());
|
||||
}
|
||||
|
||||
// Before Heartwood activation, check with the C++ validator
|
||||
ss << pblock->nNonce;
|
||||
|
||||
// H(I||V||...
|
||||
|
|
Loading…
Reference in New Issue