feat: cache last discovered signature to avoid re-fetching transactions#156
Draft
lpahlavi wants to merge 2 commits intolpahlavi/defi-2780-exponential-backoff-pollingfrom
Draft
Conversation
6c2a4f6 to
524f299
Compare
lpahlavi
added a commit
that referenced
this pull request
Apr 21, 2026
Replace the separate PollEntry/POLL_SCHEDULE map with a single AutomaticDepositCache struct per account, mirroring the cache design from #156. The cache stores next_poll_at (Option<u64>, None when monitoring has stopped) and checks_done, and is retained after monitoring stops so future PRs can add fields without losing state. The cache map moves to storage/mod.rs alongside the event log, with read/write_automatic_deposit_cache accessors. Poll scheduling logic stays in deposit/automatic/mod.rs using the cache. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Base automatically changed from
lpahlavi/defi-2780-poll-deposit-addresses
to
main
April 21, 2026 12:22
a3c5d73 to
151d64c
Compare
151d64c to
e4e947f
Compare
…actions Store the most recent `getSignaturesForAddress` result in the deposit cache and pass it as the `until` parameter on subsequent calls, so that only new transactions are returned. Also moves the CBOR codecs from `state/event/cbor` to `utils/cbor` (making them reusable), extends the signature codec with an `option` variant, adds round-trip tests for `Option<Signature>` encoding, and adds `update_index` to `StableSortKeyMap` for rescheduling existing entries. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3915d07 to
c419aa4
Compare
With a fixed limit, a single call may not return all transactions in the range (e.g., B at slot 101 is missed when the batch fills up with D and C). Add `page_cursor` to `AutomaticDepositCacheEntry`: - New scan (page_cursor = None): call with before=None, until=last_discovered. Record first() as the new last_discovered; set page_cursor=last() if full. - Continuing (page_cursor = Some): call with before=cursor, until=None. No lower bound is needed since the call budget limits scan depth. Clear page_cursor when the batch is smaller than the limit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
last_discovered_signature: Option<Signature>toAutomaticDepositCacheEntry, storing the most recent transaction signature seen for each monitored addressuntilparameter to subsequentgetSignaturesForAddresscalls, so only transactions newer than the last seen one are returnedstate/event/cbortoutils/cborto make them reusable across the codebaseoptionsub-module forOption<Signature>encodingOption<Signature>CBOR encodingDepends on #157.
Test plan
cargo test --locked --workspace --exclude cksol-int-testspassesNoneandSome(signature)round-trip correctly via the CBOR option codecgetSignaturesForAddresscalls receive the correctuntilparameter after the first poll🤖 Generated with Claude Code