Skip to content

Scaffold circuit_unpacker crate#356

Open
anatgstarkware wants to merge 1 commit into
mainfrom
anatg/circuit_unpacker
Open

Scaffold circuit_unpacker crate#356
anatgstarkware wants to merge 1 commit into
mainfrom
anatg/circuit_unpacker

Conversation

@anatgstarkware
Copy link
Copy Markdown
Contributor

@anatgstarkware anatgstarkware commented Jun 2, 2026

Summary

New circuit_unpacker crate at crates/circuit_unpacker/, added to the workspace members. This is the circuits-DSL analogue of the Cairo unpacker bootloader (BLAKE_UNPACKING mode): it walks a statically-shaped perfect-binary-tree recursion of circuit_verifier proofs and emits each real leaf's outputs.

This PR is scaffolding only — documented public API with a todo!() body:

  • UnpackerHints — prover-supplied per-real-leaf outputs; derives tree shape from leaf_outputs.len().
  • DUMMY_LEAF_MARKER (0xDEAD) and dummy_leaf_output() — canonical padding for non-power-of-two N.
  • run_unpacker() — entry point, todo!() for now.

Tree shape is a complete perfect binary tree fixed by N; right-aligned slots are dummies. No n_subtasks / size headers in preimages — positions are compile-time-known.


This change is Reviewable

@anatgstarkware anatgstarkware self-assigned this Jun 2, 2026
@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 2, 2026

PR Summary

Low Risk
No production wiring or cryptographic enforcement yet—only API, docs, and a placeholder implementation plus a minimal validity test.

Overview
Adds a new workspace crate circuit-unpacker (crates/circuit_unpacker/) as the circuits-DSL counterpart to the Cairo bootloader’s Blake unpack path: it will walk a fixed perfect-binary-tree of recursive circuit_verifier proofs and surface each real leaf’s outputs via Blake bindings aligned with circuit_verifier::verify.

This change is scaffolding only: extensive module docs, UnpackerHints (tree shape derived from leaf_outputs.len()), dummy padding via DUMMY_LEAF_MARKER / dummy_leaf_output(), and run_unpacker which currently returns empty per-leaf Vecs with a TODO instead of building constraints. A starter test unpacker_n2_no_dummies builds an off-circuit root hash and only asserts ctx.is_circuit_valid() until the real tree walk lands. Cargo.toml / Cargo.lock register the new member.

Reviewed by Cursor Bugbot for commit 507d8f1. Bugbot is set up for automated code reviews on this repo. Configure here.

@anatgstarkware anatgstarkware force-pushed the anatg/circuit_unpacker branch 2 times, most recently from 742604d to f735838 Compare June 2, 2026 12:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.39%. Comparing base (c0b937b) to head (507d8f1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #356      +/-   ##
==========================================
+ Coverage   59.19%   59.39%   +0.20%     
==========================================
  Files          35       36       +1     
  Lines        5303     5330      +27     
==========================================
+ Hits         3139     3166      +27     
  Misses       2164     2164              
Files with missing lines Coverage Δ
crates/circuit_unpacker/src/lib.rs 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anatgstarkware anatgstarkware force-pushed the anatg/circuit_unpacker branch 2 times, most recently from d33764b to 951f194 Compare June 2, 2026 13:50
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 951f194. Configure here.

// TODO: implement the Blake-binding tree walk. Returns one `Vec<Var>` per real leaf, in tree
// position order.
Vec::new()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stub silently returns empty Vec instead of panicking

Medium Severity

run_unpacker returns Vec::new() instead of calling todo!(). The PR description explicitly states this function has a "todo!() body," but the actual implementation silently returns an empty vector. Any caller (including future integration tests or downstream crates) will receive an empty result without any runtime indication that the function is unimplemented, potentially masking real bugs. The documented soundness contract in the docstring is quietly violated rather than loudly failing.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 951f194. Configure here.

@anatgstarkware anatgstarkware force-pushed the anatg/circuit_unpacker branch from 951f194 to 507d8f1 Compare June 2, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant