Skip to content

Commit

Permalink
fix: remove redundant proxy verification attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Nov 18, 2022
1 parent 6a2644e commit 0b52005
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .changeset/hip-mayflies-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@chugsplash/executor': patch
'@chugsplash/plugins': patch
---

Remove redundant Proxy verification attempts. Link ChugSplashManager proxy with its implementation on Etherscan.
53 changes: 24 additions & 29 deletions packages/executor/src/utils/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import { buildContractUrl } from '@nomiclabs/hardhat-etherscan/dist/src/util'
import { getLongVersion } from '@nomiclabs/hardhat-etherscan/dist/src/solc/version'
import { encodeArguments } from '@nomiclabs/hardhat-etherscan/dist/src/ABIEncoder'
import {
buildInfo as proxyBuildInfo,
ChugSplashManagerABI,
ProxyArtifact,
CHUGSPLASH_MANAGER_ADDRESS,
} from '@chugsplash/contracts'
import { EthereumProvider, HardhatRuntimeEnvironment } from 'hardhat/types'
import { request } from 'undici'
Expand Down Expand Up @@ -66,6 +65,18 @@ export const verifyChugSplashConfig = async (
hre.ethers.provider
)

// Link the project's ChugSplashManagerProxy with the ChugSplashManager.
const chugsplashManagerProxyAddress = getChugSplashManagerProxyAddress(
canonicalConfig.options.projectName
)
await linkProxyWithImplementation(
etherscanApiEndpoints,
etherscanApiKey,
chugsplashManagerProxyAddress,
CHUGSPLASH_MANAGER_ADDRESS,
'ChugSplashManager'
)

for (const referenceName of Object.keys(canonicalConfig.contracts)) {
const artifact = artifacts[referenceName]
const { abi, contractName, sourceName, compilerOutput } = artifact
Expand All @@ -81,33 +92,13 @@ export const verifyChugSplashConfig = async (
const implementationAddress = await ChugSplashManager.implementations(
referenceName
)

const compilerInput = canonicalConfig.inputs.find((compilerInputs) =>
Object.keys(compilerInputs.input.sources).includes(sourceName)
)

// Verify the proxy
const proxyAddress = getProxyAddress(
canonicalConfig.options.projectName,
referenceName
)
const {
sourceName: proxySourceName,
contractName: proxyContractName,
abi: proxyAbi,
} = ProxyArtifact
await attemptVerification(
hre.network.provider,
hre.network.name,
etherscanApiEndpoints,
proxyAddress,
proxySourceName,
proxyContractName,
proxyAbi,
etherscanApiKey,
proxyBuildInfo.input,
proxyBuildInfo.solcVersion,
[getChugSplashManagerProxyAddress(canonicalConfig.options.projectName)]

const compilerInput = canonicalConfig.inputs.find((compilerInputs) =>
Object.keys(compilerInputs.input.sources).includes(sourceName)
)

// Verify the implementation
Expand Down Expand Up @@ -269,7 +260,7 @@ export const linkProxyWithImplementation = async (
etherscanApiKey: string,
proxyAddress: string,
implAddress: string,
contractName: string
implContractName: string
) => {
const params = {
module: 'contract',
Expand Down Expand Up @@ -304,10 +295,13 @@ export const linkProxyWithImplementation = async (
}

if (responseBody.status === RESPONSE_OK) {
console.log(`Successfully linked ${contractName} proxy to implementation.`)
console.log(
`Successfully linked ${implContractName} proxy to implementation.`
)
} else {
throw new Error(
`Failed to link ${contractName} proxy with its implementation. Reason: ${responseBody.result}`
`Failed to link ${implContractName} proxy with its implementation.
Reason: ${responseBody.result}`
)
}
}
Expand All @@ -331,7 +325,8 @@ export const callEtherscanApi = async (
if (!(response.statusCode >= 200 && response.statusCode <= 299)) {
const responseBodyText = await response.body.text()
throw new Error(
`Etherscan API call failed with status ${response.statusCode}. Response: ${responseBodyText}`
`Etherscan API call failed with status ${response.statusCode}.
Response: ${responseBodyText}`
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/hardhat/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const postExecutionActions = async (
const currChugSplashManagerOwner = await ChugSplashManager.owner()

// Exit early if the calling address is not the current owner of the ChugSplashManager.
if (signer.getAddress() !== currChugSplashManagerOwner) {
if ((await signer.getAddress()) !== currChugSplashManagerOwner) {
return
}

Expand Down

0 comments on commit 0b52005

Please sign in to comment.