diff --git a/libweb3jsonrpc/Skale.cpp b/libweb3jsonrpc/Skale.cpp index 763c3af6c..492e25fc8 100644 --- a/libweb3jsonrpc/Skale.cpp +++ b/libweb3jsonrpc/Skale.cpp @@ -158,6 +158,10 @@ nlohmann::json Skale::impl_skale_getSnapshot( const nlohmann::json& joRequest, C // TODO check unsigned blockNumber = joRequest["blockNumber"].get< unsigned >(); + if ( blockNumber != m_client.getLatestSnapshotBlockNumer() ) { + joResponse["error"] = "Invalid snapshot block number requested - it might be deleted."; + return joResponse; + } // exit if too early if ( currentSnapshotBlockNumber >= 0 ) { @@ -366,6 +370,11 @@ Json::Value Skale::skale_getSnapshotSignature( unsigned blockNumber ) { if ( chainParams.nodeInfo.keyShareName.empty() || chainParams.nodeInfo.sgxServerUrl.empty() ) throw jsonrpc::JsonRpcException( "Snapshot signing is not enabled" ); + if ( blockNumber != this->m_client.getLatestSnapshotBlockNumer() ) { + throw jsonrpc::JsonRpcException( + "Invalid snapshot block number requested - it might be deleted." ); + } + try { dev::h256 snapshot_hash = this->m_client.getSnapshotHash( blockNumber ); if ( !snapshot_hash )