Skip to content

fix: meter programdata and return the loaded accounts data size - #428

Merged
Aursen merged 2 commits into
LiteSVM:masterfrom
L0STE:fix/loaded-accounts-data-size
Oct 4, 2026
Merged

Aursen merged 2 commits into
LiteSVM:masterfrom
L0STE:fix/loaded-accounts-data-size

Conversation

@L0STE

@L0STE L0STE commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

LiteSVM meters a transaction's loaded accounts data size against its limit (SIMD-0186), but it misses one rule Agave applies, and it doesn't tell the caller the size it metered.

Count programdata (fix). Agave also counts the programdata of every loader-v3 program the transaction loads: 64 bytes plus its data, once, and not at all when the transaction lists the programdata account itself (account_loader.rs#L543-L563). LiteSVM skipped it, so any transaction touching an upgradeable program (every Anchor program) was metered below what mainnet counts. A transaction that sets set_loaded_accounts_data_size_limit from a LiteSVM run could then pass here and fail on mainnet with MaxLoadedAccountsDataSizeExceeded.

Return the size (feature). TransactionMetadata gains loaded_accounts_data_size, set by send_transaction and simulate_transaction, including for transactions that fail in execution. RPC layers built on LiteSVM, like Surfpool's simulateTransaction, can report it instead of recounting it themselves.

Notes:

  • It is a new public field on TransactionMetadata, so code that builds the struct with a literal needs to set it.
  • litesvm-persistence doesn't store the field, so the snapshot format is unchanged and restored history reports 0. Happy to persist it with a format version bump instead, if you prefer that.

Tests, in tests/compute_budget.rs:

  • test_loaded_accounts_data_size_counts_programdata: with an upgradeable program in the transaction, a limit at the exact size passes and one byte below fails, both when the programdata is unlisted (counted with the program) and when it is listed (counted once).
  • test_transaction_metadata_reports_loaded_accounts_data_size: the reported size equals the metered size for a simulated, a successful and an execution-failed transaction.

cargo test --features precompiles, cargo clippy --all-targets -- -D warnings (with and without --all-features) and cargo +nightly fmt --all -- --check pass.

@Aursen
Aursen merged commit e281f88 into LiteSVM:master Oct 4, 2026
23 checks passed
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