-
Notifications
You must be signed in to change notification settings - Fork 30
Remove public setters from ERC7984Freezable
#198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for confidential-tokens ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Reviewer's GuideThis PR enforces freezing exclusively via the internal _setConfidentialFrozen method by removing its public overloads, exposes a test-only $_setConfidentialFrozen wrapper in the mock contract, and refactors the test suite to call only the proof-based API. Class diagram for ERC7984Freezable and ERC7984FreezableMock after removal of public settersclassDiagram
class ERC7984Freezable {
<<abstract>>
+_setConfidentialFrozen(account, encryptedAmount) internal
}
class ERC7984FreezableMock {
+$_setConfidentialFrozen(account, encryptedAmount, inputProof) public
}
ERC7984FreezableMock --|> ERC7984Freezable
Class diagram showing removed public methods from ERC7984FreezableclassDiagram
class ERC7984Freezable {
-setConfidentialFrozen(account, externalEuint64, inputProof) public
-setConfidentialFrozen(account, euint64) public
+_setConfidentialFrozen(account, encryptedAmount) internal
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughReplaces the mock’s encrypted-amount creator with a wrapper that forwards an external encrypted value and proof into the internal freezing path. Removes public freeze setters from the core extension, retaining only the internal Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant T as Test
participant M as ERC7984FreezableMock
participant F as FHE Lib
participant C as ERC7984Freezable (internal)
T->>M: $_setConfidentialFrozen(account, externalEncrypted, proof)
M->>F: fromExternal(externalEncrypted, proof)
F-->>M: euint64 encryptedAmount
M->>C: _setConfidentialFrozen(account, encryptedAmount)
C-->>T: (no return) • emits TokensFrozen • updates state
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
contracts/mocks/token/ERC7984FreezableMock.sol (1)
35-42: Make access control explicit at the entry point (fail-fast, clearer intent)
_setConfidentialFrozenenforcesonlyRole(FREEZER_ROLE)via_checkFreezer, but adding it here clarifies intent and short-circuits earlier.- ) public virtual { + ) public virtual onlyRole(FREEZER_ROLE) { _setConfidentialFrozen(account, FHE.fromExternal(encryptedAmount, inputProof)); }test/token/ERC7984/extensions/ERC7984Freezable.test.ts (1)
26-72: Minor test ergonomics: cache token addressYou call
await token.getAddress()multiple times; cache once to reduce RPC chatter and noise.- const encryptedRecipientMintInput = await fhevm - .createEncryptedInput(await token.getAddress(), holder.address) + const tokenAddr = await token.getAddress(); + const encryptedRecipientMintInput = await fhevm + .createEncryptedInput(tokenAddr, holder.address) .add64(1000) .encrypt(); @@ - const { handles, inputProof } = await fhevm - .createEncryptedInput(await token.getAddress(), freezer.address) + const { handles, inputProof } = await fhevm + .createEncryptedInput(tokenAddr, freezer.address) .add64(amount) .encrypt(); @@ - await expect( - fhevm.userDecryptEuint(FhevmType.euint64, frozenHandle, await token.getAddress(), recipient), + await expect( + fhevm.userDecryptEuint(FhevmType.euint64, frozenHandle, tokenAddr, recipient), ).to.eventually.equal(100); @@ - await expect( - fhevm.userDecryptEuint(FhevmType.euint64, balanceHandle, await token.getAddress(), recipient), + await expect( + fhevm.userDecryptEuint(FhevmType.euint64, balanceHandle, tokenAddr, recipient), ).to.eventually.equal(1000); @@ - await expect( - fhevm.userDecryptEuint(FhevmType.euint64, availableHandle, await token.getAddress(), recipient), + await expect( + fhevm.userDecryptEuint(FhevmType.euint64, availableHandle, tokenAddr, recipient), ).to.eventually.equal(900);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
contracts/mocks/token/ERC7984FreezableMock.sol(1 hunks)contracts/token/ERC7984/extensions/ERC7984Freezable.sol(0 hunks)test/token/ERC7984/extensions/ERC7984Freezable.test.ts(4 hunks)
💤 Files with no reviewable changes (1)
- contracts/token/ERC7984/extensions/ERC7984Freezable.sol
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: boostsecurity - boostsecurityio/semgrep-pro
- GitHub Check: tests
- GitHub Check: slither
- GitHub Check: coverage
🔇 Additional comments (5)
contracts/mocks/token/ERC7984FreezableMock.sol (1)
35-42: Public wrapper correctly forwards external ciphertext and proofForwarding
externalEuint64+inputProofintoFHE.fromExternal(...)and delegating to the internal_setConfidentialFrozenaligns with the removal of public setters in the core extension. Tests cover unauthorized access and event emission.test/token/ERC7984/extensions/ERC7984Freezable.test.ts (4)
26-72: End-to-end coverage for freeze path looks solidGood assertions: event, stored handle, ACL, decryptions, and available computation.
95-99: Updated callsite to new wrapper signatureSwitch to
$_setConfidentialFrozen(address,bytes32,bytes)matches the contract change and the revert check remains correct.
124-128: Good migration to the new freeze API in max-available flowCall updated correctly; downstream assertions validate availability and transfer.
175-179: Good migration to the new freeze API in over-transfer flowCall updated correctly; event and balance checks exercise the edge case.
james-toussaint
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 👍
Summary by Sourcery
Restrict the confidential freezing API to the internal
_setConfidentialFrozenfunction and update the mock and tests to use a new$_setConfidentialFrozenwrapper, removing the public setters from ERC7984Freezable.Enhancements:
setConfidentialFrozenfunctions from ERC7984Freezable$_setConfidentialFrozenpublic wrapper in ERC7984FreezableMock for testingTests:
$_setConfidentialFrozeninstead of the removed public setterssetConfidentialFrozenoverloadsSummary by CodeRabbit
Refactor
Tests