2

One of my projects has a complex view function that loops through arrays, maps etc. It doesn't spend gas, but I am afraid one day its estimated gas cost might exceed the block gas limit, and I remember reading that ETH nodes do not accept functions with such complexity (even view and pure functions).

Will view function fail if its estimated gas cost rises above the block gas limit?

2 Answers 2

2

Yes, the view function should fail.

view/pure functions are limited by the gas provided to it. They still "use" gas, even though the sender doesn't get "charged" for the gas.

For more, including how a version of Geth was providing 50 million gas for view functions, see Can Solidity view/pure functions be arbitrarily complex?


I remember reading that ETH nodes do not accept functions with such complexity

Nodes accept any bytecode that is paid for (even if it is an infinite loop). Basically the only way that a node can tell how much computation the code does, is by running the code (related is the Halting problem).

0
0

view function does not require gas to run, although if you are appending information inside an array and iterating over it again and again, gas would increase and could possibly result in failure

Your Answer

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

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