fix: always advance past 32-byte authority field in DeserializeLookupTable#197
Open
prasanna-anchorage wants to merge 1 commit into
Open
Conversation
…Table The on-chain Solana Address Lookup Table format always writes 32 bytes for the Option<Pubkey> authority field, regardless of whether it is Some or None. When None, the 32 bytes are zeros. Previously, DeserializeLookupTable only advanced the offset past the 32-byte authority pubkey when the option flag was 1 (Some). When the flag was 0 (None), the offset was not advanced, causing all subsequent fields (padding and addresses) to be read from the wrong position. This resulted in: - An extra phantom address (the zero-padded authority field) at index 0 - All real addresses shifted by +1 position - One extra address parsed (N+1 instead of N) The fix unconditionally advances the offset by 32 bytes after reading the authority option flag, matching the on-chain layout where LOOKUP_TABLE_META_SIZE is always 56 bytes. Added a test case for Authority=None to prevent regression.
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
DeserializeLookupTableincorrectly parses Address Lookup Tables whenAuthorityisNone. The on-chain format always writes 32 bytes for theOption<Pubkey>authority field (zeros when None), but the current code only advances the offset when the option flag is1(Some).This causes:
N+1addresses parsed instead ofNRoot Cause
When
some == false, the 32-byte authority field is not skipped, socurrentis at offset 22 instead of 54. The subsequent padding read and address parsing all start from wrong offsets.Fix
Unconditionally advance
currentby 32 after reading the option flag, matching the on-chain layout whereLOOKUP_TABLE_META_SIZEis always 56 bytes:This is consistent with how other Go Solana SDKs handle this (e.g., gagliardetto/solana-go calls
decoder.Discard(32)in the None branch).Testing
authority_nonetest case toTestDeserializeLookupTable7Vyx1y8vG9e9Q1MedmXpopRC6ZhVaZzGcvYh5Z3Cs75i(Orca Whirlpool, 254 entries, Authority=None)Impact
Any V0 transaction using an ALT where Authority is None will have its addresses misresolved. This affects DeFi protocols (Orca, Jupiter, etc.) where ALTs commonly have no authority set.