From cd745681d0abc423437637712bc104947c641005 Mon Sep 17 00:00:00 2001 From: Anastasia Kovaliova Date: Tue, 27 Feb 2024 15:02:15 +0200 Subject: [PATCH 01/18] test: first 4 tests Signed-off-by: Anastasia Kovaliova --- .../InternalCallee.sol/InternalCallee.json | 121 +++++++++ .../nonce/InternalCallee.sol/Sample.json | 18 ++ .../account/NonExisting.sol/NonExisting.json | 117 +++++++++ .../discrepancies/nonce/InternalCallee.sol | 21 +- test/constants.js | 1 + test/discrepancies/Nonce.js | 247 ++++++++++++++++++ test/hts-precompile/utils.js | 27 ++ 7 files changed, 551 insertions(+), 1 deletion(-) create mode 100644 artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json create mode 100644 artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json create mode 100644 artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json diff --git a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json new file mode 100644 index 000000000..6b1a6d5e8 --- /dev/null +++ b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json @@ -0,0 +1,121 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "InternalCallee", + "sourceName": "contracts/discrepancies/nonce/InternalCallee.sol", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContractAddress", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_salt", + "type": "uint256" + } + ], + "name": "deployViaCreate2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "externalFunction", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "factorySample", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revertWithRevertReason", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revertWithoutRevertReason", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_addr", + "type": "address" + } + ], + "name": "selfdestruct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "sampleAddress", + "type": "address" + } + ], + "name": "selfdestructSample", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60806040526000805534801561001457600080fd5b506103b4806100246000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063b1dd8b811161005b578063b1dd8b81146100e0578063b3943ef8146100f5578063cfc72007146100fd578063ff489d311461011057600080fd5b806311f95f6f146100825780633a32b5491461009f5780638b2db1a8146100b5575b600080fd5b61008a610118565b60405190151581526020015b60405180910390f35b6100a7610156565b604051908152602001610096565b6100c86100c3366004610287565b610170565b6040516001600160a01b039091168152602001610096565b6100f36100ee3660046102a0565b6101e9565b005b6100c861023f565b6100f361010b3660046102a0565b61026f565b61008a600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b60008060008154610166906102d0565b9182905550919050565b6000808260001b6040516101839061027b565b8190604051809103906000f59050801580156101a3573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b5050505050565b600060405161024d9061027b565b604051809103906000f080158015610269573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806102f883390190565b60006020828403121561029957600080fd5b5035919050565b6000602082840312156102b257600080fd5b81356001600160a01b03811681146102c957600080fd5b9392505050565b6000600182016102f057634e487b7160e01b600052601160045260246000fd5b506001019056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033a26469706673582212204b22adf77c8dd46d093f9ab8326be65ecc943a831917b7d4623eb5385feee33b64736f6c63430008140033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c8063b1dd8b811161005b578063b1dd8b81146100e0578063b3943ef8146100f5578063cfc72007146100fd578063ff489d311461011057600080fd5b806311f95f6f146100825780633a32b5491461009f5780638b2db1a8146100b5575b600080fd5b61008a610118565b60405190151581526020015b60405180910390f35b6100a7610156565b604051908152602001610096565b6100c86100c3366004610287565b610170565b6040516001600160a01b039091168152602001610096565b6100f36100ee3660046102a0565b6101e9565b005b6100c861023f565b6100f361010b3660046102a0565b61026f565b61008a600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b60008060008154610166906102d0565b9182905550919050565b6000808260001b6040516101839061027b565b8190604051809103906000f59050801580156101a3573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b5050505050565b600060405161024d9061027b565b604051809103906000f080158015610269573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806102f883390190565b60006020828403121561029957600080fd5b5035919050565b6000602082840312156102b257600080fd5b81356001600160a01b03811681146102c957600080fd5b9392505050565b6000600182016102f057634e487b7160e01b600052601160045260246000fd5b506001019056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033a26469706673582212204b22adf77c8dd46d093f9ab8326be65ecc943a831917b7d4623eb5385feee33b64736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json new file mode 100644 index 000000000..dcf09b71c --- /dev/null +++ b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json @@ -0,0 +1,18 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "Sample", + "sourceName": "contracts/discrepancies/nonce/InternalCallee.sol", + "abi": [ + { + "inputs": [], + "name": "selfdestruct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json b/artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json new file mode 100644 index 000000000..547a67861 --- /dev/null +++ b/artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json @@ -0,0 +1,117 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "NonExisting", + "sourceName": "contracts/solidity/account/NonExisting.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nonExistingAddr", + "type": "address" + } + ], + "name": "balanceNoneExistingAddr", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nonExistingAddr", + "type": "address" + } + ], + "name": "callOnNonExistingAccount", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nonExistingAddr", + "type": "address" + } + ], + "name": "delegatecallOnNonExistingAccount", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nonExistingAddr", + "type": "address" + } + ], + "name": "staticcallOnNonExistingAccount", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b5060405161038638038061038683398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b6102f3806100936000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806304fa55251461005c57806338750ce41461008457806370a08231146100845780637688ef3a146100ad578063ac8ff975146100c0575b600080fd5b61006f61006a36600461025e565b6100d3565b60405190151581526020015b60405180910390f35b61009f61009236600461025e565b6001600160a01b03163190565b60405190815260200161007b565b61006f6100bb36600461025e565b610162565b61006f6100ce36600461025e565b6101e0565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101169161028e565b6000604051808303816000865af19150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b606091505b5090949350505050565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101a59161028e565b600060405180830381855afa9150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916102239161028e565b600060405180830381855af49150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60006020828403121561027057600080fd5b81356001600160a01b038116811461028757600080fd5b9392505050565b6000825160005b818110156102af5760208186018101518583015201610295565b50600092019182525091905056fea26469706673582212203c6153cffa6f0bfdee9f6c3d65b45af1d2aebb38adc9b9384a2852c52f3dd2ac64736f6c63430008140033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c806304fa55251461005c57806338750ce41461008457806370a08231146100845780637688ef3a146100ad578063ac8ff975146100c0575b600080fd5b61006f61006a36600461025e565b6100d3565b60405190151581526020015b60405180910390f35b61009f61009236600461025e565b6001600160a01b03163190565b60405190815260200161007b565b61006f6100bb36600461025e565b610162565b61006f6100ce36600461025e565b6101e0565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101169161028e565b6000604051808303816000865af19150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b606091505b5090949350505050565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101a59161028e565b600060405180830381855afa9150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916102239161028e565b600060405180830381855af49150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60006020828403121561027057600080fd5b81356001600160a01b038116811461028757600080fd5b9392505050565b6000825160005b818110156102af5760208186018101518583015201610295565b50600092019182525091905056fea26469706673582212203c6153cffa6f0bfdee9f6c3d65b45af1d2aebb38adc9b9384a2852c52f3dd2ac64736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/contracts/discrepancies/nonce/InternalCallee.sol b/contracts/discrepancies/nonce/InternalCallee.sol index caacc5299..719c7e1cc 100644 --- a/contracts/discrepancies/nonce/InternalCallee.sol +++ b/contracts/discrepancies/nonce/InternalCallee.sol @@ -1,7 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; -contract Sample {} +contract Sample { + function selfdestruct() external { + selfdestruct(payable(msg.sender)); + } +} contract InternalCallee { uint calledTimes = 0; @@ -28,4 +32,19 @@ contract InternalCallee { function selfDestruct(address payable _addr) external { selfdestruct(_addr); } + + function selfdestructSample(address payable sampleAddress) external { + Sample(sampleAddress).selfdestruct(); + } + + event DeployedContractAddress(address); + + function deployViaCreate2(uint256 _salt) external returns (address) { + Sample temp = new Sample{salt: bytes32(_salt)}(); + emit DeployedContractAddress(address(temp)); + + return address(temp); + } + + } diff --git a/test/constants.js b/test/constants.js index 230258588..3eb04b3dc 100644 --- a/test/constants.js +++ b/test/constants.js @@ -56,6 +56,7 @@ const Events = { TinyBars: 'TinyBars', TinyCents: 'TinyCents', PseudoRandomSeed: 'PseudoRandomSeed', + DeployedContractAddress: 'DeployedContractAddress' }; const Path = { diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index ca9713c3a..0fecb101d 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -18,8 +18,10 @@ * */ +const { utils } = require('elliptic'); const Constants = require('../constants'); const Utils = require("../hts-precompile/utils"); +const TestUtils = require("../utils"); const {expect} = require('chai'); const {ethers} = require('hardhat'); @@ -30,6 +32,11 @@ describe('@discrepancies - Nonce Test Suite', async () => { let internalCallerContract; let tooLowGasPrice; let enoughGasPrice; + let tokenCreateContract; + let tokenTransferContract; + let tokenAddress; + let erc20Contract; + const TOTAL_SUPPLY = 1000; before(async () => { signers = await ethers.getSigners(); @@ -44,8 +51,42 @@ describe('@discrepancies - Nonce Test Suite', async () => { const internalCallerContractFactory = await ethers.getContractFactory(Constants.Contract.InternalCaller); internalCallerContract = await internalCallerContractFactory.deploy(); + + tokenCreateContract = await Utils.deployTokenCreateContract(); + tokenTransferContract = await Utils.deployTokenTransferContract(); + await Utils.updateAccountKeysViaHapi([ + await tokenCreateContract.getAddress(), + await tokenTransferContract.getAddress(), + ]); + erc20Contract = await Utils.deployERC20Contract(); + tokenAddress = await Utils.createFungibleToken( + tokenCreateContract, + signers[0].address + ); + + await Utils.updateTokenKeysViaHapi(tokenAddress, [ + await tokenCreateContract.getAddress(), + await tokenTransferContract.getAddress(), + ]); + // await Utils.associateToken( + // tokenCreateContract, + // tokenAddress, + // Constants.Contract.TokenCreateContract + // ); + // await Utils.grantTokenKyc(tokenCreateContract, tokenAddress); + + }); + async function getServicesContractNonce(evmAddress){ + try{ + const info = await Utils.getContractInfo(evmAddress, sdkClient); + return info?.ethereumNonce?.toNumber(); + }catch (e){ + return null; + } + } + async function getServicesNonce(evmAddress) { try { const info = await Utils.getAccountInfo(evmAddress, sdkClient); @@ -307,4 +348,210 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); + + it('should update nonce after successful ERC20 token call', async function() { + + const signers = await ethers.getSigners(); + const amount = 200; + + const snBefore = await getServicesNonce(signers[0].address); + const mnBefore = await getMirrorNodeNonce(signers[0].address); + + try { + const tx = await erc20Contract + .connect(signers[0]) + .transfer( + tokenAddress, + signers[1].address, + amount, + Constants.GAS_LIMIT_1_000_000 + ); + await tx.wait(); + } catch (e) { + expect(e).to.exist; + expect(e.code).to.eq(Constants.CALL_EXCEPTION); + } + + const snAfter = await getServicesNonce(signers[0].address); + const mnAfter = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + }) + + it('should update nonce after successful ERC721 token call', async function() { + erc721Contract = await Utils.deployERC721Contract(); + tokenAddress = await Utils.createNonFungibleToken( + tokenCreateContract, + signers[0].address + ); + await Utils.updateTokenKeysViaHapi(tokenAddress, [ + await tokenCreateContract.getAddress(), + await tokenTransferContract.getAddress(), + ]); + + const snBefore = await getServicesNonce(signers[0].address); + const mnBefore = await getMirrorNodeNonce(signers[0].address); + + mintedTokenSerialNumber = await Utils.mintNFT( + tokenCreateContract, + tokenAddress + ); + + const snAfter = await getServicesNonce(signers[0].address); + const mnAfter = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + }); + + it('should update nonce after successful call to Ethereum Precompiles', async function() { + const Contract = await ethers.getContractFactory( + Constants.Contract.EthNativePrecompileCaller + ); + contract = await Contract.deploy({ + gasLimit: 15_000_000, + }); + + const UNSIGNED_DATA = 'Hello Eth Native Precompiles!'; + let signer = (await ethers.getSigners())[0]; + let hashedData = ethers.hashMessage(UNSIGNED_DATA); + let signedData = await signer.signMessage(UNSIGNED_DATA); + let signerAddr = signer.address.toLowerCase().replace('0x', ''); + + const splitSignature = ethers.Signature.from(signedData); + + let v = splitSignature.v; + let r = splitSignature.r; + let s = splitSignature.s; + + const callData = `0x${TestUtils.to32ByteString(hashedData)}${TestUtils.to32ByteString( + v + )}${TestUtils.to32ByteString(r)}${TestUtils.to32ByteString(s)}`; + + const snBefore = await getServicesNonce(signers[0].address); + const mnBefore = await getMirrorNodeNonce(signers[0].address); + + const result = await contract.call0x01(callData); + const rec = await result.wait(); + expect(rec.logs[0].data).to.contain(signerAddr); + + const snAfter = await getServicesNonce(signers[0].address); + const mnAfter = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + }); + + it('should update nonce after unsuccessful contract deploy with CREATE2 ', async function() { + + const firstTx = await internalCalleeContract.deployViaCreate2(1); + await firstTx.wait(); + + const snBefore = await getServicesNonce(signers[0].address); + const mnBefore = await getMirrorNodeNonce(signers[0].address); + + await Utils.expectToFail( + internalCalleeContract.deployViaCreate2(1, {gasLimit: 500000}) + ); + + const snAfter = await getServicesNonce(signers[0].address); + const mnAfter = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + + }); + + //fails - cannot get correct nonce + it('should update all nonces after a successful contract deploy with CREATE2 ', async function() { + + const snBefore = await getServicesNonce(signers[0].address); + const mnBefore = await getMirrorNodeNonce(signers[0].address); + + //deploy a contract with CREATE2 + const firstTx = await internalCalleeContract.deployViaCreate2(1); + const txReceipt = await firstTx.wait(); + + const deployedTempContractAddress = txReceipt.logs.filter( + (e) => e.fragment.name === Constants.Events.DeployedContractAddress + )[0].args[0]; + + const snAfter = await getServicesNonce(signers[0].address); + const mnAfter = await getMirrorNodeNonce(signers[0].address); + + //get the nonce of the intermediary contract + const contractFactorySnAfter = await getServicesContractNonce(internalCalleeContract.target); + const contractFactoryMnAfter = await getServicesContractNonce(internalCalleeContract.target); + + //After successful deploy verify that the nonces of the factory contract and the tx signer are updated + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + expectIncrementedNonce(0, 0, contractFactorySnAfter, contractFactoryMnAfter); + + const selfdestructTx = await internalCalleeContract.selfdestructSample(deployedTempContractAddress); + await selfdestructTx.wait(); + + //signer nonce should increment after selfdestruct is executed + expectIncrementedNonce(snAfter, mnAfter, snAfter + 1, mnAfter + 1); + + //redeploy the contract with the same salt and verify nonces are updated + const redeployTx = await internalCalleeContract.deployViaCreate2(1); + const redeployTxReceipt = await firstTx.wait(); + + const redeployedTempContractAddress = txReceipt.logs.filter( + (e) => e.fragment.name === Constants.Events.DeployedContractAddress + )[0].args[0]; + + //get all addresses and verify nonces are updated + + }); + + //WIP + it.only('should not update nonces when deploying on an address with an already existing account', async function() { + //create a hollow account and send HBAR + const wallet = await createNewAccountWithBalance(ethers.parseEther('3.1')); + const snAfterCreate = await getServicesNonce(wallet.address); + const mnAfterCreate = await getMirrorNodeNonce(wallet.address); + // verify nonce of hollow account is 0 + expectNonIncrementedNonce(snAfterCreate, mnAfterCreate, 0, 0); + + //send ethers to the hollow account + const fundTx = await signers[0].sendTransaction({ + to: wallet.address, + value: Utils.tinybarToWeibarCoef // 1 tinybar + }); + await fundTx.wait(); + + expectNonIncrementedNonce(snAfterCreate, mnAfterCreate, 0, 0); + + //send ethers from the hollow account to the GENESIS account - fails + const signerFundTx = await wallet.sendTransaction({ + to: signers[0].address, + value: Utils.tinybarToWeibarCoef // 1 tinybar + }); + await signerFundTx.wait(); + + //verify new account nonce is 1 + const snAfterSendTx = await getServicesNonce(wallet.address); + const mnAfterSendTx = await getMirrorNodeNonce(wallet.address); + + expectIncrementedNonce(snAfterCreate, mnAfterCreate, snAfterSendTx, mnAfterSendTx); + + //delete the account + const deleteTx = await Utils.deleteAccount(wallet); + await deleteTx.wait(); + + //send HBAR to the same address and verify nonce is 0 + fundTx = await signers[0].sendTransaction({ + to: wallet.address, + value: Utils.tinybarToWeibarCoef // 1 tinybar + }); + await fundTx.wait(); + + //verify nonce is 0 + const snAfterNewCreate = await getServicesNonce(wallet.address); + const mnAfterNewCreate = await getMirrorNodeNonce(wallet.address); + + expectNonIncrementedNonce(snAfterNewCreate, mnAfterNewCreate, 0, 0); + }); + + it('should update all nonces when chained deploys of contracts', async function() { + + }); }); diff --git a/test/hts-precompile/utils.js b/test/hts-precompile/utils.js index d660b3d4c..2d3401ed7 100644 --- a/test/hts-precompile/utils.js +++ b/test/hts-precompile/utils.js @@ -32,6 +32,9 @@ const { TokenId, TokenUpdateTransaction, TokenAssociateTransaction, + ContractInfoQuery, + AccountDeleteTransaction, + Wallet } = require('@hashgraph/sdk'); const Constants = require('../constants'); @@ -525,6 +528,11 @@ class Utils { return accountInfo.accountId.toString(); } + static async getContractInfo(evmAddress, client){ + const query = new ContractInfoQuery().setContractId(evmAddress); + return await query.execute(client); + } + static async getAccountInfo(evmAddress, client) { const query = new AccountInfoQuery().setAccountId( AccountId.fromEvmAddress(0, 0, evmAddress) @@ -533,6 +541,25 @@ class Utils { return await query.execute(client); } + static async deleteAccount(account) { + let accountDeleteTransaction = await new AccountDeleteTransaction() + .setAccountId(account.address) + .setTransferAccountId(account.address) + .freezeWithSigner(account); + await accountDeleteTransaction.sign(clientSigner0); + await accountDeleteTransaction.sign( + pkSigners[0] + ); + accountDeleteTransaction = await accountDeleteTransaction.signWithSigner( + account + ); + + const r = await accountDeleteTransaction.executeWithSigner(account); + + console.log(await r.getReceiptWithSigner(account)); + } + + static getSignerCompressedPublicKey( index = 0, asBuffer = true, From 2361992b94528609a96c370e95a7adbd5d68beab Mon Sep 17 00:00:00 2001 From: Anastasia Kovaliova Date: Fri, 1 Mar 2024 13:03:51 +0200 Subject: [PATCH 02/18] add more tests for nonce discrepancies Signed-off-by: Anastasia Kovaliova --- .../ChainedContracts.json | 55 ++++++++++++ .../Deploys1Contract.json | 55 ++++++++++++ .../ChainedContracts.sol/EmptyContract.json | 42 ++++++++++ .../discrepancies/nonce/ChainedContracts.sol | 39 +++++++++ test/constants.js | 6 +- test/discrepancies/Nonce.js | 84 +++++++++++++------ test/hts-precompile/utils.js | 34 ++++---- 7 files changed, 270 insertions(+), 45 deletions(-) create mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json create mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json create mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json create mode 100644 contracts/discrepancies/nonce/ChainedContracts.sol diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json new file mode 100644 index 000000000..e8e3a833e --- /dev/null +++ b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json @@ -0,0 +1,55 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "ChainedContracts", + "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract2Address", + "type": "event" + }, + { + "inputs": [], + "name": "childContract", + "outputs": [ + { + "internalType": "contract Deploys1Contract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527f4c7e6c30855cecc78c59c5d5000ada13e03c0ae4149c9855ac07f3c40aef8ac89060200160405180910390a16100b1565b6102678061016c83390190565b60ad806100bf6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220e4a385d8ee6ca6fe4ce8426ac5240bc6d7fa7b35bf18cf58b3887c04712ad99564736f6c63430008140033608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea26469706673582212201f6d565d5866ebbed94f191c1cfd874c4cacafa8b635efcfab5726cdb580db0664736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220e4a385d8ee6ca6fe4ce8426ac5240bc6d7fa7b35bf18cf58b3887c04712ad99564736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json new file mode 100644 index 000000000..588e3476d --- /dev/null +++ b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json @@ -0,0 +1,55 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "Deploys1Contract", + "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract1Address", + "type": "event" + }, + { + "inputs": [], + "name": "childContract", + "outputs": [ + { + "internalType": "contract EmptyContract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea26469706673582212201f6d565d5866ebbed94f191c1cfd874c4cacafa8b635efcfab5726cdb580db0664736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea26469706673582212201f6d565d5866ebbed94f191c1cfd874c4cacafa8b635efcfab5726cdb580db0664736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json new file mode 100644 index 000000000..5ad77e6f5 --- /dev/null +++ b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json @@ -0,0 +1,42 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "EmptyContract", + "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract0Address", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x6080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/contracts/discrepancies/nonce/ChainedContracts.sol b/contracts/discrepancies/nonce/ChainedContracts.sol new file mode 100644 index 000000000..484b8e69f --- /dev/null +++ b/contracts/discrepancies/nonce/ChainedContracts.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +contract EmptyContract { + address public owner; + constructor(){ + emit DeployedContract0Address(address(this)); + } + + event DeployedContract0Address(address); +} + +contract Deploys1Contract { + address public owner; + EmptyContract public childContract; + + constructor() { + owner = msg.sender; + childContract = new EmptyContract(); + emit DeployedContract1Address(address(this)); + } + + event DeployedContract1Address(address); +} + +contract ChainedContracts { + address public owner; + Deploys1Contract public childContract; + + constructor() { + owner = msg.sender; + // Deploy Chain within ChildContract constructor + // chainContract = new ChainContract(); + childContract = new Deploys1Contract(); + emit DeployedContract2Address(address(this)); + } + + event DeployedContract2Address(address); +} diff --git a/test/constants.js b/test/constants.js index 3eb04b3dc..f45915e90 100644 --- a/test/constants.js +++ b/test/constants.js @@ -56,7 +56,10 @@ const Events = { TinyBars: 'TinyBars', TinyCents: 'TinyCents', PseudoRandomSeed: 'PseudoRandomSeed', - DeployedContractAddress: 'DeployedContractAddress' + DeployedContractAddress: 'DeployedContractAddress', + DeployedContract0Address: 'DeployedContract0Address', + DeployedContract1Address: 'DeployedContract1Address', + DeployedContract2Address: 'DeployedContract2Address' }; const Path = { @@ -193,6 +196,7 @@ const Contract = { Purchase: 'Purchase', InternalCallee: 'InternalCallee', InternalCaller: 'InternalCaller', + ChainedContracts: 'ChainedContracts', EthNativePrecompileCaller: 'EthNativePrecompileCaller', AtomicHTS: 'AtomicHTS', }; diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index 0fecb101d..2ed9f1422 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -24,12 +24,14 @@ const Utils = require("../hts-precompile/utils"); const TestUtils = require("../utils"); const {expect} = require('chai'); const {ethers} = require('hardhat'); +const { ContractId } = require('@hashgraph/sdk'); describe('@discrepancies - Nonce Test Suite', async () => { let signers; let sdkClient; let internalCalleeContract; let internalCallerContract; + let chainedContracts let tooLowGasPrice; let enoughGasPrice; let tokenCreateContract; @@ -79,10 +81,10 @@ describe('@discrepancies - Nonce Test Suite', async () => { }); async function getServicesContractNonce(evmAddress){ - try{ - const info = await Utils.getContractInfo(evmAddress, sdkClient); - return info?.ethereumNonce?.toNumber(); - }catch (e){ + try { + const info = await Utils.getAccountInfo(evmAddress, sdkClient); + return info; + } catch (e) { return null; } } @@ -459,7 +461,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { }); - //fails - cannot get correct nonce + //fails it('should update all nonces after a successful contract deploy with CREATE2 ', async function() { const snBefore = await getServicesNonce(signers[0].address); @@ -478,7 +480,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { //get the nonce of the intermediary contract const contractFactorySnAfter = await getServicesContractNonce(internalCalleeContract.target); - const contractFactoryMnAfter = await getServicesContractNonce(internalCalleeContract.target); + const contractFactoryMnAfter = await getMirrorNodeNonce(internalCalleeContract.target); //After successful deploy verify that the nonces of the factory contract and the tx signer are updated expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); @@ -502,25 +504,15 @@ describe('@discrepancies - Nonce Test Suite', async () => { }); - //WIP - it.only('should not update nonces when deploying on an address with an already existing account', async function() { - //create a hollow account and send HBAR + it('should not update nonces when deploying on an address with an already existing account', async function() { + //create a hollow account and send tokens const wallet = await createNewAccountWithBalance(ethers.parseEther('3.1')); const snAfterCreate = await getServicesNonce(wallet.address); const mnAfterCreate = await getMirrorNodeNonce(wallet.address); - // verify nonce of hollow account is 0 - expectNonIncrementedNonce(snAfterCreate, mnAfterCreate, 0, 0); - - //send ethers to the hollow account - const fundTx = await signers[0].sendTransaction({ - to: wallet.address, - value: Utils.tinybarToWeibarCoef // 1 tinybar - }); - await fundTx.wait(); - + // verify nonce of hollow account after token received is 0 expectNonIncrementedNonce(snAfterCreate, mnAfterCreate, 0, 0); - //send ethers from the hollow account to the GENESIS account - fails + //send ethers from the hollow account to the GENESIS account const signerFundTx = await wallet.sendTransaction({ to: signers[0].address, value: Utils.tinybarToWeibarCoef // 1 tinybar @@ -534,15 +526,15 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snAfterCreate, mnAfterCreate, snAfterSendTx, mnAfterSendTx); //delete the account - const deleteTx = await Utils.deleteAccount(wallet); - await deleteTx.wait(); + const info = await Utils.getAccountInfo(wallet.address, sdkClient); + const deleteTx = await Utils.deleteAccount(wallet,sdkClient, info.accountId); - //send HBAR to the same address and verify nonce is 0 - fundTx = await signers[0].sendTransaction({ + //send tokens to the same address and verify nonce is 0 + const fundTx2 = await signers[0].sendTransaction({ to: wallet.address, value: Utils.tinybarToWeibarCoef // 1 tinybar }); - await fundTx.wait(); + await fundTx2.wait(); //verify nonce is 0 const snAfterNewCreate = await getServicesNonce(wallet.address); @@ -551,7 +543,45 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snAfterNewCreate, mnAfterNewCreate, 0, 0); }); - it('should update all nonces when chained deploys of contracts', async function() { - + it.only('should update all nonces when chained deploys of contracts', async function() { + //deploys contract A which deploys contract B which deploys contract C + //nonces of signer, contract A and contract B should increment + //nonce of contract C should be 0 + const snBefore = await getServicesNonce(signers[0].address); + const mnBefore = await getMirrorNodeNonce(signers[0].address); + + //deploy contract A which will deploy Contract B which will deploy Contract C + const chainedContractsFactory = await ethers.getContractFactory(Constants.Contract.ChainedContracts); + const chainedContracts = await chainedContractsFactory.deploy({gasLimit: 5_000_000}); + const receipt = await chainedContracts.deploymentTransaction().wait(); + + console.log(receipt.logs); + + //get the 3 contracts addresses + const innerContract = receipt.logs[0].address; + const intermediaryContract = receipt.logs[1].address; + const outerContract = receipt.logs[2].address; + + //get the 3 contracts nonces + const servicesInnerContractNonce = await Utils.getContractInfo(innerContract, sdkClient); + const mirrorNodeInnerContractNonce = await getMirrorNodeNonce(innerContract); + + const servicesIntermediaryContractContractNonce = await getServicesContractNonce(intermediaryContract.target); + const mirrorNodeIntermediaryContractNonce = await getMirrorNodeNonce(intermediaryContract.target); + + const servicesOuterContractNonce = await getServicesContractNonce(outerContract.target); + const mirrorNodeOuterContractNonce = await getMirrorNodeNonce(outerContract.target); + + //verify signer nonces have updated correctly + const snAfter = await getServicesNonce(signers[0].address); + const mnAfter = await getMirrorNodeNonce(signers[0].address); + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + + //verify contract nonces have updated + expectIncrementedNonce(0, 0, servicesIntermediaryContractContractNonce, mirrorNodeIntermediaryContractNonce); + expectIncrementedNonce(0, 0, servicesOuterContractNonce, mirrorNodeOuterContractNonce); + + //verify nonce of the inner most contract is 0 + expectNonIncrementedNonce(0, 0, servicesInnerContractNonce, mirrorNodeInnerContractNonce); }); }); diff --git a/test/hts-precompile/utils.js b/test/hts-precompile/utils.js index 2d3401ed7..d17210e5d 100644 --- a/test/hts-precompile/utils.js +++ b/test/hts-precompile/utils.js @@ -34,7 +34,9 @@ const { TokenAssociateTransaction, ContractInfoQuery, AccountDeleteTransaction, - Wallet + Wallet, + ContractCallQuery, + ContractNonceInfo } = require('@hashgraph/sdk'); const Constants = require('../constants'); @@ -529,7 +531,8 @@ class Utils { } static async getContractInfo(evmAddress, client){ - const query = new ContractInfoQuery().setContractId(evmAddress); + const query = new ContractInfoQuery().setContractId(ContractId.fromEvmAddress(0,0,evmAddress)); + return await query.execute(client); } @@ -541,22 +544,19 @@ class Utils { return await query.execute(client); } - static async deleteAccount(account) { - let accountDeleteTransaction = await new AccountDeleteTransaction() - .setAccountId(account.address) - .setTransferAccountId(account.address) - .freezeWithSigner(account); - await accountDeleteTransaction.sign(clientSigner0); - await accountDeleteTransaction.sign( - pkSigners[0] - ); - accountDeleteTransaction = await accountDeleteTransaction.signWithSigner( - account - ); - - const r = await accountDeleteTransaction.executeWithSigner(account); + static async deleteAccount(account, signer, accountId) { - console.log(await r.getReceiptWithSigner(account)); + console.log(accountId); + let accountDeleteTransaction = await new AccountDeleteTransaction() + .setAccountId(accountId) + .setTransferAccountId(signer.getOperator().accountId); + + await accountDeleteTransaction + .freezeWith(signer) + .sign(PrivateKey.fromStringECDSA(account.signingKey.privateKey)); + + const r = await accountDeleteTransaction.execute(signer); + console.log(await r.getReceipt(signer)); } From 2b850df0c79a75c0d641503ad7c0539f2cd2bc79 Mon Sep 17 00:00:00 2001 From: Anastasia Kovaliova Date: Mon, 11 Mar 2024 12:40:11 +0200 Subject: [PATCH 03/18] add more contract functions Signed-off-by: Anastasia Kovaliova --- .../ChainedContracts.json | 4 +- .../Deploys1Contract.json | 4 +- .../Deploys2Contracts.json | 68 +++++++++++++++++++ .../ChainedContracts.sol/EmptyContract.json | 4 +- .../InternalCallee.sol/InternalCallee.json | 17 ++++- .../nonce/InternalCallee.sol/Sample.json | 4 +- .../discrepancies/nonce/ChainedContracts.sol | 17 +++++ .../discrepancies/nonce/InternalCallee.sol | 4 ++ test/constants.js | 4 +- test/discrepancies/Nonce.js | 36 +++++++++- 10 files changed, 149 insertions(+), 13 deletions(-) create mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json index e8e3a833e..596c04f3e 100644 --- a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json +++ b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json @@ -48,8 +48,8 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527f4c7e6c30855cecc78c59c5d5000ada13e03c0ae4149c9855ac07f3c40aef8ac89060200160405180910390a16100b1565b6102678061016c83390190565b60ad806100bf6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220e4a385d8ee6ca6fe4ce8426ac5240bc6d7fa7b35bf18cf58b3887c04712ad99564736f6c63430008140033608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea26469706673582212201f6d565d5866ebbed94f191c1cfd874c4cacafa8b635efcfab5726cdb580db0664736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220e4a385d8ee6ca6fe4ce8426ac5240bc6d7fa7b35bf18cf58b3887c04712ad99564736f6c63430008140033", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527f4c7e6c30855cecc78c59c5d5000ada13e03c0ae4149c9855ac07f3c40aef8ac89060200160405180910390a16100b1565b6102678061016c83390190565b60ad806100bf6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220b3f628ab7815acfaab1491937260ed0ced21715877d191dc2a0fdfdad895139664736f6c63430008140033608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220b3f628ab7815acfaab1491937260ed0ced21715877d191dc2a0fdfdad895139664736f6c63430008140033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json index 588e3476d..59862a828 100644 --- a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json +++ b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json @@ -48,8 +48,8 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea26469706673582212201f6d565d5866ebbed94f191c1cfd874c4cacafa8b635efcfab5726cdb580db0664736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea26469706673582212201f6d565d5866ebbed94f191c1cfd874c4cacafa8b635efcfab5726cdb580db0664736f6c63430008140033", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c63430008140033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json new file mode 100644 index 000000000..6960aefeb --- /dev/null +++ b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json @@ -0,0 +1,68 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "Deploys2Contracts", + "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "Deploys2ContractsAddress", + "type": "event" + }, + { + "inputs": [], + "name": "childContract1", + "outputs": [ + { + "internalType": "contract Deploys1Contract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "childContract2", + "outputs": [ + { + "internalType": "contract EmptyContract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100ed565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b0392909216919091179055604051610078906100fa565b604051809103906000f080158015610094573d6000803e3d6000fd5b50600280546001600160a01b0319166001600160a01b03929092169190911790556040513081527f98e2bce055dec4551a096b4ba166a6deb11c494ce808f67b4b0d2abbbc87be4a9060200160405180910390a1610106565b610267806101dd83390190565b60fc8061044483390190565b60c9806101146000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80638da5cb5b146041578063e30d414814606f578063f842e88b146081575b600080fd5b6000546053906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6002546053906001600160a01b031681565b6001546053906001600160a01b03168156fea2646970667358221220248c8226a7fe9e589d889f2ca3ec87e3ab204f9845a53bb91cdbc384d610d68164736f6c63430008140033608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b5060043610603c5760003560e01c80638da5cb5b146041578063e30d414814606f578063f842e88b146081575b600080fd5b6000546053906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6002546053906001600160a01b031681565b6001546053906001600160a01b03168156fea2646970667358221220248c8226a7fe9e589d889f2ca3ec87e3ab204f9845a53bb91cdbc384d610d68164736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json index 5ad77e6f5..6f76c68b5 100644 --- a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json +++ b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json @@ -35,8 +35,8 @@ "type": "function" } ], - "bytecode": "0x6080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea2646970667358221220dabee602efff72ba238f8e12f1129809d7b6d4fb5cb40cba4103dfc1dafc053a64736f6c63430008140033", + "bytecode": "0x6080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json index 6b1a6d5e8..558ecc405 100644 --- a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json +++ b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json @@ -61,6 +61,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_addr", + "type": "address" + } + ], + "name": "internalTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "revertWithRevertReason", @@ -114,8 +127,8 @@ "type": "function" } ], - "bytecode": "0x60806040526000805534801561001457600080fd5b506103b4806100246000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063b1dd8b811161005b578063b1dd8b81146100e0578063b3943ef8146100f5578063cfc72007146100fd578063ff489d311461011057600080fd5b806311f95f6f146100825780633a32b5491461009f5780638b2db1a8146100b5575b600080fd5b61008a610118565b60405190151581526020015b60405180910390f35b6100a7610156565b604051908152602001610096565b6100c86100c3366004610287565b610170565b6040516001600160a01b039091168152602001610096565b6100f36100ee3660046102a0565b6101e9565b005b6100c861023f565b6100f361010b3660046102a0565b61026f565b61008a600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b60008060008154610166906102d0565b9182905550919050565b6000808260001b6040516101839061027b565b8190604051809103906000f59050801580156101a3573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b5050505050565b600060405161024d9061027b565b604051809103906000f080158015610269573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806102f883390190565b60006020828403121561029957600080fd5b5035919050565b6000602082840312156102b257600080fd5b81356001600160a01b03811681146102c957600080fd5b9392505050565b6000600182016102f057634e487b7160e01b600052601160045260246000fd5b506001019056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033a26469706673582212204b22adf77c8dd46d093f9ab8326be65ecc943a831917b7d4623eb5385feee33b64736f6c63430008140033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c8063b1dd8b811161005b578063b1dd8b81146100e0578063b3943ef8146100f5578063cfc72007146100fd578063ff489d311461011057600080fd5b806311f95f6f146100825780633a32b5491461009f5780638b2db1a8146100b5575b600080fd5b61008a610118565b60405190151581526020015b60405180910390f35b6100a7610156565b604051908152602001610096565b6100c86100c3366004610287565b610170565b6040516001600160a01b039091168152602001610096565b6100f36100ee3660046102a0565b6101e9565b005b6100c861023f565b6100f361010b3660046102a0565b61026f565b61008a600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b60008060008154610166906102d0565b9182905550919050565b6000808260001b6040516101839061027b565b8190604051809103906000f59050801580156101a3573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b5050505050565b600060405161024d9061027b565b604051809103906000f080158015610269573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806102f883390190565b60006020828403121561029957600080fd5b5035919050565b6000602082840312156102b257600080fd5b81356001600160a01b03811681146102c957600080fd5b9392505050565b6000600182016102f057634e487b7160e01b600052601160045260246000fd5b506001019056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033a26469706673582212204b22adf77c8dd46d093f9ab8326be65ecc943a831917b7d4623eb5385feee33b64736f6c63430008140033", + "bytecode": "0x60806040526000805534801561001457600080fd5b5061049b806100246000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b1dd8b811161005b578063b1dd8b8114610100578063b3943ef814610113578063cfc720071461011b578063ff489d311461012e57600080fd5b806311f95f6f1461008d5780633a32b549146100aa5780638b2db1a8146100c057806394debf89146100eb575b600080fd5b610095610136565b60405190151581526020015b60405180910390f35b6100b2610174565b6040519081526020016100a1565b6100d36100ce36600461033f565b61018e565b6040516001600160a01b0390911681526020016100a1565b6100fe6100f9366004610358565b610207565b005b6100fe61010e366004610358565b6102a1565b6100d36102f7565b6100fe610129366004610358565b610327565b610095600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b6000806000815461018490610388565b9182905550919050565b6000808260001b6040516101a190610333565b8190604051809103906000f59050801580156101c1573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1662d5ae9360e51b17905290516001600160a01b03831691610259916103af565b6000604051808303816000865af19150503d8060008114610296576040519150601f19603f3d011682016040523d82523d6000602084013e61029b565b606091505b50505050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156102dc57600080fd5b505af11580156102f0573d6000803e3d6000fd5b5050505050565b600060405161030590610333565b604051809103906000f080158015610321573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806103df83390190565b60006020828403121561035157600080fd5b5035919050565b60006020828403121561036a57600080fd5b81356001600160a01b038116811461038157600080fd5b9392505050565b6000600182016103a857634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825160005b818110156103d057602081860181015185830152016103b6565b50600092019182525091905056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033a2646970667358221220b1c68401b1145b727c6c7bbdb2976a30edb741ed3f2be5cc9293edeeb5dce83e64736f6c63430008140033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063b1dd8b811161005b578063b1dd8b8114610100578063b3943ef814610113578063cfc720071461011b578063ff489d311461012e57600080fd5b806311f95f6f1461008d5780633a32b549146100aa5780638b2db1a8146100c057806394debf89146100eb575b600080fd5b610095610136565b60405190151581526020015b60405180910390f35b6100b2610174565b6040519081526020016100a1565b6100d36100ce36600461033f565b61018e565b6040516001600160a01b0390911681526020016100a1565b6100fe6100f9366004610358565b610207565b005b6100fe61010e366004610358565b6102a1565b6100d36102f7565b6100fe610129366004610358565b610327565b610095600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b6000806000815461018490610388565b9182905550919050565b6000808260001b6040516101a190610333565b8190604051809103906000f59050801580156101c1573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1662d5ae9360e51b17905290516001600160a01b03831691610259916103af565b6000604051808303816000865af19150503d8060008114610296576040519150601f19603f3d011682016040523d82523d6000602084013e61029b565b606091505b50505050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156102dc57600080fd5b505af11580156102f0573d6000803e3d6000fd5b5050505050565b600060405161030590610333565b604051809103906000f080158015610321573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806103df83390190565b60006020828403121561035157600080fd5b5035919050565b60006020828403121561036a57600080fd5b81356001600160a01b038116811461038157600080fd5b9392505050565b6000600182016103a857634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825160005b818110156103d057602081860181015185830152016103b6565b50600092019182525091905056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033a2646970667358221220b1c68401b1145b727c6c7bbdb2976a30edb741ed3f2be5cc9293edeeb5dce83e64736f6c63430008140033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json index dcf09b71c..255ed5434 100644 --- a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json +++ b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json @@ -11,8 +11,8 @@ "type": "function" } ], - "bytecode": "0x6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea26469706673582212202d9c344804fc42fd5ac85fda39baf93c403cfc01b71b8aedc46a82d6f735f07b64736f6c63430008140033", + "bytecode": "0x6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/contracts/discrepancies/nonce/ChainedContracts.sol b/contracts/discrepancies/nonce/ChainedContracts.sol index 484b8e69f..5e7276dc7 100644 --- a/contracts/discrepancies/nonce/ChainedContracts.sol +++ b/contracts/discrepancies/nonce/ChainedContracts.sol @@ -37,3 +37,20 @@ contract ChainedContracts { event DeployedContract2Address(address); } + +contract Deploys2Contracts { + address public owner; + Deploys1Contract public childContract1; + EmptyContract public childContract2; + + constructor() { + owner = msg.sender; + // Deploy Chain within ChildContract constructor + // chainContract = new ChainContract(); + childContract1 = new Deploys1Contract(); + childContract2 = new EmptyContract(); + emit Deploys2ContractsAddress(address(this)); + } + + event Deploys2ContractsAddress(address); +} diff --git a/contracts/discrepancies/nonce/InternalCallee.sol b/contracts/discrepancies/nonce/InternalCallee.sol index 719c7e1cc..66d1eafbb 100644 --- a/contracts/discrepancies/nonce/InternalCallee.sol +++ b/contracts/discrepancies/nonce/InternalCallee.sol @@ -37,6 +37,10 @@ contract InternalCallee { Sample(sampleAddress).selfdestruct(); } + function internalTransfer(address payable _addr) external { + _addr.call(abi.encodeWithSignature("transferTo()")); + } + event DeployedContractAddress(address); function deployViaCreate2(uint256 _salt) external returns (address) { diff --git a/test/constants.js b/test/constants.js index f45915e90..c86fb88f6 100644 --- a/test/constants.js +++ b/test/constants.js @@ -59,7 +59,8 @@ const Events = { DeployedContractAddress: 'DeployedContractAddress', DeployedContract0Address: 'DeployedContract0Address', DeployedContract1Address: 'DeployedContract1Address', - DeployedContract2Address: 'DeployedContract2Address' + DeployedContract2Address: 'DeployedContract2Address', + Deploys2ContractsAddress: 'Deploys2ContractsAddress' }; const Path = { @@ -199,6 +200,7 @@ const Contract = { ChainedContracts: 'ChainedContracts', EthNativePrecompileCaller: 'EthNativePrecompileCaller', AtomicHTS: 'AtomicHTS', + Deploys2Contracts: 'Deploys2Contracts' }; const CALL_EXCEPTION = 'CALL_EXCEPTION'; diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index 2ed9f1422..b398f9383 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -496,7 +496,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const redeployTx = await internalCalleeContract.deployViaCreate2(1); const redeployTxReceipt = await firstTx.wait(); - const redeployedTempContractAddress = txReceipt.logs.filter( + const redeployedTempContractAddress = redeployTxReceipt.logs.filter( (e) => e.fragment.name === Constants.Events.DeployedContractAddress )[0].args[0]; @@ -543,7 +543,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snAfterNewCreate, mnAfterNewCreate, 0, 0); }); - it.only('should update all nonces when chained deploys of contracts', async function() { + //should fix the get contract nonce function - waiting for SDKs + it('should update all nonces when chained deploys of contracts', async function() { //deploys contract A which deploys contract B which deploys contract C //nonces of signer, contract A and contract B should increment //nonce of contract C should be 0 @@ -584,4 +585,35 @@ describe('@discrepancies - Nonce Test Suite', async () => { //verify nonce of the inner most contract is 0 expectNonIncrementedNonce(0, 0, servicesInnerContractNonce, mirrorNodeInnerContractNonce); }); + + //need to update the get contract nonce - waiting for SDK + it('should update contract nonce for each deployed contract', async function() { + //deploys contract A which deploys contracts B and C + //nonce of signer should be 1 + //nonce of contract A should be 2 + const snBefore = await getServicesNonce(signers[0].address); + const mnBefore = await getMirrorNodeNonce(signers[0].address); + + //deploy contract A which will deploy Contract B and C + const Deploys2ContractsFactory = await ethers.getContractFactory(Constants.Contract.Deploys2Contracts); + const deploys2Contracts = await Deploys2ContractsFactory.deploy({gasLimit: 5_000_000}); + const receipt = await deploys2Contracts.deploymentTransaction().wait(); + + const deploys2ContractsAddress = receipt.logs.filter( + (e) => e.fragment.name === Constants.Events.Deploys2ContractsAddress + )[0].args[0]; + + //get contract nonce after deployment + const sContractNonce = await getServicesContractNonce(deploys2ContractsAddress); + const mContractNonce = await getMirrorNodeNonce(deploys2ContractsAddress); + + //verify signer nonces have updated correctly + const snAfter = await getServicesNonce(signers[0].address); + const mnAfter = await getMirrorNodeNonce(signers[0].address); + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + + //verify contract nonce have updated 2 times + expect(sContractNonce).to.equal(2); + expect(mContractNonce).to.equal(2); + }); }); From c48e49652ffc21e0426e3465f115e56b5bfda1e9 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 13 Mar 2024 17:12:57 +0200 Subject: [PATCH 04/18] - added additional tests for checking the nonce - added and adapted internalTransfer function in internalCallee contract - skipped the blocked tests due to some issues Signed-off-by: Nikolay Nikolov --- .../InternalCallee.sol/InternalCallee.json | 58 +++ .../discrepancies/nonce/InternalCallee.sol | 41 +- test/discrepancies/Nonce.js | 461 +++++++++++++++--- 3 files changed, 472 insertions(+), 88 deletions(-) diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json index 3c45eed0e..66c11c40f 100644 --- a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json +++ b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json @@ -1,4 +1,36 @@ [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContractAddress", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_salt", + "type": "uint256" + } + ], + "name": "deployViaCreate2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "externalFunction", @@ -25,6 +57,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_addr", + "type": "address" + } + ], + "name": "internalTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "revertWithRevertReason", @@ -63,5 +108,18 @@ "outputs": [], "stateMutability": "nonpayable", "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "sampleAddress", + "type": "address" + } + ], + "name": "selfdestructSample", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" } ] diff --git a/contracts/discrepancies/nonce/InternalCallee.sol b/contracts/discrepancies/nonce/InternalCallee.sol index 66d1eafbb..b6d97a065 100644 --- a/contracts/discrepancies/nonce/InternalCallee.sol +++ b/contracts/discrepancies/nonce/InternalCallee.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.0; contract Sample { - function selfdestruct() external { - selfdestruct(payable(msg.sender)); - } + function selfdestruct() external { + selfdestruct(payable(msg.sender)); + } } contract InternalCallee { - uint calledTimes = 0; + uint calledTimes = 0; - function factorySample() external returns (address) { - return address(new Sample()); - } + function factorySample() external returns (address) { + return address(new Sample()); + } function externalFunction() external returns (uint) { // mutate state to maintain non-view function status @@ -33,22 +33,21 @@ contract InternalCallee { selfdestruct(_addr); } - function selfdestructSample(address payable sampleAddress) external { - Sample(sampleAddress).selfdestruct(); - } - - function internalTransfer(address payable _addr) external { - _addr.call(abi.encodeWithSignature("transferTo()")); - } + function selfdestructSample(address payable sampleAddress) external { + Sample(sampleAddress).selfdestruct(); + } - event DeployedContractAddress(address); + function internalTransfer(address payable _contract, address payable _receiver) payable external { + (bool success,) = _contract.call(abi.encodeWithSignature("transferTo(address)", _receiver)); + require(success, "Function call failed"); + } - function deployViaCreate2(uint256 _salt) external returns (address) { - Sample temp = new Sample{salt: bytes32(_salt)}(); - emit DeployedContractAddress(address(temp)); - - return address(temp); - } + event DeployedContractAddress(address); + function deployViaCreate2(uint256 _salt) external returns (address) { + Sample temp = new Sample{salt: bytes32(_salt)}(); + emit DeployedContractAddress(address(temp)); + return address(temp); + } } diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index b398f9383..2c3e51b82 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -22,11 +22,11 @@ const { utils } = require('elliptic'); const Constants = require('../constants'); const Utils = require("../hts-precompile/utils"); const TestUtils = require("../utils"); -const {expect} = require('chai'); -const {ethers} = require('hardhat'); +const { expect } = require('chai'); +const { ethers } = require('hardhat'); const { ContractId } = require('@hashgraph/sdk'); -describe('@discrepancies - Nonce Test Suite', async () => { +describe.only('@discrepancies - Nonce Test Suite', async () => { let signers; let sdkClient; let internalCalleeContract; @@ -44,7 +44,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { signers = await ethers.getSigners(); sdkClient = await Utils.createSDKClient(); - const {gasPrice} = (await ethers.provider.getFeeData()); + const { gasPrice } = (await ethers.provider.getFeeData()); tooLowGasPrice = gasPrice - BigInt(1); enoughGasPrice = gasPrice + BigInt(1); @@ -70,19 +70,19 @@ describe('@discrepancies - Nonce Test Suite', async () => { await tokenCreateContract.getAddress(), await tokenTransferContract.getAddress(), ]); - // await Utils.associateToken( - // tokenCreateContract, - // tokenAddress, - // Constants.Contract.TokenCreateContract - // ); - // await Utils.grantTokenKyc(tokenCreateContract, tokenAddress); + await Utils.associateToken( + tokenCreateContract, + tokenAddress, + Constants.Contract.TokenCreateContract + ); + await Utils.grantTokenKyc(tokenCreateContract, tokenAddress); }); - async function getServicesContractNonce(evmAddress){ + async function getServicesContractNonce(evmAddress) { try { - const info = await Utils.getAccountInfo(evmAddress, sdkClient); + const info = await Utils.getContractInfo(evmAddress, sdkClient); return info; } catch (e) { return null; @@ -134,9 +134,9 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({ - gasLimit: 21_001 - }) + internalCalleeContract.externalFunction({ + gasLimit: 21_001 + }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -150,10 +150,10 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({ - gasPrice: tooLowGasPrice, - maxGasAllowance: 0 - }) + internalCalleeContract.externalFunction({ + gasPrice: tooLowGasPrice, + maxGasAllowance: 0 + }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -170,9 +170,9 @@ describe('@discrepancies - Nonce Test Suite', async () => { const internalCalleeContractWithNewSigner = internalCalleeContract.connect(newAccountWithInsufficientBalance); await Utils.expectToFail( - internalCalleeContractWithNewSigner.externalFunction({ - gasPrice: tooLowGasPrice - }) + internalCalleeContractWithNewSigner.externalFunction({ + gasPrice: tooLowGasPrice + }) ); const snAfter = await getServicesNonce(newAccountWithInsufficientBalance.address); @@ -186,10 +186,10 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({ - gasPrice: tooLowGasPrice, - maxGasAllowance: 0 - }) + internalCalleeContract.externalFunction({ + gasPrice: tooLowGasPrice, + maxGasAllowance: 0 + }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -206,9 +206,9 @@ describe('@discrepancies - Nonce Test Suite', async () => { const internalCalleeContractWithNewSigner = internalCalleeContract.connect(newAccountWithInsufficientBalance); await Utils.expectToFail( - internalCalleeContractWithNewSigner.externalFunction({ - gasPrice: enoughGasPrice - }) + internalCalleeContractWithNewSigner.externalFunction({ + gasPrice: enoughGasPrice + }) ); const snAfter = await getServicesNonce(newAccountWithInsufficientBalance.address); @@ -225,9 +225,9 @@ describe('@discrepancies - Nonce Test Suite', async () => { const internalCalleeContractWithNewSigner = internalCalleeContract.connect(newAccountWithInsufficientBalance); await Utils.expectToFail( - internalCalleeContractWithNewSigner.externalFunction({ - value: 2 * Utils.tinybarToWeibarCoef // 2 tinybars - }) + internalCalleeContractWithNewSigner.externalFunction({ + value: 2 * Utils.tinybarToWeibarCoef // 2 tinybars + }) ); const snAfter = await getServicesNonce(newAccountWithInsufficientBalance.address); @@ -241,7 +241,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.revertWithRevertReason({gasLimit: 500_000}) + internalCalleeContract.revertWithRevertReason({ gasLimit: 500_000 }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -255,7 +255,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({gasLimit: 21_064}) + internalCalleeContract.externalFunction({ gasLimit: 21_064 }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -269,7 +269,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCallerContract.transferTo(signers[1].address, {gasLimit: 500_000}) + internalCallerContract.transferTo(signers[1].address, { gasLimit: 500_000 }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -283,7 +283,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCallerContract.transferTo('0x0000000000000000000000000000000000000002', {gasLimit: 500_000}) + internalCallerContract.transferTo('0x0000000000000000000000000000000000000002', { gasLimit: 500_000 }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -297,7 +297,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCallerContract.transferTo('0x0000000000000000000000000000000000000167', {gasLimit: 500_000}) + internalCallerContract.transferTo('0x0000000000000000000000000000000000000167', { gasLimit: 500_000 }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -310,7 +310,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); - const tx = await internalCalleeContract.externalFunction({gasLimit: 500_000}); + const tx = await internalCalleeContract.externalFunction({ gasLimit: 500_000 }); await tx.wait(); const snAfter = await getServicesNonce(signers[0].address); @@ -329,7 +329,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); - const tx = await internalCallerContract.transferTo(signers[0].address, {gasLimit: 500_000}); + const tx = await internalCallerContract.transferTo(signers[0].address, { gasLimit: 500_000 }); await tx.wait(); const snAfter = await getServicesNonce(signers[0].address); @@ -342,7 +342,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); - const tx = await internalCalleeContract.factorySample({gasLimit: 500_000}); + const tx = await internalCalleeContract.factorySample({ gasLimit: 500_000 }); await tx.wait(); const snAfter = await getServicesNonce(signers[0].address); @@ -351,7 +351,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); - it('should update nonce after successful ERC20 token call', async function() { + //NONCE-017 + it('should update nonce after successful ERC20 token call', async function () { const signers = await ethers.getSigners(); const amount = 200; @@ -380,7 +381,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }) - it('should update nonce after successful ERC721 token call', async function() { + //NONCE-017 + it('should update nonce after successful ERC721 token call', async function () { erc721Contract = await Utils.deployERC721Contract(); tokenAddress = await Utils.createNonFungibleToken( tokenCreateContract, @@ -398,14 +400,15 @@ describe('@discrepancies - Nonce Test Suite', async () => { tokenCreateContract, tokenAddress ); - + const snAfter = await getServicesNonce(signers[0].address); const mnAfter = await getMirrorNodeNonce(signers[0].address); expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); - it('should update nonce after successful call to Ethereum Precompiles', async function() { + //NONCE-018 + it('should update nonce after successful call to Ethereum Precompiles', async function () { const Contract = await ethers.getContractFactory( Constants.Contract.EthNativePrecompileCaller ); @@ -418,13 +421,13 @@ describe('@discrepancies - Nonce Test Suite', async () => { let hashedData = ethers.hashMessage(UNSIGNED_DATA); let signedData = await signer.signMessage(UNSIGNED_DATA); let signerAddr = signer.address.toLowerCase().replace('0x', ''); - + const splitSignature = ethers.Signature.from(signedData); - let v = splitSignature.v; - let r = splitSignature.r; - let s = splitSignature.s; - + let v = splitSignature.v; + let r = splitSignature.r; + let s = splitSignature.s; + const callData = `0x${TestUtils.to32ByteString(hashedData)}${TestUtils.to32ByteString( v )}${TestUtils.to32ByteString(r)}${TestUtils.to32ByteString(s)}`; @@ -435,23 +438,24 @@ describe('@discrepancies - Nonce Test Suite', async () => { const result = await contract.call0x01(callData); const rec = await result.wait(); expect(rec.logs[0].data).to.contain(signerAddr); - + const snAfter = await getServicesNonce(signers[0].address); const mnAfter = await getMirrorNodeNonce(signers[0].address); expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); - it('should update nonce after unsuccessful contract deploy with CREATE2 ', async function() { - - const firstTx = await internalCalleeContract.deployViaCreate2(1); + //NONCE-019 + it('should update nonce after unsuccessful contract deploy with CREATE2 ', async function () { + + const firstTx = await internalCalleeContract.deployViaCreate2(1); await firstTx.wait(); const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.deployViaCreate2(1, {gasLimit: 500000}) + internalCalleeContract.deployViaCreate2(1, { gasLimit: 500000 }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -461,14 +465,14 @@ describe('@discrepancies - Nonce Test Suite', async () => { }); - //fails - it('should update all nonces after a successful contract deploy with CREATE2 ', async function() { + //NONCE-020 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + xit('should update all nonces after a successful contract deploy with CREATE2 ', async function () { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); //deploy a contract with CREATE2 - const firstTx = await internalCalleeContract.deployViaCreate2(1); + const firstTx = await internalCalleeContract.deployViaCreate2(1); const txReceipt = await firstTx.wait(); const deployedTempContractAddress = txReceipt.logs.filter( @@ -477,7 +481,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { const snAfter = await getServicesNonce(signers[0].address); const mnAfter = await getMirrorNodeNonce(signers[0].address); - + //get the nonce of the intermediary contract const contractFactorySnAfter = await getServicesContractNonce(internalCalleeContract.target); const contractFactoryMnAfter = await getMirrorNodeNonce(internalCalleeContract.target); @@ -493,8 +497,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snAfter, mnAfter, snAfter + 1, mnAfter + 1); //redeploy the contract with the same salt and verify nonces are updated - const redeployTx = await internalCalleeContract.deployViaCreate2(1); - const redeployTxReceipt = await firstTx.wait(); + const redeployTx = await internalCalleeContract.deployViaCreate2(1); + const redeployTxReceipt = await redeployTx.wait(); const redeployedTempContractAddress = redeployTxReceipt.logs.filter( (e) => e.fragment.name === Constants.Events.DeployedContractAddress @@ -504,7 +508,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { }); - it('should not update nonces when deploying on an address with an already existing account', async function() { + //NONCE-021 + it('should not update nonces when deploying on an address with an already existing account', async function () { //create a hollow account and send tokens const wallet = await createNewAccountWithBalance(ethers.parseEther('3.1')); const snAfterCreate = await getServicesNonce(wallet.address); @@ -527,7 +532,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { //delete the account const info = await Utils.getAccountInfo(wallet.address, sdkClient); - const deleteTx = await Utils.deleteAccount(wallet,sdkClient, info.accountId); + const deleteTx = await Utils.deleteAccount(wallet, sdkClient, info.accountId); //send tokens to the same address and verify nonce is 0 const fundTx2 = await signers[0].sendTransaction({ @@ -543,8 +548,9 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snAfterNewCreate, mnAfterNewCreate, 0, 0); }); + //NONCE-022 //should fix the get contract nonce function - waiting for SDKs - it('should update all nonces when chained deploys of contracts', async function() { + xit('should update all nonces when chained deploys of contracts', async function () { //deploys contract A which deploys contract B which deploys contract C //nonces of signer, contract A and contract B should increment //nonce of contract C should be 0 @@ -553,7 +559,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { //deploy contract A which will deploy Contract B which will deploy Contract C const chainedContractsFactory = await ethers.getContractFactory(Constants.Contract.ChainedContracts); - const chainedContracts = await chainedContractsFactory.deploy({gasLimit: 5_000_000}); + const chainedContracts = await chainedContractsFactory.deploy({ gasLimit: 5_000_000 }); const receipt = await chainedContracts.deploymentTransaction().wait(); console.log(receipt.logs); @@ -561,7 +567,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { //get the 3 contracts addresses const innerContract = receipt.logs[0].address; const intermediaryContract = receipt.logs[1].address; - const outerContract = receipt.logs[2].address; + const outerContract = receipt.logs[2].address; //get the 3 contracts nonces const servicesInnerContractNonce = await Utils.getContractInfo(innerContract, sdkClient); @@ -586,8 +592,9 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(0, 0, servicesInnerContractNonce, mirrorNodeInnerContractNonce); }); + //NONCE-023 //need to update the get contract nonce - waiting for SDK - it('should update contract nonce for each deployed contract', async function() { + xit('should update contract nonce for each deployed contract', async function () { //deploys contract A which deploys contracts B and C //nonce of signer should be 1 //nonce of contract A should be 2 @@ -596,7 +603,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { //deploy contract A which will deploy Contract B and C const Deploys2ContractsFactory = await ethers.getContractFactory(Constants.Contract.Deploys2Contracts); - const deploys2Contracts = await Deploys2ContractsFactory.deploy({gasLimit: 5_000_000}); + const deploys2Contracts = await Deploys2ContractsFactory.deploy({ gasLimit: 5_000_000 }); const receipt = await deploys2Contracts.deploymentTransaction().wait(); const deploys2ContractsAddress = receipt.logs.filter( @@ -616,4 +623,324 @@ describe('@discrepancies - Nonce Test Suite', async () => { expect(sContractNonce).to.equal(2); expect(mContractNonce).to.equal(2); }); + + //NONCE-024 - static call covers the eth call - double check in relay docker logs - 'docker logs json-rpc-relay' + it('Nonce should NOT be incremented upon static call', async function () { + const snBeforeTransfer = await getServicesNonce(signers[0].address); + const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); + const tx = await internalCallerContract.staticCallExternalFunction.staticCall(signers[1].address) + console.log(tx); + + const snAfterTransfer = await getServicesNonce(signers[0].address); + const mnAfterTransfer = await getMirrorNodeNonce(signers[0].address); + + expectNonIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterTransfer, mnAfterTransfer) + }); + + //NONCE-026 + it('Nonce should NOT be incremented upon unsuccessfull sent with Direct call - not enough balance', async function () { + initialValue = 100000 * Utils.tinybarToWeibarCoef + initialWalletBalance = Utils.tinybarToWeibarCoef; + + const newWallet = await createNewAccountWithBalance(initialWalletBalance); + const newWallet2 = await createNewAccountWithBalance(initialWalletBalance); + console.log(newWallet.address); + console.log(newWallet2.address); + + const snWallet1Before = await getServicesNonce(newWallet.address); + const mnWallet1Before = await getMirrorNodeNonce(newWallet.address); + + await Utils.expectToFail( + newWallet.sendTransaction({ + to: newWallet2.address, + value: 20000000000, + }) + ); + + const snWAllet1After = await getServicesNonce(newWallet.address); + const mnWallet1After = await getMirrorNodeNonce(newWallet.address); + + expectNonIncrementedNonce(snWallet1Before, mnWallet1Before, snWAllet1After, mnWallet1After) + }); + + //NONCE-027 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + xit('should update nonce after unsuccessful transfer with internal call - insufficent gas', async function () { + const amount = ethers.parseEther('1'); + const fundTx = await signers[0].sendTransaction({ + to: internalCallerContract.target, + value: amount + }); + await fundTx.wait(); + + const snBeforeSigner = await getServicesNonce(signers[0].address); + const mnBeforeSigner = await getMirrorNodeNonce(signers[0].address); + + await Utils.expectToFail( + internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address, {gasLimit: 25_900}) + ); + + // const tx = await internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address, {gasLimit: 22_900}); + // const txResult = await tx.wait(); + + const snAfterSigner = await getServicesNonce(signers[0].address); + const mnAfterSigner = await getMirrorNodeNonce(signers[0].address); + expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + }); + + //NONCE-027 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + xit('should update nonce after unsuccessful transfer with internal call - insufficent amount', async function () { + // const amount = Utils.tinybarToWeibarCoef; // 1 tinybar + // const fundTx = await signers[0].sendTransaction({ + // to: internalCallerContract.target, + // value: amount + // }); + // await fundTx.wait(); + + const snBeforeSigner = await getServicesNonce(signers[0].address); + const mnBeforeSigner = await getMirrorNodeNonce(signers[0].address); + + await Utils.expectToFail( + internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address) + ); + // const tx = await internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address); + // const txResult = await tx.wait(); + + const snAfterSigner = await getServicesNonce(signers[0].address); + const mnAfterSigner = await getMirrorNodeNonce(signers[0].address); + // expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + }); + + //NONCE-028 + it('should update signer nonce upon transfer to non-existing account with enough gas limit >600K', async function () { + const amount = ethers.parseEther('1'); + const snBeforeTransfer = await getServicesNonce(signers[0].address); + const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); + + const wallet1 = ethers.Wallet.createRandom(); + const newAccTx = await signers[0].sendTransaction({ + to: wallet1.address, + value: amount, + gasLimit: 650_000, + }); + await newAccTx.wait(); + + const snAfterCreate = await getServicesNonce(signers[0].address); + const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); + }); + + //NONCE-029 - Skipped due to an issue that a hollow account can be created with a gas limit of 21001 + xit('should update signer nonce upon transfer to non-existing account with not enough gas limit <600K', async function () { + const amount = ethers.parseEther('1'); + const snBeforeTransfer = await getServicesNonce(signers[0].address); + const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); + + const wallet1 = ethers.Wallet.createRandom(); + const newAccTx = await signers[0].sendTransaction({ + to: wallet1.address, + value: amount, + gasLimit: 22_000 + }); + //await newAccTx.wait(); + console.log(await newAccTx.wait()); + + // internalCallerContract.transferTo(wallet1.address, {gasLimit: 700_000}) + + const snAfterCreate = await getServicesNonce(signers[0].address); + const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); + + + // const tx = await internalCallerContract.transferTo(signers[0].address, {gasLimit: 500_000}); + // await tx.wait(); + }); + + //NONCE-030 + it('should not update nonce upon unsuccessfull transaction due to wrong chain id', async function () { + const amount = ethers.parseEther('1'); + const wallet1 = ethers.Wallet.createRandom(); + const snBeforeTransfer = await getServicesNonce(signers[0].address); + const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); + + let code = null; + try { + const newAccTx = await signers[0].sendTransaction({ + to: wallet1.address, + value: amount, + gasLimit: 650_000, + chainId: 8n + }); + await newAccTx.wait(); + expect(true).to.eq(false); + } catch (e) { + expect(e).to.exist; + console.log(e); + if (code) { + expect(e.code).to.eq(code); + } + } + + const snAfterCreate = await getServicesNonce(signers[0].address); + const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); + + expectNonIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate) + }); + + //NONCE-031 - Type 0 + it('should update nonce upon transaction of type 0', async function () { + const amount = ethers.parseEther('1'); + const wallet1 = ethers.Wallet.createRandom(); + + const defaultTransactionFields = { + to: wallet1.address, + value: amount, + gasLimit: 650_000 + }; + + + const snBeforeTransfer = await getServicesNonce(signers[0].address); + const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); + + const newAccTx1 = await signers[0].sendTransaction({ + ...defaultTransactionFields, + type: 0, + nonce: snBeforeTransfer, + gasPrice: enoughGasPrice, + }); + await newAccTx1.wait(); + console.log('Type is: ' + newAccTx1.type); + + const snAfterCreate = await getServicesNonce(signers[0].address); + const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); + }); + + //NONCE-031 - Type 1 + it('should update nonce upon transaction of type 1', async function () { + const amount = ethers.parseEther('1'); + const wallet1 = ethers.Wallet.createRandom(); + + const defaultTransactionFields = { + to: wallet1.address, + value: amount, + gasLimit: 650_000 + }; + + + const snBeforeTransfer = await getServicesNonce(signers[0].address); + const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); + + const newAccTx1 = await signers[0].sendTransaction({ + ...defaultTransactionFields, + type: 1, + nonce: snBeforeTransfer, + gasPrice: enoughGasPrice, + accessList: [], + }); + await newAccTx1.wait(); + console.log('Type is: ' + newAccTx1.type); + + const snAfterCreate = await getServicesNonce(signers[0].address); + const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); + }); + + //NONCE-031 - Type 2 + it('should update nonce upon transaction of type 2', async function () { + const amount = ethers.parseEther('1'); + const wallet1 = ethers.Wallet.createRandom(); + + const defaultTransactionFields = { + to: wallet1.address, + value: amount, + gasLimit: 650_000 + }; + + const snBeforeTransfer = await getServicesNonce(signers[0].address); + const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); + + const newAccTx1 = await signers[0].sendTransaction({ + ...defaultTransactionFields, + type: 2, + nonce: snBeforeTransfer, + maxFeePerGas: enoughGasPrice, + maxPriorityFeePerGas: enoughGasPrice, + }); + await newAccTx1.wait(); + console.log('Type is: ' + newAccTx1.type); + + const snAfterCreate = await getServicesNonce(signers[0].address); + const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); + + expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); + }); + + //NONCE-032 + it('Hollow account that is finilized with the same transaction that should upgrade its nonce', async function () { + const amount = Utils.tinybarToWeibarCoef; + + const wallet = await createNewAccountWithBalance(ethers.parseEther('10')); + const wallet2 = ethers.Wallet.createRandom().connect(ethers.provider); + + let jsonRequest2 = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(jsonRequest2.key._key).to.equal(undefined); + + const snBeforeTransfer = await getServicesNonce(wallet.address); + const mnBeforeTransfer = await getMirrorNodeNonce(wallet.address); + + const newAccTx1 = await wallet.sendTransaction({ + to: wallet2.address, + value: amount, + gasLimit: 650_000, + }); + await newAccTx1.wait(); + + let jsonRequest3 = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(jsonRequest3.key._key).to.not.equal(undefined); + + const snAfterCreate = await getServicesNonce(wallet.address); + const mnAfterCreate = await getMirrorNodeNonce(wallet.address); + + expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); + + }); + + + //NONCE-033 + it('Hollow account that is finilized with the same transaction that should not upgrade its nonce when offered gas price and and allowance fail check ', async function () { + const amount = Utils.tinybarToWeibarCoef; + + const wallet = await createNewAccountWithBalance(ethers.parseEther('10')); + + let jsonRequest2 = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(jsonRequest2.key._key).to.equal(undefined); + + const snBeforeTransfer = await getServicesNonce(wallet.address); + console.log('snBefore = ' + snBeforeTransfer); + const mnBeforeTransfer = await getMirrorNodeNonce(wallet.address); + console.log('mnBefore = ' + mnBeforeTransfer); + + await Utils.expectToFail( + wallet.sendTransaction({ + to: signers[0].address, + value: amount, + gasPrice: tooLowGasPrice, + maxGasAllowance: 0, + gasLimit: 650_000, + }) + ); + + let jsonRequest3 = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(jsonRequest3.key._key).to.not.equal(undefined); + + const snAfterCreate = await getServicesNonce(wallet.address); + console.log('snAfter = ' + snAfterCreate); + const mnAfterCreate = await getMirrorNodeNonce(wallet.address); + console.log('mnAfter = ' + mnAfterCreate); + + expectNonIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); + + }); }); From ff7b22bf42dcea70a10c007e5f390bb5326c9520 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 13 Mar 2024 17:36:16 +0200 Subject: [PATCH 05/18] - removed unneeded console.logs, polished some tests - refactored some expected to fail function in test 030 Signed-off-by: Nikolay Nikolov --- test/discrepancies/Nonce.js | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index 2c3e51b82..cb9fddfa0 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -624,12 +624,11 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expect(mContractNonce).to.equal(2); }); - //NONCE-024 - static call covers the eth call - double check in relay docker logs - 'docker logs json-rpc-relay' + //NONCE-024 it('Nonce should NOT be incremented upon static call', async function () { const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); const tx = await internalCallerContract.staticCallExternalFunction.staticCall(signers[1].address) - console.log(tx); const snAfterTransfer = await getServicesNonce(signers[0].address); const mnAfterTransfer = await getMirrorNodeNonce(signers[0].address); @@ -644,8 +643,6 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const newWallet = await createNewAccountWithBalance(initialWalletBalance); const newWallet2 = await createNewAccountWithBalance(initialWalletBalance); - console.log(newWallet.address); - console.log(newWallet2.address); const snWallet1Before = await getServicesNonce(newWallet.address); const mnWallet1Before = await getMirrorNodeNonce(newWallet.address); @@ -762,23 +759,14 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); - let code = null; - try { - const newAccTx = await signers[0].sendTransaction({ + await Utils.expectToFail( + signers[0].sendTransaction({ to: wallet1.address, value: amount, gasLimit: 650_000, chainId: 8n - }); - await newAccTx.wait(); - expect(true).to.eq(false); - } catch (e) { - expect(e).to.exist; - console.log(e); - if (code) { - expect(e.code).to.eq(code); - } - } + }) + ); const snAfterCreate = await getServicesNonce(signers[0].address); const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); @@ -808,7 +796,6 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { gasPrice: enoughGasPrice, }); await newAccTx1.wait(); - console.log('Type is: ' + newAccTx1.type); const snAfterCreate = await getServicesNonce(signers[0].address); const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); @@ -839,7 +826,6 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { accessList: [], }); await newAccTx1.wait(); - console.log('Type is: ' + newAccTx1.type); const snAfterCreate = await getServicesNonce(signers[0].address); const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); @@ -869,7 +855,6 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { maxPriorityFeePerGas: enoughGasPrice, }); await newAccTx1.wait(); - console.log('Type is: ' + newAccTx1.type); const snAfterCreate = await getServicesNonce(signers[0].address); const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); @@ -918,9 +903,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expect(jsonRequest2.key._key).to.equal(undefined); const snBeforeTransfer = await getServicesNonce(wallet.address); - console.log('snBefore = ' + snBeforeTransfer); const mnBeforeTransfer = await getMirrorNodeNonce(wallet.address); - console.log('mnBefore = ' + mnBeforeTransfer); await Utils.expectToFail( wallet.sendTransaction({ @@ -936,9 +919,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expect(jsonRequest3.key._key).to.not.equal(undefined); const snAfterCreate = await getServicesNonce(wallet.address); - console.log('snAfter = ' + snAfterCreate); const mnAfterCreate = await getMirrorNodeNonce(wallet.address); - console.log('mnAfter = ' + mnAfterCreate); expectNonIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); From 6c4a8739d076d97780e77e761bfe7bc23b768155 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Thu, 14 Mar 2024 11:54:33 +0200 Subject: [PATCH 06/18] removed .only from the describe Signed-off-by: Nikolay Nikolov --- test/discrepancies/Nonce.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index cb9fddfa0..103ae060e 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -26,7 +26,7 @@ const { expect } = require('chai'); const { ethers } = require('hardhat'); const { ContractId } = require('@hashgraph/sdk'); -describe.only('@discrepancies - Nonce Test Suite', async () => { +describe('@discrepancies - Nonce Test Suite', async () => { let signers; let sdkClient; let internalCalleeContract; From 74649fc4c7c6703c5cbd14b3320f1ad98ced0236 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 25 Mar 2024 16:59:16 +0200 Subject: [PATCH 07/18] - applied gitignore json removal Signed-off-by: Nikolay Nikolov --- .../ChainedContracts.json | 55 ------- .../Deploys1Contract.json | 55 ------- .../Deploys2Contracts.json | 68 --------- .../ChainedContracts.sol/EmptyContract.json | 42 ------ .../InternalCallee.sol/InternalCallee.json | 134 ------------------ .../nonce/InternalCallee.sol/Sample.json | 18 --- .../account/NonExisting.sol/NonExisting.json | 117 --------------- 7 files changed, 489 deletions(-) delete mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json delete mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json delete mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json delete mode 100644 artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json delete mode 100644 artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json delete mode 100644 artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json delete mode 100644 artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json deleted file mode 100644 index 596c04f3e..000000000 --- a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "ChainedContracts", - "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", - "abi": [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract2Address", - "type": "event" - }, - { - "inputs": [], - "name": "childContract", - "outputs": [ - { - "internalType": "contract Deploys1Contract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527f4c7e6c30855cecc78c59c5d5000ada13e03c0ae4149c9855ac07f3c40aef8ac89060200160405180910390a16100b1565b6102678061016c83390190565b60ad806100bf6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220b3f628ab7815acfaab1491937260ed0ced21715877d191dc2a0fdfdad895139664736f6c63430008140033608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea2646970667358221220b3f628ab7815acfaab1491937260ed0ced21715877d191dc2a0fdfdad895139664736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json deleted file mode 100644 index 59862a828..000000000 --- a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "Deploys1Contract", - "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", - "abi": [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract1Address", - "type": "event" - }, - { - "inputs": [], - "name": "childContract", - "outputs": [ - { - "internalType": "contract EmptyContract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json deleted file mode 100644 index 6960aefeb..000000000 --- a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "Deploys2Contracts", - "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", - "abi": [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "Deploys2ContractsAddress", - "type": "event" - }, - { - "inputs": [], - "name": "childContract1", - "outputs": [ - { - "internalType": "contract Deploys1Contract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "childContract2", - "outputs": [ - { - "internalType": "contract EmptyContract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100ed565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b0392909216919091179055604051610078906100fa565b604051809103906000f080158015610094573d6000803e3d6000fd5b50600280546001600160a01b0319166001600160a01b03929092169190911790556040513081527f98e2bce055dec4551a096b4ba166a6deb11c494ce808f67b4b0d2abbbc87be4a9060200160405180910390a1610106565b610267806101dd83390190565b60fc8061044483390190565b60c9806101146000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80638da5cb5b146041578063e30d414814606f578063f842e88b146081575b600080fd5b6000546053906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6002546053906001600160a01b031681565b6001546053906001600160a01b03168156fea2646970667358221220248c8226a7fe9e589d889f2ca3ec87e3ab204f9845a53bb91cdbc384d610d68164736f6c63430008140033608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560405161002f906100a4565b604051809103906000f08015801561004b573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b03929092169190911790556040513081527ff430eff672344f7f9138982ac94eed1bf772be59937976e8b99dc487228ee5e49060200160405180910390a16100b0565b60fc8061016b83390190565b60ad806100be6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b146037578063e626223a146065575b600080fd5b6000546049906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6001546049906001600160a01b03168156fea264697066735822122000fd035255a3b46e0feb429f06f3517e261b4a31e00ec555ea2e39f39140c3ea64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c634300081400336080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b5060043610603c5760003560e01c80638da5cb5b146041578063e30d414814606f578063f842e88b146081575b600080fd5b6000546053906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6002546053906001600160a01b031681565b6001546053906001600160a01b03168156fea2646970667358221220248c8226a7fe9e589d889f2ca3ec87e3ab204f9845a53bb91cdbc384d610d68164736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} diff --git a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json b/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json deleted file mode 100644 index 6f76c68b5..000000000 --- a/artifacts/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "EmptyContract", - "sourceName": "contracts/discrepancies/nonce/ChainedContracts.sol", - "abi": [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract0Address", - "type": "event" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "bytecode": "0x6080604052348015600f57600080fd5b506040513081527fa1ef4f4713541f13c4b891a4cb3630b8d1a279770a294c2ec1774d414a57bf039060200160405180910390a160ab806100516000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c80638da5cb5b14602d575b600080fd5b600054604c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122044229adcda9ef3ffd694010a25de643654aad991d60265ad70834ad990d8861f64736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} diff --git a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json deleted file mode 100644 index 558ecc405..000000000 --- a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "InternalCallee", - "sourceName": "contracts/discrepancies/nonce/InternalCallee.sol", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContractAddress", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_salt", - "type": "uint256" - } - ], - "name": "deployViaCreate2", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "externalFunction", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "factorySample", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_addr", - "type": "address" - } - ], - "name": "internalTransfer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "revertWithRevertReason", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "revertWithoutRevertReason", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_addr", - "type": "address" - } - ], - "name": "selfdestruct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "sampleAddress", - "type": "address" - } - ], - "name": "selfdestructSample", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bytecode": "0x60806040526000805534801561001457600080fd5b5061049b806100246000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b1dd8b811161005b578063b1dd8b8114610100578063b3943ef814610113578063cfc720071461011b578063ff489d311461012e57600080fd5b806311f95f6f1461008d5780633a32b549146100aa5780638b2db1a8146100c057806394debf89146100eb575b600080fd5b610095610136565b60405190151581526020015b60405180910390f35b6100b2610174565b6040519081526020016100a1565b6100d36100ce36600461033f565b61018e565b6040516001600160a01b0390911681526020016100a1565b6100fe6100f9366004610358565b610207565b005b6100fe61010e366004610358565b6102a1565b6100d36102f7565b6100fe610129366004610358565b610327565b610095600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b6000806000815461018490610388565b9182905550919050565b6000808260001b6040516101a190610333565b8190604051809103906000f59050801580156101c1573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1662d5ae9360e51b17905290516001600160a01b03831691610259916103af565b6000604051808303816000865af19150503d8060008114610296576040519150601f19603f3d011682016040523d82523d6000602084013e61029b565b606091505b50505050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156102dc57600080fd5b505af11580156102f0573d6000803e3d6000fd5b5050505050565b600060405161030590610333565b604051809103906000f080158015610321573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806103df83390190565b60006020828403121561035157600080fd5b5035919050565b60006020828403121561036a57600080fd5b81356001600160a01b038116811461038157600080fd5b9392505050565b6000600182016103a857634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825160005b818110156103d057602081860181015185830152016103b6565b50600092019182525091905056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033a2646970667358221220b1c68401b1145b727c6c7bbdb2976a30edb741ed3f2be5cc9293edeeb5dce83e64736f6c63430008140033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063b1dd8b811161005b578063b1dd8b8114610100578063b3943ef814610113578063cfc720071461011b578063ff489d311461012e57600080fd5b806311f95f6f1461008d5780633a32b549146100aa5780638b2db1a8146100c057806394debf89146100eb575b600080fd5b610095610136565b60405190151581526020015b60405180910390f35b6100b2610174565b6040519081526020016100a1565b6100d36100ce36600461033f565b61018e565b6040516001600160a01b0390911681526020016100a1565b6100fe6100f9366004610358565b610207565b005b6100fe61010e366004610358565b6102a1565b6100d36102f7565b6100fe610129366004610358565b610327565b610095600080fd5b60405162461bcd60e51b815260206004820152600c60248201526b2932bb32b93a2932b0b9b7b760a11b604482015260009060640160405180910390fd5b6000806000815461018490610388565b9182905550919050565b6000808260001b6040516101a190610333565b8190604051809103906000f59050801580156101c1573d6000803e3d6000fd5b506040516001600160a01b03821681529091507fc224c21b52d62db941f9d178d13671404cf736b0d9183e6f2e2aaaaf75849d7b9060200160405180910390a192915050565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1662d5ae9360e51b17905290516001600160a01b03831691610259916103af565b6000604051808303816000865af19150503d8060008114610296576040519150601f19603f3d011682016040523d82523d6000602084013e61029b565b606091505b50505050565b806001600160a01b031663679d38e06040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156102dc57600080fd5b505af11580156102f0573d6000803e3d6000fd5b5050505050565b600060405161030590610333565b604051809103906000f080158015610321573d6000803e3d6000fd5b50905090565b806001600160a01b0316ff5b6087806103df83390190565b60006020828403121561035157600080fd5b5035919050565b60006020828403121561036a57600080fd5b81356001600160a01b038116811461038157600080fd5b9392505050565b6000600182016103a857634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825160005b818110156103d057602081860181015185830152016103b6565b50600092019182525091905056fe6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033a2646970667358221220b1c68401b1145b727c6c7bbdb2976a30edb741ed3f2be5cc9293edeeb5dce83e64736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} diff --git a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json b/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json deleted file mode 100644 index 255ed5434..000000000 --- a/artifacts/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "Sample", - "sourceName": "contracts/discrepancies/nonce/InternalCallee.sol", - "abi": [ - { - "inputs": [], - "name": "selfdestruct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bytecode": "0x6080604052348015600f57600080fd5b50606a80601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033", - "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063679d38e014602d575b600080fd5b603233ff5b00fea264697066735822122074e1852bac88571cffb04dab271be42f519e74147ffad45e1782e0d77cbef5fa64736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} diff --git a/artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json b/artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json deleted file mode 100644 index 547a67861..000000000 --- a/artifacts/contracts/solidity/account/NonExisting.sol/NonExisting.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "NonExisting", - "sourceName": "contracts/solidity/account/NonExisting.sol", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "nonExistingAddr", - "type": "address" - } - ], - "name": "balanceNoneExistingAddr", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "nonExistingAddr", - "type": "address" - } - ], - "name": "callOnNonExistingAccount", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "nonExistingAddr", - "type": "address" - } - ], - "name": "delegatecallOnNonExistingAccount", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "nonExistingAddr", - "type": "address" - } - ], - "name": "staticcallOnNonExistingAccount", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "bytecode": "0x608060405234801561001057600080fd5b5060405161038638038061038683398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b6102f3806100936000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806304fa55251461005c57806338750ce41461008457806370a08231146100845780637688ef3a146100ad578063ac8ff975146100c0575b600080fd5b61006f61006a36600461025e565b6100d3565b60405190151581526020015b60405180910390f35b61009f61009236600461025e565b6001600160a01b03163190565b60405190815260200161007b565b61006f6100bb36600461025e565b610162565b61006f6100ce36600461025e565b6101e0565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101169161028e565b6000604051808303816000865af19150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b606091505b5090949350505050565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101a59161028e565b600060405180830381855afa9150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916102239161028e565b600060405180830381855af49150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60006020828403121561027057600080fd5b81356001600160a01b038116811461028757600080fd5b9392505050565b6000825160005b818110156102af5760208186018101518583015201610295565b50600092019182525091905056fea26469706673582212203c6153cffa6f0bfdee9f6c3d65b45af1d2aebb38adc9b9384a2852c52f3dd2ac64736f6c63430008140033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c806304fa55251461005c57806338750ce41461008457806370a08231146100845780637688ef3a146100ad578063ac8ff975146100c0575b600080fd5b61006f61006a36600461025e565b6100d3565b60405190151581526020015b60405180910390f35b61009f61009236600461025e565b6001600160a01b03163190565b60405190815260200161007b565b61006f6100bb36600461025e565b610162565b61006f6100ce36600461025e565b6101e0565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101169161028e565b6000604051808303816000865af19150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b606091505b5090949350505050565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916101a59161028e565b600060405180830381855afa9150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60408051600481526024810182526020810180516001600160e01b0316630ee642d760e11b179052905160009182916001600160a01b038516916102239161028e565b600060405180830381855af49150503d8060008114610153576040519150601f19603f3d011682016040523d82523d6000602084013e610158565b60006020828403121561027057600080fd5b81356001600160a01b038116811461028757600080fd5b9392505050565b6000825160005b818110156102af5760208186018101518583015201610295565b50600092019182525091905056fea26469706673582212203c6153cffa6f0bfdee9f6c3d65b45af1d2aebb38adc9b9384a2852c52f3dd2ac64736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} From 169708435302a5fea56903dc3149c760cb88bf06 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 25 Mar 2024 17:32:48 +0200 Subject: [PATCH 08/18] - removed unneeded json files Signed-off-by: Nikolay Nikolov --- .../ChainedContracts.json | 46 +++++++++++++++ .../Deploys1Contract.json | 46 +++++++++++++++ .../Deploys2Contracts.json | 59 +++++++++++++++++++ .../ChainedContracts.sol/EmptyContract.json | 33 +++++++++++ .../InternalCallee.sol/InternalCallee.json | 9 ++- .../nonce/InternalCallee.sol/Sample.json | 9 +++ 6 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json new file mode 100644 index 000000000..f62daec7b --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json @@ -0,0 +1,46 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract2Address", + "type": "event" + }, + { + "inputs": [], + "name": "childContract", + "outputs": [ + { + "internalType": "contract Deploys1Contract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json new file mode 100644 index 000000000..1a0849601 --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json @@ -0,0 +1,46 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract1Address", + "type": "event" + }, + { + "inputs": [], + "name": "childContract", + "outputs": [ + { + "internalType": "contract EmptyContract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json new file mode 100644 index 000000000..87e1daac6 --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json @@ -0,0 +1,59 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "Deploys2ContractsAddress", + "type": "event" + }, + { + "inputs": [], + "name": "childContract1", + "outputs": [ + { + "internalType": "contract Deploys1Contract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "childContract2", + "outputs": [ + { + "internalType": "contract EmptyContract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json new file mode 100644 index 000000000..8c1e0dd2d --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json @@ -0,0 +1,33 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract0Address", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json index 66c11c40f..aa4ce9812 100644 --- a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json +++ b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json @@ -61,13 +61,18 @@ "inputs": [ { "internalType": "address payable", - "name": "_addr", + "name": "_contract", + "type": "address" + }, + { + "internalType": "address payable", + "name": "_receiver", "type": "address" } ], "name": "internalTransfer", "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "payable", "type": "function" }, { diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json new file mode 100644 index 000000000..462c7a1ec --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json @@ -0,0 +1,9 @@ +[ + { + "inputs": [], + "name": "selfdestruct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] From 9555c4fa92b582b871d6eb624774454510309aee Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 25 Mar 2024 17:42:02 +0200 Subject: [PATCH 09/18] Revert "- removed unneeded json files" This reverts commit 169708435302a5fea56903dc3149c760cb88bf06. --- .../ChainedContracts.json | 46 --------------- .../Deploys1Contract.json | 46 --------------- .../Deploys2Contracts.json | 59 ------------------- .../ChainedContracts.sol/EmptyContract.json | 33 ----------- .../InternalCallee.sol/InternalCallee.json | 9 +-- .../nonce/InternalCallee.sol/Sample.json | 9 --- 6 files changed, 2 insertions(+), 200 deletions(-) delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json delete mode 100644 contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json deleted file mode 100644 index f62daec7b..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract2Address", - "type": "event" - }, - { - "inputs": [], - "name": "childContract", - "outputs": [ - { - "internalType": "contract Deploys1Contract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json deleted file mode 100644 index 1a0849601..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract1Address", - "type": "event" - }, - { - "inputs": [], - "name": "childContract", - "outputs": [ - { - "internalType": "contract EmptyContract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json deleted file mode 100644 index 87e1daac6..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json +++ /dev/null @@ -1,59 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "Deploys2ContractsAddress", - "type": "event" - }, - { - "inputs": [], - "name": "childContract1", - "outputs": [ - { - "internalType": "contract Deploys1Contract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "childContract2", - "outputs": [ - { - "internalType": "contract EmptyContract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json deleted file mode 100644 index 8c1e0dd2d..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract0Address", - "type": "event" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json index aa4ce9812..66c11c40f 100644 --- a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json +++ b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json @@ -61,18 +61,13 @@ "inputs": [ { "internalType": "address payable", - "name": "_contract", - "type": "address" - }, - { - "internalType": "address payable", - "name": "_receiver", + "name": "_addr", "type": "address" } ], "name": "internalTransfer", "outputs": [], - "stateMutability": "payable", + "stateMutability": "nonpayable", "type": "function" }, { diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json deleted file mode 100644 index 462c7a1ec..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - { - "inputs": [], - "name": "selfdestruct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] From 951616bce6c4514a58c24bb1562045b16b2ea1e7 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 25 Mar 2024 17:45:29 +0200 Subject: [PATCH 10/18] - removed unneeded internalCalee json Signed-off-by: Nikolay Nikolov --- .../InternalCallee.sol/InternalCallee.json | 125 ------------------ 1 file changed, 125 deletions(-) delete mode 100644 contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json deleted file mode 100644 index 66c11c40f..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json +++ /dev/null @@ -1,125 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContractAddress", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_salt", - "type": "uint256" - } - ], - "name": "deployViaCreate2", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "externalFunction", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "factorySample", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_addr", - "type": "address" - } - ], - "name": "internalTransfer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "revertWithRevertReason", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "revertWithoutRevertReason", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_addr", - "type": "address" - } - ], - "name": "selfDestruct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "sampleAddress", - "type": "address" - } - ], - "name": "selfdestructSample", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] From 1cde0ca42d72afa51e7b3ce19829978a5c3e7097 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Tue, 26 Mar 2024 11:39:51 +0200 Subject: [PATCH 11/18] Added contracts-abi json files for the contracts Signed-off-by: Nikolay Nikolov --- .../ChainedContracts.json | 46 +++++++ .../Deploys1Contract.json | 46 +++++++ .../Deploys2Contracts.json | 59 ++++++++ .../ChainedContracts.sol/EmptyContract.json | 33 +++++ .../InternalCallee.sol/InternalCallee.json | 130 ++++++++++++++++++ .../nonce/InternalCallee.sol/Sample.json | 9 ++ 6 files changed, 323 insertions(+) create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json create mode 100644 contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json new file mode 100644 index 000000000..f62daec7b --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json @@ -0,0 +1,46 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract2Address", + "type": "event" + }, + { + "inputs": [], + "name": "childContract", + "outputs": [ + { + "internalType": "contract Deploys1Contract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json new file mode 100644 index 000000000..1a0849601 --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json @@ -0,0 +1,46 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract1Address", + "type": "event" + }, + { + "inputs": [], + "name": "childContract", + "outputs": [ + { + "internalType": "contract EmptyContract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json new file mode 100644 index 000000000..87e1daac6 --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json @@ -0,0 +1,59 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "Deploys2ContractsAddress", + "type": "event" + }, + { + "inputs": [], + "name": "childContract1", + "outputs": [ + { + "internalType": "contract Deploys1Contract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "childContract2", + "outputs": [ + { + "internalType": "contract EmptyContract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json new file mode 100644 index 000000000..8c1e0dd2d --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json @@ -0,0 +1,33 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContract0Address", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json new file mode 100644 index 000000000..aa4ce9812 --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/InternalCallee.json @@ -0,0 +1,130 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "DeployedContractAddress", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_salt", + "type": "uint256" + } + ], + "name": "deployViaCreate2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "externalFunction", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "factorySample", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_contract", + "type": "address" + }, + { + "internalType": "address payable", + "name": "_receiver", + "type": "address" + } + ], + "name": "internalTransfer", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "revertWithRevertReason", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revertWithoutRevertReason", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_addr", + "type": "address" + } + ], + "name": "selfDestruct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "sampleAddress", + "type": "address" + } + ], + "name": "selfdestructSample", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json new file mode 100644 index 000000000..462c7a1ec --- /dev/null +++ b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json @@ -0,0 +1,9 @@ +[ + { + "inputs": [], + "name": "selfdestruct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] From 7c492029eccf17d364eaaa4dd195d79fe9d591c5 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Tue, 26 Mar 2024 13:23:41 +0200 Subject: [PATCH 12/18] Renamed sefdestruct to selfDestructSample function in Sample contract Signed-off-by: Nikolay Nikolov --- .../discrepancies/nonce/InternalCallee.sol/Sample.json | 2 +- contracts/discrepancies/nonce/InternalCallee.sol | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json index 462c7a1ec..1c5829084 100644 --- a/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json +++ b/contracts-abi/contracts/discrepancies/nonce/InternalCallee.sol/Sample.json @@ -1,7 +1,7 @@ [ { "inputs": [], - "name": "selfdestruct", + "name": "selfDestructSample", "outputs": [], "stateMutability": "nonpayable", "type": "function" diff --git a/contracts/discrepancies/nonce/InternalCallee.sol b/contracts/discrepancies/nonce/InternalCallee.sol index b6d97a065..5576b52ff 100644 --- a/contracts/discrepancies/nonce/InternalCallee.sol +++ b/contracts/discrepancies/nonce/InternalCallee.sol @@ -2,7 +2,8 @@ pragma solidity ^0.8.0; contract Sample { - function selfdestruct() external { + + function selfDestructSample() external { selfdestruct(payable(msg.sender)); } } @@ -34,7 +35,7 @@ contract InternalCallee { } function selfdestructSample(address payable sampleAddress) external { - Sample(sampleAddress).selfdestruct(); + Sample(sampleAddress).selfDestructSample(); } function internalTransfer(address payable _contract, address payable _receiver) payable external { From 66a6a617043be671bbd5a17a4e3f199f16d4d65e Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Thu, 9 May 2024 15:01:55 +0300 Subject: [PATCH 13/18] -removed unneeded console.logs -added comments for additional info -removed test 29 Signed-off-by: Nikolay Nikolov --- .../discrepancies/nonce/ChainedContracts.sol | 4 -- .../discrepancies/nonce/InternalCallee.sol | 2 - test/discrepancies/Nonce.js | 38 ++++--------------- test/hts-precompile/utils.js | 3 +- 4 files changed, 9 insertions(+), 38 deletions(-) diff --git a/contracts/discrepancies/nonce/ChainedContracts.sol b/contracts/discrepancies/nonce/ChainedContracts.sol index 5e7276dc7..8070c4a45 100644 --- a/contracts/discrepancies/nonce/ChainedContracts.sol +++ b/contracts/discrepancies/nonce/ChainedContracts.sol @@ -29,8 +29,6 @@ contract ChainedContracts { constructor() { owner = msg.sender; - // Deploy Chain within ChildContract constructor - // chainContract = new ChainContract(); childContract = new Deploys1Contract(); emit DeployedContract2Address(address(this)); } @@ -45,8 +43,6 @@ contract Deploys2Contracts { constructor() { owner = msg.sender; - // Deploy Chain within ChildContract constructor - // chainContract = new ChainContract(); childContract1 = new Deploys1Contract(); childContract2 = new EmptyContract(); emit Deploys2ContractsAddress(address(this)); diff --git a/contracts/discrepancies/nonce/InternalCallee.sol b/contracts/discrepancies/nonce/InternalCallee.sol index 5576b52ff..f60008c6a 100644 --- a/contracts/discrepancies/nonce/InternalCallee.sol +++ b/contracts/discrepancies/nonce/InternalCallee.sol @@ -16,12 +16,10 @@ contract InternalCallee { } function externalFunction() external returns (uint) { - // mutate state to maintain non-view function status return ++calledTimes; } function revertWithRevertReason() public returns (bool) { - // mutate state to maintain non-view function status ++calledTimes; revert("RevertReason"); } diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index 103ae060e..5defc50b5 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -466,6 +466,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { }); //NONCE-020 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 xit('should update all nonces after a successful contract deploy with CREATE2 ', async function () { const snBefore = await getServicesNonce(signers[0].address); @@ -548,8 +549,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snAfterNewCreate, mnAfterNewCreate, 0, 0); }); - //NONCE-022 - //should fix the get contract nonce function - waiting for SDKs + //NONCE-022 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 xit('should update all nonces when chained deploys of contracts', async function () { //deploys contract A which deploys contract B which deploys contract C //nonces of signer, contract A and contract B should increment @@ -592,8 +593,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(0, 0, servicesInnerContractNonce, mirrorNodeInnerContractNonce); }); - //NONCE-023 - //need to update the get contract nonce - waiting for SDK + //NONCE-023 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 xit('should update contract nonce for each deployed contract', async function () { //deploys contract A which deploys contracts B and C //nonce of signer should be 1 @@ -660,7 +661,8 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snWallet1Before, mnWallet1Before, snWAllet1After, mnWallet1After) }); - //NONCE-027 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + //NONCE-022 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 xit('should update nonce after unsuccessful transfer with internal call - insufficent gas', async function () { const amount = ethers.parseEther('1'); const fundTx = await signers[0].sendTransaction({ @@ -685,6 +687,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { }); //NONCE-027 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE + //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 xit('should update nonce after unsuccessful transfer with internal call - insufficent amount', async function () { // const amount = Utils.tinybarToWeibarCoef; // 1 tinybar // const fundTx = await signers[0].sendTransaction({ @@ -727,31 +730,6 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - //NONCE-029 - Skipped due to an issue that a hollow account can be created with a gas limit of 21001 - xit('should update signer nonce upon transfer to non-existing account with not enough gas limit <600K', async function () { - const amount = ethers.parseEther('1'); - const snBeforeTransfer = await getServicesNonce(signers[0].address); - const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); - - const wallet1 = ethers.Wallet.createRandom(); - const newAccTx = await signers[0].sendTransaction({ - to: wallet1.address, - value: amount, - gasLimit: 22_000 - }); - //await newAccTx.wait(); - console.log(await newAccTx.wait()); - - // internalCallerContract.transferTo(wallet1.address, {gasLimit: 700_000}) - - const snAfterCreate = await getServicesNonce(signers[0].address); - const mnAfterCreate = await getMirrorNodeNonce(signers[0].address); - - - // const tx = await internalCallerContract.transferTo(signers[0].address, {gasLimit: 500_000}); - // await tx.wait(); - }); - //NONCE-030 it('should not update nonce upon unsuccessfull transaction due to wrong chain id', async function () { const amount = ethers.parseEther('1'); diff --git a/test/hts-precompile/utils.js b/test/hts-precompile/utils.js index d17210e5d..c2b52ebd2 100644 --- a/test/hts-precompile/utils.js +++ b/test/hts-precompile/utils.js @@ -530,6 +530,7 @@ class Utils { return accountInfo.accountId.toString(); } + //Using SDK to call Consensus node to confirm that there are no nonce discrepancies between Consensus Node and Mirror node static async getContractInfo(evmAddress, client){ const query = new ContractInfoQuery().setContractId(ContractId.fromEvmAddress(0,0,evmAddress)); @@ -546,7 +547,6 @@ class Utils { static async deleteAccount(account, signer, accountId) { - console.log(accountId); let accountDeleteTransaction = await new AccountDeleteTransaction() .setAccountId(accountId) .setTransferAccountId(signer.getOperator().accountId); @@ -556,7 +556,6 @@ class Utils { .sign(PrivateKey.fromStringECDSA(account.signingKey.privateKey)); const r = await accountDeleteTransaction.execute(signer); - console.log(await r.getReceipt(signer)); } From 34105ffafa5d8a2883e8cb4bf07918f8e73605bd Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Thu, 9 May 2024 15:12:31 +0300 Subject: [PATCH 14/18] removed unneeded tokenAddress override Signed-off-by: Nikolay Nikolov --- test/discrepancies/Nonce.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index 5defc50b5..0698966c8 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -26,7 +26,7 @@ const { expect } = require('chai'); const { ethers } = require('hardhat'); const { ContractId } = require('@hashgraph/sdk'); -describe('@discrepancies - Nonce Test Suite', async () => { +describe.only('@discrepancies - Nonce Test Suite', async () => { let signers; let sdkClient; let internalCalleeContract; @@ -384,10 +384,6 @@ describe('@discrepancies - Nonce Test Suite', async () => { //NONCE-017 it('should update nonce after successful ERC721 token call', async function () { erc721Contract = await Utils.deployERC721Contract(); - tokenAddress = await Utils.createNonFungibleToken( - tokenCreateContract, - signers[0].address - ); await Utils.updateTokenKeysViaHapi(tokenAddress, [ await tokenCreateContract.getAddress(), await tokenTransferContract.getAddress(), From e8b3d8cbf367784de4a05abc5c00271ef4992ff5 Mon Sep 17 00:00:00 2001 From: nikolay Date: Tue, 4 Feb 2025 09:07:47 +0200 Subject: [PATCH 15/18] chore: pull main Signed-off-by: nikolay --- .../ChainedContracts.json | 46 -- .../Deploys1Contract.json | 46 -- .../Deploys2Contracts.json | 59 -- .../ChainedContracts.sol/EmptyContract.json | 33 -- .../discrepancies/nonce/ChainedContracts.sol | 52 -- test/constants.js | 5 - test/discrepancies/Nonce.js | 504 +++++------------- .../hedera-token-service/utils.js | 32 +- 8 files changed, 127 insertions(+), 650 deletions(-) delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json delete mode 100644 contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json delete mode 100644 contracts/discrepancies/nonce/ChainedContracts.sol diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json deleted file mode 100644 index f62daec7b..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/ChainedContracts.json +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract2Address", - "type": "event" - }, - { - "inputs": [], - "name": "childContract", - "outputs": [ - { - "internalType": "contract Deploys1Contract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json deleted file mode 100644 index 1a0849601..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys1Contract.json +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract1Address", - "type": "event" - }, - { - "inputs": [], - "name": "childContract", - "outputs": [ - { - "internalType": "contract EmptyContract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json deleted file mode 100644 index 87e1daac6..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/Deploys2Contracts.json +++ /dev/null @@ -1,59 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "Deploys2ContractsAddress", - "type": "event" - }, - { - "inputs": [], - "name": "childContract1", - "outputs": [ - { - "internalType": "contract Deploys1Contract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "childContract2", - "outputs": [ - { - "internalType": "contract EmptyContract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json b/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json deleted file mode 100644 index 8c1e0dd2d..000000000 --- a/contracts-abi/contracts/discrepancies/nonce/ChainedContracts.sol/EmptyContract.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "DeployedContract0Address", - "type": "event" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/contracts/discrepancies/nonce/ChainedContracts.sol b/contracts/discrepancies/nonce/ChainedContracts.sol deleted file mode 100644 index 8070c4a45..000000000 --- a/contracts/discrepancies/nonce/ChainedContracts.sol +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.0; - -contract EmptyContract { - address public owner; - constructor(){ - emit DeployedContract0Address(address(this)); - } - - event DeployedContract0Address(address); -} - -contract Deploys1Contract { - address public owner; - EmptyContract public childContract; - - constructor() { - owner = msg.sender; - childContract = new EmptyContract(); - emit DeployedContract1Address(address(this)); - } - - event DeployedContract1Address(address); -} - -contract ChainedContracts { - address public owner; - Deploys1Contract public childContract; - - constructor() { - owner = msg.sender; - childContract = new Deploys1Contract(); - emit DeployedContract2Address(address(this)); - } - - event DeployedContract2Address(address); -} - -contract Deploys2Contracts { - address public owner; - Deploys1Contract public childContract1; - EmptyContract public childContract2; - - constructor() { - owner = msg.sender; - childContract1 = new Deploys1Contract(); - childContract2 = new EmptyContract(); - emit Deploys2ContractsAddress(address(this)); - } - - event Deploys2ContractsAddress(address); -} diff --git a/test/constants.js b/test/constants.js index b535b6ac7..68c14bafe 100644 --- a/test/constants.js +++ b/test/constants.js @@ -58,11 +58,6 @@ const Events = { PseudoRandomSeed: 'PseudoRandomSeed', CryptoAllowance: 'CryptoAllowance', IsAssociated: 'IsAssociated', - DeployedContractAddress: 'DeployedContractAddress', - DeployedContract0Address: 'DeployedContract0Address', - DeployedContract1Address: 'DeployedContract1Address', - DeployedContract2Address: 'DeployedContract2Address', - Deploys2ContractsAddress: 'Deploys2ContractsAddress' }; const Path = { diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index 92acf4d38..f88db3a38 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -18,47 +18,38 @@ * */ -const { utils } = require('elliptic'); const Constants = require('../constants'); const Utils = require('../system-contracts/hedera-token-service/utils'); -const { expect } = require('chai'); -const { ethers } = require('hardhat'); -const Utils = require("../hts-precompile/utils"); +const {expect} = require('chai'); +const {ethers} = require('hardhat'); const TestUtils = require("../utils"); -const { expect } = require('chai'); -const { ethers } = require('hardhat'); -const { ContractId } = require('@hashgraph/sdk'); -describe.only('@discrepancies - Nonce Test Suite', async () => { +describe('@discrepancies - Nonce Test Suite', async () => { let signers; let sdkClient; let internalCalleeContract; let internalCallerContract; - let chainedContracts let tooLowGasPrice; let enoughGasPrice; let tokenCreateContract; let tokenTransferContract; let tokenAddress; let erc20Contract; - const TOTAL_SUPPLY = 1000; + let erc721Contract; + let mintedTokenSerialNumber; before(async () => { signers = await ethers.getSigners(); sdkClient = await Utils.createSDKClient(); - const { gasPrice } = await ethers.provider.getFeeData(); + const {gasPrice} = await ethers.provider.getFeeData(); tooLowGasPrice = gasPrice - BigInt(1); enoughGasPrice = gasPrice + BigInt(1); - const internalCalleeContractFactory = await ethers.getContractFactory( - Constants.Contract.InternalCallee - ); + const internalCalleeContractFactory = await ethers.getContractFactory(Constants.Contract.InternalCallee); internalCalleeContract = await internalCalleeContractFactory.deploy(); - const internalCallerContractFactory = await ethers.getContractFactory( - Constants.Contract.InternalCaller - ); + const internalCallerContractFactory = await ethers.getContractFactory(Constants.Contract.InternalCaller); internalCallerContract = await internalCallerContractFactory.deploy(); tokenCreateContract = await Utils.deployTokenCreateContract(); @@ -69,8 +60,8 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { ]); erc20Contract = await Utils.deployERC20Contract(); tokenAddress = await Utils.createFungibleToken( - tokenCreateContract, - signers[0].address + tokenCreateContract, + signers[0].address ); await Utils.updateTokenKeysViaHapi(tokenAddress, [ @@ -78,24 +69,13 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { await tokenTransferContract.getAddress(), ]); await Utils.associateToken( - tokenCreateContract, - tokenAddress, - Constants.Contract.TokenCreateContract + tokenCreateContract, + tokenAddress, + Constants.Contract.TokenCreateContract ); await Utils.grantTokenKyc(tokenCreateContract, tokenAddress); - - }); - async function getServicesContractNonce(evmAddress) { - try { - const info = await Utils.getContractInfo(evmAddress, sdkClient); - return info; - } catch (e) { - return null; - } - } - async function getServicesNonce(evmAddress) { try { const info = await Utils.getAccountInfo(evmAddress, sdkClient); @@ -113,9 +93,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { } } - async function createNewAccountWithBalance( - initialBalance = Utils.tinybarToWeibarCoef - ) { + async function createNewAccountWithBalance(initialBalance = Utils.tinybarToWeibarCoef) { const wallet = ethers.Wallet.createRandom().connect(ethers.provider); const newAccTx = await signers[0].sendTransaction({ to: wallet.address, @@ -126,23 +104,13 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { return wallet; } - function expectNonIncrementedNonce( - servicesNonceBefore, - mirrorNodeNonceBefore, - servicesNonceAfter, - mirrorNodeNonceAfter - ) { + function expectNonIncrementedNonce(servicesNonceBefore, mirrorNodeNonceBefore, servicesNonceAfter, mirrorNodeNonceAfter) { expect(servicesNonceBefore).to.equal(mirrorNodeNonceBefore); expect(servicesNonceBefore).to.equal(servicesNonceAfter); expect(mirrorNodeNonceBefore).to.equal(mirrorNodeNonceAfter); } - function expectIncrementedNonce( - servicesNonceBefore, - mirrorNodeNonceBefore, - servicesNonceAfter, - mirrorNodeNonceAfter - ) { + function expectIncrementedNonce(servicesNonceBefore, mirrorNodeNonceBefore, servicesNonceAfter, mirrorNodeNonceAfter) { expect(servicesNonceBefore).to.equal(mirrorNodeNonceBefore); expect(servicesNonceAfter).to.equal(servicesNonceBefore + 1); expect(mirrorNodeNonceAfter).to.equal(mirrorNodeNonceBefore + 1); @@ -153,9 +121,9 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({ - gasLimit: 21_001, - }) + internalCalleeContract.externalFunction({ + gasLimit: 21_001, + }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -169,10 +137,10 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({ - gasPrice: tooLowGasPrice, - maxGasAllowance: 0 - }) + internalCalleeContract.externalFunction({ + gasPrice: tooLowGasPrice, + maxGasAllowance: 0 + }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -182,31 +150,20 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { }); it('should not update nonce when offered gas price is less than current and sender does not have enough balance handler check failed', async function () { - const newAccountWithInsufficientBalance = - await createNewAccountWithBalance(); + const newAccountWithInsufficientBalance = await createNewAccountWithBalance(); - const snBefore = await getServicesNonce( - newAccountWithInsufficientBalance.address - ); - const mnBefore = await getMirrorNodeNonce( - newAccountWithInsufficientBalance.address - ); + const snBefore = await getServicesNonce(newAccountWithInsufficientBalance.address); + const mnBefore = await getMirrorNodeNonce(newAccountWithInsufficientBalance.address); - const internalCalleeContractWithNewSigner = internalCalleeContract.connect( - newAccountWithInsufficientBalance - ); + const internalCalleeContractWithNewSigner = internalCalleeContract.connect(newAccountWithInsufficientBalance); await Utils.expectToFail( - internalCalleeContractWithNewSigner.externalFunction({ - gasPrice: tooLowGasPrice - }) + internalCalleeContractWithNewSigner.externalFunction({ + gasPrice: tooLowGasPrice + }) ); - const snAfter = await getServicesNonce( - newAccountWithInsufficientBalance.address - ); - const mnAfter = await getMirrorNodeNonce( - newAccountWithInsufficientBalance.address - ); + const snAfter = await getServicesNonce(newAccountWithInsufficientBalance.address); + const mnAfter = await getMirrorNodeNonce(newAccountWithInsufficientBalance.address); expectNonIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); @@ -216,10 +173,10 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({ - gasPrice: tooLowGasPrice, - maxGasAllowance: 0 - }) + internalCalleeContract.externalFunction({ + gasPrice: tooLowGasPrice, + maxGasAllowance: 0 + }) ); const snAfter = await getServicesNonce(signers[0].address); @@ -229,61 +186,41 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { }); it('should not update nonce when offered gas price is bigger than current and sender does not have enough balance handler check failed', async function () { - const newAccountWithInsufficientBalance = - await createNewAccountWithBalance(); + const newAccountWithInsufficientBalance = await createNewAccountWithBalance(); - const snBefore = await getServicesNonce( - newAccountWithInsufficientBalance.address - ); - const mnBefore = await getMirrorNodeNonce( - newAccountWithInsufficientBalance.address - ); + const snBefore = await getServicesNonce(newAccountWithInsufficientBalance.address); + const mnBefore = await getMirrorNodeNonce(newAccountWithInsufficientBalance.address); - const internalCalleeContractWithNewSigner = internalCalleeContract.connect( - newAccountWithInsufficientBalance - ); + const internalCalleeContractWithNewSigner = internalCalleeContract.connect(newAccountWithInsufficientBalance); await Utils.expectToFail( - internalCalleeContractWithNewSigner.externalFunction({ - gasPrice: enoughGasPrice - }) + internalCalleeContractWithNewSigner.externalFunction({ + gasPrice: enoughGasPrice + }) ); - const snAfter = await getServicesNonce( - newAccountWithInsufficientBalance.address - ); - const mnAfter = await getMirrorNodeNonce( - newAccountWithInsufficientBalance.address - ); + const snAfter = await getServicesNonce(newAccountWithInsufficientBalance.address); + const mnAfter = await getMirrorNodeNonce(newAccountWithInsufficientBalance.address); expectNonIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); it('should not update nonce when sender does not have enough balance handler check failed', async function () { - const newAccountWithInsufficientBalance = - await createNewAccountWithBalance(); + const newAccountWithInsufficientBalance = await createNewAccountWithBalance(); - const snBefore = await getServicesNonce( - newAccountWithInsufficientBalance.address - ); - const mnBefore = await getMirrorNodeNonce( - newAccountWithInsufficientBalance.address - ); + const snBefore = await getServicesNonce(newAccountWithInsufficientBalance.address); + const mnBefore = await getMirrorNodeNonce(newAccountWithInsufficientBalance.address); const internalCalleeContractWithNewSigner = internalCalleeContract.connect( - newAccountWithInsufficientBalance + newAccountWithInsufficientBalance ); await Utils.expectToFail( - internalCalleeContractWithNewSigner.externalFunction({ - value: 2 * Utils.tinybarToWeibarCoef // 2 tinybars - }) + internalCalleeContractWithNewSigner.externalFunction({ + value: 2 * Utils.tinybarToWeibarCoef // 2 tinybars + }) ); - const snAfter = await getServicesNonce( - newAccountWithInsufficientBalance.address - ); - const mnAfter = await getMirrorNodeNonce( - newAccountWithInsufficientBalance.address - ); + const snAfter = await getServicesNonce(newAccountWithInsufficientBalance.address); + const mnAfter = await getMirrorNodeNonce(newAccountWithInsufficientBalance.address); expectNonIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); @@ -293,7 +230,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.revertWithRevertReason({ gasLimit: 500_000 }) + internalCalleeContract.revertWithRevertReason({gasLimit: 500_000}) ); const snAfter = await getServicesNonce(signers[0].address); @@ -307,7 +244,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.externalFunction({ gasLimit: 21_064 }) + internalCalleeContract.externalFunction({gasLimit: 21_064}) ); const snAfter = await getServicesNonce(signers[0].address); @@ -321,7 +258,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCallerContract.transferTo(signers[1].address, { gasLimit: 500_000 }) + internalCallerContract.transferTo(signers[1].address, {gasLimit: 500_000}) ); const snAfter = await getServicesNonce(signers[0].address); @@ -335,7 +272,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCallerContract.transferTo('0x0000000000000000000000000000000000000002', { gasLimit: 500_000 }) + internalCallerContract.transferTo('0x0000000000000000000000000000000000000002', {gasLimit: 500_000}) ); const snAfter = await getServicesNonce(signers[0].address); @@ -349,7 +286,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCallerContract.transferTo('0x0000000000000000000000000000000000000167', { gasLimit: 500_000 }) + internalCallerContract.transferTo('0x0000000000000000000000000000000000000167', {gasLimit: 500_000}) ); const snAfter = await getServicesNonce(signers[0].address); @@ -362,7 +299,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); - const tx = await internalCalleeContract.externalFunction({ gasLimit: 500_000 }); + const tx = await internalCalleeContract.externalFunction({gasLimit: 500_000}); await tx.wait(); const snAfter = await getServicesNonce(signers[0].address); @@ -381,7 +318,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); - const tx = await internalCallerContract.transferTo(signers[0].address, { gasLimit: 500_000 }); + const tx = await internalCallerContract.transferTo(signers[0].address, {gasLimit: 500_000}); await tx.wait(); const snAfter = await getServicesNonce(signers[0].address); @@ -394,7 +331,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); - const tx = await internalCalleeContract.factorySample({ gasLimit: 500_000 }); + const tx = await internalCalleeContract.factorySample({gasLimit: 500_000}); await tx.wait(); const snAfter = await getServicesNonce(signers[0].address); @@ -403,9 +340,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); - //NONCE-017 it('should update nonce after successful ERC20 token call', async function () { - const signers = await ethers.getSigners(); const amount = 200; @@ -414,13 +349,13 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { try { const tx = await erc20Contract - .connect(signers[0]) - .transfer( - tokenAddress, - signers[1].address, - amount, - Constants.GAS_LIMIT_1_000_000 - ); + .connect(signers[0]) + .transfer( + tokenAddress, + signers[1].address, + amount, + Constants.GAS_LIMIT_1_000_000 + ); await tx.wait(); } catch (e) { expect(e).to.exist; @@ -433,7 +368,6 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }) - //NONCE-017 it('should update nonce after successful ERC721 token call', async function () { erc721Contract = await Utils.deployERC721Contract(); await Utils.updateTokenKeysViaHapi(tokenAddress, [ @@ -445,8 +379,8 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); mintedTokenSerialNumber = await Utils.mintNFT( - tokenCreateContract, - tokenAddress + tokenCreateContract, + tokenAddress ); const snAfter = await getServicesNonce(signers[0].address); @@ -455,12 +389,9 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); - //NONCE-018 it('should update nonce after successful call to Ethereum Precompiles', async function () { - const Contract = await ethers.getContractFactory( - Constants.Contract.EthNativePrecompileCaller - ); - contract = await Contract.deploy({ + const contractFactory = await ethers.getContractFactory(Constants.Contract.EthNativePrecompileCaller); + const contract = await contractFactory.deploy({ gasLimit: 15_000_000, }); @@ -476,9 +407,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { let r = splitSignature.r; let s = splitSignature.s; - const callData = `0x${TestUtils.to32ByteString(hashedData)}${TestUtils.to32ByteString( - v - )}${TestUtils.to32ByteString(r)}${TestUtils.to32ByteString(s)}`; + const callData = `0x${TestUtils.to32ByteString(hashedData)}${TestUtils.to32ByteString(v)}${TestUtils.to32ByteString(r)}${TestUtils.to32ByteString(s)}`; const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); @@ -493,9 +422,7 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); - //NONCE-019 it('should update nonce after unsuccessful contract deploy with CREATE2 ', async function () { - const firstTx = await internalCalleeContract.deployViaCreate2(1); await firstTx.wait(); @@ -503,177 +430,53 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnBefore = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - internalCalleeContract.deployViaCreate2(1, { gasLimit: 500000 }) + internalCalleeContract.deployViaCreate2(1, {gasLimit: 500000}) ); const snAfter = await getServicesNonce(signers[0].address); const mnAfter = await getMirrorNodeNonce(signers[0].address); expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); - - }); - - //NONCE-020 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE - //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 - xit('should update all nonces after a successful contract deploy with CREATE2 ', async function () { - - const snBefore = await getServicesNonce(signers[0].address); - const mnBefore = await getMirrorNodeNonce(signers[0].address); - - //deploy a contract with CREATE2 - const firstTx = await internalCalleeContract.deployViaCreate2(1); - const txReceipt = await firstTx.wait(); - - const deployedTempContractAddress = txReceipt.logs.filter( - (e) => e.fragment.name === Constants.Events.DeployedContractAddress - )[0].args[0]; - - const snAfter = await getServicesNonce(signers[0].address); - const mnAfter = await getMirrorNodeNonce(signers[0].address); - - //get the nonce of the intermediary contract - const contractFactorySnAfter = await getServicesContractNonce(internalCalleeContract.target); - const contractFactoryMnAfter = await getMirrorNodeNonce(internalCalleeContract.target); - - //After successful deploy verify that the nonces of the factory contract and the tx signer are updated - expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); - expectIncrementedNonce(0, 0, contractFactorySnAfter, contractFactoryMnAfter); - - const selfdestructTx = await internalCalleeContract.selfdestructSample(deployedTempContractAddress); - await selfdestructTx.wait(); - - //signer nonce should increment after selfdestruct is executed - expectIncrementedNonce(snAfter, mnAfter, snAfter + 1, mnAfter + 1); - - //redeploy the contract with the same salt and verify nonces are updated - const redeployTx = await internalCalleeContract.deployViaCreate2(1); - const redeployTxReceipt = await redeployTx.wait(); - - const redeployedTempContractAddress = redeployTxReceipt.logs.filter( - (e) => e.fragment.name === Constants.Events.DeployedContractAddress - )[0].args[0]; - - //get all addresses and verify nonces are updated - }); - //NONCE-021 it('should not update nonces when deploying on an address with an already existing account', async function () { - //create a hollow account and send tokens + // create a hollow account const wallet = await createNewAccountWithBalance(ethers.parseEther('3.1')); const snAfterCreate = await getServicesNonce(wallet.address); const mnAfterCreate = await getMirrorNodeNonce(wallet.address); - // verify nonce of hollow account after token received is 0 + // verify that the hollow account nonce is 0 expectNonIncrementedNonce(snAfterCreate, mnAfterCreate, 0, 0); - //send ethers from the hollow account to the GENESIS account + // send hbars to signers[0] address const signerFundTx = await wallet.sendTransaction({ to: signers[0].address, value: Utils.tinybarToWeibarCoef // 1 tinybar }); await signerFundTx.wait(); - //verify new account nonce is 1 + // verify that the nonce has been incremented and is set to 1 const snAfterSendTx = await getServicesNonce(wallet.address); const mnAfterSendTx = await getMirrorNodeNonce(wallet.address); - expectIncrementedNonce(snAfterCreate, mnAfterCreate, snAfterSendTx, mnAfterSendTx); - //delete the account + // delete the newly created account const info = await Utils.getAccountInfo(wallet.address, sdkClient); - const deleteTx = await Utils.deleteAccount(wallet, sdkClient, info.accountId); + await Utils.deleteAccount(wallet, sdkClient, info.accountId); - //send tokens to the same address and verify nonce is 0 + // send hbars to the same address const fundTx2 = await signers[0].sendTransaction({ to: wallet.address, value: Utils.tinybarToWeibarCoef // 1 tinybar }); await fundTx2.wait(); - //verify nonce is 0 + // verify that the hollow account nonce is 0 const snAfterNewCreate = await getServicesNonce(wallet.address); const mnAfterNewCreate = await getMirrorNodeNonce(wallet.address); expectNonIncrementedNonce(snAfterNewCreate, mnAfterNewCreate, 0, 0); }); - //NONCE-022 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE - //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 - xit('should update all nonces when chained deploys of contracts', async function () { - //deploys contract A which deploys contract B which deploys contract C - //nonces of signer, contract A and contract B should increment - //nonce of contract C should be 0 - const snBefore = await getServicesNonce(signers[0].address); - const mnBefore = await getMirrorNodeNonce(signers[0].address); - - //deploy contract A which will deploy Contract B which will deploy Contract C - const chainedContractsFactory = await ethers.getContractFactory(Constants.Contract.ChainedContracts); - const chainedContracts = await chainedContractsFactory.deploy({ gasLimit: 5_000_000 }); - const receipt = await chainedContracts.deploymentTransaction().wait(); - - console.log(receipt.logs); - - //get the 3 contracts addresses - const innerContract = receipt.logs[0].address; - const intermediaryContract = receipt.logs[1].address; - const outerContract = receipt.logs[2].address; - - //get the 3 contracts nonces - const servicesInnerContractNonce = await Utils.getContractInfo(innerContract, sdkClient); - const mirrorNodeInnerContractNonce = await getMirrorNodeNonce(innerContract); - - const servicesIntermediaryContractContractNonce = await getServicesContractNonce(intermediaryContract.target); - const mirrorNodeIntermediaryContractNonce = await getMirrorNodeNonce(intermediaryContract.target); - - const servicesOuterContractNonce = await getServicesContractNonce(outerContract.target); - const mirrorNodeOuterContractNonce = await getMirrorNodeNonce(outerContract.target); - - //verify signer nonces have updated correctly - const snAfter = await getServicesNonce(signers[0].address); - const mnAfter = await getMirrorNodeNonce(signers[0].address); - expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); - - //verify contract nonces have updated - expectIncrementedNonce(0, 0, servicesIntermediaryContractContractNonce, mirrorNodeIntermediaryContractNonce); - expectIncrementedNonce(0, 0, servicesOuterContractNonce, mirrorNodeOuterContractNonce); - - //verify nonce of the inner most contract is 0 - expectNonIncrementedNonce(0, 0, servicesInnerContractNonce, mirrorNodeInnerContractNonce); - }); - - //NONCE-023 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE - //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 - xit('should update contract nonce for each deployed contract', async function () { - //deploys contract A which deploys contracts B and C - //nonce of signer should be 1 - //nonce of contract A should be 2 - const snBefore = await getServicesNonce(signers[0].address); - const mnBefore = await getMirrorNodeNonce(signers[0].address); - - //deploy contract A which will deploy Contract B and C - const Deploys2ContractsFactory = await ethers.getContractFactory(Constants.Contract.Deploys2Contracts); - const deploys2Contracts = await Deploys2ContractsFactory.deploy({ gasLimit: 5_000_000 }); - const receipt = await deploys2Contracts.deploymentTransaction().wait(); - - const deploys2ContractsAddress = receipt.logs.filter( - (e) => e.fragment.name === Constants.Events.Deploys2ContractsAddress - )[0].args[0]; - - //get contract nonce after deployment - const sContractNonce = await getServicesContractNonce(deploys2ContractsAddress); - const mContractNonce = await getMirrorNodeNonce(deploys2ContractsAddress); - - //verify signer nonces have updated correctly - const snAfter = await getServicesNonce(signers[0].address); - const mnAfter = await getMirrorNodeNonce(signers[0].address); - expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); - - //verify contract nonce have updated 2 times - expect(sContractNonce).to.equal(2); - expect(mContractNonce).to.equal(2); - }); - - //NONCE-024 it('Nonce should NOT be incremented upon static call', async function () { const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); @@ -685,10 +488,9 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterTransfer, mnAfterTransfer) }); - //NONCE-026 it('Nonce should NOT be incremented upon unsuccessfull sent with Direct call - not enough balance', async function () { - initialValue = 100000 * Utils.tinybarToWeibarCoef - initialWalletBalance = Utils.tinybarToWeibarCoef; + const initialValue = 100000 * Utils.tinybarToWeibarCoef + const initialWalletBalance = Utils.tinybarToWeibarCoef; const newWallet = await createNewAccountWithBalance(initialWalletBalance); const newWallet2 = await createNewAccountWithBalance(initialWalletBalance); @@ -697,77 +499,26 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { const mnWallet1Before = await getMirrorNodeNonce(newWallet.address); await Utils.expectToFail( - newWallet.sendTransaction({ - to: newWallet2.address, - value: 20000000000, - }) + newWallet.sendTransaction({ + to: newWallet2.address, + value: 20000000000, + }) ); - const snWAllet1After = await getServicesNonce(newWallet.address); + const snWallet1After = await getServicesNonce(newWallet.address); const mnWallet1After = await getMirrorNodeNonce(newWallet.address); - expectNonIncrementedNonce(snWallet1Before, mnWallet1Before, snWAllet1After, mnWallet1After) - }); - - //NONCE-022 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE - //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 - xit('should update nonce after unsuccessful transfer with internal call - insufficent gas', async function () { - const amount = ethers.parseEther('1'); - const fundTx = await signers[0].sendTransaction({ - to: internalCallerContract.target, - value: amount - }); - await fundTx.wait(); - - const snBeforeSigner = await getServicesNonce(signers[0].address); - const mnBeforeSigner = await getMirrorNodeNonce(signers[0].address); - - await Utils.expectToFail( - internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address, {gasLimit: 25_900}) - ); - - // const tx = await internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address, {gasLimit: 22_900}); - // const txResult = await tx.wait(); - - const snAfterSigner = await getServicesNonce(signers[0].address); - const mnAfterSigner = await getMirrorNodeNonce(signers[0].address); - expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); + expectNonIncrementedNonce(snWallet1Before, mnWallet1Before, snWallet1After, mnWallet1After) }); - //NONCE-027 - WAITING FOR SDK TEAM FOR CHECKING THE CONTRACT NONCE - //ISSUE: https://github.com/hashgraph/hedera-sdk-js/issues/2192 - xit('should update nonce after unsuccessful transfer with internal call - insufficent amount', async function () { - // const amount = Utils.tinybarToWeibarCoef; // 1 tinybar - // const fundTx = await signers[0].sendTransaction({ - // to: internalCallerContract.target, - // value: amount - // }); - // await fundTx.wait(); - - const snBeforeSigner = await getServicesNonce(signers[0].address); - const mnBeforeSigner = await getMirrorNodeNonce(signers[0].address); - - await Utils.expectToFail( - internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address) - ); - // const tx = await internalCalleeContract.internalTransfer(internalCallerContract.target, signers[1].address); - // const txResult = await tx.wait(); - - const snAfterSigner = await getServicesNonce(signers[0].address); - const mnAfterSigner = await getMirrorNodeNonce(signers[0].address); - // expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); - }); - - //NONCE-028 it('should update signer nonce upon transfer to non-existing account with enough gas limit >600K', async function () { - const amount = ethers.parseEther('1'); const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); const wallet1 = ethers.Wallet.createRandom(); const newAccTx = await signers[0].sendTransaction({ to: wallet1.address, - value: amount, + value: ethers.parseEther('1'), gasLimit: 650_000, }); await newAccTx.wait(); @@ -778,20 +529,18 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - //NONCE-030 it('should not update nonce upon unsuccessfull transaction due to wrong chain id', async function () { - const amount = ethers.parseEther('1'); const wallet1 = ethers.Wallet.createRandom(); const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); await Utils.expectToFail( - signers[0].sendTransaction({ - to: wallet1.address, - value: amount, - gasLimit: 650_000, - chainId: 8n - }) + signers[0].sendTransaction({ + to: wallet1.address, + value: ethers.parseEther('1'), + gasLimit: 650_000, + chainId: 8n + }) ); const snAfterCreate = await getServicesNonce(signers[0].address); @@ -800,14 +549,12 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate) }); - //NONCE-031 - Type 0 it('should update nonce upon transaction of type 0', async function () { - const amount = ethers.parseEther('1'); const wallet1 = ethers.Wallet.createRandom(); const defaultTransactionFields = { to: wallet1.address, - value: amount, + value: ethers.parseEther('1'), gasLimit: 650_000 }; @@ -829,18 +576,15 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - //NONCE-031 - Type 1 it('should update nonce upon transaction of type 1', async function () { - const amount = ethers.parseEther('1'); const wallet1 = ethers.Wallet.createRandom(); const defaultTransactionFields = { to: wallet1.address, - value: amount, + value: ethers.parseEther('1'), gasLimit: 650_000 }; - const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); @@ -859,14 +603,12 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - //NONCE-031 - Type 2 it('should update nonce upon transaction of type 2', async function () { - const amount = ethers.parseEther('1'); const wallet1 = ethers.Wallet.createRandom(); const defaultTransactionFields = { to: wallet1.address, - value: amount, + value: ethers.parseEther('1'), gasLimit: 650_000 }; @@ -888,61 +630,53 @@ describe.only('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - //NONCE-032 - it('Hollow account that is finilized with the same transaction that should upgrade its nonce', async function () { - const amount = Utils.tinybarToWeibarCoef; - + it('hollow account that is finalized with the same transaction that should upgrade its nonce', async function () { const wallet = await createNewAccountWithBalance(ethers.parseEther('10')); const wallet2 = ethers.Wallet.createRandom().connect(ethers.provider); - let jsonRequest2 = await Utils.getAccountInfo(wallet.address, sdkClient); - expect(jsonRequest2.key._key).to.equal(undefined); + let infoBefore = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(infoBefore.key._key).to.equal(undefined); const snBeforeTransfer = await getServicesNonce(wallet.address); const mnBeforeTransfer = await getMirrorNodeNonce(wallet.address); const newAccTx1 = await wallet.sendTransaction({ to: wallet2.address, - value: amount, + value: Utils.tinybarToWeibarCoef, gasLimit: 650_000, }); await newAccTx1.wait(); - let jsonRequest3 = await Utils.getAccountInfo(wallet.address, sdkClient); - expect(jsonRequest3.key._key).to.not.equal(undefined); + let infoAfter = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(infoAfter.key._key).to.not.equal(undefined); const snAfterCreate = await getServicesNonce(wallet.address); const mnAfterCreate = await getMirrorNodeNonce(wallet.address); expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); - }); - - //NONCE-033 - it('Hollow account that is finilized with the same transaction that should not upgrade its nonce when offered gas price and and allowance fail check ', async function () { - const amount = Utils.tinybarToWeibarCoef; - + it('hollow account that is finilized with the same transaction that should not upgrade its nonce when offered gas price and and allowance fail check ', async function () { const wallet = await createNewAccountWithBalance(ethers.parseEther('10')); - let jsonRequest2 = await Utils.getAccountInfo(wallet.address, sdkClient); - expect(jsonRequest2.key._key).to.equal(undefined); + let infoBefore = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(infoBefore.key._key).to.equal(undefined); const snBeforeTransfer = await getServicesNonce(wallet.address); const mnBeforeTransfer = await getMirrorNodeNonce(wallet.address); await Utils.expectToFail( - wallet.sendTransaction({ - to: signers[0].address, - value: amount, - gasPrice: tooLowGasPrice, - maxGasAllowance: 0, - gasLimit: 650_000, - }) + wallet.sendTransaction({ + to: signers[0].address, + value: Utils.tinybarToWeibarCoef, + gasPrice: tooLowGasPrice, + maxGasAllowance: 0, + gasLimit: 650_000, + }) ); - let jsonRequest3 = await Utils.getAccountInfo(wallet.address, sdkClient); - expect(jsonRequest3.key._key).to.not.equal(undefined); + let infoAfter = await Utils.getAccountInfo(wallet.address, sdkClient); + expect(infoAfter.key._key).to.not.equal(undefined); const snAfterCreate = await getServicesNonce(wallet.address); const mnAfterCreate = await getMirrorNodeNonce(wallet.address); diff --git a/test/system-contracts/hedera-token-service/utils.js b/test/system-contracts/hedera-token-service/utils.js index 236da2331..10ba0a940 100644 --- a/test/system-contracts/hedera-token-service/utils.js +++ b/test/system-contracts/hedera-token-service/utils.js @@ -34,10 +34,7 @@ const { TokenAssociateTransaction, AccountBalanceQuery, ContractInfoQuery, - AccountDeleteTransaction, - Wallet, - ContractCallQuery, - ContractNonceInfo + AccountDeleteTransaction } = require('@hashgraph/sdk'); const Constants = require('../../constants'); @@ -712,13 +709,6 @@ class Utils { return accountInfo.accountId.toString(); } - //Using SDK to call Consensus node to confirm that there are no nonce discrepancies between Consensus Node and Mirror node - static async getContractInfo(evmAddress, client){ - const query = new ContractInfoQuery().setContractId(ContractId.fromEvmAddress(0,0,evmAddress)); - - return await query.execute(client); - } - static async getAccountInfo(evmAddress, client) { const query = new AccountInfoQuery().setAccountId( AccountId.fromEvmAddress(0, 0, evmAddress) @@ -728,27 +718,21 @@ class Utils { } static async getContractInfo(evmAddress, client) { - const query = new ContractInfoQuery().setContractId( - ContractId.fromEvmAddress(0, 0, evmAddress) - ); + const query = new ContractInfoQuery().setContractId(ContractId.fromEvmAddress(0, 0, evmAddress)); return await query.execute(client); } static async deleteAccount(account, signer, accountId) { + const accountDeleteTransaction = (await (new AccountDeleteTransaction() + .setAccountId(accountId) + .setTransferAccountId(signer.getOperator().accountId) + .freezeWith(signer) + ).sign(PrivateKey.fromStringECDSA(account.signingKey.privateKey))); - let accountDeleteTransaction = await new AccountDeleteTransaction() - .setAccountId(accountId) - .setTransferAccountId(signer.getOperator().accountId); - - await accountDeleteTransaction - .freezeWith(signer) - .sign(PrivateKey.fromStringECDSA(account.signingKey.privateKey)); - - const r = await accountDeleteTransaction.execute(signer); + await accountDeleteTransaction.execute(signer); } - static getSignerCompressedPublicKey( index = 0, asBuffer = true, From 75b54dd63cde300606c5132eb321ff5c80865489 Mon Sep 17 00:00:00 2001 From: nikolay Date: Tue, 4 Feb 2025 09:09:01 +0200 Subject: [PATCH 16/18] chore: format contract Signed-off-by: nikolay --- .../discrepancies/nonce/InternalCallee.sol | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/contracts/discrepancies/nonce/InternalCallee.sol b/contracts/discrepancies/nonce/InternalCallee.sol index f60008c6a..b01686caf 100644 --- a/contracts/discrepancies/nonce/InternalCallee.sol +++ b/contracts/discrepancies/nonce/InternalCallee.sol @@ -2,18 +2,17 @@ pragma solidity ^0.8.0; contract Sample { - - function selfDestructSample() external { - selfdestruct(payable(msg.sender)); - } + function selfDestructSample() external { + selfdestruct(payable(msg.sender)); + } } contract InternalCallee { - uint calledTimes = 0; + uint calledTimes = 0; - function factorySample() external returns (address) { - return address(new Sample()); - } + function factorySample() external returns (address) { + return address(new Sample()); + } function externalFunction() external returns (uint) { return ++calledTimes; @@ -32,21 +31,21 @@ contract InternalCallee { selfdestruct(_addr); } - function selfdestructSample(address payable sampleAddress) external { - Sample(sampleAddress).selfDestructSample(); - } + function selfdestructSample(address payable sampleAddress) external { + Sample(sampleAddress).selfDestructSample(); + } - function internalTransfer(address payable _contract, address payable _receiver) payable external { - (bool success,) = _contract.call(abi.encodeWithSignature("transferTo(address)", _receiver)); - require(success, "Function call failed"); - } + function internalTransfer(address payable _contract, address payable _receiver) payable external { + (bool success,) = _contract.call(abi.encodeWithSignature("transferTo(address)", _receiver)); + require(success, "Function call failed"); + } - event DeployedContractAddress(address); + event DeployedContractAddress(address); - function deployViaCreate2(uint256 _salt) external returns (address) { - Sample temp = new Sample{salt: bytes32(_salt)}(); - emit DeployedContractAddress(address(temp)); + function deployViaCreate2(uint256 _salt) external returns (address) { + Sample temp = new Sample{salt : bytes32(_salt)}(); + emit DeployedContractAddress(address(temp)); - return address(temp); - } + return address(temp); + } } From dcfa01c5c1ffa36e6eb2244dc1a5bac7ff1c675c Mon Sep 17 00:00:00 2001 From: nikolay Date: Tue, 4 Feb 2025 09:46:09 +0200 Subject: [PATCH 17/18] chore: remove unused constants Signed-off-by: nikolay --- test/constants.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/constants.js b/test/constants.js index 68c14bafe..79fe839fd 100644 --- a/test/constants.js +++ b/test/constants.js @@ -196,7 +196,6 @@ const Contract = { Purchase: 'Purchase', InternalCallee: 'InternalCallee', InternalCaller: 'InternalCaller', - ChainedContracts: 'ChainedContracts', EthNativePrecompileCaller: 'EthNativePrecompileCaller', AtomicHTS: 'AtomicHTS', BLSTest: 'BLSTest', @@ -206,8 +205,7 @@ const Contract = { CancunOpcodes: 'CancunOpcodes', KZGPointEvaluation: 'KZGPointEvaluation', StateRegistry: 'StateRegistry', - AliasAccountUtility: 'AliasAccountUtility', - Deploys2Contracts: 'Deploys2Contracts' + AliasAccountUtility: 'AliasAccountUtility' }; const CALL_EXCEPTION = 'CALL_EXCEPTION'; From f49d8bea22a57145d9647bdfcc11daaa186acea9 Mon Sep 17 00:00:00 2001 From: nikolay Date: Wed, 5 Feb 2025 08:45:30 +0200 Subject: [PATCH 18/18] chore: rename some tests Signed-off-by: nikolay --- test/discrepancies/Nonce.js | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/test/discrepancies/Nonce.js b/test/discrepancies/Nonce.js index f88db3a38..aa8bdb7e7 100644 --- a/test/discrepancies/Nonce.js +++ b/test/discrepancies/Nonce.js @@ -347,20 +347,9 @@ describe('@discrepancies - Nonce Test Suite', async () => { const snBefore = await getServicesNonce(signers[0].address); const mnBefore = await getMirrorNodeNonce(signers[0].address); - try { - const tx = await erc20Contract - .connect(signers[0]) - .transfer( - tokenAddress, - signers[1].address, - amount, - Constants.GAS_LIMIT_1_000_000 - ); - await tx.wait(); - } catch (e) { - expect(e).to.exist; - expect(e.code).to.eq(Constants.CALL_EXCEPTION); - } + await Utils.expectToFail( + erc20Contract.transfer(tokenAddress, signers[1].address, amount, Constants.GAS_LIMIT_1_000_000) + ); const snAfter = await getServicesNonce(signers[0].address); const mnAfter = await getMirrorNodeNonce(signers[0].address); @@ -439,7 +428,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBefore, mnBefore, snAfter, mnAfter); }); - it('should not update nonces when deploying on an address with an already existing account', async function () { + it('should reset nonce when an account has been deleted and created again', async function () { // create a hollow account const wallet = await createNewAccountWithBalance(ethers.parseEther('3.1')); const snAfterCreate = await getServicesNonce(wallet.address); @@ -477,7 +466,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snAfterNewCreate, mnAfterNewCreate, 0, 0); }); - it('Nonce should NOT be incremented upon static call', async function () { + it('should not increment nonce upon static call', async function () { const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); const tx = await internalCallerContract.staticCallExternalFunction.staticCall(signers[1].address) @@ -488,8 +477,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterTransfer, mnAfterTransfer) }); - it('Nonce should NOT be incremented upon unsuccessfull sent with Direct call - not enough balance', async function () { - const initialValue = 100000 * Utils.tinybarToWeibarCoef + it('should not increment nonce upon unsuccessful sent with direct call - not enough balance', async function () { const initialWalletBalance = Utils.tinybarToWeibarCoef; const newWallet = await createNewAccountWithBalance(initialWalletBalance); @@ -511,7 +499,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectNonIncrementedNonce(snWallet1Before, mnWallet1Before, snWallet1After, mnWallet1After) }); - it('should update signer nonce upon transfer to non-existing account with enough gas limit >600K', async function () { + it('should update nonce upon transfer to non-existing account with enough gas limit > 600k (hollow account creation)', async function () { const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); @@ -529,7 +517,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - it('should not update nonce upon unsuccessfull transaction due to wrong chain id', async function () { + it('should not update nonce upon unsuccessful transaction due to wrong chain id', async function () { const wallet1 = ethers.Wallet.createRandom(); const snBeforeTransfer = await getServicesNonce(signers[0].address); const mnBeforeTransfer = await getMirrorNodeNonce(signers[0].address); @@ -630,7 +618,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - it('hollow account that is finalized with the same transaction that should upgrade its nonce', async function () { + it('should update nonce on hollow account finalization', async function () { const wallet = await createNewAccountWithBalance(ethers.parseEther('10')); const wallet2 = ethers.Wallet.createRandom().connect(ethers.provider); @@ -656,7 +644,7 @@ describe('@discrepancies - Nonce Test Suite', async () => { expectIncrementedNonce(snBeforeTransfer, mnBeforeTransfer, snAfterCreate, mnAfterCreate); }); - it('hollow account that is finilized with the same transaction that should not upgrade its nonce when offered gas price and and allowance fail check ', async function () { + it('should not update nonce on hollow account finalization due to reversion when offered gas price and allowance fail check', async function () { const wallet = await createNewAccountWithBalance(ethers.parseEther('10')); let infoBefore = await Utils.getAccountInfo(wallet.address, sdkClient);