PriceUpdateV2 LEN

Open
#1,871 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
blockchain

Research direction

Start at the PriceUpdateV2 definition and inspect its LEN constant alongside AnchorDeserialize::try_from_slice and PriceUpdateV2::try_deserialize. Compare the declared size with the 134-byte on-chain account example, then verify that the chosen correction makes deserialization behavior consistent without breaking existing accounts.

Written by the indexing model from the issue text.

Description

Issue

Deserializing an PriceUpdateV2 account info using AnchorDeserialize::try_from_slice(data) fails.

Note: Using PriceUpdateV2::try_deserialize(&mut data) works.

Cause

The PriceUpdateV2 structure have a size of 136 bytes, while LEN is 134 and onchain accounts are 134 bytes.

Onchain Account Example

Screenshot 2024-09-04 at 17 05 43

https://explorer.solana.com/address/7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE?cluster=devnet

PriceUpdateV2 struct in the code

#[account]
#[derive(BorshSchema)]
pub struct PriceUpdateV2 {
    pub write_authority:    Pubkey,
    pub verification_level: VerificationLevel,
    pub price_message:      PriceFeedMessage,
    pub posted_slot:        u64,
}

impl PriceUpdateV2 {
    pub const LEN: usize = 8 + 32 + 2 + 32 + 8 + 8 + 4 + 8 + 8 + 8 + 8 + 8;
}
Dominant language
TypeScript
Stars
247
Forks
348
Avg merge
2d 1h
Merged PRs (30d)
27

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyth-network/pyth-crosschain

All issues in pyth-network/pyth-crosschain

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.