From 5774da512594fac8a4ae15eb08f31230aa500066 Mon Sep 17 00:00:00 2001 From: Oren Date: Tue, 27 Sep 2022 15:28:52 +0300 Subject: [PATCH 01/25] Increase solc compilcation max output buffer Increased from the default 200KB to 10MB. Hopefully it fixes https://github.com/ethereum/sourcify/issues/807 --- services/verification/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/verification/src/utils.ts b/services/verification/src/utils.ts index 384d91cf9..7890ddfe2 100644 --- a/services/verification/src/utils.ts +++ b/services/verification/src/utils.ts @@ -167,7 +167,7 @@ export async function useCompiler(version: string, solcJsonInput: any, log: Info const logObject = {loc: "[RECOMPILE]", version, solcPath}; log.info(logObject, "Compiling with external executable"); - const shellOutputBuffer = spawnSync(solcPath, ["--standard-json"], {input: inputStringified}); + const shellOutputBuffer = spawnSync(solcPath, ["--standard-json"], {input: inputStringified, maxBuffer: 1000 * 1000 * 10}); // Handle errors. if (shellOutputBuffer.error) { From 01c55b41520403f93d89dbbb826ddf64dcd4008f Mon Sep 17 00:00:00 2001 From: Kaan Uzdogan Date: Tue, 27 Sep 2022 16:17:58 +0200 Subject: [PATCH 02/25] Print multiple RPC errors --- services/verification/src/services/Injector.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/verification/src/services/Injector.ts b/services/verification/src/services/Injector.ts index 3bf0e2702..12cb2c4a6 100644 --- a/services/verification/src/services/Injector.ts +++ b/services/verification/src/services/Injector.ts @@ -154,10 +154,9 @@ export class Injector { try { deployedBytecode = await getBytecode(this.chains[chain].web3array, address); } catch (err: any) { - console.log(err) if (err?.errors?.length > 0) err.message = err.errors.map((e: { message: string; }) => e.message || e)// Avoid uninformative message "All Promises Rejected" - this.log.error({ loc: "[MATCH]", address, chain, msg: err.message }); + this.log.error({ loc: "[MATCH]", address, chain }, err.message.toString()); throw err; } From ddb3cbb069c039a71a399ae0b16b1d008929f84e Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Wed, 19 Apr 2023 17:49:04 +0200 Subject: [PATCH 03/25] Quick Release (#986) Disable match with simulation * Comment out all contextVariables * matchWithSimulation totally commented * Fix linting problem while creating ui build after commenting out matchWithSimulation --- packages/lib-sourcify/README.md | 1 - packages/lib-sourcify/src/lib/types.ts | 6 +-- packages/lib-sourcify/src/lib/verification.ts | 17 ++++++--- packages/lib-sourcify/test/utils.ts | 10 +++-- .../lib-sourcify/test/verification.spec.ts | 15 +++++--- src/monitor/monitor.ts | 2 +- .../VerificationController-util.ts | 22 ++++++----- .../controllers/VerificationController.ts | 14 +++---- src/server/services/RepositoryService.ts | 6 +-- src/server/services/VerificationService.ts | 10 ++--- .../ChainAddressForm/index.tsx | 38 ++++++++++--------- ui/src/types.ts | 4 +- 12 files changed, 83 insertions(+), 62 deletions(-) diff --git a/packages/lib-sourcify/README.md b/packages/lib-sourcify/README.md index 2eb24e060..e143fa845 100644 --- a/packages/lib-sourcify/README.md +++ b/packages/lib-sourcify/README.md @@ -51,7 +51,6 @@ export async function verifyDeployed( checkedContract: CheckedContract, sourcifyChain: SourcifyChain, address: string, - contextVariables?: ContextVariables, creatorTxHash?: string ): Promise; ``` diff --git a/packages/lib-sourcify/src/lib/types.ts b/packages/lib-sourcify/src/lib/types.ts index 143da6f40..076454bb8 100644 --- a/packages/lib-sourcify/src/lib/types.ts +++ b/packages/lib-sourcify/src/lib/types.ts @@ -82,7 +82,7 @@ export interface Match { abiEncodedConstructorArguments?: string; create2Args?: Create2Args; libraryMap?: StringMap; - contextVariables?: ContextVariables; + /* contextVariables?: ContextVariables; */ creatorTxHash?: string; immutableReferences?: ImmutableReferences; } @@ -135,10 +135,10 @@ type Currency = { decimals: number; }; -export type ContextVariables = { +/* export type ContextVariables = { abiEncodedConstructorArguments?: string; msgSender?: string; -}; +}; */ interface File { keccak256?: string; diff --git a/packages/lib-sourcify/src/lib/verification.ts b/packages/lib-sourcify/src/lib/verification.ts index 0fafbeae5..53cbeb737 100644 --- a/packages/lib-sourcify/src/lib/verification.ts +++ b/packages/lib-sourcify/src/lib/verification.ts @@ -1,6 +1,6 @@ import { CheckedContract } from './CheckedContract'; import { - ContextVariables, + /* ContextVariables, */ Create2Args, ImmutableReferences, Match, @@ -14,12 +14,14 @@ import { decode as bytecodeDecode, splitAuxdata, } from '@ethereum-sourcify/bytecode-utils'; +/* import { EVM } from '@ethereumjs/evm'; import { EEI } from '@ethereumjs/vm'; import { Address } from '@ethereumjs/util'; import { Common } from '@ethereumjs/common'; import { DefaultStateManager } from '@ethereumjs/statemanager'; import { Blockchain } from '@ethereumjs/blockchain'; +*/ import { hexZeroPad, isHexString } from '@ethersproject/bytes'; import { BigNumber } from '@ethersproject/bignumber'; import { getAddress, getContractAddress } from '@ethersproject/address'; @@ -31,7 +33,7 @@ export async function verifyDeployed( checkedContract: CheckedContract, sourcifyChain: SourcifyChain, address: string, - contextVariables?: ContextVariables, + /* _contextVariables?: ContextVariables, */ creatorTxHash?: string ): Promise { const match: Match = { @@ -62,6 +64,7 @@ export async function verifyDeployed( if (match.status) return match; // Try to match with simulating the creation bytecode + /* await matchWithSimulation( match, recompiled.creationBytecode, @@ -74,6 +77,7 @@ export async function verifyDeployed( match.contextVariables = contextVariables; return match; } + */ // Try to match with creationTx, if available if (creatorTxHash) { @@ -193,6 +197,7 @@ export function matchWithDeployedBytecode( } } +/* export async function matchWithSimulation( match: Match, recompiledCreaionBytecode: string, @@ -234,7 +239,7 @@ export async function matchWithSimulation( data: initcode, gasLimit: BigInt(0xffffffffff), // prettier vs. eslint indentation conflict here - /* eslint-disable indent */ + // eslint-disable indent caller: msgSender ? new Address( Buffer.from( @@ -243,7 +248,7 @@ export async function matchWithSimulation( ) ) : undefined, - /* eslint-enable indent */ + // eslint-disable indent }); const simulationDeployedBytecode = '0x' + result.execResult.returnValue.toString('hex'); @@ -253,7 +258,9 @@ export async function matchWithSimulation( simulationDeployedBytecode, deployedBytecode ); -} +} +*/ + /** * Matches the contract via the transaction that created the contract, if that tx is known. * Checks if the tx.input matches the recompiled creation bytecode. Double checks that the contract address matches the address being verified. diff --git a/packages/lib-sourcify/test/utils.ts b/packages/lib-sourcify/test/utils.ts index 3fb0979a9..a76fa727e 100644 --- a/packages/lib-sourcify/test/utils.ts +++ b/packages/lib-sourcify/test/utils.ts @@ -10,7 +10,11 @@ import path from 'path'; import Web3 from 'web3'; import fs from 'fs'; -import { ContextVariables, Match, SourcifyChain, verifyDeployed } from '../src'; +import { + /* ContextVariables, */ Match, + SourcifyChain, + verifyDeployed, +} from '../src'; import { checkFiles } from '../src'; import { expect } from 'chai'; @@ -76,7 +80,7 @@ export const checkAndVerifyDeployed = async ( contractFolderPath: string, sourcifyChain: SourcifyChain, address: string, - contextVariables?: ContextVariables, + /* contextVariables?: ContextVariables, */ creatorTxHash?: string ) => { const checkedContracts = await checkFilesFromContractFolder( @@ -87,7 +91,7 @@ export const checkAndVerifyDeployed = async ( checkedContracts[0], sourcifyChain, address, - contextVariables, + /* contextVariables, */ creatorTxHash ); return match; diff --git a/packages/lib-sourcify/test/verification.spec.ts b/packages/lib-sourcify/test/verification.spec.ts index f79b91943..9371422d5 100644 --- a/packages/lib-sourcify/test/verification.spec.ts +++ b/packages/lib-sourcify/test/verification.spec.ts @@ -4,7 +4,7 @@ import { SourcifyChain } from '../src/lib/types'; import Web3 from 'web3'; import Ganache from 'ganache'; import { - callContractMethodWithTx, + /* callContractMethodWithTx, */ checkAndVerifyDeployed, checkFilesFromContractFolder, deployCheckAndVerify, @@ -15,13 +15,15 @@ import { describe, it, before } from 'mocha'; import { expect } from 'chai'; import { calculateCreate2Address, + /* getBytecode, matchWithSimulation, + */ matchWithCreationTx, replaceImmutableReferences, verifyCreate2, } from '../src'; -import { Match } from '@ethereum-sourcify/lib-sourcify'; +// import { Match } from '@ethereum-sourcify/lib-sourcify'; const ganacheServer = Ganache.server({ wallet: { totalAccounts: 1 }, @@ -253,7 +255,7 @@ describe('lib-sourcify tests', () => { expectMatch(match, 'perfect', deployedAddress); }); - it('should verify a contract created by a factory contract and has immutables', async () => { + /* it('should verify a contract created by a factory contract and has immutables', async () => { const deployValue = 12345; const childFolderPath = path.join( __dirname, @@ -298,9 +300,9 @@ describe('lib-sourcify tests', () => { ); expectMatch(match, 'perfect', childAddress); - }); + }); */ - it('should verify a contract created by a factory contract and has immutables without constructor arguments but with msg.sender assigned immutable', async () => { + /* it('should verify a contract created by a factory contract and has immutables without constructor arguments but with msg.sender assigned immutable', async () => { const childFolderPath = path.join( __dirname, 'sources', @@ -341,6 +343,7 @@ describe('lib-sourcify tests', () => { expectMatch(match, 'perfect', childAddress); }); + */ }); describe('Unit tests', function () { @@ -377,6 +380,7 @@ describe('lib-sourcify tests', () => { expect(replacedBytecode).equals(recompiledDeployedBytecode); }); + /* it('should matchWithSimulation', async () => { const childFolderPath = path.join( __dirname, @@ -436,6 +440,7 @@ describe('lib-sourcify tests', () => { expectMatch(match, 'perfect', childAddress); }); + */ it('should fail to matchWithCreationTx with wrong creationTxHash', async () => { const contractFolderPath = path.join( diff --git a/src/monitor/monitor.ts b/src/monitor/monitor.ts index ccf57543a..756351f48 100755 --- a/src/monitor/monitor.ts +++ b/src/monitor/monitor.ts @@ -272,7 +272,7 @@ class ChainMonitor extends EventEmitter { contract, this.chainId, address, - undefined, + /* undefined, */ creatorTxHash ); await this.repositoryService.storeMatch(contract, match); diff --git a/src/server/controllers/VerificationController-util.ts b/src/server/controllers/VerificationController-util.ts index 5bed0e413..c8509702a 100644 --- a/src/server/controllers/VerificationController-util.ts +++ b/src/server/controllers/VerificationController-util.ts @@ -47,10 +47,10 @@ export type LegacyVerifyRequest = Request & { addresses: string[]; chain: string; chosenContract: number; - contextVariables?: { + /* contextVariables?: { abiEncodedConstructorArguments?: string; msgSender?: string; - }; + }; */ }; type PathBuffer = { @@ -158,10 +158,10 @@ export type ContractMeta = { name?: string; address?: string; chainId?: string; - contextVariables?: { + /* contextVariables?: { abiEncodedConstructorArguments?: string; msgSender?: string; - }; + }; */ creatorTxHash?: string; status?: Status; statusMessage?: string; @@ -388,8 +388,12 @@ export const verifyContractsInSession = async ( continue; } - const { address, chainId, contract, contextVariables, creatorTxHash } = - contractWrapper; + const { + address, + chainId, + contract, + /* contextVariables, */ creatorTxHash, + } = contractWrapper; // The session saves the CheckedContract as a simple object, so we need to reinstantiate it const checkedContract = new CheckedContract( @@ -412,7 +416,7 @@ export const verifyContractsInSession = async ( checkedContract, chainId as string, address as string, - contextVariables, + /* contextVariables, */ creatorTxHash ); // Send to verification again with all source files. @@ -431,8 +435,8 @@ export const verifyContractsInSession = async ( const tempMatch = await verificationService.verifyDeployed( contractWithAllSources, chainId as string, - address as string, - contextVariables + address as string + /* contextVariables */ ); if ( tempMatch.status === "perfect" || diff --git a/src/server/controllers/VerificationController.ts b/src/server/controllers/VerificationController.ts index 437571ed7..2f7d8eda9 100644 --- a/src/server/controllers/VerificationController.ts +++ b/src/server/controllers/VerificationController.ts @@ -132,7 +132,7 @@ export default class VerificationController contract, req.body.chain, req.addresses[0], // Due to the old API taking an array of addresses. - req.body.contextVariables, + /* req.body.contextVariables, */ req.body.creatorTxHash ); // Send to verification again with all source files. @@ -145,7 +145,7 @@ export default class VerificationController contractWithAllSources, req.body.chain, req.addresses[0], // Due to the old API taking an array of addresses. - req.body.contextVariables, + /* req.body.contextVariables, */ req.body.creatorTxHash ); if (tempMatch.status === "perfect") { @@ -231,7 +231,7 @@ export default class VerificationController if (contractWrapper) { contractWrapper.address = receivedContract.address; contractWrapper.chainId = receivedContract.chainId; - contractWrapper.contextVariables = receivedContract.contextVariables; + /* contractWrapper.contextVariables = receivedContract.contextVariables; */ contractWrapper.creatorTxHash = receivedContract.creatorTxHash; if (isVerifiable(contractWrapper)) { verifiable[id] = contractWrapper; @@ -550,10 +550,10 @@ export default class VerificationController .exists() .bail() .custom((chain, { req }) => (req.chain = checkChainId(chain))), - body("contextVariables.msgSender").optional(), - body("contextVariables.abiEncodedConstructorArguments").optional(), + /* body("contextVariables.msgSender").optional(), + body("contextVariables.abiEncodedConstructorArguments").optional(), */ // Handle non-json multipart/form-data requests. - body("abiEncodedConstructorArguments") + /* body("abiEncodedConstructorArguments") .optional() .custom( (abiEncodedConstructorArguments, { req }) => @@ -570,7 +570,7 @@ export default class VerificationController msgSender, ...req.body.contextVariables, }) - ), + ), */ body("creatorTxHash") .optional() .custom( diff --git a/src/server/services/RepositoryService.ts b/src/server/services/RepositoryService.ts index 0b9ea66ca..34628f113 100644 --- a/src/server/services/RepositoryService.ts +++ b/src/server/services/RepositoryService.ts @@ -7,7 +7,7 @@ import { Create2Args, StringMap, Metadata, - ContextVariables, + /* ContextVariables, */ CheckedContract, } from "@ethereum-sourcify/lib-sourcify"; import { toChecksumAddress } from "web3-utils"; @@ -424,7 +424,7 @@ export default class RepositoryService implements IRepositoryService { ); } - if ( + /* if ( match.contextVariables && Object.keys(match.contextVariables).length > 0 ) { @@ -435,7 +435,7 @@ export default class RepositoryService implements IRepositoryService { "context-variables.json", match.contextVariables ); - } + } */ if (match.creatorTxHash) { this.storeTxt( diff --git a/src/server/services/VerificationService.ts b/src/server/services/VerificationService.ts index b33e4cc7c..5a4e213af 100644 --- a/src/server/services/VerificationService.ts +++ b/src/server/services/VerificationService.ts @@ -3,7 +3,7 @@ import { CheckedContract, SourcifyChainMap, Match, - ContextVariables, + /* ContextVariables, */ } from "@ethereum-sourcify/lib-sourcify"; import { SourcifyEventManager } from "../../common/SourcifyEventManager/SourcifyEventManager"; import { getCreatorTx } from "./VerificationService-util"; @@ -13,7 +13,7 @@ export interface IVerificationService { checkedContract: CheckedContract, chainId: string, address: string, - contextVariables?: ContextVariables, + /* contextVariables?: ContextVariables, */ creatorTxHash?: string ): Promise; } @@ -28,7 +28,7 @@ export default class VerificationService implements IVerificationService { checkedContract: CheckedContract, chainId: string, address: string, - contextVariables?: ContextVariables, + /* contextVariables?: ContextVariables, */ creatorTxHash?: string ): Promise { const sourcifyChain = this.supportedChainsMap[chainId]; @@ -38,7 +38,7 @@ export default class VerificationService implements IVerificationService { checkedContract, sourcifyChain, address, - contextVariables, + /* contextVariables, */ creatorTxHash ); return match; @@ -59,7 +59,7 @@ export default class VerificationService implements IVerificationService { checkedContract, sourcifyChain, address, - contextVariables, + /* contextVariables, */ foundCreatorTxHash ); return match; diff --git a/ui/src/pages/Verifier/CheckedContractsView/CheckedContract/ChainAddressForm/index.tsx b/ui/src/pages/Verifier/CheckedContractsView/CheckedContract/ChainAddressForm/index.tsx index feabc1e91..2fe558120 100644 --- a/ui/src/pages/Verifier/CheckedContractsView/CheckedContract/ChainAddressForm/index.tsx +++ b/ui/src/pages/Verifier/CheckedContractsView/CheckedContract/ChainAddressForm/index.tsx @@ -21,8 +21,8 @@ import { checkAllByAddresses } from "../../../../../utils/api"; import Message from "./Message"; import { HiChevronDown } from "react-icons/hi"; import ReactTooltip from "react-tooltip"; -import Constructorarguments from "../../../../../components/ConstructorArguments"; -import InputToggle from "../../../../../components/InputToggle"; +/* import Constructorarguments from "../../../../../components/ConstructorArguments"; +import InputToggle from "../../../../../components/InputToggle"; */ type ChainAddressFormProps = { customStatus: string; @@ -45,16 +45,16 @@ const ChainAddressForm = ({ const { sourcifyChains } = useContext(Context); const verifyButtonRef = useRef(null); const [isMoreFieldsOpen, setIsMoreFieldsOpen] = useState(false); - const [abiEncodedConstructorArguments, setAbiEncodedConstructorArguments] = + /* const [abiEncodedConstructorArguments, setAbiEncodedConstructorArguments] = useState(""); - const [msgSender, setMsgSender] = useState(""); - const [isInvalidMsgSender, setIsInvalidMsgSender] = useState(false); + const [msgSender, setMsgSender] = useState(""); */ + /* const [isInvalidMsgSender, setIsInvalidMsgSender] = useState(false); */ const [creatorTxHash, setCreatorTxHash] = useState(""); const [isInvalidCreatorTxHash, setIsInvalidCreatorTxHash] = useState(false); - const [showRawAbiInput, setShowRawAbiInput] = useState(false); + /* const [showRawAbiInput, setShowRawAbiInput] = useState(false); const [isInvalidConstructorArguments, setIsInvalidConstructorArguments] = - useState(false); + useState(false); */ useEffect(() => { if (checkedContract.address) { @@ -94,7 +94,7 @@ const ChainAddressForm = ({ console.log(`New id is: ${newChainId}`); }; - const handleMsgSenderChange: ChangeEventHandler = (e) => { + /* const handleMsgSenderChange: ChangeEventHandler = (e) => { const tempAddr = e.target.value; setMsgSender(tempAddr); const isValid = isAddress(tempAddr); @@ -103,7 +103,7 @@ const ChainAddressForm = ({ return setIsInvalidMsgSender(true); } setIsInvalidMsgSender(false); - }; + }; */ const handleCreatorTxHashChange: ChangeEventHandler = ( e @@ -118,16 +118,17 @@ const ChainAddressForm = ({ const handleSubmit: FormEventHandler = (e) => { e.preventDefault(); - if (!address || !chainId || isInvalidAddress || isInvalidMsgSender) return; + if (!address || !chainId || isInvalidAddress /* || isInvalidMsgSender */) + return; setIsLoading(true); verifyCheckedContract({ verificationId: checkedContract.verificationId || "", address: address || "", chainId: chainId, - contextVariables: { + /* contextVariables: { abiEncodedConstructorArguments, msgSender, - }, + }, */ creatorTxHash, }).finally(() => setIsLoading(false)); }; @@ -222,13 +223,15 @@ const ChainAddressForm = ({ className="mb-2" /> + {/* Inputs below are used for verification with simulation +
Inputs below will be used to simulate the creation of the contract. This helps us verify contracts created by a factory contract.
If there are other variables your contract makes use of during creation, please let us know.
- {/* Constructor arguments */} + {checkedContract?.constructorArgumentsArray && checkedContract?.constructorArgumentsArray.length > 0 && (
@@ -254,7 +257,7 @@ const ChainAddressForm = ({ />
)} - {/* msg.sender */} +
+ */}
+ ); }; -const NotFound = ({ address }: NotFoundProp) => { +const NotFound = ({ address, goBack }: NotFoundProp) => { return ( <>
@@ -344,6 +349,9 @@ const NotFound = ({ address }: NotFoundProp) => { +
); @@ -366,9 +374,9 @@ const Result = ({ response, goBack }: ResultProp) => {
{verificationIcon(response?.status)} {!!response && response?.status !== "false" ? ( - + ) : ( - + )}
diff --git a/ui/src/pages/Lookup/index.tsx b/ui/src/pages/Lookup/index.tsx index f36c4841d..e7c9d040d 100644 --- a/ui/src/pages/Lookup/index.tsx +++ b/ui/src/pages/Lookup/index.tsx @@ -45,7 +45,7 @@ const Lookup = () => { } }; - const goBack = async () => { + const goBack = () => { setResponse(undefined); navigate(`/lookup`); }; From 52a18c0aa2d263257ef4ee171b141701e5bf4952 Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Thu, 4 May 2023 10:39:29 +0200 Subject: [PATCH 09/25] Add nginx exporter for prometheus --- environments/grafana.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/environments/grafana.yaml b/environments/grafana.yaml index 565042106..400e1402e 100644 --- a/environments/grafana.yaml +++ b/environments/grafana.yaml @@ -92,3 +92,13 @@ services: - "/:/host:ro,rslave" networks: - source-verify + + nginx_exporter: + image: nginx/nginx-prometheus-exporter:0.10.0 + container_name: grafana-nginx_exporter-${TAG} + command: + - -nginx.scrape-uri + - https://sourcify.dev/nginx_status + restart: unless-stopped + networks: + - source-verify From da736892c46a5b330b834a87ca84ddf3d66f86d7 Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Thu, 4 May 2023 11:09:40 +0200 Subject: [PATCH 10/25] improve the function to sanitize path at `storeSources` --- src/server/services/RepositoryService.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/server/services/RepositoryService.ts b/src/server/services/RepositoryService.ts index 34628f113..ad1d67afe 100644 --- a/src/server/services/RepositoryService.ts +++ b/src/server/services/RepositoryService.ts @@ -631,8 +631,22 @@ export default class RepositoryService implements IRepositoryService { } // This needs to be removed at some point https://github.com/ethereum/sourcify/issues/515 private sanitizePath(originalPath: string): string { - return originalPath + const parsedPath = path.parse(originalPath); + const sanitizedDir = parsedPath.dir + .split(path.sep) + .filter((segment) => segment !== "..") + .join(path.sep) .replace(/[^a-z0-9_./-]/gim, "_") .replace(/(^|\/)[.]+($|\/)/, "_"); + + // Force absolute paths to be relative + if (parsedPath.root) { + parsedPath.root = ""; + parsedPath.dir = sanitizedDir.slice(parsedPath.root.length); + } else { + parsedPath.dir = sanitizedDir; + } + + return path.format(parsedPath); } } From f464ef6ce8a81256aeec44c30bf5d2eb9ce2e0f3 Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Thu, 4 May 2023 15:01:39 +0200 Subject: [PATCH 11/25] #860 display the create2 repo link only for create2 results --- ui/src/pages/Lookup/Result.tsx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ui/src/pages/Lookup/Result.tsx b/ui/src/pages/Lookup/Result.tsx index 0e14f0643..df1b5e08c 100644 --- a/ui/src/pages/Lookup/Result.tsx +++ b/ui/src/pages/Lookup/Result.tsx @@ -295,13 +295,22 @@ const Found = ({ response, goBack }: FoundProp) => { {isCreate2Verified && <>create2} verified - ,{" "} - - view in Sourcify Repository - + {isCreate2Verified && ( + <> + ,{" "} + + view in Sourcify Repository + + + )}

{isCreate2Verified && Create2Info(response)}

{chains.length > 0 && on the following networks:}

From 086db748c2297349e53c5ffc0287b8e79cdd4d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Fri, 5 May 2023 09:53:25 +0200 Subject: [PATCH 12/25] Fix abitype req. typescript v5+ Because the latest abitype package 0.8.2 requires typescript v5+ the package installations were failing. Updating typescript would break multiformat typings which is used by ipfs-core. We can't upgrade ipfs-core because the newer versions use ES modules, and the tests are in commonjs Hence define abitype in exact lower version 0.8.0 --- package-lock.json | 356 +++++++++++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 214 insertions(+), 144 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7808bcb8d..32c7c2865 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5295,6 +5295,12 @@ "node": ">=8" } }, + "node_modules/ansi-sequence-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.0.tgz", + "integrity": "sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==", + "dev": true + }, "node_modules/ansi-styles": { "version": "3.2.1", "license": "MIT", @@ -14152,6 +14158,12 @@ "node": ">=6" } }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, "node_modules/jsonfile": { "version": "4.0.0", "license": "MIT", @@ -15079,6 +15091,12 @@ "dev": true, "license": "MIT" }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, "node_modules/macos-release": { "version": "2.5.0", "dev": true, @@ -15169,6 +15187,18 @@ "node": ">=0.10.0" } }, + "node_modules/marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "dev": true, + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, "node_modules/mcl-wasm": { "version": "0.7.9", "resolved": "https://registry.npmjs.org/mcl-wasm/-/mcl-wasm-0.7.9.tgz", @@ -20377,6 +20407,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/shiki": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.2.tgz", + "integrity": "sha512-ltSZlSLOuSY0M0Y75KA+ieRaZ0Trf5Wl3gutE7jzLuIcWxLp5i/uEnLoQWNvgKXQ5OMpGkJnVMRLAuzjc0LJ2A==", + "dev": true, + "dependencies": { + "ansi-sequence-parser": "^1.1.0", + "jsonc-parser": "^3.2.0", + "vscode-oniguruma": "^1.7.0", + "vscode-textmate": "^8.0.0" + } + }, "node_modules/side-channel": { "version": "1.0.4", "license": "MIT", @@ -22256,6 +22298,51 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typedoc": { + "version": "0.24.6", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.6.tgz", + "integrity": "sha512-c3y3h45xJv3qYwKDAwU6Cl+26CjT0ZvblHzfHJ+SjQDM4p1mZxtgHky4lhmG0+nNarRht8kADfZlbspJWdZarQ==", + "dev": true, + "dependencies": { + "lunr": "^2.3.9", + "marked": "^4.3.0", + "minimatch": "^9.0.0", + "shiki": "^0.14.1" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 14.14" + }, + "peerDependencies": { + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x" + } + }, + "node_modules/typedoc/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typedoc/node_modules/minimatch": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.0.tgz", + "integrity": "sha512-0jJj8AvgKqWN05mrwuqi8QYKx1WmYSUoKSxu5Qhs9prezTz10sxAHGNZe9J9cqIJzta8DWsleh2KaVaLl6Ru2w==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/typescript": { "version": "4.9.4", "license": "Apache-2.0", @@ -22756,6 +22843,18 @@ "extsprintf": "^1.2.0" } }, + "node_modules/vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true + }, + "node_modules/vscode-textmate": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", + "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", + "dev": true + }, "node_modules/wcwidth": { "version": "1.0.1", "dev": true, @@ -29465,8 +29564,8 @@ "prettier": "^2.8.2", "standard-version": "^9.5.0", "ts-node": "^10.9.1", - "typedoc": "^0.23.24", - "typescript": "^4.9.4" + "typedoc": "^0.24.6", + "typescript": "^5.0.4" }, "engines": { "node": ">=10" @@ -29612,6 +29711,20 @@ "node": ">=v14" } }, + "packages/lib-sourcify/node_modules/@commitlint/load/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "optional": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "packages/lib-sourcify/node_modules/@commitlint/resolve-extends": { "version": "17.4.0", "dev": true, @@ -36254,11 +36367,6 @@ "version": "5.0.1", "license": "ISC" }, - "packages/lib-sourcify/node_modules/jsonc-parser": { - "version": "3.2.0", - "dev": true, - "license": "MIT" - }, "packages/lib-sourcify/node_modules/jsonfile": { "version": "6.1.0", "dev": true, @@ -36520,11 +36628,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/lib-sourcify/node_modules/lunr": { - "version": "2.3.9", - "dev": true, - "license": "MIT" - }, "packages/lib-sourcify/node_modules/make-dir": { "version": "3.1.0", "dev": true, @@ -36563,17 +36666,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/lib-sourcify/node_modules/marked": { - "version": "4.2.12", - "dev": true, - "license": "MIT", - "bin": { - "marked": "bin/marked.js" - }, - "engines": { - "node": ">= 12" - } - }, "packages/lib-sourcify/node_modules/md5.js": { "version": "1.3.5", "license": "MIT", @@ -38348,16 +38440,6 @@ "node": ">=8" } }, - "packages/lib-sourcify/node_modules/shiki": { - "version": "0.12.1", - "dev": true, - "license": "MIT", - "dependencies": { - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" - } - }, "packages/lib-sourcify/node_modules/side-channel": { "version": "1.0.4", "license": "MIT", @@ -39369,55 +39451,17 @@ "is-typedarray": "^1.0.0" } }, - "packages/lib-sourcify/node_modules/typedoc": { - "version": "0.23.24", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "lunr": "^2.3.9", - "marked": "^4.2.5", - "minimatch": "^5.1.2", - "shiki": "^0.12.1" - }, - "bin": { - "typedoc": "bin/typedoc" - }, - "engines": { - "node": ">= 14.14" - }, - "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x" - } - }, - "packages/lib-sourcify/node_modules/typedoc/node_modules/brace-expansion": { - "version": "2.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "packages/lib-sourcify/node_modules/typedoc/node_modules/minimatch": { - "version": "5.1.4", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, "packages/lib-sourcify/node_modules/typescript": { - "version": "4.9.4", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true, - "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=12.20" } }, "packages/lib-sourcify/node_modules/uglify-js": { @@ -39570,16 +39614,6 @@ "version": "1.0.2", "license": "MIT" }, - "packages/lib-sourcify/node_modules/vscode-oniguruma": { - "version": "1.7.0", - "dev": true, - "license": "MIT" - }, - "packages/lib-sourcify/node_modules/vscode-textmate": { - "version": "8.0.0", - "dev": true, - "license": "MIT" - }, "packages/lib-sourcify/node_modules/vscode-uri": { "version": "3.0.7", "dev": true, @@ -44050,8 +44084,8 @@ "solc": "^0.8.17", "standard-version": "^9.5.0", "ts-node": "^10.9.1", - "typedoc": "^0.23.24", - "typescript": "^4.9.4", + "typedoc": "^0.24.6", + "typescript": "^5.0.4", "web3": "^1.8.1", "web3-utils": "^1.8.1" }, @@ -44153,6 +44187,15 @@ "resolve-from": "^5.0.0", "ts-node": "^10.8.1", "typescript": "^4.6.4" + }, + "dependencies": { + "typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "optional": true + } } }, "@commitlint/resolve-extends": { @@ -51887,10 +51930,6 @@ "json-stringify-safe": { "version": "5.0.1" }, - "jsonc-parser": { - "version": "3.2.0", - "dev": true - }, "jsonfile": { "version": "6.1.0", "dev": true, @@ -52073,10 +52112,6 @@ "lowercase-keys": { "version": "3.0.0" }, - "lunr": { - "version": "2.3.9", - "dev": true - }, "make-dir": { "version": "3.1.0", "dev": true, @@ -52098,10 +52133,6 @@ "version": "4.3.0", "dev": true }, - "marked": { - "version": "4.2.12", - "dev": true - }, "md5.js": { "version": "1.3.5", "requires": { @@ -53205,15 +53236,6 @@ "version": "3.0.0", "dev": true }, - "shiki": { - "version": "0.12.1", - "dev": true, - "requires": { - "jsonc-parser": "^3.2.0", - "vscode-oniguruma": "^1.7.0", - "vscode-textmate": "^8.0.0" - } - }, "side-channel": { "version": "1.0.4", "requires": { @@ -53841,34 +53863,10 @@ "is-typedarray": "^1.0.0" } }, - "typedoc": { - "version": "0.23.24", - "dev": true, - "requires": { - "lunr": "^2.3.9", - "marked": "^4.2.5", - "minimatch": "^5.1.2", - "shiki": "^0.12.1" - }, - "dependencies": { - "brace-expansion": { - "version": "2.0.1", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "minimatch": { - "version": "5.1.4", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - } - } - }, "typescript": { - "version": "4.9.4", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true }, "uglify-js": { @@ -53972,14 +53970,6 @@ } } }, - "vscode-oniguruma": { - "version": "1.7.0", - "dev": true - }, - "vscode-textmate": { - "version": "8.0.0", - "dev": true - }, "vscode-uri": { "version": "3.0.7", "dev": true @@ -57938,6 +57928,12 @@ "version": "5.0.1", "dev": true }, + "ansi-sequence-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.0.tgz", + "integrity": "sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==", + "dev": true + }, "ansi-styles": { "version": "3.2.1", "requires": { @@ -64125,6 +64121,12 @@ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, + "jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, "jsonfile": { "version": "4.0.0", "requires": { @@ -64841,6 +64843,12 @@ "version": "2.2.1", "dev": true }, + "lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, "macos-release": { "version": "2.5.0", "dev": true @@ -64900,6 +64908,12 @@ "object-visit": "^1.0.0" } }, + "marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "dev": true + }, "mcl-wasm": { "version": "0.7.9", "resolved": "https://registry.npmjs.org/mcl-wasm/-/mcl-wasm-0.7.9.tgz", @@ -68430,6 +68444,18 @@ "integrity": "sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==", "dev": true }, + "shiki": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.2.tgz", + "integrity": "sha512-ltSZlSLOuSY0M0Y75KA+ieRaZ0Trf5Wl3gutE7jzLuIcWxLp5i/uEnLoQWNvgKXQ5OMpGkJnVMRLAuzjc0LJ2A==", + "dev": true, + "requires": { + "ansi-sequence-parser": "^1.1.0", + "jsonc-parser": "^3.2.0", + "vscode-oniguruma": "^1.7.0", + "vscode-textmate": "^8.0.0" + } + }, "side-channel": { "version": "1.0.4", "requires": { @@ -69723,6 +69749,38 @@ "is-typedarray": "^1.0.0" } }, + "typedoc": { + "version": "0.24.6", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.6.tgz", + "integrity": "sha512-c3y3h45xJv3qYwKDAwU6Cl+26CjT0ZvblHzfHJ+SjQDM4p1mZxtgHky4lhmG0+nNarRht8kADfZlbspJWdZarQ==", + "dev": true, + "requires": { + "lunr": "^2.3.9", + "marked": "^4.3.0", + "minimatch": "^9.0.0", + "shiki": "^0.14.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.0.tgz", + "integrity": "sha512-0jJj8AvgKqWN05mrwuqi8QYKx1WmYSUoKSxu5Qhs9prezTz10sxAHGNZe9J9cqIJzta8DWsleh2KaVaLl6Ru2w==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, "typescript": { "version": "4.9.4" }, @@ -70048,6 +70106,18 @@ "extsprintf": "^1.2.0" } }, + "vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true + }, + "vscode-textmate": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", + "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", + "dev": true + }, "wcwidth": { "version": "1.0.1", "dev": true, diff --git a/package.json b/package.json index 9de768026..8b44745b6 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@ethereum-sourcify/bytecode-utils": "*", "@ethereum-sourcify/lib-sourcify": "*", "@types/node-fetch": "^2.5.7", - "abitype": "^0.8.0", + "abitype": "0.8.0", "bunyan": "^1.8.12", "commander": "^9.0.0", "cors": "^2.8.5", From 4f10145fd1fc4c0f4a8abf6c93e4edaa8b065707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Fri, 5 May 2023 12:07:05 +0200 Subject: [PATCH 13/25] Show error on bad Etherscan req --- scripts/find_replace.sh | 3 ++- src/server/controllers/VerificationController-util.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/find_replace.sh b/scripts/find_replace.sh index 7d5d76f00..e31a6441a 100755 --- a/scripts/find_replace.sh +++ b/scripts/find_replace.sh @@ -76,7 +76,8 @@ do echo "find_repace.sh: replacing $VAR_NAME" VAR_VAL=$(eval "echo \${$VAR_NAME}") # Use @ as delimiter instead of / as values may contain / but @ is unlikely - sed -i "s@${VAR_NAME}=xxx@${VAR_NAME}=${VAR_VAL}@g" ../environments/.env.$TAG + # sed on MacOS has different syntax. Install "gsed" with brew install gnu-sed and replace when developing on MacOS + gsed -i "s@${VAR_NAME}=xxx@${VAR_NAME}=${VAR_VAL}@g" ../environments/.env.$TAG done cp ../environments/.env.$TAG ../environments/.env diff --git a/src/server/controllers/VerificationController-util.ts b/src/server/controllers/VerificationController-util.ts index e9a63aad9..b4411c488 100644 --- a/src/server/controllers/VerificationController-util.ts +++ b/src/server/controllers/VerificationController-util.ts @@ -567,6 +567,12 @@ export const processRequestFromEtherscan = async ( ) { throw new BadRequestError("Etherscan API rate limit reached, try later"); } + + if (resultJson.message === "NOTOK") { + throw new BadRequestError( + "Error in Etherscan API response. Result message: " + resultJson.message + ); + } if (resultJson.result[0].SourceCode === "") { throw new BadRequestError("This contract is not verified on Etherscan"); } From e2c92d911e47a4ebf7eec03df200c74d77735039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Fri, 5 May 2023 12:33:14 +0200 Subject: [PATCH 14/25] Change OPTIMISTIC_ETHERSCAN to OPTIMISMSCAN The overlap of the "ETHERSCAN_API_KEY" in both "OPTIMISTIC_ETHERSCAN_API_KEY" and "ETHERSCAN_API_KEY" was causing `sed` string replacement to behave unexpectedly, causing the Optimism key to be set as ETHERSCAN_API_KEY Change name to avoid this. --- environments/.env.dev | 2 +- environments/.env.latest | 2 +- environments/.env.secrets.gpg | Bin 2689 -> 2682 bytes environments/.env.stable | 2 +- scripts/find_replace.sh | 6 +++--- src/config.ts | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/environments/.env.dev b/environments/.env.dev index aaae137c3..397e7e275 100644 --- a/environments/.env.dev +++ b/environments/.env.dev @@ -79,7 +79,7 @@ MOONSCAN_MOONBEAM_API_KEY= MOONSCAN_MOONRIVER_API_KEY= BOBASCAN_API_KEY= GNOSISSCAN_API_KEY= -OPTIMISTIC_ETHERSCAN_API_KEY= +OPTIMISMSCAN_API_KEY= # Needed to call create2 APIs, format is: TOKEN1,TOKEN2,... CREATE2_CLIENT_TOKENS= diff --git a/environments/.env.latest b/environments/.env.latest index 789eaf4dc..05d34d5e5 100644 --- a/environments/.env.latest +++ b/environments/.env.latest @@ -78,7 +78,7 @@ MOONSCAN_MOONBEAM_API_KEY=xxx MOONSCAN_MOONRIVER_API_KEY=xxx BOBASCAN_API_KEY=xxx GNOSISSCAN_API_KEY=xxx -OPTIMISTIC_ETHERSCAN_API_KEY=xxx +OPTIMISMSCAN_API_KEY=xxx CREATE2_CLIENT_TOKENS=xxx diff --git a/environments/.env.secrets.gpg b/environments/.env.secrets.gpg index 41e9268d4c0d282273b0a2781bf2a48ff5b91dd4..075fad5033afd35ccae47f37f9b4451732b831b5 100644 GIT binary patch literal 2682 zcmV-=3WfEI4Fm}T0zjyNub7?42K&Wl9pq+zeKi+%c z>14n17!yP^vtFdA%Q8&{b%WGf+mIadq8BzZ*I^RZA*KRoMK1Aelv;s$#ZIuI; z-d{neyDSMWm0SIF5)o33FVJ17Dqitt8mo(<4Ucdutv(Y8^1Z|@dQ;PJOf4B!s02ZK(cxD&v2&o7iR+tTtJz;{9=P7R$NmExUUSGia77(~X6j z!EGjkGOmctO%|Wa+AnlYv>|t~YhXxe^;3mj!z0TFPLsP2&IaL`&tvSaHK3%b);q1M zs}umL|JP@5#SK#9X;TVF?BXZjM@MeOg0Od?gwgl2Xqnk7UkR%T`68DUa@rv$5$_O_ zeyv|0VS%iF4wF2tc`c-a{^c;O85H%Xm{Ak)2_-Y!W^-)!j4n|w@cG}|t$S(f_|>L8 zhr#{T_!@g;{Koq975lQ#B8Aq@V$r+uaS!jD+Q)Q(4AQax!-O(oTfA{xl&Eu5HOf^L z+DVL9Vt{$o1w19>yKio|jdkYlIl^Op09c;^9D=0`*=>!S6ZB!nGdVD-<)YX_UW0IZ z?Jpx+^qH($K{8=og>mMCSP&@Vpy@axs180EyT>f18Dx;^SpY}RiReu}5b|O2;>3x% z)0xJ6DUGAnIVy>zHDJkG z{2zpdqjZSQ==!P8)7%fXZ=7_6vkE55<+nL39(;MyCT`P=9|EiUu)LDE;~9SM-Ffag zd1o$VU-5-2^L2*ASO^Y`0n9CMQnH=E$|6b{n&rdffa(ZnU~yh%GBdhQ$-s|@O%Be)zLfIp7gb=6A`cua_KDH$bxe6=p(Pzw@W~sjVD&&$lS1^raF!)IJ z9dKsNuZx&nn>`=MV3;QPF;yni+T1!%%AkMkzF7UsNZ`wT(VYveceQyl-4DdW#<7=g z$N~3K!I^7Q>ZBF{H>IgNSDkDkzK=+070f3`OwK#wVN?^aoBbl_ehJkZ>=p%3;0LyRah|XQBMp#<+~quIqpR+>wXk@_o{s*^pduWu zHSw|b8Uj=3vFjQY+l0bXZ!v$2-8J08m(@n;Nub$w={&N9lF4CPN?RQ^nNVUv`qb(& zUrLHx`LqpFlMcfUHKqml{bO+s%W-PL9J)12%O%-@$k`SM*hF|i+U#hFk(#qje53Hg z6U)xoXXt!y#Gn|q9R;z}s3F2D3*`vj+<_JYC{(-ju`;fjw@x=b@fFr5PAWH${|y31 z&;vaK)!Jf7K6BGOiVmMsD{o^a44EFIK=Wrd?@40o30sbdj+@<5uxj-uT zC@{ra9)oa9(XZM<`2POT(&j20S5sgzrW5~@j{^}9E%&#tjLGWU$;aRl(%YPz2xOT9 zw;Sycyqi=XT_54|=k6mGO;5Ss5wv=qv(N&y2{cfk+N$l>T;erBoK~vrAa!3{niO;5 zk}tKRRs5Xv>_!RDW&&%Y%MZA;f1(f+4VSIq=K~?Y=M@_!#JWHSPD`~H+h^;xu9=sV z_!tXF)B_C@1x^#+AOmiP$@jC_dre2{3~j{4qft0|)yw$qdx|ZJQczC11*?g>G>3gy zT}~&Qh~)4^T&vs+A_U@5>#hlrqI#z zGg*FH+M}464qfk~*;&OjWT($$lv7pgoN!hug;g+j9Ka?{V5%$aERd}g4Z9) zGNIv%UfPrwQ56#R|JfJB%{~oYjz(ryT1l69EkjiZdF0rDJ)2~25SrT6ZE9+lO0pxo zA$SkfFDfYR3#UeHa@<|XPEbv2n0I^y`>+ekx9$mSUA7n$RkSM$GF;p;^X7Jkn3Tz- zdRBE=lnRlQ*A1xqh#;?#^@5(SFT#c+lL@gcPm{j~tsnMSQ}xJz4Q1P~+_>~m{|-gg z$MaX)PL?8ZXNH`-yD70=RkAZRu?9%0n>MT`1LP4IY@BrzUZ;7m}h#Qy!GG{>}XDtQ#IHqLp z`VSo9b5x!IGitymyy0SuB}tr>x;=IQLZbR?Pv88~;p$i3ET)73O2d8#rwx5?PMQz5 zRj}3)&n5~jaXq=$*fLYb$4>$zzvsfWT4l)IDF9cE2t-5~M_tTV&~x|^o9qFE!Ny$E zv4rWXDIn!gV6qVompg|9dX$}K7uJ4Utddk z210wwn(n%okQuFEbska;@YL7z%=+;XEceixz+(%VW0YMKfMuj7(B$M~7&iq* z>0Q>F(t^u=D|Hdz?y}L=Uh9LCrIC}nCctShqV)~yK6ZopY5Rh-Hvt;1kdz}zrk%^X zRENrk-Lf2dar^+Z;mN}gY2p)SaXw`aHT(SO1jI*0rrw_`fDUG?A_f}k)9&d4#_C2~ z*@lQXaM}*>9o*k|h~mEzJt@>uhb1lJjtX;2bD&;bg)@($*F9dwKZoZMp6ORH8heCk odE&*%s5)3*JK~&~HBt=qCORk41=WB>pF literal 2689 zcmV-{3V!vB4Fm}T0>3&gXtjHP*!$Az0c8aLQeEu0X4Y7LOe=sCL~m=EJl5;s?u@vQ&I zb!t1>N7%_5aJw6yS(3C=sMUB}$>pspIxTMQQCrbBu zy=$@CE^33{B0iY!j@@F$9tA`%T)bQz=ag5_(?vO=_Um_+pWJL7pUS7pAssoG^y7L26?WVn$1HTSo=>a8`;UrR6z;@3q$BG})cEP}?PAVlMqE>&l> zet(1^oKY_E9>qKPq6FFXp#aRj!q;a%a~Tz>Mll^TLtSJ~hUwZ{7IjAnN#l-y#+r7& z-kGu}>hzhYcMXhIhk|MDwDbOBo164}YQOTdN{cd^2<)Mw;(ekAT$S7VrRE zXmMm$Qb%n;@RKhq^}SK+@hWU-uRl#-tQJ2z*Rl&2dHc05GHr!byk=bh>^PHww^tl3(>}9NBjl$oT=;|Fm=*VZ1M*ls zC~i52L3lSM^@;#6eQU###^-Auu|ln4%zpvWk+dOF3ENTNTBB{ZQX>s5XbdZe032m! zN?BoAOGV?*pS2_ftQtwNL+`s34@+e?jE zJ3T3w5$*gWi}WBT5q+WKf9uD?sjNmhs&6a&XRjj zVc^oPwquNfv|`Mi)V}=5$~bx##d>z;hfl8gQq43|9^!bNPKh-MPQ;VXvY^7xI_5a5U=6inZvuw0EUO-nUoDDeCrK3SXP=|PTB~XHRusT{ zLJzR1)#1I=KfGM+7j0Z6dTK@m6n-^2OmsWMqS#UQ-_b9|eqMk<54yh5mJCD`l9*w_ z(~pzyVvV8}x!HJ*Z$&Z}*p*3g*@kgNiggQQPYs)K#D-G6e^*V?L+9)WIBmNvXfE;9 zCR`4U(H(>zrY3Ms)Kk|A%3EB`|TK*Br3-=1RXHb!}VfQ4~e#K0`HDXdU9h*VB zbpAHFdTe?fvR1N|V;EggBk^U|44B+}=fH0JQ|Ll)=BnUQs{)#URDsKKF^*B|bwps< z6qH6Yw1y7X5fcnq>IafO(SbTT8HSg`f+S=9pHUGrVvRVj|41aK8=W&LFFveI#~guk zVGHH5t*+b1O=jlcJVa&*t!n1SBN9(zOjmt|W)OSGXt}pDD0T$-!}o$A9p?`zp`Og#k4OiZ%j+K`Pu2QLDL1-Zn53{?6_oSP8z#T=I`de zxWKIYL#}xvg_C*9CHT=c#Q-lR6o?)q_&~yU3q>p)h^2g!u@&n?^fk5+=z%s61Jlng z%+Fb%%Ar@GeMuP7Bi{G8mm(z>tHg&s@kLDWqi7@2LaUOG9s|n}2*PK8C=dQj*m@~Y zSO2_M9MLr4(H&Bb=(o!`b~woPYm_z(9uFvZv{u<&i%iaht?5QBMs(4Ol2(A-08=)( zPfO?d2qr_(d{496e!T7HO@gEmW00yI>wll^mCR^b9~Rw}_{AY0kNiyGQ|U#CM1oKA zHv2h2nm@BC+Cos1)e!P%CQik(m~FQSfdd(n3Tg@ysKFVP;0W!sn`iqNcntrN$LlG% zZrmg3NgCKu)HY8{zKO>0;c)x}?^tHcqS6)wkP}H^ILrF+XYTuxn}WO$L3EH*r%mxz zh^8-xXm{!4v`+i>Clk*`5@1F;mgA~e)snCZm?@)3bE`ce)}##Tyk(8?pM4tRb_Avu_3lX&W+|ekv!GEhv*F{cl#fVns z9->ls4QzH`q(~@{Md1M3=h0U~Iex9PSRZQ^g|`jr`+Fl^sYl-%;Y@&4KN46d_I*0g zKXdxWr-YQ(7r)-G*8shsc%}$NsM@4okka8464t5k%X6A#YU97gw{%wkGe&h8iVrs< zwSR~k#kt_`5Emz>iAmTzr}7OK*=w(Zt2C9X=H++a{~Kh+JcV+zKI*Hhd6Ua(r$4Y=go{;|6)3S!z_* zUkKD>eQ45rD>f#LdjMs_bO8vbyo&8WeDboFQW3@X;ELflLhWKsbVly^Ao?X-!UJ$N viL2-k{?!j}V`F_^+o@np#fE83tml;bu>s|mlzjC@j>b@}wX`oPqm76RzVaox diff --git a/environments/.env.stable b/environments/.env.stable index e9ef447aa..34200569e 100644 --- a/environments/.env.stable +++ b/environments/.env.stable @@ -76,7 +76,7 @@ MOONSCAN_MOONBEAM_API_KEY=xxx MOONSCAN_MOONRIVER_API_KEY=xxx BOBASCAN_API_KEY=xxx GNOSISSCAN_API_KEY=xxx -OPTIMISTIC_ETHERSCAN_API_KEY=xxx +OPTIMISMSCAN_API_KEY=xxx CREATE2_CLIENT_TOKENS=xxx diff --git a/scripts/find_replace.sh b/scripts/find_replace.sh index e31a6441a..e2bef1c49 100755 --- a/scripts/find_replace.sh +++ b/scripts/find_replace.sh @@ -38,7 +38,7 @@ if [ "$CIRCLE_BRANCH" == "staging" ]; then MOONSCAN_MOONRIVER_API_KEY=$MOONSCAN_MOONRIVER_API_KEY_STAGING BOBASCAN_API_KEY=$BOBASCAN_API_KEY_STAGING GNOSISSCAN_API_KEY=$GNOSISSCAN_API_KEY_STAGING - OPTIMISTIC_ETHERSCAN_API_KEY=$OPTIMISTIC_ETHERSCAN_API_KEY_STAGING + OPTIMISMSCAN_API_KEY=$OPTIMISMSCAN_API_KEY_STAGING fi if [ "$CIRCLE_BRANCH" == "master" ]; then @@ -68,10 +68,10 @@ if [ "$CIRCLE_BRANCH" == "master" ]; then MOONSCAN_MOONRIVER_API_KEY=$MOONSCAN_MOONRIVER_API_KEY_MASTER BOBASCAN_API_KEY=$BOBASCAN_API_KEY_MASTER GNOSISSCAN_API_KEY=$GNOSISSCAN_API_KEY_MASTER - OPTIMISTIC_ETHERSCAN_API_KEY=$OPTIMISTIC_ETHERSCAN_API_KEY_MASTER + OPTIMISMSCAN_API_KEY=$OPTIMISMSCAN_API_KEY_MASTER fi -for VAR_NAME in INFURA_ID ALCHEMY_ID AWS_S3_ACCESS_KEY_ID AWS_S3_SECRET_ACCESS_KEY IPFS_SECRET NPM_TOKEN PUBLIC_IP LOCAL_IP SESSION_SECRET ALCHEMY_ID_OPTIMISM ALCHEMY_ID_ARBITRUM CHAINSAFE_S3_ACCESS_KEY_ID CHAINSAFE_S3_SECRET_ACCESS_KEY ESTUARY_PINNING_SECRET WEB3_STORAGE_PINNING_SECRET CREATE2_CLIENT_TOKENS GRAFANA_HTTP_USER GRAFANA_HTTP_PASS ETHERSCAN_API_KEY ARBISCAN_API_KEY POLYGONSCAN_API_KEY BSCSCAN_API_KEY SNOWTRACE_API_KEY CELOSCAN_API_KEY MOONSCAN_MOONBEAM_API_KEY MOONSCAN_MOONRIVER_API_KEY BOBASCAN_API_KEY GNOSISSCAN_API_KEY OPTIMISTIC_ETHERSCAN_API_KEY +for VAR_NAME in INFURA_ID ALCHEMY_ID AWS_S3_ACCESS_KEY_ID AWS_S3_SECRET_ACCESS_KEY IPFS_SECRET NPM_TOKEN PUBLIC_IP LOCAL_IP SESSION_SECRET ALCHEMY_ID_OPTIMISM ALCHEMY_ID_ARBITRUM CHAINSAFE_S3_ACCESS_KEY_ID CHAINSAFE_S3_SECRET_ACCESS_KEY ESTUARY_PINNING_SECRET WEB3_STORAGE_PINNING_SECRET CREATE2_CLIENT_TOKENS GRAFANA_HTTP_USER GRAFANA_HTTP_PASS ETHERSCAN_API_KEY ARBISCAN_API_KEY POLYGONSCAN_API_KEY BSCSCAN_API_KEY SNOWTRACE_API_KEY CELOSCAN_API_KEY MOONSCAN_MOONBEAM_API_KEY MOONSCAN_MOONRIVER_API_KEY BOBASCAN_API_KEY GNOSISSCAN_API_KEY OPTIMISMSCAN_API_KEY do echo "find_repace.sh: replacing $VAR_NAME" VAR_VAL=$(eval "echo \${$VAR_NAME}") diff --git a/src/config.ts b/src/config.ts index abfa62bfe..9e4ac0cae 100644 --- a/src/config.ts +++ b/src/config.ts @@ -80,11 +80,11 @@ export const etherscanAPIs: EtherscanAPIs = { }, "10": { apiURL: "https://api-optimistic.etherscan.io", - apiKey: process.env.OPTIMISTIC_ETHERSCAN_API_KEY, + apiKey: process.env.OPTIMISMSCAN_API_KEY, }, "420": { apiURL: "https://api-goerli-optimism.etherscan.io", - apiKey: process.env.OPTIMISTIC_ETHERSCAN_API_KEY, + apiKey: process.env.OPTIMISMSCAN_API_KEY, }, "43114": { apiURL: "https://api.snowtrace.io", From f19e3546c0e998dabdae219b52c61e80c160909a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Fri, 5 May 2023 12:36:01 +0200 Subject: [PATCH 15/25] Revert accidentally setting `sed` to `gsed` --- scripts/find_replace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/find_replace.sh b/scripts/find_replace.sh index e2bef1c49..a859276ad 100755 --- a/scripts/find_replace.sh +++ b/scripts/find_replace.sh @@ -77,7 +77,7 @@ do VAR_VAL=$(eval "echo \${$VAR_NAME}") # Use @ as delimiter instead of / as values may contain / but @ is unlikely # sed on MacOS has different syntax. Install "gsed" with brew install gnu-sed and replace when developing on MacOS - gsed -i "s@${VAR_NAME}=xxx@${VAR_NAME}=${VAR_VAL}@g" ../environments/.env.$TAG + sed -i "s@${VAR_NAME}=xxx@${VAR_NAME}=${VAR_VAL}@g" ../environments/.env.$TAG done cp ../environments/.env.$TAG ../environments/.env From f9e74dc12deaddc0db97a4c263125fc9bd8821f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Vi=C3=A9not?= Date: Mon, 8 May 2023 09:05:37 +0200 Subject: [PATCH 16/25] Add chain 295 (Hedera Mainnet) (#1009) * Add chain details for 295 (Hedera Mainnet) * Add test contracts for chain 295 (Hedera Mainnet) * Change constructor argument to avoid any confusion with chainId. * Attempt to reuse shared test contracts. * Remove now unneeded directory for chain 295 test contracts. --- package-lock.json | 132 +++++++++++++++++++++++++++++++++++++ src/sourcify-chains.ts | 6 ++ test/chains/chain-tests.js | 20 +++++- 3 files changed, 157 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 32c7c2865..b0e24fc61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34361,6 +34361,8 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/bn.js": { "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", + "integrity": "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==", "dev": true, "license": "MIT", "dependencies": { @@ -34369,19 +34371,54 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/lru-cache": { "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==", "dev": true, "license": "MIT" }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/node": { "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", + "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==", "dev": true, "license": "MIT" }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/seedrandom": { "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", + "integrity": "sha512-giB9gzDeiCeloIXDgzFBCgjj1k4WxcDrZtGl6h1IqmUPlxF+Nx8Ve+96QCyDZ/HseB/uvDsKbpib9hU5cU53pw==", "dev": true, "license": "MIT" }, + "packages/lib-sourcify/node_modules/ganache/node_modules/abstract-level": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/abstract-level/-/abstract-level-1.0.3.tgz", + "integrity": "sha512-t6jv+xHy+VYwc4xqZMn2Pa9DjcdzvzZmQGRjTFc8spIbRGHgBrEKbPq+rYXc7CCo0lxgYvSgKVg9qZAhpVQSjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer": "^6.0.3", + "catering": "^2.1.0", + "is-buffer": "^2.0.5", + "level-supports": "^4.0.0", + "level-transcoder": "^1.0.1", + "module-error": "^1.0.1", + "queue-microtask": "^1.2.3" + }, + "engines": { + "node": ">=12" + } + }, + "packages/lib-sourcify/node_modules/ganache/node_modules/abstract-level/node_modules/level-supports": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/level-supports/-/level-supports-4.0.1.tgz", + "integrity": "sha512-PbXpve8rKeNcZ9C1mUicC9auIYFyGpkV9/i6g76tLgANwWhtG2v7I4xNBUlkn3lE2/dZF3Pi0ygYGtLc4RXXdA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "packages/lib-sourcify/node_modules/ganache/node_modules/abstract-leveldown": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-7.2.0.tgz", @@ -34403,6 +34440,8 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/async": { "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dev": true, "license": "MIT", "dependencies": { @@ -34411,6 +34450,8 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/async-eventemitter": { "version": "0.2.4", + "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", + "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", "dev": true, "license": "MIT", "dependencies": { @@ -34475,6 +34516,8 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/bufferutil": { "version": "4.0.5", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", + "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -34527,6 +34570,8 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/emittery": { "version": "0.10.0", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.0.tgz", + "integrity": "sha512-AGvFfs+d0JKCJQ4o01ASQLGPmSCxgfU9RFXvzPvZdjKK8oscynksuJhWrSTSw7j7Ep/sZct5b5ZhYCi8S/t0HQ==", "dev": true, "license": "MIT", "engines": { @@ -34658,6 +34703,20 @@ "node": ">=10" } }, + "packages/lib-sourcify/node_modules/ganache/node_modules/level-transcoder": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/level-transcoder/-/level-transcoder-1.0.1.tgz", + "integrity": "sha512-t7bFwFtsQeD8cl8NIoQ2iwxA0CL/9IFw7/9gAjOonH0PWTTiRfY7Hq+Ejbsxh86tXobDQ6IOiddjNYIfOBs06w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer": "^6.0.3", + "module-error": "^1.0.1" + }, + "engines": { + "node": ">=12" + } + }, "packages/lib-sourcify/node_modules/ganache/node_modules/leveldown": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-6.1.0.tgz", @@ -34677,6 +34736,8 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/lodash": { "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true, "license": "MIT" }, @@ -34696,6 +34757,16 @@ "inBundle": true, "license": "MIT" }, + "packages/lib-sourcify/node_modules/ganache/node_modules/module-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/module-error/-/module-error-1.0.2.tgz", + "integrity": "sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "packages/lib-sourcify/node_modules/ganache/node_modules/napi-macros": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", @@ -34823,6 +34894,8 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/utf-8-validate": { "version": "5.0.7", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", + "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -50673,6 +50746,8 @@ }, "@types/bn.js": { "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", + "integrity": "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==", "dev": true, "requires": { "@types/node": "*" @@ -50680,16 +50755,45 @@ }, "@types/lru-cache": { "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==", "dev": true }, "@types/node": { "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", + "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==", "dev": true }, "@types/seedrandom": { "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", + "integrity": "sha512-giB9gzDeiCeloIXDgzFBCgjj1k4WxcDrZtGl6h1IqmUPlxF+Nx8Ve+96QCyDZ/HseB/uvDsKbpib9hU5cU53pw==", "dev": true }, + "abstract-level": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/abstract-level/-/abstract-level-1.0.3.tgz", + "integrity": "sha512-t6jv+xHy+VYwc4xqZMn2Pa9DjcdzvzZmQGRjTFc8spIbRGHgBrEKbPq+rYXc7CCo0lxgYvSgKVg9qZAhpVQSjA==", + "dev": true, + "requires": { + "buffer": "^6.0.3", + "catering": "^2.1.0", + "is-buffer": "^2.0.5", + "level-supports": "^4.0.0", + "level-transcoder": "^1.0.1", + "module-error": "^1.0.1", + "queue-microtask": "^1.2.3" + }, + "dependencies": { + "level-supports": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/level-supports/-/level-supports-4.0.1.tgz", + "integrity": "sha512-PbXpve8rKeNcZ9C1mUicC9auIYFyGpkV9/i6g76tLgANwWhtG2v7I4xNBUlkn3lE2/dZF3Pi0ygYGtLc4RXXdA==", + "dev": true + } + } + }, "abstract-leveldown": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-7.2.0.tgz", @@ -50707,6 +50811,8 @@ }, "async": { "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dev": true, "requires": { "lodash": "^4.17.14" @@ -50714,6 +50820,8 @@ }, "async-eventemitter": { "version": "0.2.4", + "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", + "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", "dev": true, "requires": { "async": "^2.4.0" @@ -50746,6 +50854,8 @@ }, "bufferutil": { "version": "4.0.5", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", + "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", "dev": true, "optional": true, "requires": { @@ -50789,6 +50899,8 @@ }, "emittery": { "version": "0.10.0", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.0.tgz", + "integrity": "sha512-AGvFfs+d0JKCJQ4o01ASQLGPmSCxgfU9RFXvzPvZdjKK8oscynksuJhWrSTSw7j7Ep/sZct5b5ZhYCi8S/t0HQ==", "dev": true }, "hash.js": { @@ -50864,6 +50976,16 @@ "bundled": true, "dev": true }, + "level-transcoder": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/level-transcoder/-/level-transcoder-1.0.1.tgz", + "integrity": "sha512-t7bFwFtsQeD8cl8NIoQ2iwxA0CL/9IFw7/9gAjOonH0PWTTiRfY7Hq+Ejbsxh86tXobDQ6IOiddjNYIfOBs06w==", + "dev": true, + "requires": { + "buffer": "^6.0.3", + "module-error": "^1.0.1" + } + }, "leveldown": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-6.1.0.tgz", @@ -50878,6 +51000,8 @@ }, "lodash": { "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "minimalistic-assert": { @@ -50894,6 +51018,12 @@ "bundled": true, "dev": true }, + "module-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/module-error/-/module-error-1.0.2.tgz", + "integrity": "sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA==", + "dev": true + }, "napi-macros": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", @@ -50972,6 +51102,8 @@ }, "utf-8-validate": { "version": "5.0.7", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", + "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", "dev": true, "optional": true, "requires": { diff --git a/src/sourcify-chains.ts b/src/sourcify-chains.ts index df1870069..0c7384a6d 100644 --- a/src/sourcify-chains.ts +++ b/src/sourcify-chains.ts @@ -196,6 +196,12 @@ const sourcifyChainsExtensions: SourcifyChainsExtensionsObject = { "https://blockscout.com/xdai/mainnet/" + BLOCKSCOUT_SUFFIX, txRegex: getBlockscoutRegex("/xdai/mainnet"), }, + "295": { + // Hedera Mainnet + supported: true, + monitored: false, + contractFetchAddress: "https://hashscan.io/mainnet/" + ETHERSCAN_SUFFIX, + }, "300": { supported: true, monitored: false, diff --git a/test/chains/chain-tests.js b/test/chains/chain-tests.js index eed336fb6..a22ad7c17 100644 --- a/test/chains/chain-tests.js +++ b/test/chains/chain-tests.js @@ -1423,7 +1423,7 @@ describe("Test Supported Chains", function () { ["shared/WithImmutables.sol"], "shared/withImmutables.metadata.json" ); - + // The Root Network Porcini (Testnet) verifyContract( "0x225F2cD344c61152F8E7200E62e03dEfD683f2c4", @@ -1442,6 +1442,24 @@ describe("Test Supported Chains", function () { "shared/withImmutables.metadata.json" ); + // Hedera Mainnet + verifyContract( + "0x00000000000000000000000000000000002265bb", + "295", + "Hedera Mainnet", + ["shared/1_Storage.sol"], + "shared/1_Storage.metadata.json" + ); + verifyContractWithImmutables( + "0x00000000000000000000000000000000002265dd", + "295", + "Hedera Mainnet", + ["uint256"], + [42], + ["shared/WithImmutables.sol"], + "shared/withImmutables.metadata.json" + ); + ////////////////////// // Helper functions // ////////////////////// From 059422b2086514ed279d9fb68b96cfdaa80539f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Mon, 8 May 2023 09:11:17 +0200 Subject: [PATCH 17/25] Revert package-lock in commit This reverts the package-lock in commit f9e74dc12deaddc0db97a4c263125fc9bd8821f8. --- package-lock.json | 132 ---------------------------------------------- 1 file changed, 132 deletions(-) diff --git a/package-lock.json b/package-lock.json index b0e24fc61..32c7c2865 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34361,8 +34361,6 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/bn.js": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", - "integrity": "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==", "dev": true, "license": "MIT", "dependencies": { @@ -34371,54 +34369,19 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/lru-cache": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==", "dev": true, "license": "MIT" }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/node": { "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", - "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==", "dev": true, "license": "MIT" }, "packages/lib-sourcify/node_modules/ganache/node_modules/@types/seedrandom": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", - "integrity": "sha512-giB9gzDeiCeloIXDgzFBCgjj1k4WxcDrZtGl6h1IqmUPlxF+Nx8Ve+96QCyDZ/HseB/uvDsKbpib9hU5cU53pw==", "dev": true, "license": "MIT" }, - "packages/lib-sourcify/node_modules/ganache/node_modules/abstract-level": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/abstract-level/-/abstract-level-1.0.3.tgz", - "integrity": "sha512-t6jv+xHy+VYwc4xqZMn2Pa9DjcdzvzZmQGRjTFc8spIbRGHgBrEKbPq+rYXc7CCo0lxgYvSgKVg9qZAhpVQSjA==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer": "^6.0.3", - "catering": "^2.1.0", - "is-buffer": "^2.0.5", - "level-supports": "^4.0.0", - "level-transcoder": "^1.0.1", - "module-error": "^1.0.1", - "queue-microtask": "^1.2.3" - }, - "engines": { - "node": ">=12" - } - }, - "packages/lib-sourcify/node_modules/ganache/node_modules/abstract-level/node_modules/level-supports": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/level-supports/-/level-supports-4.0.1.tgz", - "integrity": "sha512-PbXpve8rKeNcZ9C1mUicC9auIYFyGpkV9/i6g76tLgANwWhtG2v7I4xNBUlkn3lE2/dZF3Pi0ygYGtLc4RXXdA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - } - }, "packages/lib-sourcify/node_modules/ganache/node_modules/abstract-leveldown": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-7.2.0.tgz", @@ -34440,8 +34403,6 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/async": { "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dev": true, "license": "MIT", "dependencies": { @@ -34450,8 +34411,6 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/async-eventemitter": { "version": "0.2.4", - "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", - "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", "dev": true, "license": "MIT", "dependencies": { @@ -34516,8 +34475,6 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/bufferutil": { "version": "4.0.5", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", - "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -34570,8 +34527,6 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/emittery": { "version": "0.10.0", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.0.tgz", - "integrity": "sha512-AGvFfs+d0JKCJQ4o01ASQLGPmSCxgfU9RFXvzPvZdjKK8oscynksuJhWrSTSw7j7Ep/sZct5b5ZhYCi8S/t0HQ==", "dev": true, "license": "MIT", "engines": { @@ -34703,20 +34658,6 @@ "node": ">=10" } }, - "packages/lib-sourcify/node_modules/ganache/node_modules/level-transcoder": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/level-transcoder/-/level-transcoder-1.0.1.tgz", - "integrity": "sha512-t7bFwFtsQeD8cl8NIoQ2iwxA0CL/9IFw7/9gAjOonH0PWTTiRfY7Hq+Ejbsxh86tXobDQ6IOiddjNYIfOBs06w==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer": "^6.0.3", - "module-error": "^1.0.1" - }, - "engines": { - "node": ">=12" - } - }, "packages/lib-sourcify/node_modules/ganache/node_modules/leveldown": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-6.1.0.tgz", @@ -34736,8 +34677,6 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/lodash": { "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true, "license": "MIT" }, @@ -34757,16 +34696,6 @@ "inBundle": true, "license": "MIT" }, - "packages/lib-sourcify/node_modules/ganache/node_modules/module-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/module-error/-/module-error-1.0.2.tgz", - "integrity": "sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "packages/lib-sourcify/node_modules/ganache/node_modules/napi-macros": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", @@ -34894,8 +34823,6 @@ }, "packages/lib-sourcify/node_modules/ganache/node_modules/utf-8-validate": { "version": "5.0.7", - "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", - "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -50746,8 +50673,6 @@ }, "@types/bn.js": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", - "integrity": "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==", "dev": true, "requires": { "@types/node": "*" @@ -50755,45 +50680,16 @@ }, "@types/lru-cache": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==", "dev": true }, "@types/node": { "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", - "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==", "dev": true }, "@types/seedrandom": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", - "integrity": "sha512-giB9gzDeiCeloIXDgzFBCgjj1k4WxcDrZtGl6h1IqmUPlxF+Nx8Ve+96QCyDZ/HseB/uvDsKbpib9hU5cU53pw==", "dev": true }, - "abstract-level": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/abstract-level/-/abstract-level-1.0.3.tgz", - "integrity": "sha512-t6jv+xHy+VYwc4xqZMn2Pa9DjcdzvzZmQGRjTFc8spIbRGHgBrEKbPq+rYXc7CCo0lxgYvSgKVg9qZAhpVQSjA==", - "dev": true, - "requires": { - "buffer": "^6.0.3", - "catering": "^2.1.0", - "is-buffer": "^2.0.5", - "level-supports": "^4.0.0", - "level-transcoder": "^1.0.1", - "module-error": "^1.0.1", - "queue-microtask": "^1.2.3" - }, - "dependencies": { - "level-supports": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/level-supports/-/level-supports-4.0.1.tgz", - "integrity": "sha512-PbXpve8rKeNcZ9C1mUicC9auIYFyGpkV9/i6g76tLgANwWhtG2v7I4xNBUlkn3lE2/dZF3Pi0ygYGtLc4RXXdA==", - "dev": true - } - } - }, "abstract-leveldown": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-7.2.0.tgz", @@ -50811,8 +50707,6 @@ }, "async": { "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dev": true, "requires": { "lodash": "^4.17.14" @@ -50820,8 +50714,6 @@ }, "async-eventemitter": { "version": "0.2.4", - "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", - "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", "dev": true, "requires": { "async": "^2.4.0" @@ -50854,8 +50746,6 @@ }, "bufferutil": { "version": "4.0.5", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", - "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", "dev": true, "optional": true, "requires": { @@ -50899,8 +50789,6 @@ }, "emittery": { "version": "0.10.0", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.0.tgz", - "integrity": "sha512-AGvFfs+d0JKCJQ4o01ASQLGPmSCxgfU9RFXvzPvZdjKK8oscynksuJhWrSTSw7j7Ep/sZct5b5ZhYCi8S/t0HQ==", "dev": true }, "hash.js": { @@ -50976,16 +50864,6 @@ "bundled": true, "dev": true }, - "level-transcoder": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/level-transcoder/-/level-transcoder-1.0.1.tgz", - "integrity": "sha512-t7bFwFtsQeD8cl8NIoQ2iwxA0CL/9IFw7/9gAjOonH0PWTTiRfY7Hq+Ejbsxh86tXobDQ6IOiddjNYIfOBs06w==", - "dev": true, - "requires": { - "buffer": "^6.0.3", - "module-error": "^1.0.1" - } - }, "leveldown": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-6.1.0.tgz", @@ -51000,8 +50878,6 @@ }, "lodash": { "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "minimalistic-assert": { @@ -51018,12 +50894,6 @@ "bundled": true, "dev": true }, - "module-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/module-error/-/module-error-1.0.2.tgz", - "integrity": "sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA==", - "dev": true - }, "napi-macros": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", @@ -51102,8 +50972,6 @@ }, "utf-8-validate": { "version": "5.0.7", - "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", - "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", "dev": true, "optional": true, "requires": { From 132d403738e9e0d5cd8131eca3e2a4bd702edbbe Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Mon, 8 May 2023 14:54:30 +0200 Subject: [PATCH 18/25] fix `matchWithCreationTx` by decoding the constructor arguments * add tests for wrong constructor arguments in creatorTx * add missing test for successful creation bytecode verification --- packages/lib-sourcify/package-lock.json | 1 + packages/lib-sourcify/package.json | 1 + packages/lib-sourcify/src/lib/verification.ts | 53 +++++++++-- .../artifact.json | 4 + .../metadata.json | 44 ++++++++++ .../sources/WithImmutables.sol | 6 ++ .../lib-sourcify/test/verification.spec.ts | 87 ++++++++++++++++++- 7 files changed, 186 insertions(+), 10 deletions(-) create mode 100644 packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/artifact.json create mode 100644 packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/metadata.json create mode 100644 packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/sources/WithImmutables.sol diff --git a/packages/lib-sourcify/package-lock.json b/packages/lib-sourcify/package-lock.json index f8070e310..899cd82a2 100644 --- a/packages/lib-sourcify/package-lock.json +++ b/packages/lib-sourcify/package-lock.json @@ -16,6 +16,7 @@ "@ethereumjs/statemanager": "^1.0.4", "@ethereumjs/util": "^8.0.5", "@ethereumjs/vm": "^6.4.1", + "@ethersproject/abi": "^5.7.0", "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", diff --git a/packages/lib-sourcify/package.json b/packages/lib-sourcify/package.json index 18a747232..313afc332 100644 --- a/packages/lib-sourcify/package.json +++ b/packages/lib-sourcify/package.json @@ -49,6 +49,7 @@ "@ethereumjs/statemanager": "^1.0.4", "@ethereumjs/util": "^8.0.5", "@ethereumjs/vm": "^6.4.1", + "@ethersproject/abi": "^5.7.0", "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", diff --git a/packages/lib-sourcify/src/lib/verification.ts b/packages/lib-sourcify/src/lib/verification.ts index bd70d8dbd..179df8149 100644 --- a/packages/lib-sourcify/src/lib/verification.ts +++ b/packages/lib-sourcify/src/lib/verification.ts @@ -4,6 +4,7 @@ import { Create2Args, ImmutableReferences, Match, + Metadata, RecompilationResult, SourcifyChain, StringMap, @@ -27,6 +28,8 @@ import { hexZeroPad, isHexString } from '@ethersproject/bytes'; import { BigNumber } from '@ethersproject/bignumber'; import { getAddress, getContractAddress } from '@ethersproject/address'; import semverSatisfies from 'semver/functions/satisfies'; +import { defaultAbiCoder as abiCoder, ParamType } from '@ethersproject/abi'; +import { AbiConstructor } from 'abitype'; const RPC_TIMEOUT = 5000; @@ -114,12 +117,14 @@ export async function verifyDeployed( // Try to match with creationTx, if available if (creatorTxHash) { + const recompiledMetadata: Metadata = JSON.parse(recompiled.metadata); await matchWithCreationTx( match, recompiled.creationBytecode, sourcifyChain, address, - creatorTxHash + creatorTxHash, + recompiledMetadata ); if (isPerfectMatch(match)) { return match; @@ -134,7 +139,8 @@ export async function verifyDeployed( recompiled.creationBytecode, sourcifyChain, address, - creatorTxHash + creatorTxHash, + recompiledMetadata ); } ); @@ -355,7 +361,8 @@ export async function matchWithCreationTx( recompiledCreationBytecode: string, sourcifyChain: SourcifyChain, address: string, - creatorTxHash: string + creatorTxHash: string, + recompiledMetadata: Metadata ) { const creatorTx = await getTx(creatorTxHash, sourcifyChain); const creatorTxData = creatorTx.input; @@ -387,6 +394,40 @@ export async function matchWithCreationTx( } if (match.status) { + const abiEncodedConstructorArguments = + extractAbiEncodedConstructorArguments( + creatorTxData, + recompiledCreationBytecode + ); + let constructorAbiParamInputs = ( + recompiledMetadata?.output?.abi?.find( + (param) => param.type === 'constructor' + ) as AbiConstructor + )?.inputs as ParamType[]; + if (abiEncodedConstructorArguments) { + if (!constructorAbiParamInputs) { + match.status = null; + match.message = `Failed to match with creation bytecode: constructor ABI Inputs are missing`; + return; + } + // abiCoder doesn't break if called with a wrong `abiEncodedConstructorArguments` + // so in order to successfuly check if the constructor arguments actually match + // we need to re-encode it and compare them + const decodeResult = abiCoder.decode( + constructorAbiParamInputs, + abiEncodedConstructorArguments + ); + const encodeResult = abiCoder.encode( + constructorAbiParamInputs, + decodeResult + ); + if (encodeResult !== abiEncodedConstructorArguments) { + match.status = null; + match.message = `Failed to match with creation bytecode: constructor arguments ABI decoding failed ${encodeResult} vs ${abiEncodedConstructorArguments}`; + return; + } + } + // we need to check if this contract creation tx actually yields the same contract address https://github.com/ethereum/sourcify/issues/887 const createdContractAddress = getContractAddress({ from: creatorTx.from, @@ -398,11 +439,7 @@ export async function matchWithCreationTx( return; } match.libraryMap = libraryMap; - const abiEncodedConstructorArguments = - extractAbiEncodedConstructorArguments( - creatorTxData, - recompiledCreationBytecode - ); + match.abiEncodedConstructorArguments = abiEncodedConstructorArguments; match.creatorTxHash = creatorTxHash; } diff --git a/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/artifact.json b/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/artifact.json new file mode 100644 index 000000000..56fc11e2e --- /dev/null +++ b/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/artifact.json @@ -0,0 +1,4 @@ +{ + "bytecode": "60a060405234801561001057600080fd5b506040516103ca0000000000000000000000000000000000000000000000000000000000000001", + "abi": [] +} diff --git a/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/metadata.json b/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/metadata.json new file mode 100644 index 000000000..06a0ba48c --- /dev/null +++ b/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/metadata.json @@ -0,0 +1,44 @@ +{ + "compiler": { + "version": "0.8.19+commit.7dd6d404" + }, + "language": "Solidity", + "output": { + "abi": [], + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } + }, + "settings": { + "compilationTarget": { + "sources/WithImmutables.sol": "WithImmutables" + }, + "evmVersion": "paris", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs" + }, + "optimizer": { + "enabled": false, + "runs": 200 + }, + "remappings": [] + }, + "sources": { + "sources/WithImmutables.sol": { + "keccak256": "0xa67bac14ebd5956d06bd0f33e2ffd55db729d4ec85bca19ec5b321e6be0b7cc8", + "urls": [ + "bzz-raw://6d83c127e075a149ec14c6af579bc7b24955cdb7578ae7da2f253b7142d267cc", + "dweb:/ipfs/QmW6tdCTV7X5dd5LCKDWedbMmkurQTMi4ePx7LY3DNuLn7" + ] + } + }, + "version": 1 +} diff --git a/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/sources/WithImmutables.sol b/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/sources/WithImmutables.sol new file mode 100644 index 000000000..4f90eb28e --- /dev/null +++ b/packages/lib-sourcify/test/sources/WithImmutablesCreationBytecodeAttack/sources/WithImmutables.sol @@ -0,0 +1,6 @@ +pragma solidity >=0.7.0; + +contract WithImmutables{ + constructor (uint256 a) { + } +} \ No newline at end of file diff --git a/packages/lib-sourcify/test/verification.spec.ts b/packages/lib-sourcify/test/verification.spec.ts index d7f400ca8..248feb2f5 100644 --- a/packages/lib-sourcify/test/verification.spec.ts +++ b/packages/lib-sourcify/test/verification.spec.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ import path from 'path'; -import { SourcifyChain } from '../src/lib/types'; +import { Metadata, SourcifyChain } from '../src/lib/types'; import Web3 from 'web3'; import Ganache from 'ganache'; import { @@ -564,14 +564,97 @@ describe('lib-sourcify tests', () => { chainId: sourcifyChainGanache.chainId.toString(), status: null, }; + const recompiledMetadata: Metadata = JSON.parse(recompiled.metadata); await matchWithCreationTx( match, recompiled.creationBytecode, sourcifyChainGanache, deployedAddress, - wrongCreatorTxHash + wrongCreatorTxHash, + recompiledMetadata ); expectMatch(match, null, deployedAddress, undefined); // status is null }); + + it('should fail to matchWithCreationTx with creatorTxHash having wrong constructor arguments', async () => { + const contractFolderPath = path.join( + __dirname, + 'sources', + 'WithImmutables' + ); + const maliciousContractFolderPath = path.join( + __dirname, + 'sources', + 'WithImmutablesCreationBytecodeAttack' + ); + + const [deployedAddress, wrongCreatorTxHash] = + await deployFromAbiAndBytecode( + localWeb3Provider, + contractFolderPath, + accounts[0], + ['12345'] + ); + const [,] = await deployFromAbiAndBytecode( + localWeb3Provider, + maliciousContractFolderPath, + accounts[0], + ['12345'] + ); + + const checkedContracts = await checkFilesFromContractFolder( + maliciousContractFolderPath + ); + const recompiled = await checkedContracts[0].recompile(); + const match = { + address: deployedAddress, + chainId: sourcifyChainGanache.chainId.toString(), + status: null, + }; + const recompiledMetadata: Metadata = JSON.parse(recompiled.metadata); + await matchWithCreationTx( + match, + '0x60a060405234801561001057600080fd5b506040516103ca', // I force recompiled.creationBytecode because it would take time to generate the right attack, + sourcifyChainGanache, + deployedAddress, + wrongCreatorTxHash, + recompiledMetadata + ); + expectMatch(match, null, deployedAddress, undefined); // status is null + }); + + it('should successfuly verify with matchWithCreationTx with creationTxHash', async () => { + const contractFolderPath = path.join( + __dirname, + 'sources', + 'WithImmutables' + ); + const [deployedAddress, creatorTxHash] = await deployFromAbiAndBytecode( + localWeb3Provider, + contractFolderPath, + accounts[0], + ['12345'] + ); + + const checkedContracts = await checkFilesFromContractFolder( + contractFolderPath + ); + const recompiled = await checkedContracts[0].recompile(); + const match = { + address: deployedAddress, + chainId: sourcifyChainGanache.chainId.toString(), + status: null, + }; + const recompiledMetadata: Metadata = JSON.parse(recompiled.metadata); + await matchWithCreationTx( + match, + recompiled.creationBytecode, + sourcifyChainGanache, + deployedAddress, + creatorTxHash, + recompiledMetadata + ); + expectMatch(match, 'perfect', deployedAddress, undefined); // status is null + }); }); }); From 763e0d57342dd3fbba878f90cd14496b62a53564 Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Mon, 8 May 2023 16:05:54 +0200 Subject: [PATCH 19/25] test for paths in metadata containing multiple `../` * check that the file is saved in the correct directory --- test/server.js | 54 ++++++++++++++++ .../Storage/metadata.upMultipleDirs.json | 64 +++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 test/testcontracts/Storage/metadata.upMultipleDirs.json diff --git a/test/server.js b/test/server.js index 6b211554d..bce28a0ca 100644 --- a/test/server.js +++ b/test/server.js @@ -890,6 +890,60 @@ describe("Server", function () { ); }); }); + + it("should store a contract in /contracts/full_match|partial_match/0xADDRESS despite the files paths in the metadata", async () => { + const artifact = require("./testcontracts/Storage/Storage.json"); + const [address] = await deployFromAbiAndBytecodeForCreatorTxHash( + localWeb3Provider, + artifact.abi, + artifact.bytecode, + accounts[0], + [] + ); + + const metadata = require("./testcontracts/Storage/metadata.upMultipleDirs.json"); + const sourcePath = path.join( + "test", + "testcontracts", + "Storage", + "Storage.sol" + ); + const sourceBuffer = fs.readFileSync(sourcePath); + + // Now pass the creatorTxHash + const res = await chai + .request(server.app) + .post("/") + .send({ + address: address, + chain: defaultContractChain, + files: { + "metadata.json": JSON.stringify(metadata), + "Storage.sol": sourceBuffer.toString(), + }, + }); + assertVerification( + null, + res, + null, + address, + defaultContractChain, + "partial" + ); + const isExist = fs.existsSync( + path.join( + server.repository, + "contracts", + "partial_match", + defaultContractChain, + address, + "sources", + "..contracts", + "Storage.sol" + ) + ); + chai.expect(isExist, "Files saved in the wrong directory").to.be.true; + }); }); describe("solc v0.6.12 and v0.7.0 extra files in compilation causing metadata match but bytecode mismatch", function () { diff --git a/test/testcontracts/Storage/metadata.upMultipleDirs.json b/test/testcontracts/Storage/metadata.upMultipleDirs.json new file mode 100644 index 000000000..e51b7ceac --- /dev/null +++ b/test/testcontracts/Storage/metadata.upMultipleDirs.json @@ -0,0 +1,64 @@ +{ + "compiler": { "version": "0.8.4+commit.c7e474f2" }, + "language": "Solidity", + "output": { + "abi": [ + { + "inputs": [], + "name": "retrieve", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "num", "type": "uint256" } + ], + "name": "store", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "devdoc": { + "details": "Store & retrieve value in a variable", + "kind": "dev", + "methods": { + "retrieve()": { + "details": "Return value ", + "returns": { "_0": "value of 'number'" } + }, + "store(uint256)": { + "details": "Store value in variable", + "params": { "num": "value to store" } + } + }, + "title": "Storage", + "version": 1 + }, + "userdoc": { "kind": "user", "methods": {}, "version": 1 } + }, + "settings": { + "compilationTarget": { + "..contracts/../../../../../Storage.sol": "Storage" + }, + "evmVersion": "istanbul", + "libraries": {}, + "metadata": { "bytecodeHash": "ipfs" }, + "optimizer": { "enabled": false, "runs": 200 }, + "remappings": [] + }, + "sources": { + "..contracts/../../../../../Storage.sol": { + "keccak256": "0x88c47206b5ec3d60ab820e9d126c4ac54cb17fa7396ff49ebe27db2862982ad8", + "license": "GPL-3.0", + "urls": [ + "bzz-raw://5d1eeb01c8c10bed9e290f4a80a8d4081422a7b298a13049d72867022522cf6b", + "dweb:/ipfs/QmaFRC9ZtT7y3t9XNWCbDuMTEwKkyaQJzYFzw3NbeohSn5" + ] + } + }, + "version": 1 +} From a6af063cfd97a3c8ef1a9535e4d5e101eca740fa Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Mon, 8 May 2023 16:56:23 +0200 Subject: [PATCH 20/25] fix linter error --- packages/lib-sourcify/src/lib/verification.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lib-sourcify/src/lib/verification.ts b/packages/lib-sourcify/src/lib/verification.ts index 179df8149..aa126c49a 100644 --- a/packages/lib-sourcify/src/lib/verification.ts +++ b/packages/lib-sourcify/src/lib/verification.ts @@ -399,7 +399,7 @@ export async function matchWithCreationTx( creatorTxData, recompiledCreationBytecode ); - let constructorAbiParamInputs = ( + const constructorAbiParamInputs = ( recompiledMetadata?.output?.abi?.find( (param) => param.type === 'constructor' ) as AbiConstructor From c7f92eb6dca7c43c6bf436bc6ddae531696d7eb9 Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Mon, 8 May 2023 17:00:21 +0200 Subject: [PATCH 21/25] fix linter warning * remove unused Metadata variable from RepositoryController --- src/server/services/RepositoryService.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server/services/RepositoryService.ts b/src/server/services/RepositoryService.ts index ad1d67afe..0ef87d004 100644 --- a/src/server/services/RepositoryService.ts +++ b/src/server/services/RepositoryService.ts @@ -6,7 +6,6 @@ import { Status, Create2Args, StringMap, - Metadata, /* ContextVariables, */ CheckedContract, } from "@ethereum-sourcify/lib-sourcify"; From dceda9f77251b56888f1cdc5cf287f7c073b383e Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Tue, 9 May 2023 09:25:13 +0200 Subject: [PATCH 22/25] return an error for an empty `recompiledCreationBytecode` in `matchWithCreationTx` --- packages/lib-sourcify/src/lib/verification.ts | 5 +++ .../metadata.json | 44 +++++++++++++++++++ .../sources/FFF.sol | 6 +++ .../lib-sourcify/test/verification.spec.ts | 41 +++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/metadata.json create mode 100644 packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/sources/FFF.sol diff --git a/packages/lib-sourcify/src/lib/verification.ts b/packages/lib-sourcify/src/lib/verification.ts index aa126c49a..7e6ac8175 100644 --- a/packages/lib-sourcify/src/lib/verification.ts +++ b/packages/lib-sourcify/src/lib/verification.ts @@ -364,6 +364,11 @@ export async function matchWithCreationTx( creatorTxHash: string, recompiledMetadata: Metadata ) { + if (recompiledCreationBytecode === '0x') { + match.status = null; + match.message = `Failed to match with creation bytecode: recompiled contract's creation bytecode is empty`; + return; + } const creatorTx = await getTx(creatorTxHash, sourcifyChain); const creatorTxData = creatorTx.input; diff --git a/packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/metadata.json b/packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/metadata.json new file mode 100644 index 000000000..d434360de --- /dev/null +++ b/packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/metadata.json @@ -0,0 +1,44 @@ +{ + "compiler": { + "version": "0.6.12+commit.27d51765" + }, + "language": "Solidity", + "output": { + "abi": [], + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } + }, + "settings": { + "compilationTarget": { + "sources/FFF.sol": "FFF" + }, + "evmVersion": "istanbul", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs" + }, + "optimizer": { + "enabled": false, + "runs": 200 + }, + "remappings": [] + }, + "sources": { + "sources/FFF.sol": { + "keccak256": "0x7ed3554b3f768ad3b3069d7fc8b1a08a24500507fc8a60eb11c726e37f3cd9a3", + "urls": [ + "bzz-raw://6d83c127e075a149ec14c6af579bc7b24955cdb7578ae7da2f253b7142d267cc", + "dweb:/ipfs/QmW6tdCTV7X5dd5LCKDWedbMmkurQTMi4ePx7LY3DNuLn7" + ] + } + }, + "version": 1 +} diff --git a/packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/sources/FFF.sol b/packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/sources/FFF.sol new file mode 100644 index 000000000..b12b1d274 --- /dev/null +++ b/packages/lib-sourcify/test/sources/AbstractCreationBytecodeAttack/sources/FFF.sol @@ -0,0 +1,6 @@ +pragma solidity 0.6.12; + +abstract contract FFF{ + constructor (uint256 a) public payable { + } +} \ No newline at end of file diff --git a/packages/lib-sourcify/test/verification.spec.ts b/packages/lib-sourcify/test/verification.spec.ts index 248feb2f5..821bed1bf 100644 --- a/packages/lib-sourcify/test/verification.spec.ts +++ b/packages/lib-sourcify/test/verification.spec.ts @@ -623,6 +623,47 @@ describe('lib-sourcify tests', () => { expectMatch(match, null, deployedAddress, undefined); // status is null }); + it('should fail to matchWithCreationTx when passing an abstract contract', async () => { + const contractFolderPath = path.join( + __dirname, + 'sources', + 'WithImmutables' + ); + + const [deployedAddress, creatorTxHash] = await deployFromAbiAndBytecode( + localWeb3Provider, + contractFolderPath, + accounts[0], + ['12345'] + ); + + const maliciousContractFolderPath = path.join( + __dirname, + 'sources', + 'AbstractCreationBytecodeAttack' + ); + const checkedContracts = await checkFilesFromContractFolder( + maliciousContractFolderPath + ); + const recompiled = await checkedContracts[0].recompile(); + const match = { + address: deployedAddress, + chainId: sourcifyChainGanache.chainId.toString(), + status: null, + }; + const recompiledMetadata: Metadata = JSON.parse(recompiled.metadata); + + await matchWithCreationTx( + match, + recompiled.creationBytecode, + sourcifyChainGanache, + deployedAddress, + creatorTxHash, + recompiledMetadata + ); + expectMatch(match, null, deployedAddress, undefined); // status is null + }); + it('should successfuly verify with matchWithCreationTx with creationTxHash', async () => { const contractFolderPath = path.join( __dirname, From d8a561f91dc476cee4c3d422c67680682667bc98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Tue, 9 May 2023 12:11:54 +0200 Subject: [PATCH 23/25] Throw before if compiled bytecode empty --- packages/lib-sourcify/src/lib/verification.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/lib-sourcify/src/lib/verification.ts b/packages/lib-sourcify/src/lib/verification.ts index 7e6ac8175..7fe9fc73e 100644 --- a/packages/lib-sourcify/src/lib/verification.ts +++ b/packages/lib-sourcify/src/lib/verification.ts @@ -47,6 +47,15 @@ export async function verifyDeployed( }; const recompiled = await checkedContract.recompile(); + if ( + recompiled.deployedBytecode === '0x' || + recompiled.creationBytecode === '0x' + ) { + throw new Error( + `The compiled contract bytecode is "0x". Are you trying to verify an abstract contract?` + ); + } + const deployedBytecode = await getBytecode(sourcifyChain, address); // Can't match if there is no deployed bytecode @@ -364,11 +373,6 @@ export async function matchWithCreationTx( creatorTxHash: string, recompiledMetadata: Metadata ) { - if (recompiledCreationBytecode === '0x') { - match.status = null; - match.message = `Failed to match with creation bytecode: recompiled contract's creation bytecode is empty`; - return; - } const creatorTx = await getTx(creatorTxHash, sourcifyChain); const creatorTxData = creatorTx.input; From 71acbebf57ac2fc34d28e097cff7af0bb6498b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Tue, 9 May 2023 12:24:00 +0200 Subject: [PATCH 24/25] Add back empty bytecode check to matchWithCreationTx As the function can be used as standalone, we should not remove the check from the function itself. Keep both this and throwing before trying to match. --- packages/lib-sourcify/src/lib/verification.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/lib-sourcify/src/lib/verification.ts b/packages/lib-sourcify/src/lib/verification.ts index 7fe9fc73e..e012fd5d8 100644 --- a/packages/lib-sourcify/src/lib/verification.ts +++ b/packages/lib-sourcify/src/lib/verification.ts @@ -373,6 +373,12 @@ export async function matchWithCreationTx( creatorTxHash: string, recompiledMetadata: Metadata ) { + if (recompiledCreationBytecode === '0x') { + match.status = null; + match.message = `Failed to match with creation bytecode: recompiled contract's creation bytecode is empty`; + return; + } + const creatorTx = await getTx(creatorTxHash, sourcifyChain); const creatorTxData = creatorTx.input; From 3008e8ad4a913557818a2eedba4412fdbfe1a2a2 Mon Sep 17 00:00:00 2001 From: Marco Castignoli Date: Tue, 9 May 2023 16:56:01 +0200 Subject: [PATCH 25/25] fix vscode debugger's configuration for lib-sourcify --- .vscode/launch.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5896086b4..2567a70d4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -190,10 +190,7 @@ // "--grep=v0.6.12", "--exit", ], - "outFiles": [ - "./**/*.js", - "${workspaceFolder}/packages/lib-sourcify/build/**/*.js" - ], + "sourceMaps": true, "smartStep": true, "console": "integratedTerminal", // "internalConsoleOptions": "neverOpen"