trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.86k stars 1.6k forks source link

Ethereum new fee support EIP1559 #1322

Closed optout21 closed 3 years ago

optout21 commented 3 years ago

Fee structure in Ethereum is planned to be changed. https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md

Wallet core should support this, supporting both legacy and new version. The base fee is determined by the network, no need for user input or estimation. Optional tip (inclusion fee) is an option for the user. Max fee is also a setting (user-supplied or fixed?).

A proposed way to support both schemes by extending ethreum SigningInput with new fields max_inclusion_fee_per_gas and max_fee_per_gas:

Discriminator: If gas_price > 0, legacy fee scheme is used; if gas_price == 0 new EIP1559 scheme is used.

Legacy pre-EIP1559 scheme: gas_price and gas_limit are used as before, new fields are disregarded.

EIP1559: new fields max_inclusion_fee_per_gas and max_fee_per_gas are used (maxInclusionFeePerGas, maxFeePerGas, gas_limit is used, `gas_price' is disregarded (must be 0).

Note: EIP-2718 is a prerequisite, as EIP1559-compliant transaction is a new EIP-2718 type.

optout21 commented 3 years ago

Postpone committing EIP2718 support to the time when EIP1559 is approaching.

optout21 commented 3 years ago

EIP1559 is already active on the Ropsten test network.