From df9d6ac2b0c530309f682d7a5b2c111bed0071bb Mon Sep 17 00:00:00 2001 From: elshan_eth Date: Fri, 6 Dec 2024 15:44:40 +0100 Subject: [PATCH] Fx code & add tx hash to json out --- deployment-txs/mainnet.json | 6 +++++- deployment-txs/sepolia.json | 6 +++++- src/task.ts | 24 ++++++++---------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/deployment-txs/mainnet.json b/deployment-txs/mainnet.json index 90768cc3..a5c2d556 100644 --- a/deployment-txs/mainnet.json +++ b/deployment-txs/mainnet.json @@ -173,5 +173,9 @@ "0x201efd508c8DfE9DE1a13c2452863A78CB2a86Cc": "0x1e14baaeb10fc3a6b689e77ec34e8c5e8e21853f6e23257459dd99c35b6ff06b", "0x527d0E14acc53FB040DeBeae1cAb973D23FB3568": "0x44d82009c125f39bd2bbd1f723e7284e4226d5d752a66b18536e5d92c37b0c82", "0xB9d01CA61b9C181dA1051bFDd28e1097e920AB14": "0x2794463090a850910415b88df0f756e01e0838c8782e83a89389992c17469513", - "0x89Ef89Fd9a6ec73bcE588F309C1F65C406d2891C": "0xb85dd153e2e12599487632277c99375af44402e6c6053d47fa622a7a02d71691" + "0x89Ef89Fd9a6ec73bcE588F309C1F65C406d2891C": "0xb85dd153e2e12599487632277c99375af44402e6c6053d47fa622a7a02d71691", + "0xbA1333333333a1BA1108E8412f11850A5C319bA9": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4", + "0x0E8B07657D719B86e06bF0806D6729e3D528C9A9": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4", + "0x35fFB749B273bEb20F40f35EdeB805012C539864": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4", + "0xa731C23D7c95436Baaae9D52782f966E1ed07cc8": "0x49a4986a672bcc20eecf99a3603f0099b19ab663eebe5dd5fe04808c380147b4" } \ No newline at end of file diff --git a/deployment-txs/sepolia.json b/deployment-txs/sepolia.json index 78768062..f1860880 100644 --- a/deployment-txs/sepolia.json +++ b/deployment-txs/sepolia.json @@ -86,5 +86,9 @@ "0x7532d5a3bE916e4a4D900240F49F0BABd4FD855C": "0xe42c9cdc05ab3de2b8698ed32e56dce0f85c1017099aa965784d8023fb29d012", "0xFc253B433B7225AC7736EAbDF4115F7252aECb91": "0x45579023de61bae57ba62a72a50783509afa7c47f466150b3d5f134d220624b6", "0xd67F485C07D258B3e93835a3799d862ffcB55923": "0x48d803b01baf630543481ca6eefca5dc269d8670cf44afd08dcba3792a48710f", - "0x7373C5b9610d43466395617c428eCAA5b47ac5AA": "0x00dcc321792c060560757aea332ba6247d84c0365f535105229ea75b8d9d3f9d" + "0x7373C5b9610d43466395617c428eCAA5b47ac5AA": "0x00dcc321792c060560757aea332ba6247d84c0365f535105229ea75b8d9d3f9d", + "0xbA1333333333a1BA1108E8412f11850A5C319bA9": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81", + "0x0E8B07657D719B86e06bF0806D6729e3D528C9A9": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81", + "0x35fFB749B273bEb20F40f35EdeB805012C539864": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81", + "0xa731C23D7c95436Baaae9D52782f966E1ed07cc8": "0xe9ab355e0f5987453c48b3fe64f7c63ae4ba6dc5a85d1e43fb3a066dffe16a81" } \ No newline at end of file diff --git a/src/task.ts b/src/task.ts index 805dfb8a..a1074488 100644 --- a/src/task.ts +++ b/src/task.ts @@ -5,7 +5,6 @@ import { Contract, ethers } from 'ethers'; import { hexToBytes, Address } from '@ethereumjs/util'; import { Chain, Common, Hardfork } from '@ethereumjs/common'; import { EVM } from '@ethereumjs/evm'; -import { DefaultStateManager } from '@ethereumjs/statemanager'; import { getContractAddress } from '@ethersproject/address'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; @@ -29,8 +28,6 @@ import { getContractDeploymentTransactionHash, saveContractDeploymentTransaction import { getTaskActionIds } from './actionId'; import { getArtifactFromContractOutput } from './artifact'; import { getSigner } from './signers'; -import { Block } from '@ethereumjs/evm/dist/cjs/types'; -import { zeroAddress } from 'ethereumjs-util'; // Maps to ../v2 and ../v3. const VERSION_ROOTS = ['v2', 'v3'].map((version) => path.resolve(__dirname, `../${version}`)); @@ -155,7 +152,6 @@ export default class Task { logger.success(`Deploy contracts using factory...`); from = from || (await getSigner()); - const receipt = await from?.sendTransaction(populatedDeployTransaction); return await receipt.wait(); @@ -169,16 +165,14 @@ export default class Task { const { ethers } = await import('hardhat'); if (deployTransaction == null) { + // All contracts are deployed by the one factory transaction, so we can find the transaction hash by the first element const deployedAddress = this.output()[contractsInfo[0].name]; const deploymentTxHash = getContractDeploymentTransactionHash(deployedAddress, this.network); deployTransaction = await ethers.provider.getTransactionReceipt(deploymentTxHash); } const evm = await this.createEVM(); - for (const contractInfo of contractsInfo) { - const instance = await this.instanceAt(contractInfo.name, contractInfo.expectedAddress); - const isDeployedBytecodeValid = await this.checkBytecodeAndSaveEVMState( evm, deployTransaction, @@ -187,9 +181,13 @@ export default class Task { contractInfo.args ); + if (isDeployedBytecodeValid && this.mode === TaskMode.CHECK) { + logger.success(`Verified contract '${contractInfo.name}' on network '${this.network}' of task '${this.id}'`); + } + if (isDeployedBytecodeValid == false) { throw Error( - `Contract ${contractInfo.name} at ${contractInfo.expectedAddress} does not match expected bytecode.` + `Contract ${contractInfo.name} at ${contractInfo.expectedAddress} does not match expected bytecode with abi.` ); } @@ -197,6 +195,7 @@ export default class Task { continue; } + const instance = await this.instanceAt(contractInfo.name, contractInfo.expectedAddress); this.save({ [contractInfo.name]: instance }); logger.success(`Contract ${contractInfo.name} attached at ${contractInfo.expectedAddress}`); @@ -207,15 +206,8 @@ export default class Task { this.network ); } - } - - if (this.mode === TaskMode.CHECK) { - return; - } - for (const contractInfo of contractsInfo) { - const { name, expectedAddress, args } = contractInfo; - await this.verify(name, expectedAddress, args); + await this.verify(contractInfo.name, contractInfo.expectedAddress, contractInfo.args); } }