Refactor genesis files and update CMake targets
Moved genesis-related generated files and logic from currency_core/generated and genesis_generator to a new src/genesis directory. Updated CMakeLists and include paths to reflect the new structure. Adjusted test and db build scripts to use ZLIB::ZLIB and miniupnpc::miniupnpc targets. Added README with instructions for genesis block updates. Removed premine wallet generation logic from config CMakeLists.
This commit is contained in:
parent
6a7b6dd2df
commit
6e4d8f7683
16 changed files with 58 additions and 48 deletions
|
|
@ -84,7 +84,7 @@ source_group(wallet FILES ${WALLET})
|
|||
INIT_SHARED_PCH()
|
||||
|
||||
add_subdirectory(config)
|
||||
add_subdirectory(genesis_generator)
|
||||
add_subdirectory(genesis)
|
||||
|
||||
add_library(common ${COMMON})
|
||||
add_dependencies(common version config ${PCH_LIB_NAME})
|
||||
|
|
|
|||
|
|
@ -19,45 +19,11 @@ target_include_directories(config INTERFACE
|
|||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
|
||||
)
|
||||
|
||||
#add_custom_target(gen_config_header
|
||||
# DEPENDS "${CMAKE_BINARY_DIR}/src/config/currency_config.h"
|
||||
#)
|
||||
|
||||
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/src/config/currency_config_dummy.cpp" "")
|
||||
|
||||
add_library(currency_config OBJECT
|
||||
"${CMAKE_BINARY_DIR}/src/config/currency_config.h"
|
||||
"${CMAKE_BINARY_DIR}/src/config/currency_config_dummy.cpp"
|
||||
)
|
||||
add_dependencies(currency_config config)
|
||||
|
||||
set(GENERATE_PREMINE_WALLET OFF CACHE BOOL "Generate premine wallet")
|
||||
set(PREMINE_WALLET_PASSWORD "" CACHE STRING "Premine wallet password")
|
||||
|
||||
if (GENERATE_PREMINE_WALLET AND GENERATE_FRESH_GENESIS)
|
||||
message(FATAL_ERROR "Genesis can not be generated together with premine wallet")
|
||||
endif()
|
||||
|
||||
if (GENERATE_PREMINE_WALLET)
|
||||
unset(GENERATE_PREMINE_WALLET CACHE)
|
||||
message(WARNING "Generating premine wallet")
|
||||
|
||||
if (NOT DEFINED PREMINE_WALLET_PASSWORD OR PREMINE_WALLET_PASSWORD STREQUAL "")
|
||||
message(FATAL_ERROR "set PREMINE_WALLET_PASSWORD or GENESIS_PREMINE_ADDRESS to generate genesis block")
|
||||
endif()
|
||||
|
||||
# Make wallet directory
|
||||
add_custom_target(
|
||||
premine_wallet
|
||||
"${CMAKE_COMMAND}" -E make_directory "${CMAKE_SOURCE_DIR}/premine_wallet"
|
||||
COMMENT "Creating premine wallet directory"
|
||||
)
|
||||
|
||||
# Generate wallet
|
||||
add_custom_command(TARGET premine_wallet POST_BUILD
|
||||
COMMAND echo ${PREMINE_WALLET_PASSWORD} | $<TARGET_FILE:simplewallet> --generate-new-wallet ${CMAKE_SOURCE_DIR}/premine_wallet/premine_wallet
|
||||
COMMENT "Generating premine wallet in ${CMAKE_SOURCE_DIR}/premine_wallet"
|
||||
)
|
||||
|
||||
add_dependencies(premine_wallet simplewallet)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@
|
|||
namespace currency
|
||||
{
|
||||
#ifndef TESTNET
|
||||
#include "generated/_genesis.cpp.gen"
|
||||
#include "../genesis/_genesis.cpp.gen"
|
||||
#else
|
||||
#include "generated/_genesis_tn.cpp.gen"
|
||||
#include "../genesis/_genesis_tn.cpp.gen"
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ namespace currency
|
|||
{
|
||||
#pragma pack(push, 1)
|
||||
#ifndef TESTNET
|
||||
#include "generated/_genesis.h.gen"
|
||||
#include "../genesis/_genesis.h.gen"
|
||||
#else
|
||||
#include "generated/_genesis_tn.h.gen"
|
||||
#include "../genesis/_genesis_tn.h.gen"
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
extern const genesis_tx_raw_data ggenesis_tx_raw;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
namespace currency
|
||||
{
|
||||
#ifndef TESTNET
|
||||
#include "generated/_genesis_acc.cpp.gen"
|
||||
#include "../genesis/_genesis_acc.cpp.gen"
|
||||
#else
|
||||
#include "generated/_genesis_acc_tn.cpp.gen"
|
||||
#include "../genesis/_genesis_acc_tn.cpp.gen"
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ if (GENERATE_FRESH_GENESIS)
|
|||
message(FATAL_ERROR "GENESIS_PREMINE_ADDRESS is not set and could not be read from file. Please set it via -DGENESIS_PREMINE_ADDRESS=<address>")
|
||||
else()
|
||||
add_custom_command(TARGET genesis_generator POST_BUILD
|
||||
COMMAND $<TARGET_FILE:genesis_generator> --address ${GENESIS_PREMINE_ADDRESS} --proof "${GENESIS_PROOF}" --output "${CMAKE_SOURCE_DIR}/src/currency_core/generated/"
|
||||
COMMAND $<TARGET_FILE:genesis_generator> --address ${GENESIS_PREMINE_ADDRESS} --proof "${GENESIS_PROOF}" --output "${CMAKE_SOURCE_DIR}/src/genesis/"
|
||||
COMMENT "Generating genesis data..."
|
||||
VERBATIM
|
||||
)
|
||||
44
src/genesis/README.md
Normal file
44
src/genesis/README.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Genesis Block Update Instructions
|
||||
|
||||
This document outlines the steps to trigger a genesis block update. The following instructions are based on the provided Makefile snippet.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* CMake
|
||||
* Make
|
||||
|
||||
## Steps
|
||||
|
||||
1. **Generate Premine Wallet (Optional):**
|
||||
|
||||
This step generates a premine wallet. It sets the `GENERATE_PREMINE_WALLET` CMake option to `1` and the `PREMINE_WALLET_PASSWORD` to `12345678`.
|
||||
|
||||
```bash
|
||||
cmake <cmake_release> <testnet> -DGENERATE_PREMINE_WALLET=1 -DPREMINE_WALLET_PASSWORD=12345678
|
||||
cmake --build ./src --target premine_wallet
|
||||
```
|
||||
|
||||
2. **Generate Fresh Genesis Block:**
|
||||
|
||||
This step generates a fresh genesis block. It sets the `GENERATE_FRESH_GENESIS` CMake option to `1`.
|
||||
|
||||
```bash
|
||||
cmake <cmake_release> <testnet> -DGENERATE_FRESH_GENESIS=1
|
||||
cmake --build ./src --target genesis_generator
|
||||
```
|
||||
|
||||
3. **Build the Project:**
|
||||
|
||||
This step builds the entire project.
|
||||
|
||||
```bash
|
||||
cmake <cmake_release> <testnet>
|
||||
make
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
* Replace `<cmake_release>` and `<testnet>` with the actual values used in your environment. These are likely variables defined elsewhere in the Makefile.
|
||||
* The `|| true` at the end of the `premine_wallet` build command ensures that the script continues even if the build fails.
|
||||
* This process assumes that the `CMAKE` macro and other variables like `dir_release` are properly defined in the Makefile.
|
||||
* The exact impact of these steps on the genesis block update depends on the codebase. Consult the source code for more details.
|
||||
|
|
@ -28,12 +28,12 @@ add_executable(net_load_tests_srv net_load_tests/srv.cpp)
|
|||
|
||||
add_dependencies(coretests version)
|
||||
|
||||
target_link_libraries(coretests rpc wallet currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(functional_tests rpc wallet currency_core crypto common zlibstatic ethash libminiupnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(coretests rpc wallet currency_core common crypto ZLIB::ZLIB ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(functional_tests rpc wallet currency_core crypto common ZLIB::ZLIB ethash miniupnpc::miniupnpc ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(hash-tests crypto ethash)
|
||||
target_link_libraries(hash-target-tests crypto currency_core ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(performance_tests wallet rpc currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(unit_tests wallet currency_core common crypto gtest_main zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(performance_tests wallet rpc currency_core common crypto ZLIB::ZLIB ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(unit_tests wallet currency_core common crypto gtest_main ZLIB::ZLIB ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(net_load_tests_clt currency_core common crypto gtest_main ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(net_load_tests_srv currency_core common crypto gtest_main ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
add_executable(db_tests db_tests.cpp)
|
||||
target_link_libraries(db_tests crypto common lmdb zlibstatic ${Boost_LIBRARIES})
|
||||
target_link_libraries(db_tests crypto common lmdb ZLIB::ZLIB ${Boost_LIBRARIES})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue