Fix byte-array PDA seeds deriving with a Borsh length prefix - #1126
Merged
Conversation
A Vec<u8> instruction argument used as a PDA seed keeps its Borsh sizePrefixTypeNode(u32, bytes) type when converted from an Anchor IDL. Anchor derives byte-array seeds from the raw bytes without the length prefix, so the generated client computes a different PDA than the on-chain program. String seeds already strip the prefix; byte-array seeds were the missing case. Extend the argument-seed conversion to also recognize a size-prefixed bytes argument and emit a raw bytesTypeNode seed.
🦋 Changeset detectedLatest commit: 815c912 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
lorisleiva
marked this pull request as ready for review
August 28, 2026 16:20
lorisleiva
added a commit
that referenced
this pull request
Aug 29, 2026
This PR is a follow-up to #1126, which fixed byte-array PDA seeds for Anchor v01 IDLs. The legacy v00 path has the same bug: `pdaNodeFromAnchorV00` strips the Borsh size prefix from constant `string` and `bytes` seeds but not from variable ones, so a variable seed derives a different PDA than the on-chain program. This change hoists the seed type conversion into a single helper used by both branches, so constant and variable seeds are now consistent by construction.
Contributor
|
@lorisleiva thanks for this merged |
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.

This PR resurrects #1101 by @latent-9, which I accidentally closed whilst cleaning up stale branches (sorry again! 🙏). The original commit is cherry-picked verbatim from the PR ref, so authorship is preserved and it already has an approving review on the original thread.
In short: a
Vec<u8>instruction argument used as a PDA seed kept its BorshsizePrefixTypeNode(u32, bytesTypeNode())type when converted from an Anchor IDL, whereas Anchor derives byte-array seeds from the raw bytes. This meant generated clients computed a different PDA than the on-chain program. The fix mirrors the existingisBorshStringspecial case with anisBorshBytescounterpart that emits a rawbytesTypeNode()seed.