Skip to content

Latest commit

 

History

History
214 lines (152 loc) · 18.6 KB

sakman-G.md

File metadata and controls

214 lines (152 loc) · 18.6 KB

1. Custom error are cheaper than string messages

ethereum/contracts/zksync/facets/Base.sol: L16 L22

ethereum/contracts/zksync/libraries/Diamond.sol: L100 L109 L126 L135 L150 L170 L176 L214 L279

ethereum/contracts/common/L2ContractHelper.sol: L50 L53 L65 L67

ethereum/contracts/common/ReentrancyGuard.sol: L55 L72

ethereum/contracts/common/AllowList.sol: L33 L38 L67 L155

zksync/contracts/bridge/L2ETHBridge.sol: L49 L64

ethereum/contracts/bridge/L1EthBridge.sol: L93 L141 L166 L205

ethereum/contracts/zksync/libraries/Merkle.sol: L23 L24 L25

ethereum/contracts/zksync/facets/Executor.sol: L28 L41 L52 L57-L61 L117 L129 L145 L159 L192 L193-L196 L199 L237 L241-L245 L261 L265 L337

ethereum/contracts/bridge/L1ERC20Bridge.sol: L117 L207 L210 L232 L271 L274

ethereum/contracts/zksync/facets/Governance.sol: L30

zksync/contracts/bridge/L2ERC20Bridge.sol: L58 L63 L95

ethereum/contracts/zksync/facets/DiamondCut.sol: L40 L55 L59-L63 L65 L80 L94 L106 L111 L112

ethereum/contracts/zksync/facets/Getters.sol: L148

ethereum/contracts/zksync/facets/Mailbox.sol: L56 L63 L124

ethereum/contracts/zksync/libraries/PriorityQueue.sol: L64 L72

ethereum/contracts/zksync/DiamondProxy.sol: L13 L24 L29

zksync/contracts/bridge/L2StandardERC20.sol: L44 L45

ethereum/contracts/common/AllowListed.sol: L15

2. Use immutable instead of constant for the following to save runtime gas

ethereum/contracts/common/L2ContractHelper.sol: L41

zksync/contracts/L2ContractHelper.sol: L24

3. Consider marking functions as payable if there is no risk of sending value through them

This change will save gas each time a function is called

ethereum/contracts/common/AllowList.sol: L57 L140 L153

ethereum/contracts/zksync/facets/Governance.sol: L28

zksync/contracts/bridge/L2StandardERC20.sol: L102 L109

4. Function that are called only once can be inlined in the calling function

This change will save around 30 gas units

ethereum/contracts/zksync/libraries/Diamond.sol: L119 L143 L167 L277

ethereum/contracts/common/ReentrancyGuard.sol: L43

5. When comparing variables of type uint, use require(x != 0) instead of require(x > 0)

ethereum/contracts/bridge/L1ERC20Bridge.sol: L117 L210

ethereum/contracts/zksync/libraries/Merkle.sol: L23

6. Use bitshifting instead of multiplication and divison

ethereum/contracts/zksync/libraries/Merkle.sol: L25

ethereum/contracts/zksync/Config.sol: L23

ethereum/contracts/common/L2ContractHelper.sol: L53 L72

7. Calldata is cheaper than memory for function input

zksync/contracts/bridge/L2StandardERC20.sol: L43

ethereum/contracts/common/L2ContractHelper.sol: L43 L47

ethereum/contracts/bridge/L1ERC20Bridge.sol: L260

ethereum/contracts/common/libraries/UnsafeBytes.sol: L18 L25 L32

ethereum/contracts/zksync/libraries/Diamond.sol: L89 L121 L145 L277

ethereum/contracts/zksync/facets/Mailbox.sol: L43 L53

zksync/contracts/ExternalDecoder.sol: L10 L15

ethereum/contracts/bridge/L1EthBridge.sol: L214

ethereum/contracts/zksync/libraries/PriorityQueue.sol: L54

zksync/contracts/L2ContractHelper.sol: L26

ethereum/contracts/zksync/facets/Executor.sol: L23 L152 L190 L278 L385

8. Use constant and immutable for constants

zksync/contracts/bridge/L2ETHBridge.sol: L16 L22

ethereum/contracts/zksync/facets/Base.sol: L12

zksync/contracts/bridge/L2ERC20Bridge.sol: L19 L23 L26

zksync/contracts/bridge/L2StandardERC20.sol: L24 L32 L35

9. Place i++ in an unchecked blocks in for-loops

ethereum/contracts/zksync/libraries/Diamond.sol: L94 L132 L153

10. Use x < y + 1 in stead of x <= y

ethereum/contracts/zksync/facets/DiamondCut.sol: L49 L52

ethereum/contracts/zksync/facets/Executor.sol: L51 L216 L268

ethereum/contracts/zksync/DiamondProxy.sol: L24

ethereum/contracts/zksync/facets/Mailbox.sol: L56 L124