celestia-app icon indicating copy to clipboard operation
celestia-app copied to clipboard

clarify gas metering

Open liamsi opened this issue 3 years ago • 3 comments

Summary

Clarify how to meter for gas for messages and state-relevant Txs too.

Context

Dropping some raw notes from discussions we had:

Transaction cost metering should only be based on bytes . potenial workarounds: implicitly set gas limit to infinity (maybe not infinity, maybe use gas used purely for byte cost). This means no need for gas limit field in tx.

Some context: In the SDK applications can define gas metering as they please.

Here is an example of metering based on bytes: https://github.com/cosmos/cosmos-sdk/blob/eb8aaf939513d3bf6e82bd13691cfbe9ef4ad28c/x/auth/ante/basic.go#L88-L95

more docs: https://docs.cosmos.network/master/basics/gas-fees.html#block-gas-meter and the AnteHandler: https://docs.cosmos.network/master/basics/gas-fees.html#antehandler

Timeline / Action Items

Note the implementation can happen for the incentivized testnet but we should definitely "de-risk" this earlier, i.e. we should start looking into what exact changes will be necessary certainly before the test-net milsetone.

liamsi avatar Mar 20 '21 13:03 liamsi

Extra info: If you set the gas per all ops to 0 and the gas per byte to 1 gas per byte, then you exactly have metering per byte.

In terms on gas limit, the implicit gas limit should be the deterministic gas cost of a tx, not infinity. If it's infinity, accounts won't have sufficient balance to pay fees and the txs will be invalid. Of course, this point depends on where the implicit gas limit is injected; if after the validity checks then there's less of an issue.

adlerjohn avatar Mar 20 '21 14:03 adlerjohn

The example mentioned is the default that we're using, so gas is determined strictly per byte basis. Unless we add some additional operational gas cost, that will be zero too. What the default mechanism doesn't account for, is that we process messages before calling the function that deducts gas during DeliverTx. We only have to add another anteHandler to account for the message's size.

evan-forbes avatar Aug 05 '21 16:08 evan-forbes

I think we can close with after #397

evan-forbes avatar May 15 '22 18:05 evan-forbes