Skip to content

feat: process pending signatures queue and accept automatic deposits#176

Draft
lpahlavi wants to merge 3 commits intolpahlavi/unify-accepted-deposit-eventfrom
lpahlavi/defi-2780-process-signatures-queue
Draft

feat: process pending signatures queue and accept automatic deposits#176
lpahlavi wants to merge 3 commits intolpahlavi/unify-accepted-deposit-eventfrom
lpahlavi/defi-2780-process-signatures-queue

Conversation

@lpahlavi
Copy link
Copy Markdown
Contributor

@lpahlavi lpahlavi commented Apr 24, 2026

Summary

  • Implements process_pending_signatures timer function: iterates the PENDING_SIGNATURES queue in round-robin order, pops one signature per account per round, validates each via fetch_and_validate_deposit, emits AcceptedDeposit { source: Automatic } on success, silently discards invalid signatures, and reschedules itself at Duration::ZERO if more remain
  • Adds TaskType::ProcessPendingSignatures to the task set
  • Skips signatures whose deposit_status is already Some(_) to avoid double-processing
  • Wires a new 5-second PROCESS_PENDING_SIGNATURES_DELAY timer in main.rs
  • 4 unit tests: valid deposit accepted, invalid discarded, already-processed skipped, reschedule when more remain
  • Integration test verifying the full update_balance → poll → signature processing → AcceptedDeposit event flow

Stack

This PR stacks on top of:

  1. refactor: add source field to AcceptedDeposit event #179 — add source field to AcceptedDeposit event (rebased on)
  2. feat: add pending-signatures queue for automated deposit flow #175 — pending-signatures queue (cherry-pick; drop when feat: add pending-signatures queue for automated deposit flow #175 merges)
  3. refactor: extract shared deposit validation from manual flow #174 — extract shared deposit validation (cherry-pick; drop when refactor: extract shared deposit validation from manual flow #174 merges)

Test plan

  • cargo test -p cksol_minter --lib — all tests pass
  • CI green

🤖 Generated with Claude Code

@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-pending-signatures-queue branch 2 times, most recently from 7476c0a to 18d4ecf Compare April 24, 2026 13:28
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-process-signatures-queue branch 2 times, most recently from c03a2cc to 691066e Compare April 24, 2026 14:33
@lpahlavi lpahlavi changed the base branch from lpahlavi/defi-2780-pending-signatures-queue to lpahlavi/unify-accepted-deposit-event April 24, 2026 14:34
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-process-signatures-queue branch 6 times, most recently from d27a8ba to bad6704 Compare April 28, 2026 07:17
For each monitored account, pops signatures from the pending queue, calls
getTransaction, and emits AcceptedDeposit { source: Automatic } for valid
deposits. Invalid or already-processed signatures are silently discarded.
Reschedules immediately if more signatures remain after a round.

Adds an integration test verifying the end-to-end flow from update_balance
through poll and signature processing to AcceptedDeposit event emission.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-process-signatures-queue branch from bad6704 to 8b26721 Compare April 28, 2026 07:22
lpahlavi and others added 2 commits April 28, 2026 09:26
Replaces the DepositRuntimeExt trait with direct methods on
TestCanisterRuntime, and adds stub helpers for all RPC and ledger calls:
getTransaction, getSignaturesForAddress, getSlot, getBlock,
sendTransaction, getSignatureStatuses, icrc1_transfer, icrc2_transfer_from.

Each helper has a doc comment identifying the RPC call it stubs.
Updates all test files to use these methods, eliminating verbose
MultiRpcResult::Consistent(...) boilerplate and local type aliases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the imperative loop with a column-by-column flat_map: iterates
round 0 across all accounts, then round 1, etc., and stops early via
take(MAX_CONCURRENT_RPC_CALLS). Drains the taken count from each queue
afterward. This eliminates the mutable capacity tracking and makes the
interleaving intent explicit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant