From 5774da512594fac8a4ae15eb08f31230aa500066 Mon Sep 17 00:00:00 2001 From: Oren Date: Tue, 27 Sep 2022 15:28:52 +0300 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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 */} +
+ */}