-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
5,713 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"1": { | ||
"registry": "0x33a02E6cC863D393d6Bf231B697b82F6e499cA71", | ||
"stakeManagerProxy": "0x5e3Ef299fDDf15eAa0432E6e66473ace8c13D908", | ||
"withdrawManagerProxy": "0x2A88696e0fFA76bAA1338F2C74497cC013495922", | ||
"governance": "0x6e7a5820baD6cebA8Ef5ea69c0C92EbbDAc9CE48", | ||
"timelock": "0xCaf0aa768A3AE1297DF20072419Db8Bb8b5C8cEf", | ||
"polToken": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6", | ||
"matic": "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0", | ||
"migration": "0x29e7DF7b6A1B2b07b731457f499E1696c60E2C4e", | ||
"nativGasToken": "0x0000000000000000000000000000000000001010", | ||
"gSafe": "0xFa7D2a996aC6350f4b56C043112Da0366a59b74c", | ||
"exitNFT": "0xDF74156420Bd57ab387B195ed81EcA36F9fABAca" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,98 @@ | ||
pragma solidity ^0.8.4; | ||
|
||
// These imports get generated by npm run generate:interfaces | ||
import {WithdrawManagerProxy} from "../../scripts/helpers/interfaces/WithdrawManagerProxy.generated.sol"; | ||
import {WithdrawManager} from "../../scripts/helpers/interfaces/WithdrawManager.generated.sol"; | ||
import {ValidatorShare} from "../../scripts/helpers/interfaces/ValidatorShare.generated.sol"; | ||
import {DepositManager} from "../../scripts/helpers/interfaces/DepositManager.generated.sol"; | ||
import {Registry} from "../../scripts/helpers/interfaces/Registry.generated.sol"; | ||
import {ERC20} from "../../scripts/helpers/interfaces/ERC20.generated.sol"; | ||
import {Proxy} from "../../scripts/helpers/interfaces/Proxy.generated.sol"; | ||
|
||
import {Timelock} from "../../contracts/common/misc/ITimelock.sol"; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
struct TxObject { | ||
uint256 block_number; | ||
address from; | ||
bytes input_proof; | ||
bytes modified_input_proof; | ||
bytes32 timestamp; | ||
address to; | ||
bytes32 transaction_hash; | ||
uint256 value; | ||
} | ||
|
||
struct FileObject { | ||
TxObject[] txObjects; | ||
} | ||
|
||
contract ForkupgradeMPT is Test { | ||
using stdJson for string; | ||
|
||
uint256 mainnetFork; | ||
|
||
function setUp() public { | ||
mainnetFork = vm.createFork(vm.rpcUrl("mainnet"), 20900000); | ||
vm.selectFork(mainnetFork); | ||
} | ||
|
||
function test_UpgradeMPT() public { | ||
assertEq(vm.activeFork(), mainnetFork); | ||
|
||
string memory input = vm.readFile("scripts/deployers/mpt-fix/input.json"); | ||
string memory chainIdSlug = string(abi.encodePacked('["', vm.toString(block.chainid), '"]')); | ||
WithdrawManagerProxy withdrawManagerProxy = WithdrawManagerProxy(payable(input.readAddress(string.concat(chainIdSlug, ".withdrawManagerProxy")))); | ||
Timelock timelock = Timelock(payable(input.readAddress(string.concat(chainIdSlug, ".timelock")))); | ||
address exitNFT = input.readAddress(string.concat(chainIdSlug, ".exitNFT")); | ||
|
||
address withdrawManagerImpl = deployCode("out/WithdrawManager.sol/WithdrawManager.json"); | ||
|
||
vm.prank(address(timelock)); | ||
withdrawManagerProxy.updateImplementation(withdrawManagerImpl); | ||
WithdrawManager withdrawManager = WithdrawManager(payable(withdrawManagerProxy)); | ||
|
||
// load tx to be replayed | ||
string memory txsJson = vm.readFile("test/foundry/batch1withdrawNew.json"); | ||
bytes memory txs = vm.parseJson(txsJson); | ||
FileObject memory txBatch1 = abi.decode(txs, (FileObject)); | ||
uint256 successes = 0; | ||
// loop | ||
for (uint i = 0; i < txBatch1.txObjects.length; i++) { | ||
console.log("tx num: ", i); | ||
TxObject memory obj = txBatch1.txObjects[i]; | ||
console.log(obj.from); | ||
|
||
// Get the index of the exit | ||
uint256 index = withdrawManager.verifyInclusion(obj.modified_input_proof, 0, false); | ||
|
||
// Calculate the storage slots we need to manipulate to replay the tx | ||
bytes32 slotisKnownExit = keccak256(abi.encode(uint128(index << 1), 5)); | ||
bytes32 slotexits = bytes32(uint256(keccak256(abi.encode(index << 1, 6)))+ 3); | ||
bytes32 slot_tokenOwner = keccak256(abi.encode((index << 1), 1)); | ||
// WithdrawManager | ||
vm.store(address(withdrawManager), slotisKnownExit, 0); | ||
vm.store(address(withdrawManager), slotexits, 0); | ||
// ExitNFT | ||
vm.store(exitNFT, slot_tokenOwner, 0); | ||
|
||
|
||
// Expect the exit correctly happens, this is the last thing that happens in an orderly exit | ||
vm.expectEmit(true, false, false, false, address(withdrawManager)); | ||
emit WithdrawManager.ExitStarted(obj.from, index, address(0), 0, true); | ||
// Pretend to be the the exitor and replay tx | ||
vm.prank(obj.from); | ||
(bool successSchedule, bytes memory dataSchedule) = address(0x626fb210bf50e201ED62cA2705c16DE2a53DC966).call(obj.input_proof); | ||
if (successSchedule == false) { | ||
assembly { | ||
revert(add(dataSchedule, 32), mload(dataSchedule)) | ||
} | ||
} else { | ||
successes += 1; | ||
console.log("success"); | ||
} | ||
} | ||
console.log("Total successful tx: ", successes); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.