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

Wallet nonce is negative if it has never been used before on a chain #50

Open
fengtality opened this issue Mar 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@fengtality
Copy link
Sponsor Contributor

fengtality commented Mar 6, 2023

Describe the bug

If a users tries to use Gateway to send transactions with a wallet that has never been used before on a chain, Gateway throws errors because it tried to apply a negative nonce.

Steps To Reproduce

  • Use a new wallet on a chain
  • Approve a token, and get error
{
    "message": "Unknown error.",
    "httpErrorCode": 503,
    "errorCode": 1099,
    "stack": "Error: invalid hexlify value [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT ] (operation=\"checkSafeInteger\", fault=\"out-of-safe-range\", value=-1, code=NUMERIC_FAULT, version=bytes/5.7.0)\n    at Logger.makeError (/Users/feng/Code/gateway/node_modules/@ethersproject/wallet/node_modules/@ethersproject/logger/lib/index.js:238:21)\n    at Logger.throwError (/Users/feng/Code/gateway/node_modules/@ethersproject/wallet/node_modules/@ethersproject/logger/lib/index.js:247:20)\n    at Logger.checkSafeUint53 (/Users/feng/Code/gateway/node_modules/@ethersproject/wallet/node_modules/@ethersproject/logger/lib/index.js:285:18)\n    at hexlify (/Users/feng/Code/gateway/node_modules/@ethersproject/wallet/node_modules/@ethersproject/bytes/lib/index.js:151:16)\n    at /Users/feng/Code/gateway/node_modules/@ethersproject/wallet/node_modules/@ethersproject/transactions/lib/index.js:181:59\n    at Array.forEach (<anonymous>)\n    at _serialize (/Users/feng/Code/gateway/node_modules/@ethersproject/wallet/node_modules/@ethersproject/transactions/lib/index.js:175:23)\n    at serialize (/Users/feng/Code/gateway/node_modules/@ethersproject/wallet/node_modules/@ethersproject/transactions/lib/index.js:246:16)\n    at /Users/feng/Code/gateway/node_modules/@ethersproject/wallet/lib/index.js:163:116\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
}
  • Run /evm/nonce route:
{
    "nonce": -2
}

Proposed fix

Adjust /evm/nonce so that it is floored at 0 and make corresponding adjustments to nextNonce, etc

@fengtality fengtality added the bug Something isn't working label Mar 6, 2023
@fengtality
Copy link
Sponsor Contributor Author

Workaround: execute a transaction with the wallet using DEX interface, like wrapping a token. Afterwards, Gateway will compute the nonce correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant