Skip to content

pow%refac: flesh out util:memops, magic blob reductions, move derivations to const expressions - #91

Merged
kwvg merged 14 commits into
dashpay:developfrom
kwvg:pow_cleanup
Oct 27, 2026
Merged

kwvg merged 14 commits into
dashpay:developfrom
kwvg:pow_cleanup

Conversation

@kwvg

@kwvg kwvg commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Additional Information

Breaking Changes

None expected

How Has This Been Tested?

just comb

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional tests
  • I have made corresponding changes to the documentation
  • I did not use agentic assistance (i.e. LLMs, AI) except as disclosed and can answer questions, comments and concerns without said assistance. I assume authorship of the code submitted.
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

Agent disclosure

Code generated with Claude Code using Opus 5.5, medium effort. Reviewed with Codex using GPT-6-Astra, extra high effort as adversarial review and Claude Code with Fable 5.1, xhigh effort.

@kwvg kwvg added this to the 0.2 milestone Oct 27, 2026
@kwvg kwvg self-assigned this Oct 27, 2026
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 96ab574 and d49f11d.

Files selected for processing: 16
  • pkgs/pow/src/blake.rs
  • pkgs/pow/src/consts/blake.rs
  • pkgs/pow/src/consts/cubehash.rs
  • pkgs/pow/src/consts/jh.rs
  • pkgs/pow/src/consts/keccak.rs
  • pkgs/pow/src/consts/luffa.rs
  • pkgs/pow/src/consts/shavite.rs
  • pkgs/pow/src/consts/skein.rs
  • pkgs/pow/src/echo.rs
  • pkgs/pow/src/jh.rs
  • pkgs/pow/src/keccak.rs
  • pkgs/pow/src/luffa.rs
  • pkgs/pow/src/shavite/common.rs
  • pkgs/pow/src/util/arx.rs
  • pkgs/pow/src/util/memops.rs
  • pkgs/pow/src/util/mod.rs
Files with no reviewable changes: 2
  • pkgs/pow/src/util/mod.rs
  • pkgs/pow/src/util/arx.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Refactor
    • Streamlined internal processing across several hashing algorithms while preserving their established behavior.
    • Simplified generation of algorithm constants and permutation tables.
  • Tests
    • Added checks that derived JH-512 and Skein-512 initialization values match known values.
  • Documentation
    • Clarified descriptions of algorithm constants and processing steps.

Hash message loading now uses shared multiword helpers in Blake-512, ECHO, and SHAvite. Compile-time tables and selected IVs are generated from formulas or hash-specific round functions. JH bit-group swaps and Luffa round operations use shared implementations. Several comments and constant descriptions were also revised.

Suggested reviewers: thepastaclaw

Priority: Low

Merge Risk: Minimal · up to d49f1

No concrete issue remains that should block merging after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title names three changes: fleshing out util:memops, magic blob reductions, and moving derivations to const expressions. The summary supports all three. The memops helpers are added and remove…
Description check Passed The description says the change depends on another PR, lists no breaking changes, and says the code was tested with just comb. It also discloses AI assistance and gives a checklist. These statements…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names three changes: fleshing out util:memops, magic blob reductions, and moving derivations to const expressions. The summary supports all three. The memops helpers are added and removed, the constant tables and IVs are now derived in const contexts, and the blob-style tables are reduced. The title is long and lists several topics, but it still relates to the main changes. The util:memops typo is minor.

Full details: Description check

Explanation

The description says the change depends on another PR, lists no breaking changes, and says the code was tested with just comb. It also discloses AI assistance and gives a checklist. These statements relate to a refactor of the pow crate, so the description is related to the changeset. It does not explain the changes in detail, which the lenient check does not require.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@kwvg kwvg moved this to Primitives in base-sdk v0.2 Oct 27, 2026
@kwvg kwvg changed the title pow%refac: flesh out util:memops, magic blob reductions, move derivation to const expressions pow%refac: flesh out util:memops, magic blob reductions, move derivations to const expressions Oct 27, 2026
@thepastaclaw

thepastaclaw commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit d49f11d) · triage: critical

@thepastaclaw thepastaclaw 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.

Final validation — Phase 1 + Phase 2

The refactor preserves the reviewed Blake, CubeHash, JH, Luffa, Shavite, Skein, and Echo transformations based on direct source comparison and the existing expected-value coverage. One non-blocking test-coverage gap was introduced: the focused assertion that rounds 10–15 repeat rows 0–5 was removed, while the remaining permutation test cannot detect an incorrect repeat schedule. CI checks for this head were still queued.

🟡 1 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Pin the derived Blake sigma repeat schedule
pkgs/pow/src/consts/blake.rs:55-68

The new SIGMA table is generated with SIGMA_ROWS[r % 10], but the previous test that explicitly asserted rounds 10–15 repeat rounds 0–5 was removed. sigma_is_permutation only verifies that each row is a permutation, so it would still pass if the repeated rows were shifted or otherwise selected incorrectly. Retain a direct assertion tying every generated row to SIGMA_ROWS[r % 10] so this const derivation is independently pinned.

#[cfg(test)]
mod tests {
  use super::*;

  #[test]
  fn sigma_rows_repeat_after_ten() {
    for r in 0..SIGMA.len() {
      assert_eq!(SIGMA[r], SIGMA_ROWS[r % SIGMA_ROWS.len()]);
    }
  }

  #[test]
  fn sigma_is_permutation() {
    for row in &SIGMA {
      let mut sorted = *row;
      sorted.sort();
      let expected: [usize; 16] = core::array::from_fn(|i| i);
      assert_eq!(sorted, expected);
    }
  }
}

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate refactor that directly changes multiple cryptographic proof-of-work hash implementations and their constant derivations, including low-level memory operations in files such as pkgs/pow/src/consts/jh.rs and pkgs/pow/src/util/memops.rs.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `pkgs/pow/src/consts/blake.rs`:
- [SUGGESTION] pkgs/pow/src/consts/blake.rs:55-68: Pin the derived Blake sigma repeat schedule
  The new `SIGMA` table is generated with `SIGMA_ROWS[r % 10]`, but the previous test that explicitly asserted rounds 10–15 repeat rounds 0–5 was removed. `sigma_is_permutation` only verifies that each row is a permutation, so it would still pass if the repeated rows were shifted or otherwise selected incorrectly. Retain a direct assertion tying every generated row to `SIGMA_ROWS[r % 10]` so this const derivation is independently pinned.

@github-actions

Copy link
Copy Markdown

Note

This pull request has no conflicts! 🎊 🎉 🎊

@github-actions github-actions Bot added the topic:Primitives Pull requests that primarily concern the dash-primitives crate. label Oct 27, 2026
@kwvg
kwvg marked this pull request as ready for review October 27, 2026 11:56
@kwvg
kwvg merged commit 70606e8 into dashpay:develop Oct 27, 2026
52 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:Primitives Pull requests that primarily concern the dash-primitives crate.

Projects

Status: Primitives

Development

Successfully merging this pull request may close these issues.

2 participants