Skip to content

feat: poll monitored addresses for deposit transactions#139

Merged
lpahlavi merged 6 commits intomainfrom
lpahlavi/defi-2780-poll-deposit-addresses
Apr 21, 2026
Merged

feat: poll monitored addresses for deposit transactions#139
lpahlavi merged 6 commits intomainfrom
lpahlavi/defi-2780-poll-deposit-addresses

Conversation

@lpahlavi
Copy link
Copy Markdown
Contributor

@lpahlavi lpahlavi commented Apr 16, 2026

Summary

Part of DEFI-2780.

Adds a poll_monitored_addresses timer that calls getSignaturesForAddress for each account in monitored_accounts. After polling, each account is removed from monitoring via a StoppedMonitoringAccount event. Discovered signatures are currently ignored — upcoming PRs will process them.

Design

The timer follows the same pattern as other timers (finalize_transactions, consolidate_deposits): it processes up to MAX_CONCURRENT_RPC_CALLS accounts per invocation in parallel and reschedules immediately via scopeguard if there is more work remaining.

Each account is polled with getSignaturesForAddress and then removed from monitoring with a StoppedMonitoringAccount event regardless of success or failure. The signature limit per call matches MAX_TRANSACTIONS_PER_ACCOUNT (10).

A follow-up PR (#157) replaces this simple poll-once-and-remove approach with an exponential backoff schedule (1 min, 2, 4, …, 512 min, up to 10 polls total) backed by a stable-memory StableBTreeMap that survives canister upgrades.

Constants

Constant Value Purpose
POLL_MONITORED_ADDRESSES_DELAY 1 min Timer interval
MAX_TRANSACTIONS_PER_ACCOUNT 10 Max signatures to fetch per account per poll

🤖 Generated with Claude Code

@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-monitored-address-queue branch 20 times, most recently from 369baed to a877a37 Compare April 17, 2026 13:51
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-poll-deposit-addresses branch from e04f3b3 to e588535 Compare April 19, 2026 13:18
@lpahlavi lpahlavi changed the title feat: add PollDepositAddresses timer for automated deposit flow feat: poll monitored addresses for deposit transactions Apr 19, 2026
Base automatically changed from lpahlavi/defi-2780-monitored-address-queue to main April 20, 2026 04:08
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-poll-deposit-addresses branch from e588535 to 60b4217 Compare April 20, 2026 04:43
Copilot AI review requested due to automatic review settings April 20, 2026 05:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds automated polling of monitored ckSOL deposit addresses via a 5-minute timer, querying Solana getSignaturesForAddress and persisting per-address polling state/signature discoveries in stable memory to support automated deposit monitoring.

Changes:

  • Introduces poll_monitored_addresses timer task and new StoppedMonitoringAccount event.
  • Adds Solana RPC support for getSignaturesForAddress plus unit tests and integration-test HTTP mocks.
  • Implements a stable-memory StableBTreeMap cache for per-account polling quota/slot cursor/discovered signatures.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
minter/src/storage/mod.rs Exposes shared stable-memory manager accessor for external stable caches.
minter/src/state/mod.rs Adds stop-monitoring state transition + new task type.
minter/src/state/event.rs Adds StoppedMonitoringAccount event variant.
minter/src/state/audit.rs Replays StoppedMonitoringAccount into in-memory state.
minter/src/rpc/mod.rs Adds get_signatures_for_address RPC wrapper + error type.
minter/src/rpc/tests.rs Adds unit tests for get_signatures_for_address.
minter/src/main.rs Schedules the new polling timer and maps the new event to candid types.
minter/src/deposit/automatic/mod.rs Implements polling logic, quota handling, and event emission on quota exhaustion.
minter/src/deposit/automatic/cache.rs Adds stable-memory cache for per-account polling state/signatures.
minter/src/constants.rs Adds cycles constant for getSignaturesForAddress.
libs/types-internal/src/event.rs Adds candid event type for StoppedMonitoringAccount.
integration_tests/src/fixtures.rs Adds HTTP mock request/response builders for getSignaturesForAddress.
integration_tests/tests/tests.rs Adds integration tests for polling and quota exhaustion behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/deposit/automatic/mod.rs Outdated
Comment thread minter/src/deposit/automatic/mod.rs Outdated
Comment thread minter/src/state/event.rs Outdated
Comment thread libs/types-internal/src/event.rs Outdated
Comment thread minter/src/deposit/automatic/mod.rs Outdated
Comment thread minter/src/deposit/automatic/cache.rs Outdated
Comment thread minter/src/deposit/automatic/cache.rs Outdated
Copilot AI review requested due to automatic review settings April 20, 2026 11:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/deposit/automatic/mod.rs Outdated
Comment thread minter/src/deposit/automatic/mod.rs Outdated
Comment thread minter/src/deposit/automatic/mod.rs
Comment thread minter/src/deposit/automatic/mod.rs Outdated
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-poll-deposit-addresses branch from d549672 to b7acc85 Compare April 20, 2026 14:21
Copilot AI review requested due to automatic review settings April 20, 2026 15:04
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-poll-deposit-addresses branch from b7acc85 to 6c2a4f6 Compare April 20, 2026 15:04
Adds a timer-based mechanism to poll monitored Solana addresses for new
deposit signatures using getSignaturesForAddress. Uses lazy Schnorr key
initialization and the shared account_address helper to derive deposit
addresses per account.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2780-poll-deposit-addresses branch from 6c2a4f6 to 524f299 Compare April 20, 2026 15:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/deposit/automatic/mod.rs Outdated
- Use defaults for response size and cycles in getSignaturesForAddress
- Remove unused GET_SIGNATURES_FOR_ADDRESS_CYCLES constant
- Inline SIGNATURES_FOR_ADDRESS_LIMIT as MAX_TRANSACTIONS_PER_ACCOUNT
- Refactor poll_monitored_addresses to use MAX_CONCURRENT_RPC_CALLS
  and the scopeguard reschedule pattern used by other timers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lpahlavi lpahlavi requested review from THLO and maciejdfinity April 20, 2026 15:26
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 20, 2026 15:28
@lpahlavi lpahlavi marked this pull request as ready for review April 20, 2026 15:29
@lpahlavi lpahlavi requested a review from a team as a code owner April 20, 2026 15:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/deposit/automatic/mod.rs
Comment thread integration_tests/tests/tests.rs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 16:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/deposit/automatic/mod.rs
lpahlavi and others added 2 commits April 21, 2026 07:58
…ringAccount

Add StoppedMonitoringAccount event emitted after polling each account,
removing it from the monitored set. Add unit tests for the polling timer
covering batched execution and rescheduling behaviour. Update integration
test to reflect the new poll-once-then-remove semantics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 21, 2026 06:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/deposit/automatic/mod.rs
Comment thread minter/src/deposit/automatic/mod.rs
Comment thread integration_tests/src/fixtures.rs
pub const POLL_MONITORED_ADDRESSES_DELAY: Duration = Duration::from_mins(1);

/// Maximum number of `getTransaction` calls to make per polled account.
pub const MAX_TRANSACTIONS_PER_ACCOUNT: usize = 10;
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.

This constant is currently 50 in the design document. We can adapt either number. 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! I'll merge the PR as-is to not re-run the CI and update the value in the PR that adds the getTransaction calls.

@lpahlavi lpahlavi merged commit 0d88d4c into main Apr 21, 2026
16 checks passed
@lpahlavi lpahlavi deleted the lpahlavi/defi-2780-poll-deposit-addresses branch April 21, 2026 12:22
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