Skip to content

Commit

Permalink
Merge pull request #1784 from skalenetwork/bug/IS-902-allow-uploading…
Browse files Browse the repository at this point in the history
…-only-one-snapshot

IS-902 check block number to download snapshot
  • Loading branch information
olehnikolaiev authored Jan 17, 2024
2 parents 85146a0 + 04298fe commit 678f59b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libweb3jsonrpc/Skale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 678f59b

Please sign in to comment.