eosnetworkfoundation / eos-evm-contract

EOS EVM
Other
22 stars 14 forks source link

Add min_inclusion_price parameter to pushtx action #695

Closed elmato closed 4 months ago

elmato commented 5 months ago

Depends on https://github.com/eosnetworkfoundation/eos-evm-contract/issues/697.

Add min_inclusion_price parameter as a binary_extension to the pushtx action.

The contract must assert that the min_inclusion_price parameter can only be specified when eos_evm_version >= 1.

In evm_contract::process_tx the asserts

assert(max_priority_fee_per_gas == tx.max_fee_per_gas)
assert(tx.max_fee_per_gas >= _config->get_gas_price())

should only be executed when eos_evm_version == 0, otherwise the contract must assert that inclusion_price >= min_inclusion_price.

Where inclusion_price is calculated as follows:

let inclusion_price = min(max_priority_fee_per_gas, max_fee_per_gas - base_fee_per_gas)

where base_fee_per_gas is the active gas price from the config, i.e. _config->get_gas_price().

Note that transaction pre-validation already checks that tx.max_priority_fee_per_gas <= tx.max_fee_per_gas and that base_fee_per_gas <= tx.max_fee_per_gas. After London, since base_fee_per_gas is _config->get_gas_price(), that second inequality check provides the proper enforcement of a minimum gas price that was previously provided by assert(tx.max_fee_per_gas >= _config->get_gas_price()).