Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix Compact Arrays Header Parsing #6

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

omkarshanbhag
Copy link
Collaborator

This PR Fixes a bug in the parsing of compact array headers.

Compact arrays (or more specifically, the compact array header for byte arrays in Solana) use headers that are compact-u16. We were currently assuming that it was a single byte.

Further details here: https://solana.com/docs/core/transactions#compact-array-format

Copy link
Collaborator

@andrewkmin andrewkmin left a comment

Choose a reason for hiding this comment

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

lgtm overall, let's just add some documentation

Ok((
bytes,
&tx_body_remainder[parse_len..tx_body_remainder.len()],
))
}

fn read_compact_u16(tx_body_remainder: &[u8]) -> Result<(usize, &[u8]), Box<dyn std::error::Error>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's add some brief docs for this fn

Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a reference implementation for this? if so, we should link it — might add some peace of mind as it's fairly lowlevel

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