Improve error handling of verification

pull/5285/head
Manuel Wedler 4 months ago committed by Aniket
parent 2b98c79615
commit fd8de4e1e8
  1. 9
      apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts
  2. 14
      apps/contract-verification/src/app/app.tsx
  3. 3
      apps/contract-verification/src/app/types/VerificationTypes.ts
  4. 31
      apps/contract-verification/src/app/views/VerifyView.tsx

@ -121,9 +121,12 @@ export class EtherscanVerifier extends AbstractVerifier {
if (checkStatusResponse.result === 'Pending in queue') {
return { status: 'pending', receiptId }
}
if (checkStatusResponse.result === 'Pass - Verified' || checkStatusResponse.result === 'Already Verified') {
if (checkStatusResponse.result === 'Pass - Verified') {
return { status: 'verified', receiptId }
}
if (checkStatusResponse.result === 'Already Verified') {
return { status: 'already verified', receiptId }
}
if (checkStatusResponse.result === 'Unknown UID') {
console.error('Error on Etherscan API check verification status at ' + this.apiUrl + '\nStatus: ' + checkStatusResponse.status + '\nMessage: ' + checkStatusResponse.message + '\nResult: ' + checkStatusResponse.result)
return { status: 'failed', receiptId, message: checkStatusResponse.result }
@ -156,13 +159,13 @@ export class EtherscanVerifier extends AbstractVerifier {
const checkStatusResponse: EtherscanRpcResponse = await response.json()
if (checkStatusResponse.result === 'A corresponding implementation contract was unfortunately not detected for the proxy address.') {
if (checkStatusResponse.result === 'A corresponding implementation contract was unfortunately not detected for the proxy address.' || checkStatusResponse.result === 'The provided expected results are different than the retrieved implementation address!') {
return { status: 'failed', receiptId, message: checkStatusResponse.result }
}
if (checkStatusResponse.result === 'Verification in progress') {
return { status: 'pending', receiptId }
}
if (checkStatusResponse.result.startsWith('The proxy\'s') && checkStatusResponse.result.endsWith('and is successfully updated.')) {
if (checkStatusResponse.result.startsWith("The proxy's") && checkStatusResponse.result.endsWith('and is successfully updated.')) {
return { status: 'verified', receiptId }
}
if (checkStatusResponse.result === 'Unknown UID') {

@ -110,7 +110,14 @@ const App = () => {
const { status, message } = response
receipt.status = status
receipt.message = message
} catch (e) {} // try again in next call
} catch (e) {
receipt.failedChecks++
// Only retry 5 times
if (receipt.failedChecks >= 5) {
receipt.status = 'failed'
receipt.message = e.message
}
}
}
}
@ -122,10 +129,9 @@ const App = () => {
setSubmittedContracts((prev) => Object.assign({}, prev, changedSubmittedContracts))
}
pollStatus()
timer.current = setInterval(pollStatus, 10000)
timer.current = setInterval(pollStatus, 1000)
}
})
}, [submittedContracts])
return (
<AppContext.Provider value={{ themeType, setThemeType, settings, setSettings, chains, compilationOutput, submittedContracts, setSubmittedContracts }}>

@ -32,6 +32,7 @@ export interface VerificationReceipt {
message?: string
contractId: string
isProxyReceipt: boolean
failedChecks: number
}
export interface SubmittedContract {
@ -54,7 +55,7 @@ export interface SubmittedContracts {
}
type SourcifyStatus = 'fully verified' | 'partially verified'
type EtherscanStatus = 'verified'
type EtherscanStatus = 'verified' | 'already verified'
export type VerificationStatus = SourcifyStatus | EtherscanStatus | 'failed' | 'pending' | 'not verified' | 'unknown' | 'lookup failed'
export interface VerificationResponse {

@ -9,7 +9,7 @@ import { useNavigate } from 'react-router-dom'
import { ConstructorArguments } from '../components/ConstructorArguments'
import { ContractDropdownSelection } from '../components/ContractDropdown'
import { CustomTooltip } from '@remix-ui/helper'
import { getVerifier } from '../Verifiers'
import { AbstractVerifier, getVerifier } from '../Verifiers'
export const VerifyView = () => {
const { compilationOutput, setSubmittedContracts, settings } = useContext(AppContext)
@ -65,7 +65,7 @@ export const VerifyView = () => {
apiUrl: chainSettings.verifiers[verifierId].apiUrl,
name: verifierId as VerifierIdentifier,
}
receipts.push({ verifierInfo, status: 'pending', contractId, isProxyReceipt: false })
receipts.push({ verifierInfo, status: 'pending', contractId, isProxyReceipt: false, failedChecks: 0 })
}
const newSubmittedContract: SubmittedContract = {
@ -89,16 +89,25 @@ export const VerifyView = () => {
}
const verifierSettings = chainSettings.verifiers[verifierId]
const verifier = getVerifier(verifierId as VerifierIdentifier, { ...verifierSettings })
if (!verifier.verifyProxy) {
continue
}
const verifierInfo: VerifierInfo = {
apiUrl: verifierSettings.apiUrl,
name: verifierId as VerifierIdentifier,
}
proxyReceipts.push({ verifierInfo, status: 'pending', contractId, isProxyReceipt: true })
let verifier: AbstractVerifier
try {
verifier = getVerifier(verifierId as VerifierIdentifier, verifierSettings)
} catch (e) {
// User settings might be invalid
proxyReceipts.push({ verifierInfo, status: 'failed', contractId, isProxyReceipt: true, message: e.message, failedChecks: 0 })
continue
}
if (!verifier.verifyProxy) {
continue
}
proxyReceipts.push({ verifierInfo, status: 'pending', contractId, isProxyReceipt: true, failedChecks: 0 })
}
newSubmittedContract.proxyAddress = proxyAddress
@ -111,10 +120,14 @@ export const VerifyView = () => {
navigate('/receipts')
const verify = async (receipt: VerificationReceipt) => {
if (receipt.status === 'failed') {
return // failed already when creating
}
const { verifierInfo } = receipt
const verifierSettings = chainSettings.verifiers[verifierInfo.name]
const verifier = getVerifier(verifierInfo.name, { ...verifierSettings })
try {
const verifier = getVerifier(verifierInfo.name, verifierSettings)
let response: VerificationResponse
if (receipt.isProxyReceipt) {
response = await verifier.verifyProxy(newSubmittedContract)

Loading…
Cancel
Save