Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix struct size discrepancy by specifying enum representation #115 #117

Merged
merged 4 commits into from
Mar 13, 2024

Conversation

ali-bahjati
Copy link
Collaborator

Same as #115.

This commit resolves a size discrepancy issue observed with structs derived from the Pyth SDK when executed on Solana's runtime vs off-chain. The use of #[repr(C)] in enum definitions, leading to an unexpected increase in struct sizes when compiled for the Solana BPF target, causing the SDK to fail deserialization.
The account size for std::mem::size_of::() returned 3840, when the correct size is 3312.

By changing the enum representation from #[repr(C)] to #[repr(u8)], we ensure a consistent and minimal size for the enums across both execution environments.

This commit resolves a size discrepancy issue observed with structs
derived from the Pyth SDK when executed on Solana's runtime vs off-chain.
The use of `#[repr(C)]` in enum definitions, leading to an unexpected
increase in struct sizes when compiled for the Solana BPF target,
causing the SDK to fail deserialization.
The account size for std::mem::size_of::<SolanaPriceAccount>() returned 3840, when the correct size is 3312.

By changing the enum representation from `#[repr(C)]` to `#[repr(u8)]`,
we ensure a consistent and minimal size for the enums across both
execution environments.
@ali-bahjati ali-bahjati force-pushed the orchrd/main branch 3 times, most recently from 17e7c41 to e0fd263 Compare March 13, 2024 10:57
@ali-bahjati ali-bahjati merged commit 05ddf2b into main Mar 13, 2024
5 checks passed
@ali-bahjati ali-bahjati deleted the orchrd/main branch March 13, 2024 14:40
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants