Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions interface/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,14 @@ pub enum TokenInstruction<'a> {
///
/// Accounts expected by this instruction:
///
/// * Using runtime Rent sysvar
/// 0. `[writable]` The native token account to sync with its underlying
/// lamports.
///
/// * Using Rent sysvar account
/// 0. `[writable]` The native token account to sync with its underlying
/// lamports.
/// 1. `[]` Rent sysvar.
SyncNative,
/// Like [`TokenInstruction::InitializeAccount2`], but does not require the
/// Rent sysvar to be provided
Expand Down
9 changes: 7 additions & 2 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,13 @@ impl Processor {
let native_account_info = next_account_info(account_info_iter)?;
Self::check_account_owner(program_id, native_account_info)?;

let rent = Rent::get()?;
let rent_exempt_reserve = rent.minimum_balance(native_account_info.data_len());
let rent_exempt_reserve = if let Ok(rent_sysvar_info) = next_account_info(account_info_iter)
Copy link
Copy Markdown

@sushant-baton sushant-baton Mar 30, 2026

Choose a reason for hiding this comment

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

Suggested change
let rent_exempt_reserve = if let Ok(rent_sysvar_info) = next_account_info(account_info_iter)
        let rent_exempt_reserve = if let Ok(rent_sysvar_info) = next_account_info(account_info_iter)  && account_info_iter.address  == expected_rent_sysvar

@febo Can we change to that?
We are passing some other account as remaining account, this change is now breaking our deployed logic on devnet.
We pass the other account because of another solana runtime bug solana-labs/solana#9711 during a CPI call, Solana Runtime only checks balances of accounts used by the CPI call.
Not adding the extra account account here would make the CPI  "sum of account balances before and after instruction do not match" error.

We have the following code:

    normalAccountWithData.sub_lamports(sol_amount)?;
    wsolAta.add_lamports(sol_amount)?;

anchor_lang::solana_program::program::invoke(
        &Instruction {
            program_id: token::spl_token::ID,
            accounts: vec![
                AccountMeta::new(wsolAta.key(), false),
                AccountMeta::new(normalAccountWithData.key(), false),
            ],
            data: TokenInstruction::SyncNative.pack(),
        },
        &[
            [wsolAta.to](http://wsolata.to/)_account_info(),
            [normalAccountWithData.to](http://normalaccountwithdata.to/)_account_info(),
        ],
    )?;

EDIT: another suggestion maybe add next_account_info to check key if it is the token_program_id then assume it is not passed, this is exactly how anchor implements optional accounts.

Whats the timeline for this on mainnet?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We understand we can add the sysvar rent before the additional account but we cannot push it to mainnet before you push this to mainnet too I presume. Can we have timelines so it can be coordinated

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.

You can start adding the rent sysvar right away -- if the current program is ok with a different random account, it should be fine with the rent sysvar either way

{
let rent = Rent::from_account_info(rent_sysvar_info)?;
rent.minimum_balance(native_account_info.data_len())
} else {
Rent::get()?.minimum_balance(native_account_info.data_len())
};

let mut native_account = Account::unpack(&native_account_info.data.borrow())?;

Expand Down