-
Notifications
You must be signed in to change notification settings - Fork 119
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
MirrorNodeContractQuery
MirrorNodeContractQuery
There was a problem hiding this 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
sdk/src/main/java/com/hedera/hashgraph/sdk/MirrorNodeContractQuery.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
sdk/src/main/java/com/hedera/hashgraph/sdk/MirrorNodeContractQuery.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ivan Ivanov <[email protected]>
...n/java/com/hedera/hashgraph/sdk/test/integration/MirrorNodeContractQueryIntegrationTest.java
Show resolved
Hide resolved
@@ -40,7 +42,7 @@ | |||
/** | |||
* Utility class used internally by the sdk. | |||
*/ | |||
class EntityIdHelper { | |||
public class EntityIdHelper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
Made this class public in order to access it from the tests, changed most public methods to package private
There was a problem hiding this 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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2073 +/- ##
============================================
+ Coverage 82.20% 82.70% +0.50%
- Complexity 3588 3975 +387
============================================
Files 186 200 +14
Lines 11697 12825 +1128
Branches 1150 1263 +113
============================================
+ Hits 9615 10607 +992
- Misses 1604 1717 +113
- Partials 478 501 +23 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
* MirrorNodeContractQuery returns a result from EVM execution such as cost-free execution of read-only smart contract | ||
* queries, gas estimation, and transient simulation of read-write operations. | ||
*/ | ||
public class MirrorNodeContractQuery { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I responded to the in the Notion page, but also wanted to write a comment here that the name of the API is a bit vague to intuitively understand what it does.
This API allows the dev to estimate the cost of gas for a given contract call using the mirror node. I know you mentioned you wanted to differentiate a call to the mirror node vs consensus node. I am not sure if that matters as much as using a name that someone can easily understand what task they can achieve.
The proposed design had ContractEstimateGasQuery() which clearly indicates what this API is used for. Are there issues going with that naming convention for this API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR and the notion page. Introducing 2 new APIs: MirrorNodeContractCallQuery
and MirrorNodeContractEstimateGasQuery
Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
.execute(client); | ||
|
||
/* | ||
* Step 5: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Step 5: | |
* Step 6: |
Description:
A new
MirrorNodeContractQuery
class has been introduced to support EVM gas estimation and simulation. This query class provides two distinct types of queries:MirrorNodeContractCallQuery
– Executes a contract call and returns the result, simulating the execution of the contract.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 theapi/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