Skip to content

Commit

Permalink
fix: update holesky rollup creator address to v1.1.0 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored Mar 15, 2024
1 parent 1e39d21 commit 04fadb0
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ETHERSCAN_API_KEY=
ARBISCAN_API_KEY=

NITRO_TESTNODE_DEPLOYER_PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
NITRO_TESTNODE_L2_ROLLUP_OWNER_PRIVATE_KEY=0xdc04c5399f82306ec4b4d654a342f40e2e0620fe39950d967e1e574b32d4dd36
NITRO_TESTNODE_L3_ROLLUP_OWNER_PRIVATE_KEY=0xecdf21cb41c65afb51f91df408b7656e2c8739a5877f2814add0afd780cc210e
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Set up the local node
uses: OffchainLabs/actions/run-nitro-test-node@main
with:
nitro-testnode-ref: transfer-ownership
nitro-testnode-ref: 1647de2c5f75ee0fbe5986e3f20d35bc75191ea6 # https://github.com/OffchainLabs/nitro-testnode/pull/42
# Use simple mode
no-simple: false
# RollupCreator on L1 is deployed by default
Expand Down
20 changes: 16 additions & 4 deletions patches/@wagmi+cli+1.5.2.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
diff --git a/node_modules/@wagmi/cli/dist/plugins/index.d.ts b/node_modules/@wagmi/cli/dist/plugins/index.d.ts
index 04a78d1..0eb6430 100644
index 04a78d1..1574961 100644
--- a/node_modules/@wagmi/cli/dist/plugins/index.d.ts
+++ b/node_modules/@wagmi/cli/dist/plugins/index.d.ts
@@ -119,7 +119,9 @@ declare const apiUrls: {
@@ -114,12 +114,15 @@ declare const apiUrls: {
1: string;
5: string;
11155111: string;
+ 17000: string;
10: string;
420: string;
137: string;
80001: string;
42161: string;
Expand All @@ -13,10 +19,16 @@ index 04a78d1..0eb6430 100644
97: string;
128: string;
diff --git a/node_modules/@wagmi/cli/dist/plugins/index.js b/node_modules/@wagmi/cli/dist/plugins/index.js
index 8e23da2..bd8221d 100644
index 8e23da2..4cc878a 100644
--- a/node_modules/@wagmi/cli/dist/plugins/index.js
+++ b/node_modules/@wagmi/cli/dist/plugins/index.js
@@ -1386,7 +1386,9 @@ var apiUrls = {
@@ -1381,12 +1381,15 @@ var apiUrls = {
[1]: "https://api.etherscan.io/api",
[5]: "https://api-goerli.etherscan.io/api",
[11155111]: "https://api-sepolia.etherscan.io/api",
+ [17000]: "https://api-holesky.etherscan.io/api",
[10]: "https://api-optimistic.etherscan.io/api",
[420]: "https://api-goerli-optimistic.etherscan.io/api",
[137]: "https://api.polygonscan.com/api",
[80001]: "https://api-testnet.polygonscan.com/api",
[42161]: "https://api.arbiscan.io/api",
Expand Down
2 changes: 1 addition & 1 deletion src/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export const rollupCreatorABI = [
export const rollupCreatorAddress = {
1: '0x90D68B056c411015eaE3EC0b98AD94E2C91419F1',
1337: '0x596eAbE0291D4cdAfAC7ef53D16C92Bf6922b5e0',
17000: '0xB84111D0539105ef0D1A96D2f555E3f6AeEd47d4',
17000: '0xB512078282F462Ba104231ad856464Ceb0a7747e',
42161: '0x9CAd81628aB7D8e239F1A5B497313341578c5F71',
42170: '0x9CAd81628aB7D8e239F1A5B497313341578c5F71',
333333: '0x0000000000000000000000000000000000000000',
Expand Down
95 changes: 69 additions & 26 deletions wagmi.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { erc, etherscan } from '@wagmi/cli/plugins';
import { hashMessage } from 'viem';
import dotenv from 'dotenv';

import { ParentChainId } from './src';
Expand All @@ -16,37 +17,70 @@ import {

dotenv.config();

if (typeof process.env.ARBISCAN_API_KEY === 'undefined') {
throw new Error('Missing ARBISCAN_API_KEY environment variable');
}
function loadApiKey(key: string): string {
const apiKey = process.env[key];

const apiKey: string = process.env.ARBISCAN_API_KEY;
if (typeof apiKey === 'undefined' || apiKey.length === 0) {
throw new Error(`Missing the ${key} environment variable!`);
}

return apiKey;
}

function sleep(ms: number = 3_000) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

const blockExplorerApiUrls: Record<ParentChainId, string> = {
const arbiscanApiKey = loadApiKey('ARBISCAN_API_KEY');
const etherscanApiKey = loadApiKey('ETHERSCAN_API_KEY');

const blockExplorerApiUrls: Record<ParentChainId, { url: string; apiKey: string }> = {
// mainnet
[mainnet.id]: 'https://etherscan.io/api',
[arbitrumOne.id]: 'https://arbiscan.io/api',
[arbitrumNova.id]: 'https://api-nova.arbiscan.io/api',
[mainnet.id]: {
url: 'https://api.etherscan.io/api',
apiKey: etherscanApiKey,
},
[arbitrumOne.id]: {
url: 'https://api.arbiscan.io/api',
apiKey: arbiscanApiKey,
},
[arbitrumNova.id]: {
url: 'https://api-nova.arbiscan.io/api',
apiKey: arbiscanApiKey,
},
// testnet
[sepolia.id]: 'https://api-sepolia.etherscan.io/api',
[holesky.id]: 'https://api-holesky.etherscan.io/api',
[arbitrumSepolia.id]: 'https://api-sepolia.arbiscan.io/api',
[sepolia.id]: {
url: 'https://api-sepolia.etherscan.io/api',
apiKey: etherscanApiKey,
},
[holesky.id]: {
url: 'https://api-holesky.etherscan.io/api',
apiKey: etherscanApiKey,
},
[arbitrumSepolia.id]: {
url: 'https://api-sepolia.arbiscan.io/api',
apiKey: arbiscanApiKey,
},
// local nitro-testnode / fine to omit these as we skip abi fetch
[nitroTestnodeL1.id]: '',
[nitroTestnodeL2.id]: '',
[nitroTestnodeL3.id]: '',
[nitroTestnodeL1.id]: { url: '', apiKey: '' },
[nitroTestnodeL2.id]: { url: '', apiKey: '' },
[nitroTestnodeL3.id]: { url: '', apiKey: '' },
};

export async function fetchAbi(chainId: ParentChainId, address: `0x${string}`) {
await (
const { url, apiKey } = blockExplorerApiUrls[chainId];

const responseJson = await (
await fetch(
`${blockExplorerApiUrls[chainId]}?module=contract&action=getabi&format=raw&address=${address}&apikey=${process.env.ARBISCAN_API_KEY}`,
`${url}?module=contract&action=getabi&format=raw&address=${address}&apikey=${apiKey}`,
)
).json();

if (responseJson.message === 'NOTOK') {
throw new Error(`Failed to fetch ABI for ${chainId}: ${responseJson.result}`);
}

return responseJson;
}

type ContractConfig = {
Expand All @@ -66,7 +100,7 @@ const contracts: ContractConfig[] = [
[arbitrumNova.id]: '0x9CAd81628aB7D8e239F1A5B497313341578c5F71',
// testnet
[sepolia.id]: '0xfbd0b034e6305788007f6e0123cc5eae701a5751',
[holesky.id]: '0xB84111D0539105ef0D1A96D2f555E3f6AeEd47d4',
[holesky.id]: '0xB512078282F462Ba104231ad856464Ceb0a7747e',
[arbitrumSepolia.id]: '0x06E341073b2749e0Bb9912461351f716DeCDa9b0',
// local nitro-testnode (on "release" branch with --tokenbridge --l3node --l3-token-bridge flags)
[nitroTestnodeL1.id]: '0x596eabe0291d4cdafac7ef53d16c92bf6922b5e0',
Expand Down Expand Up @@ -113,7 +147,9 @@ export async function assertContractAbisMatch(contract: ContractConfig) {
return;
}

const abis = await Promise.all(
console.log(`- ${contract.name}`);

const abiHashes = await Promise.all(
Object.entries(contract.address)
// don't fetch abis for testnode
.filter(([chainIdString]) => {
Expand All @@ -124,20 +160,27 @@ export async function assertContractAbisMatch(contract: ContractConfig) {
chainId !== nitroTestnodeL3.id
);
})
// fetch abis for all chains
.map(([chainId, address]) => fetchAbi(Number(chainId) as ParentChainId, address)),
// fetch abis for all chains and hash them
.map(async ([chainId, address]) => {
const abi = await fetchAbi(Number(chainId) as ParentChainId, address);
const abiHash = hashMessage(JSON.stringify(abi));

console.log(`- ${abiHash} (${chainId})`);

return abiHash;
}),
);

// make sure all abis are the same
if (!allEqual(abis.map((abi) => JSON.stringify(abi)))) {
throw new Error(`- ${contract.name} ERROR`);
// make sure all abis hashes are the same
if (!allEqual(abiHashes)) {
throw new Error(`- ${contract.name}`);
}

console.log(`- ${contract.name} ✔`);
console.log(`- ${contract.name}\n`);
}

export default async function () {
console.log(`Checking if contract ABIs match...`);
console.log(`Checking if contracts match by comparing hashed JSON ABIs.\n`);

for (const contract of contracts) {
await assertContractAbisMatch(contract);
Expand All @@ -154,7 +197,7 @@ export default async function () {
}),
etherscan({
chainId: arbitrumSepolia.id,
apiKey,
apiKey: arbiscanApiKey,
contracts,
cacheDuration: 0,
}),
Expand Down

0 comments on commit 04fadb0

Please sign in to comment.