Repository navigation
ci(ed25519-vectors): guard differential-vector drift (#1008) - #1075
Conversation
The on-chain Ed25519Verifier must stay at least as strict as the ed25519-dalek verify_strict deCDN nodes run off-chain (#669); committed differential vectors in Ed25519Verifier.t.sol / CapacityBondRegionE2E.t.sol pin that parity. Nothing verified the pin survived a dependency change, and the generator is a version-isolated workspace, so drift could go unnoticed until a runtime vector mismatch. Two ways it can drift, two guards: - Freshness: a new CI job 'ed25519-vectors' reruns the generator and fails on any diff. Generator gains a '--write' mode that splices both blocks in place between the markers (replacing the error-prone manual copy-paste); forge fmt owns final formatting, so write+fmt is idempotent when in sync. - Version parity: a pure-Rust test (crates/incentive/tests/ed25519_pin_parity.rs) asserts the generator's pinned ed25519-dalek/curve25519-dalek match the versions decdn-incentive resolves. It reads both committed lockfiles directly (the root lock version-qualifies the incentive dep edge), so no cargo metadata subprocess; runs in the existing 'test' job. Also adds the generator Cargo.lock to the 'rust' path filter so a lock-only bump triggers the parity test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThe Ed25519 vector generator now writes regenerated Solidity blocks into committed tests, CI reruns and diffs those outputs, and a Rust test checks lockfile version parity between the node and generator workspaces. README and generated comments were updated to match. ChangesEd25519 vector regeneration and CI parity enforcement
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant CI as CI workflow
participant Job as ed25519-vectors
participant Generator as main.rs
participant Repo as committed .t.sol files
CI->>Job: trigger on Rust or Solidity changes
Job->>Generator: cargo run --locked -- --write
Generator->>Repo: update generated Solidity blocks
Job->>Repo: forge fmt + git diff --exit-code
Repo-->>Job: diff status
Job-->>CI: pass or fail
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 91.52% (2320/2535 lines) |
There was a problem hiding this comment.
Code Review
This pull request automates the regeneration of Ed25519 test vectors and introduces a pin-parity guard to prevent version drift. Specifically, the ed25519-vectors generator has been updated with a --write flag to splice generated Solidity code directly into the test files in place. Additionally, a new integration test ed25519_pin_parity.rs has been added to assert that the ed25519-dalek and curve25519-dalek versions used by the node match those pinned by the generator. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Coverage reportTotal: 81.99% (was 81.99%, ● 0.00%) — 42467/51797 lines No coverage data for changed Rust files. History
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/ci.yml (1)
575-615: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueConsider adding an explicit
permissions:block.Other jobs in this workflow (e.g.
changes,solidity-fmt) explicitly scope permissions or rely on defaults understood at the workflow level; this new job has no explicitpermissions:block, so it inherits whatever the default token scope is. Since it only needs read access to check out and diff, scoping tocontents: readwould tighten least-privilege posture.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/ci.yml around lines 575 - 615, Add an explicit permissions block for the ed25519-vectors job so it does not inherit broader default token scope. Update the workflow job definition for ed25519-vectors to declare only the access it needs, using contents: read, and keep the rest of the job behavior unchanged (checkout, cargo run, forge fmt, and git diff).crates/incentive/tests/ed25519_pin_parity.rs (1)
20-155: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffTest uses
panic!/expectthroughout, contrary to the blanket**/*.rsguideline.The repo-wide guideline says not to use
unwrap/expect/panic!; this file uses them extensively (via#![allow(clippy::expect_used, clippy::panic)]) to fail loudly on a malformed/missing lockfile. This is test-only code operating on local committed files (not network/peer-facing), and the comment cites an existing precedent (sighup_signal.rs), so the practical risk is low — flagging for awareness rather than blocking.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/incentive/tests/ed25519_pin_parity.rs` around lines 20 - 155, This test file intentionally allows panic/expect usage to fail loudly on malformed or missing committed lockfiles, but it should still be kept narrowly scoped and documented against the repo-wide no-unwrap guideline. Review the helper functions in ed25519_pin_parity.rs, keep the existing test-only allowlist tied to the lockfile checks, and if possible replace any remaining broad panic/expect patterns in read_lock, dep_version, sole_version, find_pkg, and find_pkg_by_name with explicit assertions or clearer failure paths while preserving the hard-fail behavior for these local fixtures.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Line 587: The checkout step currently uses the default credential persistence
behavior, which leaves the GITHUB_TOKEN in .git/config even though this job only
reads the repo and runs local diffs. Update the actions/checkout usage in the CI
workflow to disable credential persistence by setting persist-credentials to
false on the checkout step so later steps cannot expose the token.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 575-615: Add an explicit permissions block for the ed25519-vectors
job so it does not inherit broader default token scope. Update the workflow job
definition for ed25519-vectors to declare only the access it needs, using
contents: read, and keep the rest of the job behavior unchanged (checkout, cargo
run, forge fmt, and git diff).
In `@crates/incentive/tests/ed25519_pin_parity.rs`:
- Around line 20-155: This test file intentionally allows panic/expect usage to
fail loudly on malformed or missing committed lockfiles, but it should still be
kept narrowly scoped and documented against the repo-wide no-unwrap guideline.
Review the helper functions in ed25519_pin_parity.rs, keep the existing
test-only allowlist tied to the lockfile checks, and if possible replace any
remaining broad panic/expect patterns in read_lock, dep_version, sole_version,
find_pkg, and find_pkg_by_name with explicit assertions or clearer failure paths
while preserving the hard-fail behavior for these local fixtures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9cea586f-b7da-4cc7-8f1e-4799218feeb1
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!**/*.lock
📒 Files selected for processing (7)
.github/workflows/ci.ymlcontracts/test/CapacityBondRegionE2E.t.solcontracts/test/Ed25519Verifier.t.solcontracts/test/ed25519-vectors/README.mdcontracts/test/ed25519-vectors/src/main.rscrates/incentive/Cargo.tomlcrates/incentive/tests/ed25519_pin_parity.rs
This job only regenerates + diffs vectors locally and never pushes; with no automated releases from CI, the GITHUB_TOKEN need not persist in .git/config. Set persist-credentials: false (zizmor artipacked), with a comment documenting the rationale. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Resolve conflict in contracts/test/CapacityBondRegionE2E.t.sol: main (#1078) inserted REG_TERMS_HASH inside the AUTO-GENERATED ed25519-vector marker block. That block is now generator-authoritative (freshness CI job regenerates it and fails on any diff), and termsHash is not part of the ed25519 ownership digest, so REG_TERMS_HASH is moved just below the END AUTO-GENERATED frame. The block's regen comment keeps the PR's '--write' wording that the generator emits. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… parse (#1081) Follow-up robustness hardening to the drift guard added in #1075. Neither fires in the normal CI/local workflow; both make a corrupt-input edge case fail loudly or parse correctly instead of silently misbehaving. - splice(): verify the line above/below each marker is actually a `// ===` frame before consuming it. A hand-edited .t.sol that lost a frame line (but kept the marker) previously had its first real line silently deleted; it now panics with a clear message. Also gives an accurate diagnostic when the END marker is the last line, replacing the misleading "markers out of order". - ed25519_pin_parity: take only the version token from a qualified Cargo.lock dependency edge, stripping any trailing ` (source)` suffix (present when a git/path override coexists with the registry copy) so it can't leak into the version string and cause a spurious mismatch. Verified: --write + forge fmt stays idempotent, the parity test still passes and still trips on a simulated pin drift, and the new frame check panics on a frame-stripped file. fmt/clippy clean. Co-authored-by: Claude Opus 4.8 <[email protected]>
What & why
Closes #1008. The on-chain
Ed25519Verifiermust stay at least as strict ased25519-dalek::verify_strict— the check deCDN nodes run off-chain (#669). Committed differential vectors inEd25519Verifier.t.sol/CapacityBondRegionE2E.t.solpin that parity, but nothing verified the pin survived a dependency change, and the generator (contracts/test/ed25519-vectors) is a version-isolated workspace with its own=-pinnedCargo.lock. So drift could go unnoticed until a runtime vector mismatch.There are two independent drift vectors, so two guards:
ed25519-vectorsreruns the generator +forge fmtand fails on any diffdecdn-incentiveresolvesChanges
contracts/test/ed25519-vectors/src/main.rs— new--writemode: splices both blocks into the.t.solfiles between theAUTO-GENERATEDmarkers, replacing the error-prone manual copy-paste.forge fmtowns final formatting, so--write+forge fmtis idempotent when in sync. Default (no args) still prints to stdout.crates/incentive/tests/ed25519_pin_parity.rs(new) — pure-Rust parity test. Reads both committed lockfiles withtoml(the root lock version-qualifiesdecdn-incentive's dep edge ased25519-dalek 2.2.0, so nocargo metadatasubprocess). Runs in the existingtestjob..github/workflows/ci.yml— freshness jobed25519-vectors(wired intoci-successneeds/allowed-skips); generatorCargo.lockadded to therustpath filter so a lock-only bump triggers the parity test.crates/incentive/Cargo.toml,Cargo.lock—tomldev-dep (one lockfile line).contracts/test/ed25519-vectors/README.md— documents--write+ the CI enforcement..t.solfiles — comment-only changes (Source:marker line + REG regen note). No vector value changes.Verification
git difffails.--write+forge fmtidempotent (only the intended comment diffs; re-running adds nothing).decdn-incentivesuite: 187 passed.clippy -D warnings+ workspacecargo fmt --checkclean.forge fmt --check+FOUNDRY_PROFILE=ci forge build --deny warnings+ the 20Ed25519Verifier/CapacityBondRegionE2Etests all pass. markdownlint clean.Reviewer notes
CapacityBondRegionE2E.t.sol) are in non-overlapping hunks (my comment is inside the marker block; feat(contracts): enforce Publisher and TokenHolder standing at appeal filing (audit I-3) (#1017) #1050 edits imports + constructor calls outside it), andCargo.lockoverlaps with chore(deps): bump alloy from 2.1.0 to 2.1.1 in the rust-dependencies group #1071/chore(deps): drop quick-xml RUSTSEC-2026-0194/0195 ignores; bump plist + crossbeam-epoch (#1056) #1072 are regenerable.// Reference:literal inmain.rsmust be updated by hand (self-consistent, so the freshness check can't catch it) — the parity test's failure message calls this out.🤖 Generated with Claude Code
Summary by CodeRabbit