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

Base rlp encoded logic in signTransaction on return type of getMessageToSign #99

Merged
merged 2 commits into from
Aug 30, 2021

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Aug 27, 2021

This PR follows the advice of this comment #96 (comment), and in signTransaction uses the return type of getMessageToSign to decide whether it needs to be RLP encoded or not.

The tests are updated to be able to properly test the cases where rlp encoding is and is not needed, which are the legacy and EIP1559 transaction cases respectively.

Although not strictly necessary, now that new transaction type specific properties are present on the test transactions, the mocking of TransactionFactory.fromTxData has also been removed. This ensures that the transactions of different types are more thoroughly tested (the alternatively would have been more substantial mocking for TransactionFactory.fromTxData).

@danjm danjm requested a review from a team as a code owner August 27, 2021 18:34
@danjm danjm force-pushed the improve-rlp-encoding-logic branch from 0281c9e to e7be828 Compare August 27, 2021 18:34
@danjm danjm mentioned this pull request Aug 27, 2021
2 tasks
@@ -252,9 +252,11 @@ class LedgerBridgeKeyring extends EventEmitter {
// Note also that `getMessageToSign` will return valid RLP for all transaction types, whereas the
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems inaccurate 🤔

I thought the whole point of the following condition is that getMessageToSign doesn't return valid RLP for legacy transactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Gudahtt reading through this and the conversation here I think you are right. We might want some clarification from @danjm but I don't know how quickly that will come since he's out til next Tuesday. Do you think we can move forward with this PR otherwise?

Copy link
Member

Choose a reason for hiding this comment

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

Sure, we can fix the comment later

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@adonesky1 adonesky1 merged commit 11f687b into main Aug 30, 2021
@adonesky1 adonesky1 deleted the improve-rlp-encoding-logic branch August 30, 2021 22:14
aloisklink added a commit to aloisklink/eth-trezor-keyring that referenced this pull request Sep 20, 2021
aloisklink added a commit to aloisklink/eth-trezor-keyring that referenced this pull request Oct 17, 2021
danjm pushed a commit to MetaMask/eth-trezor-keyring that referenced this pull request Nov 17, 2021
danjm added a commit to MetaMask/eth-trezor-keyring that referenced this pull request Nov 18, 2021
* Upgrade trezor-connect to 8.2.1

This adds support for EIP-1559 for the Trezor T,
once we get all this library to work with it as well.

We use version "8.2.1-extended" exactly,
as we need non-browser support for local tests.

* Update @ethereumjs/common to 2.4.0 for 1559 tests

* Upgrade @ethereumjs/tx dependency to ^3.2.1

Although 3.3.0 is out, I've selected ^3.2.1 just
to match the current version of MetaMask's package.json file.

Version 3.2.0 adds support for EIP-1559 transactions.

* Test EIP-1559 transaction support

Test case copied over from
MetaMask/eth-ledger-bridge-keyring#99

* Set ESLint ecmaVersion to 2018

This adds support for object-rest-spread (e.g. {...x, ...y}),
without using the babel parser, which we use in tests.

This is different from what the Metamask extension has, which
is 2017, but they're using the babel parser.

* Add EIP-1559 transaction support

Creating an unfrozen transaction (added in #88) seems to be a change
that was only required in eth-ledger-keyring, not in Trezor,
and is fixed by @ethereumjs/tx: v3.1.4 anyway.

I've removed this part,
since it was causing issues with EIP-1559 transactions, and does
not seem necessary for non-EIP-1559 transactions either.

* Document EIP1559 support for Model T on README.md

* Add method to expose trezor model

* Lint fix

* Update index.js

Co-authored-by: Alois Klink <[email protected]>

* Use event listener instead of getFeatures call to set model

* Lint fix

* Revert getEIP1559Support to getModel

* Move event listener first and trigger event via init

* Lint fix

* Remove error handle in getModel method

Co-authored-by: Alois Klink <[email protected]>
Co-authored-by: David Walsh <[email protected]>
julianariel pushed a commit to block-wallet/eth-ledger-bridge-keyring that referenced this pull request Apr 27, 2022
…eToSign (MetaMask#99)

* Base rlp encoded logic in signTransaction on return type of getMessageToSign

* Update ethereumjs common library version to support eip1559 txes in tests
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.

3 participants