116 info(
"call_instance ", i,
": ");
162 size_t value_idx = index_dist(rng);
164 int inner_mutation_choice = inner_mutation_dist(rng);
165 switch (inner_mutation_choice) {
169 input.
call_instances[value_idx].l2_gas = MemoryValue::from<uint32_t>(gas_dist(rng));
175 input.
call_instances[value_idx].da_gas = MemoryValue::from<uint32_t>(gas_dist(rng));
182 FF(addr_dist(rng), addr_dist(rng), addr_dist(rng), addr_dist(rng));
210 int mutation_choice = mutation_dist(rng);
212 switch (mutation_choice) {
231 size_t instr_sizes_offset =
232 num_events * (spec.at(WireOpCode::CALL).size_in_bytes + spec.at(WireOpCode::RETURN).size_in_bytes +
235 0, std::numeric_limits<uint32_t>::max() - uint32_t(instr_sizes_offset));
236 input.
start_pc = start_pc_dist(rng);
262 .parent_id =
context->get_parent_id(),
264 .gas_used =
context->get_gas_used(),
265 .gas_limit =
context->get_gas_limit(),
275 auto allocated_l2_gas_read = input.
l2_gas;
276 auto allocated_da_gas_read = input.
da_gas;
282 .operand<uint8_t>(20)
290 parent_context->set_next_pc(parent_context->get_pc() +
static_cast<uint32_t
>(instr.size_in_bytes()));
296 gas_tracker->consume_gas();
297 auto new_gas_limit = gas_tracker->compute_gas_limit_for_call(
298 Gas{ allocated_l2_gas_read.as<uint32_t>(), allocated_da_gas_read.as<uint32_t>() });
304 parent_context->set_pc(parent_context->get_next_pc());
305 ex_event.
inputs = { allocated_l2_gas_read,
306 allocated_da_gas_read,
308 MemoryValue::from<uint32_t>(0) };
313 ex_events.push_back(ex_event);
323 ex_events.push_back(nested_event);
325 return child_context;
334 .operand<uint8_t>(40)
341 context->set_next_pc(
context->get_pc() +
static_cast<uint32_t
>(instr.size_in_bytes()));
345 gas_tracker->consume_gas();
360 ex_event.
inputs = { MemoryValue::from<uint32_t>(10) };
363 ex_events.push_back(ex_event);
385 size_t current_call_idx = 0;
393 execution_components,
395 fuzz_return(ex_events, child_context, execution_components);
402 }
catch (
const std::exception& e) {
414 if (getenv(
"AVM_DEBUG") !=
nullptr) {
415 info(
"Debugging trace:");
420 check_relation<external_call_rel>(
trace);
#define AVM_RETURN_BASE_L2_GAS
#define AVM_CALL_BASE_L2_GAS
void run(uint32_t starting_row=0)
static TaggedValue from(T value)
std::string to_string() const
Sets up gadgets and instance managers to provide a context for fuzzing. NOTE: rudimentary set up for ...
DeduplicatingEventEmitter< GreaterThanEvent > greater_than_emitter
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< 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)
std::unique_ptr< GasTrackerInterface > make_gas_tracker(GasEvent &gas_event, const Instruction &instruction, ContextInterface &context) override
Create a gas tracker bound to the given event, instruction, and context.
std::unique_ptr< AddressingInterface > make_addressing(AddressingEvent &event) override
Create an addressing resolver that writes its resolution results into the given event.
simulation::Instruction build() const
InstructionBuilder & operand(OperandBuilder operand)
void process(const simulation::EventEmitterInterface< simulation::ExecutionEvent >::Container &ex_events, TraceContainer &trace)
Process the execution events and populate the relevant columns in the trace. ExecutionError enum is u...
void process(const simulation::EventEmitterInterface< simulation::GreaterThanEvent >::Container &events, TraceContainer &trace)
Process the greater-than events and populate the relevant columns in the trace.
GreaterThanTraceBuilder gt_builder
const std::vector< MemoryValue > data
std::unique_ptr< uint8_t[]> buffer
const uint32_t min_l2_gas
const uint8_t max_total_calls
ContextEvent fill_context_event(std::unique_ptr< ContextInterface > &context)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
size_t LLVMFuzzerCustomMutator(uint8_t *data, size_t size, size_t max_size, unsigned int seed)
const uint8_t max_flat_calls
void fuzz_return(std::vector< ExecutionEvent > &ex_events, std::unique_ptr< ContextInterface > &context, ExecutionComponentsProvider &execution_components)
const uint8_t max_nested_calls
void mutate_call_instance(ExternalCallFuzzerInput &input, std::mt19937 rng)
std::unique_ptr< ContextInterface > fuzz_call(std::vector< ExecutionEvent > &ex_events, GadgetFuzzerContextHelper &helper, std::unique_ptr< ContextInterface > &parent_context, ExecutionComponentsProvider &execution_components, ExternalCallFuzzerInstance input)
InstructionInfoDB instruction_info_db
void check_interaction(tracegen::TestTraceContainer &trace)
AVM range check gadget for witness generation.
lookup_settings< lookup_external_call_is_l2_gas_left_gt_allocated_settings_ > lookup_external_call_is_l2_gas_left_gt_allocated_settings
const std::unordered_map< WireOpCode, WireInstructionSpec > & get_wire_instruction_spec()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static ExternalCallFuzzerInstance from_buffer(const uint8_t *buffer)
ExternalCallFuzzerInstance()=default
AztecAddress contract_address
void to_buffer(uint8_t *buffer) const
Settings to be passed ot GenericLookupRelationImpl.
ContextEvent after_context_event
AddressingEvent addressing_event
std::vector< MemoryValue > inputs
Instruction wire_instruction