Skip to content

Commit 2542efb

Browse files
committed
fix: throw COULD_NOT_SIMULATE_TRANSACTION for eth_gasPrice
Signed-off-by: Logan Nguyen <[email protected]>
1 parent 5e834c7 commit 2542efb

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

packages/relay/src/lib/services/ethService/contractService/ContractService.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import constants from '../../../constants';
1616
import { JsonRpcError, predefined } from '../../../errors/JsonRpcError';
1717
import { MirrorNodeClientError } from '../../../errors/MirrorNodeClientError';
1818
import { Log } from '../../../model';
19-
import { Precheck } from '../../../precheck';
2019
import { IContractCallRequest, IContractCallResponse, IGetLogsParams, RequestDetails } from '../../../types';
2120
import { CacheService } from '../../cacheService/cacheService';
2221
import { CommonService } from '../../ethService/ethCommonService/CommonService';
@@ -525,14 +524,12 @@ export class ContractService implements IContractService {
525524
}
526525

527526
if (e.isContractRevert()) {
528-
if (this.logger.isLevelEnabled('trace')) {
529-
this.logger.trace(
530-
`mirror node eth_call request encountered contract revert. message: ${e.message}, details: ${e.detail}, data: ${e.data}`,
531-
);
532-
}
533-
return predefined.CONTRACT_REVERT(e.detail || e.message, e.data);
527+
throw predefined.CONTRACT_REVERT(e.detail || e.message, e.data);
528+
} else if (e.statusCode === 400) {
529+
throw predefined.COULD_NOT_SIMULATE_TRANSACTION(e.detail || e.message);
534530
}
535-
// for any other Mirror Node upstream server errors (429, 500, 502, 503, 504, etc.), preserve the original error and re-throw to the upper layer
531+
532+
// for any other Mirror Node upstream server errors (429, 500, 502, 503, 504, etc.), preserve the original error and re-throw to the upper layer for further handling logic
536533
throw e;
537534
}
538535

packages/relay/src/lib/services/ethService/ethCommonService/CommonService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export class CommonService implements ICommonService {
458458
}
459459
}
460460

461-
throw predefined.COULD_NOT_ESTIMATE_GAS_PRICE('Failed to retrieve gas price from network fees');
461+
throw predefined.INTERNAL_ERROR('Failed to retrieve gas price from network fees');
462462
}
463463

464464
/**

packages/relay/tests/lib/eth/eth_gasPrice.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('@ethGasPrice Gas Price spec', async function () {
8484

8585
restMock.onGet(`network/fees`).reply(200, JSON.stringify(partialNetworkFees));
8686
await RelayAssertions.assertRejection(
87-
predefined.COULD_NOT_ESTIMATE_GAS_PRICE('Failed to retrieve gas price from network fees'),
87+
predefined.INTERNAL_ERROR('Failed to retrieve gas price from network fees'),
8888
ethImpl.gasPrice,
8989
true,
9090
ethImpl,
@@ -140,7 +140,7 @@ describe('@ethGasPrice Gas Price spec', async function () {
140140

141141
it('eth_gasPrice with no network fees records found', async function () {
142142
await RelayAssertions.assertRejection(
143-
predefined.COULD_NOT_ESTIMATE_GAS_PRICE('Failed to retrieve gas price from network fees'),
143+
predefined.INTERNAL_ERROR('Failed to retrieve gas price from network fees'),
144144
ethImpl.gasPrice,
145145
true,
146146
ethImpl,

packages/server/tests/acceptance/htsPrecompile/precompileCalls.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,11 @@ describe('@precompile-calls Tests for eth_call with HTS', async function () {
741741
data: CALLDATA_BALANCE_OF + NON_EXISTING_ACCOUNT.padStart(64, '0'),
742742
};
743743

744-
await relay.callFailing(Constants.ETH_ENDPOINTS.ETH_CALL, [callData, 'latest'], predefined.CONTRACT_REVERT());
744+
await relay.callFailing(
745+
Constants.ETH_ENDPOINTS.ETH_CALL,
746+
[callData, 'latest'],
747+
predefined.COULD_NOT_SIMULATE_TRANSACTION('Sender account not found.'),
748+
);
745749
});
746750

747751
it('Call to allowance method of an HTS token with non-existing owner account in call data returns error', async () => {

0 commit comments

Comments
 (0)