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

transaction.chainId/signature.v mismatch error when signing transactions using Ledger #3647

Closed
michalinacienciala opened this issue Oct 27, 2023 · 9 comments · Fixed by #3650

Comments

@michalinacienciala
Copy link
Contributor

michalinacienciala commented Oct 27, 2023

I did some tests of staking in the Subscape dapp (I used the stage-live deployment) on Ethereum Sepolia and although some staking transactions were successful, some failed with the following errors in the wallet logs:

logger.ts:208 Error encountered! ledgerID: LEDGER_NANO_S_0x43866d77672dd19252e8ea2274ecece9c62d3262 transactionRequest: [object Object] error: Error: transaction.chainId/signature.v mismatch (argument="signature", value={"r":"0x2b069505b96a272c34d3820efdec59442b4424d4362bec7af2e368150df6a9c3","s":"0x4efc2c085a3688549d2ede91647168de8dbdd45434ab602fcefcaf69c906aaf6","v":843518}, code=INVALID_ARGUMENT, version=transactions/5.7.0)

and

Error signing transaction Error: transaction.chainId/signature.v mismatch (argument="signature", value={"r":"0x2b069505b96a272c34d3820efdec59442b4424d4362bec7af2e368150df6a9c3","s":"0x4efc2c085a3688549d2ede91647168de8dbdd45434ab602fcefcaf69c906aaf6","v":843518}, code=INVALID_ARGUMENT, version=transactions/5.7.0)
    at Logger.makeError (index.js:224:23)
    at Logger.throwError (index.js:233:20)
    at Logger.throwArgumentError (index.js:236:21)
    at _serialize (index.js:204:20)
    at serialize (index.js:221:16)
    at index.ts:415:35

and

ProviderBridgeService.routeContentScriptRPCRequest
Error processing request

I used version 0.50.0c1e7552 of the wallet and used Ledger Nano S (2.60.0) with Ethereum app (1.10.1) for signing.

Here are the tests that I did:
TEST 1. Stake 2 TAHO. Staking failed with a different error (Transfer amount exceeds spender allowance) - not in scope of this issue
TEST 2. Stake 2 TAHO. Both transactions successful
TEST 3. Stake 3 TAHO. Token approval successful, Contract interaction failed with transaction.chainId/signature.v mismatch
TEST 4. Stake 3 TAHO. Contract interaction failed with transaction.chainId/signature.v mismatch
TEST 5. Stake 3 TAHO. Contract interaction successful
TEST 6: Stake 1 TAHO. Both transactions successful
TEST 7: Stake 2 TAHO. Approve asset spend successful, Contract interaction failed with transaction.chainId/signature.v mismatch
TEST 8: Stake 2 TAHO. Contract interaction failed with transaction.chainId/signature.v mismatch
TEST 9: Stake 2 TAHO. Contract interaction failed with transaction.chainId/signature.v mismatch
TEST 10: Stake 2 TAHO. Contract interaction failed with transaction.chainId/signature.v mismatch
TEST 11: Stake 2 TAHO. Contract interaction failed with transaction.chainId/signature.v mismatch
TEST 12: Stake 2 TAHO. Contract interaction failed with transaction.chainId/signature.v mismatch

Video covering tests 6-12:

Screen.Recording.2023-10-27.at.11.47.02.mov

Looking at the results, there's no clear rule about which transactions fail and which are successful.

I wonder if the problem may be caused by similar issue as discussed here: ethers-io/ext-signer-ledger#6 (comment). In this issue, bumping ledger libraries in ether.js (https://github.com/ethers-io/ethers.js/pull/1370/files) has helped. But we already use higher versions than those...

@michalinacienciala
Copy link
Contributor Author

michalinacienciala commented Oct 27, 2023

Tried other dApps and networks:

TEST 13. Swap 0.01 ETH to WETH on Ethereum Sepolia on Uniswap. Signing Sign transaction successful. WETH not visible in the wallet.

TEST 14. MM Test Dapp. Arbitrum Sepolia. Send EIP 1559 Transaction. Fail, transaction.chainId/signature.v mismatch

TEST 15. Swap 0.005 ETH to WETH on Ethereum Goerli on Uniswap. Signing Sign transaction successful. WETH visible in the wallet. But there were some errors in the wallet:

POST https://ethereum-goerli-rpc.allthatnode.com/ 429 (Too Many Requests)

and

Uncaught (in promise) Error: failed response (requestBody="{\"method\":\"eth_blockNumber\",\"params\":[],\"id\":605,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://ethereum-goerli-rpc.allthatnode.com", code=SERVER_ERROR, version=web/5.7.1)
    at Logger.makeError (index.js:224:23)
    at Logger.throwError (index.js:233:20)
    at index.js:275:27
    at Generator.next (<anonymous>)
    at fulfilled (index.js:5:58)

TEST 16. MM Test Dapp. Ethereum Sepolia. Send EIP 1559 Transaction. Success, no errors.

TEST 17. MM Test Dapp. Ethereum Sepolia. Send EIP 1559 Transaction. Success, no errors.

TEST 18. MM Test Dapp. Ethereum Sepolia. Send EIP 1559 Transaction. Success, no errors.

TEST 19. MM Test Dapp. Arbitrum Sepolia. Send EIP 1559 Transaction. Fail, transaction.chainId/signature.v mismatch

TEST 20. MM Test Dapp. Arbitrum Sepolia. Send EIP 1559 Transaction. Fail, transaction.chainId/signature.v mismatch

TEST 21. MM Test Dapp. Arbitrum. Send EIP 1559 Transaction. Success, no errors.

After upgrading Ethereum App in Ledger to 1.10.3:

TEST 22. MM Test Dapp. Arbitrum Sepolia. Send EIP 1559 Transaction. Fail, transaction.chainId/signature.v mismatch

... (will update here with other results)

@andreachapman
Copy link
Contributor

andreachapman commented Oct 27, 2023

@michalinacienciala - I've done two tests on https://bridge.arbitrum.io/. I've sent from Sepolia to Arbitrum Sepolia and I didn't get the transaction.chainId/signature.v mismatch error on either. I did see the 429 that you mentioned in another thread but for the purposes of this test, I was able to complete the trxn from the ledger.

Here's the video for one:

Screen.Recording.2023-10-27.at.10.43.45.AM.mov

And the scan site: https://sepolia.etherscan.io//tx/0x7e0c9cafb6b5fa5725e2451034c74cffb4c9307640b6fa9af8b3fc2667d32167

And then I also did a test the other way from Arbitrum Sepolia to Ethereum Sepolia and I didn't get the error there either:

Screen.Recording.2023-10-27.at.10.50.59.AM.mov

https://sepolia.arbiscan.io//tx/0x32aff882dbabd3b55f31aba055fbdfcb588651c1038fe6063142b6e94419788b

Leder Nano X with Version 1.10.2
Wallet: Version 0.50.0c1e7552

@michalinacienciala
Copy link
Contributor Author

@andreachapman , could you do maybe 2 more retries of the test with sending from the Arbitrum Sepolia (only if you have time)?

@andreachapman
Copy link
Contributor

@michalinacienciala - ok, I think I have some more evidence. So I did two more sending from Arb Sepolia like you said and again, both were successful. But then, I decided to move some $TAHO to my ledger account. It didn't previously have any. So I moved $TAHO from testertesting.eth to my ledger wallet and then the next transaction I did to send from Arb Sepolia, it failed and I got that error you saw in the extension logs.

Screenshot 2023-10-27 at 11 15 05 AM

However, I then did another one to send from Arb Sepolia and it was successful
Screenshot 2023-10-27 at 11 21 42 AM

So it's definitely not consistent from what I'm seeing. But very interesting that I did like 5 tests and never saw that error until right after I moved TAHO to my ledger wallet.

@michalinacienciala
Copy link
Contributor Author

So it's definitely not consistent from what I'm seeing. But very interesting that I did like 5 tests and never saw that error until right after I moved TAHO to my ledger wallet.

Hmm, interesting. The account I'm seeing all those failures on also has TAHO. So it may have something to do with it - although I'm not 100% sure, as in some cases I did have TAHO and was able to do successful transactions (e.g in TEST 2, see video below)

Uploading Screen Recording 2023-10-27 at 10.08.18.mov…

@michalinacienciala
Copy link
Contributor Author

michalinacienciala commented Oct 27, 2023

My tests 1-22 were all done on the same Ledger account (0x43866d77672dd19252e8ea2274ecece9c62d3262) which had TAHO.

For the TEST 23 I've added another, clean Ledger account (0xbb510ca2cf69e40000a415ccee2009467c10afb3) to wallet and send there some ETH. No TAHO was on that account. Then I did a test transaction on MM Test Dapp on Arbitrum Sepolia and for the first time on that network there I didn't get a failure...

I'll do one more try and then send some TAHO to that account and try one more time. I'll update this comment once I have the results.

[EDIT] OK, I did another try on Arbitrum Sepolia for account with no TAHO (0xbb510ca2cf69e40000a415ccee2009467c10afb3) and this time I did hit the issue. So it does also happens on accounts with no TAHO

@michalinacienciala
Copy link
Contributor Author

Let me post a summary here:
The only network we see the problem with transaction.chainId/signature.v mismatch occurring on is Arbitrum Sepolia. Issue occurs both for accounts which have TAHO and those which don't. But the issue does not occur for all transactions on Arbitrum Sepolia - sometimes we can have a streak of several successful transactions in a row and then get failures. Sometimes most transactions are failing, but there are single ones that are successful. There's no evident rule behind that.
Issue was seen on all the Ledger / Ethereum app versions that we've tested on:
Ledger Nano S & Ethereum 1.10.1
Ledger Nano S & Ethereum 1.10.3
Ledger Nano X & Ethereum 1.10.2

Shadowfiend added a commit that referenced this issue Nov 2, 2023
… handling (#3650)

It currently seems like there is an issue with Ledger's handling of high
chain ids for certain transactions, where the Ledger can provide a first
byte that breaks the expectations of the chain id adjustment done for
legacy transactions to conform to EIP-155. The resulting `v` value
returned from the signing flow is invalid and Ethers throws because of
this.

This fix *may* be correct, but it may not be. To adjust for this fact,
the patch limits adjustments of the underlying parity value in Ledger to
happen only when the chain id matches Arbitrum Sepolia's (412614), as
that's the only place we've seen consistent reports of the issue.

See also LedgerHQ/ledger-live#5265 .

Fixes #3647 .

## Testing

- Easiest way to test here is really to just hammer
https://app.taho.xyz/ . In reproducing, we've found that some
transactions trigger the issue and others don't, depending on what the
first byte of the Ledger response to the signing request is.

Latest build:
[extension-builds-3650](https://github.com/tahowallet/extension/suites/17798752935/artifacts/1021248068)
(as of Wed, 01 Nov 2023 09:45:37 GMT).
@michalinacienciala
Copy link
Contributor Author

Unfortunately, I still see the issue. I've tested on builds from #3650 and #3613. In both cases I got the transaction.chainId/signature.v mismatch when unstaking (on a prod Subscape).

Here's a video from testing on a build from #3613: https://drive.google.com/file/d/1WxLyCzRQPbAdBOrB93JXc9Yj4Z1yNBRb/view?usp=drive_link (warning: the file is big (>400MB)).

@michalinacienciala
Copy link
Contributor Author

Ok, fixed after latest changes in #3613.
Verified on a release build from #3652.

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 a pull request may close this issue.

2 participants