feat(v2): add Kani + Miri verification harness#4424
Open
abishekk92 wants to merge 15 commits intosolana-foundation:anchor-nextfrom
Open
feat(v2): add Kani + Miri verification harness#4424abishekk92 wants to merge 15 commits intosolana-foundation:anchor-nextfrom
abishekk92 wants to merge 15 commits intosolana-foundation:anchor-nextfrom
Conversation
|
@abishekk92 is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
jamie-osec
requested changes
Apr 20, 2026
Collaborator
jamie-osec
left a comment
There was a problem hiding this comment.
I have a few comments about some parts of this PR, and I have my doubts about the usefulness of some of these Kani tests, but generally looks nice to have - Miri verification for the AccountCursor machinery is great 🙂
Author
|
Thanks a lot for your review @jamie-osec, the feedback is very helpful (addressed them in the fix commit). I've taken the liberty to extract some of the test scaffold in to |
33e0644 to
165c605
Compare
This comment was marked as resolved.
This comment was marked as resolved.
48966ff to
a2be601
Compare
…e AccountView tags
…67.0 panic on CBMC ERROR
a2be601 to
4fb0b84
Compare
59a15f5 to
bdefcd2
Compare
…cation # Conflicts: # lang-v2/src/accounts/slab.rs # lang-v2/src/testing/account_buffer.rs
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.
Kani + Miri verification harness for anchor-lang-v2, anchor-spl-v2
Summary
anchor-lang-v2andanchor-spl-v2-Zmiri-tree-borrows+ 19 runtime correctness testsMakefileand GitHub Actions workflow to run the suiteAccountCursor::next's alignment step to strict-provenance form (required for Tree Borrows)All 108 Kani harnesses pass under Kani 0.67.0; all 78 Miri + runtime tests pass.
Verification coverage
What's verified
anchor-lang-v2 — Kani (89 harnesses)
Pod{U,I}{16,32,64}— roundtrip, ord, checked/saturating arithmetic, bitwise ops, shifts all match nativePod{U,I}128— add/sub/mul/saturating under Z3;PodU128div/rem unbounded;PodI128rem with bounded divisorPodBool— roundtrip,notinvolution, non-zero-byte semanticsAccountBitvec— set/get, bit preservation, idempotenceencode_system_transferhelperrent_exempt_lamports— overflow guard, boundary, monotonicityanchor-spl-v2 — Kani (19 harnesses)
DISC_TRANSFER == 3, …,DISC_SYNC_NATIVE == 17)transfer,mint_to,burn,transfer_checked) via sharedencode_amount_ix/encode_amount_decimals_ixhelpersanchor-lang-v2 — Miri (52 tests)
AccountViewCopy-aliasing — alias, interleaved writes, reference stabilityAccountCursor::next— non-dup walk, dup resolution, chained dups, lookup cache, short-circuitPodVec— push/pop/extend, bytemuck roundtrip, corrupted-len adversarial (OOB panics, not UB)Slab—header_ptrwrite provenance,ITEMS_OFFSETalign-up math,swap_removecorrectnessSystemAccount,UncheckedAccount,Program<T>,Signerload/reject pathsanchor-spl-v2 — Miri (7 tests)
Mint/TokenAccount— size/align guards, zero-init, byte roundtrip, wrong-size rejectionRuntime tests (19 tests)
account:{name}→ first 8 bytes)PodVeccorrupted-len contract — panic points pinned as#[should_panic]AccountCursor::nextstrict-provenance migrationTree Borrows rejects the existing int-to-ptr alignment mask:
Sound on today's compiler + SBF; the
as *mut u8round-trip exposes provenance under Rust's strict-provenance contract. Migrated to.addr()+.add(delta):Same generated code;
miri_cursor_walkpasses under Tree Borrows after the change.CI changes
.github/workflows/verify-v2.yamlwith three jobs (kani,miri,unit) — path-filtered to v2 crates +Makefile+ the workflow file.miri+unitonly (~5 min).anchor-next/workflow_dispatchruns all three includingkani(~8-10 min on 4 vCPU with-j --output-format=terse).actions/checkout@de0fac2e… # v6.0.2,dtolnay/rust-toolchain@e97e2d8c… # v1) to match thepublish-*/build-cliworkflows.How to test
All harnesses gated behind
#[cfg(kani)]— no runtime behavior changes.