feat: poll monitored addresses for deposit transactions#139
Conversation
369baed to
a877a37
Compare
e04f3b3 to
e588535
Compare
e588535 to
60b4217
Compare
There was a problem hiding this comment.
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_addressestimer task and newStoppedMonitoringAccountevent. - Adds Solana RPC support for
getSignaturesForAddressplus unit tests and integration-test HTTP mocks. - Implements a stable-memory
StableBTreeMapcache 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.
There was a problem hiding this comment.
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.
d549672 to
b7acc85
Compare
b7acc85 to
6c2a4f6
Compare
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>
6c2a4f6 to
524f299
Compare
There was a problem hiding this comment.
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.
- 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>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
…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>
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this comment.
This constant is currently 50 in the design document. We can adapt either number. 🙂
There was a problem hiding this comment.
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.
Summary
Part of DEFI-2780.
Adds a
poll_monitored_addressestimer that callsgetSignaturesForAddressfor each account inmonitored_accounts. After polling, each account is removed from monitoring via aStoppedMonitoringAccountevent. 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 toMAX_CONCURRENT_RPC_CALLSaccounts per invocation in parallel and reschedules immediately via scopeguard if there is more work remaining.Each account is polled with
getSignaturesForAddressand then removed from monitoring with aStoppedMonitoringAccountevent regardless of success or failure. The signature limit per call matchesMAX_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
StableBTreeMapthat survives canister upgrades.Constants
POLL_MONITORED_ADDRESSES_DELAYMAX_TRANSACTIONS_PER_ACCOUNT🤖 Generated with Claude Code