Skip to content

Commit 6579396

Browse files
committed
Ledger/tx_logic: document top level module
1 parent bd46a4d commit 6579396

File tree

1 file changed

+58
-0
lines changed
  • ledger/src/scan_state/transaction_logic

1 file changed

+58
-0
lines changed

ledger/src/scan_state/transaction_logic/mod.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
1+
//! Transaction logic module
2+
//!
3+
//! This module implements the core logic for applying and validating all
4+
//! transaction types in the Mina protocol. It is a direct port of the OCaml
5+
//! implementation from `src/lib/transaction_logic/mina_transaction_logic.ml`
6+
//! and maintains identical business logic.
7+
//!
8+
//! # Transaction Types
9+
//!
10+
//! The module handles three main categories of transactions:
11+
//!
12+
//! ## User Commands
13+
//! - **Signed Commands**: Payments and stake delegations
14+
//! - **zkApp Commands**: Complex multi-account zero-knowledge operations
15+
//!
16+
//! ## Protocol Transactions
17+
//! - **Fee Transfers**: Distribution of transaction fees to block producers
18+
//! - **Coinbase**: Block rewards for successful block production
19+
//!
20+
//! # Two-Phase Application
21+
//!
22+
//! Transaction application follows a two-phase model to enable efficient proof
23+
//! generation:
24+
//!
25+
//! 1. **First Pass** ([`apply_transaction_first_pass`]): Validates
26+
//! preconditions and begins application. For zkApp commands, applies the fee
27+
//! payer and first phase of account updates.
28+
//!
29+
//! 2. **Second Pass** ([`apply_transaction_second_pass`]): Completes
30+
//! application. For zkApp commands, applies the second phase of account
31+
//! updates and finalizes state.
32+
//!
33+
//! # Key Types
34+
//!
35+
//! - [`Transaction`]: Top-level enum for all transaction types
36+
//! - [`UserCommand`]: User-initiated transactions (signed or zkApp)
37+
//! - [`TransactionStatus`]: Applied or failed with specific error codes
38+
//! - [`TransactionFailure`]: 50+ specific failure reasons
39+
//! - [`FeeTransfer`]: Fee distribution transaction
40+
//! - [`Coinbase`]: Block reward transaction
41+
//!
42+
//! # Module Organization
43+
//!
44+
//! - [`local_state`]: Local state management during zkApp application
45+
//! - [`protocol_state`]: Protocol state views for transaction application
46+
//! - [`signed_command`]: Payment and stake delegation logic
47+
//! - [`transaction_applied`]: Final transaction application results
48+
//! - [`transaction_partially_applied`]: Two-phase transaction application
49+
//! - [`transaction_union_payload`]: Unified transaction representation for SNARK circuits
50+
//! - [`transaction_witness`]: Witness generation for transaction proofs
51+
//! - [`valid`]: Valid (but not yet verified) user commands
52+
//! - [`verifiable`]: Verifiable user commands ready for proof verification
53+
//! - [`zkapp_command`]: zkApp command processing
54+
//! - [`zkapp_statement`]: zkApp statement types for proof generation
55+
156
use self::{
257
local_state::{apply_zkapp_command_first_pass, apply_zkapp_command_second_pass, LocalStateEnv},
358
protocol_state::{GlobalState, ProtocolStateView},
@@ -243,12 +298,15 @@ impl<T> WithStatus<T> {
243298

244299
pub trait GenericCommand {
245300
fn fee(&self) -> Fee;
301+
246302
fn forget(&self) -> UserCommand;
247303
}
248304

249305
pub trait GenericTransaction: Sized {
250306
fn is_fee_transfer(&self) -> bool;
307+
251308
fn is_coinbase(&self) -> bool;
309+
252310
fn is_command(&self) -> bool;
253311
}
254312

0 commit comments

Comments
 (0)