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
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)
26 , merkle_check(poseidon2, merkle_check_emitter)
32 written_public_data_slots_tree_check_emitter)
34 poseidon2, merkle_check, field_gt, build_retrieved_bytecodes_tree(), retrieved_bytecodes_tree_check_emitter)
35
36{
40
43
46
53 InternalCallStackManagerProvider internal_call_stack_manager_provider(internal_call_stack_emitter);
63
66 mem_provider,
67 calldata_hashing_provider,
68 internal_call_stack_manager_provider,
74}
75
76// A lighter version of ContextProvider::make_enqueued_context
78 AztecAddress msg_sender,
79 bool is_static,
80 FF transaction_fee,
82 Gas gas_limit,
83 Gas gas_used,
84 TransactionPhase phase)
85{
87 // Note: not incremented between contexts
88 uint32_t context_id = context_provider->get_next_context_id();
91 address,
92 msg_sender,
93 transaction_fee,
94 is_static,
95 gas_limit,
96 gas_used,
99 memory_provider.make_memory(static_cast<uint16_t>(context_id)),
101 merkle_db,
105 phase,
106 calldata);
107}
108
109// A lighter version of ContextProvider::make_nested_context
111 AztecAddress address, AztecAddress msg_sender, ContextInterface& parent_context, bool is_static, Gas gas_limit)
112{
113
114 HintedRawMerkleDB raw_merkle_db(hints);
117 // TODO(MW): Using below causes segfault (probably stack too deep) with external call gadget fuzzer
118 // auto merkle_db = make_empty_merkle_db();
119 // Note: not incremented between contexts
120 uint32_t context_id = context_provider->get_next_context_id();
123 parent_context.get_address(),
124 msg_sender,
125 parent_context.get_transaction_fee(),
126 is_static,
127 gas_limit,
128 parent_context.get_globals(),
130 memory_provider.make_memory(static_cast<uint16_t>(context_id)),
136 parent_context.get_phase(),
137 parent_context,
138 0,
139 0);
140}
141
150} // 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:68
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