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

EIP-1559 specs for Ethereum Remote Client #17160

Closed
onyb opened this issue Jul 26, 2021 · 2 comments
Closed

EIP-1559 specs for Ethereum Remote Client #17160

onyb opened this issue Jul 26, 2021 · 2 comments

Comments

@onyb
Copy link
Member

onyb commented Jul 26, 2021

Background

EIP-1559 proposes a dynamic adjustment of block sizes in response to changes in demand for gas, thereby translating volatility in transaction fees to volatility in block space. Transactions must pay a BASEFEE, which is basically some sort of a moving average based on the current gas limit.

Technical background

EIP-1559 introduces three gas variables into the picture:

  1. baseFeePerGas ➜ recorded in block headers and burnt. 🔥
  2. maxPriorityFeePerGas ➜ aka miner tip. ⚒️
  3. maxFeePerGas ➜ same as baseFeePerGas + maxPriorityFeePerGas; anything extra is refunded back to user.

These new gas variables must be encoded into a brand-new transaction type (EIP-2718), defined by the following RLP:

0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit,
             destination, value, data, accessList, signatureYParity, signatureR, signatureS])

Note that the baseFeePerGas is implicit and not part of the transaction RLP.

Screens

Metamask UX before EIP-1559

Metamask UX after EIP-1559 ✨

User stories

  1. As a user, I can sign EIP-2178 typed transactions, post the London upgrade.
  2. As a user, I can sign transactions that use EIP-1559 gas variables, post the London upgrade.
  3. As a user, I can switch back to legacy transactions and gas controls, under Settings.
  4. As a user, I can optionally customize the max priority fee and max fee, if EIP-1559 is activated.
  5. As a user, I can continue using EVM-compatible chains and networks not supporting EIP-1559.

High-level Tech specs

  • Upgrade keyring controllers to work with @ethereumjs/tx (including Ledger and Trezor bridges).
  • Support EIP-2718 Typed Transaction Envelope using @ethereumjs/tx.
  • Implement new components for EIP-1559 fee controls (see Metamask screens for UX inspiration).
  • Update existing components (ex, transaction detail, history, etc.) to display fees correctly.
  • Update transaction parser to extract details from EIP-2718 transactions.
  • Implement a background script to read block headers and extract the base fee per gas.
  • Integrate with gas API providers or support eth_maxPriorityFeePerGas (geth only?).
  • Implement a background script to track the miner tip to pay for slow/medium/fast confirmations.
  • Update fee estimation for transactions (see tx-gas-utils controller).
  • Conditionally support various EIPs (1559, 2718) based on the activated hardfork.
  • Support EIP-1559 in speedup and cancel functionalities.
  • Allow switching back to legacy gas and raw transaction format easily.

Additional resources

@onyb
Copy link
Member Author

onyb commented Aug 30, 2021

Self-QA audit

❌ = known failures - fix ongoing.
?? = not tested yet

Smoke tests

  • Wallet unlocks without crashing (wait at least 15 seconds).
  • Able to switch networks from the main wallet dashboard, without crashing.
  • Legacy Type-0 transactions continue to work on Ledger hardware wallet.
    • ⚠️ Redo test with the latest firmware/app.
    • ⚠️ Also test Ledger integration extensively (unlock, get receive address, send, etc).
  • Legacy Type-0 transactions continue to work on Trezor hardware wallet.
    • ⚠️ We have upgraded to Trezor Connect v8, hence Trezor integration must be extensively tested (unlock, get receive address, send, etc).

Send ETH flow

  • Clicking on "Send" button does not result in any provider errors (watch out for Varnish errors in the console).
  • Able to switch networks from the "Send ETH" container.
  • Should not display gas controls in the "Send ETH" container.
  • Should display EIP-1559 gas fields in the transaction summary (estimated max priority fee, and max fee).
  • Should open gas controls on clicking "EDIT" in the transaction summary page.
  • Should allow choosing between slow/average/fast under Basic gas controls.
  • Should allow customizing max priority fee, max fee, and gas limit, in Advanced gas controls.
  • Should perform basic validation of gas fields in Advanced gas controls.
  • Should broadcast the transaction on clicking "Confirm".

Activity

  • Should display max fee per gas and max priority fee per gas (in GWEI), under transaction details (values may be approximated).
  • Should display total gas fee (max fee per gas X gas limit), under the Activity Log.

Send ERC-20 flow

  • Should work exactly the same as Send ETH.

Replace by Fee / Replace by Nonce

  • Pending transaction previously submitted with very low max priority fee, can be be sped up with custom fees.
  • "-32000 transaction underpriced" RPC error is thrown if max priority fee per gas is 0.
  • Pending transaction can be cancelled by bumping the max priority fee by 1.1x.
  • Pending cancel transaction can be sped up by bumping the max priority fee by 1.1x.
  • Failed transaction can be resubmitted by customizing the max priority fee.

Swap

  • Should be able to swap ETH-DAI using legacy gas pricing fields (type-0 transaction).
  • Should be able to approve allowance limit for DAI, in DAI-ETH swap. This must use legacy gas fields (type-0 transaction).
  • Should be able to swap DAI-ETH using legacy gas pricing fields (type-0 transaction).
  • Should be able to customize legacy gas pricing fields while fetching swap quotes.
  • Should be able to customize legacy gas pricing fields in transaction confirmation page.

Fee estimation

  • Max priority fee (per gas) estimates, in the gas controls modal, are close to what's being currently being paid on the network.
  • maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas always holds true (check etherscan).
  • Time estimates for slow/average/fast are realistic (not very accurate, so don't bother too much).

Dapp interactions

  • Should be able to swap ETH-UNI on Uniswap, using legacy gas pricing fields (type-0 transaction).
  • ?? Should be able to ..., using EIP-1559 gas pricing fields (type-2 transaction).

@srirambv
Copy link
Contributor

srirambv commented Sep 8, 2021

Verification passed on

Brave 1.29.75 Chromium: 93.0.4577.58 (Official Build) (x86_64)
Revision c4410ece044414ea42fa4ba328d08195e818a99c-refs/branch-heads/4577@{#1076}
OS macOS Version 11.5.2 (Build 20G95)
Component 1.0.37 dev
Verified tests from #17160 (comment) & brave/ethereum-remote-client#268
Smoke tests
  • Wallet unlocks without crashing (wait at least 15 seconds)
  • Able to switch networks from the main wallet dashboard, without crashing
  • Legacy Type-0 transactions continue to work on Ledger hardware wallet
Unlock Account Send Swap
image image image image
  • Legacy Type-0 transactions continue to work on Trezor hardware wallet
Unlock Account Send Swap
image image image image
Send ETH flow
  • Verified clicking on "Send" button does not result in any provider errors in console
  • Verified able to switch networks from the "Send ETH" container
  • Verified gas controls is not shown in the "Send ETH" container
  • Verified EIP-1559 gas fields are shown in the transaction summary (estimated max priority fee, and max fee)
  • Verified gas controls open on clicking "EDIT" in the transaction summary page
  • Verified choosing between slow/average/fast is available under Basic gas controls
  • Verified customizing max priority fee, max fee, and gas limit, is available in Advanced gas controls
  • Verified basic validation of gas fields in Advanced gas controls
  • Verified transaction is broadcasted on clicking "Confirm".
image image image image image image
Activity
  • Verified max fee per gas and max priority fee per gas in GWEI is displayed under transaction details
  • Verified Total gas fee (Gas Used by Transaction X Max Fee Per Gas) is shown under Activity log
    image
Send ERC-20 flow
  • Verified Send ERC-20 token works as expected. Txhash
    image
Replace by Fee / Replace by Nonce
  • Verified pending transaction previously submitted with very low max priority fee, can be be sped up with custom fees.
  • Verified "-32000 transaction underpriced" RPC error is thrown if max priority fee per gas is 0.
  • Verified pending transaction can be cancelled by bumping the max priority fee by 1.1x.
  • Verified pending cancel transaction can be sped up by bumping the max priority fee by 1.1x.
  • Verified failed transaction can be resubmitted by customizing the max priority fee.

image
image

Swap
  • Verified able to swap ETH-DAI using legacy gas pricing fields (type-0 transaction).
  • Verified able to approve allowance limit for DAI, in DAI-ETH swap. This must use legacy gas fields (type-0 transaction).
  • Verified able to swap DAI-ETH using legacy gas pricing fields (type-0 transaction).
  • Verified able to customize legacy gas pricing fields while fetching swap quotes.
  • Verified able to customize legacy gas pricing fields in transaction confirmation page
image image image image image image image image image image
Fee estimation
  • Verified Max priority fee (per gas) estimates, in the gas controls modal, are close to what's being currently being paid on the network.
  • Verified maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas always holds true
  • Verified Time estimates for slow/average/fast are realistic
Dapp interactions
  • Verified able to swap ETH-UNI on Uniswap, using legacy gas pricing fields type-0 transaction
    image

Verification passed on

Brave 1.30.65 Chromium: 93.0.4577.63 (Official Build) beta (64-bit)
Revision ff5c0da2ec0adeaed5550e6c7e98417dac77d98a-refs/branch-heads/4577@{#1135}
OS Linux
Component 1.0.37 dev
Verified tests from #17160 (comment) & brave/ethereum-remote-client#268
Smoke tests
  • Wallet unlocks without crashing (wait at least 15 seconds)
  • Able to switch networks from the main wallet dashboard, without crashing
  • Legacy Type-0 transactions continue to work on Trezor hardware wallet
Unlock Account Send Swap
image image image image
  • Legacy Type-0 transactions can't be checked on Ledger due to limitations with connecting the H/w device on Linux
Send ETH flow
  • Verified clicking on "Send" button does not result in any provider errors in console
  • Verified able to switch networks from the "Send ETH" container
  • Verified gas controls is not shown in the "Send ETH" container
  • Verified EIP-1559 gas fields are shown in the transaction summary (estimated max priority fee, and max fee)
  • Verified gas controls open on clicking "EDIT" in the transaction summary page
  • Verified choosing between slow/average/fast is available under Basic gas controls
  • Verified customizing max priority fee, max fee, and gas limit, is available in Advanced gas controls
  • Verified basic validation of gas fields in Advanced gas controls
  • Verified transaction is broadcasted on clicking "Confirm".

image |
image | image | image | image | image
-- | -- | -- | -- | -- | --

Activity
  • Verified max fee per gas and max priority fee per gas in GWEI is displayed under transaction details
  • Verified Total gas fee (Gas Used by Transaction X Max Fee Per Gas) is shown under Activity log
    image
Send ERC-20 flow
  • Verified Send ERC-20 token works as expected. Txhash
    image
Replace by Fee / Replace by Nonce
  • Verified pending transaction previously submitted with very low max priority fee, can be be sped up with custom fees.
  • Verified "-32000 transaction underpriced" RPC error is thrown if max priority fee per gas is 0.
  • Verified pending transaction can be cancelled by bumping the max priority fee by 1.1x.
  • Verified pending cancel transaction can be sped up by bumping the max priority fee by 1.1x.
  • Verified failed transaction can be resubmitted by customizing the max priority fee.
    Screenshot from 2021-09-08 13-58-07
    image
Swap
  • Verified able to swap ETH-DAI using legacy gas pricing fields (type-0 transaction).
  • Verified able to approve allowance limit for DAI, in DAI-ETH swap. This must use legacy gas fields (type-0 transaction).
  • Verified able to swap DAI-ETH using legacy gas pricing fields (type-0 transaction).
  • Verified able to customize legacy gas pricing fields while fetching swap quotes.
  • Verified able to customize legacy gas pricing fields in transaction confirmation page
image image image image image image image image
Fee estimation
  • Verified Max priority fee (per gas) estimates, in the gas controls modal, are close to what's being currently being paid on the network.
  • Verified maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas always holds true
  • Verified Time estimates for slow/average/fast are realistic
Dapp interactions
  • Verified able to swap ETH-UNI on Uniswap, using legacy gas pricing fields (type-0 transaction)
    image

Verification passed on

Brave 1.31.27 Chromium: 93.0.4577.63 (Official Build) nightly (64-bit)
Revision ff5c0da2ec0adeaed5550e6c7e98417dac77d98a-refs/branch-heads/4577@{#1135}
OS Windows 10 OS Version 2009 (Build 19043.1165)
Component 1.0.37. dev
Verified tests from #17160 (comment) & brave/ethereum-remote-client#268
Smoke tests
  • Wallet unlocks without crashing (wait at least 15 seconds)
  • Able to switch networks from the main wallet dashboard, without crashing
  • Legacy Type-0 transactions continue to work on Trezor hardware wallet
Unlock Account Send Swap
image image image image
  • Legacy Type-0 transactions continue to work on Ledger Nano hardware wallet
Unlock Account Send Swap
image image image image
Send ETH flow
  • Verified clicking on "Send" button does not result in any provider errors in console
  • Verified able to switch networks from the "Send ETH" container
  • Verified gas controls is not shown in the "Send ETH" container
  • Verified EIP-1559 gas fields are shown in the transaction summary (estimated max priority fee, and max fee)
  • Verified gas controls open on clicking "EDIT" in the transaction summary page
  • Verified choosing between slow/average/fast is available under Basic gas controls
  • Verified customizing max priority fee, max fee, and gas limit, is available in Advanced gas controls
  • Verified basic validation of gas fields in Advanced gas controls
  • Verified transaction is broadcasted on clicking "Confirm".
image image image image image image
Activity
  • Verified max fee per gas and max priority fee per gas in GWEI is displayed under transaction details
  • Verified Total gas fee (Gas Used by Transaction X Max Fee Per Gas) is shown under Activity log
    image
Send ERC-20 flow
  • Verified Send ERC-20 token works as expected. (Txhash)
    image
Replace by Fee / Replace by Nonce
  • Verified pending transaction previously submitted with very low max priority fee, can be be sped up with custom fees.
  • Verified "-32000 transaction underpriced" RPC error is thrown if max priority fee per gas is 0.
  • Verified pending transaction can be cancelled by bumping the max priority fee by 1.1x.
  • Verified pending cancel transaction can be sped up by bumping the max priority fee by 1.1x.
  • Verified failed transaction can be resubmitted by customizing the max priority fee.
    image
    image
Swap
  • Verified able to swap ETH-DAI using legacy gas pricing fields (type-0 transaction).
  • Verified able to approve allowance limit for DAI, in DAI-ETH swap. This must use legacy gas fields (type-0 transaction).
  • Verified able to swap DAI-ETH using legacy gas pricing fields (type-0 transaction).
  • Verified able to customize legacy gas pricing fields while fetching swap quotes.
  • Verified able to customize legacy gas pricing fields in transaction confirmation page
image image image image image image image
Fee estimation
  • Verified Max priority fee (per gas) estimates, in the gas controls modal, are close to what's being currently being paid on the network.
  • Verified maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas always holds true
  • Verified Time estimates for slow/average/fast are realistic
Dapp interactions
  • Verified able to swap ETH-UNI on Uniswap, using legacy gas pricing fields (type-0 transaction)
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment