Skip to content

Conversation

@dannywillems
Copy link
Member

Summary

  • Create a new standalone crate mina-tx-type that extracts transaction type
    structures for external reuse
  • Add comprehensive rustdoc documentation for all transaction fields
  • Support no_std environments (hardware wallets, WASM)

The crate includes:

  • ZkAppCommand and related types (FeePayer, AccountUpdate, CallForest)
  • Account update body with all fields (update, balance_change, preconditions)
  • Preconditions (network, account, valid_while)
  • SetOrKeep and OrIgnore wrapper types
  • Authorization types (AuthorizationKind, MayUseToken, Permissions)
  • Primitive types (Fee, Amount, Balance, Nonce, Slot, etc.)

Test plan

  • Verify crate compiles with cargo check -p mina-tx-type
  • Verify no_std build with cargo check -p mina-tx-type --no-default-features
  • Run tests with cargo test -p mina-tx-type

Closes #1665

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

OCaml Reference Validation Results

Repository: https://github.com/MinaProtocol/mina.git
Branch: compatible
Status: ✓ Validation passed

Click to see full validation output
Checking OCaml references against https://github.com/MinaProtocol/mina.git (branch: compatible)
Fetching current commit from compatible...
Current OCaml commit: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c

Validating references...
========================
✓ VALID: ledger/src/account/account.rs -> src/lib/mina_base/account.ml L:201-224
  ⚠ STALE COMMIT: fc6be4c58091c761f827c858229c2edf9519e941 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/for_tests.rs -> src/lib/transaction_logic/mina_transaction_logic.ml L:2285-2285
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/for_tests.rs -> src/lib/transaction_logic/mina_transaction_logic.ml L:2351-2356
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/for_tests.rs -> src/lib/transaction_logic/mina_transaction_logic.ml L:2407
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/transaction_status.ml L:9-51
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/transaction_status.ml L:452-454
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/with_status.ml L:6-10
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/fee_transfer.ml L:76-80
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/fee_transfer.ml L:68-69
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/coinbase.ml L:17-21
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/transaction/transaction.ml L:8-11
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:34-48
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/stake_delegation.ml L:11-13
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:179-181
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:239-243
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:352-362
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: ecbf1132c1c05dddc4629dd1ecf0a31c1af6682c)

Summary
=======
Total references found: 16
Valid references: 16
Invalid references: 0
Stale commits: 16

⚠ Warning: 16 reference(s) have stale commits
Run with --update to update them automatically

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

✓ Code Reference Verification Passed

All code references in the documentation have been verified successfully!

Total references checked: 1
Valid references: 1

The documentation is in sync with the codebase on the develop branch.

Create a new standalone crate `mina-tx-type` that extracts transaction type
structures from the ledger crate. This enables external projects to reuse
these structures without duplicating code.

The crate includes:
- ZkAppCommand and related types (FeePayer, AccountUpdate, CallForest)
- Account update body with all fields (update, balance_change, preconditions)
- Preconditions (network, account, valid_while)
- SetOrKeep and OrIgnore wrapper types
- Authorization types (AuthorizationKind, MayUseToken, Permissions)
- Primitive types (Fee, Amount, Balance, Nonce, Slot, etc.)

Key features:
- no_std only (no std feature) for embedded/constrained environments
- Comprehensive rustdoc documentation for all fields
- Generic over public key and field element types

References issue #1665.
Move currency types (Amount, Balance, Fee, Nonce, Slot, etc.) to
mina-tx-type and have ledger crate re-export them. This includes:

- Add mina-p2p-messages as dependency for type conversions
- Add ark-ff dependency for field operations in Magnitude trait
- Move From implementations for p2p message types to mina-tx-type
- Move rand Distribution implementations to mina-tx-type
- Update ledger/scan_state/currency.rs to re-export from mina-tx-type
- Add extension traits (AmountToChecked, etc.) for checked conversions
- Clean up unused imports across ledger crate
- Add mina-tx-type to frontend Dockerfile for WASM builds
Moves additional types and traits from ledger to mina-tx-type:

- N type: Generic 64-bit number for proof computations
- ToChecked trait: Convert currency types to checked circuit forms
- SignedRandExt trait: Random signed value generation
- SlotRandExt trait: Random slot generation for tests

Also consolidates ToInputs implementations in ledger/src/hash.rs using
the impl_to_inputs macro for currency types.

Note: ToInputs trait cannot be moved to mina-tx-type due to Rust's
orphan rule - ledger needs to implement ToInputs for foreign types.

Issue: #1665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Extract transaction types into a crate

2 participants