forked from ArbitrumFoundation/governance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into extra-contender-phase
- Loading branch information
Showing
32 changed files
with
549 additions
and
40 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
Binary file not shown.
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 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,90 @@ | ||
import { IAccessControlUpgradeable__factory } from "../typechain-types"; | ||
import { keccak256, toUtf8Bytes } from "ethers/lib/utils"; | ||
import { Provider, JsonRpcProvider } from "@ethersproject/providers"; | ||
|
||
import { RoleGrantedEventObject } from "../typechain-types/@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable"; | ||
|
||
interface RolesToRolePreimages { | ||
[key: string]: string; | ||
} | ||
|
||
interface RolesToAccounts { | ||
[key: string]: Set<string>; | ||
} | ||
|
||
const rolesPreimages = [ | ||
"TIMELOCK_ADMIN_ROLE", | ||
"PROPOSER_ROLE", | ||
"EXECUTOR_ROLE", | ||
"CANCELLER_ROLE", | ||
"ADMIN_ROLE", | ||
"COHORT_REPLACER", | ||
"MEMBER_ADDER", | ||
"MEMBER_REPLACER", | ||
"MEMBER_ROTATOR", | ||
"MEMBER_REMOVER", | ||
]; | ||
const rolesToRolePreimages: RolesToRolePreimages = {}; | ||
rolesPreimages.forEach((roleStr: string) => { | ||
rolesToRolePreimages[keccak256(toUtf8Bytes(roleStr))] = roleStr; | ||
}); | ||
|
||
export const getCurrentRoles = async ( | ||
rpcProvider: Provider, | ||
contractAddr: string, | ||
displayName: string, | ||
fromBlock = 0, | ||
verbose = true | ||
) => { | ||
const network = await rpcProvider.getNetwork(); | ||
if (verbose) { | ||
console.log(`Checking roles for ${contractAddr} "${displayName}" on chain ${network.chainId}`); | ||
} | ||
|
||
const accessControlContract = IAccessControlUpgradeable__factory.connect( | ||
contractAddr, | ||
rpcProvider | ||
); | ||
const filterTopics = accessControlContract.interface.encodeFilterTopics("RoleGranted", []); | ||
|
||
const roleGrantedLogsRaw = await rpcProvider.getLogs({ | ||
fromBlock, | ||
topics: filterTopics, | ||
address: contractAddr, | ||
}); | ||
|
||
const roleGrantedLogs = roleGrantedLogsRaw.map((log) => { | ||
const parsedLog = accessControlContract.interface.parseLog(log); | ||
return parsedLog.args as unknown as RoleGrantedEventObject; | ||
}); | ||
|
||
const rolesToAccounts: RolesToAccounts = {}; | ||
for (let roleGrantedLog of roleGrantedLogs) { | ||
const { role, account } = roleGrantedLog; | ||
|
||
if (!(await accessControlContract.hasRole(role, account))) { | ||
continue; | ||
} | ||
|
||
if (rolesToAccounts[role]) { | ||
rolesToAccounts[role].add(account); | ||
} else { | ||
rolesToAccounts[role] = new Set([account]); | ||
} | ||
} | ||
if (verbose) { | ||
for (let roleHash of Object.keys(rolesToAccounts)) { | ||
const roleToDisplay = rolesToRolePreimages[roleHash] | ||
? rolesToRolePreimages[roleHash] | ||
: roleHash; | ||
console.log(""); | ||
console.log(`Accounts with '${roleToDisplay}':`); | ||
for (let account of rolesToAccounts[roleHash]) { | ||
console.log(account); | ||
} | ||
} | ||
console.log(""); | ||
console.log(""); | ||
} | ||
return rolesToAccounts; | ||
}; |
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,52 @@ | ||
import { Wallet } from "@ethersproject/wallet"; | ||
import { JsonRpcProvider } from "@ethersproject/providers"; | ||
import { L1AddressRegistry__factory } from "../typechain-types"; | ||
|
||
import { ContractVerifier } from "./contractVerifier"; | ||
import dotenv from "dotenv"; | ||
import { utils } from "ethers"; | ||
const abi = utils.defaultAbiCoder; | ||
|
||
dotenv.config(); | ||
|
||
const ETH_URL = process.env.ETH_URL; | ||
const ETH_KEY = process.env.ETH_KEY; | ||
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY; | ||
|
||
if (!ETH_URL) throw new Error("ETH_URL required"); | ||
if (!ETH_KEY) throw new Error("ETH_KEY required"); | ||
if (!ETHERSCAN_API_KEY) throw new Error("ETHERSCAN_API_KEY required"); | ||
|
||
const main = async () => { | ||
const l1Provider = new JsonRpcProvider(ETH_URL); | ||
const signer = new Wallet(ETH_KEY, l1Provider); | ||
|
||
const l1Verifier = new ContractVerifier(1, ETHERSCAN_API_KEY, {}); | ||
|
||
const NOVA_INBOX = "0xc4448b71118c9071Bcb9734A0EAc55D18A153949"; | ||
const L1_GOV_TIMELOCK = "0xE6841D92B0C345144506576eC13ECf5103aC7f49"; | ||
const NOVA_L1_CUSTOM_GATEWAY = "0x23122da8C581AA7E0d07A36Ff1f16F799650232f"; | ||
const NOVA_L1_GATEWAY_ROUTER = "0xC840838Bc438d73C16c2f8b22D2Ce3669963cD48"; | ||
|
||
const novaL1AddressRegistry = await new L1AddressRegistry__factory(signer).deploy( | ||
NOVA_INBOX, // nova inbox | ||
L1_GOV_TIMELOCK, // l1 gov timelock | ||
NOVA_L1_CUSTOM_GATEWAY, // nova l1 custom gateway | ||
NOVA_L1_GATEWAY_ROUTER // nova l1 gateway router | ||
); | ||
await novaL1AddressRegistry.deployed(); | ||
console.log("L1AddressRegistry deployed at", novaL1AddressRegistry.address); | ||
|
||
await l1Verifier.verifyWithAddress( | ||
"L1AddressRegistry", | ||
novaL1AddressRegistry.address, | ||
abi.encode( | ||
["address", "address", "address", "address"], | ||
[NOVA_INBOX, L1_GOV_TIMELOCK, NOVA_L1_CUSTOM_GATEWAY, NOVA_L1_GATEWAY_ROUTER] | ||
) | ||
); | ||
}; | ||
|
||
main().then(() => { | ||
console.log("Done"); | ||
}); |
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,21 @@ | ||
import { JsonRpcProvider } from "@ethersproject/providers"; | ||
import dotenv from "dotenv"; | ||
import { getCurrentRoles } from "./checkAccessControlRoles"; | ||
dotenv.config(); | ||
|
||
(async () => { | ||
const ethRpc = new JsonRpcProvider(process.env.ETH_URL); | ||
|
||
const arbOneRpc = new JsonRpcProvider(process.env.ARB_URL); | ||
|
||
const novaRPC = new JsonRpcProvider(process.env.NOVA_URL); | ||
|
||
await getCurrentRoles(arbOneRpc, "0x34d45e99f7D8c45ed05B5cA72D54bbD1fb3F98f0", "L2 Core Timelock"); | ||
await getCurrentRoles(arbOneRpc, "0xD509E5f5aEe2A205F554f36E8a7d56094494eDFC", "Security Council Manager"); | ||
await getCurrentRoles(arbOneRpc, "0xCF57572261c7c2BCF21ffD220ea7d1a27D40A827", "Arb1 Upgrade Executor"); | ||
|
||
await getCurrentRoles(ethRpc, "0xE6841D92B0C345144506576eC13ECf5103aC7f49", "L1 Timelock"); | ||
await getCurrentRoles(ethRpc, "0x3ffFbAdAF827559da092217e474760E2b2c3CeDd", "L1 Upgrade Executor"); | ||
|
||
await getCurrentRoles(novaRPC, "0x86a02dD71363c440b21F4c0E5B2Ad01Ffe1A7482", "Nova Upgrade Executor"); | ||
})(); |
Oops, something went wrong.