smartcontract/cli: fix user-balances and fund underestimating required wallet balance#3213
Open
juan-malbeclabs wants to merge 2 commits intomainfrom
Open
smartcontract/cli: fix user-balances and fund underestimating required wallet balance#3213juan-malbeclabs wants to merge 2 commits intomainfrom
juan-malbeclabs wants to merge 2 commits intomainfrom
Conversation
martinsander00
approved these changes
Mar 13, 2026
…d wallet balance The wallet's own rent-exempt minimum was treated as a floor on the required amount rather than being added to it. When a user account needs to be provisioned, the fee payer must retain wallet_rent_min lamports for itself after paying the new account's rent — so the correct formula is wallet_rent_min + needs_rent, not needs_rent.max(wallet_rent_min). - user_balances.rs: needs_rent.max(wallet_rent_min) → needs_rent + wallet_rent_min - fund.rs: needs_rent.max(min_balance).max(wallet_rent_min) → wallet_rent_min + needs_rent.max(min_balance)
ec5ba09 to
32a4a9b
Compare
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 of Changes
access-pass user-balances: was treatingwallet_rent_minas a floor on therequiredamount instead of adding it; after paying for a new User PDA the fee payer still needs to retain its own rent-exempt minimum or Solana rejects the transactionaccess-pass fund: same bug —wallet_rent_minwas the third argument to a chain of.max()calls; fixed to always add it on top of the operational needDiff Breakdown
Pure bug fix — no new code, only corrected formulas and updated test expectations.
Key files (click to expand)
smartcontract/cli/src/accesspass/user_balances.rs—needs_rent.max(wallet_rent_min)→needs_rent + wallet_rent_minsmartcontract/cli/src/accesspass/fund.rs—needs_rent.max(min_balance).max(wallet_rent_min)→wallet_rent_min + needs_rent.max(min_balance); test expectations updated accordinglyTesting Verification
missing: 0but provisioning failed withinsufficient funds for renton account (0) (the fee payer)requiredfor 1 remaining slot is ~0.003702 SOL (rent_per_ip + gas + wallet_rent_min), correctly showing a deficit of ~0.000595 SOL