|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <tx_execution.hpp>
Public Member Functions | |
| 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) | |
| TxExecutionResult | simulate (const Tx &tx) |
| Simulates the entire transaction execution phases. | |
| const TxContext & | get_tx_context () const |
Private Member Functions | |
| void | insert_non_revertibles (const Tx &tx) |
| Insert the non-revertible accumulated data into the Merkle DB and emit corresponding events. It might error if the limits for the number of allowable inserts are exceeded or a nullifier collision occurs, but this results in an unprovable tx. | |
| void | insert_revertibles (const Tx &tx) |
| Insert the revertible accumulated data into the Merkle DB and emit corresponding events. It might error if the limits for the number of allowable inserts are exceeded or a nullifier collision occurs. | |
| 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 EnqueuedCallEvent. | |
| 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 CollectGasFeeEvent. | |
| 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 PrivateEmitL2L1MessageEvent. The side effect tracker is used to track the L2 to L1 messages. | |
| void | emit_nullifier (bool revertible, const FF &nullifier) |
| Handle a nullifier insertion and emit a TxPhaseEvent event with the embedded event type PrivateAppendTreeEvent. | |
| void | emit_note_hash (bool revertible, const FF ¬e_hash) |
| Handle a note hash insertion and emit a TxPhaseEvent event with the embedded event type PrivateAppendTreeEvent. | |
| void | pad_trees () |
| Pad the note hash and nullifier trees and emit a TxPhaseEvent event with the embedded event type PadTreesEvent. | |
| void | cleanup () |
| Emit a TxPhaseEvent event with the embedded event type CleanupEvent. This is used to finalize the accounting of some state changes and side effects. | |
| void | emit_empty_phase (TransactionPhase phase) |
| Emit a TxPhaseEvent event with the embedded event type EmptyPhaseEvent. This is used to indicate that a phase has no events, but in tracegen we use it to populate a so-called padded (placeholder) row. | |
| 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. | |
Definition at line 34 of file tx_execution.hpp.
|
inline |
Definition at line 36 of file tx_execution.hpp.
|
private |
Emit a TxPhaseEvent event with the embedded event type CleanupEvent. This is used to finalize the accounting of some state changes and side effects.
Definition at line 635 of file tx_execution.cpp.
|
private |
Emit a TxPhaseEvent event with the embedded event type EmptyPhaseEvent. This is used to indicate that a phase has no events, but in tracegen we use it to populate a so-called padded (placeholder) row.
| phase | The phase to emit the empty phase event for. |
Definition at line 652 of file tx_execution.cpp.
|
private |
Handle an L2 to L1 message insertion and emit a TxPhaseEvent event with the embedded event type PrivateEmitL2L1MessageEvent. The side effect tracker is used to track the L2 to L1 messages.
| revertible | Whether the L2 to L1 message is revertible. |
| l2_to_l1_message | The L2 to L1 message to insert. |
| TxExecutionException | if the maximum number of L2 to L1 messages is reached. |
Definition at line 427 of file tx_execution.cpp.
|
private |
Handle a note hash insertion and emit a TxPhaseEvent event with the embedded event type PrivateAppendTreeEvent.
| revertible | Whether the note hash is revertible. |
| note_hash | The note hash to insert. If revertible, it is siloed but not unique. Otherwise, it is unique. |
| TxExecutionException | if the maximum number of note hashes is reached. |
Definition at line 384 of file tx_execution.cpp.
|
private |
Handle a nullifier insertion and emit a TxPhaseEvent event with the embedded event type PrivateAppendTreeEvent.
| revertible | Whether the nullifier is revertible. |
| nullifier | The nullifier to insert. |
| TxExecutionException | if the maximum number of nullifiers is reached or a nullifier collision occurs. |
Definition at line 339 of file tx_execution.cpp.
|
private |
Handle a public call request and emit a TxPhaseEvent event with the embedded event type EnqueuedCallEvent.
| call | The public call request with calldata. |
| phase | The phase in which the call is executed. |
| transaction_fee | The transaction fee to be paid. |
| success | Whether the call succeeded. |
| start_gas | The gas used at the start of the call. |
| end_gas | The gas used at the end of the call. |
| state_before | The state before the call. |
| state_after | The state after the call. |
Definition at line 305 of file tx_execution.cpp.
|
private |
Get the debug function name for a given contract address and calldata.
| contract_address | The address of the contract. |
| calldata | The calldata of the function. |
Definition at line 669 of file tx_execution.cpp.
|
inline |
Definition at line 66 of file tx_execution.hpp.
|
private |
Insert the non-revertible accumulated data into the Merkle DB and emit corresponding events. It might error if the limits for the number of allowable inserts are exceeded or a nullifier collision occurs, but this results in an unprovable tx.
| tx | The transaction to insert the non-revertible accumulated data into. |
| TxExecutionException | if the maximum number of nullifiers, note hashes, L2 to L1 messages is reached, or a nullifier collision occurs. |
Definition at line 466 of file tx_execution.cpp.
|
private |
Insert the revertible accumulated data into the Merkle DB and emit corresponding events. It might error if the limits for the number of allowable inserts are exceeded or a nullifier collision occurs.
| tx | The transaction to insert the revertible accumulated data into. |
| TxExecutionException | if the maximum number of nullifiers, note hashes, L2 to L1 messages is reached, or a nullifier collision occurs. |
Definition at line 516 of file tx_execution.cpp.
|
private |
Pad the note hash and nullifier trees and emit a TxPhaseEvent event with the embedded event type PadTreesEvent.
Definition at line 620 of file tx_execution.cpp.
|
private |
Pay the fee for the transaction and emit a TxPhaseEvent event with the embedded event type CollectGasFeeEvent.
| fee_payer | The address of the fee payer. |
| fee | The fee to be paid. |
| fee_per_da_gas | The fee per DA gas. |
| fee_per_l2_gas | The fee per L2 gas. |
| TxExecutionException | if the fee payer does not have enough balance to pay the fee. |
Definition at line 568 of file tx_execution.cpp.
| TxExecutionResult bb::avm2::simulation::TxExecution::simulate | ( | const Tx & | tx | ) |
Simulates the entire transaction execution phases.
There are multiple distinct transaction phases that are executed in order:
If an error occurs during non-revertible insertions or a Setup phase enqueued call fails, the transaction is considered unprovable and an unrecoverable TxExecutionException is thrown. If an error occurs during revertible insertions or App Logic phase, all the state changes are reverted to the post-setup state and we continue with the Teardown phase. If an error occurs during Teardown phase, all the state changes are reverted to the post-setup state and we continue with the Collect Gas Fees phase.
The phase values and their order are reflected in the enum TransactionPhase in aztec_types.hpp. These values are emitted as part of the TxPhaseEvent.
| tx | The transaction to simulate. |
| TxExecutionException | if
|
Definition at line 62 of file tx_execution.cpp.
|
private |
Definition at line 69 of file tx_execution.hpp.
|
private |
Definition at line 75 of file tx_execution.hpp.
|
private |
Definition at line 70 of file tx_execution.hpp.
|
private |
Definition at line 71 of file tx_execution.hpp.
|
private |
Definition at line 76 of file tx_execution.hpp.
|
private |
Definition at line 73 of file tx_execution.hpp.
|
private |
Definition at line 72 of file tx_execution.hpp.
|
private |
Definition at line 74 of file tx_execution.hpp.
|
private |
Definition at line 79 of file tx_execution.hpp.
|
private |
Definition at line 78 of file tx_execution.hpp.