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?
Best Answer
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?
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).