Omniscia Tangible Audit
VRFConsumerBaseV2Upgradeable Code Style Findings
VRFConsumerBaseV2Upgradeable Code Style Findings
VRF-01C: Potential Optimization of Variable Mutability
Type | Severity | Location |
---|---|---|
Gas Optimization | VRFConsumerBaseV2Upgradeable.sol:L101, L106-L108 |
Description:
The vrfCoordinator
variable is assigned to only once during the contract's initialization flow via VRFConsumerBaseV2Upgradeable::__VRFConsumerBase_init
.
Example:
101address public vrfCoordinator;102
103/**104 * @param _vrfCoordinator address of VRFCoordinator contract105 */106function __VRFConsumerBase_init(address _vrfCoordinator) internal onlyInitializing {107 vrfCoordinator = _vrfCoordinator;108}
Recommendation:
We advise the original VRFConsumerBaseV2
implementation of Chainlink to be utilized instead, as it is compatible with upgradeable contracts and makes use of an immutable
variable that greatly optimizes read-access gas costs of the coordinator.
Alternatively, we advise the vrfCoordinator
variable to be set as immutable
and a VRFConsumerBaseV2Upgradeable::constructor
to be introduced replacing the VRFConsumerBaseV2Upgradeable::__VRFConsumerBase_init
function and thus mimicking the Chainlink implementation.
Alleviation (106fc61dcd38fe29a81d1984ccde9171f5f231af):
The Tangible team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase