code-423n4 / 2022-03-volt-findings

0 stars 0 forks source link

Gas Optimizations #4

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

In this line of Permissions.sol, _setupRole from AccessControl.sol is called,

https://github.com/code-423n4/2022-03-volt/blob/cec24b859c69d1397ce4048b6e9b8e96410b31dd/contracts/core/Permissions.sol#L212

and there it says this function is deprecated in favor of _grantRole. Then _setupRole function makes a call to _grantRole. I think some gas optimization might be made if _grantRole is used in Permissions.sol as that is called in the end.

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol#L195

(In AccessControlEnumerable.sol, _grantRole is overriden, I don't know this changes anything but it has an additional line of code so I wanted to include this as well.)

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControlEnumerable.sol#L52