feat: Make weETHModule an upgradeable proxy (DEV-1149) - #228
Conversation
Summary by OctaneNew ContractsNo new contracts were added. Updated Contracts
🔗 Commit Hash: 485c8d5 |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughThe PR migrates WEETHModule from a non-upgradeable contract to an upgradeable contract using the UUPS proxy pattern. Deployment now wraps WEETHModule in an ERC1967Proxy, replacing the constructor with an initialize function, adding upgrade authorization controls, and including a storage gap for forward compatibility. Changes
Sequence DiagramsequenceDiagram
participant Test as Test Suite
participant Proxy as ERC1967Proxy
participant Impl as WEETHModule<br/>(Implementation)
Test->>Proxy: Create proxy with implementation
Test->>Proxy: Initialize via abi.encodeCall
Proxy->>Impl: delegatecall initialize(admin, almProxy)
Impl->>Impl: __AccessControlEnumerable_init()
Impl->>Impl: __UUPSUpgradeable_init()
Impl->>Impl: Grant DEFAULT_ADMIN_ROLE
Impl->>Impl: Store almProxy reference
Proxy-->>Test: Initialization complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@src/WeEthModule.sol`:
- Around line 21-23: The WeEthModule UUPS upgradeable contract is missing the
reserved storage gap which prevents future state variable additions from
corrupting proxy storage; add a private uint256 array named __gap (e.g.,
uint256[50] private __gap) to the WeEthModule contract (which inherits
AccessControlEnumerableUpgradeable and UUPSUpgradeable) right after the existing
state variables like almProxy to reserve space for future upgrades.
- Around line 33-39: In initialize, call parent initializers by invoking
__AccessControlEnumerable_init() and __UUPSUpgradeable_init() before granting
roles, validate admin is not the zero address with require(admin != address(0),
"WeEthModule/invalid-admin"), then call _grantRole(DEFAULT_ADMIN_ROLE, admin)
and set almProxy = _almProxy; ensure __AccessControlEnumerable_init and
__UUPSUpgradeable_init are invoked at the start of the initialize function
(alongside the existing _almProxy zero check) to follow upgradeable-contract
best practices.
In `@test/mainnet-fork/weETH.t.sol`:
- Around line 25-27: Remove the unused interface IWeEthModuleLike from the file:
it is defined but never referenced, since initialization uses
abi.encodeCall(WeEthModule.initialize, ...) and does not require the interface;
delete the IWeEthModuleLike declaration to clean up unused code and leave
WeEthModule.initialize and the abi.encodeCall usage intact.
Overview
🔗 Commit Hash: 485c8d5 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
| address public immutable almProxy; | ||
| address public almProxy; | ||
|
|
||
| uint256[49] private __gap; |
|
|
||
| constructor(address admin, address _almProxy) { | ||
| constructor() { | ||
| _disableInitializers(); |
There was a problem hiding this comment.
Same as buffer, add comment
| } | ||
|
|
||
| function initialize(address admin, address _almProxy) external initializer { | ||
| require(_almProxy != address(0), "WeEthModule/invalid-alm-proxy"); |
There was a problem hiding this comment.
Same as buffer, add require and test
| liquidityPool = ILiquidityPoolLike(IEETHLike(eETH).liquidityPool()); | ||
|
|
||
| weETHModule = address(new WEETHModule(Ethereum.SPARK_PROXY, address(almProxy))); | ||
| weETHModule = address( |
There was a problem hiding this comment.
Needs test converage for:
- zero admin
- zero almProxy
- double intialization
- initialization of implementation
- successful initialization (initial state)
| using SafeERC20 for IERC20; | ||
|
|
||
| address public immutable almProxy; | ||
| address public almProxy; |
There was a problem hiding this comment.
Same changes needed as OTC
7edeed8
|
Coverage after merging dev-1149-weethModule-proxy into dev will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary by CodeRabbit
Release Notes
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.