You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(3) Using private rather than public for constants, saves gas
If needed, the value can be read from the verified contract source code. Savings are due to the compiler not having to create non-payable getter functions for deployment calldata, and not adding another entry to the method ID table
Proof Of Concept
uint256 public constant MIN_REGISTRATION_DURATION = 28 days;
USDC ENS
Author: Rolezn
=================
Gas Optimizations
(1) Constants can be set to uint8 for gas optimizations
https://github.com/code-423n4/2022-07-ens/blob/main/contracts/dnssec-oracle/DNSSECImpl.sol#L21-L24
(2) ++i costs less gas than i++, especially when it’s used in for-loops (--i/i-- too)
Saves gas per loop
Proof Of Concept
for(uint i = 0; i < len; i++) {
From https://github.com/code-423n4/2022-07-ens/blob/main/contracts/dnssec-oracle/BytesUtils.sol#L266
for(uint i = 0; i < input.length; i++) {
From https://github.com/code-423n4/2022-07-ens/blob/main/contracts/dnssec-oracle/DNSSECImpl.sol#L93
for (uint256 i = 0; i < data.length; i++) {
From https://github.com/code-423n4/2022-07-ens/blob/main/contracts/ethregistrar/ETHRegistrarController.sol#L256
(3) Using private rather than public for constants, saves gas
If needed, the value can be read from the verified contract source code. Savings are due to the compiler not having to create non-payable getter functions for deployment calldata, and not adding another entry to the method ID table
Proof Of Concept
uint256 public constant MIN_REGISTRATION_DURATION = 28 days;
From https://github.com/code-423n4/2022-07-ens/blob/main/contracts/ethregistrar/ETHRegistrarController.sol#L21
(4) It costs more gas to initialize variables to zero than to let the default of zero be applied
Proof Of Concept
for (uint256 i = 0; i < data.length; i++) {
From https://github.com/code-423n4/2022-07-ens/blob/main/contracts/ethregistrar/ETHRegistrarController.sol#L256
for (uint256 i = 0; i < accounts.length; ++i) {
From https://github.com/code-423n4/2022-07-ens/blob/main/contracts/wrapper/ERC1155Fuse.sol#L92
for (uint256 i = 0; i < ids.length; ++i) {
From https://github.com/code-423n4/2022-07-ens/blob/main/contracts/wrapper/ERC1155Fuse.sol#L92
The text was updated successfully, but these errors were encountered: