Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
fuzzer_context.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <memory>
8#include <vector>
9
12
13namespace bb::avm2::fuzzer {
14
16 public:
18 : contract_db_(std::make_unique<FuzzerContractDB>())
19 {}
20
21 // ---- Mutable API (for top-level fuzzers) ----
22
27 FF register_contract_from_bytecode(const std::vector<uint8_t>& bytecode);
28
31
33 void reset();
34
35 // ---- Const API (for instruction generation, passed as const&) ----
36
40 {
41 if (contract_addresses_.empty()) {
42 return FF::zero();
43 }
45 }
46
48 bool has_contracts() const { return !contract_addresses_.empty(); }
49
51 size_t contract_count() const { return contract_addresses_.size(); }
52
55
56 private:
57 std::vector<FF> contract_addresses_;
59};
60
61} // namespace bb::avm2::fuzzer
std::shared_ptr< Napi::ThreadSafeFunction > bytecode
FuzzerContractDB & get_contract_db() const
Get the contract database for simulation.
FF register_contract_from_bytecode(const std::vector< uint8_t > &bytecode)
Register a contract from its bytecode.
bool has_contracts() const
Check if any contracts are registered.
void reset()
Clear all contract addresses and reset the contract DB.
FF get_contract_address(size_t index) const
Get a contract address by index (wraps around using modulo)
size_t contract_count() const
Get the number of registered contracts.
void add_contract_address(FF address)
Add a contract address to the context (without registering a contract)
std::unique_ptr< FuzzerContractDB > contract_db_
AvmFlavorSettings::FF FF
Definition field.hpp:10
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13