Skip to content

ci(ed25519-vectors): guard differential-vector drift (#1008) - #1075

Merged
alpergundogdu merged 3 commits into
mainfrom
fix/1008-ed25519-vector-ci-guard
Jul 9, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
fix/1008-ed25519-vector-ci-guard

Conversation

@yigitdot

@yigitdot yigitdot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Closes #1008. The on-chain Ed25519Verifier must stay at least as strict as ed25519-dalek::verify_strict — the check deCDN nodes run off-chain (#669). Committed differential vectors in Ed25519Verifier.t.sol / CapacityBondRegionE2E.t.sol pin 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 =-pinned Cargo.lock. So drift could go unnoticed until a runtime vector mismatch.

There are two independent drift vectors, so two guards:

Drift Guard
Generator or its pin changed without re-pasting → stale vectors Freshness — new CI job ed25519-vectors reruns the generator + forge fmt and fails on any diff
Node's dalek bumped but the generator's isolated pin not → silent parity drift (freshness passes green, verifier tested against a different dalek than the node runs) Version parity — Rust test asserts the generator's pins match what decdn-incentive resolves

Changes

  • contracts/test/ed25519-vectors/src/main.rs — new --write mode: splices both blocks into the .t.sol files between the AUTO-GENERATED markers, replacing the error-prone manual copy-paste. forge fmt owns final formatting, so --write + forge fmt is 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 with toml (the root lock version-qualifies decdn-incentive's dep edge as ed25519-dalek 2.2.0, so no cargo metadata subprocess). Runs in the existing test job.
  • .github/workflows/ci.yml — freshness job ed25519-vectors (wired into ci-success needs/allowed-skips); generator Cargo.lock added to the rust path filter so a lock-only bump triggers the parity test.
  • crates/incentive/Cargo.toml, Cargo.lock — toml dev-dep (one lockfile line).
  • contracts/test/ed25519-vectors/README.md — documents --write + the CI enforcement.
  • The two .t.sol files — comment-only changes (Source: marker line + REG regen note). No vector value changes.

Verification

  • Parity test passes in-sync; trips with a clear message on a simulated generator/node dalek mismatch.
  • Freshness rigorously proven: a staged stale vector is overwritten by regeneration → git diff fails.
  • Generator --write + forge fmt idempotent (only the intended comment diffs; re-running adds nothing).
  • decdn-incentive suite: 187 passed. clippy -D warnings + workspace cargo fmt --check clean.
  • Solidity gate: forge fmt --check + FOUNDRY_PROFILE=ci forge build --deny warnings + the 20 Ed25519Verifier/CapacityBondRegionE2E tests all pass. markdownlint clean.

Reviewer notes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a CI job that regenerates committed Ed25519 differential-vector Solidity tests and hard-fails if they’re out of date.
    • Added an automated “pin parity” test to ensure Ed25519 dependency versions match between on-chain verifier vectors and the generator.
  • Bug Fixes
    • Improved CI change detection so lockfile-only updates correctly trigger the Rust/verification pipeline.
  • Documentation
    • Expanded and clarified Ed25519 vector regeneration and version-bump instructions, including exact commands and CI enforcement behavior.

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]>
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 82ce6ba7-0c30-4123-a48b-64f202fc61f0

📥 Commits

Reviewing files that changed from the base of the PR and between 062387b and 3512804.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (1)
  • contracts/test/CapacityBondRegionE2E.t.sol
✅ Files skipped from review due to trivial changes (1)
  • contracts/test/CapacityBondRegionE2E.t.sol

Walkthrough

The 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.

Changes

Ed25519 vector regeneration and CI parity enforcement

Layer / File(s) Summary
Generator refactor and write mode
contracts/test/ed25519-vectors/src/main.rs
Builds Solidity output as strings, adds --write splicing, and generates the verifier and register-node blocks through marker-frame helpers.
Generated Solidity comment updates
contracts/test/Ed25519Verifier.t.sol, contracts/test/CapacityBondRegionE2E.t.sol
Updates generated-source comments and regeneration text to match the new cargo run -- --write flow.
CI regeneration and diff enforcement
.github/workflows/ci.yml
Treats the generator lockfile as Rust-relevant, adds the ed25519-vectors regeneration job, and includes it in ci-success.
Pin parity test and regeneration docs
crates/incentive/Cargo.toml, crates/incentive/tests/ed25519_pin_parity.rs, contracts/test/ed25519-vectors/README.md
Adds a lockfile-parity test with toml parsing support and documents the updated regeneration and version-bump workflow.

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
Loading

Suggested reviewers: alpergundogdu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly summarizes the CI guard for Ed25519 vector drift.
Linked Issues check ✅ Passed The PR adds CI regeneration checks and pin-parity testing that directly address #1008’s drift-prevention goal.
Out of Scope Changes check ✅ Passed The changes stay focused on Ed25519 vector freshness, parity, and related documentation and comments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1008-ed25519-vector-ci-guard

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 91.52% (2320/2535 lines)
▲ +0.00pp vs base (91.52% → 91.52%)
Run: 28918591825

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.99% (was 81.99%, ● 0.00%) — 42467/51797 lines

No coverage data for changed Rust files.

History
Commit Total Δ vs base
3e7f74a 82.11% ● 0.00%
3512804 (HEAD) 81.99% ● 0.00%

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/ci.yml (1)

575-615: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Consider 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 explicit permissions: block, so it inherits whatever the default token scope is. Since it only needs read access to check out and diff, scoping to contents: read would 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 tradeoff

Test uses panic!/expect throughout, contrary to the blanket **/*.rs guideline.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 36aafe6 and 3e7f74a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • contracts/test/CapacityBondRegionE2E.t.sol
  • contracts/test/Ed25519Verifier.t.sol
  • contracts/test/ed25519-vectors/README.md
  • contracts/test/ed25519-vectors/src/main.rs
  • crates/incentive/Cargo.toml
  • crates/incentive/tests/ed25519_pin_parity.rs

Comment thread .github/workflows/ci.yml Resolved
yigitdot and others added 2 commits July 7, 2026 21:03
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]>
@yigitdot
yigitdot requested a review from thiras July 8, 2026 17:38
@alpergundogdu
alpergundogdu merged commit b31952a into main Jul 9, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the fix/1008-ed25519-vector-ci-guard branch July 9, 2026 09:27
alpergundogdu added a commit that referenced this pull request Jul 9, 2026
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants