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

fix: estimate_gas doesn't reflect changes in mirror-node #2409

Merged

Conversation

victor-yanev
Copy link
Contributor

@victor-yanev victor-yanev commented Apr 25, 2024

Description:
This PR updates the fallback calculations of estimateGas (in cases where the request to mirror node fails):

  • for contract create tx we reuse the Precheck.transactionIntrinsicGasCost method
  • for contract call tx we have a new constant TX_CONTRACT_CALL_AVERAGE_GAS: 500_000 which we use instead of using TX_DEFAULT_GAS: 400_000
    • Note: 500_000 is an informed guess which adds a small buffer on top of the default gas of 400_000
    • Couldn't come up with an exact value which might be "correct" most of the times and the 400_000 which is set for TX_DEFAULT_GAS is definitely not enough for contract calls and in some scenarios the method would return insufficient amount of gas as an estimation.
    • We can watch out for related bugs and update this to a different value later if we find that it's not sufficient again or if it's giving too large of an estimation

Related issue(s):

Fixes #2379

Notes for reviewer:

Checklist

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

Copy link

github-actions bot commented Apr 25, 2024

Acceptance Tests

     20 files     301 suites   34m 42s ⏱️
   602 tests    598 ✔️   3 💤 1
1 026 runs  1 011 ✔️ 11 💤 4

Results for commit 436558f.

♻️ This comment has been updated with latest results.

…t-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts
…t-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts
Copy link

github-actions bot commented Apr 29, 2024

Tests

    2 files  157 suites   14s ⏱️
852 tests 851 ✔️ 1 💤 0
864 runs  863 ✔️ 1 💤 0

Results for commit 436558f.

♻️ This comment has been updated with latest results.

@victor-yanev victor-yanev marked this pull request as ready for review April 29, 2024 14:49
@victor-yanev victor-yanev added the bug Something isn't working label May 2, 2024
Copy link
Collaborator

@konstantinabl konstantinabl left a comment

Choose a reason for hiding this comment

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

Amazing work! Few nits

@konstantinabl
Copy link
Collaborator

If possible fix some of the SonarCloud issues

Copy link

sonarqubecloud bot commented May 9, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

…n-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts
#	packages/relay/tests/lib/eth/eth_call.spec.ts
#	packages/relay/tests/lib/eth/eth_estimateGas.spec.ts
@victor-yanev victor-yanev requested review from Nana-EC and a team as code owners June 10, 2024 12:02
@victor-yanev victor-yanev requested review from a team and georgi-l95 as code owners June 10, 2024 12:02
…n-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts
#	packages/relay/tests/lib/eth/eth_call.spec.ts
#	packages/relay/tests/lib/eth/eth_estimateGas.spec.ts
@victor-yanev victor-yanev added this to the 0.50.0 milestone Jun 11, 2024
…n-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/precheck.ts
…n-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/precheck.ts
@quiet-node quiet-node modified the milestones: 0.50.0, 0.51.0 Jun 17, 2024
Copy link
Contributor

@ebadiere ebadiere left a comment

Choose a reason for hiding this comment

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

Please resolve the merge issue.

…n-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/clients/mirrorNodeClient.ts
…n-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/clients/mirrorNodeClient.ts
Copy link

@ebadiere ebadiere modified the milestones: 0.51.0, 0.52.0 Jul 1, 2024
Copy link
Collaborator

@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

@victor-yanev victor-yanev merged commit f458e38 into main Jul 9, 2024
37 checks passed
@victor-yanev victor-yanev deleted the 2379-estimate_gas-does-not-reflect-changes-in-mirror-node branch July 9, 2024 10:35
ebadiere pushed a commit that referenced this pull request Jul 9, 2024
* fix: estimate_gas doesn't reflect changes in mirror-node

Signed-off-by: Victor Yanev <[email protected]>

* fix: estimate_gas doesn't reflect changes in mirror-node

Signed-off-by: Victor Yanev <[email protected]>

* fix: tests in eth_estimateGas.spec.ts

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'refs/heads/main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts

* chore: simplify isNonZeroValue condition

Signed-off-by: Victor Yanev <[email protected]>

* chore: add docs + fix compilation errors

Signed-off-by: Victor Yanev <[email protected]>

* chore: fix remaining sonar issues

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts
#	packages/relay/tests/lib/eth/eth_call.spec.ts
#	packages/relay/tests/lib/eth/eth_estimateGas.spec.ts

* chore: revert changes to EthImpl#call

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/precheck.ts

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/clients/mirrorNodeClient.ts

---------

Signed-off-by: Victor Yanev <[email protected]>
Signed-off-by: ebadiere <[email protected]>
ebadiere pushed a commit that referenced this pull request Jul 9, 2024
* fix: estimate_gas doesn't reflect changes in mirror-node

Signed-off-by: Victor Yanev <[email protected]>

* fix: estimate_gas doesn't reflect changes in mirror-node

Signed-off-by: Victor Yanev <[email protected]>

* fix: tests in eth_estimateGas.spec.ts

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'refs/heads/main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts

* chore: simplify isNonZeroValue condition

Signed-off-by: Victor Yanev <[email protected]>

* chore: add docs + fix compilation errors

Signed-off-by: Victor Yanev <[email protected]>

* chore: fix remaining sonar issues

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts
#	packages/relay/tests/lib/eth/eth_call.spec.ts
#	packages/relay/tests/lib/eth/eth_estimateGas.spec.ts

* chore: revert changes to EthImpl#call

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/precheck.ts

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/clients/mirrorNodeClient.ts

---------

Signed-off-by: Victor Yanev <[email protected]>
Signed-off-by: ebadiere <[email protected]>
ebadiere pushed a commit that referenced this pull request Aug 1, 2024
* fix: estimate_gas doesn't reflect changes in mirror-node

Signed-off-by: Victor Yanev <[email protected]>

* fix: estimate_gas doesn't reflect changes in mirror-node

Signed-off-by: Victor Yanev <[email protected]>

* fix: tests in eth_estimateGas.spec.ts

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'refs/heads/main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts

* chore: simplify isNonZeroValue condition

Signed-off-by: Victor Yanev <[email protected]>

* chore: add docs + fix compilation errors

Signed-off-by: Victor Yanev <[email protected]>

* chore: fix remaining sonar issues

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/eth.ts
#	packages/relay/tests/lib/eth/eth_call.spec.ts
#	packages/relay/tests/lib/eth/eth_estimateGas.spec.ts

* chore: revert changes to EthImpl#call

Signed-off-by: Victor Yanev <[email protected]>

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/precheck.ts

* Merge branch 'main' into 2379-estimate_gas-does-not-reflect-changes-in-mirror-node

Signed-off-by: Victor Yanev <[email protected]>

# Conflicts:
#	packages/relay/src/lib/clients/mirrorNodeClient.ts

---------

Signed-off-by: Victor Yanev <[email protected]>
Signed-off-by: ebadiere <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working limechain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

estimate_gas doesn't reflect changes in mirror-node
6 participants