Skip to content

program: Sync native updates rent exempt reserve#132

Open
joncinque wants to merge 4 commits intosolana-program:mainfrom
joncinque:sync-native
Open

program: Sync native updates rent exempt reserve#132
joncinque wants to merge 4 commits intosolana-program:mainfrom
joncinque:sync-native

Conversation

@joncinque
Copy link
Contributor

Problem

This is the p-token version of solana-program/token-2022#1006.

The current rent-exempt reserve at the time of account creation is stored in the is_native field of a token account. When rent is decreased, or ever increased, this value will be incorrect, leading to an incorrect amount stored in the token account.

Summary of changes

Update sync_native to use the current rent-exempt reserve, and allow for the amount to potentially decrease.

In this PR, I've also updated the old program implementation -- I'm not sure if that's needed, so I'll remove if you prefer.

I also need to ignore one of the regression fixtures since the behavior has changed.

#### Problem

This is the p-token version of
solana-program/token-2022#1006.

The current rent-exempt reserve at the time of account creation is
stored in the `is_native` field of a token account. When rent is
decreased, or ever increased, this value will be incorrect, leading to
an incorrect `amount` stored in the token account.

#### Summary of changes

Update `sync_native` to use the current rent-exempt reserve, and allow
for the amount to potentially decrease.
@joncinque joncinque requested review from 2501babe and febo February 27, 2026 22:20
febo
febo previously approved these changes Feb 27, 2026
Copy link
Contributor

@febo febo left a comment

Choose a reason for hiding this comment

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

Looks great! Something that occurred to me is whether would be useful to add a test that uses a rent sysvar with a lower/higher lamports per byte value to simulate the situation where the minimum rent requirement changes between creation and sync.

@joncinque
Copy link
Contributor Author

Something that occurred to me is whether would be useful to add a test that uses a rent sysvar with a lower/higher lamports per byte value to simulate the situation where the minimum rent requirement changes between creation and sync.

No problem, done!

Copy link
Contributor

@febo febo left a comment

Choose a reason for hiding this comment

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

Looks great!

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