Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement MirrorNodeContractQuery #2073

Merged
merged 19 commits into from
Dec 11, 2024

Conversation

0xivanov
Copy link
Contributor

@0xivanov 0xivanov commented Nov 11, 2024

Description:

A new MirrorNodeContractQuery class has been introduced to support EVM gas estimation and simulation. This query class provides two distinct types of queries:

  1. MirrorNodeContractCallQuery – Executes a contract call and returns the result, simulating the execution of the contract.
  2. MirrorNodeContractEstimateGasQuery – Estimates the gas usage for a contract call, allowing developers to understand the cost of executing a transaction.

The inputs for these queries match those of ContractExecuteTransaction, making it easy for developers to calculate the cost of a follow-up transaction.

The MirrorNodeContractQuery issues an HTTP request to the api/v1/contracts/call endpoint of the Mirror Node Web3 module, which supports both gas estimation and transient simulation of state-changing transactions. This enables accurate cost predictions and helps developers optimize their contract interactions before executing them on the network.

Related issue(s):

Fixes #2076

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Ivan Ivanov <[email protected]>
@0xivanov 0xivanov self-assigned this Nov 11, 2024
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
@0xivanov 0xivanov changed the title feat(wip): Implement MirrorNodeContractQuery feat: Implement MirrorNodeContractQuery Nov 12, 2024
Copy link

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start.
Missing some fields.
Also you might be able to leverage some Mirror Node web3 module tests as references of example calls.
@kselveliev should be able to help

@0xivanov 0xivanov marked this pull request as ready for review November 14, 2024 11:55
@0xivanov 0xivanov requested a review from a team as a code owner November 14, 2024 11:55
@0xivanov 0xivanov requested a review from agadzhalov November 14, 2024 11:55
Signed-off-by: Ivan Ivanov <[email protected]>
@0xivanov 0xivanov requested review from a team as code owners November 14, 2024 12:33
@0xivanov 0xivanov requested a review from dalvizu November 14, 2024 12:33
rbarkerSL
rbarkerSL previously approved these changes Nov 19, 2024
Copy link
Contributor

@rbarkerSL rbarkerSL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval applies to gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts

Signed-off-by: Ivan Ivanov <[email protected]>
kselveliev
kselveliev previously approved these changes Nov 19, 2024
Copy link

@kselveliev kselveliev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 91.59664% with 10 lines in your changes missing coverage. Please review.

Project coverage is 83.14%. Comparing base (b86ee46) to head (7a5c88b).
Report is 187 commits behind head on main.

Files with missing lines Patch % Lines
.../hedera/hashgraph/sdk/MirrorNodeContractQuery.java 92.85% 3 Missing and 3 partials ⚠️
.../java/com/hedera/hashgraph/sdk/EntityIdHelper.java 86.20% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2073      +/-   ##
============================================
+ Coverage     82.20%   83.14%   +0.94%     
- Complexity     3588     4029     +441     
============================================
  Files           186      202      +16     
  Lines         11697    12820    +1123     
  Branches       1150     1266     +116     
============================================
+ Hits           9615    10659    +1044     
- Misses         1604     1701      +97     
+ Partials        478      460      -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Ivan Ivanov <[email protected]>
@0xivanov 0xivanov added the enhancement New feature or request label Dec 2, 2024
@0xivanov
Copy link
Contributor Author

0xivanov commented Dec 2, 2024

Hey @Nana-EC @SimiHunjan can you please take a look at the updated version of the queries?
You can focus on the exposed APIs and not so much the business logic.

Copy link

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, some comments

Signed-off-by: Ivan Ivanov <[email protected]>
agadzhalov
agadzhalov previously approved these changes Dec 10, 2024
san-est
san-est previously approved these changes Dec 10, 2024
Copy link

@san-est san-est left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applies to files owned by us: gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts

Copy link

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, left some details on the examples section

Signed-off-by: Ivan Ivanov <[email protected]>
@0xivanov 0xivanov dismissed stale reviews from san-est and agadzhalov via 7a5c88b December 10, 2024 19:54
Copy link

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thanks

Signed-off-by: Ivan Ivanov <[email protected]>
Copy link

@san-est san-est left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-approving:
applies to files owned by us: gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts

@0xivanov 0xivanov merged commit 88d1dcc into main Dec 11, 2024
7 checks passed
@0xivanov 0xivanov deleted the implement-MirrorNodeContractQuery- branch December 11, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement MirrorNodeContractQuery
7 participants