12using namespace avm2::simulation;
21 msgpack::pack(buf,
value);
22 return std::vector<uint8_t>(buf.data(), buf.data() + buf.size());
27 auto unpacked = msgpack::unpack(
reinterpret_cast<const char*
>(bytes.data()), bytes.size());
29 unpacked.get().convert(
value);
102 if (!resp.value.has_value()) {
103 throw std::runtime_error(
"Invalid get_leaf_value request for tree " +
107 return deserialize_from_msgpack<avm2::FF>(resp.value.value());
113 .
treeId = MerkleTreeId::PUBLIC_DATA_TREE, .revision =
revision_, .leafIndex = leaf_index });
114 if (!resp.preimage.has_value()) {
115 throw std::runtime_error(
"Invalid get_leaf_preimage_public_data_tree request for index " +
118 return deserialize_from_msgpack<IndexedLeaf<PublicDataLeafValue>>(resp.preimage.value());
124 .
treeId = MerkleTreeId::NULLIFIER_TREE, .revision =
revision_, .leafIndex = leaf_index });
125 if (!resp.preimage.has_value()) {
126 throw std::runtime_error(
"Invalid get_leaf_preimage_nullifier_tree request for index " +
129 return deserialize_from_msgpack<IndexedLeaf<NullifierLeafValue>>(resp.preimage.value());
143 return deserialize_from_msgpack<SequentialInsertionResult<PublicDataLeafValue>>(resp.result);
153 return deserialize_from_msgpack<SequentialInsertionResult<NullifierLeafValue>>(resp.result);
159 serialized_leaves.reserve(leaves.size());
160 for (
const auto& leaf : leaves) {
171 case MerkleTreeId::NULLIFIER_TREE: {
173 padding_leaves.reserve(num_leaves);
175 for (
size_t i = 0; i < num_leaves; i++) {
184 case MerkleTreeId::NOTE_HASH_TREE: {
186 padding_leaves.reserve(num_leaves);
188 for (
size_t i = 0; i < num_leaves; i++) {
196 throw std::runtime_error(
"Padding not supported for tree " +
std::to_string(
static_cast<uint64_t
>(tree_id)));
#define NULLIFIER_SUBTREE_HEIGHT
Auto-generated IPC client.
void create_checkpoint(WsdbCreateCheckpoint cmd)
WsdbGetSiblingPath::Response get_sibling_path(WsdbGetSiblingPath cmd) const
WsdbBatchInsert::Response batch_insert(WsdbBatchInsert cmd) const
void commit_checkpoint(WsdbCommitCheckpoint cmd)
WsdbGetTreeInfo::Response get_tree_info(WsdbGetTreeInfo cmd) const
WsdbSequentialInsert::Response sequential_insert(WsdbSequentialInsert cmd) const
WsdbGetLeafValue::Response get_leaf_value(WsdbGetLeafValue cmd) const
void revert_checkpoint(WsdbRevertCheckpoint cmd)
WsdbFindLowLeaf::Response find_low_leaf(WsdbFindLowLeaf cmd) const
void append_leaves(WsdbAppendLeaves cmd) const
WsdbGetLeafPreimage::Response get_leaf_preimage(WsdbGetLeafPreimage cmd) const
avm2::TreeSnapshots get_tree_roots() const override
avm2::simulation::SiblingPath get_sibling_path(avm2::simulation::MerkleTreeId tree_id, avm2::simulation::index_t leaf_index) const override
void commit_checkpoint() override
static std::vector< uint8_t > serialize_to_msgpack(const T &value)
avm2::simulation::IndexedLeaf< avm2::simulation::PublicDataLeafValue > get_leaf_preimage_public_data_tree(avm2::simulation::index_t leaf_index) const override
wsdb::WsdbIpcClient & client_
std::optional< avm2::TreeSnapshots > cached_tree_roots_
crypto::merkle_tree::GetLowIndexedLeafResponse get_low_indexed_leaf(avm2::simulation::MerkleTreeId tree_id, const avm2::FF &value) const override
static T deserialize_from_msgpack(const std::vector< uint8_t > &bytes)
void revert_checkpoint() override
std::stack< uint32_t > checkpoint_stack_
avm2::simulation::SequentialInsertionResult< avm2::simulation::PublicDataLeafValue > insert_indexed_leaves_public_data_tree(const avm2::simulation::PublicDataLeafValue &leaf_value) override
void pad_tree(avm2::simulation::MerkleTreeId tree_id, size_t num_leaves) override
avm2::simulation::IndexedLeaf< avm2::simulation::NullifierLeafValue > get_leaf_preimage_nullifier_tree(avm2::simulation::index_t leaf_index) const override
void invalidate_tree_roots_cache()
void append_leaves(avm2::simulation::MerkleTreeId tree_id, std::span< const avm2::FF > leaves) override
void create_checkpoint() override
WsdbIpcMerkleDB(wsdb::WsdbIpcClient &client, world_state::WorldStateRevision revision)
Construct from a connected WSDB IPC client and world state revision.
avm2::simulation::SequentialInsertionResult< avm2::simulation::NullifierLeafValue > insert_indexed_leaves_nullifier_tree(const avm2::simulation::NullifierLeafValue &leaf_value) override
avm2::FF get_leaf_value(avm2::simulation::MerkleTreeId tree_id, avm2::simulation::index_t leaf_index) const override
world_state::WorldStateRevision revision_
uint32_t get_checkpoint_id() const override
::bb::crypto::merkle_tree::fr_sibling_path SiblingPath
::bb::crypto::merkle_tree::index_t index_t
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
AppendOnlyTreeSnapshot l1_to_l2_message_tree
static NullifierLeafValue empty()
NamedUnion command structs for the aztec-wsdb world state database API.
LowLevelMerkleDBInterface implementation backed by WSDB IPC.