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

#include <update_check.hpp>

Inheritance diagram for bb::avm2::simulation::UpdateCheck:
bb::avm2::simulation::UpdateCheckInterface

Public Member Functions

 UpdateCheck (Poseidon2Interface &poseidon2, RangeCheckInterface &range_check, GreaterThanInterface &gt, HighLevelMerkleDBInterface &merkle_db, EventEmitterInterface< UpdateCheckEvent > &read_event_emitter, const GlobalVariables &globals)
 
void check_current_class_id (const AztecAddress &address, const ContractInstance &instance) override
 Validate that a contract's current class ID is consistent with the delayed public mutable update state.
 
- Public Member Functions inherited from bb::avm2::simulation::UpdateCheckInterface
virtual ~UpdateCheckInterface ()=default
 

Private Attributes

EventEmitterInterface< UpdateCheckEvent > & update_check_events
 
Poseidon2Interfaceposeidon2
 
RangeCheckInterfacerange_check
 
GreaterThanInterfacegt
 
HighLevelMerkleDBInterfacemerkle_db
 
const GlobalVariablesglobals
 

Detailed Description

Definition at line 14 of file update_check.hpp.

Constructor & Destructor Documentation

◆ UpdateCheck()

bb::avm2::simulation::UpdateCheck::UpdateCheck ( Poseidon2Interface poseidon2,
RangeCheckInterface range_check,
GreaterThanInterface gt,
HighLevelMerkleDBInterface merkle_db,
EventEmitterInterface< UpdateCheckEvent > &  read_event_emitter,
const GlobalVariables globals 
)
inline

Definition at line 16 of file update_check.hpp.

Member Function Documentation

◆ check_current_class_id()

void bb::avm2::simulation::UpdateCheck::check_current_class_id ( const AztecAddress address,
const ContractInstance instance 
)
overridevirtual

Validate that a contract's current class ID is consistent with the delayed public mutable update state.

Reads the delayed public mutable hash from the public data tree. If the hash is zero, the contract was never updated and current_class_id must equal original_class_id. Otherwise, reads the preimage (metadata, pre, post) in unconstrained mode, verifies it against the hash, decomposes the metadata to extract the timestamp of change, and selects the pre or post class ID based on whether the update has taken effect yet.

Emits a single UpdateCheckEvent on success with all fields populated. When the hash is zero, the preimage fields (metadata, pre_class_id, post_class_id) are all zero in the emitted event.

Parameters
addressThe contract address to check.
instanceThe contract instance containing original and current class IDs to validate.
Exceptions
std::runtime_errorIf hash is zero and current_class_id does not match original_class_id.
std::runtime_errorIf the stored hash does not match the reconstructed preimage hash (sanity check).
std::runtime_errorIf the expected class ID (derived from update state and timestamp) does not match current_class_id.

Implements bb::avm2::simulation::UpdateCheckInterface.

Definition at line 44 of file update_check.cpp.

Member Data Documentation

◆ globals

const GlobalVariables& bb::avm2::simulation::UpdateCheck::globals
private

Definition at line 38 of file update_check.hpp.

◆ gt

GreaterThanInterface& bb::avm2::simulation::UpdateCheck::gt
private

Definition at line 36 of file update_check.hpp.

◆ merkle_db

HighLevelMerkleDBInterface& bb::avm2::simulation::UpdateCheck::merkle_db
private

Definition at line 37 of file update_check.hpp.

◆ poseidon2

Poseidon2Interface& bb::avm2::simulation::UpdateCheck::poseidon2
private

Definition at line 34 of file update_check.hpp.

◆ range_check

RangeCheckInterface& bb::avm2::simulation::UpdateCheck::range_check
private

Definition at line 35 of file update_check.hpp.

◆ update_check_events

EventEmitterInterface<UpdateCheckEvent>& bb::avm2::simulation::UpdateCheck::update_check_events
private

Definition at line 33 of file update_check.hpp.


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