There are some modifiers within the Beanstalk project that are very often used. Some examples are: mowSender()
, fundsSafu()
, or noSupplyChange()
. There is a technique that the Beanstalk team can employ to make interactions with its contracts cheaper by embedding these modifiers in private functions. This will result in significant gas savings (up to 50%), making interactions for Beanstalk's users much more cost-effective.
Currently, the modifiers from the Summary section are implemented as regular modifiers and used as such.
Note that in the documentation for the fundsSafu()
modifier, it is stated that it should be used on every function that can write.
However, when using modifiers very often, as is the case with those mentioned above, it is recommended to embed these modifiers in private functions. This will make the calls where these modifiers are invoked much cheaper. By applying this change, Beanstalk can significantly reduce their gas costs.
I wrote this simple contract which can be copy-pasted in Remix to show the gas saved by employing this approach.
As can be clearly seen, employing this approach reduces gas costs by about 2 times.
Higher gas costs for users to interact with the Beanstalk project.
Manual code review, Remix IDE
Consider consolidating the logic of often-used modifiers within a private function. For example, the modifier referenced below could be refactored as demonstrated:
Invalid as per docs https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity
Invalid as per docs https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.