Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9a44c3b
feature: anchor block and state
xDimon Dec 17, 2025
48705c1
refactor: changes generating some files
xDimon Dec 23, 2025
2597140
draft
xDimon Dec 23, 2025
ab14d7a
draft
xDimon Dec 24, 2025
64113fc
refactor: log config over cli
xDimon Dec 26, 2025
06cfe1a
fix: review issues
xDimon Dec 29, 2025
adfb692
draft
xDimon Dec 30, 2025
8b665f2
draft
xDimon Dec 30, 2025
c935b3e
git: Merge branch 'master' into refactor/block_tree_and_forck_choice
xDimon Jan 13, 2026
186a4a6
fix: test
xDimon Jan 13, 2026
193479d
more logs
xDimon Jan 13, 2026
16597ea
fix: receiving and import blocks with correct
xDimon Jan 14, 2026
d4fa0af
fix: fork-choice initialization after restart
xDimon Jan 15, 2026
bf61bf8
docs: update README with instructions to clear data repositories and …
kamilsa Jan 15, 2026
3711251
hotfix
xDimon Jan 15, 2026
ec96d97
hotfix
xDimon Jan 15, 2026
0df1d8a
refactor: approach of store and operate with attestations and signatures
xDimon Jan 16, 2026
6960f45
git: Merge branch 'master' into refactor/block_tree_and_forck_choice
xDimon Jan 16, 2026
241fede
fix: tests
xDimon Jan 16, 2026
88075cb
+ todo
xDimon Jan 16, 2026
a545459
refactor: bit_cast for hash_tree_root
xDimon Jan 16, 2026
718dff6
+ todo
xDimon Jan 16, 2026
098bf93
fix: lru cache and cover it by tests
xDimon Jan 16, 2026
685a40d
fix: interval enumeration if log
xDimon Jan 16, 2026
2146991
digest-banner
xDimon Jan 19, 2026
442ac89
feature: save/restore finalized and justified block
xDimon Jan 20, 2026
b37a3ec
fix: digest-banner
xDimon Jan 20, 2026
f161609
hotfix
xDimon Jan 20, 2026
63a0d59
fix: use last justified over block tree
xDimon Jan 20, 2026
c981ad1
improve validation checks for attestation targets in fork choice logic
kamilsa Jan 20, 2026
c004b2c
improve connection handling in networking module
kamilsa Jan 20, 2026
555d9cf
fix: tests
xDimon Jan 21, 2026
8e2cf16
fix: TODOs, tests, etc. and update
xDimon Jan 21, 2026
efabce9
refactor: import of block with its children and use queue
xDimon Jan 21, 2026
ff73f49
update: qtils
xDimon Jan 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ include(vcpkg-overlay/cppcodec.cmake)
# add_compile_options(-fmodules)
# endif()

add_compile_definitions(
BOOST_DI_CFG_DIAGNOSTICS_LEVEL=2
BOOST_DI_CFG_CTOR_LIMIT_SIZE=32
)

add_definitions(
-DBOOST_DI_CFG_DIAGNOSTICS_LEVEL=2
-DBOOST_DI_CFG_CTOR_LIMIT_SIZE=32
)

add_library(headers INTERFACE)
target_include_directories(headers INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
Expand Down
8 changes: 7 additions & 1 deletion example/0-single/genesis/config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Genesis Settings
GENESIS_TIME: 1763468331
GENESIS_TIME: 1766302305
# Key Settings
ACTIVE_EPOCH: 18
# Validator Settings
VALIDATOR_COUNT: 1
GENESIS_VALIDATORS:
- "b3183808a14d1875748fd96989441855092ef73c6bf5a7680f03b32d1c12f96ec4659e64fd526f3d975eb168907ee7589946f972"
27 changes: 27 additions & 0 deletions example/0-single/genesis/validator-keys-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Hash-Signature Validator Keys Manifest
# Generated by hash-sig-cli

key_scheme: SIGTopLevelTargetSumLifetime32Dim64Base8
hash_function: Poseidon2
encoding: TargetSum
lifetime: 4294967296
log_num_active_epochs: 18
num_active_epochs: 262144
num_validators: 4

validators:
- index: 0
pubkey_hex: 0xb3183808a14d1875748fd96989441855092ef73c6bf5a7680f03b32d1c12f96ec4659e64fd526f3d975eb168907ee7589946f972
privkey_file: validator_0_sk.json

- index: 1
pubkey_hex: 0xd89fef7b41821a67c118e26808f48e28d00cbe082a1f88369b8828147f3905656b3b04785a5b26403a0c0a574b4f333bd4d48a03
privkey_file: validator_1_sk.json

- index: 2
pubkey_hex: 0xd404bb1091a750710952a64b22240d0013bcc66a64b5b1780b89b120c0dd7d212fa3cb5e42f56e74fcc68950e6b493647524a627
privkey_file: validator_2_sk.json

- index: 3
pubkey_hex: 0xb196071b88a6f16d658e512f753be6222e54e91a19e0d676201ac5161cd90e1e40210d36e024f81ae30ee67714092009c20b415c
privkey_file: validator_3_sk.json
1 change: 1 addition & 0 deletions example/0-single/genesis/validator_0_pk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":[2087627763,754406247,1168254309,360212415,1578884007,772417919,1172421982,1682864316],"parameter":[472747929,573156706,1979134263,986355730,1782443694]}
1 change: 1 addition & 0 deletions example/0-single/genesis/validator_0_sk.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ logging:
- name: storage
children:
- name: block_storage
- name: blockchain
children:
- name: block_tree
- name: fork_choice
level: trace
76 changes: 61 additions & 15 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,81 @@
# SPDX-License-Identifier: Apache-2.0
#

execute_process(
COMMAND git symbolic-ref -q HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_REF
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)

if(GIT_REF)
set(GIT_REF_FILE "${CMAKE_SOURCE_DIR}/.git/${GIT_REF}")
else()
set(GIT_REF_FILE "${CMAKE_SOURCE_DIR}/.git/HEAD")
endif()

set(BUILD_VERSION_CPP "${CMAKE_BINARY_DIR}/generated/app/build_version.cpp")
set(GET_VERSION_SCRIPT "${CMAKE_SOURCE_DIR}/scripts/get_version.sh")
add_custom_command(
OUTPUT ${BUILD_VERSION_CPP}
COMMAND echo "// Auto-generated file" > ${BUILD_VERSION_CPP}
COMMAND echo "#include <string>" >> ${BUILD_VERSION_CPP}
COMMAND echo "namespace lean {" >> ${BUILD_VERSION_CPP}
COMMAND echo " const std::string &buildVersion() {" >> ${BUILD_VERSION_CPP}
COMMAND printf " static const std::string buildVersion(\"" >> ${BUILD_VERSION_CPP}
COMMAND ${GET_VERSION_SCRIPT} >> ${BUILD_VERSION_CPP}
COMMAND echo "\");" >> ${BUILD_VERSION_CPP}
COMMAND echo " return buildVersion;" >> ${BUILD_VERSION_CPP}
COMMAND echo " }" >> ${BUILD_VERSION_CPP}
COMMAND echo "}" >> ${BUILD_VERSION_CPP}

COMMAND ${CMAKE_COMMAND} -E make_directory "$<SHELL_PATH:${CMAKE_BINARY_DIR}/generated/app>"

COMMAND ${CMAKE_COMMAND} -E echo "// Auto-generated file" > "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "#include <string>" >> "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "" >> "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "namespace lean {" >> "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo " const std::string &buildVersion() {" >> "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E env sh -c "printf '%s' ' static const std::string buildVersion(\"' >> \"${BUILD_VERSION_CPP}\""

COMMAND ${CMAKE_COMMAND} -E env sh -c "\"${GET_VERSION_SCRIPT}\" >> \"${BUILD_VERSION_CPP}\""

COMMAND ${CMAKE_COMMAND} -E echo "\");" >> "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo " return buildVersion;" >> "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo " }" >> "${BUILD_VERSION_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "} // namespace lean" >> "${BUILD_VERSION_CPP}"

COMMENT "Generate build_version.cpp"
DEPENDS ${GET_VERSION_SCRIPT}
DEPENDS
"${GET_VERSION_SCRIPT}"
"${GIT_REF_FILE}"
VERBATIM
)
add_library(build_version
"${BUILD_VERSION_CPP}"
)

set(DEFAULT_LOGGING_YAML_CPP "${CMAKE_BINARY_DIR}/generated/app/default_logging_yaml.cpp")
file(READ "${CMAKE_SOURCE_DIR}/example/config.yaml" DEFAULT_LOGGING_YAML)
configure_file("${CMAKE_CURRENT_LIST_DIR}/default_logging_yaml.cpp.in" "${DEFAULT_LOGGING_YAML_CPP}")
set(DEFAULT_CONFIG_CPP "${CMAKE_BINARY_DIR}/generated/app/default_config.cpp")
set(DEFAULT_CONFIG_YAML "${CMAKE_SOURCE_DIR}/example/config.yaml")
add_custom_command(
OUTPUT "${DEFAULT_CONFIG_CPP}"

COMMAND ${CMAKE_COMMAND} -E make_directory "$<SHELL_PATH:${CMAKE_BINARY_DIR}/generated/app>"

COMMAND ${CMAKE_COMMAND} -E echo "// Auto-generated file" > "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "#include \"app/default_config.hpp\"" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "namespace lean {" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo " const std::string &defaultConfigYaml() {" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo " static const std::string defaultConfigYaml = R\"yaml(" >> "${DEFAULT_CONFIG_CPP}"

COMMAND ${CMAKE_COMMAND} -E cat "${DEFAULT_CONFIG_YAML}" >> "${DEFAULT_CONFIG_CPP}"

COMMAND ${CMAKE_COMMAND} -E echo "" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo ")yaml\";" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo " return defaultConfigYaml;" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo " }" >> "${DEFAULT_CONFIG_CPP}"
COMMAND ${CMAKE_COMMAND} -E echo "} // namespace lean" >> "${DEFAULT_CONFIG_CPP}"

DEPENDS "${DEFAULT_CONFIG_YAML}"
COMMENT "Generate default_config.cpp"
VERBATIM
)

add_library(app_configuration SHARED
configuration.cpp
"${DEFAULT_LOGGING_YAML_CPP}"
"${DEFAULT_CONFIG_CPP}"
)
target_link_libraries(app_configuration
Boost::boost
Expand Down
61 changes: 40 additions & 21 deletions src/app/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "app/build_version.hpp"
#include "app/configuration.hpp"
#include "app/default_logging_yaml.hpp"
#include "app/default_config.hpp"
#include "app/validator_keys_manifest.hpp"
#include "crypto/xmss/xmss_util.hpp"
#include "log/formatters/filepath.hpp"
Expand Down Expand Up @@ -161,9 +161,17 @@ namespace lean::app {
namespace po = boost::program_options;
namespace fs = std::filesystem;

// clang-format off

po::options_description options;
options.add_options()("help,h", "show help")("version,v", "show version")(
"config,c", po::value<std::string>(), "config-file path");
options.add_options()
("help,h", "show help")
("version,v", "show version")
("config,c", po::value<std::string>(), "config-file path")
("log,l", po::value<std::vector<std::string>>(), "Sets a custom logging filter")
;

// clang-format on

po::variables_map vm;

Expand Down Expand Up @@ -211,6 +219,10 @@ namespace lean::app {
}
}

if (vm.contains("log")) {
logger_cli_args_ = vm["log"].as<std::vector<std::string>>();
}

return false;
}

Expand All @@ -237,10 +249,10 @@ namespace lean::app {
outcome::result<YAML::Node> Configurator::getLoggingConfig() {
auto load_default = [&]() -> outcome::result<YAML::Node> {
try {
return YAML::Load(defaultLoggingYaml())["logging"];
return YAML::Load(defaultConfigYaml())["logging"];
} catch (const std::exception &e) {
file_errors_ << "E: Failed to load default logging config: " << e.what()
<< "\n";
file_errors_ << "E: Failed to load embedded default config: "
<< e.what() << "\n";
return Error::ConfigFileParseFailed;
}
};
Expand All @@ -254,6 +266,7 @@ namespace lean::app {
}
return load_default();
}

outcome::result<std::shared_ptr<Configuration>> Configurator::calculateConfig(
qtils::SharedRef<soralog::Logger> logger) {
logger_ = std::move(logger);
Expand Down Expand Up @@ -405,7 +418,8 @@ namespace lean::app {
auto value = validator_keys_manifest.as<std::string>();
config_->validator_keys_manifest_path_ = value;
} else {
file_errors_ << "E: Value 'general.validator-keys-manifest' must be scalar\n";
file_errors_ << "E: Value 'general.validator-keys-manifest' must "
"be scalar\n";
file_has_error_ = true;
}
}
Expand Down Expand Up @@ -504,10 +518,11 @@ namespace lean::app {
cli_values_map_, "xmss-sk", [&](const std::string &value) {
config_->xmss_secret_key_path_ = value;
});
find_argument<std::string>(
cli_values_map_, "validator-keys-manifest", [&](const std::string &value) {
config_->validator_keys_manifest_path_ = value;
});
find_argument<std::string>(cli_values_map_,
"validator-keys-manifest",
[&](const std::string &value) {
config_->validator_keys_manifest_path_ = value;
});
if (fail) {
return Error::CliArgsParseFailed;
}
Expand Down Expand Up @@ -610,11 +625,13 @@ namespace lean::app {

// Validate and load XMSS keys (mandatory)
if (config_->xmss_public_key_path_.empty()) {
SL_ERROR(logger_, "The '--xmss-pk' (XMSS public key) path must be provided");
SL_ERROR(logger_,
"The '--xmss-pk' (XMSS public key) path must be provided");
return Error::InvalidValue;
}
if (config_->xmss_secret_key_path_.empty()) {
SL_ERROR(logger_, "The '--xmss-sk' (XMSS secret key) path must be provided");
SL_ERROR(logger_,
"The '--xmss-sk' (XMSS secret key) path must be provided");
return Error::InvalidValue;
}

Expand All @@ -637,26 +654,28 @@ namespace lean::app {
}

// Load XMSS keypair from JSON files
OUTCOME_TRY(keypair, crypto::xmss::loadKeypairFromJson(
config_->xmss_secret_key_path_,
config_->xmss_public_key_path_
));
OUTCOME_TRY(
keypair,
crypto::xmss::loadKeypairFromJson(config_->xmss_secret_key_path_,
config_->xmss_public_key_path_));
config_->xmss_keypair_ = std::move(keypair);
SL_INFO(logger_, "Loaded XMSS keypair from:");
SL_INFO(logger_, " Public key: {}", config_->xmss_public_key_path_);
SL_INFO(logger_, " Secret key: {}", config_->xmss_secret_key_path_);

// Load validator keys manifest (mandatory)
if (config_->validator_keys_manifest_path_.empty()) {
SL_ERROR(logger_, "The '--validator-keys-manifest' path must be provided");
SL_ERROR(logger_,
"The '--validator-keys-manifest' path must be provided");
return Error::InvalidValue;
}

config_->validator_keys_manifest_path_ =
resolve_relative(config_->validator_keys_manifest_path_, "validator-keys-manifest");
config_->validator_keys_manifest_path_ = resolve_relative(
config_->validator_keys_manifest_path_, "validator-keys-manifest");
if (not is_regular_file(config_->validator_keys_manifest_path_)) {
SL_ERROR(logger_,
"The 'validator-keys-manifest' file does not exist or is not a file: {}",
"The 'validator-keys-manifest' file does not exist or is not a "
"file: {}",
config_->validator_keys_manifest_path_);
return Error::InvalidValue;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/configurator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ namespace lean::app {
outcome::result<bool> step2();

outcome::result<YAML::Node> getLoggingConfig();
std::vector<std::string> getLoggingCliArgs() {
return logger_cli_args_;
}

outcome::result<std::shared_ptr<Configuration>> calculateConfig(
qtils::SharedRef<soralog::Logger> logger);
Expand All @@ -70,6 +73,7 @@ namespace lean::app {
bool file_has_warn_ = false;
bool file_has_error_ = false;
std::ostringstream file_errors_;
std::vector<std::string> logger_cli_args_;

boost::program_options::options_description cli_options_;
boost::program_options::variables_map cli_values_map_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace lean {
/**
* YAML to read default logging config.
* YAML to read default config.
*/
const std::string &defaultLoggingYaml();
const std::string &defaultConfigYaml();
} // namespace lean
16 changes: 0 additions & 16 deletions src/app/default_logging_yaml.cpp.in

This file was deleted.

Loading
Loading