fix(solana/macros): enforce exact return types in #[ibc_app] macro#1012
Open
mariuszzak wants to merge 2 commits intomainfrom
Open
fix(solana/macros): enforce exact return types in #[ibc_app] macro#1012mariuszzak wants to merge 2 commits intomainfrom
#[ibc_app] macro#1012mariuszzak wants to merge 2 commits intomainfrom
Conversation
The `is_result_vec_u8` and `is_result_unit` validation functions both delegated to `matches_result_type` which only checked that the outer type was `Result<_>` without inspecting the inner type parameter. This allowed `on_recv_packet(...) -> Result<()>` to pass the macro at compile time while failing at runtime with `InvalidAppResponse` because the CPI helper unconditionally expects `Vec<u8>` return data. - Implement proper inner-type inspection via `extract_result_inner_type` - Remove `ResultUnit` from `on_recv_packet` allowed return types - Fix pre-existing `quote!` bug in `validate_message_parameter` error - Update doc comments to list required return types explicitly - Add 24 unit tests for type-checking utilities - Add 17 trybuild compile-fail tests covering all validation paths
Each callback now has exactly one allowed return type, so replace the `&[ReturnTypeExpectation]` slice with a plain `ReturnTypeExpectation` value and remove the `.any()` iteration and multi-type formatting logic.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1012 +/- ##
=======================================
Coverage 99.91% 99.91%
=======================================
Files 27 27
Lines 1123 1123
=======================================
Hits 1122 1122
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Description
#[ibc_app]macro's return type validation only checked that callbacks returnedResult<_>without inspecting the inner type. This allowedon_recv_packet(...) -> Result<()>to compile but fail at runtime withInvalidAppResponsesince the router CPI helper expectsVec<u8>return data.is_result_vec_u8andis_result_unitactually inspect the generic argument insideResult<T>.on_recv_packetonly acceptsResult<Vec<u8>>,on_acknowledgement_packetandon_timeout_packetonly acceptResult<()>.quote!bug in thevalidate_message_parametererror message.ref: https://github.com/zenith-security/2026-02-cosmos-labs/issues/33#issuecomment-4125162539
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
godoccomments.Files changedin the GitHub PR explorer.SonarCloud Reportin the comment section below once CI passes.