Try   HackMD

Gas Repricing

Github issue: celestia-app#3012

Context

CIAS is a project that applied inscriptions to Celestia. Instead of using blob data, they used the memo field.

For example, this tx has a memo field that base64 decodes to

data:,{"op":"cancel","amt":3230000,"tick":"cias","p":"cia-20"}

Memo usecases

Note that not all uses of the memo field are nefarious.

  1. Crypto exchanges use memos to uniquely identify the user depositing into an exchange. For example, when depositing ATOM into Coinbase or Gemini, users must specify a memo.

    Exchange Memo characters
    Gemini 13
    Coinbase 10
  2. Some IBC relayers include the Hermes version in their memo. For example: mzonder | hermes 1.7.4+ab73266 (https://hermes.informal.systems) which is 64 characters.

Problem

The gas cost of bytes in the memo field may be mis-priced relative to blobs. Ideally Celestia should enable use cases like inscriptions but encourage them to use blobs rather than memos.

Proposal

We've discussed three concrete gas modifications to encourage users to use blobs instead of memos.

  1. Decrease auth.MaxMemoCharacters from 256
  2. Add fixed cost for txs that contain memos
  3. Increase auth.TxSizeCostPerByte from 10

Decrease auth.MaxMemoCharacters

auth.MaxMemoCharacters is a governance param currently set to 256. This param places a hard limit on the number of characters in the memo field. If this value is decreased, it may make it impractical for inscriptions projects to use the memo field.

How do we select a new value? An example CIAS tx uses 84 characters. Exchanges use 13 characters. IBC relayers use 64 characters. So proposal to use 64 characters.

Cons:

  • If decreased too much, may prohibit other valid use cases of the memo field.

Implementation:

  • Governance proposal to modify this param.

Add fixed cost for txs that contain memos

Discourages the use of memos. Note: This approach is similar to how 1000 gas is consumed per signature verification.

Cons:

  • Makes the gas estimation a bit more complicated.
  • Impacts crypto exchanges and IBC relayers as much as it impacts inscriptions projects.

Implementation:

  • Add a new governance param for the fixed cost.
  • Add a new antehandler that deducts gas if the tx includes a memo. Can useNewSigGasConsumeDecorator as inspiration.

Increase auth.TxSizeCostPerByte

Increases the cost of all bytes in a tx, not just the memo. Currently blob.GasPerBlobByte = 8 so the cost of a blob byte is quite similar to the cost of a tx byte.

How expensive does this make transactions?

auth.TxSizeCostPerByte Gas used by MsgSend without memo Gas used by MsgSend with 256 character memo
10 77004 79594
16 78806 82950
100 105434 131334
1000 320734 649734

Assuming minimum-gas-prices = "0.002utia"

auth.TxSizeCostPerByte Tx fee of MsgSend without memo Tx fee of MsgSend with 256 character memo
10 154 utia 159 utia
16 157 utia 165 utia
100 210 utia 262 utia
1000 641 utia 1299 utia

Ref: https://github.com/rootulp/celestia-app/tree/rp/gas-pricing

Cons:

  • Changing this has the downside that gas estimation may break if it assumes a hardcoded value.

Implementation:

  • Governance proposal to modify this param.

FAQ

What do other blockchains use for these params?

Param Celestia Cosmos Hub Osmosis
auth.MaxMemoCharacters 256 512 256
auth.TxSizeCostPerByte 10 10 10

Ref:

Notes:

  1. We should be concerned about degenerate case where ppl use public keys to store data. See Bitcoin for an example for this. Therefore, we should couple gas re-price change with increase to new state writes.
  2. Does the memo of IBC transactions get to ignore the max memo characters? No it doesn't. The IBC memo and tx memo are two distinct memos.
  3. Need further analaysis on memo field. Can we get it smaller than 64 bytes? Ask exchanges what the max memo they use? Specifically Binance.
  4. If we do gov proposal for auth.TxSizeCostPerByte = 16 then we need to communicate to roll-ups and other service providers that we're changing it.

FLUPs:

  • Add a row for auth.TxSizeCostPerByte = 16 to the tables above
  • Discuss with exchanges on what is the max memo they use
  • [ ]