Skip to content

fix(pyth/anchor): vendor PriceUpdateV2 to build on Anchor 1.0; re-enable in CI#56

Merged
mikemaccana merged 2 commits into
mainfrom
claude/pyth-anchor-fix
Jun 5, 2026
Merged

fix(pyth/anchor): vendor PriceUpdateV2 to build on Anchor 1.0; re-enable in CI#56
mikemaccana merged 2 commits into
mainfrom
claude/pyth-anchor-fix

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Summary

basics/pyth/anchor was excluded because pyth-solana-receiver-sdk can't be built against Anchor 1.0 / borsh 1.x. I checked for an upgrade path first — there isn't one:

  • Latest pyth-solana-receiver-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 (borsh ^0.10.3, no feature to switch).
  • Anchor's AnchorSerialize/AnchorDeserialize derives need borsh 1.x, so the SDK's own PriceUpdateV2 fails to compile:
    error[E0277]: the trait bound `pythnet_sdk::messages::PriceFeedMessage: BorshSerialize` is not satisfied
    
  • No published pyth-solana-receiver-sdk targets anchor-lang 1.0 (this repo's standard), and no pythnet-sdk has moved to borsh 1.x. So upgrading deps can't fix it.

Fix

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 (sha256("account:PriceUpdateV2")[..8]) match the on-chain account exactly, and it's owned by the Pyth Receiver program (Owner impl), 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 in lib.rs.

Verification

cargo build-sbf succeeds, cargo fmt --check + cargo clippy --all-targets -D warnings are clean, and the existing LiteSVM test (test_read_price — builds a mock PriceUpdateV2 account and calls read_price) passes. Dropped basics/pyth/anchor from .github/.ghaignore.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP


Generated by Claude Code

claude added 2 commits June 5, 2026 19:52
…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.
@mikemaccana mikemaccana merged commit 9bc01d2 into main Jun 5, 2026
18 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