feat(minter): check the deposit address balance and charge cycles in deposit_sol - #211
Draft
gregorydemay wants to merge 3 commits into
Draft
gregorydemay wants to merge 3 commits into
gregorydemay wants to merge 3 commits into
Conversation
gregorydemay
added this pull request to stack #209
September 23, 2026 08:47
…deposit_sol `deposit_sol` now requires the process deposit cycles, rejects an account with a deposit in flight without contacting the SOL RPC canister, reads the balance of the deposit address at the `finalized` commitment and queues the sweepable amount, i.e. the balance minus the rent exemption threshold, if it reaches the minimum deposit amount. The caller pays the balance read and, when the deposit is queued, the deposit consolidation fee; the rest is refunded. A dedicated guard rejects a concurrent call for the same account. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…idator Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`deposit_sol` reads the next deposit id from the state and records the `QueuedDeposit` event like every other event. The guard set reserving an account for the duration of a `deposit_sol` call lives in this branch together with the guard that uses it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
gregorydemay
force-pushed
the
feat/deposit-sol-balance-check
branch
from
September 23, 2026 09:40
6b300cc to
df25706
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Implements the balance-sweep deposit_sol flow through queueing, including finalized balance checks, cycle accounting, concurrency protection, and status reporting.
Changes:
- Adds finalized balance retrieval and sweepable amount calculation.
- Adds guards, queued deposit state, and cycle charging/refunds.
- Expands unit, PocketIC, and Solana validator test coverage.
| File | Description |
|---|---|
minter/src/state/tests.rs |
Initializes request guard state. |
minter/src/state/mod.rs |
Stores guards and queued deposit state. |
minter/src/rpc/tests.rs |
Tests balance RPC behavior. |
minter/src/rpc/mod.rs |
Adds finalized balance retrieval. |
minter/src/main.rs |
Wires the asynchronous endpoint. |
minter/src/guard/tests.rs |
Tests deposit guards. |
minter/src/guard/mod.rs |
Adds deposit guards and error mapping. |
minter/src/deposit/sweep/tests.rs |
Tests queueing, errors, cycles, and status. |
minter/src/deposit/sweep/mod.rs |
Implements balance checking and queueing. |
minter/src/constants.rs |
Defines balance RPC cycle requirements. |
libs/types-internal/src/event.rs |
Enables event equality assertions. |
integration_tests/tests/tests.rs |
Adds PocketIC deposit flow tests. |
integration_tests/tests/solana_test_validator.rs |
Tests queueing against Solana test validator. |
integration_tests/src/lib.rs |
Adds cycle-aware test helpers. |
integration_tests/src/fixtures.rs |
Adds balance RPC mocks and fixtures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Third PR of the balance-sweep deposit stack (#207, #208, #210).
deposit_solnow does what section 3.1.3 of the design describes up to queueing: it requires the attached cycles, reserves the account for the duration of the call, rejects a second call while a deposit for the account is in flight with that deposit's id, reads the balance of the deposit address at finalized commitment, computes the sweepable amount as the balance minus the rent exemption threshold, rejects it below the minimum deposit amount while charging only the balance read, and otherwise queues the deposit, charges the read plus the consolidation fee, refunds the rest and returns the id.deposit_statusreports the queued deposit with its sweepable amount.Nothing is swept yet; that is the next PR. Covered by unit tests with self-validating cycle assertions, PocketIC tests of every outcome including concurrent and duplicate calls, and a test against solana-test-validator that queues a real transfer.
🤖 Generated with Claude Code