Normal Behavior:
The festivalContract
address is set once via setFestivalContract
and is never meant to change for the lifetime of the BeatToken
contract. Solidity provides the immutable
keyword, which allows a variable to be assigned once at construction and then read at a lower gas cost than a regular storage variable.
Issue:
Currently, festivalContract
is a regular storage variable, which incurs a higher gas cost for every read. If the design is truly immutable (i.e., the address is only set once and never changes), using the immutable
keyword can reduce gas costs for every access to this variable, especially in the mint
and burnFrom
functions, which are called frequently.
Likelihood:
This is a minor gas optimization and only applies if the contract is truly designed to never change the festival contract address after initial assignment.
Impact:
The gas savings are minor per call, but can add up over many transactions, especially in high-volume scenarios.
Every time festivalContract
is read in mint
or burnFrom
, a storage read is performed, which is more expensive than reading an immutable
variable.
If the contract is truly designed so that festivalContract
is set only once (e.g., in the constructor), declare it as immutable
and assign it in the constructor.
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.