Skip to content

fix(message): json version detection#404

Merged
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/fix-json-msg-ver-detect
Apr 23, 2026
Merged

fix(message): json version detection#404
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/fix-json-msg-ver-detect

Conversation

@sonicfromnewyoke
Copy link
Copy Markdown
Contributor

Problem

when a transaction is fetched from an RPC with encoding: json, solana.Message.version is always left as MessageVersionLegacy, even for V0 transactions
The version field is unexported and has no JSON tag, so the default unmarshaler never populates it
This breaks IsVersioned() and any code path that branches on the message version - most notably ALT resolution.

Summary of Changes

  • added Message.UnmarshalJSON that detects V0 vs legacy by the presence of the addressTableLookups key
  • Message.MarshalJSON perf - emit PublicKeySlice / Hash directly and let their existing fast MarshalJSON methods handle base58 encoding, instead of pre-encoding to []string in a loop
  • NewTransaction perf - accountKeyIndex switched from map[string]uint16 (base58-encoded keys) to map[PublicKey]uint16 ([32]byte keys), eliminating one base58 encode per account per instruction

closes #339
related to #262

@HealthyBuilder
Copy link
Copy Markdown
Collaborator

critical bug fix. Thank you!

@HealthyBuilder HealthyBuilder merged commit 1fd2201 into solana-foundation:main Apr 23, 2026
11 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.

Marshalling Transaction from RPC response with EncodingJSON sets incorrect versioning

2 participants