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

[LIVE-14459] Bugfix - Fix invalid EIP-155 v and refactor transaction decoding #8175

Merged

Conversation

lambertkevin
Copy link
Contributor

@lambertkevin lambertkevin commented Oct 23, 2024

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • v value from ECDSA signature should now always be correct depending on the transaction type

📝 Description

The v value from ECDSA signatures returned by @ledgerhq/hw-app-eth could be wrongly applying EIP-155 on legacy transactions (type 0) depending on the signature's parity. This is now fixed and verified as broadcastable on all known chainIds via anvil.
The whole transaction parsing and chunking has also been refactored to increase chunk size and make the code more readable and fully tested.
@ledgerhq/coin-evm was hacking its way through this v value being incorrect, and therefore this unnecessary hack is now removed.

QA can force transaction type 0 on all networks by using the EVM_FORCE_LEGACY_TRANSACTIONS flag as env variable (+ --env-mode=loose for turbo 🤷‍♂️ )

Also removes ethers full library from dependencies for @ledgerhq/hw-app-eth and @ledgerhq/coin-evm and substitute it with sub librairies, which should reduce the install and bundle size of both librairies.

Fixes #5265

❓ Context


🧐 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)

@lambertkevin lambertkevin requested review from a team as code owners October 23, 2024 13:34
@live-github-bot live-github-bot bot added the ledgerjs Has changes in the ledgerjs open source libs label Oct 23, 2024
Copy link

vercel bot commented Oct 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
web-tools ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 29, 2024 9:31am
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-docs ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 9:31am
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 9:31am
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 9:31am
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 9:31am

Wozacosta
Wozacosta previously approved these changes Oct 25, 2024
Copy link
Contributor

@Wozacosta Wozacosta left a comment

Choose a reason for hiding this comment

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

🔥

@lambertkevin lambertkevin force-pushed the bugfix/wrong-v-for-eip155-and-hw-app-eth-improvements branch from 0a7e8c0 to 1de115f Compare October 25, 2024 15:54
It should be decreasing the bundle size by using only sub librairies
It should be easier to reason about, increase chunk size and more tested
Should also fix the `v` value of ECDSA sig bing incorrect for legacy txs
It's now unecessary as `hw-app-eth` has now a correct `v` for legacy txs
@lambertkevin lambertkevin merged commit b93a421 into develop Oct 29, 2024
53 of 54 checks passed
@lambertkevin lambertkevin deleted the bugfix/wrong-v-for-eip155-and-hw-app-eth-improvements branch October 29, 2024 11:37
Canestin pushed a commit that referenced this pull request Oct 30, 2024
…n decoding (#8175)

* Remove `ethers` full lib from dependencies
It should be decreasing the bundle size by using only sub librairies

* Refactoring of the whole transaction decoding flow
It should be easier to reason about, increase chunk size and more tested
Should also fix the `v` value of ECDSA sig bing incorrect for legacy txs

* Refactoring and cleaning

* Remove `ethers` from @ledgerhq/evm-tools as well

* Remove `applyEIP155` helper in `coin-evm`
It's now unecessary as `hw-app-eth` has now a correct `v` for legacy txs

* Add env var to force using legacy txs w/ EVMs

* Changeset

* unimported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ledgerjs Has changes in the ledgerjs open source libs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Possibly incorrect v for legacy transactions on Arbitrum Sepolia chain id (421614)
2 participants