mirror of
https://github.com/wownero/wownero.git
synced 2026-11-19 15:13:56 +01:00
rpc: return error gracefully on cryptonight v1 check
This commit is contained in:
@@ -1622,7 +1622,9 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
else // CryptoNight
|
else // CryptoNight
|
||||||
{
|
{
|
||||||
const int pow_variant = major_version >= 7 ? major_version - 6 : 0;
|
static_assert(HF_VERSION_CRYPTONIGHT_VARIANT_1 >= 1);
|
||||||
|
const int pow_variant = major_version >= HF_VERSION_CRYPTONIGHT_VARIANT_1
|
||||||
|
? major_version - (HF_VERSION_CRYPTONIGHT_VARIANT_1 - 1) : 0;
|
||||||
crypto::cn_slow_hash(block_hashing_blob.data(), block_hashing_blob.size(), res, pow_variant, height);
|
crypto::cn_slow_hash(block_hashing_blob.data(), block_hashing_blob.size(), res, pow_variant, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,7 @@
|
|||||||
#define HF_VERSION_DYNAMIC_FEE 4
|
#define HF_VERSION_DYNAMIC_FEE 4
|
||||||
#define HF_VERSION_MIN_MIXIN_4 6
|
#define HF_VERSION_MIN_MIXIN_4 6
|
||||||
#define HF_VERSION_MIN_MIXIN_6 7
|
#define HF_VERSION_MIN_MIXIN_6 7
|
||||||
|
#define HF_VERSION_CRYPTONIGHT_VARIANT_1 7
|
||||||
#define HF_VERSION_MIN_MIXIN_10 8
|
#define HF_VERSION_MIN_MIXIN_10 8
|
||||||
#define HF_VERSION_MIN_MIXIN_15 15
|
#define HF_VERSION_MIN_MIXIN_15 15
|
||||||
#define HF_VERSION_ENFORCE_RCT 6
|
#define HF_VERSION_ENFORCE_RCT 6
|
||||||
|
|||||||
@@ -2081,6 +2081,20 @@ namespace cryptonote
|
|||||||
error_resp.message = "Wrong block blob";
|
error_resp.message = "Wrong block blob";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (req.major_version == HF_VERSION_CRYPTONIGHT_VARIANT_1 && req.major_version < RX_BLOCK_VERSION)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
crypto::cn_variant1_check(blockblob.size(), /*variant=*/1);
|
||||||
|
}
|
||||||
|
catch(const std::exception& e)
|
||||||
|
{
|
||||||
|
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB_SIZE;
|
||||||
|
error_resp.message = "Block blob size is too small for CryptoNight v1, rejecting block";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!m_core.check_incoming_block_size(blockblob))
|
if(!m_core.check_incoming_block_size(blockblob))
|
||||||
{
|
{
|
||||||
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB_SIZE;
|
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB_SIZE;
|
||||||
@@ -2101,8 +2115,18 @@ namespace cryptonote
|
|||||||
buf.copy(reinterpret_cast<char *>(&seed_hash), sizeof(crypto::hash));
|
buf.copy(reinterpret_cast<char *>(&seed_hash), sizeof(crypto::hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
cryptonote::get_block_longhash(&(m_core.get_blockchain_storage()), blockblob, pow_hash, req.height,
|
try
|
||||||
req.major_version, req.seed_hash.size() ? &seed_hash : NULL, 0);
|
{
|
||||||
|
cryptonote::get_block_longhash(&(m_core.get_blockchain_storage()), blockblob, pow_hash, req.height,
|
||||||
|
req.major_version, req.seed_hash.size() ? &seed_hash : NULL, 0);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
MERROR("Caught unexpected error while hashing in " << __PRETTY_FUNCTION__ << ": " << e.what());
|
||||||
|
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||||
|
error_resp.message = e.what();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
res = string_tools::pod_to_hex(pow_hash);
|
res = string_tools::pod_to_hex(pow_hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user