Skip to content

account-info: Switch account data helpers to wincode under a feature - #1077

Merged
kskalski merged 3 commits into
anza-xyz:masterfrom
kskalski:account-info-wincode
Nov 14, 2026
Merged

kskalski merged 3 commits into
anza-xyz:masterfrom
kskalski:account-info-wincode

Conversation

@kskalski

@kskalski kskalski commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

AccountInfo serializes and deserializes account data only through bincode, so solana-program can't drop bincode without losing these helpers.

Summary of Changes

  • add a wincode feature that replaces the implementation of AccountInfo::{serialize_data, deserialize_data}, while the bincode feature provides them only when wincode is off
  • export WincodeConfig and WINCODE_CONFIG, which keep the bincode wire format and raise the preallocation limit to the max account data length, matching solana-account
  • Add a test-only compile-time check that WINCODE_CONFIG has the type of solana_account_info::WincodeConfig.

Problem
`AccountInfo` serializes and deserializes account data only through bincode, so solana-program can't drop bincode without losing these helpers.

Summary of Changes
- add a `wincode` feature that replaces the implementation of `AccountInfo::{serialize_data, deserialize_data}`, while the `bincode` feature provides them only when `wincode` is off
- export `WincodeConfig` and `WINCODE_CONFIG`, which keep the bincode wire format and raise the preallocation limit to the max account data length, matching solana-account
Problem
solana-account and solana-account-info define the same wincode config separately, so the two copies can drift apart.

Summary of Changes
Add a test-only compile-time check that `WINCODE_CONFIG` has the type of `solana_account_info::WincodeConfig`.
@kskalski
kskalski marked this pull request as ready for review November 11, 2026 04:39
@kskalski
kskalski requested a review from joncinque November 11, 2026 04:39
Comment thread account/src/lib.rs Outdated
.with_preallocation_size_limit::<WINCODE_PREALLOC_LIMIT>(
);
#[cfg(all(test, feature = "wincode"))]
const _: solana_account_info::WincodeConfig = WINCODE_CONFIG;

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.

once we do account breaking release we can replace the config in this crate with alises to solana_account_info instead of this test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We actually plan to deprecate solana_account_info and remove, so may as well leave this 😅

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.

ok, removed, since we now use different limits

@joncinque joncinque left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great, just a few questions

Comment thread account-info/src/lib.rs
T: for<'de> wincode::SchemaRead<'de, WincodeConfig, Dst = T>,
{
wincode::config::deserialize(&self.data.borrow(), WINCODE_CONFIG)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This deserialization creates a whole new instance, correct? In that case, the current WINCODE_CONFIG limit will be way too big.

The stack only gives you 4KiB, and the heap defaults to 32KiB, so we can probably make the number much smaller.

It would only work on a 10MiB account if it used a zero-copy deserialization. Is that possible using this function? If not, let's reduce the limit to 32KiB.

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.

Ok, I lowered the limit, though I suppose we should use the max allowed heap size not default:
agave/program-runtime/src/execution_budget.rs:35 has pub const MAX_HEAP_FRAME_BYTES: u32 = 256 * 1024
?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yep that works!

Comment thread account-info/Cargo.toml

[dev-dependencies]
solana-address = { workspace = true, features = ["atomic"] }
wincode = { workspace = true, features = ["alloc"] }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we enable the wincode feature on the crate in dev-dependencies? That way we'll always run the wincode test

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.

done 93559b6

Comment thread account/src/lib.rs Outdated
.with_preallocation_size_limit::<WINCODE_PREALLOC_LIMIT>(
);
#[cfg(all(test, feature = "wincode"))]
const _: solana_account_info::WincodeConfig = WINCODE_CONFIG;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We actually plan to deprecate solana_account_info and remove, so may as well leave this 😅

Problem
- `AccountInfo::deserialize_data` decodes an owned value, so a 10 MiB preallocation limit admits collections far larger than any program heap.
- The solana-account check pins its wincode config to the account-info one, although runtime accounts need the 10 MiB limit.
- The wincode tests run only when the `wincode` feature is enabled explicitly.

Summary of Changes
- lower the account-info wincode preallocation limit to 256 KiB, the largest heap frame a program can request
- drop the solana-account check that pins the two wincode configs together
- enable the `wincode` feature through a dev-dependency on the crate itself, so the wincode tests always run

@joncinque joncinque left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great!

@kskalski
kskalski merged commit 129a6da into anza-xyz:master Nov 14, 2026
30 checks passed
@kskalski
kskalski deleted the account-info-wincode branch November 14, 2026 01:44
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