Skip to content

fix(solana/spl_token): migrate to shared core::InstructionView, drop data clone - #381

Open
shahan-khatchadourian-anchorage wants to merge 1 commit into
mainfrom
worktree-380-spl-token-migrate-instruction-view
Open

fix(solana/spl_token): migrate to shared core::InstructionView, drop data clone#381
shahan-khatchadourian-anchorage wants to merge 1 commit into
mainfrom
worktree-380-spl-token-migrate-instruction-view

Conversation

@shahan-khatchadourian-anchorage

@shahan-khatchadourian-anchorage shahan-khatchadourian-anchorage commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Removes the private InstructionView struct from spl_token/mod.rs that clones context.data().to_vec() into a Vec<u8> on every instruction — a per-instruction heap allocation with no architectural justification.
  • Switches to the shared crate::core::InstructionView for program ID and account resolution.
  • Accesses instruction bytes via context.data() directly (a zero-copy borrow), consistent with all other presets in the codebase.
  • Fixes the stale None => "unknown" fallback arm (now "unresolved(oob:N)" matching the canonical form in core::InstructionView).

Closes #380

Test plan

  • cargo test -p visualsign-solana — 328 passed, 0 failed, 3 ignored
  • make -C src lint — clippy clean with -D warnings
  • cargo fmt --all -- --check — clean
  • Diff is mechanical: import change, struct deletion, &instruction.data -> context.data() substitutions, and the rustfmt reflow those substitutions imply (the shorter argument lets 17 create_text_field("Raw Data", ...) calls fit on one line)

Note on formatting coverage

The rustfmt reflow above is invisible to CI. presets/mod.rs declares preset modules through include!(concat!(env!("OUT_DIR"), "/generated_presets_mod.rs")), so rustfmt cannot traverse into presets/*/cargo fmt --all formats presets/mod.rs and nothing beneath it. The whole preset tree is therefore unformatted as far as the make generated + clean-tree gate is concerned. Worth a follow-up issue; out of scope here.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 18, 2026 07:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the spl_token Solana preset to use the shared crate::core::InstructionView (introduced in #367) and removes the preset’s private InstructionView that cloned instruction bytes per instruction, switching all byte access to a zero-copy borrow via context.data().

Changes:

  • Replaces the private spl_token::InstructionView with the shared core::InstructionView for program/account display resolution.
  • Eliminates per-instruction heap allocation by removing context.data().to_vec() and decoding directly from context.data().
  • Aligns unresolved-account fallback behavior with the canonical core::InstructionView placeholder format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…data clone

Removes the private InstructionView struct (which copied context.data()
into a Vec<u8> on every instruction) and switches to the shared
crate::core::InstructionView introduced in #367. Instruction bytes are
now accessed via context.data() directly wherever needed, eliminating
the per-instruction heap allocation. Also fixes the stale None-arm
fallback that rendered "unknown" instead of the canonical
"unresolved(oob:N)" form.

Closes #380

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chain:solana test:proptest Run the Solana property-test suite on this PR test:surfpool Run the Solana surfpool mainnet-fork suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spl_token: migrate private InstructionView to shared core::InstructionView

3 participants