Skip to content

Commit e4728fb

Browse files
AlfredoG87Ivo-Yankovgeorgi-l95
authored
Cherry pick PR 1012 into 0.22 release (#1109)
Precompile acceptance tests for eth_call with Mirror node (#1012) * test: acceptance tests for eth_call with precompiles * feat: add new CI * remove workaround * fix workflow * test: add negative tests * chore: fix unintended change * fix: assertions for custom fees * chore: bump mirror version and disable failing tests * chore: bump mirror node version * chore: fix failing tests --------- Signed-off-by: Ivo Yankov <[email protected]> Signed-off-by: georgi-l95 <[email protected]> Signed-off-by: Alfredo Gutierrez <[email protected]> Co-authored-by: Ivo Yankov <[email protected]> Co-authored-by: georgi-l95 <[email protected]>
1 parent 219a65d commit e4728fb

File tree

19 files changed

+2716
-30
lines changed

19 files changed

+2716
-30
lines changed

.github/workflows/acceptance.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ jobs:
5656
with:
5757
testfilter: htsprecompilev1
5858

59+
precompilecalls:
60+
name: Precompile
61+
uses: ./.github/workflows/acceptance-workflow.yml
62+
with:
63+
testfilter: precompile
64+
5965
websocket:
6066
name: Websocket
6167
uses: ./.github/workflows/acceptance-workflow.yml

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"acceptancetest:htsprecompilev1": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@htsprecompilev1' --exit",
3333
"acceptancetest:release": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@release' --exit",
3434
"acceptancetest:ws": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@web-socket' --exit",
35+
"acceptancetest:precompile": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@precompile-calls' --exit",
3536
"build": "npx lerna run build",
3637
"build-and-test": "npx lerna run build && npx lerna run test",
3738
"build:docker": "docker build . -t ${npm_package_name}",

packages/relay/src/lib/eth.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,22 +1042,19 @@ export class EthImpl implements Eth {
10421042
// ETH_CALL_DEFAULT_TO_CONSENSUS_NODE = false enables the use of Mirror node
10431043
if (process.env.ETH_CALL_DEFAULT_TO_CONSENSUS_NODE == 'false') {
10441044
//temporary workaround until precompiles are implemented in Mirror node evm module
1045-
const isHts = await this.mirrorNodeClient.resolveEntityType(call.to, requestId, [constants.TYPE_TOKEN]);
1046-
if (!(isHts?.type === constants.TYPE_TOKEN)) {
1047-
// Execute the call and get the response
1048-
this.logger.debug(`${requestIdPrefix} Making eth_call on contract ${call.to} with gas ${gas} and call data "${call.data}" from "${call.from}" using mirror-node.`, call.to, gas, call.data, call.from);
1049-
const callData = {
1050-
...call,
1051-
gas,
1052-
value,
1053-
estimate: false
1054-
}
1055-
const contractCallResponse = await this.mirrorNodeClient.postContractCall(callData, requestId);
1056-
if (contractCallResponse && contractCallResponse.result) {
1057-
return EthImpl.prepend0x(contractCallResponse.result);
1058-
}
1059-
return EthImpl.emptyHex;
1045+
// Execute the call and get the response
1046+
this.logger.debug(`${requestIdPrefix} Making eth_call on contract ${call.to} with gas ${gas} and call data "${call.data}" from "${call.from}" using mirror-node.`, call.to, gas, call.data, call.from);
1047+
const callData = {
1048+
...call,
1049+
gas,
1050+
value,
1051+
estimate: false
1052+
}
1053+
const contractCallResponse = await this.mirrorNodeClient.postContractCall(callData, requestId);
1054+
if (contractCallResponse && contractCallResponse.result) {
1055+
return EthImpl.prepend0x(contractCallResponse.result);
10601056
}
1057+
return EthImpl.emptyHex;
10611058
}
10621059

10631060
return await this.callConsensusNode(call, gas, requestId);

0 commit comments

Comments
 (0)