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/live 15551 aptos refactor cache for get estimated gas #8848

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

may01
Copy link
Contributor

@may01 may01 commented Jan 8, 2025

βœ… Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • aptos fee estimation

πŸ“ Description

The cache for transaction fees was broken, and after the removal of the advanced transaction settings, there is unnecessary logic and structures remaining in the code.

Issues that were resolved:

  • The cached value was stored to the wrong key in some cases.
  • Removed redundant call to estimate the gas price. Now, the price is taken from the simulation.
  • Optional parameters corresponding to advanced user input have been removed.
  • Previously, the simulation used default parameters for the first call and estimated parameters for subsequent calls, which created potential side effects. Now, all simulations use default parameters (gasPrice, gasAmount).
  • If the simulation fails, we now set default values instead of using the latest estimated value.
  • The transaction status check has been updated to use only relevant parameters.

❓ Context

  • JIRA or GitHub link:

🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@may01 may01 requested a review from a team as a code owner January 8, 2025 23:41
Copy link

vercel bot commented Jan 8, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
web-tools ❌ Failed (Inspect) Jan 10, 2025 4:21pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2025 4:21pm
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2025 4:21pm
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2025 4:21pm

semeano
semeano previously approved these changes Jan 9, 2025
@may01 may01 requested review from jccguimaraes and semeano January 9, 2025 14:11
@may01 may01 requested review from a team as code owners January 9, 2025 14:27
@live-github-bot live-github-bot bot added desktop Has changes in LLD mobile Has changes in LLM ui Has changes in the design system library ledgerjs Has changes in the ledgerjs open source libs automation CI/CD stuff translations Translation files have been touched screenshots Screenshots have been updated labels Jan 9, 2025
@ledger-wiz-cspm-secret-detection
Copy link

ledger-wiz-cspm-secret-detection bot commented Jan 9, 2025

Wiz Scan Summary

Scanner Findings
Data Finding Sensitive Data
Secret Finding Secrets
IaC Misconfiguration IaC Misconfigurations
Total

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@ledger-wiz-cspm-secret-detection

Wiz Scan Summary

Scanner Findings
Data Finding Sensitive Data 2 Info
Secret Finding Secrets
IaC Misconfiguration IaC Misconfigurations
Total 2 Info

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.


if (!CACHE.has(key)) {
CACHE.set(key, await getFee(account, transaction, aptosClient));
if (!CACHE.amount.eq(transaction.amount)) {
Copy link
Member

Choose a reason for hiding this comment

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

@hedi-edelbloute does makeLRUCache removes the need for the CACHE?

@may01 may01 requested a review from jccguimaraes January 10, 2025 10:58
@may01 may01 force-pushed the feat/LIVE-15551-aptos-refactor-cache-for-get-estimated-gas branch from c362c13 to aad4ecf Compare January 10, 2025 11:48
@@ -64,10 +64,8 @@ const aptos: CurrenciesData<Transaction> = {
family: "aptos",
mode: "send",
fees: "1100",
options: '{ "maxGasAmount": "11", "gasUnitPrice": "100" }',
estimate:
options:
'{ "maxGasAmount": "11", "gasUnitPrice": "100", "sequenceNumber": "1", "expirationTimestampSecs": "1734535375" }',
Copy link
Contributor

Choose a reason for hiding this comment

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

wasn't sequenceNumber and expirationTimestampSecs removed?

Copy link
Member

Choose a reason for hiding this comment

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

this is a good point. If it was removed, how did it not failed? πŸ€”

@may01 may01 force-pushed the feat/LIVE-15551-aptos-refactor-cache-for-get-estimated-gas branch from d35af06 to d2fbe96 Compare January 10, 2025 16:18
@semeano semeano self-requested a review January 10, 2025 17:08
Copy link
Contributor

@semeano semeano left a comment

Choose a reason for hiding this comment

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

Check my latest comments

Comment on lines 977 to 979
"SequenceNumberError": {
"title": "Sequence number error",
"description": "Please close the window and try again later"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be removed also?

@@ -415,7 +411,6 @@ describe("Aptos API", () => {
options: {
maxGasAmount: Number(options.maxGasAmount),
gasUnitPrice: Number(options.gasUnitPrice),
accountSequenceNumber: Number(options.sequenceNumber),
expireTimestamp: 120,
Copy link
Contributor

@semeano semeano Jan 10, 2025

Choose a reason for hiding this comment

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

Do we need this line? ---> expireTimestamp: 120,

expect(result).toEqual(expected);
});
});

describe("with vm_status as INSUFFICIENT_BALANCE", () => {
it("should return a fee estimation object", async () => {
simulateTransaction = jest.fn(() => [
{
success: false,
vm_status: ["INSUFFICIENT_BALANCE"],
expiration_timestamp_secs: 5,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we keep this line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Has changes in live-common desktop Has changes in LLD mobile Has changes in LLM translations Translation files have been touched
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants