Skip to content

fix: repair three CI-broken native programs#631

Open
NikkiAung wants to merge 2 commits into
solana-foundation:mainfrom
NikkiAung:fix/ci-broken-native-programs
Open

fix: repair three CI-broken native programs#631
NikkiAung wants to merge 2 commits into
solana-foundation:mainfrom
NikkiAung:fix/ci-broken-native-programs

Conversation

@NikkiAung

@NikkiAung NikkiAung commented Jul 10, 2026

Copy link
Copy Markdown

Summary

  • cross-program-invocation/native: bump borsh 1.5.7→1.6.1, borsh-derive 1.5.7→1.6.1, solana-program 3.0→4.0 in hand and lever Cargo.toml — the isolated workspace was pinning stale versions that conflict with the rest of the workspace
  • realloc/native: migrate ts/ from borsh v1 Map-based API to borsh v2 {struct:...} schema; add missing "borsh": "^2.0.0" direct dependency (it was absent from package.json, making the import unresolvable); fix isSigner: false→true on target account in createCreateInstruction (was causing MissingRequiredSignature on the create_account CPI); fix CJS require("node:fs") → ESM import in util.ts
  • favorites/native: fix u64 assertion (new BN(number as Buffer, "le")Number(favoritesData.number) since borsh v2 deserializes u64 as bigint); fix "wrong seeds" test which was deriving the correct PDA and expecting failure — changed to use a genuinely wrong seed so the on-chain check actually rejects it

Test plan

  • CI runs pnpm build-and-test for cross-program-invocation/native — Rust build with updated deps passes, TS test passes
  • CI runs pnpm build-and-test for realloc/native — Rust build passes, borsh v2 serialization works at runtime, create_account CPI succeeds with correct signer flag
  • favorites/native test logic fixes visible in diff; full CI validation pending .ghaignore removal once bankrun/SBF compatibility is confirmed on current platform-tools

@NikkiAung NikkiAung requested a review from dev-jodee as a code owner July 10, 2026 20:49
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes three CI-broken native Solana programs by upgrading stale dependencies and correcting TypeScript test and serialization bugs. The changes are targeted and mechanical: borsh version bumps for CPI programs, a full migration from borsh v1's class-based Map schema API to borsh v2's plain-object {struct: ...} schema for realloc, and test logic corrections in favorites.

  • cross-program-invocation/native: Bumps borsh 1.5.7→1.6.1 and solana-program 3.0→4.0 in both hand and lever Cargo.toml files to match the broader workspace.
  • realloc/native: Adds missing borsh@^2.0.0 direct dependency, migrates all instruction and state schema definitions to borsh v2 format, fixes isSigner: false→true on the target account in createCreateInstruction, and converts require("node:fs") to an ESM import.
  • favorites/native: Fixes u64 deserialization assertion and the "wrong seeds" negative test by using a threw flag outside the catch block.

Confidence Score: 5/5

The changes are narrowly scoped dependency upgrades and targeted bug fixes; no new logic is introduced and all corrections are verified against the Rust program source.

The borsh v2 schema migration is mechanical and field-for-field faithful to the Rust structs. The isSigner fix matches what the Rust create_address_info handler requires when calling invoke with create_account. The favorites test restructuring correctly addresses the prior catch-swallowing defect.

basics/realloc/native/pnpm-lock.yaml — the removed libc constraints on the Linux-specific bankrun native binaries are worth confirming on CI.

Important Files Changed

Filename Overview
basics/realloc/native/ts/instructions/create.ts Migrated to borsh v2 plain-object schema; correctly sets isSigner: true on target to satisfy Solana's create_account requirement when using invoke.
basics/favorites/native/tests/test.ts Fixes u64 bigint assertion and wrong-seeds negative test; the threw-flag pattern correctly addresses the catch-swallowing issue flagged in prior review.
basics/realloc/native/ts/util/util.ts Converts CJS dynamic require to ESM static import; correct fix for an ESM-mode TypeScript file.
basics/realloc/native/package.json Adds missing borsh@^2.0.0 direct dependency that was previously only available transitively.
basics/realloc/native/pnpm-lock.yaml Adds borsh@2.0.0 snapshot; removes libc field from solana-bankrun Linux native packages, which may affect platform resolution on glibc/musl Linux systems.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[TS Client] -->|createCreateInstruction| B[Build borsh v2 payload]
    B -->|struct schema| C[serialize instruction bytes]
    C --> D[TransactionInstruction target:isSigner=true payer:isSigner=true]
    D --> E[Solana Runtime]
    E -->|invoke| F[system_program::create_account]
    F --> G[target account created]
    G --> H[serialize AddressInfo to account data]
    I[favorites test] -->|wrong_seed PDA| O[On-chain PDA check fails]
    O --> P{threw = true}
    P -->|assert outside catch| Q[Test passes correctly]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[TS Client] -->|createCreateInstruction| B[Build borsh v2 payload]
    B -->|struct schema| C[serialize instruction bytes]
    C --> D[TransactionInstruction target:isSigner=true payer:isSigner=true]
    D --> E[Solana Runtime]
    E -->|invoke| F[system_program::create_account]
    F --> G[target account created]
    G --> H[serialize AddressInfo to account data]
    I[favorites test] -->|wrong_seed PDA| O[On-chain PDA check fails]
    O --> P{threw = true}
    P -->|assert outside catch| Q[Test passes correctly]
Loading

Reviews (2): Last reviewed commit: "fix: correct negative test logic in favo..." | Re-trigger Greptile

Comment on lines 138 to 143
try {
await client.processTransaction(tx);
console.error("Expected the test to fail");
assert(false, "Expected transaction to fail with wrong PDA seeds");
} catch (_err) {
assert(true);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Negative test always passes — assertion swallowed by catch

assert(false, ...) inside the try block throws an AssertionError, but the catch (_err) clause catches it indiscriminately and then calls assert(true), so the test passes whether processTransaction succeeds or throws. If the program ever stops rejecting wrong seeds, this test will still show green. Consider restructuring to hoist the assertion outside the catch:

let failed = false;
try {
  await client.processTransaction(tx);
} catch {
  failed = true;
}
assert(failed, "Expected transaction to fail with wrong PDA seeds");

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