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

Add NodeGateway retrying nonce requests if response outdated #1946

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

davidyuk
Copy link
Member

@davidyuk davidyuk commented Feb 15, 2024

This PR is supported by the Æternity Crypto Foundation

We are retrying requests multiple times if the response status code is 404 or so. It is made because a public API gateway has a load balancer, and some nodes behind it can be a bit unsynced producing outdated results. The same issue with nonce tracking, node can return an outdated nonce, but it is much harder to detect. A wrong nonce completely blocks tx mining (see aeternity/aeternity#4173).

To solve this problem I've implemented a class inherited from Node. This class extracts nonces from submitted transactions and if the nonce returned by node looks outdated then it retries the request the same way if it would be 404. Sdk tests became much more stable using this on testnet.

A general solution would be #291.

@davidyuk davidyuk added this to the v13.3.0 milestone Feb 15, 2024
@davidyuk davidyuk force-pushed the feature/test-on-testnet branch 2 times, most recently from dcd5562 to 49c6024 Compare February 15, 2024 08:18
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 79.89%. Comparing base (a21bc1f) to head (27d1a4c).
Report is 1 commits behind head on develop.

Files Patch % Lines
src/node/Gateway.ts 78.04% 5 Missing and 4 partials ⚠️
src/node/Direct.ts 94.59% 0 Missing and 2 partials ⚠️
src/node/Base.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1946      +/-   ##
===========================================
- Coverage    79.91%   79.89%   -0.02%     
===========================================
  Files          101      103       +2     
  Lines         3450     3497      +47     
  Branches       733      742       +9     
===========================================
+ Hits          2757     2794      +37     
- Misses         381      386       +5     
- Partials       312      317       +5     

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

Copy link
Member

@dincho dincho left a comment

Choose a reason for hiding this comment

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

I did only functional review. This is formal approval of the new strategy not the codebase/implementation.

If I understand it correctly this changes are making sure that the gateway/node/backend nonce is in sync with the SDK instance (kind of/partially). In general I don’t see possible regressions (other than extra error that must be probably handled by the apps), and only eventual improvement.

@dincho
Copy link
Member

dincho commented Feb 15, 2024

I think the default 8 retries are a bit too much, while currently there are no RPS limits we'll implement it at some point (as protection measure) which can cause issues.

In general I don't think the SDK should care about of the "gateway" concepts and should tread it as ordinal node/API backend, however the user/developer should be able to choose the proposed nonce strategy for any backend.

Also hardcoding the endpoints also sounds like a bad idea, yes we should keep them as defaults, but the users should be able to change it?

@dincho
Copy link
Member

dincho commented Feb 15, 2024

Also hardcoding the endpoints also sounds like a bad idea, yes we should keep them as defaults, but the users should be able to change it?

Okay I was confused (didn't fully read) these lines: https://github.com/aeternity/aepp-sdk-js/pull/1946/files#diff-9f5cadd5139250f5eef2e796974c1db0f422f7adb4541f5b5b356a26c54711afR43

It still means one would get the waring if they don't use our gateways? A bit annoying I guess as there are multiple environments, user nodes, hyperchains etc.

@davidyuk
Copy link
Member Author

It still means one would get the waring if they don't use our gateways?

It is a hint to use NodeGateway in case the old Node class is used with our API gateways.

@davidyuk davidyuk changed the title test: add ability to run on testnet, mainnet Add NodeGateway retrying nonce requests if response outdated Mar 2, 2024
@davidyuk davidyuk marked this pull request as draft March 2, 2024 10:56
@davidyuk davidyuk modified the milestones: v13.3.0, v13.4.0 Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants