VIS-2 / taobank-04-24

0 stars 0 forks source link

Unbounded view functions can fail #42

Open DanailYordanov opened 4 months ago

DanailYordanov commented 4 months ago

Context

VaultFactoryHelper::getProtocolTvl() VaultFactoryHelper::getLiquidatableVaults() VaultFactoryHelper::getRedeemableVaults()

Description

Some of the view functions in VaultFactoryHelper iterate over the vault count which can become a large number.

There are two potential limits to how much data a smart contract can return at once: gas limits and execution time. For a function call that’s part of a transaction (e.g. from another smart contract), gas is often a limiting factor. Each byte of data returned from the call consumes gas, as does iterating through the data set. For view functions being called from outside the EVM (e.g. from JavaScript in a web app), gas is not a limiting factor because there is no transaction being executed. The node processing the call does the computation locally and returns the result. Each node gets to set its own processing limits - typically limiting execution time. If the call takes too long, it will fail.

Recommendation

Use cursor/pagination pattern.