From 06a445ac8ad61dd7293b5202efd1e9844a284a9e Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Tue, 22 Oct 2024 15:27:49 +0100 Subject: [PATCH 1/2] IS 1083 fix snapshot downloading priority --- skaled/main.cpp | 51 +++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/skaled/main.cpp b/skaled/main.cpp index 03a02ffa5..b6eb27657 100644 --- a/skaled/main.cpp +++ b/skaled/main.cpp @@ -1606,27 +1606,10 @@ int main( int argc, char** argv ) try { std::vector< std::string > coreVolumes = { BlockChain::getChainDirName( chainParams ), "filestorage", "prices_" + chainParams.nodeInfo.id.str() + ".db", "blocks_" + chainParams.nodeInfo.id.str() + ".db" }; - std::vector< std::string > archiveVolumes = {}; - if ( chainParams.nodeInfo.archiveMode ) { -#ifdef HISTORIC_STATE - archiveVolumes.insert( archiveVolumes.end(), { "historic_roots", "historic_state" } ); -#endif - } snapshotManager.reset( new SnapshotManager( chainParams, getDataDir(), sharedSpace ? sharedSpace->getPath() : "" ) ); } - bool downloadGenesisForSyncNode = false; - if ( chainParams.nodeInfo.syncNode ) { - auto bc = BlockChain( chainParams, getDataDir() ); - if ( bc.number() == 0 ) { - downloadSnapshotFlag = true; - if ( chainParams.nodeInfo.syncFromCatchup ) { - downloadGenesisForSyncNode = true; - } - } - } - if ( downloadSnapshotFlag ) { statusAndControl->setExitState( StatusAndControl::StartAgain, true ); statusAndControl->setExitState( StatusAndControl::StartFromSnapshot, true ); @@ -1637,18 +1620,8 @@ int main( int argc, char** argv ) try { sharedSpace_lock.reset( new std::lock_guard< SharedSpace >( *sharedSpace ) ); try { - if ( !downloadGenesisForSyncNode ) - downloadAndProccessSnapshot( - snapshotManager, chainParams, urlToDownloadSnapshotFrom, true ); - else { - try { - downloadAndProccessSnapshot( - snapshotManager, chainParams, urlToDownloadSnapshotFrom, false ); - snapshotManager->restoreSnapshot( 0 ); - } catch ( SnapshotManager::SnapshotAbsent& ) { - clog( VerbosityWarning, "main" ) << "Snapshot for 0 block is not found"; - } - } + downloadAndProccessSnapshot( + snapshotManager, chainParams, urlToDownloadSnapshotFrom, true ); // if we dont have 0 snapshot yet try { @@ -1672,6 +1645,26 @@ int main( int argc, char** argv ) try { } // if --download-snapshot + // download 0 snapshot if needed + if ( chainParams.nodeInfo.syncNode ) { + auto bc = BlockChain( chainParams, getDataDir() ); + if ( bc.number() == 0 ) { + if ( chainParams.nodeInfo.syncFromCatchup && !downloadSnapshotFlag ) { + statusAndControl->setExitState( StatusAndControl::StartAgain, true ); + statusAndControl->setExitState( StatusAndControl::StartFromSnapshot, true ); + statusAndControl->setSubsystemRunning( StatusAndControl::SnapshotDownloader, true ); + + try { + downloadAndProccessSnapshot( + snapshotManager, chainParams, urlToDownloadSnapshotFrom, false ); + snapshotManager->restoreSnapshot( 0 ); + } catch ( SnapshotManager::SnapshotAbsent& ) { + clog( VerbosityWarning, "main" ) << "Snapshot for 0 block is not found"; + } + } + } + } + statusAndControl->setSubsystemRunning( StatusAndControl::SnapshotDownloader, false ); statusAndControl->setExitState( StatusAndControl::StartAgain, true ); From c358786d2855f2e24b764518cc746c0fd683fb66 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Thu, 24 Oct 2024 15:16:48 +0100 Subject: [PATCH 2/2] IS 1083 snapshotdownload flag --- skaled/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/skaled/main.cpp b/skaled/main.cpp index 86969b032..c7eb2389d 100644 --- a/skaled/main.cpp +++ b/skaled/main.cpp @@ -1592,6 +1592,7 @@ int main( int argc, char** argv ) try { std::string urlToDownloadSnapshotFrom = ""; if ( vm.count( "no-snapshot-majority" ) ) { + downloadSnapshotFlag = true; urlToDownloadSnapshotFrom = vm["no-snapshot-majority"].as< string >(); clog( VerbosityInfo, "main" ) << "Manually set url to download snapshot from: " << urlToDownloadSnapshotFrom;