Add proptest feature with arb module for IDL type strategies#1
Draft
shahan-khatchadourian-anchorage wants to merge 6 commits into
Draft
Add proptest feature with arb module for IDL type strategies#1shahan-khatchadourian-anchorage wants to merge 6 commits into
shahan-khatchadourian-anchorage wants to merge 6 commits into
Conversation
This was referenced Mar 13, 2026
e65a694 to
b00e90f
Compare
8248d99 to
6df6928
Compare
Closed
6df6928 to
e8637bc
Compare
b00e90f to
5008a35
Compare
e8637bc to
8789d88
Compare
5008a35 to
380b40c
Compare
b9def34 to
f7de98b
Compare
380b40c to
04bfa23
Compare
f7de98b to
cb7828a
Compare
04bfa23 to
c9aa94a
Compare
cb7828a to
8e6b4dc
Compare
e419d5c to
cbd53ea
Compare
Adds a `proptest` feature flag that exposes `solana_parser::arb`, a collection of proptest strategies for generating arbitrary IDL types and valid borsh-encoded instruction bytes. Key additions: - `arb_primitive_idl_type` / `arb_idl_type` — leaf and recursive IdlType strategies; the recursive case uses `prop_recursive` to depth-bound generation of Vec/Option/Array containers - `arb_idl_instruction` / `arb_idl` / `arb_idl_json` — instruction and full IDL strategies; `arb_idl` guarantees unique discriminators by deriving them from unique instruction names via the Anchor formula - `arb_bytes_for_type` / `arb_valid_instruction_bytes` — generates borsh-encoded bytes that are exactly consumed by `parse_data_into_args`, enabling roundtrip Ok assertions in property tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cbd53ea to
3a523cc
Compare
…tions Three libFuzzer targets: - fuzz_idl_json: arbitrary bytes as IDL JSON into decode_idl_data - fuzz_instruction_data: arbitrary bytes as instruction data into parse_instruction_with_idl - fuzz_transaction: arbitrary bytes as encoded transaction into parse_transaction Run with: cargo +nightly fuzz run <target> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merged
1 task
Move proptest strategies from src/arb.rs into fuzz-core/src/proptest.rs and add arbitrary::Arbitrary implementation for IDL types in fuzz-core/src/arbitrary.rs (ArbIdl wrapper). This separates fuzz infrastructure from the core library into a dedicated crate that can be depended on by both libfuzzer targets and proptest consumers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded IDL with ArbIdl-based dynamic generation, fixing the
wrong discriminator bug where the hardcoded value didn't match the
Anchor-computed SHA256("global:transfer") discriminator. The fuzz target
now generates random IDL shapes and exercises parse_instruction_with_idl
across varying instruction schemas.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move fuzz_idl_parsing.rs and its proptest regressions here where the IDL parsing code lives. Add embedded_idls_never_panic and embedded_idls_valid_data_always_parses_ok tests that replace the fuzz_all_idls.sh shell script with Rust test code iterating over all 13 embedded IDLs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The proptest feature was removed from solana_parser when arb.rs moved to fuzz-core. The workspace-level cargo test already runs fuzz-core tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Adds a
proptestfeature flag tosolana_parserexposingsolana_parser::arb, a collection of proptest strategies for generating arbitrary IDL types and valid borsh-encoded instruction bytes.arb_primitive_idl_type/arb_idl_type— leaf and recursiveIdlTypestrategies; the recursive case usesprop_recursiveto depth-bound generation ofVec/Option/Arraycontainers without infinite recursion at strategy-construction timearb_idl_instruction/arb_idl/arb_idl_json— instruction and full IDL strategies;arb_idlguarantees unique discriminators by deriving them from unique instruction names via the Anchor formulaarb_bytes_for_type/arb_valid_instruction_bytes— generates borsh-encoded bytes that are exactly consumed byparse_data_into_args, enabling roundtripOkassertions in property testsZero impact on consumers who don't opt in —
proptestis an optional dependency, only activated viafeatures = ["proptest"].Merge order
Step 1: Merge #2 first (custom IDL support and
parse_instruction_with_idlfrom @prasincs).Step 2: Merge this PR.
Test plan
cargo testpasses on this repovisualsign-parser#203) fuzz and pipeline integration tests pass withfeatures = ["proptest"]enabled🤖 Generated with Claude Code