[G-03] Recommend to use uint256(1)/uint256(2) for true and false
If you don't use boolean for storage you will avoid Gwarmaccess 100 gas. Also boolean from true to false cost 20000 gas rather than uint256(2) to uint256(1) that cost less.
There have 3 instance of this issues:
File: L1GraphTokenGateway.sol line 35
mapping(address => bool) public callhookWhitelist;
[G-04] Using of custom errors than are came from 0.8.4 instead of require()/revert() strings will save deployment gas
Use more recent version of solidity compiler and take advantage of custom errors and save from deployment gas and when condtions are done for reverting.
[G-05] Recommending to not use constructor parameters where is possible because of their cost.
If you not use constructor parameters, deployment will be cheaper. I recomend instead of them to hard code them and change in time if needed with custome function for that purpose.
[G-01]
!=
cost 6 gas less than>
in requireRecommend to use the
!=
for comparisons with 0 in require statemnent. This is type of gas optimization is 6 gas cheaper than>
There have 3 instance of this issues:
File: L1GraphTokenGateway.sol lines 201, 217
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol#L201
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol#L217
File: L2GraphTokenGateway.sol line 146
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol#L146
[G-02] Recommend to use short require string to save deployment gas
If you use longer require strings than 32 bytes that will cost more expensive than short require string.
There are 8 instances of this issue:
File: GraphTokenGateway.sol line 21
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/GraphTokenGateway.sol#L21
File: Managed.sol line 53
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Managed.sol#L53
File: GraphProxy.sol lines 105, 141, 144
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol#L105
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol#L141
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol#L144
File: GraphUpgradeable.sol line 32
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphUpgradeable.sol#L32
[G-03] Recommend to use
uint256(1)
/uint256(2)
for true and falseIf you don't use boolean for storage you will avoid Gwarmaccess 100 gas. Also boolean from true to false cost 20000 gas rather than uint256(2) to uint256(1) that cost less.
There have 3 instance of this issues:
File: L1GraphTokenGateway.sol line 35
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol#L35
File: Pausable.sol lines 8, 10
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Pausable.sol#L8
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Pausable.sol#L10
[G-04] Using of custom errors than are came from 0.8.4 instead of
require()
/revert()
strings will save deployment gasUse more recent version of solidity compiler and take advantage of custom errors and save from deployment gas and when condtions are done for reverting.
There have 64 instance of this issues:
File: GraphTokenGateway.sol lines 19,31,40
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/GraphTokenGateway.sol/#L19
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/GraphTokenGateway.sol/#L31
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/GraphTokenGateway.sol/#L40
File: L1GraphTokenGateway.sol lines 74,78,82,110,111,122,132,142,153,154,165,166,200,201,202,213,217,224,271,275
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L74
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L78
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L82
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L110
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L111
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L122
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L132
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L142
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L153
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L154
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L165
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L166
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L200
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L201
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L202
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L213
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L217
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L224
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L271
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol/#L275
File: Governed.sol lines 24,41,54
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Governed.sol/#L24
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Governed.sol/#L41
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Governed.sol/#L54
File: Managed.sol lines 44,45,49,53,57,104
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Managed.sol/#L44
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Managed.sol/#L45
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Managed.sol/#L49
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Managed.sol/#L53
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Managed.sol/#L57
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/governance/Managed.sol/#L104
File: L2GraphTokenGateway.sol lines 69,98,108,118,145,146,147,148,153,233,234
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L69
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L98
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L108
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L118
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L145
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L146
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L147
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L148
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L153
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L233
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol/#L234
File: GraphTokenUpgradeable.sol lines 60,94,95,106,115,123
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/GraphTokenUpgradeable.sol/#L60
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/GraphTokenUpgradeable.sol/#L94
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/GraphTokenUpgradeable.sol/#L95
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/GraphTokenUpgradeable.sol/#L106
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/GraphTokenUpgradeable.sol/#L115
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/GraphTokenUpgradeable.sol/#L123
File: L2GraphToken.sol lines 36,49,60,70
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/L2GraphToken.sol/#L36
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/L2GraphToken.sol/#L49
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/L2GraphToken.sol/#L60
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/token/L2GraphToken.sol/#L70
File: GraphProxy.sol lines 105,133,141,142,157
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol/#L105
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol/#L133
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol/#L141
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol/#L142
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol/#L157
File: GraphProxyAdmin.sol lines 34,47,59
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxyAdmin.sol/#L34
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxyAdmin.sol/#L47
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxyAdmin.sol/#L59
File: GraphProxyStorage.sol line 62
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxyStorage.sol/#L62
File: GraphUpgradeable.sol lines 24,32
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphUpgradeable.sol/#L24
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphUpgradeable.sol/#L32
[G-05] Recommending to not use constructor parameters where is possible because of their cost.
If you not use constructor parameters, deployment will be cheaper. I recomend instead of them to hard code them and change in time if needed with custome function for that purpose.
There have 1 instance of this issues:
File: GraphProxy.sol line 46
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/upgrades/GraphProxy.sol#L46
[G-06] Recommend to use one operator for comparison
If you use
>=
or<=
this will cost more gas because in the EVM there is no implementation of Opcodes for>=
and `<= and two operations are done.There have 3 instance of this issues:
File: L1GraphTokenGateway.sol line 224, 275
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/gateway/L1GraphTokenGateway.sol#L224
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529fc4udit/2022-10-thegraph/contracts/gateway/L1GraphTokenGateway.sol/#L275
File: GraphTokenUpgradeable.sol line 95
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529fc4udit/2022-10-thegraph/contracts/l2/token/GraphTokenUpgradeable.sol/#L95
[G‑07] Recommend to change memory to calldata for read-only arguments for functions that are called extnally
There have 1 instance of this issues:
File: L2GraphTokenGateway.sol line 286
https://github.com/code-423n4/2022-10-thegraph/blob/fce4d7761db12f6f3edae9051cb54bf4ef11529f/contracts/l2/gateway/L2GraphTokenGateway.sol#L286