fix(contracts): resolve remaining Zenith findings [skip-line-limit] - #1788
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR enforces exact token transfers, atomic license-token surplus sweeping, strict exit-delay validation, deterministic slash rounding, deployed verifier checks, and post-distribution LiquidityLauncher whitelist removal. Tests cover token, registry, settlement, sale, and verifier flows. ChangesProtocol invariants
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Requester
participant Interfold
participant InterfoldPricing
participant FeeToken
Requester->>Interfold: request with quoted fee
Interfold->>InterfoldPricing: transferFromExact fee
InterfoldPricing->>FeeToken: transferFrom requested amount
FeeToken-->>InterfoldPricing: delivered balance delta
InterfoldPricing-->>Interfold: accept exact amount or revert
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/interfold-contracts/test/E3Lifecycle/E3Integration.spec.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. packages/interfold-contracts/test/Registry/BondingRegistry.spec.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/interfold-contracts/contracts/lib/BondingAssetLib.sol (1)
283-301: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winCheck the registry balance delta before accepting an outgoing transfer.
_transferExactchecks only the recipient balance delta. A sender-fee or debit-rebasing token can creditrecipientbyamountwhile debitingBondingRegistryby more thanamount.This bypasses
AssetTransferMismatch.sweepLicenseSurpluscan then consume bonded liabilities. Exit claims and slashed-fund withdrawals can leave the registry undercollateralized.Record and validate the sender balance delta too. Use a separate error, or generalize
AssetTransferMismatch, so the error reports the failed delta correctly. Add a sender-fee token regression test.Proposed direction
+uint256 senderBefore = token.balanceOf(address(this)); uint256 beforeBalance = token.balanceOf(recipient); token.safeTransfer(recipient, amount); uint256 afterBalance = token.balanceOf(recipient); +uint256 senderAfter = token.balanceOf(address(this)); +uint256 spent = senderBefore > senderAfter ? senderBefore - senderAfter : 0; +if (spent != amount) { + revert IBondingRegistry.AssetTransferMismatch(tokenAddress, amount, spent); +}🤖 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 `@packages/interfold-contracts/contracts/lib/BondingAssetLib.sol` around lines 283 - 301, Update _transferExact to record the registry/token sender balance before and after safeTransfer, validate that the sender’s decrease equals amount in addition to validating the recipient’s increase, and report any failed delta with the correct value using a separate or generalized transfer-mismatch error. Add a regression test using a sender-fee token covering outgoing transfers and preventing surplus sweeping or withdrawals from leaving the registry undercollateralized.
🤖 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 `@agent/flow-trace/02_TOKENS_AND_ACTIVATION.md`:
- Around line 419-420: Update the documented license transfer step to pass
licenseAmount to licenseToken.safeTransfer instead of amount, keeping the
totalLicenseLiability decrement and asset accounting consistent.
---
Outside diff comments:
In `@packages/interfold-contracts/contracts/lib/BondingAssetLib.sol`:
- Around line 283-301: Update _transferExact to record the registry/token sender
balance before and after safeTransfer, validate that the sender’s decrease
equals amount in addition to validating the recipient’s increase, and report any
failed delta with the correct value using a separate or generalized
transfer-mismatch error. Add a regression test using a sender-fee token covering
outgoing transfers and preventing surplus sweeping or withdrawals from leaving
the registry undercollateralized.
🪄 Autofix
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: e63f704b-1c66-4d61-8f1f-b421945f7606
📒 Files selected for processing (27)
agent/INVARIANTS.mdagent/flow-trace/00_INDEX.mdagent/flow-trace/02_TOKENS_AND_ACTIVATION.mdagent/flow-trace/03_E3_REQUEST_AND_COMMITTEE.mdagent/flow-trace/05_FAILURE_REFUND_SLASHING.mdagent/flow-trace/06_DEACTIVATION_AND_COMPLETION.mdpackages/interfold-contracts/contracts/E3RefundManager.solpackages/interfold-contracts/contracts/Interfold.solpackages/interfold-contracts/contracts/interfaces/IBondingRegistry.solpackages/interfold-contracts/contracts/interfaces/ICiphernodeRegistry.solpackages/interfold-contracts/contracts/interfaces/IE3RefundManager.solpackages/interfold-contracts/contracts/interfaces/IInterfold.solpackages/interfold-contracts/contracts/lib/BondingAssetLib.solpackages/interfold-contracts/contracts/lib/InterfoldPricing.solpackages/interfold-contracts/contracts/registry/BondingRegistry.solpackages/interfold-contracts/contracts/registry/CiphernodeRegistryOwnable.solpackages/interfold-contracts/contracts/test/MockBondingRegistry.solpackages/interfold-contracts/contracts/token/InterfoldTicketToken.solpackages/interfold-contracts/contracts/token/sale/InterfoldTokenSaleDeployer.solpackages/interfold-contracts/deploy/sale/MAINNET_CCA_CHECKLIST.mdpackages/interfold-contracts/scripts/sale/validate.tspackages/interfold-contracts/test/E3Lifecycle/E3Integration.spec.tspackages/interfold-contracts/test/Governance/AccessAndBounds.spec.tspackages/interfold-contracts/test/Pricing/PullPaymentsAndAllowlist.spec.tspackages/interfold-contracts/test/Registry/BondingRegistry.spec.tspackages/interfold-contracts/test/Token/InterfoldTicketToken.spec.tspackages/interfold-contracts/test/Token/InterfoldTokenSaleDeployer.spec.ts
5f08a30 to
8e5ab5e
Compare
8e5ab5e to
de8faef
Compare
de8faef to
20ce159
Compare
20ce159 to
eefd62f
Compare
Summary
Fixes:
Testing
Summary by CodeRabbit
Bug Fixes
Updates