5#include "barretenberg/aztec/aztec_constants.hpp"
31 const std::unordered_map<MerkleTreeId, uint32_t> tree_heights{
32 { MerkleTreeId::NULLIFIER_TREE, NULLIFIER_TREE_HEIGHT },
33 { MerkleTreeId::NOTE_HASH_TREE, NOTE_HASH_TREE_HEIGHT },
34 { MerkleTreeId::PUBLIC_DATA_TREE, PUBLIC_DATA_TREE_HEIGHT },
35 { MerkleTreeId::L1_TO_L2_MESSAGE_TREE, L1_TO_L2_MSG_TREE_HEIGHT },
36 { MerkleTreeId::ARCHIVE, ARCHIVE_HEIGHT },
38 const std::unordered_map<MerkleTreeId, index_t> tree_prefill{
39 { MerkleTreeId::NULLIFIER_TREE, 128 },
40 { MerkleTreeId::PUBLIC_DATA_TREE, 128 },
47 DOM_SEP__BLOCK_HEADER_HASH);
68 const auto& klass = it->second;
71 .artifact_hash = klass.artifact_hash,
72 .private_functions_root = klass.private_functions_root,
73 .packed_bytecode = klass.packed_bytecode,
137 .collect_call_metadata =
true,
144 std::filesystem::create_directories(
data_dir);
153 std::filesystem::remove_all(
data_dir, ec);
158 return WorldStateRevision{ .
forkId =
fork_id, .includeUncommitted =
true };
171 .private_functions_root = 0,
172 .packed_bytecode = bytecode_vec,
173 .public_bytecode_commitment = commitment,
178 .current_contract_class_id = class_id,
179 .original_contract_class_id = class_id,
180 .initialization_hash = 0,
181 .immutables_hash = 0,
186 .outgoing_viewing_key_hash = 0,
187 .tagging_key_hash = 0,
188 .message_signing_key_hash = 0,
189 .fallback_key_hash = 0,
224 ws->append_leaves<
FF>(MerkleTreeId::L1_TO_L2_MESSAGE_TREE, { message },
fork_id);
229 if (fee_payer.is_zero()) {
232 const FF fee_juice_balance_slot =
233 Poseidon2::hash({ DOM_SEP__PUBLIC_STORAGE_MAP_SLOT, FEE_JUICE_BALANCES_SLOT, fee_payer });
234 const FF leaf_slot =
Poseidon2::hash({ DOM_SEP__PUBLIC_LEAF_SLOT,
FF(FEE_JUICE_ADDRESS), fee_juice_balance_slot });
245 app_logic_enqueued_calls.reserve(app_calls.size());
246 for (
const auto& call : app_calls) {
251 .contract_address = call.contract_address,
252 .is_static_call = call.is_static_call,
255 .calldata = call.calldata,
269 .timestamp = 1000000,
280 .teardown_gas_limits =
Gas{ .
l2_gas = 1000000, .da_gas = 1000000 },
286 .app_logic_enqueued_calls = app_logic_enqueued_calls,
287 .gas_used_by_private =
Gas{ .
l2_gas = PUBLIC_TX_L2_GAS_OVERHEAD, .da_gas = TX_DA_GAS_OVERHEAD },
288 .fee_payer = fee_payer,
TxSimulationResult simulate_for_hint_collection(simulation::ContractDBInterface &raw_contract_db, const world_state::WorldStateRevision &world_state_revision, world_state::WorldState &ws, const PublicSimulatorConfig &config, const Tx &tx, const GlobalVariables &global_variables, const ProtocolContracts &protocol_contracts, simulation::CancellationTokenPtr cancellation_token=nullptr)
TxSimulationResult simulate_fast_with_existing_ws(simulation::ContractDBInterface &raw_contract_db, const world_state::WorldStateRevision &world_state_revision, world_state::WorldState &ws, const PublicSimulatorConfig &config, const Tx &tx, const GlobalVariables &global_variables, const ProtocolContracts &protocol_contracts, simulation::CancellationTokenPtr cancellation_token=nullptr)
void append_note_hash(const FF ¬e_hash)
static PublicSimulatorConfig default_config()
world_state::WorldStateRevision current_revision() const
static AztecAddress default_sender()
PublicTxSimulationTester.
TestContractDB contract_db_
void set_public_storage(const AztecAddress &address, const FF &slot, const FF &value)
TxSimulationResult simulate_tx(const std::vector< TestEnqueuedCall > &app_calls, const PublicSimulatorConfig &config=default_config())
void insert_siloed_nullifier(const FF &siloed_nullifier)
void fund_fee_payer(const AztecAddress &fee_payer)
std::unique_ptr< world_state::WorldState > ws
~PublicTxSimulationTester()
DeployedContract deploy_contract(std::span< const uint8_t > bytecode, const FF &salt=0)
void append_l1_to_l2_message(const FF &message)
PublicTxSimulationTester()
void add_contract_instance(const AztecAddress &address, const ContractInstance &instance)
std::optional< ContractInstance > get_contract_instance(const AztecAddress &address) const override
TestContractDB.
std::optional< ContractClass > get_contract_class(const ContractClassId &class_id) const override
std::stack< Checkpoint > checkpoints
void revert_checkpoint() override
std::unordered_map< AztecAddress, ContractInstance > contract_instances
std::unordered_map< ContractClassId, ContractClassWithCommitment > contract_classes
void add_contracts(const ContractDeploymentData &contract_deployment_data) override
std::optional< std::string > get_debug_function_name(const AztecAddress &address, const FunctionSelector &selector) const override
void commit_checkpoint() override
void create_checkpoint() override
void add_contract_class(const ContractClassWithCommitment &contract_class)
std::optional< FF > get_bytecode_commitment(const ContractClassId &class_id) const override
Native Poseidon2 hash function implementation.
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
static constexpr affine_element one() noexcept
Holds the Merkle trees responsible for storing the state of the Aztec protocol.
std::vector< uint8_t > bytecode
FF compute_public_bytecode_commitment(std::span< const uint8_t > bytecode)
::bb::crypto::merkle_tree::NullifierLeafValue NullifierLeafValue
FF compute_contract_class_id(const FF &artifact_hash, const FF &private_fn_root, const FF &public_bytecode_commitment)
::bb::crypto::merkle_tree::PublicDataLeafValue PublicDataLeafValue
FF unconstrained_silo_nullifier(const AztecAddress &contract_address, const FF &nullifier)
FF compute_calldata_hash(std::span< const FF > calldata)
FF compute_contract_address(const ContractInstance &contract_instance)
std::string random_temp_directory()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::vector< FF > nullifiers
PublicCallRequest request
bool skip_fee_enforcement
std::unordered_map< ContractClassId, ContractClassWithCommitment > contract_classes