Unbreak main: the perps v2 build, the Anchor install, and the Biome check - #130
Conversation
`perps: let the pool authority retune the funding rate` landed on main after the v2 port and was written against v1: `Context<T>` rather than `&mut Context<T>`, `Signer<'info>`, `Box<Account<'info, Pool>>`, and `has_one = authority`. The crate does not compile, so `anchor build` fails for the whole project and its 28 tests never run. Nothing caught it because `perpetual-futures` is not a root workspace member, so neither `cargo clippy` nor `cargo fmt --check` has ever seen the crate, and the Anchor workflow only builds projects a push actually touches. The port is the usual set: `&mut Context<T>`, the `'info` lifetime dropped, `Box<BorshAccount<Pool>>` to match every sibling handler, and `has_one` replaced by `address = pool.authority` on the signer. Two more things the crate needed, for the same reason nobody had looked at it: `#[instruction(side: Side)]` warns as an unused variable under v2's `#[derive(Accounts)]` expansion, so it takes the leading underscore the other examples use, and main's new lending and perpetual-futures test code was never formatted. `cargo check` and `cargo clippy -- -D warnings` are both clean on the crate now. The LiteSVM tests still need `cargo build-sbf` to produce the `.so` they embed, which CI does and this change does not affect.
|
Status on this branch: Rustfmt, Clippy, and all eight Kani proof jobs are green. The Anchor build-and-test job is still running, and it is the one that actually proves the fix. Biome check is red, and it is red on Both fixes are written and sitting on Generated by Claude Code |
…inary
The Anchor job died in its install step:
Error: No prebuilt binary found for version `2.0.0-rc.1` (HTTP 404).
Try `avm install 2.0.0-rc.1 --from-source`.
No project was built, and the summary step then failed to read a
failed_projects.txt that nothing had written. Earlier runs passed on a warm
toolchain cache, which skipped the install entirely and hid this; any run
that misses the cache hits it.
Taking avm's own suggestion. The source build is slow, and the existing cache
keyed on the version is what keeps it off the critical path after the first
run.
|
The Anchor job failed, but not on the code. It died in its install step before building anything: The summary step then failed to read a Taken avm's own suggestion in One consequence worth knowing: the Generated by Claude Code |
The TypeScript workflow runs `biome check ./`, which formats JSON as well as TypeScript. `anchor build` regenerated `basics/cross-program-invocation/anchor/idls/lever.json` with one array element per line, and Biome puts those on a single line, so the check has failed on every commit since the IDL was last regenerated. `main` is red on this today. Formatting only; the IDL's contents are unchanged, so `declare_program!` and the LiteSVM tests that read it see exactly what they saw before.
The previous commit's `avm install --from-source` was the wrong fix. avm
builds the CLI from the `v2.0.0-rc.1` git tag, which is not the same code as
the `anchor-lang` 2.0.0-rc.1 published on crates.io that every program here
compiles against. The CLI and the library disagreed about the IDL, and
`anchor build` failed across roughly half the projects for reasons that had
nothing to do with the projects:
error[E0405]: cannot find trait `IdlBuild` in crate `anchor_lang`
Error: missing field `variants` at line 1 column 15428
Both come from `anchor idl build`: the CLI emits a shim referencing a trait
the published crate does not have, and writes IDL JSON its own parser then
rejects.
crates.io publishes `anchor-cli` 2.0.0-rc.1 alongside the library, so
installing it there keeps the two on one release. avm is a version manager
and this workflow pins a single version, so it was not buying anything.
`--locked` builds the CLI against its own published lockfile so the result
does not drift with the registry.
The cache key changes with the install method, so a run cannot resurrect a
binary built the old way.
|
Correcting my earlier comment: avm builds the CLI from the Both come out of crates.io publishes The One thing worth flagging separately: Generated by Claude Code |
|
The sweep finished. Correcting my previous comment first: I claimed the Result: 9 of 55 projects fail, every one of them at
|
declares an IdlType enum |
does not | |
|---|---|---|
fails on variants |
7 | 0 |
| passes | 0 | 48 |
Every project in the repository that declares an enum with #[derive(..., IdlType, ...)] fails. No project without one does. The enums are unremarkable and varied: EventStatus (three unit variants), OrderSide/OrderStatus, AnchorField (three unit variants plus Key(String)).
The data cannot separate two explanations, and both matter for what to do next:
#[derive(IdlType)]on enums is broken in2.0.0-rc.1, in which case nothing here is wrong and the fix is an Anchor release.- v2 needs something alongside
IdlTypeon enums that all seven are missing, in which case it is one recipe change applied seven times.
Distinguishing them needs one anchor idl build run against a trivial enum, which I cannot do: release.anza.xyz is blocked by this session's egress proxy, so I cannot install Anchor or run the IDL build locally at all. Everything above is from CI plus a local census.
Why none of this was visible
idl-build is a Cargo feature nothing turns on except anchor idl build. cargo check, cargo clippy, cargo fmt and the Rustfmt/Clippy jobs are all structurally blind to code behind it, which is how order-book's IdlBuild impls survived the port. And anchor build had effectively stopped running: the workflow only builds projects a push touches, and its toolchain install has been broken behind a cache that hid it. This run is the first full sweep in a long time, which is why nine projects surfaced at once.
Suggestion
Land this PR for what it does fix, and track the IDL work separately. It fixes three things that are broken on main today and blocks nothing:
finance/perpetual-futuresno longer fails to compile. Its original error is gone; it now fails at the IDL stage alongside six unrelated projects, so it is no longer a perps-specific problem.- The Anchor workflow can install Anchor again.
maincannot right now. - Biome passes.
Merging leaves nine projects failing on anchor idl build, which is the same nine that would fail on main the moment its toolchain install is repaired. This PR does not cause them and does not make them worse.
Generated by Claude Code
mainis red in three independent ways. This PR fixes all three.1.
finance/perpetual-futuresdoes not compileplus eight more behind it, so
anchor buildfails for the whole project and its 28 tests never run.perps: let the pool authority retune the funding ratelanded onmainafter the Anchor v2 port and was written against v1:Context<T>rather than&mut Context<T>,Signer<'info>,Box<Account<'info, Pool>>, andhas_one = authority.Nothing caught it.
perpetual-futuresis not a root workspace member, so neithercargo clippynorcargo fmt --checkhas ever seen the crate, and the Anchor workflow only builds projects a push actually touches.The fix is the usual v2 port:
&mut Context<T>, the'infolifetime dropped,Box<BorshAccount<Pool>>to match every sibling handler, andhas_onereplaced byaddress = pool.authorityon the signer. Two more things the crate needed for the same reason nobody had looked at it:#[instruction(side: Side)]warns as an unused variable under v2's#[derive(Accounts)]expansion so it takes the leading underscore the other examples use, andmain's new lending and perps test code was never formatted.2. The Anchor workflow cannot install Anchor
Runs on
mainwere green only because they hit a warm toolchain cache and skipped the install entirely. That cache is gone, and the install underneath it does not work:avm has no prebuilt binary for this pre-release. Its
--from-sourcepath is not a substitute: it builds the CLI from thev2.0.0-rc.1git tag, which is not the same code as theanchor-lang2.0.0-rc.1 published on crates.io that every program here compiles against. I tried that first and it tookanchor builddown across half the repository withcannot find trait IdlBuild in crate anchor_langandmissing field variants, both out ofanchor idl build, on projects that have nothing wrong with them.crates.io publishes
anchor-cli2.0.0-rc.1 alongside the library, so the workflow now installs it from there with--lockedand drops avm. avm is a version manager and this workflow pins one version, so it was not earning its place. The cache key changes with the install method, so no run can resurrect a binary built the old way.3. Biome fails on a regenerated IDL
biome check ./formats JSON as well as TypeScript.anchor buildregeneratedbasics/cross-program-invocation/anchor/idls/lever.jsonwith one array element per line, and Biome puts those on a single line, so the TypeScript workflow has failed on every commit since. Formatting only; the IDL's contents are unchanged, sodeclare_program!and the LiteSVM tests that read it see what they saw before.Verification
Locally:
cargo check,cargo clippy -- -D warningsandcargo fmt --checkare clean onperpetual-futures; repository-widecargo fmt --all --checkandcargo clippy -- -D warnings -A clippy::diverging_sub_expressionpass;biome checkover the 155 tracked files CI sees reports zero errors.Because this touches
.github/workflows/anchor.yml, thechangesjob builds every Anchor project rather than the few this diff touches, so each run here is a full 55-project sweep.On the mismatched-CLI run,
perpetual-futuresgot past the compile error this PR exists to fix and died at the same IDL stage as everyone else, with noperpetual_futurescompile diagnostic anywhere in the log;escrowandlending, in the same group, built and tested clean. The sweep on the corrected toolchain is what will confirm it end to end.Relationship to #128
#128 carries the
perpetual-futuresfix as one commit among a ~100-file change that adds every Anchor program to the root workspace. Here it is on its own, so it can land without waiting on that review. The file contents are identical, so whichever merges second is a no-op for those hunks.The remaining known breakage, the ASM workflow's
cargo install --git .../sbpf.gitpicking between two binaries after upstream added anxtaskcrate, is not included here: ASM does not run on this PR, so it is not blocking. That fix sits onclaude/docs-match-implementation.