Expand description
Two-phase transaction application
This module implements the two-phase transaction application model used in Mina. This approach enables efficient proof generation, particularly for zkApp commands.
§Application Phases
§First Pass
The first pass (apply_transaction_first_pass) performs:
- Transaction validation (nonces, balances, permissions)
- Fee payment
- For zkApp commands: applies fee payer and begins account update processing
- For other transactions: completes the entire application
- Records the previous ledger hash
§Second Pass
The second pass (apply_transaction_second_pass) performs:
- For zkApp commands: completes account update processing and emits events/actions
- For other transactions: simply packages the results from first pass
§Key Types
TransactionPartiallyApplied: Intermediate state between passesZkappCommandPartiallyApplied: zkApp-specific intermediate stateFullyApplied: Wrapper for non-zkApp transactions that complete in first pass
§Fee Transfers and Coinbase
Fee transfers and coinbase transactions also use helper functions in this module:
apply_fee_transfer: Distributes fees to block producersapply_coinbase: Handles block rewards and optional fee transfersprocess_fee_transfer: Core logic for fee distribution with permission checks
Both transactions have structured failure status to indicate which part failed:
- Single transfer:
[[failure]] - Two transfers both fail:
[[failure1]; [failure2]] - First succeeds, second fails:
[[]; [failure2]] - First fails, second succeeds:
[[failure1]; []]
Structs§
Enums§
Functions§
- apply_
coinbase - Structure of the failure status:
I. No fee transfer and coinbase transfer fails:
[[failure]]II. With fee transfer- Both fee transfer and coinbase fails:[[failure-of-fee-transfer]; [failure-of-coinbase]]Fee transfer succeeds and coinbase fails:[[];[failure-of-coinbase]]Fee transfer fails and coinbase succeeds:[[failure-of-fee-transfer];[]] - apply_
fee_ transfer - https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/transaction_logic/mina_transaction_logic.ml#L1991
- apply_
transaction_ first_ pass - Applies the first pass of transaction application.
- apply_
transaction_ second_ pass - Completes the second pass of transaction application.
- apply_
transactions - apply_
user_ command - apply_
user_ command_ unchecked - compute_
updates - get_
new_ 🔒accounts - has_
permission_ 🔒to_ receive - https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/transaction_logic/mina_transaction_logic.ml#L1852
- is_
timed - pay_fee
- pay_
fee_ impl - process_
fee_ transfer - Structure of the failure status:
I. Only one fee transfer in the transaction (
One) and it fails: [[failure]] II. Two fee transfers in the transaction (Two)- Both fee transfers fail: [[failure-of-first-fee-transfer]; [failure-of-second-fee-transfer]] First succeeds and second one fails: [[];[failure-of-second-fee-transfer]] First fails and second succeeds: [[failure-of-first-fee-transfer];[]] - set_
with_ location - sub_
account_ 🔒creation_ fee - https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/transaction_logic/mina_transaction_logic.ml#L607
- update_
timing_ 🔒when_ no_ deduction - validate_
time