Skip to content

program: Relax minimum rent check#79

Merged
febo merged 4 commits into
mainfrom
febo/relax-minimum-rent-check
Jun 5, 2026
Merged

program: Relax minimum rent check#79
febo merged 4 commits into
mainfrom
febo/relax-minimum-rent-check

Conversation

@febo

@febo febo commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Problem

Currently, Allocate, Extend, Initialize and Write include explicit minimum rent exempt, but could rely on the runtime instead.

Solution

For Allocate and Initialize, replace the minimum rent check by a check that account must have lamports; these are the only 2 instructions that can create the PDA. Remove the rent exempt check in Extend and Write since these instructions require an initialized account with data.

@febo febo marked this pull request as ready for review June 4, 2026 12:42
@febo febo requested a review from joncinque June 4, 2026 12:42
joncinque
joncinque previously approved these changes Jun 4, 2026

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

if buffer.lamports() < minimum_balance {
// The buffer account must have non-zero lamports. The runtime will then
// ensure that the account is rent exempt.
if buffer.lamports() == 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, seeing this here makes me realize that this will probably become the future of rent-exemption checks on-chain!

Comment thread program/src/processor/extend.rs Outdated
// - must be rent exempt (pre-funded account) since we are reallocating the buffer
// account
// - must be rent exempt (pre-funded account) since we are reallocating the
// account (checked by the runtime)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could say that initialize checked to make sure it had at least some lamports, since without the check in initialize, extend would still work on an account with 0 lamports, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point! Same for allocate. I will add a comment for both.

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@febo febo merged commit b774ba1 into main Jun 5, 2026
21 checks passed
@febo febo deleted the febo/relax-minimum-rent-check branch June 5, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants