Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/anchor-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
# Install the CLI from crates.io rather than through avm, matching the
# Anchor v2 job. `cargo install --git ... avm` builds avm from the tip of
# anchor's main branch, so what CI installs drifts with whatever landed
# there. 1.2.1 is an ordinary published release — unlike the 2.0.0-rc.1
# there. 1.2.1 is an ordinary published release — unlike the 2.0.0-rc.2
# pre-release that forced the v2 job off avm — so the CLI comes straight
# from the registry. --locked builds it against its own published lockfile
# so the result does not drift with the registry either.
Expand Down
68 changes: 8 additions & 60 deletions .github/workflows/anchor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,25 @@ jobs:
path: |
~/.cargo/bin/anchor
# Pinned to match the anchor-lang/anchor-spl crate version the programs depend on.
key: anchor-cli-crates-io-${{ runner.os }}-2.0.0-rc.1
- name: Install Anchor 2.0.0-rc.1
key: anchor-cli-crates-io-${{ runner.os }}-2.0.0-rc.2
- name: Install Anchor 2.0.0-rc.2
run: |
export PATH="$HOME/.cargo/bin:$PATH"
# `anchor --version` can emit more than one line; read the first line only so
# a multi-line value never reaches downstream parsing.
current="$(anchor --version 2>/dev/null | head -n1 | awk '{print $2}' || true)"
if [ "$current" != "2.0.0-rc.1" ]; then
if [ "$current" != "2.0.0-rc.2" ]; then
# Install the CLI from crates.io rather than through avm. avm has no
# prebuilt binary for this pre-release (a plain `avm install` 404s), and
# its --from-source path builds the CLI from the git tag, which is not
# the same code as the published anchor-lang 2.0.0-rc.1 the programs
# the same code as the published anchor-lang 2.0.0-rc.2 the programs
# compile against: `anchor idl build` then emits a shim referencing
# `anchor_lang::IdlBuild`, which that crate does not have, and writes
# IDL JSON the parser rejects with "missing field `variants`".
# Installing the CLI from crates.io keeps it and the library on one
# published release. --locked builds it against its own published
# lockfile so the result does not drift with the registry.
cargo install anchor-cli --version 2.0.0-rc.1 --locked --force
cargo install anchor-cli --version 2.0.0-rc.2 --locked --force
fi
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Install Surfpool
Expand Down Expand Up @@ -275,69 +275,17 @@ jobs:
done
fi

# TEMPORARY WORKAROUND - delete this block and the `$idl_flag` and
# `$test_flag` below once an Anchor release after 2.0.0-rc.1 is out.
#
# anchor-derive-accounts 2.0.0-rc.1 emits enum type definitions with
# the JSON key "fields" where the IDL spec requires "variants", so
# `anchor build` cannot parse the IDL it just generated and dies
# with `Error: missing field variants`. Every project below has
# an enum reachable from its IDL and hits it. Reproduce with any
# program containing `#[derive(IdlType)] pub enum E { A, B }`.
#
# Fixed upstream, unreleased at time of writing:
# https://github.com/otter-sec/anchor/pull/4947
#
# Patching just the derive crate to that fix is not an option: it
# requires solana-address 2.7, and these programs pin
# `>=2.6, <2.7` because anchor-lang 2.0.0-rc.1 is built against
# wincode 0.5 while solana-address 2.7 moved to 0.6.
#
# Skipping IDL generation costs nothing today: none of these
# projects consumes a generated IDL (no `idls/` directory, no
# `declare_program!`). The program is still compiled and its tests
# still run.
#
# The skip also means `anchor test` must not start a validator for
# these projects. Surfpool 1.6 deploys the program at startup
# through a runbook that reads `target/idl/<program>.json`, and with
# no IDL it exits with `Runbook execution failed` before any test
# runs. None of these projects needs a validator: each one's
# Anchor.toml runs `cargo test`, which tests against LiteSVM
# in-process.
case "$project" in
./basics/pyth/anchor \
|./finance/betting-market/anchor \
|./finance/options/anchor \
|./finance/order-book/anchor \
|./finance/perpetual-futures/anchor \
|./finance/prop-amm/anchor \
|./tokens/token-extensions/default-account-state/anchor \
|./tokens/token-extensions/metadata/anchor \
|./tokens/token-extensions/transfer-hook/allow-block-list-token/anchor)
echo "::notice::skipping IDL generation for $project (anchor#4947)"
idl_flag="--no-idl"
test_flag="--skip-local-validator"
;;
*)
idl_flag=""
test_flag=""
;;
esac

# Run anchor build
if ! anchor build $idl_flag; then
if ! anchor build; then
echo "::error::anchor build failed for $project"
echo "$project: anchor build failed" >> $GITHUB_WORKSPACE/failed_projects.txt
rm -rf target node_modules
cd - > /dev/null
return 1
fi

# Run anchor test. It regenerates the IDL too, so the skip above
# has to apply here as well or the projects it exempts fail at the
# test step instead of the build step.
if ! anchor test $idl_flag $test_flag; then
# Run anchor test
if ! anchor test; then
echo "::error::anchor test failed for $project"
echo "$project: anchor test failed" >> $GITHUB_WORKSPACE/failed_projects.txt
rm -rf target node_modules
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solana-asm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ jobs:

# Install sbpf assembler from HEAD. HEAD emits SBPF v3 (0x03 OS-ABI)
# ELF, which requires litesvm >= 0.13 (Agave 4.0) to load; the
# workspace pins litesvm 0.13.1. If a future sbpf change breaks
# workspace pins litesvm 0.18.1. If a future sbpf change breaks
# loading, pin a revision here with --rev.
#
# The package name is required: the repository now also ships an
Expand Down
83 changes: 83 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,89 @@ All notable changes to this repository are documented here.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [2026-10-28] - Anchor v2 examples on Anchor 2.0.0-rc.2, sending v1 transactions

Anchor 2.0.0-rc.2's test harness, `anchor-v2-testing`, runs on LiteSVM 0.18, which
executes v1 transactions, and `solana-kite` 0.7.0 is built on the same LiteSVM line.
Together they let the Anchor v2 tests send v1 transactions, as the Anchor v1 tests
have since 2026-10-08. rc.2 needs `solana-instruction` 3.5, which LiteSVM 0.13.1's
exact `=3.2.0` pin rules out, so every crate in the root workspace moves to
LiteSVM 0.18 together.

### Changed

- All Anchor v2 examples move `anchor-lang` and `anchor-spl` from `2.0.0-rc.1` to
`2.0.0-rc.2`, `wincode` from 0.5 to 0.6, and `anchor-v2-testing` from revision
`3e38a121` to `a2066021`, the commit the `v2.0.0-rc.2` tag points at.
- The Anchor v2 tests move from `solana-kite` 0.4.0 to 0.7.0, so they send v1
transactions. Kite's senders and helpers take a new last argument,
`compute_unit_limit: Option<u32>`, and every call passes `None`: kite simulates
the transaction and sends it with the compute units the simulation used.
- `anchor-v2-testing` no longer re-exports `LiteSVM` at its root, so the tests
import `anchor_v2_testing::litesvm::LiteSVM`.
- The three Anchor v2 tests that build a transaction themselves (`hello-solana`,
`options` and `order-book`, to read logs or measure compute units) build it with
kite's `build_transaction_from_instructions` and `get_transaction_config`, with
`MAX_COMPUTE_UNIT_LIMIT` from `solana-compute-budget`, as their Anchor v1 copies do.
- The native, Pinocchio and ASM tests in the root workspace, and the standalone
`cross-program-invocation/native` and `escrow/native` workspaces, move from
LiteSVM 0.13.1 to 0.18.1, with `solana-transaction`, `solana-message`,
`solana-account` and `solana-pubkey` on the 4.x lines LiteSVM 0.18 uses. Their
tests still send legacy transactions.
- The Anchor v2 workflow installs and caches `anchor-cli 2.0.0-rc.2`. Every Anchor
v2 README, `CONTRIBUTING.md` and `docs/anchor-v2-migration.md` name rc.2.
- Fixes for what LiteSVM 0.18 and rc.2 changed under the examples:
- `basics/transfer-sol/asm` finds its instruction data from the system program
account's data length instead of a fixed offset. Agave 4.3 renamed that builtin
from `system_program` to `solana_system_program`, and the longer name moved the
instruction data 8 bytes. `checking-accounts/asm` already worked this way.
- LiteSVM 0.18 starts at a recent mainnet slot instead of slot 0, so the
`prop-amm` and `perpetual-futures` stale-price tests warp relative to the
current slot.
- `create-account/anchor`'s test reads the rent-exempt minimum from LiteSVM, which
the program reads too, rather than the SDK's `Rent::default()`.
- With anchor#4947 fixed, `pyth` and `order-book` build an IDL again. rc.2 needs
`IdlType` on `pyth`'s vendored Pyth types and `IdlAccountType` in place of the
removed `IdlBuild` on `order-book`'s slab types.
- `finance/managed-fund/anchor/app/src/idl/managed_fund.json` is regenerated with
`anchor idl build` from rc.2. rc.2 no longer writes `pda` for accounts whose
constraint names an explicit bump or an associated token, nor `address` for
`swap_router_program`; the app passes every account explicitly with
`accountsStrict`, so it uses neither, and `pnpm verify` and `pnpm typecheck`
pass. `basics/cross-program-invocation/anchor/idls/lever.json` regenerates
unchanged.
- The native token examples and the root workspace ask for `mpl-token-metadata`
`5.1.2-alpha.2` rather than exactly `=5.1.2-alpha.2`: a range that starts at the
pre-release still matches anchor-spl's exact pin. `finance/lending/quasar` asks
for `quasar-svm` `0.1.0` rather than `=0.1.0`, since quasar-test pins it exactly.
The resolved versions do not change.

### Added

- `basics/transaction-v1/anchor`: the Anchor v2 copy of the transaction v1 example.
- `solana-program-runtime = "~4.3"` and `solana-fee = "~4.3"` dev-dependencies in
every Anchor v2 crate and in `cross-program-invocation/native`. LiteSVM 0.18.1
asks for the Agave crates with `^4.3` ranges, so a fresh resolve picks Agave
4.4.0, released 2026-10-28, which LiteSVM 0.18.1 does not compile against. These
workspaces commit no lockfile, so every build resolves fresh. The two constraints
hold the Agave crates at 4.3 until a LiteSVM release builds against 4.4.

### Removed

- The `solana-address = ">=2.6, <2.7"` pin from the Anchor v2 manifests. rc.1 was
built against wincode 0.5 and solana-address 2.7 against 0.6; rc.2 is on 0.6 too.
The three compression examples keep a direct `solana-address` dependency for its
`borsh` feature.
- The Anchor v2 workflow's workaround for anchor#4947, which skipped IDL generation
for nine projects whose enums rc.1 wrote into the IDL under the wrong key. rc.2
carries the fix.

### Unchanged

- `tokens/token-extensions/transfer-hook/block-list/pinocchio` and
`tools/shank-and-codama/native` stay on LiteSVM 0.13.1. Each is its own
workspace, and each pins its test stack to the generation of its generated client.

## [2026-10-15] - Anchor v1 examples on Anchor 1.2.1

Anchor 1.2.1 is a patch release of the v1 line. Its one change is an opt-in
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See [CHANGELOG.md](./CHANGELOG.md) for release history. This file had no changel
- Each example lives at `category/example-name/<framework>/`, e.g. `basics/counter/anchor/`.
- Supported frameworks: `anchor`, `anchor-v1`, `quasar`, `pinocchio`, `native`, `asm`. Use the existing layout as a reference.
- `anchor-v1/` is Anchor v1 (1.2.1), the current stable Anchor. `anchor/` is the same example
on Anchor v2 (2.0.0-rc.1), the release candidate for the next major version, and is where new
on Anchor v2 (2.0.0-rc.2), the release candidate for the next major version, and is where new
Anchor work starts; the v1 copy tracks its v2 counterpart. A change to what an example does (a new handler, a new check, a
fix, a renamed field) goes into both copies, in the same pull request where practical, so a
v1 reader gets the same program and the same tests. The copies differ only where the Anchor
Expand All @@ -33,10 +33,10 @@ See [CHANGELOG.md](./CHANGELOG.md) for release history. This file had no changel

Run an example's tests with the command for its framework, from the framework directory (e.g. `basics/counter/anchor/`):

- **Anchor v2** (in `anchor/`): `anchor test` (runs `cargo test`, per the `[scripts]` table in `Anchor.toml`), with the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.1 --locked`.
- **Anchor v2** (in `anchor/`): `anchor test` (runs `cargo test`, per the `[scripts]` table in `Anchor.toml`), with the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked`.
- **Anchor v1** (in `anchor-v1/`): the same `anchor test`, with the v1 CLI: `avm install 1.2.1 && avm use 1.2.1`. Selecting the wrong CLI is the usual cause of a confusing build failure in these directories.
Anchor v1 tests send v1 transactions (4,096 bytes, resource limits in the message) through
`solana-kite` 0.6. Its senders take a last `compute_unit_limit: Option<u32>`: pass `None` and kite
Both Anchor copies' tests send v1 transactions (4,096 bytes, resource limits in the message)
through `solana-kite`: 0.6 for Anchor v1, 0.7 for Anchor v2. Its senders take a last `compute_unit_limit: Option<u32>`: pass `None` and kite
simulates the transaction and sends it with the compute units the simulation used. A test that needs the
transaction's metadata (logs, compute units, a program error code) builds it with kite's
`build_transaction_from_instructions` and sends it through LiteSVM itself. Kite rejects ComputeBudget
Expand Down
Loading
Loading