fix(pyth/anchor): vendor PriceUpdateV2 to build on Anchor 1.0; re-enable in CI#56
Merged
Conversation
…ble in CI basics/pyth/anchor was excluded because pyth-solana-receiver-sdk can't be built against Anchor 1.0 / borsh 1.x. The latest SDK (1.2.0) builds against anchor-lang 0.32 and pulls pythnet-sdk (2.3.1), which still derives borsh 0.10 on PriceFeedMessage, while Anchor's AnchorSerialize/AnchorDeserialize derives need borsh 1.x — so the SDK's own PriceUpdateV2 fails to compile (`PriceFeedMessage: BorshSerialize is not satisfied`). No SDK release targets anchor-lang 1.0 and no pythnet-sdk release has moved to borsh 1.x, so the dep can't be upgraded. Drop the pyth-solana-receiver-sdk dependency and vendor the PriceUpdateV2 / PriceFeedMessage / VerificationLevel layout locally with Anchor 1.0 derives and manual Discriminator/Owner/AccountSerialize/AccountDeserialize impls. The fields, order, and 8-byte discriminator match the on-chain account, and it is owned by the Pyth Receiver program, so accounts written by Pyth deserialize unchanged. Document the situation in the README (GitHub note callout) and a matching comment in lib.rs, including the "as of June 2026" caveat to revisit once an Anchor 1.0 / borsh 1.x SDK ships. The existing LiteSVM test (builds a mock PriceUpdateV2 and calls read_price) passes. Drop basics/pyth/anchor from .github/.ghaignore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
basics/pyth/anchorwas excluded becausepyth-solana-receiver-sdkcan't be built against Anchor 1.0 / borsh 1.x. I checked for an upgrade path first — there isn't one:pyth-solana-receiver-sdk(1.2.0) builds againstanchor-lang0.32 and pullspythnet-sdk(2.3.1), which still derives borsh 0.10 onPriceFeedMessage(borsh ^0.10.3, no feature to switch).AnchorSerialize/AnchorDeserializederives need borsh 1.x, so the SDK's ownPriceUpdateV2fails to compile:pyth-solana-receiver-sdktargetsanchor-lang1.0 (this repo's standard), and nopythnet-sdkhas moved to borsh 1.x. So upgrading deps can't fix it.Fix
Drop the
pyth-solana-receiver-sdkdependency and vendor thePriceUpdateV2/PriceFeedMessage/VerificationLevellayout locally with Anchor 1.0 derives and manualDiscriminator/Owner/AccountSerialize/AccountDeserializeimpls. The fields, order, and 8-byte discriminator (sha256("account:PriceUpdateV2")[..8]) match the on-chain account exactly, and it's owned by the Pyth Receiver program (Ownerimpl), so accounts written by Pyth deserialize unchanged.The situation is documented in two places (with an "as of June 2026" caveat to revisit once a compatible SDK ships): a GitHub
> [!NOTE]callout in the README and a matching comment inlib.rs.Verification
cargo build-sbfsucceeds,cargo fmt --check+cargo clippy --all-targets -D warningsare clean, and the existing LiteSVM test (test_read_price— builds a mockPriceUpdateV2account and callsread_price) passes. Droppedbasics/pyth/anchorfrom.github/.ghaignore.https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
Generated by Claude Code