Skip to content

A simple smart contract to test the effectiveness of common code4rena gas optimizations.

Notifications You must be signed in to change notification settings

ardislu/code4rena-gas-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

code4rena-gas-test

Update October 2023: starting in Solidity 0.8.22, the G011 ("Unnecessary checked arithmetic in for loop") gas optimization is performed automatically by the solc compiler! So the unchecked block can be dropped:

+ for (uint256 i; i < len; ++i) {
- for (uint256 i; i < len; ) {
-   unchecked { ++i; }
}

Other gas optimizations remain the same however.


A simple smart contract to test the effectiveness of common code4rena gas optimizations.

Specifically:

  • G001 - Don't Initialize Variables with Default Value
  • G002 - Cache Array Length Outside of Loop
  • G011 - Unnecessary checked arithmetic in for loop
  • G012 - Use Prefix Increment instead of Postfix Increment if possible

Use Echidna to run the test:

echidna GasTest.sol --config echidna.yaml

About

A simple smart contract to test the effectiveness of common code4rena gas optimizations.

Topics

Resources

Stars

Watchers

Forks