1

I'm reading through the Position Paper. Specifically in section 1.3, which covers how Ethereum economically de-incentivizes actors from submitting theoretically unbounded computations to the blockchain. It goes on to discuss a potential denial-of-service attack on Ethereum and then states:

Our solution is to cap the maximum number of steps that a program is allowed to run for in a single transaction.

Can we take this to mean that Tezos maintains roughly the same concepts of gas/gas limit as Ethereum? And does this mean simply that Tezos enforces a hard gas limit for each smart contract?

Furthermore, how would one determine if a smart contract on the Tezos chain would exceed the hard gas limit? Couldn't a computation require more gas based on different conditions (e.g. an oracle data changes and requires more computation)?

1 Answer 1

1

There are gas caps per operation, and an overall gas cap per block. Each 'step' within a contract has a gas cost, so you can pre-calculate (in a sense) how much gas it could take. The cost of these operations have decreased several times since Tezos started due to optimizations in how the Michelson code is "compiled" and executed internally.

https://mainnet-tezos.giganode.io/chains/main/blocks/head/context/constants

"hard_gas_limit_per_operation":"1040000",
"hard_gas_limit_per_block":"5200000"
4
  • But is a smart contract's number of steps deterministic? Couldn't a developer write a for-loop that is dependent on external data (like an oracle) and thus the contract take a potentially unbounded number of steps? Sep 17, 2021 at 3:26
  • Could you write it? Sure. Would it execute completely? Probably not. Each iteration of the loop has a cost. Once your contract runs out of gas to pay the cost, the execution dies with "out of gas" error message.
    – utdrmac
    Sep 17, 2021 at 14:39
  • And what of the hard gas limit? I assume the contract would hit that and die? Sep 17, 2021 at 18:47
  • It would return an error to the client that initiated the contract call. proto.alpha.gas_exhausted.block
    – utdrmac
    Sep 18, 2021 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.