Skip to content

Commit

Permalink
Merge branch 'master' into ci/tidier26
Browse files Browse the repository at this point in the history
  • Loading branch information
yperbasis committed Sep 18, 2024
2 parents cbc348f + 7d8050e commit 914510a
Show file tree
Hide file tree
Showing 59 changed files with 736 additions and 365 deletions.
2 changes: 1 addition & 1 deletion cmake/copyright.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ list(FILTER SRC EXCLUDE REGEX [[silkworm/core/common/lru_cache(_test)?\..pp$]])
list(FILTER SRC EXCLUDE REGEX [[silkworm/core/crypto/kzg\.cpp$]])
list(FILTER SRC EXCLUDE REGEX [[silkworm/infra/concurrency/thread_pool\.hpp$]])
list(FILTER SRC EXCLUDE REGEX [[silkworm/interfaces/]])
list(FILTER SRC EXCLUDE REGEX [[silkworm/node/common/preverified_hashes_[a-z]+\.cpp$]])
list(FILTER SRC EXCLUDE REGEX [[silkworm/db/snapshots/config/[a-z_]+\.hpp$]])
list(FILTER SRC EXCLUDE REGEX [[silkworm/rpc/json_rpc/specification\.cpp$]])
list(FILTER SRC EXCLUDE REGEX [[silkworm/sync/internals/preverified_hashes/preverified_hashes_[a-z]+\.cpp$]])

foreach(F IN LISTS SRC)
check("${F}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/format.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ file(
list(FILTER SRC EXCLUDE REGEX "silkworm/interfaces/")
list(FILTER SRC EXCLUDE REGEX "silkworm/core/chain/genesis_[a-z_]+.cpp\$")
list(FILTER SRC EXCLUDE REGEX "silkworm/core/chain/dao.hpp$")
list(FILTER SRC EXCLUDE REGEX "silkworm/node/common/preverified_hashes_[a-z]+.cpp\$")
list(FILTER SRC EXCLUDE REGEX "silkworm/rpc/json_rpc/specification.cpp\$")
list(FILTER SRC EXCLUDE REGEX "silkworm/sync/internals/preverified_hashes/preverified_hashes_[a-z]+.cpp\$")

execute_process(COMMAND ${CLANG_FORMAT} -style=file -i ${SRC})
2 changes: 1 addition & 1 deletion cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if(NOT SILKWORM_CORE_ONLY)
common/snapshot_options.cpp
common/snapshot_options.hpp
)
set(SILKWORM_LIBRARIES silkworm_node silkworm_sync cmd_common $<$<BOOL:${MSVC}>:Kernel32.lib>)
set(SILKWORM_LIBRARIES silkworm_node cmd_common $<$<BOOL:${MSVC}>:Kernel32.lib>)
add_executable(silkworm "${SILKWORM_CMD_SRC}")
target_link_libraries(silkworm PRIVATE ${SILKWORM_LIBRARIES})

Expand Down
10 changes: 1 addition & 9 deletions cmd/common/node_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@

#include "common.hpp"
#include "human_size_option.hpp"
#include "snapshot_options.hpp"

namespace silkworm::cmd::common {

void add_node_options(CLI::App& cli, node::Settings& settings) {
void add_node_options(CLI::App& cli, NodeSettings& settings) {
cli.add_flag("--chaindata.exclusive", settings.chaindata_env_config.exclusive,
"Chaindata database opened in exclusive mode");
cli.add_flag("--chaindata.readahead", settings.chaindata_env_config.read_ahead,
Expand Down Expand Up @@ -69,17 +68,10 @@ void add_node_options(CLI::App& cli, node::Settings& settings) {

cli.add_flag("--fakepow", settings.fake_pow, "Disables proof-of-work verification");

add_option_private_api_address(cli, settings.server_settings.address_uri);
add_option_remote_sentry_addresses(cli, settings.remote_sentry_addresses, /*is_required=*/false);

// Chain options
add_option_chain(cli, settings.network_id);

// RPC server options
add_context_pool_options(cli, settings.server_settings.context_pool_settings);

// Snapshot&Bittorrent options
add_snapshot_options(cli, settings.snapshot_settings);
}

} // namespace silkworm::cmd::common
4 changes: 2 additions & 2 deletions cmd/common/node_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

#include <CLI/CLI.hpp>

#include <silkworm/node/settings.hpp>
#include <silkworm/node/common/node_settings.hpp>

namespace silkworm::cmd::common {

void add_node_options(CLI::App& cli, node::Settings& settings);
void add_node_options(CLI::App& cli, NodeSettings& settings);

} // namespace silkworm::cmd::common
16 changes: 8 additions & 8 deletions cmd/dev/backend_kv_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
#include <silkworm/infra/grpc/client/client_context_pool.hpp>
#include <silkworm/node/backend/ethereum_backend.hpp>
#include <silkworm/node/backend_kv_server.hpp>
#include <silkworm/node/settings.hpp>
#include <silkworm/sentry/eth/status_data_provider.hpp>
#include <silkworm/sentry/grpc/client/sentry_client.hpp>
#include <silkworm/sentry/multi_sentry_client.hpp>
#include <silkworm/sentry/session_sentry_client.hpp>

#include "../common/common.hpp"
#include "../common/db_max_readers_option.hpp"
#include "../common/settings.hpp"
#include "../common/shutdown_signal.hpp"

using namespace silkworm;
Expand All @@ -63,15 +63,15 @@ std::string get_library_versions() {
}

//! Standalone BackEndKV server settings
struct StandaloneBackEndKVSettings : public SilkwormSettings {
struct StandaloneBackEndKVSettings : public node::Settings {
bool simulate_state_changes{false};
};

//! Parse the command-line arguments into the BackEnd and KV server settings
void parse_command_line(int argc, char* argv[], CLI::App& app, StandaloneBackEndKVSettings& settings) {
auto& log_settings = settings.log_settings;
auto& node_settings = settings.node_settings;
auto& server_settings = settings.node_settings.server_settings;
auto& server_settings = settings.server_settings;

// Node options
std::filesystem::path data_dir;
Expand All @@ -84,7 +84,7 @@ void parse_command_line(int argc, char* argv[], CLI::App& app, StandaloneBackEnd
add_option_db_max_readers(app, max_readers);

// RPC Server options
add_option_private_api_address(app, node_settings.server_settings.address_uri);
add_option_private_api_address(app, server_settings.address_uri);
add_option_remote_sentry_addresses(app, node_settings.remote_sentry_addresses, /* is_required = */ true);
add_context_pool_options(app, server_settings.context_pool_settings);

Expand Down Expand Up @@ -129,7 +129,7 @@ std::shared_ptr<silkworm::sentry::api::SentryClient> make_sentry_client(
// wrap remote client in a session client
sentry_client = std::make_shared<silkworm::sentry::SessionSentryClient>(
remote_sentry_client,
eth_status_data_provider.to_factory_function());
silkworm::sentry::eth::StatusDataProvider::to_factory_function(std::move(eth_status_data_provider)));
} else {
std::vector<std::shared_ptr<silkworm::sentry::api::SentryClient>> clients;

Expand All @@ -141,7 +141,7 @@ std::shared_ptr<silkworm::sentry::api::SentryClient> make_sentry_client(
// wrap remote client in a session client
auto session_sentry_client = std::make_shared<silkworm::sentry::SessionSentryClient>(
remote_sentry_client,
eth_status_data_provider.to_factory_function());
silkworm::sentry::eth::StatusDataProvider::to_factory_function(eth_status_data_provider));
clients.push_back(session_sentry_client);
}

Expand All @@ -165,7 +165,7 @@ int main(int argc, char* argv[]) {

auto& log_settings = settings.log_settings;
auto& node_settings = settings.node_settings;
auto& server_settings = settings.node_settings.server_settings;
auto& server_settings = settings.server_settings;

// Initialize logging with custom settings
log::init(log_settings);
Expand All @@ -175,7 +175,7 @@ int main(int argc, char* argv[]) {
SILK_LOG << "BackEndKvServer build info: " << node_name;
SILK_LOG << "BackEndKvServer library info: " << get_library_versions();
SILK_LOG << "BackEndKvServer launched with chaindata: " << node_settings.chaindata_env_config.path
<< " address: " << node_settings.server_settings.address_uri
<< " address: " << server_settings.address_uri
<< " contexts: " << server_settings.context_pool_settings.num_contexts;

auto database_env = db::open_env(node_settings.chaindata_env_config);
Expand Down
23 changes: 19 additions & 4 deletions cmd/dev/db_toolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include <silkworm/infra/concurrency/spawn.hpp>
#include <silkworm/infra/test_util/task_runner.hpp>
#include <silkworm/node/stagedsync/execution_pipeline.hpp>
#include <silkworm/node/stagedsync/stages/stage_bodies.hpp>
#include <silkworm/node/stagedsync/stages/stage_interhashes/trie_cursor.hpp>

#include "../common/common.hpp"
Expand Down Expand Up @@ -570,12 +571,26 @@ void unwind(db::EnvConfig& config, BlockNum unwind_point, bool remove_blocks) {
auto chain_config{db::read_chain_config(txn)};
ensure(chain_config.has_value(), "Not an initialized Silkworm db or unknown/custom chain");

boost::asio::io_context io_context;

NodeSettings settings{
.data_directory = std::make_unique<DataDirectory>(),
.chaindata_env_config = config,
.chain_config = chain_config};

stagedsync::ExecutionPipeline stage_pipeline{&settings};
stagedsync::BodiesStageFactory bodies_stage_factory = [&](stagedsync::SyncContext* sync_context) {
return std::make_unique<stagedsync::BodiesStage>(sync_context, *settings.chain_config, [] { return 0; });
};

stagedsync::TimerFactory log_timer_factory = [&](std::function<bool()> callback) {
return std::make_shared<Timer>(io_context.get_executor(), settings.sync_loop_log_interval_seconds * 1000, std::move(callback));
};

stagedsync::ExecutionPipeline stage_pipeline{
&settings,
std::move(log_timer_factory),
std::move(bodies_stage_factory),
};
const auto unwind_result{stage_pipeline.unwind(txn, unwind_point)};

ensure(unwind_result == stagedsync::Stage::Result::kSuccess,
Expand Down Expand Up @@ -1287,10 +1302,10 @@ void compare(db::EnvConfig& config, const fs::path& target_datadir_path, bool ch
*
* Can parse a custom genesis file in json format or import data from known chain configs
*
* \param DataDir data_dir : hold data directory info about db paths
* \param data_dir : hold data directory info about db paths
* \param json_file : a string representing the path where to load custom json from
* \param uint32_t chain_id : an identifier for a known chain
* \param bool dry : whether or not commit data or run in simulation
* \param chain_id : an identifier for a known chain
* \param dry : whether to commit data or run in simulation
*
*/
void do_init_genesis(DataDirectory& data_dir, const std::string&& json_file, uint32_t chain_id, bool dry) {
Expand Down
Loading

0 comments on commit 914510a

Please sign in to comment.