Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
wsdb_handlers.cpp
Go to the documentation of this file.
1
18#include "barretenberg/wsdb/generated/wsdb_ipc_server.hpp"
20
21#include <optional>
22#include <stdexcept>
23
24namespace bb::wsdb {
25
26using namespace bb::world_state;
27using namespace bb::crypto::merkle_tree;
28
29// ---------------------------------------------------------------------------
30// Tree info / state queries
31// ---------------------------------------------------------------------------
32
33wire::WsdbGetTreeInfoResponse handle_get_tree_info(WsdbRequest& ctx, wire::WsdbGetTreeInfo&& cmd)
34{
35 auto info = ctx.world_state.get_tree_info(revision_from_wire(cmd.revision), tree_id_from_wire(cmd.treeId));
36 return wire::WsdbGetTreeInfoResponse{
37 .treeId = cmd.treeId,
38 .root = fr_to_wire(info.meta.root),
39 .size = info.meta.size,
40 .depth = info.meta.depth,
41 };
42}
43
44wire::WsdbGetStateReferenceResponse handle_get_state_reference(WsdbRequest& ctx, wire::WsdbGetStateReference&& cmd)
45{
46 auto state = ctx.world_state.get_state_reference(revision_from_wire(cmd.revision));
47 return wire::WsdbGetStateReferenceResponse{ .state = state_reference_to_wire(state) };
48}
49
50wire::WsdbGetInitialStateReferenceResponse handle_get_initial_state_reference(WsdbRequest& ctx,
51 wire::WsdbGetInitialStateReference&&)
52{
54 return wire::WsdbGetInitialStateReferenceResponse{ .state = state_reference_to_wire(state) };
55}
56
57// ---------------------------------------------------------------------------
58// Leaf queries
59// ---------------------------------------------------------------------------
60
61wire::WsdbGetLeafValueResponse handle_get_leaf_value(WsdbRequest& ctx, wire::WsdbGetLeafValue&& cmd)
62{
63 auto revision = revision_from_wire(cmd.revision);
64 auto tree_id = tree_id_from_wire(cmd.treeId);
65 auto leaf_index = static_cast<index_t>(cmd.leafIndex);
66
67 switch (tree_id) {
71 auto leaf = ctx.world_state.get_leaf<bb::fr>(revision, tree_id, leaf_index);
72 return wire::WsdbGetLeafValueResponse{ .value = leaf.has_value() ? std::optional<Fr>(fr_to_wire(*leaf))
73 : std::nullopt };
74 }
75 default:
76 throw std::runtime_error("Unsupported tree type for get_leaf_value");
77 }
78}
79
80wire::WsdbGetPublicDataLeafValueResponse handle_get_public_data_leaf_value(WsdbRequest& ctx,
81 wire::WsdbGetPublicDataLeafValue&& cmd)
82{
83 auto leaf = ctx.world_state.get_leaf<PublicDataLeafValue>(revision_from_wire(cmd.revision),
85 static_cast<index_t>(cmd.leafIndex));
86 return wire::WsdbGetPublicDataLeafValueResponse{
87 .value =
89 };
90}
91
92wire::WsdbGetNullifierLeafValueResponse handle_get_nullifier_leaf_value(WsdbRequest& ctx,
93 wire::WsdbGetNullifierLeafValue&& cmd)
94{
95 auto leaf = ctx.world_state.get_leaf<NullifierLeafValue>(revision_from_wire(cmd.revision),
97 static_cast<index_t>(cmd.leafIndex));
98 return wire::WsdbGetNullifierLeafValueResponse{ .value = leaf.has_value() ? std::optional<wire::NullifierLeafValue>(
100 : std::nullopt };
101}
102
103wire::WsdbGetPublicDataLeafPreimageResponse handle_get_public_data_leaf_preimage(
104 WsdbRequest& ctx, wire::WsdbGetPublicDataLeafPreimage&& cmd)
105{
108 static_cast<index_t>(cmd.leafIndex));
109 return wire::WsdbGetPublicDataLeafPreimageResponse{
110 .preimage = leaf.has_value()
113 };
114}
115
116wire::WsdbGetNullifierLeafPreimageResponse handle_get_nullifier_leaf_preimage(WsdbRequest& ctx,
117 wire::WsdbGetNullifierLeafPreimage&& cmd)
118{
121 static_cast<index_t>(cmd.leafIndex));
122 return wire::WsdbGetNullifierLeafPreimageResponse{ .preimage = leaf.has_value()
125 : std::nullopt };
126}
127
128wire::WsdbGetSiblingPathResponse handle_get_sibling_path(WsdbRequest& ctx, wire::WsdbGetSiblingPath&& cmd)
129{
131 revision_from_wire(cmd.revision), tree_id_from_wire(cmd.treeId), static_cast<index_t>(cmd.leafIndex));
132 return wire::WsdbGetSiblingPathResponse{ .path = fr_vec_to_wire(path) };
133}
134
135wire::WsdbGetBlockNumbersForLeafIndicesResponse handle_get_block_numbers_for_leaf_indices(
136 WsdbRequest& ctx, wire::WsdbGetBlockNumbersForLeafIndices&& cmd)
137{
138 std::vector<index_t> leaf_indices;
139 leaf_indices.reserve(cmd.leafIndices.size());
140 for (auto i : cmd.leafIndices) {
141 leaf_indices.push_back(static_cast<index_t>(i));
142 }
145 revision_from_wire(cmd.revision), tree_id_from_wire(cmd.treeId), leaf_indices, block_numbers);
146 std::vector<std::optional<uint32_t>> wire_block_numbers;
147 wire_block_numbers.reserve(block_numbers.size());
148 for (const auto& bn : block_numbers) {
149 wire_block_numbers.push_back(bn);
150 }
151 return wire::WsdbGetBlockNumbersForLeafIndicesResponse{ .blockNumbers = std::move(wire_block_numbers) };
152}
153
154// ---------------------------------------------------------------------------
155// Leaf search operations
156// ---------------------------------------------------------------------------
157
158wire::WsdbFindLeafIndicesResponse handle_find_leaf_indices(WsdbRequest& ctx, wire::WsdbFindLeafIndices&& cmd)
159{
160 auto revision = revision_from_wire(cmd.revision);
161 auto tree_id = tree_id_from_wire(cmd.treeId);
162 auto start_index = static_cast<index_t>(cmd.startIndex);
163
165 switch (tree_id) {
169 auto typed_leaves = fr_vec_from_wire(cmd.leaves);
170 ctx.world_state.find_leaf_indices<bb::fr>(revision, tree_id, typed_leaves, indices, start_index);
171 break;
172 }
173 default:
174 throw std::runtime_error("Unsupported tree type for find_leaf_indices");
175 }
177 wire_indices.reserve(indices.size());
178 for (const auto& i : indices) {
179 wire_indices.push_back(i.has_value() ? std::optional<uint64_t>(static_cast<uint64_t>(*i)) : std::nullopt);
180 }
181 return wire::WsdbFindLeafIndicesResponse{ .indices = std::move(wire_indices) };
182}
183
184wire::WsdbFindPublicDataLeafIndicesResponse handle_find_public_data_leaf_indices(
185 WsdbRequest& ctx, wire::WsdbFindPublicDataLeafIndices&& cmd)
186{
191 indices,
192 static_cast<index_t>(cmd.startIndex));
194 wire_indices.reserve(indices.size());
195 for (const auto& i : indices) {
196 wire_indices.push_back(i.has_value() ? std::optional<uint64_t>(static_cast<uint64_t>(*i)) : std::nullopt);
197 }
198 return wire::WsdbFindPublicDataLeafIndicesResponse{ .indices = std::move(wire_indices) };
199}
200
201wire::WsdbFindNullifierLeafIndicesResponse handle_find_nullifier_leaf_indices(WsdbRequest& ctx,
202 wire::WsdbFindNullifierLeafIndices&& cmd)
203{
208 indices,
209 static_cast<index_t>(cmd.startIndex));
211 wire_indices.reserve(indices.size());
212 for (const auto& i : indices) {
213 wire_indices.push_back(i.has_value() ? std::optional<uint64_t>(static_cast<uint64_t>(*i)) : std::nullopt);
214 }
215 return wire::WsdbFindNullifierLeafIndicesResponse{ .indices = std::move(wire_indices) };
216}
217
218wire::WsdbFindLowLeafResponse handle_find_low_leaf(WsdbRequest& ctx, wire::WsdbFindLowLeaf&& cmd)
219{
220 auto low_leaf_info = ctx.world_state.find_low_leaf_index(
221 revision_from_wire(cmd.revision), tree_id_from_wire(cmd.treeId), fr_from_wire(cmd.key));
222 return wire::WsdbFindLowLeafResponse{
223 .alreadyPresent = low_leaf_info.is_already_present,
224 .index = static_cast<uint64_t>(low_leaf_info.index),
225 };
226}
227
228wire::WsdbFindSiblingPathsResponse handle_find_sibling_paths(WsdbRequest& ctx, wire::WsdbFindSiblingPaths&& cmd)
229{
230 auto revision = revision_from_wire(cmd.revision);
231 auto tree_id = tree_id_from_wire(cmd.treeId);
233 switch (tree_id) {
237 auto typed_leaves = fr_vec_from_wire(cmd.leaves);
238 ctx.world_state.find_sibling_paths<bb::fr>(revision, tree_id, typed_leaves, paths);
239 break;
240 }
241 default:
242 throw std::runtime_error("Unsupported tree type for find_sibling_paths");
243 }
245 wire_paths.reserve(paths.size());
246 for (const auto& p : paths) {
247 if (!p.has_value()) {
248 wire_paths.push_back(std::nullopt);
249 continue;
250 }
251 wire_paths.push_back(wire::SiblingPathAndIndex{
252 .index = static_cast<uint64_t>(p->index),
253 .path = fr_vec_to_wire(p->path),
254 });
255 }
256 return wire::WsdbFindSiblingPathsResponse{ .paths = std::move(wire_paths) };
257}
258
259wire::WsdbFindPublicDataSiblingPathsResponse handle_find_public_data_sibling_paths(
260 WsdbRequest& ctx, wire::WsdbFindPublicDataSiblingPaths&& cmd)
261{
266 paths);
268 wire_paths.reserve(paths.size());
269 for (const auto& p : paths) {
270 wire_paths.push_back(p.has_value()
271 ? std::optional<wire::SiblingPathAndIndex>(wire::SiblingPathAndIndex{
272 .index = static_cast<uint64_t>(p->index), .path = fr_vec_to_wire(p->path) })
273 : std::nullopt);
274 }
275 return wire::WsdbFindPublicDataSiblingPathsResponse{ .paths = std::move(wire_paths) };
276}
277
278wire::WsdbFindNullifierSiblingPathsResponse handle_find_nullifier_sibling_paths(
279 WsdbRequest& ctx, wire::WsdbFindNullifierSiblingPaths&& cmd)
280{
285 paths);
287 wire_paths.reserve(paths.size());
288 for (const auto& p : paths) {
289 wire_paths.push_back(p.has_value()
290 ? std::optional<wire::SiblingPathAndIndex>(wire::SiblingPathAndIndex{
291 .index = static_cast<uint64_t>(p->index), .path = fr_vec_to_wire(p->path) })
292 : std::nullopt);
293 }
294 return wire::WsdbFindNullifierSiblingPathsResponse{ .paths = std::move(wire_paths) };
295}
296
297// ---------------------------------------------------------------------------
298// Tree mutation operations
299// ---------------------------------------------------------------------------
300
301wire::WsdbAppendLeavesResponse handle_append_leaves(WsdbRequest& ctx, wire::WsdbAppendLeaves&& cmd)
302{
303 auto tree_id = tree_id_from_wire(cmd.treeId);
304 switch (tree_id) {
308 ctx.world_state.append_leaves<bb::fr>(tree_id, fr_vec_from_wire(cmd.leaves), cmd.forkId);
309 break;
310 }
311 default:
312 throw std::runtime_error("Unsupported tree type for append_leaves");
313 }
314 return wire::WsdbAppendLeavesResponse{};
315}
316
317wire::WsdbAppendPublicDataLeavesResponse handle_append_public_data_leaves(WsdbRequest& ctx,
318 wire::WsdbAppendPublicDataLeaves&& cmd)
319{
322 return wire::WsdbAppendPublicDataLeavesResponse{};
323}
324
325wire::WsdbAppendNullifierLeavesResponse handle_append_nullifier_leaves(WsdbRequest& ctx,
326 wire::WsdbAppendNullifierLeaves&& cmd)
327{
330 return wire::WsdbAppendNullifierLeavesResponse{};
331}
332
333wire::WsdbBatchInsertPublicDataResponse handle_batch_insert_public_data(WsdbRequest& ctx,
334 wire::WsdbBatchInsertPublicData&& cmd)
335{
336 auto result =
339 cmd.subtreeDepth,
340 cmd.forkId);
341 return wire::WsdbBatchInsertPublicDataResponse{ .result = batch_public_data_to_wire(result) };
342}
343
344wire::WsdbBatchInsertNullifierResponse handle_batch_insert_nullifier(WsdbRequest& ctx,
345 wire::WsdbBatchInsertNullifier&& cmd)
346{
347 auto result =
350 cmd.subtreeDepth,
351 cmd.forkId);
352 return wire::WsdbBatchInsertNullifierResponse{ .result = batch_nullifier_to_wire(result) };
353}
354
355wire::WsdbSequentialInsertPublicDataResponse handle_sequential_insert_public_data(
356 WsdbRequest& ctx, wire::WsdbSequentialInsertPublicData&& cmd)
357{
360 return wire::WsdbSequentialInsertPublicDataResponse{ .result = sequential_public_data_to_wire(result) };
361}
362
363wire::WsdbSequentialInsertNullifierResponse handle_sequential_insert_nullifier(
364 WsdbRequest& ctx, wire::WsdbSequentialInsertNullifier&& cmd)
365{
368 return wire::WsdbSequentialInsertNullifierResponse{ .result = sequential_nullifier_to_wire(result) };
369}
370
371wire::WsdbUpdateArchiveResponse handle_update_archive(WsdbRequest& ctx, wire::WsdbUpdateArchive&& cmd)
372{
374 state_reference_from_wire(cmd.blockStateRef), block_header_hash_from_wire(cmd.blockHeaderHash), cmd.forkId);
375 return wire::WsdbUpdateArchiveResponse{};
376}
377
378// ---------------------------------------------------------------------------
379// Transaction operations
380// ---------------------------------------------------------------------------
381
382wire::WsdbCommitResponse handle_commit(WsdbRequest& ctx, wire::WsdbCommit&&)
383{
385 ctx.world_state.commit(status);
386 return wire::WsdbCommitResponse{
387 .status = world_state_status_full_to_wire(status),
388 };
389}
390
391wire::WsdbRollbackResponse handle_rollback(WsdbRequest& ctx, wire::WsdbRollback&&)
392{
393 ctx.world_state.rollback();
394 return wire::WsdbRollbackResponse{};
395}
396
397// ---------------------------------------------------------------------------
398// Block synchronization
399// ---------------------------------------------------------------------------
400
401wire::WsdbSyncBlockResponse handle_sync_block(WsdbRequest& ctx, wire::WsdbSyncBlock&& cmd)
402{
403 auto block_state_ref = state_reference_from_wire(cmd.blockStateRef);
404 auto block_header_hash = block_header_hash_from_wire(cmd.blockHeaderHash);
405 auto padded_note_hashes = fr_vec_from_wire(cmd.paddedNoteHashes);
406 auto padded_l1_to_l2_messages = fr_vec_from_wire(cmd.paddedL1ToL2Messages);
407
408 std::vector<NullifierLeafValue> padded_nullifiers;
409 padded_nullifiers.reserve(cmd.paddedNullifiers.size());
410 for (const auto& w : cmd.paddedNullifiers) {
411 padded_nullifiers.emplace_back(nullifier_from_wire(w.nullifier));
412 }
413
414 std::vector<PublicDataLeafValue> public_data_writes;
415 public_data_writes.reserve(cmd.publicDataWrites.size());
416 for (const auto& w : cmd.publicDataWrites) {
417 public_data_writes.emplace_back(public_data_slot_from_wire(w.slot), public_data_value_from_wire(w.value));
418 }
419
420 WorldStateStatusFull status = ctx.world_state.sync_block(block_state_ref,
421 block_header_hash,
422 padded_note_hashes,
423 padded_l1_to_l2_messages,
424 padded_nullifiers,
425 public_data_writes);
426 return wire::WsdbSyncBlockResponse{
427 .status = world_state_status_full_to_wire(status),
428 };
429}
430
431// ---------------------------------------------------------------------------
432// Fork management
433// ---------------------------------------------------------------------------
434
435wire::WsdbCreateForkResponse handle_create_fork(WsdbRequest& ctx, wire::WsdbCreateFork&& cmd)
436{
437 std::optional<block_number_t> block = cmd.latest ? std::nullopt : std::optional<block_number_t>(cmd.blockNumber);
438 uint64_t id = ctx.world_state.create_fork(block);
439 return wire::WsdbCreateForkResponse{ .forkId = id };
440}
441
442wire::WsdbDeleteForkResponse handle_delete_fork(WsdbRequest& ctx, wire::WsdbDeleteFork&& cmd)
443{
444 ctx.world_state.delete_fork(cmd.forkId);
445 return wire::WsdbDeleteForkResponse{};
446}
447
448// ---------------------------------------------------------------------------
449// Block management
450// ---------------------------------------------------------------------------
451
452wire::WsdbFinalizeBlocksResponse handle_finalize_blocks(WsdbRequest& ctx, wire::WsdbFinalizeBlocks&& cmd)
453{
454 WorldStateStatusSummary status = ctx.world_state.set_finalized_blocks(cmd.toBlockNumber);
455 return wire::WsdbFinalizeBlocksResponse{
456 .status = world_state_status_summary_to_wire(status),
457 };
458}
459
460wire::WsdbUnwindBlocksResponse handle_unwind_blocks(WsdbRequest& ctx, wire::WsdbUnwindBlocks&& cmd)
461{
462 WorldStateStatusFull status = ctx.world_state.unwind_blocks(cmd.toBlockNumber);
463 return wire::WsdbUnwindBlocksResponse{
464 .status = world_state_status_full_to_wire(status),
465 };
466}
467
468wire::WsdbRemoveHistoricalBlocksResponse handle_remove_historical_blocks(WsdbRequest& ctx,
469 wire::WsdbRemoveHistoricalBlocks&& cmd)
470{
471 WorldStateStatusFull status = ctx.world_state.remove_historical_blocks(cmd.toBlockNumber);
472 return wire::WsdbRemoveHistoricalBlocksResponse{
473 .status = world_state_status_full_to_wire(status),
474 };
475}
476
477// ---------------------------------------------------------------------------
478// Status
479// ---------------------------------------------------------------------------
480
481wire::WsdbGetStatusResponse handle_get_status(WsdbRequest& ctx, wire::WsdbGetStatus&&)
482{
485 return wire::WsdbGetStatusResponse{
486 .status = world_state_status_summary_to_wire(status),
487 };
488}
489
490// ---------------------------------------------------------------------------
491// Checkpoint operations
492// ---------------------------------------------------------------------------
493
494wire::WsdbCreateCheckpointResponse handle_create_checkpoint(WsdbRequest& ctx, wire::WsdbCreateCheckpoint&& cmd)
495{
496 ctx.world_state.checkpoint(cmd.forkId);
497 return wire::WsdbCreateCheckpointResponse{};
498}
499
500wire::WsdbCommitCheckpointResponse handle_commit_checkpoint(WsdbRequest& ctx, wire::WsdbCommitCheckpoint&& cmd)
501{
502 ctx.world_state.commit_checkpoint(cmd.forkId);
503 return wire::WsdbCommitCheckpointResponse{};
504}
505
506wire::WsdbRevertCheckpointResponse handle_revert_checkpoint(WsdbRequest& ctx, wire::WsdbRevertCheckpoint&& cmd)
507{
508 ctx.world_state.revert_checkpoint(cmd.forkId);
509 return wire::WsdbRevertCheckpointResponse{};
510}
511
512wire::WsdbCommitAllCheckpointsResponse handle_commit_all_checkpoints(WsdbRequest& ctx,
513 wire::WsdbCommitAllCheckpoints&& cmd)
514{
515 ctx.world_state.commit_all_checkpoints_to(cmd.forkId, 0);
516 return wire::WsdbCommitAllCheckpointsResponse{};
517}
518
519wire::WsdbRevertAllCheckpointsResponse handle_revert_all_checkpoints(WsdbRequest& ctx,
520 wire::WsdbRevertAllCheckpoints&& cmd)
521{
522 ctx.world_state.revert_all_checkpoints_to(cmd.forkId, 0);
523 return wire::WsdbRevertAllCheckpointsResponse{};
524}
525
526// ---------------------------------------------------------------------------
527// Database operations
528// ---------------------------------------------------------------------------
529
530wire::WsdbCopyStoresResponse handle_copy_stores(WsdbRequest& ctx, wire::WsdbCopyStores&& cmd)
531{
532 ctx.world_state.copy_stores(cmd.dstPath, cmd.compact.value_or(false));
533 return wire::WsdbCopyStoresResponse{};
534}
535
536} // namespace bb::wsdb
WorldStateStatusFull remove_historical_blocks(const block_number_t &toBlockNumber)
BatchInsertionResult< T > batch_insert_indexed_leaves(MerkleTreeId tree_id, const std::vector< T > &leaves, uint32_t subtree_depth, Fork::Id fork_id=CANONICAL_FORK_ID)
Batch inserts a set of leaves into an indexed Merkle Tree.
void append_leaves(MerkleTreeId tree_id, const std::vector< T > &leaves, Fork::Id fork_id=CANONICAL_FORK_ID)
Appends a set of leaves to an existing Merkle Tree.
StateReference get_initial_state_reference() const
Gets the initial state reference for all the trees in the world state.
void find_sibling_paths(const WorldStateRevision &revision, MerkleTreeId tree_id, const std::vector< T > &leaves, std::vector< std::optional< SiblingPathAndIndex > > &paths) const
Finds the sibling paths of leaves in a tree.
std::optional< crypto::merkle_tree::IndexedLeaf< T > > get_indexed_leaf(const WorldStateRevision &revision, MerkleTreeId tree_id, index_t leaf_index) const
Get the leaf preimage object.
uint32_t checkpoint(const uint64_t &forkId)
void revert_checkpoint(const uint64_t &forkId)
crypto::merkle_tree::TreeMetaResponse get_tree_info(const WorldStateRevision &revision, MerkleTreeId tree_id) const
Get tree metadata for a particular tree.
void commit_all_checkpoints_to(const uint64_t &forkId, uint32_t depth)
std::pair< bool, std::string > commit(WorldStateStatusFull &status)
Commits the current state of the world state.
SequentialInsertionResult< T > insert_indexed_leaves(MerkleTreeId tree_id, const std::vector< T > &leaves, Fork::Id fork_id=CANONICAL_FORK_ID)
Inserts a set of leaves sequentially into an indexed Merkle Tree.
void get_block_numbers_for_leaf_indices(const WorldStateRevision &revision, MerkleTreeId tree_id, const std::vector< index_t > &leafIndices, std::vector< std::optional< block_number_t > > &blockNumbers) const
StateReference get_state_reference(const WorldStateRevision &revision) const
Gets the state reference for all the trees in the world state.
WorldStateStatusFull unwind_blocks(const block_number_t &toBlockNumber)
void commit_checkpoint(const uint64_t &forkId)
void get_status_summary(WorldStateStatusSummary &status) const
void rollback()
Rolls back any uncommitted changes made to the world state.
WorldStateStatusFull sync_block(const StateReference &block_state_ref, const bb::fr &block_header_hash, const std::vector< bb::fr > &notes, const std::vector< bb::fr > &l1_to_l2_messages, const std::vector< crypto::merkle_tree::NullifierLeafValue > &nullifiers, const std::vector< crypto::merkle_tree::PublicDataLeafValue > &public_writes)
WorldStateStatusSummary set_finalized_blocks(const block_number_t &toBlockNumber)
void delete_fork(const uint64_t &forkId)
uint64_t create_fork(const std::optional< block_number_t > &blockNumber)
crypto::merkle_tree::fr_sibling_path get_sibling_path(const WorldStateRevision &revision, MerkleTreeId tree_id, index_t leaf_index) const
Get the sibling path object for a leaf in a tree.
void find_leaf_indices(const WorldStateRevision &revision, MerkleTreeId tree_id, const std::vector< T > &leaves, std::vector< std::optional< index_t > > &indices, index_t start_index=0) const
Finds the index of a leaf in a tree.
std::optional< T > get_leaf(const WorldStateRevision &revision, MerkleTreeId tree_id, index_t leaf_index) const
Gets the value of a leaf in a tree.
void revert_all_checkpoints_to(const uint64_t &forkId, uint32_t depth)
crypto::merkle_tree::GetLowIndexedLeafResponse find_low_leaf_index(const WorldStateRevision &revision, MerkleTreeId tree_id, const bb::fr &leaf_key) const
Finds the leaf that would have its nextIdx/nextValue fields modified if the target leaf were to be in...
void copy_stores(const std::string &dstPath, bool compact) const
Copies all underlying LMDB stores to the target directory while acquiring a write lock.
void update_archive(const StateReference &block_state_ref, const bb::fr &block_header_hash, Fork::Id fork_id=CANONICAL_FORK_ID)
Updates the archive tree with a new block.
#define info(...)
Definition log.hpp:93
std::vector< fr > fr_sibling_path
Definition hash_path.hpp:14
@ L1_TO_L2_MESSAGE_TREE
Definition types.hpp:23
world_state::StateReference state_reference_from_wire(const std::vector< wire::TreeStateReference > &w)
wire::WsdbFindNullifierLeafIndicesResponse handle_find_nullifier_leaf_indices(WsdbRequest &ctx, wire::WsdbFindNullifierLeafIndices &&cmd)
wire::WsdbAppendNullifierLeavesResponse handle_append_nullifier_leaves(WsdbRequest &ctx, wire::WsdbAppendNullifierLeaves &&cmd)
wire::WsdbGetPublicDataLeafPreimageResponse handle_get_public_data_leaf_preimage(WsdbRequest &ctx, wire::WsdbGetPublicDataLeafPreimage &&cmd)
std::vector< crypto::merkle_tree::PublicDataLeafValue > public_data_leaf_vec_from_wire(const std::vector< wire::PublicDataLeafValue > &w)
wire::WsdbGetSiblingPathResponse handle_get_sibling_path(WsdbRequest &ctx, wire::WsdbGetSiblingPath &&cmd)
wire::WsdbUpdateArchiveResponse handle_update_archive(WsdbRequest &ctx, wire::WsdbUpdateArchive &&cmd)
std::vector< Fr > fr_vec_to_wire(const std::vector< bb::fr > &d)
wire::SequentialInsertionResultNullifier sequential_nullifier_to_wire(const world_state::SequentialInsertionResult< crypto::merkle_tree::NullifierLeafValue > &d)
wire::BatchInsertionResultPublicData batch_public_data_to_wire(const world_state::BatchInsertionResult< crypto::merkle_tree::PublicDataLeafValue > &d)
wire::WsdbFindPublicDataSiblingPathsResponse handle_find_public_data_sibling_paths(WsdbRequest &ctx, wire::WsdbFindPublicDataSiblingPaths &&cmd)
std::vector< crypto::merkle_tree::NullifierLeafValue > nullifier_leaf_vec_from_wire(const std::vector< wire::NullifierLeafValue > &w)
wire::NullifierLeafValue nullifier_leaf_to_wire(const crypto::merkle_tree::NullifierLeafValue &d)
wire::WsdbGetPublicDataLeafValueResponse handle_get_public_data_leaf_value(WsdbRequest &ctx, wire::WsdbGetPublicDataLeafValue &&cmd)
wire::IndexedNullifierLeafValue indexed_nullifier_leaf_to_wire(const crypto::merkle_tree::IndexedLeaf< crypto::merkle_tree::NullifierLeafValue > &d)
wire::WsdbFindPublicDataLeafIndicesResponse handle_find_public_data_leaf_indices(WsdbRequest &ctx, wire::WsdbFindPublicDataLeafIndices &&cmd)
wire::WsdbRollbackResponse handle_rollback(WsdbRequest &ctx, wire::WsdbRollback &&)
wire::WsdbFindSiblingPathsResponse handle_find_sibling_paths(WsdbRequest &ctx, wire::WsdbFindSiblingPaths &&cmd)
wire::WsdbGetStatusResponse handle_get_status(WsdbRequest &ctx, wire::WsdbGetStatus &&)
wire::WsdbSequentialInsertPublicDataResponse handle_sequential_insert_public_data(WsdbRequest &ctx, wire::WsdbSequentialInsertPublicData &&cmd)
wire::WsdbFindNullifierSiblingPathsResponse handle_find_nullifier_sibling_paths(WsdbRequest &ctx, wire::WsdbFindNullifierSiblingPaths &&cmd)
wire::WsdbGetTreeInfoResponse handle_get_tree_info(WsdbRequest &ctx, wire::WsdbGetTreeInfo &&cmd)
world_state::WorldStateRevision revision_from_wire(const wire::WorldStateRevision &w)
wire::WsdbGetStateReferenceResponse handle_get_state_reference(WsdbRequest &ctx, wire::WsdbGetStateReference &&cmd)
bb::fr public_data_slot_from_wire(const PublicDataSlot &w)
world_state::MerkleTreeId tree_id_from_wire(MerkleTreeId w)
wire::WsdbGetNullifierLeafPreimageResponse handle_get_nullifier_leaf_preimage(WsdbRequest &ctx, wire::WsdbGetNullifierLeafPreimage &&cmd)
wire::SequentialInsertionResultPublicData sequential_public_data_to_wire(const world_state::SequentialInsertionResult< crypto::merkle_tree::PublicDataLeafValue > &d)
wire::WsdbBatchInsertNullifierResponse handle_batch_insert_nullifier(WsdbRequest &ctx, wire::WsdbBatchInsertNullifier &&cmd)
wire::WsdbUnwindBlocksResponse handle_unwind_blocks(WsdbRequest &ctx, wire::WsdbUnwindBlocks &&cmd)
wire::IndexedPublicDataLeafValue indexed_public_data_leaf_to_wire(const crypto::merkle_tree::IndexedLeaf< crypto::merkle_tree::PublicDataLeafValue > &d)
wire::WsdbAppendLeavesResponse handle_append_leaves(WsdbRequest &ctx, wire::WsdbAppendLeaves &&cmd)
wire::WsdbGetInitialStateReferenceResponse handle_get_initial_state_reference(WsdbRequest &ctx, wire::WsdbGetInitialStateReference &&)
wire::WsdbRevertAllCheckpointsResponse handle_revert_all_checkpoints(WsdbRequest &ctx, wire::WsdbRevertAllCheckpoints &&cmd)
wire::BatchInsertionResultNullifier batch_nullifier_to_wire(const world_state::BatchInsertionResult< crypto::merkle_tree::NullifierLeafValue > &d)
wire::WsdbBatchInsertPublicDataResponse handle_batch_insert_public_data(WsdbRequest &ctx, wire::WsdbBatchInsertPublicData &&cmd)
wire::WsdbSyncBlockResponse handle_sync_block(WsdbRequest &ctx, wire::WsdbSyncBlock &&cmd)
wire::WsdbFindLeafIndicesResponse handle_find_leaf_indices(WsdbRequest &ctx, wire::WsdbFindLeafIndices &&cmd)
wire::WsdbRevertCheckpointResponse handle_revert_checkpoint(WsdbRequest &ctx, wire::WsdbRevertCheckpoint &&cmd)
wire::WorldStateStatusFull world_state_status_full_to_wire(const bb::world_state::WorldStateStatusFull &d)
wire::WsdbAppendPublicDataLeavesResponse handle_append_public_data_leaves(WsdbRequest &ctx, wire::WsdbAppendPublicDataLeaves &&cmd)
bb::fr public_data_value_from_wire(const PublicDataValue &w)
wire::PublicDataLeafValue public_data_leaf_to_wire(const crypto::merkle_tree::PublicDataLeafValue &d)
bb::fr nullifier_from_wire(const Nullifier &w)
wire::WsdbRemoveHistoricalBlocksResponse handle_remove_historical_blocks(WsdbRequest &ctx, wire::WsdbRemoveHistoricalBlocks &&cmd)
wire::WsdbCommitResponse handle_commit(WsdbRequest &ctx, wire::WsdbCommit &&)
wire::WsdbCommitAllCheckpointsResponse handle_commit_all_checkpoints(WsdbRequest &ctx, wire::WsdbCommitAllCheckpoints &&cmd)
bb::fr block_header_hash_from_wire(const BlockHeaderHash &w)
wire::WsdbGetBlockNumbersForLeafIndicesResponse handle_get_block_numbers_for_leaf_indices(WsdbRequest &ctx, wire::WsdbGetBlockNumbersForLeafIndices &&cmd)
wire::WsdbFindLowLeafResponse handle_find_low_leaf(WsdbRequest &ctx, wire::WsdbFindLowLeaf &&cmd)
wire::WsdbSequentialInsertNullifierResponse handle_sequential_insert_nullifier(WsdbRequest &ctx, wire::WsdbSequentialInsertNullifier &&cmd)
wire::WsdbDeleteForkResponse handle_delete_fork(WsdbRequest &ctx, wire::WsdbDeleteFork &&cmd)
wire::WsdbGetLeafValueResponse handle_get_leaf_value(WsdbRequest &ctx, wire::WsdbGetLeafValue &&cmd)
wire::WsdbGetNullifierLeafValueResponse handle_get_nullifier_leaf_value(WsdbRequest &ctx, wire::WsdbGetNullifierLeafValue &&cmd)
wire::WorldStateStatusSummary world_state_status_summary_to_wire(const bb::world_state::WorldStateStatusSummary &d)
wire::WsdbCommitCheckpointResponse handle_commit_checkpoint(WsdbRequest &ctx, wire::WsdbCommitCheckpoint &&cmd)
wire::WsdbFinalizeBlocksResponse handle_finalize_blocks(WsdbRequest &ctx, wire::WsdbFinalizeBlocks &&cmd)
wire::WsdbCreateForkResponse handle_create_fork(WsdbRequest &ctx, wire::WsdbCreateFork &&cmd)
std::vector< wire::TreeStateReference > state_reference_to_wire(const world_state::StateReference &d)
wire::WsdbCreateCheckpointResponse handle_create_checkpoint(WsdbRequest &ctx, wire::WsdbCreateCheckpoint &&cmd)
wire::WsdbCopyStoresResponse handle_copy_stores(WsdbRequest &ctx, wire::WsdbCopyStores &&cmd)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
world_state::WorldState & world_state
Non-template handler declarations for the wsdb service.
Wire <-> domain conversion helpers for the aztec-wsdb service.