Skip to content

Commit

Permalink
IS 902 handle wrong snapshot block number request for signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Jan 16, 2024
1 parent 9431fab commit aab2420
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libweb3jsonrpc/Skale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ 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"] = "Wrong snapshot block number requested.";
joResponse["error"] = "Invalid snapshot block number requested - it might be deleted.";
return joResponse;
}

Expand Down Expand Up @@ -370,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 )
Expand Down

0 comments on commit aab2420

Please sign in to comment.