Skip to content

Move Anchor v2 examples to 2.0.0-rc.4 - #215

Merged
mikemaccana merged 9 commits into
mainfrom
anchor-v2-rc4
Nov 15, 2026
Merged

mikemaccana merged 9 commits into
mainfrom
anchor-v2-rc4

Conversation

@mikemaccana

@mikemaccana mikemaccana commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Moves all 56 Anchor v2 examples (anchor/ directories) from 2.0.0-rc.2 to 2.0.0-rc.4. The anchor-v1/ copies are unchanged. CI builds and tests all 56 projects (496 tests), and every workflow passes.

Versions

  • anchor-lang / anchor-spl → 2.0.0-rc.4; anchor-v2-testing → 2cdb58ba (the v2.0.0-rc.4 tag). wincode stays on 0.6.
  • The root Cargo.lock records the same: anchor-lang, anchor-spl and anchor-derive-accounts at 2.0.0-rc.4, anchor-v2-testing at 2cdb58ba.
  • The Anchor v2 workflow installs anchor-cli 2.0.0-rc.4.

rc.3 breaking changes

  • #[account(unsafe(dup))] is removed (anchor#5091). token-minter, transfer-tokens and transfer-switch use #[account(mut)], because Signer/SystemAccount/UncheckedAccount alias freely. A mutable account in two data slots now fails with AccountBorrowFailed, so the escrow and options same-account tests expect that error.
  • remaining_accounts() is infallible and returns &[AccountView], so I dropped the ? at all 11 call sites.

rc.4 changes missing from Anchor's changelog

rc.4's changelog lists only TypeScript changes, but it also ships anchor#5185 (allocator-free v2 public API) and anchor#4891:

  • No Box accounts. I unboxed 245 fields. CI shows no stack-frame warnings across the 56 programs.
  • Interface<'static, T> → Interface<T> (81 fields).
  • CpiContext::<_, N>. N is the CPI's account capacity and can't be inferred, so I set N to the struct's field count at all 176 calls. transfer-fee's harvest now caps sources at MAX_HARVEST_SOURCES (16) with a new TooManyHarvestSources error, and has a test for it.
  • declare_program! CPI functions take a FixedVec data buffer onchain. hand supplies one, caps name at MAX_NAME_LEN (32) with NameTooLong, and tests 32 and 33 bytes.
  • No onchain Instruction. The compression examples use a local OwnedInstruction that implements CpiInstruction.
  • load_mut is safe, so order-book drops its unsafe blocks.

Docs

The CHANGELOG, docs/anchor-v2-migration.md (new "Duplicate Accounts Fail Through Borrows" section, plus the API changes above), READMEs and CONTRIBUTING are all updated. Comments about boxing are removed.

The finance plugin's Anchor v2 guide is updated to match in quicknode/solana-finance-claude-plugin#94.

https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB
https://claude.ai/code/session_01GZHin4a7zmaQg8n7Dv4BAP

- anchor-lang and anchor-spl 2.0.0-rc.2 -> 2.0.0-rc.4 in all 56 anchor/ projects;
  anchor-v2-testing pinned to 2cdb58ba (the v2.0.0-rc.4 tag).
- Anchor v2 workflow installs anchor-cli 2.0.0-rc.4.
- rc.3 removed #[account(unsafe(dup))]: token-minter, transfer-tokens and
  transfer-switch use #[account(mut)] on the aliasing Signer/UncheckedAccount fields.
- rc.3 made remaining_accounts() infallible and it returns &[AccountView]:
  drop the `?` at all eleven call sites; transfer-fee's harvest copies with .to_vec().
- Docs, READMEs, migration guide and CHANGELOG name rc.4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB
claude and others added 8 commits November 14, 2026 16:30
rc.4 removed Box<T>'s AnchorAccount impl (anchor#5185) and the lifetime
parameter on Interface (anchor#4891).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB
rc.4's CpiContext takes a const N, the number of accounts the CPI passes
(anchor#5185). harvest_withheld_tokens_to_mint takes its sources as a slice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB
- compression: hand-built Bubblegum CPIs use a local OwnedInstruction that
  implements CpiInstruction; rc.4 no longer re-exports Instruction onchain.
- cross-program-invocation: supply the FixedVec data buffer the generated
  switch_power CPI takes onchain, cap `name` at MAX_NAME_LEN with a
  NameTooLong error, and test both sides of the limit.
- transfer-fee: harvest's CpiContext holds the mint plus MAX_HARVEST_SOURCES
  token accounts; more fail with TooManyHarvestSources, tested.
- escrow, options: a mutable account in two slots now fails with
  AccountBorrowFailed rather than ConstraintDuplicateMutableAccount.
- Remove comments and README notes about boxed accounts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB
The declare_program! CPI function takes `String` on the host and `&str`
onchain. CHANGELOG and docs/anchor-v2-migration.md describe unboxed
accounts, CpiContext capacities, declare_program! data buffers,
OwnedInstruction and the safe load_mut.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB
anchor-lang, anchor-spl and anchor-derive-accounts move from 2.0.0-rc.2 to
2.0.0-rc.4, and anchor-v2-testing to the v2.0.0-rc.4 tag revision 2cdb58ba.

Claude-Session: https://claude.ai/code/session_01GZHin4a7zmaQg8n7Dv4BAP
@mikemaccana
mikemaccana merged commit d4c68c7 into main Nov 15, 2026
46 checks passed
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