Coreum Deterministic Gas

Intro

Coreum is using a deterministic gas model for its transactions. Meaning that given a transaction type (e.g /coreum.asset.ft.v1.MsgMint) one can know how much gas will be used before hand, and this amount is fixed if some preconditions are met. Of course this deterministic gas does not apply to the type of transactions that have a complicated, nondeterministic execution path (e.g /cosmwasm.wasm.v1.MsgExecuteContract). We provide tables with all deterministic gas & nondeterministic gas for all our types. For a more recent data, consult this fileopen in new window

Formula

Here is the formula for the transaction

Gas = FixedGas + Sum(Gas for each message) + GasForExtraBytes + GasForExtraSignatures

If message type is deterministic, then the value is looked up from the table, if it is non-deterministic, then the required gas is determined after the execution.

GasForExtraBytes = max(0, TxByteSize-FreeBytes) * TxSizeCostPerByte

GasForExtraSignatures = max(0, NumOfSigs-FreeSigs) * SigVerifyCost

Currently we have values for the above variables as follows:

  • FixedGas: 50000
  • SigVerifyCost: 1000
  • TxSizeCostPerByte: 10
  • FreeSignatures: 1
  • FreeBytes: 2048

As an example if the transaction has 1 signature on it and is below 2048 bytes, the user will not pay anything extra, and if one of those values exceed those limits, the user will pay for the extra resources.

Full example

Let's say we have a transaction with 2 messages of type /coreum.asset.ft.v1.MsgMint inside, also there are 2 signatures and the tx size is 2050 bytes, total will be:

TotalGas = 50000 + 35000 * 2 + (2050-2048) * 10 + 1 * 1000

TotalGas = 121040

Gas Tables

Deterministic messages

Message TypeGas
/coreum.asset.ft.v1.MsgBurn23000
/coreum.asset.ft.v1.MsgFreeze5000
/coreum.asset.ft.v1.MsgGloballyFreeze5000
/coreum.asset.ft.v1.MsgGloballyUnfreeze2500
/coreum.asset.ft.v1.MsgIssue70000
/coreum.asset.ft.v1.MsgMint11000
/coreum.asset.ft.v1.MsgSetWhitelistedLimit5000
/coreum.asset.ft.v1.MsgUnfreeze2500
/coreum.asset.nft.v1.MsgBurn16000
/coreum.asset.nft.v1.MsgFreeze7000
/coreum.asset.nft.v1.MsgIssueClass16000
/coreum.asset.nft.v1.MsgMint39000
/coreum.asset.nft.v1.MsgUnfreeze5000
/coreum.nft.v1beta1.MsgSend16000
/cosmos.authz.v1beta1.MsgExecspecial case
/cosmos.authz.v1beta1.MsgGrant7000
/cosmos.authz.v1beta1.MsgRevoke2500
/cosmos.bank.v1beta1.MsgMultiSendspecial case
/cosmos.bank.v1beta1.MsgSendspecial case
/cosmos.distribution.v1beta1.MsgFundCommunityPool15000
/cosmos.distribution.v1beta1.MsgSetWithdrawAddress5000
/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward65000
/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission22000
/cosmos.feegrant.v1beta1.MsgGrantAllowance10000
/cosmos.feegrant.v1beta1.MsgRevokeAllowance2500
/cosmos.gov.v1beta1.MsgDeposit52000
/cosmos.gov.v1beta1.MsgSubmitProposal65000
/cosmos.gov.v1beta1.MsgVote7000
/cosmos.gov.v1beta1.MsgVoteWeighted9000
/cosmos.slashing.v1beta1.MsgUnjail25000
/cosmos.staking.v1beta1.MsgBeginRedelegate142000
/cosmos.staking.v1beta1.MsgCreateValidator76000
/cosmos.staking.v1beta1.MsgDelegate69000
/cosmos.staking.v1beta1.MsgEditValidator13000
/cosmos.staking.v1beta1.MsgUndelegate112000
/cosmos.vesting.v1beta1.MsgCreateVestingAccount25000
/cosmwasm.wasm.v1.MsgClearAdmin6500
/cosmwasm.wasm.v1.MsgUpdateAdmin8000

Special Cases

There are some special cases when custom logic is applied for deterministic gas calculation. Real examples of special case tests could be found hereopen in new window

/cosmos.bank.v1beta1.MsgSend

DeterministicGasForMsg = bankSendPerCoinGas * NumberOfCoins

bankSendPerCoinGas is currently equal to 24000.

/cosmos.bank.v1beta1.MsgMultiSend

DeterministicGasForMsg = bankMultiSendPerOperationGas * (NumberOfInputs + NumberOfOutputs)

bankMultiSendPerOperationGas is currently equal to 11000.

/cosmos.authz.v1beta1.MsgExec

DeterministicGasForMsg = authzMsgExecOverhead + Sum(DeterministicGas(ChildMsg))

authzMsgExecOverhead is currently equal to 2000.

Nondeterministic messages

Message Type
/cosmos.crisis.v1beta1.MsgVerifyInvariant
/cosmos.evidence.v1beta1.MsgSubmitEvidence
/cosmwasm.wasm.v1.MsgExecuteContract
/cosmwasm.wasm.v1.MsgIBCCloseChannel
/cosmwasm.wasm.v1.MsgIBCSend
/cosmwasm.wasm.v1.MsgInstantiateContract
/cosmwasm.wasm.v1.MsgInstantiateContract2
/cosmwasm.wasm.v1.MsgMigrateContract
/cosmwasm.wasm.v1.MsgStoreCode
Last Updated: