Skip to content

refactor: migrate inline dev-deps to workspace references in basics/ - #632

Open
NikkiAung wants to merge 2 commits into
solana-foundation:mainfrom
NikkiAung:feat/workspace-dev-deps
Open

refactor: migrate inline dev-deps to workspace references in basics/#632
NikkiAung wants to merge 2 commits into
solana-foundation:mainfrom
NikkiAung:feat/workspace-dev-deps

Conversation

@NikkiAung

@NikkiAung NikkiAung commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces all inline-pinned [dev-dependencies] versions with .workspace = true across 28 native, pinocchio, and asm Cargo.toml files under basics/
  • Adds two new entries to the root [workspace.dependencies]: solana-rent = "4.1.0" and solana-transaction-error = "3.2.0"
  • Also migrates the cross-program-invocation hand/lever programs' inline [dependencies] (borsh, borsh-derive, solana-program, solana-system-interface) to workspace references

This removes the version duplication that makes future upgrades error-prone — when a crate version bumps in root Cargo.toml, it now propagates automatically to all member crates.

Test plan

  • cargo metadata --no-deps resolves cleanly with no errors
  • CI build matrix passes for all affected programs

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

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR is a purely mechanical refactor that migrates inline-pinned [dev-dependencies] versions across 28 Cargo.toml files under basics/ to use *.workspace = true references. It also adds two new entries to the root [workspace.dependencies]solana-rent = "4.1.0" and solana-transaction-error = "3.2.0" — that were previously only pinned per-crate.

  • All migrated crates are confirmed members of the root workspace (not a sub-workspace), so every *.workspace = true reference resolves cleanly against the root Cargo.toml.
  • The two newly promoted workspace entries carry the exact same version strings that all consuming crates were already pinning inline, so no version changes are introduced.
  • The previously flagged issue with cross-program-invocation/native hand/lever programs (which live in an isolated sub-workspace) has been addressed — those files are not modified in this diff.

Confidence Score: 5/5

Safe to merge — pure version-reference migration with no logic or version changes introduced.

Every *.workspace = true reference introduced by this PR resolves against a confirmed entry in the root [workspace.dependencies]. The two newly promoted entries (solana-rent, solana-transaction-error) carry the exact version strings that all consuming crates were already pinning inline, so no dependency version drift occurs. The cross-program-invocation/native sub-workspace crates (hand & lever) that caused resolution failures previously are not touched in this diff — those files retain inline versions.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
Cargo.toml Adds solana-transaction-error = "3.2.0" and solana-rent = "4.1.0" to [workspace.dependencies]; both versions match prior inline pins exactly.
basics/repository-layout/native/program/Cargo.toml Migrates both [dependencies] (borsh, borsh-derive, solana-program) and [dev-dependencies] to workspace references; all entries present in root workspace.
basics/checking-accounts/asm/Cargo.toml Migrates all dev-deps including solana-transaction-error (newly added to root workspace) to workspace references; asm crate is a root workspace member so resolution is correct.
basics/counter/native/program/Cargo.toml Migrates all 7 dev-deps (including solana-rent) to workspace references; all entries present in root workspace.
basics/rent/native/program/Cargo.toml Migrates all 7 dev-deps including solana-rent to workspace references; all entries present in root workspace.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    RootCargo["Root Cargo.toml\n[workspace.dependencies]\n+ solana-rent = 4.1.0\n+ solana-transaction-error = 3.2.0"]

    RootCargo -->|".workspace = true"| Native["Native programs\naccount-data, checking-accounts,\nclose-account, counter, create-account,\nfavorites, hello-solana, processing-instructions,\nprogram-derived-addresses, realloc,\nrent, repository-layout, transfer-sol"]

    RootCargo -->|".workspace = true"| Pinocchio["Pinocchio programs\naccount-data, checking-accounts,\nclose-account, counter, create-account,\nfavorites, processing-instructions,\nprogram-derived-addresses, realloc,\nrent, repository-layout, transfer-sol"]

    RootCargo -->|".workspace = true"| ASM["ASM programs\nchecking-accounts/asm\ncreate-account/asm"]

    SubWS["Sub-workspace\nbasics/cross-program-invocation/native/\n(hand & lever — NOT in root workspace)"]
    SubWS -. "inline versions kept\n(reverted per ae48c71)" .-> SubWS
Loading

Reviews (4): Last reviewed commit: "fix: revert CPI hand/lever to inline dep..." | Re-trigger Greptile

Comment on lines 12 to 20
[dependencies]
borsh = "1.5.7"
borsh-derive = "1.5.7"
solana-program = "3.0"
borsh.workspace = true
borsh-derive.workspace = true
solana-program.workspace = true
cross-program-invocatio-native-lever = { path = "../lever", features = ["cpi"] }

[lib]
crate-type = ["cdylib", "lib"]

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 Workspace references in a non-root workspace member

The hand and lever programs live inside their own isolated sub-workspace declared at basics/cross-program-invocation/native/Cargo.toml, which has no [workspace.dependencies] section. Every borsh.workspace = true, borsh-derive.workspace = true, solana-program.workspace = true, litesvm.workspace = true, etc. added here will resolve against that local workspace, not the root workspace. Because the local workspace defines no [workspace.dependencies], Cargo will error: `workspace.borsh` was not found in the root manifest's `workspace.dependencies`. Building the CPI native example directly (or any CI job that targets it) will fail. Either add the needed entries to basics/cross-program-invocation/native/Cargo.toml's [workspace.dependencies], or keep the versions inline for these two crates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted in commit ae48c71hand and lever are back to inline dep versions (borsh = "1.6.1", solana-program = "4.0") since their isolated sub-workspace at basics/cross-program-invocation/native/Cargo.toml has no [workspace.dependencies] section.

Comment on lines +13 to +16
borsh.workspace = true
borsh-derive.workspace = true
solana-program.workspace = true
solana-system-interface.workspace = 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 Same sub-workspace issue as hand

lever is also a member of basics/cross-program-invocation/native/Cargo.toml (not the root workspace). All four *.workspace = true references here (borsh, borsh-derive, solana-program, solana-system-interface) will fail to resolve for the same reason described on hand/Cargo.toml.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as hand — reverted to inline deps in ae48c71.

Comment on lines +30 to +32
street,
city,
}),

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 isSigner flipped for target account

The target account changed from isSigner: false to isSigner: true. If target is a program-derived address, the runtime will reject the transaction because PDAs cannot provide a traditional signature. If target is a regular keypair, the transaction must include that keypair as a signer — but this change is unrelated to the stated scope of this PR (workspace dep migration), and the realloc test files were not updated to supply the extra signature. Please confirm the intended semantics and update the test accordingly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

target here is a regular keypair (not a PDA), so isSigner: true is correct — SystemProgram.createAccount requires the new account to co-sign the transaction. The test already supplies the signature on line 35: tx.add(ix).sign(payer, testAccount).

@NikkiAung

Copy link
Copy Markdown
Contributor Author

Thanks for the review @greptile-apps!

CPI hand/lever — fixed in the latest push (commit d801098). Those programs live in basics/cross-program-invocation/native/ which is its own sub-workspace with no [workspace.dependencies], so I've reverted them back to inline versions.

realloc/native/ts/instructions/create.ts — this change is not part of this PR. The isSigner: true fix for the target account is in a separate PR (#631) that was already opened before this branch was created. This PR only touches Cargo.toml files and the root Cargo.toml.

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Thanks for the clarification on both points!

CPI hand/lever — confirmed, the revert in d801098 looks correct. basics/cross-program-invocation/native/ has its own root [workspace] table without a [workspace.dependencies] section, so .workspace = true would fail to resolve there. Keeping those deps inline is the right call.

realloc/native/ts/instructions/create.ts — understood, that's tracked in #631. No action needed here.

The PR looks good from a correctness standpoint. Once CI confirms cargo metadata --no-deps resolves cleanly across all 28 affected members, this should be ready to merge.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@dev-jodee dev-jodee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

needs signed commits

@NikkiAung
NikkiAung force-pushed the feat/workspace-dev-deps branch from d801098 to ae48c71 Compare July 21, 2026 00:40
@NikkiAung

Copy link
Copy Markdown
Contributor Author

@dev-jodee All commits have been re-signed with an SSH signing key and now show as Verified on GitHub. Thanks for the heads up!

NikkiAung and others added 2 commits July 24, 2026 17:35
Replace inline-pinned `[dev-dependencies]` versions with `.workspace = true`
across all 28 native, pinocchio, and asm Cargo.toml files under `basics/`.
Also adds `solana-rent` and `solana-transaction-error` to the root
`[workspace.dependencies]`, and migrates the CPI hand/lever programs'
inline `[dependencies]` (borsh, solana-program) to workspace references.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
basics/cross-program-invocation/native/ is its own sub-workspace with
no [workspace.dependencies], so .workspace = true fails to resolve
for hand and lever. Keep their deps inline.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NikkiAung
NikkiAung force-pushed the feat/workspace-dev-deps branch from ae48c71 to 7b5a98d Compare July 25, 2026 00:36
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.

2 participants