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 Transactions #1972

Closed
yondonfu opened this issue Aug 3, 2021 · 1 comment
Closed

EIP-1559 Transactions #1972

yondonfu opened this issue Aug 3, 2021 · 1 comment
Labels

Comments

@yondonfu
Copy link
Member

yondonfu commented Aug 3, 2021

EIP-1559 Transactions

Resources

I suggest reviewing the following resources for more context:

https://hackmd.io/@timbeiko/1559-resources
https://hackmd.io/@q8X_WM2nTfu6nuvAzqXiTQ/1559-wallets
https://hackmd.io/@timbeiko/1559-json-rpc
https://blog.alchemy.com/blog/eip-1559

Background

Since EIP-1559 is backwards compatible, all transaction related functionality in go-livepeer will continue to work after the Ethereum London hardfork. However, it will be advantageous to add support for EIP-1559 transaction because these transactions can be more cost efficient than legacy transactions in certain scenarios since there is an opportunity to get a refund with EIP-1559 transactions equal to maxFeePerGas - (baseFeePerGas + maxPriorityFeePerGas (baseFeePerGas will depend on the block that a transaction is included in).

This post includes the following:

  • Gas price estimation behavior before and after EIP-1599 for informational purposes
  • Gas estimation behavior before and after EIP-1559 for informational purposes
  • Replacement transaction behavior before and after EIP-1559 for informational purposes
  • Updates that should be made to go-livepeer to support EIP-1559 transactions

Gas Price Estimation

Before EIP-1559, the eth_gasPrice RPC method could be used to query an Ethereum node for a gas price estimation based on the node's gas price oracle implementation.

After EIP-1559, the eth_maxPriorityFeePerGas RPC method can be used to query an Ethereum node for a max priority fee estimation based on the node's gas price oracle implementation and the header of the latest mined block contains the base fee for the next block.

The default behavior for Go contract bindings generated via abigen will be:

The eth_feeHistory RPC method can also be used to query an Ethereum node for historical data on transaction fees. This RPC method can be used to construct alternative max priority fee estimation algorithms instead of just relying on the result of eth_maxPriorityFeePerGas. For example, MyCrypto uses the median 1st percentile effective max priority fee in the previous 5 blocks.

After EIP-1559, the eth_gasPrice RPC method will still work as before (i.e. return a single integer value) for backwards compatibility. Internally, geth just returns the sum of the estimated max priority fee and the base fee for the next block. The result can be set as the value for the gasPrice field of a pre-1559 tx. The value of gasPrice will be interpreted as the value for both the max priority fee and the max fee.

[1] The geth codebase refers to the max priority fee as the "gas tip cap".
[2] The geth codebase refers to the max fee as the "gas fee cap".

Gas Estimation

Before EIP-1559, the eth_estimateGas RPC method did not require the gasPrice argument to be specified.

After EIP-1559, the eth_estimateGas RPC method requires either the gasPrice argument or the maxPriorityFeePerGas AND maxFeePerGas arguments to be specified.

The default behavior of Go contract bindings generated by abigen is to ensure that the required arguments are provided in the eth_estimateGas RPC call.

Replacement Txs

Before EIP-1559, by default geth would reject replacement txs if the gas price of the replacement tx was not at least 10% greater than that of the tx being replaced.

After EIP-1559, by default geth will require replacement txs to either have a max fee that is at least 10% greater than that of the tx being replaced OR have a max priority fee that is at least 10% greater than that of the tx being replaced.

Since the gasPrice field in a pre-1559 transaction is interpreted as the value for both the max priority fee and the max fee, a replacement tx that is created by bumping the value of the gasPrice field at least 10% will pass the new validation rules after EIP-1559 since a 10% increase in the gasPrice value will be a 10% increase in both max priority fee and the max fee values.

go-livepeer updates for EIP-1559 transactions

  • Upgrade the geth dependency
  • Re-generate contract bindings to support EIP-1559 transactions (the contract binding generation implemention in geth should already include this support)
  • Consider updating the gas price monitor in go-livepeer to not use the eth_gasPrice RPC method and instead use the new EIP-1559 fee fields
@yondonfu yondonfu added the Epic label Aug 3, 2021
@yondonfu
Copy link
Member Author

Apparently, eth_maxPriorityFeePerGas is currently not a part of the Ethereum JSON-RPC spec. So, the RPC method can be relied upon when connected to geth, but cannot be relied upon when connected to another client. See ethereum/go-ethereum#23479 for implications.

There is a PR ethereum/go-ethereum#23484 to add fallback behavior for contract bindings (generated by abigen) if the eth_maxPriorityFeePerGas RPC method is not found on the client. An alternative would be to use the eth_feeHistory RPC method (which is included in the JSON-RPC spec) to construct a fee estimation algorithm that could replicate whatever the implementation of eth_maxPriorityFeePerGas in geth does as mentioned in the "Gas Price Estimation" section of the OP. Making a note to consider both these options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant