Propagate RandomX hashing failures safely

This commit is contained in:
Capri 2026-09-14 21:09:32 +00:00
commit 6e0ae5dd3c
Signed by: VextaProject
SSH key fingerprint: SHA256:739BZv8LvIDY2tR7lXLy/IQ6MaGTQtYcG9GNvCjmpVM
3 changed files with 10 additions and 15 deletions

View file

@ -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(
stream.data(),
stream.size(),
seed.data(),
seed.size(),
result.begin())) {
result.SetNull();
}
return result;
return VextaRandomXHash(
stream.data(),
stream.size(),
seed.data(),
seed.size(),
result.begin());
}
std::string CBlock::ToString(const Consensus::Params& params) const

View file

@ -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
{

View file

@ -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(),