Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
tx_execution.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
23
24namespace bb::avm2::simulation {
25
26// TODO(fcarreiro): Create interface and move there.
32
33// In charge of executing a transaction.
34class TxExecution final {
35 public:
63
65
66 const TxContext& get_tx_context() const { return tx_context; }
67
68 private:
77
80
81 // This function can throw if there is a nullifier collision.
82 void insert_non_revertibles(const Tx& tx);
83 // This function can throw if there is a nullifier collision.
84 void insert_revertibles(const Tx& tx);
86 TransactionPhase phase,
87 const FF& transaction_fee,
88 bool success,
89 const Gas& start_gas,
90 const Gas& end_gas,
91 const TxContextEvent& state_before,
92 const TxContextEvent& state_after);
93 void pay_fee(const AztecAddress& fee_payer,
94 const FF& fee,
95 const uint128_t& fee_per_da_gas,
96 const uint128_t& fee_per_l2_gas);
97
98 void emit_l2_to_l1_message(bool revertible, const ScopedL2ToL1Message& l2_to_l1_message);
99 void emit_nullifier(bool revertible, const FF& nullifier);
100 void emit_note_hash(bool revertible, const FF& note_hash);
101
102 void pad_trees();
103
104 void cleanup();
105
107
108 std::string get_debug_function_name(const AztecAddress& contract_address, const std::vector<FF>& calldata);
109};
110
111} // namespace bb::avm2::simulation
void cleanup()
Emit a TxPhaseEvent event with the embedded event type CleanupEvent. This is used to finalize the acc...
void emit_public_call_request(const PublicCallRequestWithCalldata &call, TransactionPhase phase, const FF &transaction_fee, bool success, const Gas &start_gas, const Gas &end_gas, const TxContextEvent &state_before, const TxContextEvent &state_after)
Handle a public call request and emit a TxPhaseEvent event with the embedded event type EnqueuedCallE...
TxExecutionResult simulate(const Tx &tx)
Simulates the entire transaction execution phases.
void insert_revertibles(const Tx &tx)
Insert the revertible accumulated data into the Merkle DB and emit corresponding events....
FieldGreaterThanInterface & field_gt
void pad_trees()
Pad the note hash and nullifier trees and emit a TxPhaseEvent event with the embedded event type PadT...
std::string get_debug_function_name(const AztecAddress &contract_address, const std::vector< FF > &calldata)
Get the debug function name for a given contract address and calldata.
void emit_empty_phase(TransactionPhase phase)
Emit a TxPhaseEvent event with the embedded event type EmptyPhaseEvent. This is used to indicate that...
void insert_non_revertibles(const Tx &tx)
Insert the non-revertible accumulated data into the Merkle DB and emit corresponding events....
const TxContext & get_tx_context() const
HighLevelMerkleDBInterface & merkle_db
EventEmitterInterface< TxEvent > & events
void pay_fee(const AztecAddress &fee_payer, const FF &fee, const uint128_t &fee_per_da_gas, const uint128_t &fee_per_l2_gas)
Pay the fee for the transaction and emit a TxPhaseEvent event with the embedded event type CollectGas...
ContractDBInterface & contract_db
void emit_note_hash(bool revertible, const FF &note_hash)
Handle a note hash insertion and emit a TxPhaseEvent event with the embedded event type PrivateAppend...
ContextProviderInterface & context_provider
void emit_l2_to_l1_message(bool revertible, const ScopedL2ToL1Message &l2_to_l1_message)
Handle an L2 to L1 message insertion and emit a TxPhaseEvent event with the embedded event type Priva...
TxExecution(ExecutionInterface &call_execution, ContextProviderInterface &context_provider, ContractDBInterface &contract_db, HighLevelMerkleDBInterface &merkle_db, WrittenPublicDataSlotsTreeCheckInterface &written_public_data_slots_tree, RetrievedBytecodesTreeCheckInterface &retrieved_bytecodes_tree, SideEffectTrackerInterface &side_effect_tracker, FieldGreaterThanInterface &field_gt, Poseidon2Interface &poseidon2, CallStackMetadataCollectorInterface &call_stack_metadata_collector, EventEmitterInterface< TxEvent > &event_emitter, bool skip_fee_enforcement=false)
CallStackMetadataCollectorInterface & call_stack_metadata_collector
ExecutionInterface & call_execution
EventEmitter< DataCopyEvent > event_emitter
AvmFlavorSettings::FF FF
Definition field.hpp:10
unsigned __int128 uint128_t
Definition serialize.hpp:44
SideEffectTracker side_effect_tracker