Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
cli.cpp
Go to the documentation of this file.
6#include "barretenberg/wsdb/generated/wsdb_ipc_server.hpp"
8
10#include <cstdint>
11#include <iostream>
12#include <string>
13#include <unordered_map>
14#include <vector>
15
16namespace bb::wsdb {
17
18using namespace bb::world_state;
19using namespace bb::crypto::merkle_tree;
20
21int parse_and_run_wsdb(int argc, char* argv[])
22{
23 CLI::App app{ "aztec-wsdb: Standalone world state database server" };
24 app.require_subcommand(1);
25
26 // -----------------------------------------------------------------------
27 // Subcommand: msgpack
28 // -----------------------------------------------------------------------
29 CLI::App* msgpack_command = app.add_subcommand("msgpack", "Msgpack API interface.");
30
31 // msgpack run
32 CLI::App* msgpack_run_command =
33 msgpack_command->add_subcommand("run", "Start the world state database IPC server.");
34
35 std::string input_path;
36 msgpack_run_command->add_option(
37 "-i,--input", input_path, "IPC socket/shm path (.sock for UDS, .shm for shared memory)");
38
39 std::string data_dir;
40 msgpack_run_command->add_option("-d,--data-dir", data_dir, "Data directory for LMDB stores")->required();
41
42 // Tree heights (JSON map: treeId -> height)
43 std::string tree_heights_json;
44 msgpack_run_command->add_option("--tree-heights", tree_heights_json, "Tree heights as JSON: {0:40,1:32,...}");
45
46 // Tree prefill sizes
47 std::string tree_prefill_json;
48 msgpack_run_command->add_option(
49 "--tree-prefill", tree_prefill_json, "Tree prefill sizes as JSON: {0:128,2:128,...}");
50
51 // Map sizes (KB)
52 std::string map_sizes_json;
53 msgpack_run_command->add_option("--map-sizes", map_sizes_json, "LMDB map sizes in KB as JSON: {0:1024,...}");
54
55 uint32_t threads = 16;
56 msgpack_run_command->add_option("-t,--threads", threads, "Thread pool size (default: 16)")
57 ->check(CLI::PositiveNumber);
58
59 uint32_t initial_header_generator_point = 0;
60 msgpack_run_command->add_option(
61 "--initial-header-generator-point", initial_header_generator_point, "Header generator point (default: 0)");
62
63 // Prefilled public data as JSON array of [slot_hex, value_hex] pairs
64 std::string prefilled_public_data_json;
65 msgpack_run_command->add_option(
66 "--prefilled-public-data", prefilled_public_data_json, "Prefilled public data as JSON array");
67
68 uint64_t genesis_timestamp = 0;
69 msgpack_run_command->add_option("--genesis-timestamp", genesis_timestamp, "Genesis block timestamp (default: 0)");
70
71 size_t request_ring_size = 1024 * 1024;
72 msgpack_run_command
73 ->add_option(
74 "--request-ring-size", request_ring_size, "Request ring buffer size for shared memory IPC (default: 1MB)")
75 ->check(CLI::PositiveNumber);
76
77 size_t response_ring_size = 1024 * 1024;
78 msgpack_run_command
79 ->add_option("--response-ring-size",
80 response_ring_size,
81 "Response ring buffer size for shared memory IPC (default: 1MB)")
82 ->check(CLI::PositiveNumber);
83
84 // Parse CLI
85 try {
86 app.parse(argc, argv);
87 } catch (const CLI::ParseError& e) {
88 return app.exit(e);
89 }
90
91 try {
92 if (msgpack_run_command->parsed()) {
93 return execute_wsdb_server(input_path,
94 data_dir,
95 tree_heights_json,
96 tree_prefill_json,
97 map_sizes_json,
98 threads,
99 initial_header_generator_point,
100 prefilled_public_data_json,
101 genesis_timestamp,
102 request_ring_size,
103 response_ring_size);
104 }
105 } catch (const std::exception& e) {
106 std::cerr << "Error: " << e.what() << '\n';
107 return 1;
108 }
109
110 return 0;
111}
112
113} // namespace bb::wsdb
int execute_wsdb_server(const std::string &input_path, const std::string &data_dir, const std::string &tree_heights_json, const std::string &tree_prefill_json, const std::string &map_sizes_json, uint32_t threads, uint32_t initial_header_generator_point, const std::string &prefilled_public_data_json, uint64_t genesis_timestamp, size_t request_ring_size, size_t response_ring_size)
Start the aztec-wsdb IPC server.
int parse_and_run_wsdb(int argc, char *argv[])
Definition cli.cpp:21
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13