|
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. | |
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, either of which results in an unprovable tx. | |
| void | insert_revertibles (const Tx &tx) |
| Insert the revertible accumulated data into the Merkle DB and emit corresponding events. A side-effect limit error is recoverable (the caller reverts to post-setup); a nullifier collision is unrecoverable (the tx is unprovable). | |
| 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 690 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 707 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 472 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 429 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. |
| NullifierCollisionException | if the nullifier collides with an existing one (unrecoverable). |
Definition at line 378 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 343 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 724 of file tx_execution.cpp.
|
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, either of which 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, or L2 to L1 messages is reached. |
| NullifierCollisionException | if a nullifier collision occurs (unrecoverable). |
Definition at line 511 of file tx_execution.cpp.
|
private |
Insert the revertible accumulated data into the Merkle DB and emit corresponding events. A side-effect limit error is recoverable (the caller reverts to post-setup); a nullifier collision is unrecoverable (the tx is unprovable).
| tx | The transaction to insert the revertible accumulated data into. |
| TxExecutionException | if the maximum number of nullifiers, note hashes, or L2 to L1 messages is reached. |
| NullifierCollisionException | if a nullifier collision occurs (unrecoverable). |
Definition at line 564 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 673 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 618 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 exception is thrown. If a side-effect limit is reached during revertible insertions or App Logic phase fails, all the state changes are reverted to the post-setup state and we continue with the Teardown phase. A nullifier collision during revertible insertions is ALSO unprovable (not revertible): the nullifier originated from private, so a collision indicates the tx should never have been proposed. The NullifierCollisionException propagates out of simulate() as-is. 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. |
| NullifierCollisionException | if a private nullifier collision occurs in either the non-revertible or revertible insertion phase. |
| TxExecutionException | if
|
Definition at line 84 of file tx_execution.cpp.
|
private |
Definition at line 67 of file tx_execution.hpp.
|
private |
Definition at line 73 of file tx_execution.hpp.
|
private |
Definition at line 68 of file tx_execution.hpp.
|
private |
Definition at line 69 of file tx_execution.hpp.
|
private |
Definition at line 74 of file tx_execution.hpp.
|
private |
Definition at line 71 of file tx_execution.hpp.
|
private |
Definition at line 70 of file tx_execution.hpp.
|
private |
Definition at line 72 of file tx_execution.hpp.
|
private |
Definition at line 77 of file tx_execution.hpp.
|
private |
Definition at line 76 of file tx_execution.hpp.