Skip to content

Dynamic Fee Native Tx

yihuang edited this page Sep 21, 2022 · 4 revisions

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.

Revisit EIP-1559 Rules

In EIP-1559 rules:

effectiveGasPrice = min(baseFee + tipFeeCap, feeCap)
effectiveTipFee = effectiveGasPrice - baseFee
// tx priority is proportional to effectiveTipFee

When the ExtensionOptionDynamicFeeTx is omitted and tipFeeCap defults to max int, the formula becomes:

effectiveGasPrice = feeCap
effectiveTipFee = feeCap - baseFee

Which is a resemblance to cosmos-sdk's current behavior.

IBC Relayer

It's important for some IBC relayers to have their messages processed in FIFO manner, they can achieve 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 setting the extension option, an example config looks like this:

gas_price = { price = 6000000000000, denom = 'basetcro' }
extension_options = [
  { type = 'ethermint_dynamic_fee', value = '500000000000' },
]