We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
You can make the initialized variable not initialized bec its already 0 it wastes gas bec your sstore 25000 gas https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L54 Make functions on admin function payable it saves gas bec of not checking for msg.value = zero https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L124 Instead of using && in a require statement use multiple require statements to save gas https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L301 Make require string less than 32 bytes save gas https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L386 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L390 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L405 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L416 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L511 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L527
Use custom errors instead of revert string to save gas Custom errors from Solidity 0.8.4 are cheaper than revert strings (cheaper deployment cost and runtime cost when the revert condition is met) Source: Custom Errors in Solidity: Starting from Solidity v0.8.4, there is a convenient and gas-efficient way to explain to users why an operation failed through the use of custom errors. Until now, you could already use strings to give more information about failures (e.g., revert("Insufficient funds.");), but they are rather expensive, especially when it comes to deploy cost, and it is difficult to use dynamic information in them. Custom errors are defined using the error statement, which can be used inside and outside of contracts (including interfaces and libraries) https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L386 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L390 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L396 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L511 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L527 ++i costs less gas compared to i++ for unsigned integer, as pre-increment is cheaper (about 5 gas per iteration) i++ increments i and returns the initial value of i https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L579 https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L660
The text was updated successfully, but these errors were encountered:
simon135 issue #31
44e4753
No branches or pull requests
You can make the initialized variable not initialized bec its already 0 it wastes gas bec your sstore 25000 gas
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L54
Make functions on admin function payable it saves gas bec of not checking for msg.value = zero
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L124
Instead of using && in a require statement use multiple require statements to save gas
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L301
Make require string less than 32 bytes save gas
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L386
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L390
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L405
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L416
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L511
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L527
Use custom errors instead of revert string to save gas
Custom errors from Solidity 0.8.4 are cheaper than revert strings (cheaper deployment cost and runtime cost when the revert condition is met) Source: Custom Errors in Solidity: Starting from Solidity v0.8.4, there is a convenient and gas-efficient way to explain to users why an operation failed through the use of custom errors. Until now, you could already use strings to give more information about failures (e.g., revert("Insufficient funds.");), but they are rather expensive, especially when it comes to deploy cost, and it is difficult to use dynamic information in them. Custom errors are defined using the error statement, which can be used inside and outside of contracts (including interfaces and libraries)
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L386
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L390
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L396
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L511
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L527
++i costs less gas compared to i++ for unsigned integer, as pre-increment is cheaper (about 5 gas per iteration) i++ increments i and returns the initial value of i
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L579
https://github.com/code-423n4/2022-05-cudos/blob/4e08b7ba7c40252ac64fe4169f8a40622333ee63/solidity/contracts/Gravity.sol#L660
The text was updated successfully, but these errors were encountered: