Skip to content

Commit 73f6a02

Browse files
authored
rpcdaemon: add stub for remote Execution engine (#2060)
1 parent ac4d0f7 commit 73f6a02

File tree

5 files changed

+85
-5
lines changed

5 files changed

+85
-5
lines changed

silkworm/rpc/commands/rpc_api_table.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ void RpcApiTable::add_debug_handlers() {
104104
method_handlers_[json_rpc::method::k_debug_accountAt] = &commands::RpcApi::handle_debug_account_at;
105105
method_handlers_[json_rpc::method::k_debug_getRawBlock] = &commands::RpcApi::handle_debug_get_raw_block;
106106
method_handlers_[json_rpc::method::k_debug_getRawHeader] = &commands::RpcApi::handle_debug_get_raw_header;
107-
// method_handlers_[json_rpc::method::k_debug_getRawReceipts] = &commands::RpcApi::;
108107
method_handlers_[json_rpc::method::k_debug_getRawTransaction] = &commands::RpcApi::handle_debug_get_raw_transaction;
109108

110109
stream_handlers_[json_rpc::method::k_debug_traceCall] = &commands::RpcApi::handle_debug_trace_call;

silkworm/rpc/daemon.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <silkworm/infra/concurrency/private_service.hpp>
3535
#include <silkworm/infra/concurrency/shared_service.hpp>
3636
#include <silkworm/rpc/common/compatibility.hpp>
37+
#include <silkworm/rpc/engine/remote_execution_engine.hpp>
3738
#include <silkworm/rpc/ethbackend/remote_backend.hpp>
3839
#include <silkworm/rpc/ethdb/file/local_database.hpp>
3940
#include <silkworm/rpc/ethdb/kv/remote_database.hpp>
@@ -280,6 +281,8 @@ void Daemon::add_shared_services() {
280281
auto state_cache = std::make_shared<ethdb::kv::CoherentStateCache>();
281282
// Create the unique filter storage to be shared among the execution contexts
282283
auto filter_storage = std::make_shared<FilterStorage>(context_pool_.num_contexts() * kDefaultFilterStorageSize);
284+
// Create the unique Execution remote client to be shared among the execution contexts
285+
auto remote_execution_engine = std::make_shared<engine::RemoteExecutionEngine>();
283286

284287
// Add the shared state to the execution contexts
285288
for (std::size_t i{0}; i < settings_.context_pool_settings.num_contexts; ++i) {
@@ -288,8 +291,7 @@ void Daemon::add_shared_services() {
288291
add_shared_service(io_context, block_cache);
289292
add_shared_service<ethdb::kv::StateCache>(io_context, state_cache);
290293
add_shared_service(io_context, filter_storage);
291-
// TODO(canepat) replace w/ proper Execution remote client
292-
add_shared_service<engine::ExecutionEngine>(io_context, nullptr);
294+
add_shared_service<engine::ExecutionEngine>(io_context, remote_execution_engine);
293295
}
294296
}
295297

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2024 The Silkworm Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#include "remote_execution_engine.hpp"
18+
19+
namespace silkworm::rpc::engine {
20+
21+
Task<PayloadStatus> RemoteExecutionEngine::new_payload(const NewPayloadRequest& /*request*/, Msec /*timeout*/) {
22+
// TODO(canepat) implement using an Execution API remote client
23+
co_return PayloadStatus::Syncing;
24+
}
25+
26+
Task<ForkChoiceUpdatedReply> RemoteExecutionEngine::fork_choice_updated(const ForkChoiceUpdatedRequest& /*request*/, Msec /*timeout*/) {
27+
// TODO(canepat) implement using an Execution API remote client
28+
co_return ForkChoiceUpdatedReply{.payload_status = PayloadStatus::Syncing};
29+
}
30+
31+
Task<ExecutionPayloadAndValue> RemoteExecutionEngine::get_payload(uint64_t /*payloadId*/, Msec /*timeout*/) {
32+
// TODO(canepat) implement using an Execution API remote client
33+
co_return ExecutionPayloadAndValue{};
34+
}
35+
36+
Task<ExecutionPayloadBodies> RemoteExecutionEngine::get_payload_bodies_by_hash(const std::vector<Hash>& /*block_hashes*/, Msec /*timeout*/) {
37+
// TODO(canepat) implement using an Execution API remote client
38+
co_return ExecutionPayloadBodies{};
39+
}
40+
41+
Task<ExecutionPayloadBodies> RemoteExecutionEngine::get_payload_bodies_by_range(BlockNum /*start*/, uint64_t /*count*/, Msec /*timeout*/) {
42+
// TODO(canepat) implement using an Execution API remote client
43+
co_return ExecutionPayloadBodies{};
44+
}
45+
46+
} // namespace silkworm::rpc::engine
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2024 The Silkworm Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include "execution_engine.hpp"
20+
21+
namespace silkworm::rpc::engine {
22+
23+
class RemoteExecutionEngine final : public ExecutionEngine {
24+
public:
25+
RemoteExecutionEngine() = default;
26+
~RemoteExecutionEngine() override = default;
27+
28+
Task<PayloadStatus> new_payload(const NewPayloadRequest& request, Msec timeout) override;
29+
Task<ForkChoiceUpdatedReply> fork_choice_updated(const ForkChoiceUpdatedRequest& request, Msec timeout) override;
30+
Task<ExecutionPayloadAndValue> get_payload(uint64_t payloadId, Msec timeout) override;
31+
Task<ExecutionPayloadBodies> get_payload_bodies_by_hash(const std::vector<Hash>& block_hashes, Msec timeout) override;
32+
Task<ExecutionPayloadBodies> get_payload_bodies_by_range(BlockNum start, uint64_t count, Msec timeout) override;
33+
};
34+
35+
} // namespace silkworm::rpc::engine

silkworm/rpc/json_rpc/methods.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ inline constexpr const char* k_debug_traceBlockByNumber{"debug_traceBlockByNumbe
9898
inline constexpr const char* k_debug_traceBlockByHash{"debug_traceBlockByHash"};
9999
inline constexpr const char* k_debug_getRawBlock{"debug_getRawBlock"};
100100
inline constexpr const char* k_debug_getRawHeader{"debug_getRawHeader"};
101-
inline constexpr const char* k_debug_getRawReceipts{"debug_getRawReceipts"};
102101
inline constexpr const char* k_debug_getRawTransaction{"debug_getRawTransaction"};
103102

104103
inline constexpr const char* k_trace_call{"trace_call"};
@@ -148,7 +147,6 @@ inline constexpr const char* k_txpool_content{"txpool_content"};
148147

149148
inline constexpr const char* k_ots_getApiLevel{"ots_getApiLevel"};
150149
inline constexpr const char* k_ots_hasCode{"ots_hasCode"};
151-
152150
inline constexpr const char* k_ots_getBlockDetails{"ots_getBlockDetails"};
153151
inline constexpr const char* k_ots_getBlockDetailsByHash{"ots_getBlockDetailsByHash"};
154152
inline constexpr const char* k_ots_getBlockTransactions{"ots_getBlockTransactions"};

0 commit comments

Comments
 (0)