-
Notifications
You must be signed in to change notification settings - Fork 237
Dynamic Fee Native Tx
Since Cronos v0.9.0
, together with introducing prioritized mempool, we also apply the EIP-1559-like feemarket to cosmos-sdk native tx.
In ethereum dynamic fee tx, there are two fields to control the gas price: feeCap
and tipFeeCap
.
In cosmos-sdk tx, traditionally we only have one gas-price field, which is computed based on fee / gas_wanted
, since Cronos v0.9.0
, the current gas-price
is treated as feeCap
, we introduce an optional extension option ExtensionOptionDynamicFeeTx
where user can supply the tipFeeCap
, which defaults to max int if omitted.
In EIP-1559 rules:
effectiveGasPrice = min(baseFee + tipFeeCap, feeCap)
effectiveTipFee = effectiveGasPrice - baseFee
// tx priority is proportional to effectiveTipFee
When the default behavior where tipFeeCap
is max int is:
effectiveGasPrice = feeCap
effectiveTipFee = feeCap - baseFee
Which is a resemblance to cosmos-sdk's current behavior.
It's important for some IBC relayers to have their messages processed in FIFO manner, they can archive that by setting the tipFeeCap
through the ExtensionOptionDynamicFeeTx
.
For example, by setting a big enough feeCap
and constant tipFeeCap
, effectively we have:
effectiveGasPrice = baseFee + tipFeeCap
effectiveTipFee = tipFeeCap
So we got a constant tx priority, tendermint v1 mempool will guarantee the FIFO behavior for the same priority.
Currently, hermes main branch support settings the extension option, an example config looks like this:
gas_price = { price = 6000000000000, denom = 'basetcro' }
extension_options = [
{ type = 'ethermint_dynamic_fee', value = '500000000000' },
]