fix(contracts): rewrite MARKPool for MARK's 4-signal circuit#98
Conversation
MARKPool was incorrectly designed around a 13-signal circuit from an external project. Rewritten from scratch for MARK's own UTXOSettlement circuit (4 public signals: nullifierHash, commitmentHash, amount, isMint). New model: operators commit note hashes on-chain, note owners prove ownership via ZK proof to withdraw RYLA. No Merkle tree required. - MARKPool: commit + withdraw (ZK-proven) - IUTXOVerifier: 4-signal interface matching generated verifier - UTXOVerifier.sol: regenerated from MARK's own trusted setup - Removed: MerkleTree, PoseidonT3, PoolPublicInputs (not needed) - circuits/artifacts/utxo_verification_key.json: MARK's verification key 10 unit tests passing.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
WalkthroughThis PR redesigns the UTXO settlement architecture from a complex Merkle-tree-based multi-input system to a minimal single-note commitment/nullifier scheme. The Circom circuit is replaced with a 4-signal UTXOSettlement template, verifier keys are regenerated and IC points reduced to 4, MARKPool contract simplified to operator-only commit and proof-based withdraw, and supporting Merkle/Poseidon libraries removed. ChangesUTXO Settlement Redesign
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc2d17ab16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@contracts/src/pool/MARKPool.sol`:
- Around line 88-104: The NatSpec for commit() is misleading — it claims "RYLA
is transferred in and burned" though the commit function only records a
commitment (commitmentHash -> amount) and emits NoteCommitted; update the
NatSpec to accurately describe behavior by removing the transfer/burn statement
and clearly stating that the operator registers the commitment on-chain (the
actual mint/transfer happens on withdrawal), and ensure the params and
description reference the stored mapping commitments and emitted event
NoteCommitted for clarity.
In `@contracts/test/unit/pool/MARKPool.t.sol`:
- Around line 59-77: Add a unit test in MARKPool.t.sol that triggers the
commit() branch validating the SNARK scalar field: create a commitment value >=
SNARK_SCALAR_FIELD (e.g., SNARK_SCALAR_FIELD or SNARK_SCALAR_FIELD + 1) and call
pool.commit with that value while vm.prank(operator) is set, then
vm.expectRevert(PoolErrors.CommitmentInvalid.selector). Reference the existing
test style (testCommitRevertsForZeroCommitment/testCommitRevertsForZeroAmount)
and use the same operator/AMOUNT setup so the new test (e.g.,
testCommitRevertsForScalarFieldOverflow) asserts the revert when
uint256(commitmentHash) >= SNARK_SCALAR_FIELD.
🪄 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: ASSERTIVE
Plan: Pro Plus
Run ID: e17d449f-b0ac-4b8c-85e8-749ae9eb3b32
📒 Files selected for processing (9)
circuits/artifacts/utxo_verification_key.jsoncircuits/utxo/UTXOSettlement.circomcontracts/src/pool/MARKPool.solcontracts/src/pool/PoolPublicInputs.solcontracts/src/pool/crypto/MerkleTree.solcontracts/src/pool/crypto/PoseidonT3.solcontracts/src/pool/interfaces/IUTXOVerifier.solcontracts/src/pool/verifier/UTXOVerifier.solcontracts/test/unit/pool/MARKPool.t.sol
💤 Files with no reviewable changes (3)
- contracts/src/pool/crypto/MerkleTree.sol
- contracts/src/pool/PoolPublicInputs.sol
- contracts/src/pool/crypto/PoseidonT3.sol
MARKPool was incorrectly designed around a 13-signal circuit from an external project. Rewritten from scratch for MARK's own UTXOSettlement circuit.
New model: operators commit note hashes on-chain (commit), note owners prove ownership via ZK proof to withdraw RYLA (withdraw). No Merkle tree required for this circuit.
UTXOVerifier.sol regenerated from MARK's own trusted setup (fresh Powers of Tau, fresh phase 2 contribution). Verification key committed to circuits/artifacts/.
Scope: contracts, circuits
Verification: 84 unit tests passing.
Risk: Low. Replaces incorrect implementation with correct one. MARKPool is additive — no existing contracts changed.
Summary by CodeRabbit
New Features
commitoperation for registering notes with the pool.Bug Fixes & Improvements
Removals
deposit,transact, and protocol epoch features.