Skip to content

Commit

Permalink
Merge pull request #225 from OffchainLabs/verify-improve
Browse files Browse the repository at this point in the history
chore: verification improvements
  • Loading branch information
gzeoneth authored Aug 15, 2024
2 parents 2bcd282 + 72394e0 commit 4cbf68f
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 45 deletions.
30 changes: 22 additions & 8 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@nomiclabs/hardhat-waffle'
import 'hardhat-deploy'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-etherscan'
import '@nomicfoundation/hardhat-verify'
import '@typechain/hardhat'
import 'solidity-coverage'
import 'hardhat-gas-reporter'
Expand Down Expand Up @@ -110,8 +110,8 @@ module.exports = {
? [process.env['DEVNET_PRIVKEY']]
: [],
},
rinkeby: {
url: 'https://rinkeby.infura.io/v3/' + process.env['INFURA_KEY'],
holesky: {
url: 'https://holesky.infura.io/v3/' + process.env['INFURA_KEY'],
accounts: process.env['DEVNET_PRIVKEY']
? [process.env['DEVNET_PRIVKEY']]
: [],
Expand Down Expand Up @@ -146,6 +146,18 @@ module.exports = {
? [process.env['MAINNET_PRIVKEY']]
: [],
},
base: {
url: 'https://mainnet.base.org',
accounts: process.env['MAINNET_PRIVKEY']
? [process.env['MAINNET_PRIVKEY']]
: [],
},
baseSepolia: {
url: 'https://sepolia.base.org',
accounts: process.env['DEVNET_PRIVKEY']
? [process.env['DEVNET_PRIVKEY']]
: [],
},
geth: {
url: 'http://localhost:8545',
},
Expand All @@ -155,12 +167,14 @@ module.exports = {
mainnet: process.env['ETHERSCAN_API_KEY'],
goerli: process.env['ETHERSCAN_API_KEY'],
sepolia: process.env['ETHERSCAN_API_KEY'],
rinkeby: process.env['ETHERSCAN_API_KEY'],
holesky: process.env['ETHERSCAN_API_KEY'],
arbitrumOne: process.env['ARBISCAN_API_KEY'],
arbitrumTestnet: process.env['ARBISCAN_API_KEY'],
nova: process.env['NOVA_ARBISCAN_API_KEY'],
arbGoerliRollup: process.env['ARBISCAN_API_KEY'],
arbSepolia: process.env['ARBISCAN_API_KEY'],
base: process.env['BASESCAN_API_KEY'],
baseSepolia: process.env['BASESCAN_API_KEY'],
},
customChains: [
{
Expand All @@ -183,8 +197,8 @@ module.exports = {
network: 'arbSepolia',
chainId: 421614,
urls: {
apiURL: 'https://sepolia-explorer.arbitrum.io/api',
browserURL: 'https://sepolia-explorer.arbitrum.io/',
apiURL: 'https://api-sepolia.arbiscan.io/api',
browserURL: 'https://sepolia.arbiscan.io/',
},
},
],
Expand All @@ -200,6 +214,6 @@ module.exports = {
target: 'ethers-v5',
},
contractSizer: {
strict: true
}
strict: true,
},
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"devDependencies": {
"@arbitrum/sdk": "^3.4.1",
"@ethersproject/providers": "^5.7.2",
"@nomicfoundation/hardhat-verify": "^2.0.9",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@tovarishfin/hardhat-yul": "^3.0.5",
"@typechain/ethers-v5": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/createEthRollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@nomiclabs/hardhat-ethers'
import { createRollup } from './rollupCreation'

async function main() {
const feeToken = undefined
const feeToken = ethers.constants.AddressZero
const rollupCreatorAddress = process.env.ROLLUP_CREATOR_ADDRESS
if (!rollupCreatorAddress) {
throw new Error('ROLLUP_CREATOR_ADDRESS not set')
Expand Down
18 changes: 17 additions & 1 deletion scripts/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { deployAllContracts } from './deploymentUtils'
import { deployAllContracts, _isRunningOnArbitrum } from './deploymentUtils'
import { maxDataSize } from './config'

import {
ArbSys__factory
} from '../build/types'

async function main() {
const [signer] = await ethers.getSigners()

console.log('Deploying contracts with maxDataSize:', maxDataSize)
if (process.env['IGNORE_MAX_DATA_SIZE_WARNING'] !== 'true') {
let isArbitrum = await _isRunningOnArbitrum(signer)
if (isArbitrum && maxDataSize as any !== 104857) {
throw new Error('maxDataSize should be 104857 when the parent chain is Arbitrum (set IGNORE_MAX_DATA_SIZE_WARNING to ignore)')
} else if (!isArbitrum && maxDataSize as any !== 117964) {
throw new Error('maxDataSize should be 117964 when the parent chain is not Arbitrum (set IGNORE_MAX_DATA_SIZE_WARNING to ignore)')
}
} else {
console.log('Ignoring maxDataSize warning')
}

try {
// Deploying all contracts
Expand Down
32 changes: 30 additions & 2 deletions scripts/deploymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ export async function verifyContract(
contract?: string
address: string
constructorArguments: any[]
force: boolean
} = {
address: contractAddress,
constructorArguments: constructorArguments,
force: true,
}

// if contractPathAndName is provided, add it to the verification options
Expand All @@ -45,8 +47,15 @@ export async function verifyContract(
await run('verify:verify', verificationOptions)
console.log(`Verified contract ${contractName} successfully.`)
} catch (error: any) {
if (error.message.includes('Already Verified')) {
if (error.message.toLowerCase().includes('already verified')) {
console.log(`Contract ${contractName} is already verified.`)
} else if (error.message.includes('does not have bytecode')) {
await verifyContract(
contractName,
contractAddress,
constructorArguments,
contractPathAndName
)
} else {
console.error(
`Verification for ${contractName} failed with the following error: ${error.message}`
Expand All @@ -69,11 +78,21 @@ export async function deployContract(
let deploymentArgs = [...constructorArgs]
if (overrides) {
deploymentArgs.push(overrides)
} else {
// overrides = {
// maxFeePerGas: ethers.utils.parseUnits('5.0', 'gwei'),
// maxPriorityFeePerGas: ethers.utils.parseUnits('0.01', 'gwei')
// }
// deploymentArgs.push(overrides)
}

const contract: Contract = await connectedFactory.deploy(...deploymentArgs)
await contract.deployTransaction.wait()
console.log(`New ${contractName} created at address:`, contract.address)
console.log(
`* New ${contractName} created at address: ${
contract.address
} ${constructorArgs.join(' ')}`
)

if (verify)
await verifyContract(contractName, contract.address, constructorArgs)
Expand Down Expand Up @@ -226,6 +245,15 @@ export async function deployAllContracts(
verify
)
const deployHelper = await deployContract('DeployHelper', signer, [], verify)
if (verify && !process.env.DISABLE_VERIFICATION) {
// Deploy RollupProxy contract only for verification, should not be used anywhere else
await deployContract(
'RollupProxy',
signer,
[],
verify
)
}
return {
bridgeCreator,
prover0,
Expand Down
24 changes: 8 additions & 16 deletions scripts/rollupCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BigNumber, Signer } from 'ethers'
import { ERC20, ERC20__factory, IERC20__factory } from '../build/types'
import { sleep } from './testSetup'
import { promises as fs } from 'fs'
import { _isRunningOnArbitrum } from './deploymentUtils'
import { _isRunningOnArbitrum, verifyContract } from './deploymentUtils'

// 1 gwei
const MAX_FER_PER_GAS = BigNumber.from('1000000000')
Expand Down Expand Up @@ -149,21 +149,13 @@ export async function createRollup(
console.log(
`Attempting to verify Rollup contract at address ${rollupAddress}...`
)
try {
await run('verify:verify', {
contract: 'src/rollup/RollupProxy.sol:RollupProxy',
address: rollupAddress,
constructorArguments: [],
})
} catch (error: any) {
if (error.message.includes('Already Verified')) {
console.log(`Contract RollupProxy is already verified.`)
} else {
console.error(
`Verification for RollupProxy failed with the following error: ${error.message}`
)
}
}

await verifyContract(
'RollupProxy',
rollupAddress,
[],
'src/rollup/RollupProxy.sol:RollupProxy'
)
}

console.log('Inbox (proxy) Contract created at address:', inboxAddress)
Expand Down
2 changes: 2 additions & 0 deletions src/mocks/BridgeUnproxied.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {BadSequencerMessageNumber} from "../libraries/Error.sol";
import "../bridge/Bridge.sol";

contract BridgeUnproxied is Bridge {
uint256 public DUMMYVAR = 0; // This is a dummy variable to disambiguous with the Bridge contract

constructor() {
_activeOutbox = EMPTY_ACTIVEOUTBOX;
rollup = IOwnable(msg.sender);
Expand Down
36 changes: 20 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,21 @@
"@nomicfoundation/ethereumjs-rlp" "5.0.4"
ethereum-cryptography "0.1.3"

"@nomicfoundation/hardhat-verify@^2.0.9":
version "2.0.9"
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.9.tgz#98a1c9a3742b008be71a709d074f10dec23bc5f0"
integrity sha512-7kD8hu1+zlnX87gC+UN4S0HTKBnIsDfXZ/pproq1gYsK94hgCk+exvzXbwR0X2giiY/RZPkqY9oKRi0Uev91hQ==
dependencies:
"@ethersproject/abi" "^5.1.2"
"@ethersproject/address" "^5.0.2"
cbor "^8.1.0"
chalk "^2.4.2"
debug "^4.1.1"
lodash.clonedeep "^4.5.0"
semver "^6.3.0"
table "^6.8.0"
undici "^5.14.0"

"@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.2.tgz#3a9c3b20d51360b20affb8f753e756d553d49557"
Expand Down Expand Up @@ -864,22 +879,6 @@
resolved "https://registry.yarnpkg.com/hardhat-deploy-ethers/-/hardhat-deploy-ethers-0.3.0-beta.13.tgz#b96086ff768ddf69928984d5eb0a8d78cfca9366"
integrity sha512-PdWVcKB9coqWV1L7JTpfXRCI91Cgwsm7KLmBcwZ8f0COSm1xtABHZTyz3fvF6p42cTnz1VM0QnfDvMFlIRkSNw==

"@nomiclabs/hardhat-etherscan@^3.1.0":
version "3.1.8"
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.1.8.tgz#3c12ee90b3733e0775e05111146ef9418d4f5a38"
integrity sha512-v5F6IzQhrsjHh6kQz4uNrym49brK9K5bYCq2zQZ729RYRaifI9hHbtmK+KkIVevfhut7huQFEQ77JLRMAzWYjQ==
dependencies:
"@ethersproject/abi" "^5.1.2"
"@ethersproject/address" "^5.0.2"
cbor "^8.1.0"
chalk "^2.4.2"
debug "^4.1.1"
fs-extra "^7.0.1"
lodash "^4.17.11"
semver "^6.3.0"
table "^6.8.0"
undici "^5.14.0"

"@nomiclabs/hardhat-waffle@^2.0.1":
version "2.0.6"
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.6.tgz#d11cb063a5f61a77806053e54009c40ddee49a54"
Expand Down Expand Up @@ -4771,6 +4770,11 @@ lodash.camelcase@^4.3.0:
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY=

lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==

lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
Expand Down

0 comments on commit 4cbf68f

Please sign in to comment.