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
14
16
17using namespace bb::avm2::simulation;
18
20 : execution_id_manager(start_clk)
23 , greater_than(field_gt, range_check, greater_than_emitter)
24 , memory_provider(range_check, execution_id_manager, memory_emitter)
25 , merkle_check(poseidon2, merkle_check_emitter)
31 written_public_data_slots_tree_check_emitter)
33 poseidon2, merkle_check, field_gt, build_retrieved_bytecodes_tree(), retrieved_bytecodes_tree_check_emitter)
34
35{
39
42
45
52 InternalCallStackManagerProvider internal_call_stack_manager_provider(internal_call_stack_emitter);
62
65 mem_provider,
66 calldata_hashing_provider,
67 internal_call_stack_manager_provider,
73}
74
75// A lighter version of ContextProvider::make_enqueued_context
77 AztecAddress msg_sender,
78 bool is_static,
79 FF transaction_fee,
81 Gas gas_limit,
82 Gas gas_used,
83 TransactionPhase phase)
84{
86 // Note: not incremented between contexts
87 uint32_t context_id = context_provider->get_next_context_id();
90 address,
91 msg_sender,
92 transaction_fee,
93 is_static,
94 gas_limit,
95 gas_used,
98 memory_provider.make_memory(static_cast<uint16_t>(context_id)),
100 merkle_db,
104 phase,
105 calldata);
106}
107
108// A lighter version of ContextProvider::make_nested_context
110 AztecAddress address, AztecAddress msg_sender, ContextInterface& parent_context, bool is_static, Gas gas_limit)
111{
112
113 HintedRawMerkleDB raw_merkle_db(hints);
116 // TODO(MW): Using below causes segfault (probably stack too deep) with external call gadget fuzzer
117 // auto merkle_db = make_empty_merkle_db();
118 // Note: not incremented between contexts
119 uint32_t context_id = context_provider->get_next_context_id();
122 parent_context.get_address(),
123 msg_sender,
124 parent_context.get_transaction_fee(),
125 is_static,
126 gas_limit,
127 parent_context.get_globals(),
129 memory_provider.make_memory(static_cast<uint16_t>(context_id)),
135 parent_context.get_phase(),
136 parent_context,
137 0,
138 0);
139}
140
149} // namespace bb::avm2::fuzzing
DeduplicatingEventEmitter< FieldGreaterThanEvent > field_gt_emitter
GreaterThan greater_than
FieldGreaterThan field_gt
DeduplicatingEventEmitter< RangeCheckEvent > range_check_emitter
const Gas GAS_LIMIT
Definition constants.hpp:40
EventEmitter< Poseidon2PermutationMemoryEvent > perm_mem_event_emitter
EventEmitter< Poseidon2PermutationEvent > perm_event_emitter
EventEmitter< Poseidon2HashEvent > hash_event_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< RetrievedBytecodesTreeCheckEvent > retrieved_bytecodes_tree_check_emitter
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)
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
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:61
std::vector< FF > nullifiers
Definition avm_io.hpp:319
GlobalVariables global_variables
Definition avm_io.hpp:359
ProtocolContracts protocol_contracts
Definition avm_io.hpp:362
AccumulatedData non_revertible_accumulated_data
Definition avm_io.hpp:335