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();
|
return GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 CBlockHeader::GetRandomXPoWHash(const uint256& seed) const
|
bool CBlockHeader::GetRandomXPoWHash(const uint256& seed, uint256& result) const
|
||||||
{
|
{
|
||||||
CDataStream stream(SER_GETHASH, PROTOCOL_VERSION);
|
CDataStream stream(SER_GETHASH, PROTOCOL_VERSION);
|
||||||
stream << *this;
|
stream << *this;
|
||||||
|
|
||||||
uint256 result;
|
return VextaRandomXHash(
|
||||||
|
stream.data(),
|
||||||
if (!VextaRandomXHash(
|
stream.size(),
|
||||||
stream.data(),
|
seed.data(),
|
||||||
stream.size(),
|
seed.size(),
|
||||||
seed.data(),
|
result.begin());
|
||||||
seed.size(),
|
|
||||||
result.begin())) {
|
|
||||||
result.SetNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CBlock::ToString(const Consensus::Params& params) const
|
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 input is the canonical serialized 80-byte block header.
|
||||||
* The seed is supplied in raw uint256 serialization byte order.
|
* 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
|
int64_t GetBlockTime() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -589,7 +589,8 @@ BOOST_AUTO_TEST_CASE(RandomX_header_hash_vector_test)
|
||||||
HexStr(seedBytes),
|
HexStr(seedBytes),
|
||||||
"0ffeeddccbbaa9988776655443322110ffeeddccbbaa99887766554433221100");
|
"0ffeeddccbbaa9988776655443322110ffeeddccbbaa99887766554433221100");
|
||||||
|
|
||||||
const uint256 randomXHash = header.GetRandomXPoWHash(seed);
|
uint256 randomXHash;
|
||||||
|
BOOST_REQUIRE(header.GetRandomXPoWHash(seed, randomXHash));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(
|
BOOST_CHECK_EQUAL(
|
||||||
randomXHash.ToString(),
|
randomXHash.ToString(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue