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

Support EIP-2718 transaction types, EIP-2930 and EIP-1559 support #11288

Merged
merged 5 commits into from
Jun 16, 2021

Conversation

brad-decker
Copy link
Contributor

@brad-decker brad-decker commented Jun 14, 2021

EIP-2718 Support via @ethereumjs/tx

Up until this PR we have used a locked version of ethereumjs-tx, which has been deprecated in favor of the namespace @ethereumjs/tx. The following work was done as a prerequisite for this PR to be able to be merged:

  1. upgrade ethereumjs util #10886
  2. upgrade eth-keyring-controller #10933
  3. Upgrading eth-ledger-bridge-keyring -> 0.6.0, eth-trezor-keyring -> 0.7.0 #11290
  4. upgrade ethereumjus-util eth-hd-keyring#35, upgrade eth-simple-keyring to 4.2.0 eth-hd-keyring#37, upgrade ethereumjs-wallet eth-hd-keyring#38, upgrade eth-sig-util eth-hd-keyring#39
  5. support newer versons of ethereumjs/tx with immutability eth-simple-keyring#61, upgrades ethereumjs-wallet which drops scrypt eth-simple-keyring#65, upgrade eth-sig-util to 3.0.1 eth-simple-keyring#67
  6. upgrade ethereumjs-util KeyringController#79, upgrade eth-sig-util to v3.0.1 KeyringController#82, upgrade eth-simple-keyring to v4.2.0 KeyringController#83, upgrade eth-hd-keyring to v3.6.0 KeyringController#84
  7. Upgrade ethereumjs-util library to latest version eth-ledger-bridge-keyring#65, upgrade ethereumjs/tx support eth-ledger-bridge-keyring#68
  8. upgrade ethereumjs-util eth-trezor-keyring#60, Upgrade ethereumjs libraries eth-trezor-keyring#88

This PR gets us onto the newest version of @etheruemjs/tx which includes support for EIP-2718, EIP-2930, and EIP-1559. No UI modification is included in this PR, sending transactions in MetaMask will still use legacy (type 0) transactions.

@ethereumjs/common

This PR also implements the Common library from ethereumjs which helps to instantiate the different types of chain parameters that can affect which types of transactions work on which chains. In this version of @ethereumjs/tx you must use TransactionFactory.fromTxData to create a transaction. This factory method references which chain, hardfork and EIPs are currently supported then analyzes the txParams to build the appropriate type of transaction.

Updates were necessary in our signTransaction method, as well as in a few test files.

@metamaskbot
Copy link
Collaborator

Builds ready [2a2d6ea]
Page Load Metrics (573 ± 53 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint44766284
domContentLoaded34770057211053
load34870257311053
domInteractive34670057211053

@metamaskbot
Copy link
Collaborator

Builds ready [c7fea9b]
Page Load Metrics (635 ± 77 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint46866694
domContentLoaded38793063316077
load38993163516077
domInteractive38793063316077

@brad-decker brad-decker changed the title [WIP] use new version of ethereumjs/tx Support EIP-2718 transaction types, EIP-2930 and EIP-1559 support Jun 15, 2021
@brad-decker brad-decker marked this pull request as ready for review June 15, 2021 18:02
@brad-decker brad-decker requested a review from a team as a code owner June 15, 2021 18:02
rickycodes
rickycodes previously approved these changes Jun 15, 2021
Copy link
Contributor

@rickycodes rickycodes left a comment

Choose a reason for hiding this comment

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

this looks proper to me!

@brad-decker brad-decker requested review from darkwing and ryanml and removed request for adonesky1 June 15, 2021 18:09

const customChainParams = {
name: nickname,
chainId: parseInt(chainId, 16),
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor but can we use parseInt when we first create the variable, since it's not used as a string in this function? Would be cool to know its type right away. Not a blocker, just a suggestion.

Copy link
Contributor Author

@brad-decker brad-decker Jun 15, 2021

Choose a reason for hiding this comment

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

@darkwing done in latest. Also renamed nickname -> name during destructuring

darkwing
darkwing previously approved these changes Jun 15, 2021
@darkwing darkwing closed this Jun 15, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2021
@darkwing darkwing reopened this Jun 15, 2021
return Common.forCustomChain('mainnet', customChainParams, HARDFORK);
}

return new Common({ chain: type, hardfork: HARDFORK });
Copy link
Contributor

@ryanml ryanml Jun 15, 2021

Choose a reason for hiding this comment

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

Also minor, (and our linter may not like this, I forget) Can we check for type !== 'rpc' at the top of the function and return new Common({ chain: type, hardfork: HARDFORK }); immediately, then we don't have to have the rpc type logic in a conditional? Totally minor and probably too picky :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Good call. I also changed 'rpc' -> NETWORK_TYPE_RPC

ryanml
ryanml previously approved these changes Jun 15, 2021
Copy link
Contributor

@ryanml ryanml left a comment

Choose a reason for hiding this comment

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

other than my nit, lgtm!

@brad-decker brad-decker dismissed stale reviews from ryanml, darkwing, and rickycodes via 63e43c5 June 15, 2021 18:49
ryanml
ryanml previously approved these changes Jun 15, 2021
Copy link
Contributor

@ryanml ryanml left a comment

Choose a reason for hiding this comment

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

beautiful!

@metamaskbot
Copy link
Collaborator

Builds ready [b876ed5]
Page Load Metrics (544 ± 48 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint448760126
domContentLoaded35065854310048
load35165954410048
domInteractive35065854210048

@metamaskbot
Copy link
Collaborator

Builds ready [b5e806b]
Page Load Metrics (624 ± 45 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint46836184
domContentLoaded3897936229345
load3907946249345
domInteractive3897936229345

@rickycodes rickycodes self-requested a review June 16, 2021 15:08
Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

Code makes sense and all my manual testing worked great! Thank you @brad-decker !

@brad-decker brad-decker merged commit cf34e64 into develop Jun 16, 2021
@brad-decker brad-decker deleted the ethereumjs-tx-upgrade branch June 16, 2021 20:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants