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 and others added 2 commits April 24, 2026 16:20
- Change `monitored_accounts` from `BTreeSet` to `InsertionOrderedMap`
  to preserve insertion order for fair round-robin polling in a future PR
- Add module-level `PENDING_SIGNATURES` thread-local to buffer discovered
  transaction signatures per account
- Fill in `poll_account`'s signature arm: filter out failed transactions
  and push successful signatures into the queue
- Expose `pending_signatures_for` / `reset_pending_signatures` test helpers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Squashed from lpahlavi/defi-2780-extract-deposit-validation:

- Add `fetch_and_validate_deposit` shared helper to `deposit/mod.rs`
- Extract `GET_TRANSACTION_CYCLES` constant (50 B cycles)
- Remove `cycles_to_attach` parameter from `get_transaction` — it now
  uses the constant internally
- Refactor `try_accept_deposit` to delegate to `fetch_and_validate_deposit`
- Fix `Burn(#[n(0)])` → `Burn(#[n(1)])` in `Memo` cbor annotation

Note: the `meta.err` / `TransactionFailed` removal from #174 was NOT
cherry-picked; that is a bug in #174 that should be fixed separately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-process-signatures-queue branch from 22337fd to c03a2cc Compare April 24, 2026 14:27
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 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
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