From 67011c220185fb54a54d44b178d5bc12738741fa Mon Sep 17 00:00:00 2001 From: GraveYield Date: Thu, 14 May 2026 14:52:26 +0800 Subject: [PATCH] chore(m3): address CodeRabbit CHANGELOG nits + add CI anchor build log artifact Two follow-ups from PR #15's review and post-merge investigation: 1. CHANGELOG.md fixes (CodeRabbit's 2 minor findings on PR #15): - "init_if_needed Anchor feature" added section rewritten to describe the Anchor 0.32-compatible lazy init via manual create_account CPI that actually shipped (PR #15's design replaced PR #12's init_if_needed approach to satisfy Anchor 0.32's "Cannot use init on SystemAccount" check). - "lp_holder_pool_vault migrated to SystemAccount" entry split into two cases: claim_lp_proceeds gets SystemAccount (read-only, safe under 0.32); salvage_pool gets UncheckedAccount + manual CPI. - Verification status section updated to reflect locally-passed checks (fmt, clippy, 20/20 tests, BPF compile) plus the known CI anchor build failure being tracked. 2. CI workflow gains an artifact upload on anchor build failure. The anchor build step now tees stdout/stderr to /tmp/anchor-build.log, and on failure that file is uploaded as a workflow artifact via actions/upload-artifact@v4. Needed because the Composio integration this repo uses for programmatic CI inspection does not expose log download endpoints; the only way to see the actual anchor build error message has been the GitHub Actions web UI. After this PR merges and a future CI run fails on anchor build, the log artifact can be downloaded for offline diagnosis. No source changes. No on-chain semantics change. --- .github/workflows/ci.yml | 17 +++++++++++++++- CHANGELOG.md | 43 +++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc14321..08336ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,8 +69,23 @@ jobs: uses: cargo-bins/cargo-binstall@main - name: Install Anchor CLI run: cargo binstall --no-confirm --version ${ANCHOR_VERSION} anchor-cli + # Capture anchor build's full output to a file and upload it as a + # workflow artifact when the job fails — needed because the actual + # error message is otherwise only visible via the GitHub Actions + # web UI logs page (the Composio integration this repo uses for + # programmatic CI inspection does not expose log download). - name: Anchor build - run: anchor build + run: | + set -o pipefail + anchor build 2>&1 | tee /tmp/anchor-build.log + - name: Upload anchor build log on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: anchor-build-log + path: /tmp/anchor-build.log + if-no-files-found: warn + retention-days: 7 ts-typecheck: name: pnpm typecheck diff --git a/CHANGELOG.md b/CHANGELOG.md index a98a93d..bc073c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,10 +31,16 @@ distribution (m7) remain honest-stubbed and explicitly marked. - **Error 6019 `CertTtlBelowMinimum`** on GraveScanner. Raised by `initialize` and `update_protocol_config` when a `cert_ttl_seconds` parameter falls below `MIN_CERT_TTL_SECONDS`. -- **`init_if_needed` Anchor feature** on `programs/grave-vault/Cargo.toml` - for the `lp_holder_pool_vault` SystemAccount. First salvage of a pool - creates the 0-data system-owned PDA; subsequent salvages of the same - pool are gated upstream by the `pool_registry` init constraint. +- **Anchor 0.32-compatible lazy vault init** for `lp_holder_pool_vault` in + `salvage_pool`. Anchor 0.32 rejects `init` / `init_if_needed` on + `SystemAccount` by design; PR #12's original approach is replaced with + a manual `anchor_lang::system_program::create_account` CPI issued by + the handler when `vault.lamports() == 0`. First salvage of a pool + creates the 0-data system-owned PDA via the CPI (signed with the PDA + bump); subsequent salvages of the same pool are still blocked at the + `pool_registry` init constraint, so the lazy creation only matters on + the first call. Net on-chain semantics are identical to the original + `init_if_needed` design. #### Changed @@ -51,11 +57,14 @@ distribution (m7) remain honest-stubbed and explicitly marked. now handles the 8-byte discriminator check and owner-program (`grave_scanner::ID`) validation automatically; the previous manual ownership require! is redundant and removed. -- **`lp_holder_pool_vault`** in both `salvage_pool` and `claim_lp_proceeds` - migrated from `UncheckedAccount<'info>` to `SystemAccount<'info>`. In - `salvage_pool` the constraint adds `init_if_needed` + `space = 0`. The - account remains charter-invariant unsweepable; only `claim_lp_proceeds` - may debit it (against a valid Merkle proof, m6+). +- **`lp_holder_pool_vault`** in `claim_lp_proceeds` migrated from + `UncheckedAccount<'info>` to `SystemAccount<'info>` (read-only path, + no `init` constraint — safe under Anchor 0.32). In `salvage_pool` the + account is declared as `UncheckedAccount<'info>` with `mut, seeds, + bump` (PDA validation only) and lazy-initialized via the manual CPI + described above. The account remains charter-invariant unsweepable; + only `claim_lp_proceeds` may debit it (against a valid Merkle proof, + m6+). - **`evaluate_pool_phase_2`** now reads `cfg.cert_ttl_seconds` from ProtocolConfig instead of the hardcoded const when stamping `cert.expires_at`. @@ -77,9 +86,19 @@ distribution (m7) remain honest-stubbed and explicitly marked. #### Verification status -- `cargo check`: not yet run in this sandbox — pending Seth's - ship-now-vs-verify-first call. v1.0.7 will be the post-verification - patch with any compile fixes named in the CHANGELOG. +Locally verified on the official Solana 3.x stack (rust 1.91.1, anchor +0.32.1, solana 3.0.10, platform-tools v1.54): + +- `cargo fmt --all -- --check`: clean +- `cargo clippy --workspace --all-targets -- -D warnings`: clean +- `cargo test --workspace --lib`: **20/20 pass** (19 grave-scanner + 1 + grave-vault) +- `cargo-build-sbf --tools-version v1.54`: BPF compile clean in ~51s + +CI `anchor build` job is currently failing at the post-cargo-build-sbf +phase (anchor's IDL generation step) — investigation tracked in a +follow-up patch. The local cargo-build-sbf compile of both programs +succeeds, so the deployable BPF artifact is unaffected. #### Pre-mainnet checklist