I understand that read-only calls don't cost any gas fees. However, are there any limitations to these read-only calls and static calls that don't cost gas?
For example:
struct Person {
string name,
uint256 age
}
Person[] private persons;
function getAllNames() view external returns(memory string[]) {
String[] memory names = [];
for (uint256 i=0; i<persons.length; i++) {
names.push(persons[i].name);
}
return names;
}
function getAllPersons() view external returns(Person[]) {
return persons;
}
Let's say the array persons
is huge with tens of thousands of records or even hundreds of thousands of records. Both the functions getAllNames()
which loops through the huge array and getAllPersons()
which returns the entire persons
array are view functions. They don't cost gas fees when called as read-only functions.
However, do read-only calls or static calls to such functions have limitations too? Does the EVM still calculate the gas cost when running these "free" read-only functions and error out when its internal gas calculation limit is reached? Or am I safe to call such functions that loops through giant arrays without worries?
Particularly, is there some sort of gas limit or other kinds of limitations to expensive read-only functions that could take a long time to run on the nodes?