114 info(
"call_instance ", i,
": ");
160 size_t value_idx = index_dist(rng);
162 int inner_mutation_choice = inner_mutation_dist(rng);
163 switch (inner_mutation_choice) {
167 input.
call_instances[value_idx].l2_gas = MemoryValue::from<uint32_t>(gas_dist(rng));
173 input.
call_instances[value_idx].da_gas = MemoryValue::from<uint32_t>(gas_dist(rng));
180 FF(addr_dist(rng), addr_dist(rng), addr_dist(rng), addr_dist(rng));
208 int mutation_choice = mutation_dist(rng);
210 switch (mutation_choice) {
229 size_t instr_sizes_offset =
230 num_events * (spec.at(WireOpCode::CALL).size_in_bytes + spec.at(WireOpCode::RETURN).size_in_bytes +
233 0, std::numeric_limits<uint32_t>::max() - uint32_t(instr_sizes_offset));
234 input.
start_pc = start_pc_dist(rng);
260 .parent_id =
context->get_parent_id(),
262 .gas_used =
context->get_gas_used(),
263 .gas_limit =
context->get_gas_limit(),
273 auto allocated_l2_gas_read = input.
l2_gas;
274 auto allocated_da_gas_read = input.
da_gas;
280 .operand<uint8_t>(20)
288 parent_context->set_next_pc(parent_context->get_pc() +
static_cast<uint32_t
>(instr.size_in_bytes()));
294 gas_tracker->consume_gas();
295 auto new_gas_limit = gas_tracker->compute_gas_limit_for_call(
296 Gas{ allocated_l2_gas_read.as<uint32_t>(), allocated_da_gas_read.as<uint32_t>() });
302 parent_context->set_pc(parent_context->get_next_pc());
303 ex_event.
inputs = { allocated_l2_gas_read,
304 allocated_da_gas_read,
306 MemoryValue::from<uint32_t>(0) };
311 ex_events.push_back(ex_event);
321 ex_events.push_back(nested_event);
323 return child_context;
332 .operand<uint8_t>(40)
339 context->set_next_pc(
context->get_pc() +
static_cast<uint32_t
>(instr.size_in_bytes()));
343 gas_tracker->consume_gas();
358 ex_event.
inputs = { MemoryValue::from<uint32_t>(10) };
361 ex_events.push_back(ex_event);
383 size_t current_call_idx = 0;
391 execution_components,
393 fuzz_return(ex_events, child_context, execution_components);
400 }
catch (
const std::exception& e) {
412 if (getenv(
"AVM_DEBUG") !=
nullptr) {
413 info(
"Debugging trace:");
418 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
std::unique_ptr< AddressingInterface > make_addressing(AddressingEvent &event) override
simulation::Instruction build() const
InstructionBuilder & operand(OperandBuilder operand)
void process(const simulation::EventEmitterInterface< simulation::ExecutionEvent >::Container &ex_events, TraceContainer &trace)
void process(const simulation::EventEmitterInterface< simulation::GreaterThanEvent >::Container &events, TraceContainer &trace)
GreaterThanTraceBuilder gt_builder
const std::vector< MemoryValue > data
uint8_t buffer[RANDOM_BUFFER_SIZE]
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)
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
ContextEvent after_context_event
AddressingEvent addressing_event
std::vector< MemoryValue > inputs
Instruction wire_instruction