Conversation
🦋 Changeset detectedLatest commit: 8b1ab79 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
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:
WalkthroughAdds preparatory state and initialization to the Redeployer script (public Changes
Sequence DiagramsequenceDiagram
participant Test
participant Redeployer
participant Auditor
participant MarketUSDC as Market(USDC)
participant MarketWETH as Market(WETH)
participant ExaFactory
Test->>Redeployer: new Redeployer()
Test->>Redeployer: prepare()
Redeployer->>Auditor: _protocolOrStub(resolve or deploy StubAuditor)
Redeployer->>MarketUSDC: _protocolOrStub(resolve or deploy StubMarketUSDC)
Redeployer->>MarketWETH: _protocolOrStub(resolve or deploy StubMarketWETH)
Redeployer->>Redeployer: _deployPlugins(admin) (uses auditor, marketUSDC, marketWETH)
Test->>Redeployer: deployExaFactory(admin)
Redeployer->>ExaFactory: create factory + plugins
ExaFactory-->>Redeployer: return deployment info
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the Redeployer script to avoid redundant stub deployments. The logic for handling dependencies like Auditor and Market contracts is moved from being inside each deployment function call to a one-time setup, which improves efficiency. The changes are well-structured and the tests have been updated accordingly.
I have one suggestion to improve the robustness of the stubbing logic to better mirror the previous implementation and prevent potential issues in tests.
|
✅ All tests passed. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1fa9a8c4-4d26-411b-b3cf-c176698c6dad
📒 Files selected for processing (4)
.changeset/bumpy-foxes-refuse.mdcontracts/.gas-snapshotcontracts/script/Redeployer.s.solcontracts/test/Redeployer.t.sol
There was a problem hiding this comment.
♻️ Duplicate comments (1)
contracts/script/Redeployer.s.sol (1)
68-86:⚠️ Potential issue | 🟠 MajorGuard and backfill all plugin dependencies, not just
auditor.Line 68 only backfills when
auditoris zero, and Line 180 only validatesauditor. Ifauditoris set butmarketUSDC/marketWETHare zero, plugin deployment can fail at constructor-time with invalid markets.🔧 Suggested fix
- if (address(auditor) == address(0)) { + if (address(auditor) == address(0)) { auditor = IAuditor( CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAuditor")), vm.getCode("Redeployer.s.sol:StubAuditor")) ); - address stubAsset = - CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAsset")), vm.getCode("Redeployer.s.sol:StubAsset")); + } + + if (address(marketUSDC) == address(0) || address(marketWETH) == address(0)) { + address stubAsset = CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("StubAsset"))); + if (stubAsset.code.length == 0) { + stubAsset = + CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAsset")), vm.getCode("Redeployer.s.sol:StubAsset")); + } + + if (address(marketUSDC) == address(0)) { + address stubUSDC = CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("StubMarketUSDC"))); + marketUSDC = IMarket( + stubUSDC.code.length == 0 + ? CREATE3_FACTORY.deploy( + keccak256(abi.encode("StubMarketUSDC")), + abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) + ) + : stubUSDC + ); + } + + if (address(marketWETH) == address(0)) { + address stubWETH = CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("StubMarketWETH"))); + marketWETH = IMarket( + stubWETH.code.length == 0 + ? CREATE3_FACTORY.deploy( + keccak256(abi.encode("StubMarketWETH")), + abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) + ) + : stubWETH + ); + } - marketUSDC = IMarket( - CREATE3_FACTORY.deploy( - keccak256(abi.encode("StubMarketUSDC")), - abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) - ) - ); - marketWETH = IMarket( - CREATE3_FACTORY.deploy( - keccak256(abi.encode("StubMarketWETH")), - abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) - ) - ); } @@ - if (address(auditor) == address(0)) revert NotPrepared(); + if (address(auditor) == address(0) || address(marketUSDC) == address(0) || address(marketWETH) == address(0)) { + revert NotPrepared(); + }Also applies to: 179-180
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6b9ddd18-4e44-47bb-b692-023871716822
📒 Files selected for processing (4)
.changeset/bumpy-foxes-refuse.mdcontracts/.gas-snapshotcontracts/script/Redeployer.s.solcontracts/test/Redeployer.t.sol
681ea16 to
478caf9
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
contracts/script/Redeployer.s.sol (1)
68-86:⚠️ Potential issue | 🟠 MajorHarden readiness checks for partially resolved dependencies.
prepare()and_deployPlugins()gate onauditoronly. Ifauditoris present butmarketUSDC/marketWETHare not, deployment can fail later inExaPluginconstruction instead of reverting withNotPrepared().🔧 Suggested fix
- if (address(auditor).code.length == 0) { + if (address(auditor).code.length == 0) { auditor = IAuditor( CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAuditor")), vm.getCode("Redeployer.s.sol:StubAuditor")) ); + } + if (address(marketUSDC).code.length == 0 || address(marketWETH).code.length == 0) { address stubAsset = CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAsset")), vm.getCode("Redeployer.s.sol:StubAsset")); - marketUSDC = IMarket( - CREATE3_FACTORY.deploy( - keccak256(abi.encode("StubMarketUSDC")), - abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) - ) - ); - marketWETH = IMarket( - CREATE3_FACTORY.deploy( - keccak256(abi.encode("StubMarketWETH")), - abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) - ) - ); + if (address(marketUSDC).code.length == 0) { + marketUSDC = IMarket( + CREATE3_FACTORY.deploy( + keccak256(abi.encode("StubMarketUSDC")), + abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) + ) + ); + } + if (address(marketWETH).code.length == 0) { + marketWETH = IMarket( + CREATE3_FACTORY.deploy( + keccak256(abi.encode("StubMarketWETH")), + abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) + ) + ); + } } @@ - if (address(auditor).code.length == 0) revert NotPrepared(); + if ( + address(auditor).code.length == 0 + || address(marketUSDC).code.length == 0 + || address(marketWETH).code.length == 0 + ) revert NotPrepared();Also applies to: 179-193
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 27201171-afe2-4d37-9f59-68bbbe95d8e4
📒 Files selected for processing (4)
.changeset/bumpy-foxes-refuse.mdcontracts/.gas-snapshotcontracts/script/Redeployer.s.solcontracts/test/Redeployer.t.sol
There was a problem hiding this comment.
♻️ Duplicate comments (1)
contracts/script/Redeployer.s.sol (1)
179-193:⚠️ Potential issue | 🟠 MajorExpand readiness guard to cover both markets.
_deployPlugins()currently guards onlyauditor, but it immediately consumesmarketUSDCandmarketWETHas constructor inputs. Missing market code can surface as an opaque low-level revert instead ofNotPrepared.🔧 Proposed fix
function _deployPlugins(address admin) internal returns (IPlugin, IPlugin) { - if (address(auditor).code.length == 0) revert NotPrepared(); + if ( + address(auditor).code.length == 0 || address(marketUSDC).code.length == 0 || address(marketWETH).code.length == 0 + ) revert NotPrepared();
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7b34488d-6631-4754-8b0f-08ec0d9f6758
📒 Files selected for processing (4)
.changeset/bumpy-foxes-refuse.mdcontracts/.gas-snapshotcontracts/script/Redeployer.s.solcontracts/test/Redeployer.t.sol
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
contracts/script/Redeployer.s.sol (1)
90-103:⚠️ Potential issue | 🟡 Minor
run()NatSpec says exclusive nonce, but implementation is inclusive.The parameter docs and loop behavior diverge (
<= targetNonce). Please make these consistent to prevent incorrect caller assumptions.📝 Minimal fix (doc alignment)
- /// `@param` targetNonce The nonce to stop at (exclusive) + /// `@param` targetNonce The nonce to stop at (inclusive)
♻️ Duplicate comments (1)
contracts/script/Redeployer.s.sol (1)
68-86:⚠️ Potential issue | 🟠 Major
NotPreparedcan be skipped while markets are still unresolved.
prepare()backfills stubs only whenauditoris missing, and_deployPlugins()only validatesauditor. Ifauditorresolves butmarketUSDC/marketWETHdo not, plugin deployment can fail with a low-level revert instead ofNotPrepared, andprepare()won’t repair that state.🔧 Suggested fix
- if (address(auditor).code.length == 0) { + if (address(auditor).code.length == 0) { auditor = IAuditor( CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAuditor")), vm.getCode("Redeployer.s.sol:StubAuditor")) ); - address stubAsset = - CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAsset")), vm.getCode("Redeployer.s.sol:StubAsset")); + } + + if (address(marketUSDC).code.length == 0 || address(marketWETH).code.length == 0) { + address stubAsset = CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("StubAsset"))); + if (stubAsset.code.length == 0) { + stubAsset = CREATE3_FACTORY.deploy(keccak256(abi.encode("StubAsset")), vm.getCode("Redeployer.s.sol:StubAsset")); + } + if (address(marketUSDC).code.length == 0) { marketUSDC = IMarket( CREATE3_FACTORY.deploy( keccak256(abi.encode("StubMarketUSDC")), abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) ) ); + } + if (address(marketWETH).code.length == 0) { marketWETH = IMarket( CREATE3_FACTORY.deploy( keccak256(abi.encode("StubMarketWETH")), abi.encodePacked(vm.getCode("Redeployer.s.sol:StubMarket"), abi.encode(stubAsset)) ) ); + } } @@ - if (address(auditor).code.length == 0) revert NotPrepared(); + if (address(auditor).code.length == 0 || address(marketUSDC).code.length == 0 || address(marketWETH).code.length == 0) { + revert NotPrepared(); + }Also applies to: 179-193
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ad9fb905-5aa6-418a-9507-a42a5b07c847
📒 Files selected for processing (3)
contracts/.gas-snapshotcontracts/script/Redeployer.s.solcontracts/test/Redeployer.t.sol
Summary by CodeRabbit
Refactor
Tests
Chores