Use a solidity version of at least 0.8.0 to get overflow protection without LowGasSafeMath
Use a solidity version of at least 0.8.2 to get simple compiler automatic inlining Use a solidity version of at least 0.8.3 to get better struct packing and cheaper multiple storage reads Use a solidity version of at least 0.8.4 to get custom errors, which are cheaper at deployment than revert()/require()
strings Use a solidity version of at least 0.8.10 to have external calls skip contract existence checks if the external call has a return value
Including all files in the scope.
ethereum/contracts/zksync/DiamondProxy.sol:24
ethereum/contracts/zksync/libraries/Diamond.sol:126
ethereum/contracts/zksync/libraries/Diamond.sol:150
ethereum/contracts/zksync/libraries/Diamond.sol:170
ethereum/contracts/common/L2ContractHelper.sol:67
Saves 6 gas per instance if using assembly to check for address(0)
e.g.
assembly {
if iszero(_addr) {
mstore(0x00, "zero address")
revert(0x00, 0x20)
}
}
Instances include:
ethereum/contracts/zksync/DiamondProxy.sol:29
ethereum/contracts/zksync/libraries/Diamond.sol:126
ethereum/contracts/zksync/libraries/Diamond.sol:135
ethereum/contracts/zksync/libraries/Diamond.sol:150
ethereum/contracts/zksync/libraries/Diamond.sol:156
ethereum/contracts/zksync/libraries/Diamond.sol:170
ethereum/contracts/zksync/libraries/Diamond.sol:176
ethereum/contracts/common/AllowList.sol:33
zksync/contracts/bridge/L2ERC20Bridge.sol:95
zksync/contracts/bridge/L2StandardERC20.sol:44
zksync/contracts/bridge/L2StandardERC20.sol:45
Instances include:
ethereum/contracts/zksync/Config.sol:23
ethereum/contracts/zksync/Config.sol:26
Modifiers make code more elegant, but cost more than normal functions.
Instances include:
ethereum/contracts/zksync/facets/Base.sol:15
ethereum/contracts/zksync/facets/Base.sol:21
ethereum/contracts/common/AllowList.sol:33
ethereum/contracts/common/AllowListed.sol:9
ethereum/contracts/common/ReentrancyGuard.sol:38
ethereum/contracts/common/ReentrancyGuard.sol:65
zksync/contracts/bridge/L2StandardERC20.sol:95
instances:
ethereum/contracts/zksync/facets/DiamondCut.sol:105-L122
ethereum/contracts/zksync/libraries/Diamond.sol:95-L98
It is generally cheaper to load variables directly from calldata, rather than copying them to memory. Only use memory if the variable needs to be modified.
Instances include:
ethereum/contracts/zksync/libraries/PriorityQueue.sol:54