Platform: Code4rena
Start Date: 07/10/2022
Pot Size: $50,000 USDC
Total HM: 4
Participants: 62
Period: 5 days
Judge: 0xean
Total Solo HM: 2
Id: 169
League: ETH
Rank: 38/62
Findings: 1
Award: $20.79
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xNazgul, 0xSmartContract, 0xdeadbeef, B2, Bnke0x0, Deivitto, ElKu, Jujic, KoKo, Pheonix, RaymondFam, RedOneN, RockingMiles, Rolezn, Saintcode_, Shinchan, TomJ, Tomio, __141345__, ajtra, aysha, c3phas, carlitox477, catchup, delfin454000, emrekocak, erictee, fatherOfBlocks, gerdusx, gianganhnguyen, gogo, martin, mcwildy, medikko, oyc_109, pedr02b2, rbserver, ret2basic, rotcivegaf, saian, sakman, zishansami
20.7905 USDC - $20.79
Revert strings that are longer than 32 bytes requires at least one additional mstore, along with additional overhead for computing memory offset, etc. Shortening revert strings to fit in 32 bytes will decrease deployment time gas and will decrease runtime gas when the revert condition is met.
require(msg.sender == _implementation(), "Caller must be the implementation");
require(msg.sender == controller.getGovernor(), "Caller must be Controller governor");
require(_newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
In event emits using local variables or function arguments instead of storage variable can avoid storage read and save gas
emit NewPendingOwnership(oldPendingGovernor, pendingGovernor);
emit NewOwnership(oldGovernor, governor); emit NewPendingOwnership(oldPendingGovernor, pendingGovernor);
emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);
Require statements including conditions with the && operator can be broken down in multiple require statements to save gas.
require( pendingGovernor != address(0) && msg.sender == pendingGovernor, "Caller must be pending governor" );
Storage values that are read multiple times in the same function can be cached to avoid expensive SLOAD and save gas
pendingGovernor
can be replaced by variable oldPendingGovernor
address oldPendingGovernor = pendingGovernor; governor = pendingGovernor;
_partialPause
can be replaced by _toPause
_partialPaused = _toPause; if (_partialPaused)
_paused
can be replaced by _toPause
_paused = _toPause; if (_paused)
By switching from non-zero to non-zero value, expensive SSTORE from 0/false to non-zero can be avoided. and when boolean is used, writing to storage costs more than uint256 as each write operation has to perform extra read operation to correctly place the boolean value in the slot. So switching from 0/false to 1/true can be replaced by 1 and 2
bool internal _partialPaused; bool internal _paused;