From 25965a22deddcbd5295c4381667722e2f596094a Mon Sep 17 00:00:00 2001 From: Eric Badiere Date: Thu, 14 Dec 2023 13:50:05 -0700 Subject: [PATCH] fix: Removed the contract revert reason from the eth_getTransactionByHash. (#1979) * fix: Removed the contract revert reason from the eth_getTransactionByHash. Signed-off-by: ebadiere * fix: removed test that no longer needed. Signed-off-by: ebadiere * fix: Removed eth_getTransactionByHash test that tested contract revert reasons. Signed-off-by: ebadiere --------- Signed-off-by: ebadiere --- packages/relay/src/lib/eth.ts | 9 -- .../lib/eth/eth_getTransactionByHash.spec.ts | 19 ---- .../tests/acceptance/rpc_batch3.spec.ts | 88 ------------------- 3 files changed, 116 deletions(-) diff --git a/packages/relay/src/lib/eth.ts b/packages/relay/src/lib/eth.ts index 165fd79fe9..fab74b0d7d 100644 --- a/packages/relay/src/lib/eth.ts +++ b/packages/relay/src/lib/eth.ts @@ -1752,15 +1752,6 @@ export class EthImpl implements Eth { const fromAddress = await this.resolveEvmAddress(contractResult.from, requestIdPrefix, [constants.TYPE_ACCOUNT]); const toAddress = await this.resolveEvmAddress(contractResult.to, requestIdPrefix); - if ( - process.env.DEV_MODE && - process.env.DEV_MODE === 'true' && - contractResult.result === 'CONTRACT_REVERT_EXECUTED' - ) { - const err = predefined.CONTRACT_REVERT(contractResult.error_message, contractResult.error_message); - throw err; - } - return formatContractResult({ ...contractResult, from: fromAddress, diff --git a/packages/relay/tests/lib/eth/eth_getTransactionByHash.spec.ts b/packages/relay/tests/lib/eth/eth_getTransactionByHash.spec.ts index 2543c3612b..50fa378e07 100644 --- a/packages/relay/tests/lib/eth/eth_getTransactionByHash.spec.ts +++ b/packages/relay/tests/lib/eth/eth_getTransactionByHash.spec.ts @@ -280,25 +280,6 @@ describe('@ethGetTransactionByHash eth_getTransactionByHash tests', async functi }); }); - it('throws error for reverted transactions when DEV_MODE=true', async function () { - const initialDevModeValue = process.env.DEV_MODE; - process.env.DEV_MODE = 'true'; - - const uniqueTxHash = '0xa8cad7b827375d12d73af57b6a3f84353645fd31305ea58ff52dda53ec640533'; - restMock.onGet(`contracts/results/${uniqueTxHash}`).reply(200, DEFAULT_DETAILED_CONTRACT_RESULT_BY_HASH_REVERTED); - const args = [uniqueTxHash]; - const errMessage = DEFAULT_DETAILED_CONTRACT_RESULT_BY_HASH_REVERTED.error_message; - const data = DEFAULT_DETAILED_CONTRACT_RESULT_BY_HASH_REVERTED.error_message; - await RelayAssertions.assertRejection( - predefined.CONTRACT_REVERT(errMessage, data), - ethImpl.getTransactionByHash, - true, - ethImpl, - args, - ); - process.env.DEV_MODE = initialDevModeValue; - }); - it('returns synthetic transaction when it matches cache', async function () { // prepare cache with synthetic log const cacheKeySyntheticLog = `${constants.CACHE_KEY.SYNTHETIC_LOG_TRANSACTION_HASH}${defaultDetailedContractResultByHash.hash}`; diff --git a/packages/server/tests/acceptance/rpc_batch3.spec.ts b/packages/server/tests/acceptance/rpc_batch3.spec.ts index 9051daf057..9e3134e782 100644 --- a/packages/server/tests/acceptance/rpc_batch3.spec.ts +++ b/packages/server/tests/acceptance/rpc_batch3.spec.ts @@ -561,94 +561,6 @@ describe('@api-batch-3 RPC Server Acceptance Tests', function () { expect(receipt.revertReason).to.eq(PAYABLE_METHOD_ERROR_DATA); }); - describe('eth_getTransactionByHash for reverted payable contract calls', async function () { - const payableMethodsData = [ - { - data: '0xfe0a3dd7', - method: 'revertWithNothing', - message: '', - errorData: '0x', - }, - { - data: '0x0323d234', - method: 'revertWithString', - message: 'Some revert message', - errorData: - '0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000013536f6d6520726576657274206d65737361676500000000000000000000000000', - }, - { - data: '0x46fc4bb1', - method: 'revertWithCustomError', - message: '', - errorData: '0x0bd3d39c', - }, - { - data: '0x33fe3fbd', - method: 'revertWithPanic', - message: '', - errorData: '0x4e487b710000000000000000000000000000000000000000000000000000000000000012', - }, - ]; - const hashes: any = []; - - beforeEach(async () => { - requestId = Utils.generateRequestId(); - }); - - before(async function () { - for (const element of payableMethodsData) { - const transaction = { - // value: ONE_TINYBAR, - gasLimit: numberTo0x(30000), - chainId: Number(CHAIN_ID), - to: reverterEvmAddress, - nonce: await relay.getAccountNonce(accounts[0].address, requestId), - maxFeePerGas: await relay.gasPrice(requestId), - data: element.data, - }; - const signedTx = await accounts[0].wallet.signTransaction(transaction); - const hash = await relay.sendRawTransaction(signedTx, requestId); - hashes.push(hash); - - // Wait until receipt is available in mirror node - await mirrorNode.get(`/contracts/results/${hash}`, requestId); - } - }); - - for (let i = 0; i < payableMethodsData.length; i++) { - it(`Payable method ${payableMethodsData[i].method} returns tx object`, async function () { - const tx = await relay.call(RelayCall.ETH_ENDPOINTS.ETH_GET_TRANSACTION_BY_HASH, [hashes[i]], requestId); - expect(tx).to.exist; - expect(tx.hash).to.exist; - expect(tx.hash).to.eq(hashes[i]); - }); - } - - // skip this test if using a remote relay since updating the env vars would not affect it - if (global.relayIsLocal) { - describe('DEV_MODE = true', async function () { - before(async () => { - process.env.DEV_MODE = 'true'; - }); - - after(async () => { - process.env.DEV_MODE = 'false'; - }); - - for (let i = 0; i < payableMethodsData.length; i++) { - it(`Payable method ${payableMethodsData[i].method} throws an error`, async function () { - await relay.callFailing( - RelayCall.ETH_ENDPOINTS.ETH_GET_TRANSACTION_BY_HASH, - [hashes[i]], - predefined.CONTRACT_REVERT(payableMethodsData[i].message, payableMethodsData[i].errorData), - requestId, - ); - }); - } - }); - } - }); - describe('eth_call for reverted pure contract calls', async function () { beforeEach(async () => { requestId = Utils.generateRequestId();