Skip to content

fix: repair realloc/native and cross-program-invocation/native excluded after CI overhaul#651

Open
NikkiAung wants to merge 4 commits into
solana-foundation:mainfrom
NikkiAung:fix/repair-excluded-native-programs
Open

fix: repair realloc/native and cross-program-invocation/native excluded after CI overhaul#651
NikkiAung wants to merge 4 commits into
solana-foundation:mainfrom
NikkiAung:fix/repair-excluded-native-programs

Conversation

@NikkiAung

@NikkiAung NikkiAung commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

All three programs were removed from `.ghaignore` by PR #631 but the CI overhaul (PR #650) re-added them because it introduced a `tsc --noEmit` check and `pnpm install --frozen-lockfile` that exposed new issues.

  • `basics/cross-program-invocation/native` — `tsc --noEmit` failure: root `tsconfig.json` had `types: ["mocha", "chai"]` which excluded `@types/node`. The test imports from `node:buffer`, `node:fs`, `node:path` and uses `litesvm` — all require Node.js types.

    • Fix: add `"node"` to `types`, upgrade `target`/`lib` to `es2020`, add `skipLibCheck: true`, add `@types/node: ^22.19.1`, drop unused `chai`/`@types/chai`, bump TypeScript to `^5.5.0`
  • `basics/realloc/native` — runner mismatch: the test already used `node:test`'s `describe`/`test` runner but `package.json` still ran it with `ts-mocha`. Mocha saw zero registered tests. Also missing: a root `tsconfig.json` for the new typecheck step.

    • Fix: switch `test` script to `tsx --test`, drop `mocha`/`chai`/`ts-mocha`, add `@types/node: ^22.19.1` and `tsx: ^4.22.0`, bump TypeScript to `^5.5.0`, add root `tsconfig.json`
  • `basics/favorites/native` — bankrun 0.3.x SBF simulation engine rejects instructions emitted by the current stable `build-sbf` toolchain (new SBPF opcodes). litesvm tracks the upstream Solana BPF loader more closely.

    • Fix: replace `solana-bankrun` with `litesvm 0.8.0`, rewrite `tests/test.ts` to use litesvm's synchronous API (`sendTransaction`/`getAccount`), bump TypeScript to `^5.5.0`, update tsconfig to `es2020`

All three removed from `.ghaignore`.

Test plan

  • CI `solana-native.yml` passes for `basics/realloc/native`
  • CI `solana-native.yml` passes for `basics/cross-program-invocation/native`
  • CI `solana-native.yml` passes for `basics/favorites/native`
  • `.ghaignore` no longer contains the three paths

🤖 Generated with Claude Code

**cross-program-invocation/native**: the root tsconfig.json had
`types: ["mocha", "chai"]` which excluded @types/node. The test imports
from node:buffer, node:fs, node:path and uses litesvm — all need Node.js
types. The new tsc --noEmit check added by the CI overhaul caught this.
Fix: add "node" to types, update target/lib to es2020, add skipLibCheck,
add @types/node ^22.19.1, drop unused chai/@types/chai, bump TypeScript
to ^5.5.0.

**realloc/native**: the test was already using node:test's describe/test
runner but package.json still ran it with ts-mocha, causing a mismatch
where mocha saw 0 registered tests. Fix: switch to `tsx --test`, drop
mocha/chai/ts-mocha, add @types/node ^22.19.1 and tsx ^4.22.0, bump
TypeScript to ^5.5.0, add root tsconfig.json so tsc --noEmit can pass.

Both removed from .ghaignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NikkiAung
NikkiAung requested a review from dev-jodee as a code owner July 25, 2026 03:18
…on rejection

The bankrun 0.3.x SBF simulation engine rejects instructions emitted by
the current stable build-sbf toolchain (new SBPF opcodes). litesvm
tracks the upstream Solana SBF loader more closely and handles them.

Changes:
- tests/test.ts: replace async bankrun start()/processTransaction()/
  getAccount() with synchronous litesvm LiteSVM()/sendTransaction()/
  getAccount(). Each test gets a fresh LiteSVM in beforeEach for
  proper isolation. Wrong-seeds test now uses `!(result instanceof
  TransactionMetadata)` pattern instead of try/catch.
- package.json: add litesvm 0.8.0 dependency, remove solana-bankrun,
  bump @types/node ^22.8.1 → ^22.19.1, bump typescript ^4.3.5 → ^5.5.0
- tsconfig.json: upgrade target/lib es6/es2015 → es2020, add skipLibCheck

Removed from .ghaignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown

Greptile Summary

Repairs CI coverage for three native examples.

  • Re-enables the CPI, favorites, and realloc examples in native CI.
  • Updates TypeScript configurations and dependencies for the current type-checking workflow.
  • Migrates favorites and realloc tests to LiteSVM and corrects realloc’s test runner.
  • Updates the CPI build script to compile both programs.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failures remain within the scope of the follow-up review.

No blocking failure remains.

Important Files Changed

Filename Overview
.github/.ghaignore Removes the three repaired native examples from the CI exclusion list.
basics/cross-program-invocation/native/package.json Updates TypeScript dependencies and builds both CPI programs.
basics/cross-program-invocation/native/tsconfig.json Enables Node types and ES2020 compilation for CI type checking.
basics/favorites/native/tests/test.ts Replaces Bankrun test execution with LiteSVM’s synchronous API.
basics/favorites/native/package.json Replaces the Bankrun dependency with LiteSVM and updates TypeScript tooling.
basics/realloc/native/tests/realloc.test.ts Migrates the sequential realloc tests from Bankrun to LiteSVM.
basics/realloc/native/package.json Switches the Node test suite to tsx and adds LiteSVM dependencies.
basics/realloc/native/tsconfig.json Adds the root TypeScript configuration required by CI.

Reviews (4): Last reviewed commit: "fix(#651): fix cpi build script glob con..." | Re-trigger Greptile

NikkiAung and others added 2 commits July 25, 2026 10:37
… build script

realloc/native: bankrun 0.3.x rejects new SBPF opcodes emitted by the
stable toolchain (same issue as favorites/native). Switch to litesvm:
replace async bankrun start()/processTransaction()/getAccount() with
synchronous LiteSVM API. Use before() hook to set up shared SVM state
across the three sequential tests. Remove solana-bankrun dep.

cross-program-invocation/native: build script used --sbf-out-dir=./program/target/so,
creating a program/ directory. The CI's Rust unit test check fires when
[ -d program ] and then fails trying cargo test --manifest-path=./program/Cargo.toml
which doesn't exist. Fix: output to ./programs/target/so and specify
manifest paths explicitly, matching the build-and-test script.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…alloc test schema mismatch

CPI/native: build script output dir `./programs/target/so` is inside the
`programs/*` workspace glob, causing `cargo metadata` to fail on the second
build when the `programs/target/` directory exists. Switch to `./target/so`
which is outside the glob.

Realloc/native: "Reallocate WITH zero init" shrinks the account to WorkInfo
layout. Calling printEnhancedAddressInfo after this realloc tried to read a
larger schema from the smaller buffer → "buffer is smaller than expected".
Remove the stale printEnhancedAddressInfo call; only printWorkInfo applies.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant