6#include "barretenberg/wsdb/generated/wsdb_ipc_server.hpp"
9#include "ipc_runtime/ipc_server.hpp"
10#include "ipc_runtime/serve_helper.hpp"
11#include "ipc_runtime/signal_handlers.hpp"
18#include <unordered_map>
39 if (c !=
'{' && c !=
'}' && c !=
' ') {
43 std::istringstream ss(cleaned);
46 auto colon_pos =
pair.find(
':');
47 if (colon_pos != std::string::npos) {
62 auto u64_map = parse_tree_uint64_map(json);
63 for (
const auto& [k, v] : u64_map) {
64 result[k] =
static_cast<uint32_t
>(v);
75 auto u64_map = parse_tree_uint64_map(json);
76 for (
const auto& [k, v] : u64_map) {
77 result[k] =
static_cast<index_t>(v);
87static fr hex_to_fr(
const std::string& hex)
89 std::string cleaned = hex;
90 if (cleaned.size() >= 2 && cleaned[0] ==
'0' && (cleaned[1] ==
'x' || cleaned[1] ==
'X')) {
91 cleaned = cleaned.substr(2);
99 if (json.empty() || json ==
"[]") {
104 std::vector<std::string> hex_values;
106 bool in_string =
false;
108 for (
char c : json) {
110 in_string = !in_string;
111 }
else if (in_string) {
113 }
else if ((c ==
',' || c ==
']') && !current.empty()) {
114 hex_values.push_back(
std::move(current));
120 if (hex_values.size() % 2 != 0) {
121 std::cerr <<
"Warning: odd number of hex values in prefilled public data, ignoring last" <<
'\n';
123 for (
size_t i = 0; i + 1 < hex_values.size(); i += 2) {
124 result.emplace_back(hex_to_fr(hex_values[i]), hex_to_fr(hex_values[i + 1]));
134 const std::string& data_dir,
135 const std::string& tree_heights_json,
136 const std::string& tree_prefill_json,
137 const std::string& map_sizes_json,
139 uint32_t initial_header_generator_point,
140 const std::string& prefilled_public_data_json,
141 uint64_t genesis_timestamp,
142 size_t request_ring_size,
143 size_t response_ring_size)
148 auto tree_height = parse_tree_uint32_map(tree_heights_json);
149 auto tree_prefill = parse_tree_index_map(tree_prefill_json);
158 if (!map_sizes_json.empty()) {
159 auto parsed = parse_tree_uint64_map(map_sizes_json);
160 for (
const auto& [k, v] : parsed) {
167 if (!prefilled_public_data_json.empty()) {
168 prefilled_public_data = parse_prefilled_public_data(prefilled_public_data_json);
169 std::cerr <<
"Parsed " << prefilled_public_data.size() <<
" prefilled public data entries" <<
'\n';
173 std::cerr <<
"Creating WorldState at " << data_dir <<
" with " << threads <<
" threads" <<
'\n';
179 prefilled_public_data,
180 initial_header_generator_point,
188 ipc::ServerOptions opts;
189 opts.max_shm_clients = 2;
190 opts.shm_request_ring_size = request_ring_size;
191 opts.shm_response_ring_size = response_ring_size;
192 auto server = ipc::make_server(input_path, opts);
194 std::cerr <<
"Error: --input path must end with .sock or .shm: " << input_path <<
'\n';
197 std::cerr <<
"aztec-wsdb listening on " << input_path <<
'\n';
198 ipc::install_default_signal_handlers(*server);
200 if (!server->listen()) {
201 std::cerr <<
"Error: Could not start IPC server" <<
'\n';
205 std::cerr <<
"aztec-wsdb IPC server ready" <<
'\n';
207 auto handler = make_wsdb_handler(request);
209 return handler(std::vector<uint8_t>(raw.begin(), raw.end()));
const uint64_t DEFAULT_MAP_SIZE
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.
field< Bn254FrParams > fr
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
pair(A, B) -> pair< unwrap_ref_decay_t< A >, unwrap_ref_decay_t< B > >
world_state::WorldState & world_state
Non-template handler declarations for the wsdb service.
Service-level context passed to every wsdb handler.