Repository navigation
Conversation
Transfer rent only when the account needs more lamports. Keep the payer signature check when skipping transfers. This prevents subtraction overflow on overfunded accounts and avoids unnecessary transfers.
There was a problem hiding this comment.
Every commit in a Solana Foundation repository needs signature verification, and these are unverified:
fda8cdefix(realloc): handle already funded accounts
Set up signing, then sign the existing commits (git rebase --exec 'git commit --amend --no-edit -S' main) and force-push. This review is dismissed automatically once every commit verifies.
|
Hi @pol-cova, Thanks for the pull request. We ask that every change references an issue a maintainer has accepted, and there isn't one linked here. These examples are a teaching resource and each one has to stay small enough to read in one sitting, so whether a new example or framework flavor belongs here is worth settling before anyone writes it. Agreeing on the approach in an issue first means nobody writes code that can't be merged. See CONTRIBUTING.md for the full workflow. Please open an issue describing the change, or comment on the existing one. Once a maintainer has labelled it |
[Medium impact] The PR appears safe to merge. SummaryBoth realloc examples now handle accounts that already hold enough lamports.
Reviews (1) · Last reviewed commit: "fix(realloc): handle already funded acco..." · Reviewed by Greptile |
Linked issue
What and why
The native and Pinocchio realloc examples panic when an account holds more lamports than its new rent minimum.
Calculate the rent shortfall safely and transfer only when more lamports are needed. Preserve the payer signature check when skipping the transfer.
Add regression tests for exact funding, excess funding, and unsigned-payer rejection. Check account data, balances, and CPI behavior.
No dependency or account-layout changes.
Testing
pnpm testin both affected examples: 6 passing each.AI disclosure
investigate the bug, and some implementations of the fix.