Skip to content

Commit

Permalink
fix: replace ++i with i++
Browse files Browse the repository at this point in the history
closes #68
  • Loading branch information
MaxMustermann2 committed Aug 5, 2024
1 parent 4af2fd6 commit ca7d77c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/Bootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ contract Bootstrap is
// like reentrancy.
// slither-disable-next-line reentrancy-no-eth
function _addWhitelistTokens(address[] calldata tokens) internal {
for (uint256 i; i < tokens.length; i++) {
for (uint256 i; i < tokens.length; ++i) {
address token = tokens[i];
if (token == address(0)) {
revert Errors.ZeroAddress();
Expand Down
2 changes: 1 addition & 1 deletion src/core/ClientGatewayLzReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ abstract contract ClientGatewayLzReceiver is PausableUpgradeable, OAppReceiverUp
revert InvalidAddWhitelistTokensRequest(expectedLength, requestPayload.length);
}

for (uint256 i; i < count; i++) {
for (uint256 i; i < count; ++i) {
uint256 start = i * TOKEN_ADDRESS_BYTES_LENGTH + 1;
uint256 end = start + TOKEN_ADDRESS_BYTES_LENGTH;
address token = address(bytes20(requestPayload[start:end]));
Expand Down
4 changes: 2 additions & 2 deletions src/core/ExocoreGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ contract ExocoreGateway is
if (!success) {
revert Errors.ExocoreGatewayFailedToGetClientChainIds();
}
for (uint256 i = 0; i < chainIndices.length; i++) {
for (uint256 i = 0; i < chainIndices.length; ++i) {
uint32 chainIndex = chainIndices[i];
if (!chainToBootstrapped[chainIndex]) {
_sendInterchainMsg(chainIndex, Action.REQUEST_MARK_BOOTSTRAP, "", true);
Expand Down Expand Up @@ -190,7 +190,7 @@ contract ExocoreGateway is

bool success;
bool updated;
for (uint256 i; i < tokens.length; i++) {
for (uint256 i; i < tokens.length; ++i) {
require(tokens[i] != bytes32(0), "ExocoreGateway: token cannot be zero address");
require(tvlLimits[i] > 0, "ExocoreGateway: tvl limit should not be zero");
require(bytes(names[i]).length != 0, "ExocoreGateway: name cannot be empty");
Expand Down
6 changes: 3 additions & 3 deletions src/libraries/Merkle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ library Merkle {
proof.length != 0, "Merkle.processInclusionProofSha256: proof length should be a non-zero multiple of 32"
);
bytes32[1] memory computedHash = [leaf];
for (uint256 i = 0; i < proof.length; i++) {
for (uint256 i = 0; i < proof.length; ++i) {
bytes32[1] memory node = [proof[i]];
if (index % 2 == 0) {
// if ith bit of index is 0, then computedHash is a left sibling
Expand Down Expand Up @@ -90,15 +90,15 @@ library Merkle {
//create a layer to store the internal nodes
bytes32[] memory layer = new bytes32[](numNodesInLayer);
//fill the layer with the pairwise hashes of the leaves
for (uint256 i = 0; i < numNodesInLayer; i++) {
for (uint256 i = 0; i < numNodesInLayer; ++i) {
layer[i] = sha256(abi.encodePacked(leaves[2 * i], leaves[2 * i + 1]));
}
//the next layer above has half as many nodes
numNodesInLayer /= 2;
//while we haven't computed the root
while (numNodesInLayer != 0) {
//overwrite the first numNodesInLayer nodes in layer with the pairwise hashes of their children
for (uint256 i = 0; i < numNodesInLayer; i++) {
for (uint256 i = 0; i < numNodesInLayer; ++i) {
layer[i] = sha256(abi.encodePacked(layer[2 * i], layer[2 * i + 1]));
}
//the next layer above has half as many nodes
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/ValidatorContainer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ library ValidatorContainer {

function merkleizeValidatorContainer(bytes32[] calldata validatorContainer) internal pure returns (bytes32) {
bytes32[] memory leaves = validatorContainer;
for (uint256 i; i < MERKLE_TREE_HEIGHT; i++) {
for (uint256 i; i < MERKLE_TREE_HEIGHT; ++i) {
bytes32[] memory roots = new bytes32[](leaves.length / 2);
for (uint256 j; j < leaves.length / 2; j++) {
roots[j] = sha256(abi.encodePacked(leaves[2 * j], leaves[2 * j + 1]));
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/WithdrawalContainer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ library WithdrawalContainer {

function merkleizeWithdrawalContainer(bytes32[] calldata withdrawalContainer) internal pure returns (bytes32) {
bytes32[] memory leaves = withdrawalContainer;
for (uint256 i; i < MERKLE_TREE_HEIGHT; i++) {
for (uint256 i; i < MERKLE_TREE_HEIGHT; ++i) {
bytes32[] memory roots = new bytes32[](leaves.length / 2);
for (uint256 j; j < leaves.length / 2; j++) {
roots[j] = sha256(abi.encodePacked(leaves[2 * j], leaves[2 * j + 1]));
Expand Down
2 changes: 1 addition & 1 deletion src/storage/GatewayStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ contract GatewayStorage {
if (stringBytes.length != 42) {
return false;
}
for (uint256 i = 0; i < EXO_ADDRESS_PREFIX.length; i++) {
for (uint256 i = 0; i < EXO_ADDRESS_PREFIX.length; ++i) {
if (stringBytes[i] != EXO_ADDRESS_PREFIX[i]) {
return false;
}
Expand Down

3 comments on commit ca7d77c

@magj2006
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are still some statements where i is not initialize to 0, please initialize them, it'll give you good back.

@MaxMustermann2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialized, please review again. PS: better to leave your reviews on the pull request instead of the commit

@magj2006
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialized, please review again. PS: better to leave your reviews on the pull request instead of the commit

Ok :)

Please sign in to comment.