Skip to content

Commit

Permalink
#1588 add snapshot_hash_computation binary
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroNazarenko committed Dec 12, 2023
1 parent 2fcb104 commit 154c5d5
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/custom_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
cd build
cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE ${{ github.event.inputs.cmake_options }} ..
cd ..
- name: Build all
- name: Build skaled
run: |
export CC=gcc-9
export CXX=g++-9
Expand All @@ -123,7 +123,19 @@ jobs:
#strip skaled/skaled
cd ..
- name: Build and publish container
- name: Build snapshot benchmark
run: |
export CC=gcc-9
export CXX=g++-9
export TARGET=all
export CMAKE_BUILD_TYPE=Debug
cd build
make snapshot_hash_computation_benchmark -j$(nproc)
#echo "Ensure release mode skaled does not have any debug markers"
#strip skaled/skaled
cd ..
- name: Build and publish skaled container
run: |
cp build/skaled/skaled scripts/skale_build/executable/
export BRANCH=${{ github.event.inputs.branch_name }}
Expand All @@ -138,3 +150,10 @@ jobs:
with:
name: skaled
path: ./build/skaled/skaled

- name: Upload snapshot_benchmark binary as artifact
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: snapshot_benchmark
path: ./build/snapshot_hash_calculation_benchmark/snapshot_benchmark
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ endif()

add_subdirectory( skaled )
add_subdirectory( skaled_ssl_test )
add_subdirectory( snapshot_hash_calculation_benchmark )

if( TOOLS )
add_subdirectory( skale-key )
Expand Down
24 changes: 24 additions & 0 deletions snapshot_hash_calculation_benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set(
sources
main.cpp
)

set(
headers
)

set(executable_name snapshot_benchmark)

add_executable(${executable_name} ${sources} ${headers})
target_compile_options( ${executable_name} PRIVATE
-Wno-error=deprecated-copy -Wno-error=unused-result -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=maybe-uninitialized
)
target_link_libraries(
${executable_name}
PRIVATE
skutils
skale
devcore
# "${DEPS_INSTALL_ROOT}/lib/libunwind.a"
# "${DEPS_INSTALL_ROOT}/lib/liblzma.a"
)
36 changes: 36 additions & 0 deletions snapshot_hash_calculation_benchmark/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <libdevcore/CommonIO.h>
#include <libskale/SnapshotManager.h>

#include <iostream>
#include <unistd.h>

int main() {
std::string dataDir, configPath;
unsigned blockNumber;
std::cin >> dataDir >> configPath >> blockNumber;

std::string configJSON = dev::contentsString( configPath );

dev::eth::ChainParams chainParams;
chainParams.loadConfig( configJSON, configPath );

std::shared_ptr< SnapshotManager > snapshotManager;

snapshotManager.reset( new SnapshotManager( chainParams, dataDir,
{ dev::eth::BlockChain::getChainDirName( chainParams ), "filestorage",
"prices_" + chainParams.nodeInfo.id.str() + ".db",
"blocks_" + chainParams.nodeInfo.id.str() + ".db" }, "" ) );

std::cout << "SLEEPING FOR 60 seconds\n";
sleep(60);

snapshotManager->doSnapshot( blockNumber );

std::cout << "SNAPSHOT IS READY, CALCULATING ITS HASH NOW\n";

snapshotManager->computeSnapshotHash( blockNumber );

std::cout << "SNAPSHOT HASH IS READY, EXITING\n";

return 0;
}

0 comments on commit 154c5d5

Please sign in to comment.