Skip to content

set_account should call sync_accounts #217

@BretasArthur1

Description

@BretasArthur1

Problem

Currently, the only way an account gets removed from the inner SVM is if we send a transaction that spends all the lamports, triggering this check when calling send_transaction:

 pub(crate) fn sync_accounts(
        &mut self,
        mut accounts: Vec<(Pubkey, AccountSharedData)>,
    ) -> Result<(), LiteSVMError> {
        ...

 if acc.lamports() == 0 {
    self.inner.remove(&pubkey);
 }
}

However, if we use set_account to manually set an account’s lamports to 0, the account still remains in the inner SVM because no such check is performed in this path.

Why this matters:
This behavior is problematic when resetting an account locally: if we set lamports to 0 using set_account, we would expect the account to be removed, but it isn’t. This is inconsistent with the behavior when using a transaction.

Proposed solution:

  • Extend set_account so that after updating the account, it also calls sync_accounts, ensuring that accounts with zero lamports are removed from the inner SVM immediately.

  • Alternatively, make sync_accounts public

Use case:

Allows us to manually reset (remove) an account locally by simply setting its lamports to 0 (what should be the default behavior), without needing to send a transaction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions