Skip to content

instruction-view: Add new crate#401

Merged
febo merged 47 commits intoanza-xyz:masterfrom
febo:solana-instruction-view
Nov 21, 2025
Merged

instruction-view: Add new crate#401
febo merged 47 commits intoanza-xyz:masterfrom
febo:solana-instruction-view

Conversation

@febo
Copy link
Copy Markdown
Contributor

@febo febo commented Oct 23, 2025

Problem

Currently pinocchio provides a CU efficient way to perform cross-program invocation by using zero-copy structs to represent instruction-related data, which can be used with sol_invoke_signed_c syscall.

Solution

Add a new solana-instruction-view crate moving the types from pinocchio – the main type of this crate is the InstructionView.

The crate also includes a feature for cross-program invocations ("cpi") syscalls.

Comment thread instruction-view/src/lib.rs Outdated
@febo febo force-pushed the solana-instruction-view branch from 902e59c to 104f4cc Compare October 23, 2025 11:17
@febo febo marked this pull request as ready for review October 23, 2025 12:23
@febo febo requested a review from joncinque October 23, 2025 12:23
@febo febo marked this pull request as draft November 14, 2025 18:25
@febo
Copy link
Copy Markdown
Contributor Author

febo commented Nov 14, 2025

Waiting on #442 to rebase.

febo and others added 24 commits November 19, 2025 14:16
* [wip]: Address review comments

* [wip]: Fix pointer reference

* [wip]: Add logger buffer size tests

* Remove unused

* More logger tests

* Rename program to cpi

* Remove dynamic allocation

* Fixed signed tests

* Fix review comments

* Fix unsigned test case

* Add is_owner_by helper
* Add resize

* Deprecate realloc
Ignore zero_init parameter
* Use macro rules

* Update directory structure
* Add unchecked helper

* Fix lint

* Add inline

* Rename to checked

* Cosmetics

* Fix sol log params
* [wip]: Add new scripts

* [wip]: Use matric strategy

* [wip]: Fix members parsing

* [wip]: Add CI env variables

* [wip]: Remove nothrow

* [wip]: Filter changes

* [wip]: Add audit step

* [wip]: Add semver checks

* [wip]: Refactor publish workflow

* [wip]: Refactor

* [wip]: Fix commands

* Fix formatting

* Remove detect changes step

* Review comments

* Fix lint comments

* Expand crate comment

* Ignore crate comment tests

* Add missing docs

* More missing docs

* Add missing release component

* Pin cargo-release version

* Fix merge

* Review comments
* use `seeds` macro over `signer` macro

* fix doc to pass doc test

* deprecate  macro
* [wip]: Address review comments

* [wip]: Fix pointer reference

* [wip]: Add logger buffer size tests

* Remove unused

* More logger tests

* Rename program to cpi

* Remove dynamic allocation

* Fixed signed tests

* Fix review comments

* Fix unsigned test case

* Add is_owner_by helper
* add memo program

* use MAX_CPI_ACCOUNTS over MAX_TX_ACCOUNTS

* nit

* add account info borrowing check

* update docstring and comments

* use &str over &[u8]

* check num_accounts

* avoid unnecessary codegen

* update doc to use &str over &[u8]

* fix doc

* seperate lifetime
* Improve fallback and docs

* Add borrow state check

* Add inline

* Review comments

* Revert doc link merge change
* Fix review comments

* Revert offset increment change

* Improve invoke performance

* Add invoke instruction helper

* Typos

* Remove new helpers

* Remove unused

* Address review comments

* Tweak iteration

* More tweaks

* Limit the length of the slice

* Uncomment code

* Validate account length

* Tweak inline attributes

* Use invoke signed unchecked

* Refactor inline

* Renamed to with_bounds

* Update docs

* Fix accounts length test

* Revert change

* Add constant length check

* Review comments

* Fix error variant
* Add invoke instruction helper

* Typos

* Remove new helpers

* Remove unused

* Address review comments

* Tweak inline attributes

* Use invoke signed unchecked

* Refactor inline

* Renamed to with_bounds

* Update docs

* Revert change

* Add constant length check

* Add spellcheck step

* Tweak action

* Fix typos

* More fixes

* Yet more fixes

* Fixes

* Add j1 option

* More and more fixes

* Add missing acronym

* Fix merge

* Fix spelling

* Fix spelling
* Add comments on constants

* Improve offset comments

* Add bitmask to dictionary

* Renamed to field_at_offset
…-xyz#228)

* Add debug/copy derives and enable missing debug/copy lint

* Update sdk/pinocchio/src/sysvars/rent.rs

Co-authored-by: Fernando Otero <febo@anza.xyz>

* Update sdk/pinocchio/src/entrypoint/mod.rs

Co-authored-by: Fernando Otero <febo@anza.xyz>

* Update sdk/pinocchio/src/instruction.rs

Co-authored-by: Fernando Otero <febo@anza.xyz>

* Update sdk/pinocchio/src/sysvars/clock.rs

Co-authored-by: Fernando Otero <febo@anza.xyz>

* Update sdk/pinocchio/src/sysvars/fees.rs

* Update sdk/pinocchio/src/sysvars/fees.rs

* Update sdk/pinocchio/src/sysvars/instructions.rs

Co-authored-by: Fernando Otero <febo@anza.xyz>

* Update sdk/pinocchio/src/sysvars/instructions.rs

Co-authored-by: Fernando Otero <febo@anza.xyz>

* Update sdk/pinocchio/src/sysvars/instructions.rs

Co-authored-by: Fernando Otero <febo@anza.xyz>

* Update sdk/pinocchio/src/sysvars/clock.rs

* Fix syntax error in Instructions struct derive macro

---------

Co-authored-by: Fernando Otero <febo@anza.xyz>
@febo febo force-pushed the solana-instruction-view branch from 3a5bc83 to fec6cf7 Compare November 19, 2025 14:21
@febo febo marked this pull request as ready for review November 19, 2025 14:21
@febo
Copy link
Copy Markdown
Contributor Author

febo commented Nov 19, 2025

Waiting on #442 to rebase.

@joncinque Rebase done.

Comment thread instruction-view/src/cpi.rs Outdated
Copy link
Copy Markdown
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks great overall! Mostly small comments and nits

Comment thread instruction-view/src/lib.rs Outdated
Comment thread instruction-view/src/lib.rs Outdated
Comment thread instruction-view/src/cpi.rs Outdated
Comment thread instruction-view/src/cpi.rs Outdated
Comment thread instruction-view/src/cpi.rs Outdated
Comment thread instruction-view/src/cpi.rs Outdated
Comment thread instruction-view/src/lib.rs
joncinque
joncinque previously approved these changes Nov 20, 2025
Copy link
Copy Markdown
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks good to me! It's up to you if you want to do the alloc work here though, whichever you prefer

@febo febo force-pushed the solana-instruction-view branch from 111404c to 491515b Compare November 20, 2025 13:11
@febo
Copy link
Copy Markdown
Contributor Author

febo commented Nov 20, 2025

Looks good to me! It's up to you if you want to do the alloc work here though, whichever you prefer

I had a go at refactoring the invoke to support the actual maximum of CPI accounts (commit 491515b). The downside is that it requires a small bump on the minimum Rust version. We could implement with a Vec, but using the Box seems cleaner. If we don't want to bump the MSRV, then I can change the implementation.

@febo febo requested a review from joncinque November 20, 2025 13:14
Copy link
Copy Markdown
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Just a few last nits, looks really close!

Comment thread scripts/check-msrv.sh Outdated
Comment thread instruction-view/src/cpi.rs Outdated
Comment thread instruction-view/src/cpi.rs Outdated
Comment thread instruction-view/src/cpi.rs Outdated
Comment thread instruction-view/src/cpi.rs
cargo-cache-key: cargo-minimum-check
cargo-cache-fallback-key: cargo-minimum

- name: Install additional toolchains
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could add a cache to this step, but it does not seem to take very long since one of the toolchains will usually be installed already.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks fine to me! It only takes 8 seconds, and the whole check is less than a minute

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we need a separate script for this – we could just add its contents to the github workflow directly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It can't hurt, looks good!

@febo febo requested a review from joncinque November 21, 2025 10:53
Copy link
Copy Markdown
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Beautiful!

cargo-cache-key: cargo-minimum-check
cargo-cache-fallback-key: cargo-minimum

- name: Install additional toolchains
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks fine to me! It only takes 8 seconds, and the whole check is less than a minute

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It can't hurt, looks good!

@febo febo merged commit 6b7745f into anza-xyz:master Nov 21, 2025
24 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.

4 participants