Propagate RandomX hashing failures safely
This commit is contained in:
parent
2431ea4588
commit
6e0ae5dd3c
3 changed files with 10 additions and 15 deletions
|
|
@ -39,23 +39,17 @@ uint256 CBlockHeader::GetPoWAlgoHash(const Consensus::Params& params) const
|
|||
return GetHash();
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetRandomXPoWHash(const uint256& seed) const
|
||||
bool CBlockHeader::GetRandomXPoWHash(const uint256& seed, uint256& result) const
|
||||
{
|
||||
CDataStream stream(SER_GETHASH, PROTOCOL_VERSION);
|
||||
stream << *this;
|
||||
|
||||
uint256 result;
|
||||
|
||||
if (!VextaRandomXHash(
|
||||
return VextaRandomXHash(
|
||||
stream.data(),
|
||||
stream.size(),
|
||||
seed.data(),
|
||||
seed.size(),
|
||||
result.begin())) {
|
||||
result.SetNull();
|
||||
}
|
||||
|
||||
return result;
|
||||
result.begin());
|
||||
}
|
||||
|
||||
std::string CBlock::ToString(const Consensus::Params& params) const
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public:
|
|||
* The input is the canonical serialized 80-byte block header.
|
||||
* The seed is supplied in raw uint256 serialization byte order.
|
||||
*/
|
||||
uint256 GetRandomXPoWHash(const uint256& seed) const;
|
||||
bool GetRandomXPoWHash(const uint256& seed, uint256& result) const;
|
||||
|
||||
int64_t GetBlockTime() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -589,7 +589,8 @@ BOOST_AUTO_TEST_CASE(RandomX_header_hash_vector_test)
|
|||
HexStr(seedBytes),
|
||||
"0ffeeddccbbaa9988776655443322110ffeeddccbbaa99887766554433221100");
|
||||
|
||||
const uint256 randomXHash = header.GetRandomXPoWHash(seed);
|
||||
uint256 randomXHash;
|
||||
BOOST_REQUIRE(header.GetRandomXPoWHash(seed, randomXHash));
|
||||
|
||||
BOOST_CHECK_EQUAL(
|
||||
randomXHash.ToString(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue