Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #170

Open
code423n4 opened this issue May 23, 2022 · 0 comments
Open

Gas Optimizations #170

code423n4 opened this issue May 23, 2022 · 0 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Gas Optimization

G-1 Comparisons:
In contract Aura.sol
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#:~:text=require(_amount%20%3E%200%2C%20%22Must%20mint%20something%22)%3B

0 is less efficient for unsigned integers. Only if enable optimizer is on. != 0 will cost less compared to > 0.

G-2 Not needing to put False at isShutdown variable in AuraLocker.sol
In contract AuraLocker.sol
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#:~:text=bool%20public%20isShutdown%20%3D%20false%3B

You can just say bool public isShutdown; since the default value of bool is false.

G-3 Not needing to put false at initialised variable in AuraVestedEscrow.sol
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#:~:text=bool%20public%20initialised%20%3D%20false%3B
You can just say bool public initialised; as the default value of bool is false.

G-4 ++i cost less gas compared to i++

++i will cost less gas compared to i++ for uint especially useful for for loops where each iterations are about 5 gas.
Instances where:
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraClaimZap.sol#:~:text=curve%20LP%20pools-,for%20(uint256%20i%20%3D%200%3B%20i%20%3C%20rewardContracts.length%3B%20i,%7D,-//%20claim%20others/deposit

contracts/AuraLocker.sol:174:
contracts/AuraLocker.sol:306:
contracts/AuraLocker.sol:410:
contracts/AuraLocker.sol:696:
contracts/AuraLocker.sol:773:

https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#:~:text=for%20(uint256%20i%20%3D%200%3B%20i%20%3C%20_recipient.length%3B%20i%2B%2B)%20%7B

https://github.com/code-423n4/2022-05-aura/blob/main/contracts/ExtraRewardsDistributor.sol#:~:text=for%20(uint256%20i%20%3D%20epochIndex%3B%20i%20%3C%20tokenEpochs%3B%20i%2B%2B)%20%7B

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels May 23, 2022
code423n4 added a commit that referenced this issue May 23, 2022
@0xMaharishi 0xMaharishi added the duplicate This issue or pull request already exists label May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

2 participants