diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1561abf3363..f8d282bbbb6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -210,6 +210,25 @@ struct Some { } ``` +#### For-loop +The variable in the for-loop shall not be initialized with 0, and we enforce using `++var` instead of `var++``. + +This is **correct**: + +``` +for (uint256 i; i < 100; ++i) { +} + +``` + +This is **wrong**: + +``` +for (uint256 i = 0; i < 100; i++) { +} + +``` + #### Mentioning other files in the repo To mention another contract file in the repo use the standard like this: diff --git a/packages/protocol/contracts/L1/provers/Guardians.sol b/packages/protocol/contracts/L1/provers/Guardians.sol index a4daa55379e..d84a5fbac86 100644 --- a/packages/protocol/contracts/L1/provers/Guardians.sol +++ b/packages/protocol/contracts/L1/provers/Guardians.sol @@ -77,7 +77,7 @@ abstract contract Guardians is EssentialContract { delete guardians; // Set the new guardians - for (uint256 i = 0; i < _newGuardians.length; ++i) { + for (uint256 i; i < _newGuardians.length; ++i) { address guardian = _newGuardians[i]; if (guardian == address(0)) revert INVALID_GUARDIAN(); // This makes sure there are not duplicate addresses