-
Notifications
You must be signed in to change notification settings - Fork 16
feat: wip- acl cleanup script and other cleanup #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ksatyarth2
wants to merge
6
commits into
master
Choose a base branch
from
feat/accessManager-cleanup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3420a31
feat: wip- acl cleanup script and other cleanup
ksatyarth2 8904af5
forge fmt
ksatyarth2 a26e591
Merge branch 'master' into feat/accessManager-cleanup
ksatyarth2 1bf0208
fix: replace new paymaster
ksatyarth2 16ef973
fix: holesky paymaster
ksatyarth2 54b3fad
chore: no hardcoded addy
ksatyarth2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
111 changes: 111 additions & 0 deletions
111
mainnet-contracts/script/AccessManagerMigrations/07_AccessManagerCleanup.s.sol
This file contains hidden or 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,111 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
// - Guardian role 88 is unused | ||
// - Puffer Oracle role 999 is unused | ||
// - Reward Watcher 21 role is unused | ||
// - Conflicting role ID 25::Granted VT pricer role 25 to MergedAdapterWithoutRoundsPufStakingV1 proxy - 0xf9dfbf71f2d9c8a4e565e1346aeb2c3e1dc765de | ||
// - Currently Active on ValidatorTicketPricer - 0x9830ad1bd5cf73640e253edf97dee3791c4a53c3 | ||
|
||
// - Add PufferOracleV2 - 0x8eFd1Dc43AD073232F3e2924e22F173879119489 to ACL? | ||
// - There is another PufferOracle 0x0be2ae0edbebb517541df217ef0074fc9a9e994f also | ||
// - PufferOracleV2 has PufferProtocol 1234 role for few functions like provisionNode and exitValidators | ||
// - Granted function role on v2 on setMintPrice | ||
|
||
// - DUPLICATE OperationsCoordinator 0xe6d798165a32f37927af20d7ccb1f80fb731a3c0 | ||
// - Original OperationsCoordinator- 0x3fee92765f5cf8f9909a3c89f4907ea5e1cd9bf7 | ||
// - Granted Operations Coordinator 24 role to duplicate one | ||
// - Granted function role setValidatorTicketMintPrice on duplicate one | ||
|
||
// - Upgrader role 1 is granted to 0x0000000000000000000000000000000000000000 contract for upgradeToAndCall(address,bytes) function | ||
// - Lockbox no address on L1? | ||
|
||
// TODO: | ||
|
||
// create a PR to do cleanup & remove unused roles from the code | ||
// DONE - fix the conflict for role 25 by creating a new role | ||
// DONE - create a migration script like 06_AccessManagerCleanup.s.sol | ||
// DONE - that script should revoke any roles from the contracts that we don't use anymore (oracle, operations coordinator) | ||
|
||
// DONE - ROLE_ID_LOCKBOX seems unused as well. | ||
// on xPufETH there is `setLockbox` which is restricted to DAO, we don't need this role anymore. | ||
|
||
// Upgrader role is useless as well, we should revoke it | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessManager.sol"; | ||
import { Multicall } from "@openzeppelin/contracts/utils/Multicall.sol"; | ||
import { ROLE_ID_OPERATIONS_COORDINATOR } from "../../script/Roles.sol"; | ||
import { DeployerHelper } from "../../script/DeployerHelper.s.sol"; | ||
import { console } from "forge-std/console.sol"; | ||
import { PufferWithdrawalManager } from "../../src/PufferWithdrawalManager.sol"; | ||
import { ROLE_ID_VT_PRICER, ROLE_ID_WITHDRAWAL_FINALIZER } from "../../script/Roles.sol"; | ||
|
||
contract AccessManagerCleanup is DeployerHelper { | ||
function run() public view { | ||
address duplicateOperationsCoordinator = 0xe6d798165A32F37927AF20D7Ccb1f80fB731a3C0; | ||
address withdrawalManagerProxy = _getPufferWithdrawalManager(); | ||
|
||
address paymaster = _getPaymaster(); | ||
address withdrawalFinalizer = _getOPSMultisig(); | ||
address communityMultisig = _getCommunityMultisig(); | ||
|
||
uint64 ROLE_ID_UPGRADER = 1; | ||
|
||
// ------------ 1. Revoke existing ROLE_ID_WITHDRAWAL_FINALIZER roles and re-grant as we have changed the role ID which was 25 earlier and now 27 ------------ | ||
bytes[] memory calldatas = new bytes[](9); | ||
|
||
// 1.1 set target role for finalizeWithdrawals | ||
bytes4[] memory paymasterSelectors = new bytes4[](1); | ||
paymasterSelectors[0] = PufferWithdrawalManager.finalizeWithdrawals.selector; | ||
|
||
calldatas[0] = abi.encodeWithSelector( | ||
AccessManager.setTargetFunctionRole.selector, | ||
withdrawalManagerProxy, | ||
paymasterSelectors, | ||
ROLE_ID_WITHDRAWAL_FINALIZER | ||
); | ||
// 1.2 revoke existing roles | ||
calldatas[1] = | ||
abi.encodeWithSelector(AccessManager.revokeRole.selector, ROLE_ID_WITHDRAWAL_FINALIZER, paymaster); | ||
calldatas[2] = | ||
abi.encodeWithSelector(AccessManager.revokeRole.selector, ROLE_ID_WITHDRAWAL_FINALIZER, withdrawalFinalizer); | ||
|
||
// 1.3 grant finalizer roles to paymaster and withdrawalFinalizer addresses | ||
calldatas[3] = | ||
abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_WITHDRAWAL_FINALIZER, paymaster, 0); | ||
|
||
calldatas[4] = abi.encodeWithSelector( | ||
AccessManager.grantRole.selector, ROLE_ID_WITHDRAWAL_FINALIZER, withdrawalFinalizer, 0 | ||
); | ||
|
||
// 1.4 label role | ||
calldatas[5] = abi.encodeWithSelector( | ||
AccessManager.labelRole.selector, ROLE_ID_WITHDRAWAL_FINALIZER, "Withdrawal Finalizer" | ||
); | ||
|
||
// 1.5 label role 25 as VT pricer | ||
calldatas[6] = | ||
abi.encodeWithSelector(AccessManager.labelRole.selector, ROLE_ID_VT_PRICER, "Validator Ticket Pricer"); | ||
// ------------------- | ||
|
||
// 2. Revoke Operations Coordinator role from duplicate contract | ||
// 2.1 revoke role from duplicate contract | ||
calldatas[7] = abi.encodeWithSelector( | ||
AccessManager.revokeRole.selector, ROLE_ID_OPERATIONS_COORDINATOR, duplicateOperationsCoordinator | ||
); | ||
// NOTE: this duplicate contract has setValidatorTicketMintPrice function which has been granted Operations Paymaster (ID: 23) role | ||
|
||
// 3. Revoke PufferOracle role from PufferOracleV2 | ||
// NOTE: PufferOracleV2 has PufferProtocol 1234 role for few functions like provisionNode and exitValidators, so we can skip it, or can change it some unaccessible role? | ||
|
||
// 4. revoke uint64 constant ROLE_ID_UPGRADER = 1; from Community Multisig 0x446d4d6b26815f9ba78b5d454e303315d586cb2a | ||
calldatas[8] = abi.encodeWithSelector(AccessManager.revokeRole.selector, ROLE_ID_UPGRADER, communityMultisig); | ||
|
||
bytes memory encodedMulticall = abi.encodeCall(Multicall.multicall, (calldatas)); | ||
|
||
console.log("Timelock -> AccessManager"); | ||
console.log("AccessManagerCleanup calldatas:"); | ||
console.logBytes(encodedMulticall); | ||
} | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -488,6 +488,19 @@ abstract contract DeployerHelper is Script { | |
} | ||
|
||
function _getPaymaster() internal view returns (address) { | ||
if (block.chainid == mainnet) { | ||
// https://etherscan.io/address/0xb4F1f4d59bd7590e92c386083Aa260C1e09cC58b | ||
return 0xb4F1f4d59bd7590e92c386083Aa260C1e09cC58b; | ||
} else if (block.chainid == holesky) { | ||
// https://holesky.etherscan.io/address/0xDDDeAfB492752FC64220ddB3E7C9f1d5CcCdFdF0 | ||
return 0xDDDeAfB492752FC64220ddB3E7C9f1d5CcCdFdF0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we change this address? |
||
} | ||
|
||
revert("Paymaster not available for this chain"); | ||
} | ||
// Keep this address for revoking old paymaster in future | ||
|
||
function _getDeprecatedPaymaster() internal view returns (address) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this function necessary? |
||
if (block.chainid == mainnet) { | ||
// https://etherscan.io/address/0x65d2dd7A66a2733a36559fE900A236280A05FBD6 | ||
return 0x65d2dd7A66a2733a36559fE900A236280A05FBD6; | ||
|
@@ -582,4 +595,13 @@ abstract contract DeployerHelper is Script { | |
|
||
revert("RevenueDepositor not available for this chain"); | ||
} | ||
|
||
function _getPufferWithdrawalManager() internal view returns (address) { | ||
if (block.chainid == mainnet) { | ||
// https://etherscan.io/address/0xDdA0483184E75a5579ef9635ED14BacCf9d50283 | ||
return 0xDdA0483184E75a5579ef9635ED14BacCf9d50283; | ||
} | ||
|
||
revert("PufferWithdrawalManager not available for this chain"); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the 3rd file that starts by 07_. We should rename