Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ pub struct FailureCollection {
inner: Vec<Vec<TransactionFailure>>,
}

/// <https://github.com/MinaProtocol/mina/blob/bfd1009abdbee78979ff0343cc73a3480e862f58/src/lib/transaction_logic/mina_transaction_logic.ml#L2197C1-L2210C53>
/// OCaml reference: src/lib/transaction_logic/mina_transaction_logic.ml L:2197-2210

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be a permalink; I think it should remain a permalink.

/// Commit: bfd1009abdbee78979ff0343cc73a3480e862f58
/// Last verified: 2025-10-16
Comment on lines +402 to +403

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why go through the trouble of adding this information. Do you plan on updating this comment every time you check the link? It's better to just have a timestamp on the commit and to use git-blame. One of the major benefits of the permalinks is that it's usually relatively easy to observe any changes from the last time this was the most relevant commit.

impl FailureCollection {
fn empty() -> Self {
Self {
Expand Down Expand Up @@ -440,17 +442,51 @@ impl FailureCollection {
}
}

/// 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];[]]`
/// Applies a coinbase transaction to the ledger.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll admit pedantry here, but this is a grammatically incorrect sentence; there's no subject. If you want to write an incomplete sentence, all you have to do is remove the period.

Suggested change
/// Applies a coinbase transaction to the ledger.
/// Applies a coinbase transaction to the ledger

Haha... I won't be mad if you just dismiss this review comment.

///
/// Processes the coinbase by first applying the optional fee transfer (if present),
/// then applying the coinbase reward to the receiver. Updates account balances and
/// timing, creates accounts if needed, and handles permission checks.
///
/// # Parameters
///
/// - `constraint_constants`: Protocol constants including account creation fees
/// - `txn_global_slot`: Current global slot for timing validation
/// - `ledger`: Mutable ledger to update
/// - `coinbase`: Coinbase transaction containing receiver, amount, and optional
/// fee transfer
///
/// # Returns
///
/// Returns [`CoinbaseApplied`] containing:
/// - `coinbase`: The input coinbase with transaction status
/// - `new_accounts`: Vector of newly created account IDs
/// - `burned_tokens`: Amount of tokens burned from failed transfers
///
/// # Errors
///
/// Returns `Err` if:
/// - `fee_transfer.fee` exceeds `coinbase.amount` (checked subtraction fails)
/// - Burned tokens overflow when summing across transfers
///
/// For protocol-level documentation and behavioral specification, see:
/// <https://o1-labs.github.io/mina-rust/docs/developers/transactions/coinbase>
///
/// # Tests
///
/// Test coverage (in `ledger/tests/test_transaction_logic_first_pass_coinbase.rs`):
///
/// - `test_apply_coinbase_without_fee_transfer`
/// - `test_apply_coinbase_with_fee_transfer`
/// - `test_apply_coinbase_with_fee_transfer_creates_account`
/// - `test_apply_coinbase_with_fee_transfer_to_same_account`
/// - `test_apply_coinbase_creates_account`
///
/// # OCaml Reference
///
/// <https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/transaction_logic/mina_transaction_logic.ml#L2022>
/// OCaml reference: src/lib/transaction_logic/mina_transaction_logic.ml L:2074-2178
/// Commit: 0063f0196d046d9d2fc8af0cea76ff30f51b49b7
/// Last verified: 2025-10-16
pub fn apply_coinbase<L>(
constraint_constants: &ConstraintConstants,
txn_global_slot: &Slot,
Expand Down Expand Up @@ -649,7 +685,9 @@ where
})
}

/// <https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/transaction_logic/mina_transaction_logic.ml#L607>
/// OCaml reference: src/lib/transaction_logic/mina_transaction_logic.ml L:607
/// Commit: 2ee6e004ba8c6a0541056076aab22ea162f7eb3a
/// Last verified: 2025-10-16
fn sub_account_creation_fee(
constraint_constants: &ConstraintConstants,
action: AccountState,
Expand Down
Loading