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
EVM word size is 32 bytes. The uint256 1 and uint256 2 will be cheaper to use than the boolean true and boolean false since the first are 32 bytes long and the last are only 1 byte
line#L8: /// @audit Currently storage variables are packed in 4 slots but could fit in 3
Mark functions as payable to avoid the low-level evm is-a-payment-provided check
The EVM checks whether a payment is provided to the function and this check costs additional gas. If the function is marked as payable there is no such check
line#L266: bytesmemory_data/// @audit Store `_data` in calldata.
line#L286: function parseOutboundData(bytesmemory_data) privateviewreturns (address, bytesmemory) {
line#L32: function setThawingPeriod(uint32_thawingPeriod) external;
line#L34: function setCurationPercentage(uint32_percentage) external;
line#L38: function setChannelDisputeEpochs(uint32_channelDisputeEpochs) external;
line#L40: function setMaxAllocationEpochs(uint32_maxAllocationEpochs) external;
line#L44: function setDelegationRatio(uint32_delegationRatio) external;
line#L47: uint32_indexingRewardCut,
line#L49: uint32_cooldownBlocks
line#L52: function setDelegationParametersCooldown(uint32_blocks) external;
line#L56: function setDelegationTaxPercentage(uint32_percentage) external;
line#L10: function setDefaultReserveRatio(uint32_defaultReserveRatio) external;
line#L14: function setCurationTaxPercentage(uint32_percentage) external;
line#L24: require(msg.sender== _proxy.admin(), "Caller must be the proxy admin");
line#L32: require(msg.sender==_implementation(), "Caller must be the implementation");
line#L44: require(!controller.paused(), "Paused");
line#L45: require(!controller.partialPaused(), "Partial-paused");
line#L53: require(msg.sender== controller.getGovernor(), "Caller must be Controller governor");
line#L57: require(msg.sender==address(controller), "Caller must be Controller");
line#L105: require(_newAdmin !=address(0), "Cannot change the admin of a proxy to the zero address");
line#L141: require(Address.isContract(_pendingImplementation), "Implementation must be a contract");
line#L142: require(
line#L143: _pendingImplementation !=address(0) &&msg.sender== _pendingImplementation,
line#L144: "Caller must be the pending implementation"
line#L145: );
line#L157: require(msg.sender!=_admin(), "Cannot fallback to proxy target");
line#L105: require(_newAdmin !=address(0), "Cannot change the admin of a proxy to the zero address");
line#L141: require(Address.isContract(_pendingImplementation), "Implementation must be a contract");
line#L142: require(
line#L143: _pendingImplementation !=address(0) &&msg.sender== _pendingImplementation,
line#L144: "Caller must be the pending implementation"
line#L145: );
/// @audit Cache `_partialPaused`. Used 3 times in `_setPartialPaused`
line#L27: if (_toPause == _partialPaused) {
line#L31: if (_partialPaused) {
line#L34: emitPartialPauseChanged(_partialPaused);
/// @audit Cache `_paused`. Used 3 times in `_setPaused`
line#L41: if (_toPause == _paused) {
line#L45: if (_paused) {
line#L48: emitPauseChanged(_paused);
If a constant variable initialization includes keccak256(), sha256(), etc. it should be marked as immutable instead
The result of the calculation of the hash (or whatever the expression is) is expected to be saved once compiled, but that's not the case. If marked as constant the calculation will be executed every time the variable is accessed.
GAS OPTIMIZATIONS REPORT
THEGRAPH
Use
1
and2
instead oftrue
andfalse
EVM word size is 32 bytes. The
uint256 1
anduint256 2
will be cheaper to use than theboolean true
andboolean false
since the first are 32 bytes long and the last are only 1 bytePausable.sol:
Function inlining
If a function is called only once it can be inlined in order to save 20 gas
GraphTokenUpgradeable.sol:
L1GraphTokenGateway.sol:
L2GraphTokenGateway.sol:
Pack storage variables in less slots to save gas
Pausable.sol:
line#L8: /// @audit Currently storage variables are packed in 4 slots but could fit in 3
Mark functions as
payable
to avoid the low-level evmis-a-payment-provided
checkThe EVM checks whether a payment is provided to the function and this check costs additional gas. If the function is marked as
payable
there is no such checkManaged.sol:
Governed.sol:
GraphUpgradeable.sol:
L2GraphToken.sol:
Use
constant
andimmutable
keywords for storage varibles if they doesn't change through contract's lifecycleThat way the variable will go to the contract's bytecode and will not allocate a storage slot
Managed.sol:
Use
calldata
where possible instead ofmemory
to save gasL1GraphTokenGateway.sol:
L2GraphTokenGateway.sol:
L2ArbitrumMessenger.sol:
Managed.sol:
L1ArbitrumMessenger.sol:
x < y + 1
is cheaper thanx <= y
L1GraphTokenGateway.sol:
GraphTokenUpgradeable.sol:
Use
uint256
instead of the smaller uints where possibleThe word-size in ethereum is 32 bytes which means that every variables which is sized with less bytes will cost more to operate with
GraphTokenUpgradeable.sol:
IGraphToken.sol:
IStaking.sol:
IStakingData.sol:
AddressAliasHelper.sol:
ICuration.sol:
Use custom errors instead of
require
stringsGoverned.sol:
GraphTokenUpgradeable.sol:
GraphUpgradeable.sol:
GraphProxyStorage.sol:
L1ArbitrumMessenger.sol:
L2GraphToken.sol:
L2GraphTokenGateway.sol:
Managed.sol:
GraphProxy.sol:
GraphTokenGateway.sol:
L1GraphTokenGateway.sol:
Use
if (x != 0)
instead ofif (x > 0)
for uints comparisonSaves 3 gas per
if
-checkL2GraphTokenGateway.sol:
L1GraphTokenGateway.sol:
Do not use strings longer than 32 bytes
GraphProxy.sol:
GraphTokenGateway.sol:
Managed.sol:
GraphUpgradeable.sol:
Avoid using
&&
inrequire()
orif()
statementsUse multiple
require()
/if
statements insteadGraphProxy.sol:
L1GraphTokenGateway.sol:
Governed.sol:
Cache storage variables in memory
Optimization comes from using MSTORE and MLOAD instead of SSTORE and SLOAD
Governed.sol:
Pausable.sol:
If a
constant
variable initialization includeskeccak256()
,sha256()
, etc. it should be marked asimmutable
insteadThe result of the calculation of the hash (or whatever the expression is) is expected to be saved once compiled, but that's not the case. If marked as
constant
the calculation will be executed every time the variable is accessed.GraphTokenUpgradeable.sol:
Do not compare a boolean to
true
orfalse
Directly use the boolean
L1GraphTokenGateway.sol:
The text was updated successfully, but these errors were encountered: