Skip to content

Commit 2654468

Browse files
authored
node: exec_api_address setting (#2366)
1 parent cf1073e commit 2654468

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

cmd/common/node_options.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ void add_node_options(CLI::App& cli, NodeSettings& settings) {
7070

7171
add_option_remote_sentry_addresses(cli, settings.remote_sentry_addresses, /*is_required=*/false);
7272

73+
cli.add_option("--exec.api.addr", settings.exec_api_address)
74+
->description("Execution API GRPC server bind address (IP:port) for connecting an external chain sync client");
75+
7376
// Chain options
7477
add_option_chain(cli, settings.network_id);
7578
}

silkworm/node/common/node_settings.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct NodeSettings {
4747
uint32_t sync_loop_log_interval_seconds{30}; // Interval for sync loop to emit logs
4848
bool parallel_fork_tracking_enabled{false}; // Whether to track multiple parallel forks at head
4949
bool keep_db_txn_open{true}; // Whether to keep db transaction open between requests
50+
std::optional<std::string> exec_api_address; // Execution API GRPC server bind address (IP:port)
5051

5152
db::etl::CollectorSettings etl() const {
5253
return {data_directory->temp().path(), etl_buffer_size};

silkworm/node/node.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ class NodeImpl final {
6363
BlockNum last_pre_validated_block() const { return chain_sync_.last_pre_validated_block(); }
6464

6565
private:
66+
Task<void> run_execution_service();
6667
Task<void> run_execution_server();
6768
Task<void> run_backend_kv_grpc_server();
6869
Task<void> embedded_sentry_run_if_needed();
70+
Task<void> run_chain_sync();
6971

7072
Settings& settings_;
7173
ChainConfig& chain_config_;
@@ -94,9 +96,9 @@ class NodeImpl final {
9496
std::unique_ptr<snapshots::bittorrent::BitTorrentClient> bittorrent_client_;
9597
};
9698

97-
static rpc::ServerSettings make_execution_server_settings() {
99+
static rpc::ServerSettings make_execution_server_settings(std::optional<std::string> exec_api_address) {
98100
return rpc::ServerSettings{
99-
.address_uri = "localhost:9092",
101+
.address_uri = exec_api_address.value_or("localhost:9092"),
100102
.context_pool_settings = {.num_contexts = 1}, // just one execution context
101103
};
102104
}
@@ -161,7 +163,7 @@ NodeImpl::NodeImpl(
161163
db::RWAccess{chaindata_env_},
162164
},
163165
execution_service_{std::make_shared<execution::api::ActiveDirectService>(execution_engine_, execution_context_)},
164-
execution_server_{make_execution_server_settings(), execution_service_},
166+
execution_server_{make_execution_server_settings(settings_.node_settings.exec_api_address), execution_service_},
165167
execution_direct_client_{execution_service_},
166168
snapshot_sync_{settings.snapshot_settings, chain_config_.chain_id, chaindata_env_, settings_.node_settings.data_directory->temp().path(), execution_engine_.stage_scheduler()},
167169
sentry_{
@@ -206,18 +208,22 @@ Task<void> NodeImpl::run_tasks() {
206208
co_await wait_for_setup();
207209

208210
co_await (
211+
run_execution_service() &&
209212
run_execution_server() &&
210213
resource_usage_log_.run() &&
211-
chain_sync_.async_run() &&
214+
run_chain_sync() &&
212215
run_backend_kv_grpc_server());
213216
}
214217

218+
Task<void> NodeImpl::run_execution_service() {
219+
// Thread running block execution requires custom stack size because of deep EVM call stacks
220+
return execution_service_->async_run("exec-engine", /* stack_size = */ kExecutionThreadStackSize);
221+
}
222+
215223
Task<void> NodeImpl::run_execution_server() {
216224
// Thread running block execution requires custom stack size because of deep EVM call stacks
217-
if (settings_.execution_server_enabled) {
218-
co_await execution_server_.async_run(/*stack_size=*/kExecutionThreadStackSize);
219-
} else {
220-
co_await execution_service_->async_run("exec-engine", /*stack_size=*/kExecutionThreadStackSize);
225+
if (settings_.node_settings.exec_api_address) {
226+
co_await execution_server_.async_run(/* stack_size = */ kExecutionThreadStackSize);
221227
}
222228
}
223229

@@ -239,6 +245,12 @@ Task<void> NodeImpl::embedded_sentry_run_if_needed() {
239245
}
240246
}
241247

248+
Task<void> NodeImpl::run_chain_sync() {
249+
if (!settings_.node_settings.exec_api_address) {
250+
co_await chain_sync_.async_run();
251+
}
252+
}
253+
242254
Node::Node(
243255
rpc::ClientContextPool& context_pool,
244256
Settings& settings,

silkworm/node/settings.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ struct Settings {
3434
sentry::Settings sentry_settings; // Configuration for Sentry client + embedded server
3535
rpc::ServerSettings server_settings; // Configuration for the gRPC server
3636
snapshots::SnapshotSettings snapshot_settings; // Configuration for the database snapshots
37-
bool execution_server_enabled{false};
3837
};
3938

4039
} // namespace silkworm::node

0 commit comments

Comments
 (0)