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: enabled retrieval of network gasPrice in sendRawTransaction using MAPI instead of HAPI. #2981

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

quiet-node
Copy link
Member

@quiet-node quiet-node commented Sep 13, 2024

Description:

This PR enables sendRawTransaction to retrieve the current gasPrice of the network via the mirror node, instead of querying the consensus node for the fee schedule file. By switching to MAPI, the relay operator account can avoid incurring costs associated with MAPI queries.

Related issue(s):

Fixes #2979

Notes for reviewer:
This PR utilizes the gasPrice() method in the eth.ts module for sendRawTransaction to take advantage of querying the gasPrice through the mirror node. If that query fails, it falls back to querying the consensus node for the fee schedule using the getTinybarGasFee method in the sdkClient.

Checklist

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

@quiet-node quiet-node added the enhancement New feature or request label Sep 13, 2024
@quiet-node quiet-node added this to the 0.55.0 milestone Sep 13, 2024
@quiet-node quiet-node self-assigned this Sep 13, 2024
@quiet-node quiet-node linked an issue Sep 13, 2024 that may be closed by this pull request
@quiet-node quiet-node changed the title feat: enabled retrieving gasPrice using MAPI instead of HAPI feat: enabled retrieving network gasPrice in sendRawTransaction using MAPI instead of HAPI Sep 13, 2024
@quiet-node quiet-node changed the title feat: enabled retrieving network gasPrice in sendRawTransaction using MAPI instead of HAPI feat: enabled retrieval of network gasPrice in sendRawTransaction using MAPI instead of HAPI. Sep 13, 2024
Copy link

github-actions bot commented Sep 13, 2024

Tests

       3 files     274 suites   19s ⏱️
1 289 tests 1 288 ✔️ 1 💤 0
1 298 runs  1 297 ✔️ 1 💤 0

Results for commit f80b338.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Sep 13, 2024

Acceptance Tests

  17 files  225 suites   29m 34s ⏱️
601 tests 586 ✔️ 4 💤 11
734 runs  719 ✔️ 4 💤 11

Results for commit f80b338.

♻️ This comment has been updated with latest results.

ebadiere
ebadiere previously approved these changes Sep 13, 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.

LG.

packages/relay/src/lib/eth.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/eth.ts Outdated Show resolved Hide resolved
Signed-off-by: Logan Nguyen <[email protected]>

Revert "fix: updated getFeeWeibars"

This reverts commit 94b1f9d.

Revert "fix: updated getFeeWeibars"

Signed-off-by: Logan Nguyen <[email protected]>
@quiet-node quiet-node force-pushed the 2979-query-the-mirror-node-for-gas-fees branch from 94b1f9d to 80aea11 Compare September 14, 2024 00:21
Nana-EC
Nana-EC previously approved these changes Sep 14, 2024
@ebadiere ebadiere self-requested a review September 16, 2024 15:23
ebadiere
ebadiere previously approved these changes Sep 16, 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.

LG

@quiet-node quiet-node dismissed stale reviews from ebadiere and Nana-EC via f80b338 September 16, 2024 16:01
Copy link

@ebadiere ebadiere self-requested a review September 16, 2024 20:55
Copy link
Contributor

@victor-yanev victor-yanev left a comment

Choose a reason for hiding this comment

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

I'm not sure why we want to set the maxTransactionFee to MAX_GAS_PER_SEC. 🤔

Is this a realistic scenario for the relay operator to pay that much for a transaction?

@quiet-node
Copy link
Member Author

I'm not sure why we want to set the maxTransactionFee to MAX_GAS_PER_SEC. 🤔

Is this a realistic scenario for the relay operator to pay that much for a transaction?

That's a valid concern. Please create a new ticket and move the conversation there. This PR focuses on the logic of utilizing MAPI instead of HAPI to get the gasPrice of the network.

@quiet-node quiet-node merged commit ef3dd83 into main Sep 17, 2024
39 checks passed
@quiet-node quiet-node deleted the 2979-query-the-mirror-node-for-gas-fees branch September 17, 2024 14:42
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.39%. Comparing base (f55c304) to head (f80b338).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
packages/relay/src/lib/eth.ts 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2981      +/-   ##
==========================================
+ Coverage   89.54%   91.39%   +1.85%     
==========================================
  Files          56       59       +3     
  Lines        3796     3950     +154     
  Branches      775      809      +34     
==========================================
+ Hits         3399     3610     +211     
+ Misses        350      291      -59     
- Partials       47       49       +2     
Flag Coverage Δ
relay 89.68% <93.33%> (ø)
server 88.15% <ø> (ø)
ws-server 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/relay/src/formatters.ts 78.76% <100.00%> (ø)
packages/relay/src/lib/clients/sdkClient.ts 68.61% <100.00%> (+5.85%) ⬆️
packages/relay/src/lib/constants.ts 100.00% <100.00%> (+9.30%) ⬆️
packages/relay/src/lib/precheck.ts 96.11% <100.00%> (+0.97%) ⬆️
packages/relay/src/lib/eth.ts 92.74% <83.33%> (+3.92%) ⬆️

... and 8 files with indirect coverage changes

@quiet-node quiet-node modified the milestones: 0.55.0, 0.56.0 Sep 17, 2024
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.

Query the mirror node for gas fees
4 participants