Skip to content

Commit 20914cc

Browse files
authored
node, db: adjust BackEnd and KV API namespaces (#2090)
1 parent 30d4252 commit 20914cc

35 files changed

+265
-220
lines changed

cmd/dev/backend_kv_server.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <silkworm/infra/concurrency/awaitable_wait_for_one.hpp>
4040
#include <silkworm/infra/grpc/client/client_context_pool.hpp>
4141
#include <silkworm/node/backend/ethereum_backend.hpp>
42-
#include <silkworm/node/remote/ethbackend/grpc/server/backend_kv_server.hpp>
42+
#include <silkworm/node/backend_kv_server.hpp>
4343
#include <silkworm/sentry/eth/status_data_provider.hpp>
4444
#include <silkworm/sentry/grpc/client/sentry_client.hpp>
4545
#include <silkworm/sentry/multi_sentry_client.hpp>
@@ -68,7 +68,7 @@ struct StandaloneBackEndKVSettings : public SilkwormSettings {
6868
};
6969

7070
//! Parse the command-line arguments into the BackEnd and KV server settings
71-
int parse_command_line(int argc, char* argv[], CLI::App& app, StandaloneBackEndKVSettings& settings) {
71+
void parse_command_line(int argc, char* argv[], CLI::App& app, StandaloneBackEndKVSettings& settings) {
7272
auto& log_settings = settings.log_settings;
7373
auto& node_settings = settings.node_settings;
7474
auto& server_settings = settings.node_settings.server_settings;
@@ -106,8 +106,6 @@ int parse_command_line(int argc, char* argv[], CLI::App& app, StandaloneBackEndK
106106
/*create=*/false,
107107
/*readonly=*/true};
108108
node_settings.chaindata_env_config.max_readers = max_readers;
109-
110-
return 0;
111109
}
112110

113111
std::shared_ptr<silkworm::sentry::api::SentryClient> make_sentry_client(
@@ -160,10 +158,7 @@ int main(int argc, char* argv[]) {
160158

161159
try {
162160
StandaloneBackEndKVSettings settings;
163-
int result_code = parse_command_line(argc, argv, cli, settings);
164-
if (result_code != 0) {
165-
return result_code;
166-
}
161+
parse_command_line(argc, argv, cli, settings);
167162

168163
const auto pid = boost::this_process::get_id();
169164
const auto tid = std::this_thread::get_id();
@@ -215,7 +210,7 @@ int main(int argc, char* argv[]) {
215210
};
216211
backend.set_node_name(node_name);
217212

218-
rpc::BackEndKvServer server{server_settings, backend};
213+
node::BackEndKvServer server{server_settings, backend};
219214

220215
// Standalone BackEndKV server has no staged loop, so this simulates periodic state changes
221216
Task<void> tasks;

silkworm/db/remote/kv/api/client.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
#include "service.hpp"
2222

23-
namespace silkworm::remote::kv::api {
23+
namespace silkworm::kv::api {
2424

2525
struct Client {
2626
virtual ~Client() = default;
2727

2828
virtual std::shared_ptr<Service> service() = 0;
2929
};
3030

31-
} // namespace silkworm::remote::kv::api
31+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/direct_client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "direct_client.hpp"
1818

19-
namespace silkworm::remote::kv::api {
19+
namespace silkworm::kv::api {
2020

2121
DirectClient::DirectClient(std::shared_ptr<DirectService> direct_service)
2222
: direct_service_(std::move(direct_service)) {}
@@ -25,4 +25,4 @@ std::shared_ptr<api::Service> DirectClient::service() {
2525
return direct_service_;
2626
}
2727

28-
} // namespace silkworm::remote::kv::api
28+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/direct_client.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "../api/client.hpp"
2222
#include "../api/direct_service.hpp"
2323

24-
namespace silkworm::remote::kv::api {
24+
namespace silkworm::kv::api {
2525

2626
struct DirectClient : public api::Client {
2727
explicit DirectClient(std::shared_ptr<DirectService> direct_service);
@@ -33,4 +33,4 @@ struct DirectClient : public api::Client {
3333
std::shared_ptr<DirectService> direct_service_;
3434
};
3535

36-
} // namespace silkworm::remote::kv::api
36+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/direct_service.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616

1717
#include "direct_service.hpp"
1818

19-
namespace silkworm::remote::kv::api {
19+
namespace silkworm::kv::api {
2020

2121
DirectService::DirectService() = default;
2222

23+
// rpc Version(google.protobuf.Empty) returns (types.VersionReply);
24+
Task<Version> DirectService::version() {
25+
co_return kCurrentVersion;
26+
}
27+
2328
/** Temporal Point Queries **/
2429

2530
// rpc HistoryGet(HistoryGetReq) returns (HistoryGetReply);
@@ -54,4 +59,4 @@ Task<DomainRangeResult> DirectService::get_domain_range(const DomainRangeQuery&)
5459
co_return DomainRangeResult{};
5560
}
5661

57-
} // namespace silkworm::remote::kv::api
62+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/direct_service.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "service.hpp"
2020

21-
namespace silkworm::remote::kv::api {
21+
namespace silkworm::kv::api {
2222

2323
//! Straightforward asynchronous implementation of KV API service relying on \code Domains.
2424
//! This is used both client-side by 'direct' (i.e. no-gRPC) implementation and server-side by gRPC server.
@@ -33,6 +33,9 @@ class DirectService : public Service {
3333
DirectService(DirectService&&) = delete;
3434
DirectService& operator=(DirectService&&) = delete;
3535

36+
// rpc Version(google.protobuf.Empty) returns (types.VersionReply);
37+
Task<Version> version() override;
38+
3639
/** Temporal Point Queries **/
3740

3841
// rpc HistoryGet(HistoryGetReq) returns (HistoryGetReply);
@@ -53,4 +56,4 @@ class DirectService : public Service {
5356
Task<DomainRangeResult> get_domain_range(const DomainRangeQuery&) override;
5457
};
5558

56-
} // namespace silkworm::remote::kv::api
59+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/endpoint/common.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
#include <silkworm/core/common/bytes.hpp>
2323

24-
namespace silkworm::remote::kv::api {
24+
namespace silkworm::kv::api {
2525

2626
using TxId = uint64_t;
2727
using Timestamp = int64_t;
2828

2929
using ListOfBytes = std::vector<Bytes>;
3030
using ListOfTimestamp = std::vector<Timestamp>;
3131

32-
} // namespace silkworm::remote::kv::api
32+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/endpoint/temporal_point.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "common.hpp"
2323

24-
namespace silkworm::remote::kv::api {
24+
namespace silkworm::kv::api {
2525

2626
struct PointResult {
2727
bool success{false};
@@ -47,4 +47,4 @@ struct DomainPointQuery {
4747

4848
using DomainPointResult = PointResult;
4949

50-
} // namespace silkworm::remote::kv::api
50+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/endpoint/temporal_range.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "common.hpp"
2525

26-
namespace silkworm::remote::kv::api {
26+
namespace silkworm::kv::api {
2727

2828
struct IndexRangeQuery {
2929
TxId tx_id{0};
@@ -74,4 +74,4 @@ struct DomainRangeQuery {
7474

7575
using DomainRangeResult = RangeResult;
7676

77-
} // namespace silkworm::remote::kv::api
77+
} // namespace silkworm::kv::api
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 <tuple>
20+
21+
namespace silkworm::kv::api {
22+
23+
using Version = std::tuple<uint32_t, uint32_t, uint32_t>;
24+
25+
//! Current KV API protocol version.
26+
constexpr auto kCurrentVersion = Version{5, 1, 0};
27+
28+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/api/service.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@
2020

2121
#include "endpoint/temporal_point.hpp"
2222
#include "endpoint/temporal_range.hpp"
23+
#include "endpoint/version.hpp"
2324

24-
namespace silkworm::remote::kv::api {
25+
namespace silkworm::kv::api {
2526

2627
struct Service {
2728
virtual ~Service() = default;
2829

30+
// rpc Version(google.protobuf.Empty) returns (types.VersionReply);
31+
virtual Task<Version> version() = 0;
32+
2933
/** Temporal Point Queries **/
3034

3135
// rpc HistoryGet(HistoryGetReq) returns (HistoryGetReply);
@@ -46,4 +50,4 @@ struct Service {
4650
virtual Task<DomainRangeResult> get_domain_range(const DomainRangeQuery&) = 0;
4751
};
4852

49-
} // namespace silkworm::remote::kv::api
53+
} // namespace silkworm::kv::api

silkworm/db/remote/kv/grpc/client/endpoint/temporal_point.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <silkworm/core/common/util.hpp>
2020

21-
namespace silkworm::remote::kv::grpc::client {
21+
namespace silkworm::kv::grpc::client {
2222

2323
namespace proto = ::remote;
2424

@@ -65,4 +65,4 @@ api::DomainPointResult domain_get_result_from_response(const proto::DomainGetRep
6565
return result;
6666
}
6767

68-
} // namespace silkworm::remote::kv::grpc::client
68+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/endpoint/temporal_point.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
#include "../../../api/endpoint/temporal_point.hpp"
2222

23-
namespace silkworm::remote::kv::grpc::client {
23+
namespace silkworm::kv::grpc::client {
2424

2525
::remote::HistoryGetReq history_get_request_from_query(const api::HistoryPointQuery&);
2626
api::HistoryPointResult history_get_result_from_response(const ::remote::HistoryGetReply&);
2727

2828
::remote::DomainGetReq domain_get_request_from_query(const api::DomainPointQuery&);
2929
api::DomainPointResult domain_get_result_from_response(const ::remote::DomainGetReply&);
3030

31-
} // namespace silkworm::remote::kv::grpc::client
31+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/endpoint/temporal_point_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
#include "../../test_util/sample_protos.hpp"
2424

25-
namespace silkworm::remote::kv::grpc::client {
25+
namespace silkworm::kv::grpc::client {
2626

2727
using namespace evmc::literals;
28-
using namespace silkworm::remote::kv::test_util;
28+
using namespace silkworm::kv::test_util;
2929
using namespace silkworm::test_util;
3030
namespace proto = ::remote;
3131

@@ -95,4 +95,4 @@ TEST_CASE("domain_get_result_from_response", "[node][remote][kv][grpc]") {
9595
}
9696
}
9797

98-
} // namespace silkworm::remote::kv::grpc::client
98+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/endpoint/temporal_range.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <silkworm/core/common/util.hpp>
2020
#include <silkworm/infra/grpc/common/bytes.hpp>
2121

22-
namespace silkworm::remote::kv::grpc::client {
22+
namespace silkworm::kv::grpc::client {
2323

2424
namespace proto = ::remote;
2525

@@ -96,4 +96,4 @@ api::DomainRangeResult domain_range_result_from_response(const ::remote::Pairs&
9696
return result;
9797
}
9898

99-
} // namespace silkworm::remote::kv::grpc::client
99+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/endpoint/temporal_range.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "../../../api/endpoint/temporal_range.hpp"
2222

23-
namespace silkworm::remote::kv::grpc::client {
23+
namespace silkworm::kv::grpc::client {
2424

2525
::remote::IndexRangeReq index_range_request_from_query(const api::IndexRangeQuery&);
2626
api::IndexRangeResult index_range_result_from_response(const ::remote::IndexRangeReply&);
@@ -31,4 +31,4 @@ api::HistoryRangeResult history_range_result_from_response(const ::remote::Pairs
3131
::remote::DomainRangeReq domain_range_request_from_query(const api::DomainRangeQuery&);
3232
api::DomainRangeResult domain_range_result_from_response(const ::remote::Pairs&);
3333

34-
} // namespace silkworm::remote::kv::grpc::client
34+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/endpoint/temporal_range_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
#include "../../test_util/sample_protos.hpp"
2424

25-
namespace silkworm::remote::kv::grpc::client {
25+
namespace silkworm::kv::grpc::client {
2626

2727
using namespace evmc::literals;
28-
using namespace silkworm::remote::kv::test_util;
28+
using namespace silkworm::kv::test_util;
2929
using namespace silkworm::test_util;
3030
namespace proto = ::remote;
3131

@@ -140,4 +140,4 @@ TEST_CASE("domain_range_result_from_response", "[node][remote][kv][grpc]") {
140140
}
141141
}
142142

143-
} // namespace silkworm::remote::kv::grpc::client
143+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/remote_client.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "endpoint/temporal_point.hpp"
2525
#include "endpoint/temporal_range.hpp"
2626

27-
namespace silkworm::remote::kv::grpc::client {
27+
namespace silkworm::kv::grpc::client {
2828

2929
namespace proto = ::remote;
3030
using Stub = proto::KV::StubInterface;
@@ -48,6 +48,11 @@ class RemoteClientImpl final : public api::Service {
4848
RemoteClientImpl(const RemoteClientImpl&) = delete;
4949
RemoteClientImpl& operator=(const RemoteClientImpl&) = delete;
5050

51+
// rpc Version(google.protobuf.Empty) returns (types.VersionReply);
52+
Task<api::Version> version() override {
53+
co_return api::kCurrentVersion;
54+
}
55+
5156
/** Temporal Point Queries **/
5257

5358
// rpc HistoryGet(HistoryGetReq) returns (HistoryGetReply);
@@ -106,4 +111,4 @@ std::shared_ptr<api::Service> RemoteClient::service() {
106111
return p_impl_;
107112
}
108113

109-
} // namespace silkworm::remote::kv::grpc::client
114+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/remote_client.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "../../api/client.hpp"
2626
#include "../../api/service.hpp"
2727

28-
namespace silkworm::remote::kv::grpc::client {
28+
namespace silkworm::kv::grpc::client {
2929

3030
class RemoteClientImpl;
3131

@@ -40,4 +40,4 @@ struct RemoteClient : public api::Client {
4040
std::shared_ptr<RemoteClientImpl> p_impl_;
4141
};
4242

43-
} // namespace silkworm::remote::kv::grpc::client
43+
} // namespace silkworm::kv::grpc::client

silkworm/db/remote/kv/grpc/client/remote_client_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
#include "../test_util/sample_protos.hpp"
3030

31-
namespace silkworm::remote::kv::grpc::client {
31+
namespace silkworm::kv::grpc::client {
3232

3333
using namespace silkworm::grpc::test_util;
34-
using namespace silkworm::remote::kv::test_util;
34+
using namespace silkworm::kv::test_util;
3535
namespace proto = ::remote;
3636

3737
using StrictMockKVStub = testing::StrictMock<proto::FixIssue24351_MockKVStub>;
@@ -181,4 +181,4 @@ TEST_CASE_METHOD(RemoteClientTestRunner, "KV::DomainRange", "[node][remote][kv][
181181
}
182182
}
183183

184-
} // namespace silkworm::remote::kv::grpc::client
184+
} // namespace silkworm::kv::grpc::client

0 commit comments

Comments
 (0)