-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: RedeemManager Migration - Assumes initiator equals recipient (#299
) * Assumes that the initator and the receiptent are the same * feat: update redeemManager, remove preInitiator array from test * feat: add redeemManager migration test on holesky fork * feat: add more test for RedeemManager migration, increase coverage * chore: improve formatting * chore: update redeemManager test * chore: removed initiators param from redeemManager upgrade script --------- Co-authored-by: Mischa <[email protected]>
- Loading branch information
1 parent
9913e08
commit 53d70ab
Showing
9 changed files
with
135 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
contracts/test/fork/holesky/1.redeemQueueMigrationV1_2_1.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity 0.8.20; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import "../../../src/TUPProxy.sol"; | ||
import "../../../src/RedeemManager.1.sol"; | ||
import "../../../src/state/redeemManager/RedeemQueue.1.sol"; | ||
import "../../../src/state/redeemManager/RedeemQueue.2.sol"; | ||
import "../../../src/state/redeemManager/WithdrawalStack.sol"; | ||
import {ITransparentUpgradeableProxy} from | ||
"openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
|
||
interface MockIRedeemManagerV1 { | ||
function getRedeemRequestDetails(uint32 _redeemRequestId) | ||
external | ||
view | ||
returns (RedeemQueueV1.RedeemRequest memory); | ||
|
||
function getRedeemRequestCount() external view returns (uint256); | ||
} | ||
|
||
contract RedeemQueueMigrationV1_2 is Test { | ||
bool internal _skip = false; | ||
string internal _rpcUrl; | ||
|
||
address internal constant REDEEM_MANAGER_STAGING_ADDRESS = 0x0693875efbF04dDAd955c04332bA3324472DF980; | ||
address internal constant REDEEM_MANAGER_STAGING_PROXY_ADMIN_ADDRESS = 0x80Cf8bD4abf6C078C313f72588720AB86d45c5E6; | ||
|
||
function setUp() external { | ||
try vm.envString("TENDERLY_URL") returns (string memory rpcUrl) { | ||
_rpcUrl = rpcUrl; | ||
vm.createSelectFork(rpcUrl, 2440752); | ||
console.log("1.RedeemQueueMigrationV1_2.t.sol is active"); | ||
} catch { | ||
_skip = true; | ||
} | ||
} | ||
|
||
modifier shouldSkip() { | ||
if (!_skip) { | ||
_; | ||
} | ||
} | ||
|
||
function test_migrate_allRedeemRequestsInOneCall() external shouldSkip { | ||
// Getting the RedeemManager proxy instance | ||
TUPProxy redeemManagerProxy = TUPProxy(payable(REDEEM_MANAGER_STAGING_ADDRESS)); | ||
|
||
// Getting RedeemManagerV1 instance before the upgrade | ||
MockIRedeemManagerV1 RedeemManager = MockIRedeemManagerV1(REDEEM_MANAGER_STAGING_ADDRESS); | ||
// Getting all redeem request details, and count before the upgrade | ||
uint256 oldCount = RedeemManager.getRedeemRequestCount(); | ||
RedeemQueueV1.RedeemRequest[155] memory oldRequests; | ||
for (uint256 i = 0; i < 155; i++) { | ||
oldRequests[i] = RedeemManager.getRedeemRequestDetails(uint32(i)); | ||
} | ||
|
||
// Set up the fork at a new block for making the v1_2_1 upgrade, and testing | ||
vm.createSelectFork(_rpcUrl, 2440762); | ||
// Upgrade the RedeemManager | ||
RedeemManagerV1 newImplementation = new RedeemManagerV1(); | ||
vm.prank(REDEEM_MANAGER_STAGING_PROXY_ADMIN_ADDRESS); | ||
ITransparentUpgradeableProxy(address(redeemManagerProxy)).upgradeToAndCall( | ||
address(newImplementation), abi.encodeWithSelector(RedeemManagerV1.initializeRedeemManagerV1_2.selector) | ||
); | ||
|
||
// After upgrade: check that state before the upgrade, and state after upgrade are same. | ||
RedeemManagerV1 RManager = RedeemManagerV1(REDEEM_MANAGER_STAGING_ADDRESS); | ||
uint256 newCount = RManager.getRedeemRequestCount(); | ||
assertEq(newCount, oldCount); | ||
|
||
for (uint32 i = 0; i < newCount; i++) { | ||
RedeemQueueV2.RedeemRequest memory newRequest = RManager.getRedeemRequestDetails(i); | ||
|
||
assertEq(newRequest.amount, oldRequests[i].amount); | ||
assertEq(newRequest.maxRedeemableEth, oldRequests[i].maxRedeemableEth); | ||
assertEq(newRequest.recipient, oldRequests[i].recipient); | ||
assertEq(newRequest.height, oldRequests[i].height); | ||
assertEq(newRequest.initiator, oldRequests[i].recipient); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.