Arbitrary denominations for gas tokens
With #3956 we've updated the gas_scale parameter to allow for more flexibility when setting the minimum gas price for a given token. We might have the need for even more flexibility in the future but because of the fixed amount of decimal places for the tokens (6 for the native one, 0 for IBC tokens) and the need to keep the gas costs themselves at a minimum (~ 10k-1M gas units, to avoid squishing them too much), the current logic would not allow it.
If this scenario ever came up we should rework the way we define the gas used by transactions and the minimum costs:
- The minimum gas prices should be
DenominatedAmounts (even in storage, right now we convert them toAmounts) with an arbitrary denomination, so that we are not limited by the actual denomination of the specific token - At genesis we should avoid checking the validity of this denomination in the genesis file since it could be lower than the actual denomination of the token
- When we fo the checks in protocol to validate the gas price declared by a transaction we should use
DenominatedAmounts instead ofAmounts - In the SDK we should account for this denomination when validating the gas cost of the tx
- When computing the gas cost that the tx signer has to pay, we must multiply this denominated amount by the gas limit and ceil the result to the closer valid denomination for the gas token
Given that we might be able to remove the gas_scale param altogether.
Since we are already at it, we should avoid increasing the gas cost of non-wasm operations by removing the GAS_COST_CORRECTION constant:
https://github.com/anoma/namada/blob/a148ac3fa1f8f1ec73b8fa8b8c7bc96067318a3b/crates/gas/src/lib.rs#L134
and we should instead reduce the gas cost of the single wasm opcodes by the same ratio.