Skip to content

Commit

Permalink
chore: bump pragma (cowprotocol#155)
Browse files Browse the repository at this point in the history
## Description

This PR bumps the pragma to support up-to-and-including solidity
(`0.8.26`). This allows the foundry migration taking place to have tests
written in solc `0.8.x`, reducing redundancy / effort with writing the
associated test contracts.

It is important that the `bytecode` generated for production still be
compliant with `0.7.6` (save for potential issues associated with the
`metadata` hash appended by `solc`). To facilitate this, the `test`
pipeline uses a multi-version matrix strategy to ensure that the
contracts remain able to be built with `0.7.6`.

A minor miscellaneous patch is also included for VS Code's solidity
configuration, reducing configuration size.

## Test Plan

1. Verify `test` CI/CD runs `0.7.6` and `0.8.26` matrices.
2. Verify that the `ci` CI/CD runs (`hardhat`) and completes
successfully.

## Related Issues

Related: cowprotocol#106

---------

Co-authored-by: Federico Giacon <[email protected]>
  • Loading branch information
2 people authored and kamuik16 committed Jun 5, 2024
1 parent 4277af4 commit 3c0d01c
Show file tree
Hide file tree
Showing 41 changed files with 50 additions and 44 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
test:
strategy:
fail-fast: true
matrix:
profile: [solc-0.7.6,default]

name: Foundry project
runs-on: ubuntu-latest
Expand All @@ -50,13 +52,19 @@ jobs:
with:
version: nightly

- name: Run Forge build
- name: Run Forge build with ${{ matrix.profile }}
# We always build with 0.7.6 to ensure that the project is compatible with the oldest version
run: |
forge --version
forge build --sizes
if [ "${{ matrix.profile }}" == "solc-0.7.6" ]; then
forge build --sizes --use 0.7.6 --skip 'test/*'
else
forge build --sizes
fi
id: build

- name: Run Forge tests
if: matrix.profile != 'solc-0.7.6'
run: |
forge test -vvv
id: test
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"solidity.packageDefaultDependenciesDirectory": ["node_modules", "lib"],
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
Expand Down
1 change: 0 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ out = "out"
libs = ["node_modules", "lib"]

# Compiler settings
solc = "0.7.6"
via_ir = false
optimizer = true
optimizer_runs = 1000000
2 changes: 1 addition & 1 deletion src/contracts/GPv2AllowListAuthentication.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "./interfaces/GPv2Authentication.sol";
import "./libraries/GPv2EIP1967.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/GPv2Settlement.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "./GPv2VaultRelayer.sol";
Expand Down Expand Up @@ -250,7 +250,7 @@ contract GPv2Settlement is GPv2Signing, ReentrancyGuard, StorageAccessible {
function invalidateOrder(bytes calldata orderUid) external {
(, address owner, ) = orderUid.extractOrderUidParams();
require(owner == msg.sender, "GPv2: caller does not own order");
filledAmount[orderUid] = uint256(-1);
filledAmount[orderUid] = type(uint256).max;
emit OrderInvalidated(owner, orderUid);
}

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/GPv2VaultRelayer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "./interfaces/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/interfaces/GPv2Authentication.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/// @title Gnosis Protocol v2 Authentication Interface
/// @author Gnosis Developers
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/interfaces/GPv2EIP1271.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

library GPv2EIP1271 {
/// @dev Value returned by a call to `isValidSignature` if the signature
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/interfaces/IERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - Added `name`, `symbol` and `decimals` function declarations
// <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/token/ERC20/IERC20.sol>

pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/**
* @dev Interface of the ERC20 standard as defined in the EIP.
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "./IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/GPv2EIP1967.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

library GPv2EIP1967 {
/// @dev The storage slot where the proxy administrator is stored, defined
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/GPv2Interaction.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/// @title Gnosis Protocol v2 Interaction Library
/// @author Gnosis Developers
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/GPv2Order.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../interfaces/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/GPv2SafeERC20.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../interfaces/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/GPv2Trade.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../interfaces/IERC20.sol";
import "../mixins/GPv2Signing.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/GPv2Transfer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../interfaces/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/SafeCast.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// - Convert to `type(*).*` notation
// <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/utils/SafeCast.sol>

pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/libraries/SafeMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// - Added `ceilDiv` method
// <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/math/SafeMath.sol>

pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/mixins/GPv2Signing.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../interfaces/GPv2EIP1271.sol";
import "../libraries/GPv2Order.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/mixins/Initializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// - Inlined `Address.isContract` implementation
// <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/proxy/Initializable.sol>

pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/mixins/ReentrancyGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - Formatted code
// <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/utils/ReentrancyGuard.sol>

pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/**
* @dev Contract module that helps prevent reentrant calls to a function.
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/mixins/StorageAccessible.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - Added linter directives to ignore low level call and assembly warnings
// <https://github.com/gnosis/util-contracts/blob/v3.1.0-solc-7/contracts/StorageAccessible.sol>

pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/// @title ViewStorageAccessible - Interface on top of StorageAccessible base class to allow simulations from view functions
interface ViewStorageAccessible {
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/reader/AllowListStorageReader.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

/// @title Gnosis Protocol v2 Allow List Storage Reader
/// @author Gnosis Developers
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/reader/GPv2TradeSimulator.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../GPv2Settlement.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/reader/SettlementStorageReader.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

/// @title Gnosis Protocol v2 Settlement Storage Reader
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/EventEmitter.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

contract EventEmitter {
event Event(uint256 value, uint256 number);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../GPv2AllowListAuthentication.sol";
import "../libraries/GPv2EIP1967.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2AllowListAuthenticationV2.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../GPv2AllowListAuthentication.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2InteractionTestInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Interaction.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2OrderTestInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Order.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2SafeERC20TestInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../interfaces/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2SettlementTestInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../GPv2Settlement.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2SigningTestInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Order.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2TradeTestInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Order.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/GPv2TransferTestInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Transfer.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/NonPayable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

contract NonPayable {
// solhint-disable-next-line no-empty-blocks, payable-fallback
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/NonStandardERC20.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../libraries/SafeMath.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/SmartSellOrder.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../interfaces/GPv2EIP1271.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/StateChangingERC1271.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;
pragma solidity >=0.7.6 <0.9.0;

import "../interfaces/GPv2EIP1271.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/vendor/StorageAccessibleWrapper.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
pragma solidity >=0.7.6 <0.9.0;

import "../../mixins/StorageAccessible.sol";

Expand Down
4 changes: 2 additions & 2 deletions test/TestNoOp.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.7.6;
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity >=0.7.6 <0.9.0;

/// @dev No-op contract for start of forgifying contracts. Delete this!
contract TestNoOp {
Expand Down

0 comments on commit 3c0d01c

Please sign in to comment.