Skip to content

refactor(minter): model submitted transactions as a MinterTransaction enum - #252

Open
gregorydemay wants to merge 3 commits into
feat/nonce-account-readingfrom
refactor/minter-transaction-enum
Open

gregorydemay wants to merge 3 commits into
feat/nonce-account-readingfrom
refactor/minter-transaction-enum

Conversation

@gregorydemay

Copy link
Copy Markdown
Contributor

Pure refactoring in preparation for durable-nonce withdrawals: the transactions the minter submits and monitors are modelled as an enum with one variant per kind (deposit sweep, withdrawal), replacing a struct tagged by a purpose field. Every place handling a submitted transaction now matches exhaustively on its kind, so that the per-kind decisions (what to do on success, failure, or expiry) are explicit and the upcoming nonce-based withdrawal variant can reuse the same finalization infrastructure.

No behaviour change: stored events and the Candid interface are unchanged.

🤖 Generated with Claude Code

@gregorydemay
gregorydemay added this pull request to stack #253 October 6, 2026 14:26
@gregorydemay
gregorydemay removed this pull request from stack #253 October 6, 2026 14:29
@gregorydemay
gregorydemay added this pull request to stack #254 October 6, 2026 14:29
Copilot AI balanced review requested due to automatic review settings October 6, 2026 15:01
@gregorydemay
gregorydemay removed this pull request from stack #254 October 6, 2026 15:02
@gregorydemay
gregorydemay added this pull request to stack #256 October 6, 2026 15:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Transaction-size validation changes signer invocation and error precedence despite the stated behavior-preserving scope.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Refactors submitted transaction state into kind-specific MinterTransaction variants while preserving durable events and monitoring flows.

Changes:

  • Replaces SolanaTransaction with sweep and withdrawal variants.
  • Updates monitoring and tests for enum accessors.
  • Moves transaction-size validation before signing.
File Description
minter/​src/​state/​mod.rs Introduces and processes the transaction enum.
minter/​src/​state/​tests.rs Updates sweep assertions.
minter/​src/​monitor/​mod.rs Uses enum accessors during monitoring.
minter/​src/​monitor/​tests.rs Updates resubmission assertions.
minter/​src/​withdraw/​tests.rs Verifies withdrawal variant metadata.
minter/​src/​sol_transfer/​mod.rs Validates size before signing.
minter/​src/​sol_transfer/​tests.rs Updates oversized-transaction test.
minter/​src/​test_fixtures/​runtime.rs Records timer delays.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +119 to +121
ensure_within_transaction_size(&transaction.message)?;
transaction.signatures =
sign_bytes(signer_derivation_paths, signer, transaction.message_data()).await?;
@gregorydemay
gregorydemay marked this pull request as ready for review October 6, 2026 15:06
@gregorydemay
gregorydemay requested a review from a team as a code owner October 6, 2026 15:06
@zeropath-ai

zeropath-ai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to a8431f3.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► minter/src/monitor/mod.rs
    Modify block_height accessors to tx.block_height() instead of field access
► minter/src/monitor/mod.rs
    Update resubmit_transactions to use tx.message() and tx.signers()
Enhancement ► minter/src/monitor/tests.rs
    Update assertion to use resubmitted.block_height()
Enhancement ► minter/src/sol_transfer/mod.rs
    Introduce ensure_within_transaction_size and adjust message/signatures handling to use transaction.message_data()
Enhancement ► minter/src/sol_transfer/tests.rs
    Refactor to construct transactions with TestCanisterRuntime and updated signature of create_signed_batch_withdrawal_transaction call
Enhancement ► minter/src/state/mod.rs
    Refactor transaction types from SolanaTransaction to MinterTransaction with variants SweepDeposit and Withdrawal
► minter/src/state/mod.rs
    Add methods message(), signers(), block_height() for MinterTransaction
► minter/src/state/mod.rs
    Update state fields and accessors to use MinterTransaction
Enhancement ► minter/src/state/tests.rs
    Update tests to match MinterTransaction::SweepDeposit pattern and verify deposit_ids and signers via new structure
Enhancement ► minter/src/test_fixtures/runtime.rs
    Rename and adapt timer-related fields: set_timer_call_count to derive from set_timer_delays length; adjust set_timer to record delays
Enhancement ► minter/src/withdraw/tests.rs
    Update imports to use MinterTransaction; adjust submitted transaction assertions to use block_height() and pattern matching for Withdrawal variant

gregorydemay and others added 3 commits October 6, 2026 15:45
… enum

Replace the SolanaTransaction struct and its purpose field with a
MinterTransaction enum whose SweepDeposit and Withdrawal variants carry
the deposit ids or burn indices directly, so that the transaction
lifecycle handlers match exhaustively on the kind of transaction.
Stored events and the Candid interface are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…signing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mbjorkqvist mbjorkqvist left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks @gregorydemay! Just a couple of findings from Claude.

Comment thread minter/src/state/mod.rs
signers: Vec<Signer>,
/// The block height of the block whose blockhash the transaction uses.
block_height: BlockHeight,
/// Total transfer amount in lamports (excluding fees).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Since #221 removed consolidation, amount is only ever written, never read. Its doc is also inaccurate for this variant: it's set to the return value of deposits.sweep(…), which is the expected received amount, i.e. after the fee. A pure refactoring introducing a new type seems the natural moment to drop it; the draft #234 ("remove the per-transaction amount") does exactly that and will conflict with this PR (and #248 carries the field and its doc forward too). Could we drop amount here (and close #234), or land #234 first? Relatedly, deposit_ids and burn_indices are also only written; fine if the nonce work needs them, otherwise they duplicate what the state already tracks per deposit / withdrawal.

Comment thread minter/src/state/mod.rs
}

impl MinterTransaction {
pub fn message(&self) -> &VersionedMessage {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 nit: the three accessors each repeat an identical arm per variant; or-patterns (MinterTransaction::SweepDeposit { message, .. } | MinterTransaction::Withdrawal { message, .. } => message) would avoid that, as #248 already does, which would also shrink #248's diff.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 05:32
@gregorydemay
gregorydemay force-pushed the refactor/minter-transaction-enum branch from ce22834 to a8431f3 Compare October 7, 2026 05:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Transaction-size validation now changes signing behavior despite the stated behavior-preserving scope.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants