Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck Class Reference

#include <written_public_data_slots_tree_check.hpp>

Inheritance diagram for bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck:
bb::avm2::simulation::WrittenPublicDataSlotsTreeCheckInterface bb::avm2::simulation::WrittenPublicDataSlotsInterface

Public Member Functions

 WrittenPublicDataSlotsTreeCheck (IndexedTreeCheckInterface &indexed_tree_check, WrittenPublicDataSlotsTree initial_state)
 
bool contains (const AztecAddress &contract_address, const FF &slot) override
 Checks whether a public data slot exists in the written public data slots tree.
 
void insert (const AztecAddress &contract_address, const FF &slot) override
 Inserts a public data slot into the written public data slots tree.
 
AppendOnlyTreeSnapshot get_snapshot () const override
 Returns the current tree snapshot from the top of the checkpoint stack.
 
uint32_t size () const override
 Returns the number of written public data slots in the tree.
 
void create_checkpoint () override
 Creates a checkpoint by pushing a copy of the current tree state onto the stack.
 
void commit_checkpoint () override
 Commits the current checkpoint by replacing the previous tree state with the current one.
 
void revert_checkpoint () override
 Reverts the current checkpoint by discarding the top of the tree state stack.
 
- Public Member Functions inherited from bb::avm2::simulation::WrittenPublicDataSlotsInterface
virtual ~WrittenPublicDataSlotsInterface ()=default
 

Private Attributes

IndexedTreeCheckInterfaceindexed_tree_check
 
std::stack< WrittenPublicDataSlotsTreewritten_public_data_slots_tree_stack = {}
 

Detailed Description

Definition at line 15 of file written_public_data_slots_tree_check.hpp.

Constructor & Destructor Documentation

◆ WrittenPublicDataSlotsTreeCheck()

bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::WrittenPublicDataSlotsTreeCheck ( IndexedTreeCheckInterface indexed_tree_check,
WrittenPublicDataSlotsTree  initial_state 
)
inline

Definition at line 17 of file written_public_data_slots_tree_check.hpp.

Member Function Documentation

◆ commit_checkpoint()

void bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::commit_checkpoint ( )
overridevirtual

Commits the current checkpoint by replacing the previous tree state with the current one.

Pops the top of the stack and overwrites the new top, finalizing all writes made since the last create_checkpoint call.

Implements bb::avm2::simulation::WrittenPublicDataSlotsInterface.

Definition at line 132 of file written_public_data_slots_tree_check.cpp.

◆ contains()

bool bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::contains ( const AztecAddress contract_address,
const FF slot 
)
overridevirtual

Checks whether a public data slot exists in the written public data slots tree.

Computes the leaf slot from the contract address and slot, queries the in memory tree for the low leaf, converts it to generic IndexedTreeLeafData, and delegates the membership/non-membership proof to the indexed tree check gadget. Siloing is applied using the public leaf slot domain separator.

Parameters
contract_addressThe address of the contract that owns the slot.
slotThe public data slot to look up.
Returns
True if the slot exists in the tree, false otherwise.

Implements bb::avm2::simulation::WrittenPublicDataSlotsInterface.

Definition at line 20 of file written_public_data_slots_tree_check.cpp.

◆ create_checkpoint()

void bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::create_checkpoint ( )
overridevirtual

Creates a checkpoint by pushing a copy of the current tree state onto the stack.

Subsequent writes modify only the top of the stack, allowing the checkpoint to be reverted (discarding changes) or committed (propagating changes down).

Implements bb::avm2::simulation::WrittenPublicDataSlotsInterface.

Definition at line 120 of file written_public_data_slots_tree_check.cpp.

◆ get_snapshot()

AppendOnlyTreeSnapshot bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::get_snapshot ( ) const
overridevirtual

Returns the current tree snapshot from the top of the checkpoint stack.

Returns
The current tree snapshot.

Implements bb::avm2::simulation::WrittenPublicDataSlotsTreeCheckInterface.

Definition at line 97 of file written_public_data_slots_tree_check.cpp.

◆ insert()

void bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::insert ( const AztecAddress contract_address,
const FF slot 
)
overridevirtual

Inserts a public data slot into the written public data slots tree.

Computes the leaf slot, performs the insertion on the in memory tree, then delegates the constrained write (or duplicate detection) to the indexed tree check gadget. Siloing is applied using the public leaf slot domain separator.

Parameters
contract_addressThe address of the contract that owns the slot.
slotThe public data slot to insert.
Exceptions
std::runtime_errorIf the indexed tree check write returns a snapshot that does not match the in memory tree.

Implements bb::avm2::simulation::WrittenPublicDataSlotsInterface.

Definition at line 58 of file written_public_data_slots_tree_check.cpp.

◆ revert_checkpoint()

void bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::revert_checkpoint ( )
overridevirtual

Reverts the current checkpoint by discarding the top of the tree state stack.

All writes made since the last create_checkpoint call are discarded, restoring the tree to its previous state.

Implements bb::avm2::simulation::WrittenPublicDataSlotsInterface.

Definition at line 146 of file written_public_data_slots_tree_check.cpp.

◆ size()

uint32_t bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::size ( ) const
overridevirtual

Returns the number of written public data slots in the tree.

Returns
The number of slots, excluding the prefill leaf at index 0.
Note
Subtracts 1 to account for the prefill leaf at index 0.

Implements bb::avm2::simulation::WrittenPublicDataSlotsInterface.

Definition at line 107 of file written_public_data_slots_tree_check.cpp.

Member Data Documentation

◆ indexed_tree_check

IndexedTreeCheckInterface& bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::indexed_tree_check
private

Definition at line 37 of file written_public_data_slots_tree_check.hpp.

◆ written_public_data_slots_tree_stack

std::stack<WrittenPublicDataSlotsTree> bb::avm2::simulation::WrittenPublicDataSlotsTreeCheck::written_public_data_slots_tree_stack = {}
private

Definition at line 39 of file written_public_data_slots_tree_check.hpp.


The documentation for this class was generated from the following files: