Skip to content

Commit

Permalink
feat: upgrade solidity 0.8.22 (#651)
Browse files Browse the repository at this point in the history
* feat: bump solidity 0.8.22

* refactor: support ^0.8.19 but use 0.8.22

* fix: pragma

* chore: reorg contracts with different solc version

* chore: add foundry profile for different compiler versions

* refactor: remove default loop increment optimizations

* docs: update readme

* refactor: use ^0.8.19 in all strategies
  • Loading branch information
ilpepepig committed Aug 28, 2024
1 parent a0142e8 commit 2bedcc9
Show file tree
Hide file tree
Showing 107 changed files with 161 additions and 262 deletions.
2 changes: 1 addition & 1 deletion contracts/core/Allo.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ sequenceDiagram
## Smart Contract Overview

* **License:** The contract is licensed under the AGPL-3.0-only license.
* **Solidity Version:** The contract is written in Solidity version 0.8.19.
* **Solidity Version:** The contract supports Solidity versions ^0.8.19, but is developed in Solidity version 0.8.22.
* **Inheritance:** The contract inherits from several other contracts: `Initializable`, `Ownable`, `AccessControl`, `IAllo`, `Native`, and `Transfer`.

### Storage Variables
Expand Down
43 changes: 9 additions & 34 deletions contracts/core/Allo.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// External Libraries
import "solady/auth/Ownable.sol";
Expand Down Expand Up @@ -269,12 +269,8 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
/// @param _poolId ID of the pool
/// @param _managers The addresses to add
function addPoolManagers(uint256 _poolId, address[] calldata _managers) public onlyPoolAdmin(_poolId) {
for (uint256 i; i < _managers.length;) {
for (uint256 i; i < _managers.length; ++i) {
_addPoolManager(_poolId, _managers[i]);

unchecked {
++i;
}
}
}

Expand All @@ -283,36 +279,26 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
/// @param _poolId ID of the pool
/// @param _managers The addresses to remove
function removePoolManagers(uint256 _poolId, address[] calldata _managers) public onlyPoolAdmin(_poolId) {
for (uint256 i; i < _managers.length;) {
for (uint256 i; i < _managers.length; ++i) {
_revokeRole(pools[_poolId].managerRole, _managers[i]);

unchecked {
++i;
}
}
}

/// @notice Add multiple pool managers to multiple pools
/// @param _poolIds IDs of the pools
/// @param _managers The addresses to add
function addPoolManagersInMultiplePools(uint256[] calldata _poolIds, address[] calldata _managers) external {
for (uint256 i; i < _poolIds.length;) {
for (uint256 i; i < _poolIds.length; ++i) {
addPoolManagers(_poolIds[i], _managers);
unchecked {
++i;
}
}
}

/// @notice Remove multiple pool managers from multiple pools
/// @param _poolIds IDs of the pools
/// @param _managers The addresses to remove
function removePoolManagersInMultiplePools(uint256[] calldata _poolIds, address[] calldata _managers) external {
for (uint256 i; i < _poolIds.length;) {
for (uint256 i; i < _poolIds.length; ++i) {
removePoolManagers(_poolIds[i], _managers);
unchecked {
++i;
}
}
}

Expand Down Expand Up @@ -368,11 +354,8 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
if (poolIdLength != _data.length || poolIdLength != _recipientAddresses.length) revert MISMATCH();

// Loop through the '_poolIds' & '_data' and call the 'strategy.register()' function
for (uint256 i; i < poolIdLength;) {
for (uint256 i; i < poolIdLength; ++i) {
recipientIds[i] = pools[_poolIds[i]].strategy.register(_recipientAddresses[i], _data[i], _msgSender());
unchecked {
++i;
}
}

// Return the recipientIds that have been registered
Expand Down Expand Up @@ -438,12 +421,9 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
// Loop through the _poolIds & _datas and call the internal _allocate() function
uint256 totalValue;
address msgSender = _msgSender();
for (uint256 i; i < numPools;) {
for (uint256 i; i < numPools; ++i) {
_allocate(_poolIds[i], _recipients[i], _amounts[i], _datas[i], _values[i], msgSender);
totalValue += _values[i];
unchecked {
++i;
}
}
// Reverts if the sum of all the allocated values is different than 'msg.value' with 'MISMATCH()' error
if (totalValue != msg.value) revert ETH_MISMATCH();
Expand Down Expand Up @@ -548,13 +528,8 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable

// grant pool managers roles
uint256 managersLength = _managers.length;
for (uint256 i; i < managersLength;) {
address manager = _managers[i];
_addPoolManager(poolId, manager);

unchecked {
++i;
}
for (uint256 i; i < managersLength; ++i) {
_addPoolManager(poolId, _managers[i]);
}

if (baseFee > 0) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/Anchor.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The `Anchor` contract serves as a crucial utility within the Allo ecosystem, fac
## Smart Contract Overview

* **License:** The `Anchor` contract is licensed under the AGPL-3.0-only license, promoting the use of open-source software.
* **Solidity Version:** Developed using Solidity version 0.8.19, harnessing the latest advancements in Ethereum smart contract technology.
* **Solidity Version:** Supports Solidity versions ^0.8.19, but developed using Solidity version 0.8.22, harnessing the latest advancements in Ethereum smart contract technology.

### Storage Variables

Expand Down
2 changes: 1 addition & 1 deletion contracts/core/Anchor.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

import "openzeppelin-contracts/contracts/token/ERC721/utils/ERC721Holder.sol";
import "openzeppelin-contracts/contracts/token/ERC1155/utils/ERC1155Holder.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/Registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ sequenceDiagram
## Smart Contract Overview

* **License:** The `Registry` contract adheres to the MIT License, promoting permissive open-source usage.
* **Solidity Version:** Developed using Solidity version 0.8.19, harnessing the latest advancements in Ethereum smart contract technology.
* **Solidity Version:** Supports Solidity versions ^0.8.19, but developed using Solidity version 0.8.22, harnessing the latest advancements in Ethereum smart contract technology.
* **External Libraries:** The contract incorporates the `AccessControl` and `CREATE3` external libraries, enhancing access control and facilitating contract deployment.
* **Interfaces:** The contract utilizes the `IRegistry` interface for communication with external components.

Expand Down
17 changes: 4 additions & 13 deletions contracts/core/Registry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// External Libraries
import "openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol";
Expand Down Expand Up @@ -153,17 +153,14 @@ contract Registry is IRegistry, Initializable, AccessControlUpgradeable, Errors
revert UNAUTHORIZED();
}

for (uint256 i; i < memberLength;) {
for (uint256 i; i < memberLength; ++i) {
address member = _members[i];

// Will revert if any of the addresses are a zero address
if (member == address(0)) revert ZERO_ADDRESS();

// Grant the role to the member and emit the event for each member
_grantRole(profileId, member);
unchecked {
++i;
}
}

// Emit the event that the profile was created
Expand Down Expand Up @@ -291,17 +288,14 @@ contract Registry is IRegistry, Initializable, AccessControlUpgradeable, Errors
uint256 memberLength = _members.length;

// Loop through the members and add them to the profile by granting the role
for (uint256 i; i < memberLength;) {
for (uint256 i; i < memberLength; ++i) {
address member = _members[i];

// Will revert if any of the addresses are a zero address
if (member == address(0)) revert ZERO_ADDRESS();

// Grant the role to the member and emit the event for each member
_grantRole(_profileId, member);
unchecked {
++i;
}
}
}

Expand All @@ -313,12 +307,9 @@ contract Registry is IRegistry, Initializable, AccessControlUpgradeable, Errors
uint256 memberLength = _members.length;

// Loop through the members and remove them from the profile by revoking the role
for (uint256 i; i < memberLength;) {
for (uint256 i; i < memberLength; ++i) {
// Revoke the role from the member and emit the event for each member
_revokeRole(_profileId, _members[i]);
unchecked {
++i;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/core/interfaces/IBaseStrategy.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

import {IAllo} from "./IAllo.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/core/libraries/Clone.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// External Libraries
import "openzeppelin-contracts-upgradeable/contracts/proxy/ClonesUpgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/libraries/Errors.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/libraries/Metadata.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/libraries/Native.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/libraries/QFHelper.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

import "solady/utils/FixedPointMathLib.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/core/libraries/QVHelper.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

import "solady/utils/FixedPointMathLib.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/core/libraries/Transfer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// External Libraries
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/EASGatingExtension.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

/// External Libraries
import {IEAS, Attestation} from "eas-contracts/IEAS.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/NFTGatingExtension.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

/// External Libraries
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/TokenGatingExtension.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

/// External Libraries
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
8 changes: 2 additions & 6 deletions contracts/extensions/contracts/MilestonesExtension.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// Interfaces
import {IMilestonesExtension} from "../interfaces/IMilestonesExtension.sol";
Expand Down Expand Up @@ -77,18 +77,14 @@ abstract contract MilestonesExtension is CoreBaseStrategy, IMilestonesExtension

// Loop through the milestones and add them to the milestones array
uint256 milestonesLength = _milestones.length;
for (uint256 i; i < milestonesLength;) {
for (uint256 i; i < milestonesLength; ++i) {
uint256 amountPercentage = _milestones[i].amountPercentage;

if (amountPercentage == 0) revert INVALID_MILESTONE();

totalAmountPercentage += amountPercentage;
_milestones[i].status = MilestoneStatus.None;
milestones.push(_milestones[i]);

unchecked {
i++;
}
}

// Check if the all milestone amount percentage totals to 1e18 (100%)
Expand Down
14 changes: 3 additions & 11 deletions contracts/extensions/contracts/RecipientsExtension.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

import {IRecipientsExtension} from "../interfaces/IRecipientsExtension.sol";
import {IRegistry} from "../../core/interfaces/IRegistry.sol";
Expand Down Expand Up @@ -118,7 +118,7 @@ abstract contract RecipientsExtension is CoreBaseStrategy, Errors, IRecipientsEx
_validateReviewRecipients(msg.sender);
if (refRecipientsCounter != recipientsCounter) revert INVALID();
// Loop through the statuses and set the status
for (uint256 i; i < statuses.length;) {
for (uint256 i; i < statuses.length; ++i) {
uint256 rowIndex = statuses[i].index;
uint256 fullRow = statuses[i].statusRow;

Expand All @@ -130,10 +130,6 @@ abstract contract RecipientsExtension is CoreBaseStrategy, Errors, IRecipientsEx

// Emit that the recipient status has been updated with the values
emit RecipientStatusUpdated(rowIndex, fullRow, msg.sender);

unchecked {
i++;
}
}
}

Expand Down Expand Up @@ -355,7 +351,7 @@ abstract contract RecipientsExtension is CoreBaseStrategy, Errors, IRecipientsEx
function _processStatusRow(uint256 _rowIndex, uint256 _fullRow) internal returns (uint256) {
// Loop through each status in the updated row
uint256 currentRow = statusesBitMap[_rowIndex];
for (uint256 col = 0; col < 64;) {
for (uint256 col = 0; col < 64; ++col) {
// Extract the status at the column index
uint256 colIndex = col << 2; // col * 4
uint8 newStatus = uint8((_fullRow >> colIndex) & 0xF);
Expand All @@ -371,10 +367,6 @@ abstract contract RecipientsExtension is CoreBaseStrategy, Errors, IRecipientsEx
_fullRow = reviewedRow | (uint256(reviewedStatus) << colIndex);
}
}

unchecked {
col++;
}
}
return _fullRow;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/interfaces/IMilestonesExtension.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

import {Metadata} from "../../core/libraries/Metadata.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/interfaces/IRecipientsExtension.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

import {Metadata} from "../../core/libraries/Metadata.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/factories/ContractFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// External
import {CREATE3} from "solady/utils/CREATE3.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/factories/DGLFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// External Libraries
import "solady/auth/Ownable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/factories/DVMDTFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.19;
pragma solidity ^0.8.19;

// External Libraries
import "solady/auth/Ownable.sol";
Expand Down
Loading

0 comments on commit 2bedcc9

Please sign in to comment.