feat: Expose AIR column names#2771
Conversation
Defines `ColumnsAir<F>` in `openvm-circuit-primitives` for column-name introspection. Wraps it with stark-backend's `AnyAir` into `AnyAirWithColumns` (and `AirRefWithColumns`), which `AirInventory` and `SystemAirInventory::into_airs` now use; trait upcasting (Rust 1.86+) handles the boundary back to `AirRef<SC>` at the few call sites that need a stark-backend-shaped `AirRef`. Implements `ColumnsAir` (and adds `StructReflection` derives, via the crates.io `struct-reflection` crate) on every AIR and column struct in the workspace. With the trait owned by OpenVM, stark-backend no longer needs to define it; the dependency is repointed to the `v2-powdr-beta.2-remove-columns-air` fork branch. Collects the ColumnsAir portion of original commits 449db83, 9a25af6, and 8a5d23a so the trait introduction can be cherry-picked upstream cleanly.
Each side independently falls back to synthesized `adapter[i]` / `core[i]` placeholders when its `columns()` returns None, then the two are concatenated. The previous match on (adapter, core) had four branches that did the same thing in a less direct way.
|
|
||
| impl<F: Field> BaseAirWithPublicValues<F> for FieldExpr {} | ||
| impl<F: Field> PartitionedBaseAir<F> for FieldExpr {} | ||
| impl<F: Field> ColumnsAir<F> for FieldExpr {} |
There was a problem hiding this comment.
Note that we didn't bother implementing it for AIRs we don't build autopecompiles for. This keeps the default implementation, which returns None.
| } | ||
|
|
||
| impl<const CHUNK: usize, F: Field> PartitionedBaseAir<F> for MemoryMerkleAir<CHUNK> {} | ||
| impl<const CHUNK: usize, F: Field> ColumnsAir<F> for MemoryMerkleAir<CHUNK> { |
There was a problem hiding this comment.
Note that it would be possible to reduce these types of changes using a macro, but it becomes a bit ugly, especially in the presence of const generics.
See this discussion: powdr-labs#60 (comment)
ColumnsAir trait and implement it everywhereReplaces hand-written `impl ColumnsAir<F>` blocks that delegate to `StructReflectionHelper::struct_reflection` with `#[derive(ColumnsAir)]` plus `#[columns_via(ColsTy<F, ...>)]`. Net -143 lines across 38 sites. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Updates the derive macro to skip injecting `F: Field` when the struct
already has an `F` type generic, then converts ~75 hand-written empty
`impl ColumnsAir<F> for X {}` blocks to `#[derive(ColumnsAir)]`.
Skips:
- VmAirWrapper (custom body delegating to adapter/core)
- WhirFoldingAir (uses an `F` type alias rather than a generic)
- ExpBitsLenAir (`BaseAir<F>` impl requires `F: PrimeField32`,
not implied by the macro's default `F: Field`)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds #[columns_via(...)] to the 6 #[derive(ColumnsAir)] sites whose matching XxxCols struct already implements StructReflectionHelper (directly or via #[derive(StructReflection)]). Also adds #[derive(StructReflection)] to CanonicityAuxCols and DeferralCallCoreCols so the deferral call core air can use it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The derive macro now errors at compile time if `#[columns_via(...)]` is missing. Each AIR using the derive declares its column struct; AIRs without a usable column struct keep a one-line manual impl. Cascading `#[derive(StructReflection)]` was added to several PVs/cols types (`MerkleTreeCols`, `VerifierBasePvs`, `VmPvs`, `DeferralPvs`, `DeferralCircuitPvs`, `DeferralAggregationPvs`, `VkCommit`, `VerifierDefPvs`, `DeferralCallAdapterCols`). Cols whose contents include external types without reflection (e.g. wrappers around `Poseidon2SubCols`) get a manual `StructReflectionHelper` returning `None` so `columns_via` still applies uniformly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I implemented the macro per powdr-labs#60 (comment), but Claude has been annoying to navigate on this large diff. I'll do a review pass myself and am marking the PR as draft until then. |
|
OK, should be clean now! |
|
Please mention in PR description / docs that default implementation is always safe, since this is just for labeling purposes. Going to wait till @shuklaayush is back to review it, but overall I feel like the new macro makes it pretty clean |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
@claude review |
|
Claude finished @shuklaayush's task in 2m 34s —— View job PR Review:
|
e11f786
into
openvm-org:develop-v2.0.0-rc.1
…named files Upstream #2771 (e11f786) introduced the ColumnsAir trait as required for all AIRs and added StructReflection to corresponding Cols structs. During the rebase, the -X theirs strategy dropped these additions for files our rv64 branch had renamed (Rv32* -> Rv64*) or otherwise modified. Re-applies the derive macros and #[columns_via(...)] attributes so the workspace builds against develop-v2.0.0-rc.1.
…named files Upstream #2771 (e11f786) introduced the ColumnsAir trait as required for all AIRs and added StructReflection to corresponding Cols structs. During the rebase, the -X theirs strategy dropped these additions for files our rv64 branch had renamed (Rv32* -> Rv64*) or otherwise modified. Re-applies the derive macros and #[columns_via(...)] attributes so the workspace builds against develop-v2.0.0-rc.1.
…named files Upstream #2771 (e11f786) introduced the ColumnsAir trait as required for all AIRs and added StructReflection to corresponding Cols structs. During the rebase, the -X theirs strategy dropped these additions for files our rv64 branch had renamed (Rv32* -> Rv64*) or otherwise modified. Re-applies the derive macros and #[columns_via(...)] attributes so the workspace builds against develop-v2.0.0-rc.1.
This PR introduces the `ColumnsAir` trait and makes it required by all AIRs. Via this trait, AIRs can (optionally) provide a list of column names. At powdr, we use this to generate (somewhat) human-readable autoprecompiles for OpenVM ([example](https://github.com/powdr-labs/powdr/blob/main/openvm-riscv/tests/apc_snapshots/complex/rotate.txt)). Unfortunately, this touches all AIRs and therefore a lot of files, but the changes are small and now change to `stark-backend` are needed. This change represents most of our [diff to OpenVM](https://github.com/openvm-org/openvm/compare/v2.0.0-beta.2...powdr-labs:openvm:v2-powdr-beta.2-reorganized?expand=1). --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This PR introduces the `ColumnsAir` trait and makes it required by all AIRs. Via this trait, AIRs can (optionally) provide a list of column names. At powdr, we use this to generate (somewhat) human-readable autoprecompiles for OpenVM ([example](https://github.com/powdr-labs/powdr/blob/main/openvm-riscv/tests/apc_snapshots/complex/rotate.txt)). Unfortunately, this touches all AIRs and therefore a lot of files, but the changes are small and now change to `stark-backend` are needed. This change represents most of our [diff to OpenVM](https://github.com/openvm-org/openvm/compare/v2.0.0-beta.2...powdr-labs:openvm:v2-powdr-beta.2-reorganized?expand=1). --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This PR introduces the
ColumnsAirtrait and makes it required by all AIRs. Via this trait, AIRs can (optionally) provide a list of column names. At powdr, we use this to generate (somewhat) human-readable autoprecompiles for OpenVM (example).Unfortunately, this touches all AIRs and therefore a lot of files, but the changes are small and now change to
stark-backendare needed.This change represents most of our diff to OpenVM.