rpc: reject deep block submissions on restricted RPC

(cherry picked from commit 837c59bed10d06956ca7375a0e91619c0b77142e)
This commit is contained in:
selsta
2026-10-04 18:50:23 -04:00
committed by such-gitea
parent 01a7c14a82
commit f14082fdbd
+19
View File
@@ -2234,6 +2234,25 @@ namespace cryptonote
return false;
}
if (m_restricted && ctx)
{
block parent;
if (!m_core.get_block_by_hash(b.prev_id, parent))
{
error_resp.code = CORE_RPC_ERROR_CODE_BLOCK_NOT_ACCEPTED;
error_resp.message = "Unknown parent block";
return false;
}
const uint64_t block_height = get_block_height(parent) + 1;
const uint64_t chain_height = m_core.get_current_blockchain_height();
if (crypto::rx_seedheight(block_height) != crypto::rx_seedheight(chain_height))
{
error_resp.code = CORE_RPC_ERROR_CODE_BLOCK_NOT_ACCEPTED;
error_resp.message = "Block is too old for restricted RPC";
return false;
}
}
block_verification_context bvc;
if(!m_core.handle_block_found(b, bvc))
{