Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
context_helper.cpp
Go to the documentation of this file.
1#include "context_helper.hpp"
2
15
17
18using namespace bb::avm2::simulation;
19
20GadgetFuzzerContextHelper::GadgetFuzzerContextHelper(AztecAddress contract_address, bool is_static, uint32_t start_clk)
21 : execution_id_manager(start_clk)
24 , greater_than(field_gt, range_check, greater_than_emitter)
25 , memory_provider(range_check, execution_id_manager, memory_emitter)
28 , indexed_tree_check(poseidon2, merkle_check, field_gt, indexed_tree_check_emitter)
31
32{
35 hints.tx = create_default_tx(contract_address, contract_address, {}, FF(0), is_static, GAS_LIMIT);
36
39
42
47 InternalCallStackManagerProvider internal_call_stack_manager_provider(internal_call_stack_emitter);
57
60 mem_provider,
61 calldata_hashing_provider,
62 internal_call_stack_manager_provider,
68}
69
70// A lighter version of ContextProvider::make_enqueued_context
72 AztecAddress msg_sender,
73 bool is_static,
74 FF transaction_fee,
76 Gas gas_limit,
77 Gas gas_used,
78 TransactionPhase phase)
79{
81 // Note: not incremented between contexts
82 uint32_t context_id = context_provider->get_next_context_id();
85 address,
86 msg_sender,
87 transaction_fee,
88 is_static,
89 gas_limit,
90 gas_used,
93 memory_provider.make_memory(static_cast<uint16_t>(context_id)),
99 phase,
100 calldata);
101}
102
103// A lighter version of ContextProvider::make_nested_context
105 AztecAddress address, AztecAddress msg_sender, ContextInterface& parent_context, bool is_static, Gas gas_limit)
106{
107
108 HintedRawMerkleDB raw_merkle_db(hints);
111 // TODO(MW): Using below causes segfault (probably stack too deep) with external call gadget fuzzer
112 // auto merkle_db = make_empty_merkle_db();
113 // Note: not incremented between contexts
114 uint32_t context_id = context_provider->get_next_context_id();
117 parent_context.get_address(),
118 msg_sender,
119 parent_context.get_transaction_fee(),
120 is_static,
121 gas_limit,
122 parent_context.get_globals(),
124 memory_provider.make_memory(static_cast<uint16_t>(context_id)),
130 parent_context.get_phase(),
131 parent_context,
132 0,
133 0);
134}
135
144} // namespace bb::avm2::fuzzing
GreaterThan greater_than
const Gas GAS_LIMIT
Definition constants.hpp:40
EventEmitter< Poseidon2PermutationMemoryEvent > perm_mem_event_emitter
EventEmitter< Poseidon2PermutationEvent > perm_event_emitter
EventEmitter< Poseidon2HashEvent > hash_event_emitter
FieldGreaterThan field_gt
EventEmitter< simulation::MerkleCheckEvent > merkle_check_emitter
RetrievedBytecodesTreeCheck retrieved_bytecodes_tree_check
EventEmitter< simulation::FieldGreaterThanEvent > field_gt_emitter
EventEmitter< simulation::RangeCheckEvent > range_check_emitter
BytecodeHasher bytecode_hasher
StrictMock< MockHighLevelMerkleDB > merkle_db
StrictMock< MockContractDB > contract_db
StrictMock< MockContractInstanceManager > contract_instance_manager
EventEmitter< BytecodeRetrievalEvent > bytecode_retrieval_emitter
EventEmitter< InternalCallStackEvent > internal_call_stack_emitter
RetrievedBytecodesTreeCheck retrieved_bytecodes_tree_check
EventEmitter< CalldataEvent > calldata_event_emitter
GadgetFuzzerContextHelper(AztecAddress contract_address=AztecAddress(0), bool is_static=false, uint32_t start_clk=0)
std::unique_ptr< simulation::ContextInterface > make_nested_fuzzing_context(AztecAddress address, AztecAddress msg_sender, ContextInterface &parent_context, bool is_static=false, Gas gas_limit=GAS_LIMIT)
std::unique_ptr< TxBytecodeManager > tx_bytecode_manager
EventEmitter< BytecodeDecompositionEvent > bytecode_decomposition_emitter
EventEmitter< ContractInstanceRetrievalEvent > contract_instance_retrieval_emitter
EventEmitter< BytecodeHashingEvent > bytecode_hashing_emitter
std::unique_ptr< simulation::ContextInterface > make_enqueued_fuzzing_context(AztecAddress address=AztecAddress(0), AztecAddress msg_sender=AztecAddress(0), bool is_static=false, FF transaction_fee=FF(0), std::span< const FF > calldata={}, Gas gas_limit=GAS_LIMIT, Gas gas_used=GAS_USED_BY_PRIVATE, TransactionPhase phase=TransactionPhase::APP_LOGIC)
WrittenPublicDataSlotsTreeCheck written_public_data_slots_tree_check
EventEmitter< UpdateCheckEvent > update_check_emitter
std::unique_ptr< simulation::ContextProvider > context_provider
DeduplicatingEventEmitter< InstructionFetchingEvent > instruction_fetching_emitter
virtual const FF & get_transaction_fee() const =0
virtual const GlobalVariables & get_globals() const =0
virtual const AztecAddress & get_address() const =0
virtual TransactionPhase get_phase() const =0
std::unique_ptr< MemoryInterface > make_memory(uint16_t space_id) override
Definition memory.hpp:57
ExecutionIdManager execution_id_manager
HintedRawMerkleDB base_merkle_db
AVM range check gadget for witness generation.
RetrievedBytecodesTree build_retrieved_bytecodes_tree()
WrittenPublicDataSlotsTree build_public_data_slots_tree()
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
uint32_t context_id
Tx create_default_tx(const AztecAddress &contract_address, const AztecAddress &sender_address, const std::vector< FF > &calldata, const FF &transaction_fee, bool is_static_call, const Gas &gas_limit)
GlobalVariables create_default_globals()
Definition simulator.cpp:68
std::vector< FF > nullifiers
Definition avm_io.hpp:318
GlobalVariables global_variables
Definition avm_io.hpp:358
ProtocolContracts protocol_contracts
Definition avm_io.hpp:361
AccumulatedData non_revertible_accumulated_data
Definition avm_io.hpp:334
NiceMock< MockWrittenPublicDataSlotsTreeCheck > written_public_data_slots_tree_check