Skip to content

Commit

Permalink
feat: evm version
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-something committed Jul 23, 2024
1 parent a65a9c0 commit 350c39d
Show file tree
Hide file tree
Showing 46 changed files with 68 additions and 89 deletions.
1 change: 0 additions & 1 deletion crytic-export/combined_solc.json

This file was deleted.

4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ multiline_func_header = 'params_first'
sort_imports = true

[profile.default]
solc_version = '0.8.23'
solc_version = '0.8.25'
libs = ["node_modules", "lib"]
optimizer_runs = 500
evm_version = 'cancun'
evm_version = 'shanghai'
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}]
# 2018: function can be view, so far only caused by mocks
# 2394: solc insists on reporting on every transient storage use
Expand Down
2 changes: 1 addition & 1 deletion script/DeployBCoWFactory.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BCoWFactory} from 'contracts/BCoWFactory.sol';
import {Script} from 'forge-std/Script.sol';
Expand Down
2 changes: 1 addition & 1 deletion script/DeployBFactory.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BFactory} from 'contracts/BFactory.sol';
import {Script} from 'forge-std/Script.sol';
Expand Down
2 changes: 1 addition & 1 deletion script/Params.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

contract Params {
struct BFactoryDeploymentParams {
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BCoWConst.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.8.23;
pragma solidity 0.8.25;

/**
* @title BCoWConst
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BCoWFactory.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.8.23;
pragma solidity 0.8.25;

import {BCoWPool} from './BCoWPool.sol';
import {BFactory} from './BFactory.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BCoWPool.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.8.23;
pragma solidity 0.8.25;

/*
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BConst.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.8.23;
pragma solidity 0.8.25;

/**
* @title BConst
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BFactory.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.8.23;
pragma solidity 0.8.25;

import {BPool} from './BPool.sol';
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BMath.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.8.23;
pragma solidity 0.8.25;

import {BConst} from './BConst.sol';
import {BNum} from './BNum.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BNum.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.8.23;
pragma solidity 0.8.25;

import {BConst} from './BConst.sol';

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BPool.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.8.23;
pragma solidity 0.8.25;

import {BMath} from './BMath.sol';
import {BToken} from './BToken.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/BToken.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.8.23;
pragma solidity 0.8.25;

import {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol';

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IBCoWFactory.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.8.23;
pragma solidity 0.8.25;

import {IBFactory} from 'interfaces/IBFactory.sol';

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IBCoWPool.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.8.23;
pragma solidity 0.8.25;

import {GPv2Order} from '@cowprotocol/libraries/GPv2Order.sol';
import {IERC1271} from '@openzeppelin/contracts/interfaces/IERC1271.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IBFactory.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.8.23;
pragma solidity 0.8.25;

import {IBPool} from 'interfaces/IBPool.sol';

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IBPool.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.8.23;
pragma solidity 0.8.25;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ISettlement.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {IERC20} from '@cowprotocol/interfaces/IERC20.sol';
import {GPv2Interaction} from '@cowprotocol/libraries/GPv2Interaction.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/integration/BCowPool.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BPoolIntegrationTest} from './BPool.t.sol';
import {GPv2TradeEncoder} from '@composable-cow/test/vendored/GPv2TradeEncoder.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/integration/BPool.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {IERC20} from '@cowprotocol/interfaces/IERC20.sol';
import {BFactory} from 'contracts/BFactory.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/integration/DeploymentGas.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BFactory} from 'contracts/BFactory.sol';

Expand Down
7 changes: 4 additions & 3 deletions test/invariants/PROPERTIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
| when a hash has been commited, only this order can be settled | High level | 23 | [ ] | [ ] |
| BToken should not break the ToB ERC20 properties** | High level | 24 | | [x] |

(*) Bundled with 24
> (*) Bundled with 24
(**) [Trail of Bits ERC20 properties](https://github.com/crytic/properties?tab=readme-ov-file#erc20-tests)
> (**) [Trail of Bits ERC20 properties](https://github.com/crytic/properties?tab=readme-ov-file#erc20-tests)
[ ] planed to implement and still to do
<br>[x] implemented and tested
<br>:( implemented but judged as incorrect (tool limitation, etc)
<br>:( implemented but test not passing due to an external factor (tool limitation - eg halmos max unrolling loop, etc)
<br>empty not implemented and will not be (design, etc)

# Unit-test properties for the math libs (BNum and BMath):
Expand Down Expand Up @@ -85,6 +85,7 @@ bpow should be distributive over mult of the same base x^a * x^b == x^(a+b)
bpow should be distributive over mult of the same exp a^x * b^x == (a*b)^x
power of a power should mult the exp (x^a)^b == x^(a*b)

## Untested (precision issues in test settingsq)
calcOutGivenIn should be inv with calcInGivenOut
calcPoolOutGivenSingleIn should be inv with calcSingleInGivenPoolOut
calcSingleOutGivenPoolIn should be inv with calcPoolInGivenSingleOut
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {EchidnaTest} from '../helpers/AdvancedTestsUtils.sol';

Expand All @@ -17,50 +17,18 @@ contract FuzzBMath is BMath, EchidnaTest {
) public {
tokenWeightIn = clamp(tokenWeightIn, MIN_WEIGHT, MAX_WEIGHT);
tokenWeightOut = clamp(tokenWeightOut, MIN_WEIGHT, MAX_WEIGHT);
tokenBalanceIn = clamp(tokenBalanceIn, 1, type(uint256).max);

uint256 calc_tokenAmountOut =
calcOutGivenIn(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountIn, swapFee);

uint256 calc_tokenAmountIn =
calcInGivenOut(tokenBalanceOut, tokenWeightOut, tokenBalanceIn, tokenWeightIn, calc_tokenAmountOut, swapFee);

assert(tokenAmountIn == calc_tokenAmountIn);
}

event log_uint(uint256 value);

function test_debug() public {
uint256 tokenBalanceIn = 0;
uint256 tokenWeightIn = 0;
uint256 tokenBalanceOut = 0;
uint256 tokenWeightOut = 0;
uint256 tokenAmountIn = 1;
uint256 swapFee = 0;

tokenWeightIn = clamp(tokenWeightIn, MIN_WEIGHT, MAX_WEIGHT);
tokenWeightOut = clamp(tokenWeightOut, MIN_WEIGHT, MAX_WEIGHT);
tokenAmountIn = clamp(tokenAmountIn, 1, type(uint256).max);
tokenBalanceOut = clamp(tokenBalanceOut, 1, type(uint256).max);
tokenBalanceIn = clamp(tokenBalanceIn, 1, type(uint256).max);
tokenAmountIn = clamp(tokenAmountIn, 1 ether, 10 ether);
tokenBalanceOut = clamp(tokenBalanceOut, 1 ether, 10 ether);
tokenBalanceIn = clamp(tokenBalanceIn, 1 ether, 10 ether);
swapFee = clamp(swapFee, MIN_FEE, MAX_FEE);

emit log_uint(tokenWeightIn);
emit log_uint(tokenWeightOut);
emit log_uint(tokenAmountIn);
emit log_uint(tokenBalanceOut);
emit log_uint(tokenBalanceIn);
emit log_uint(swapFee);

uint256 calc_tokenAmountOut =
calcOutGivenIn(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountIn, swapFee);
emit log_uint(calc_tokenAmountOut);

uint256 calc_tokenAmountIn =
calcInGivenOut(tokenBalanceOut, tokenWeightOut, tokenBalanceIn, tokenWeightIn, calc_tokenAmountOut, swapFee);

emit log_uint(calc_tokenAmountIn);
assert(calc_tokenAmountOut == calc_tokenAmountIn);
assert(tokenAmountIn == calc_tokenAmountIn || tokenAmountIn > calc_tokenAmountIn ? tokenAmountIn - calc_tokenAmountIn < BONE : calc_tokenAmountIn - tokenAmountIn < BONE);
}

// calcInGivenOut should be inverse of calcOutGivenIn
Expand Down
16 changes: 12 additions & 4 deletions test/invariants/fuzz/BNum.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {EchidnaTest} from '../helpers/AdvancedTestsUtils.sol';

Expand Down Expand Up @@ -373,17 +373,25 @@ contract FuzzBNum is BNum, EchidnaTest, Test {
}

// bpowi should be distributive over mult of the same exp a^x b^x == (ab)^x
function bpowi_distributiveExp(uint256 _a, uint256 _b, uint256 _exp) public pure {
function bpowi_distributiveExp(uint256 _a, uint256 _b, uint256 _exp) public {
_a = clamp(_a, 1, 10_000);
_b = clamp(_b, 1, 10_000);
_exp = clamp(_exp, 1, 1000 * BONE);

uint256 _result1 = bpowi(bmul(_a, _b), _exp);
uint256 _result2 = bmul(bpowi(_a, _exp), bpowi(_b, _exp));

emit log_named_uint('result1', _result1);
emit log_named_uint('result2', _result2);

assert(_result1 == _result2);
}

// power of a power should mult the exp (x^a)^b == x^(ab)
function bpowi_powerOfPower(uint256 _base, uint256 _a, uint256 _b) public {
_base = clamp(_base, 1, 10_000);
_a = clamp(_a, 1, 1000 * BONE);
_b = clamp(_b, 1, 1000 * BONE);
_a = clamp(_a, BONE, 1000 * BONE);
_b = clamp(_b, BONE, 1000 * BONE);

uint256 _result1 = bpowi(bpowi(_base, _a), _b);
uint256 _result2 = bpowi(_base, bmul(_a, _b)) / BONE;
Expand Down
2 changes: 1 addition & 1 deletion test/invariants/fuzz/BToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {EchidnaTest} from '../helpers/AdvancedTestsUtils.sol';
import {CryticERC20ExternalBasicProperties} from
Expand Down
7 changes: 5 additions & 2 deletions test/invariants/fuzz/Protocol.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {EchidnaTest, FuzzERC20} from '../helpers/AdvancedTestsUtils.sol';

Expand Down Expand Up @@ -290,7 +290,10 @@ contract FuzzProtocol is EchidnaTest {
// 19
assert(pool.isFinalized());
} catch {
assert(_inComputed > _maxAmountIn);
assert(
_inComputed > _maxAmountIn
|| _amountOut > bnum.bmul_exposed(tokens[_tokenOut].balanceOf(address(pool)), bconst.MAX_OUT_RATIO())
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/invariants/fuzz/Protocol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ testMode: assertion
corpusDir: test/invariants/fuzz/corpuses/Protocol/
coverageFormats: ["html","lcov"]
allContracts: true
testLimit: 50000
testLimit: 50000
2 changes: 1 addition & 1 deletion test/invariants/helpers/AdvancedTestsUtils.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {Test} from 'forge-std/Test.sol';
import {MockERC20} from 'forge-std/mocks/MockERC20.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/invariants/helpers/MockSettler.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {GPv2Interaction, GPv2Trade, IERC20, ISettlement} from 'interfaces/ISettlement.sol';

Expand Down
2 changes: 1 addition & 1 deletion test/invariants/symbolic/BNum.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {HalmosTest} from '../helpers/AdvancedTestsUtils.sol';
import {BNum} from 'contracts/BNum.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/invariants/symbolic/Protocol.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {FuzzERC20, HalmosTest} from '../helpers/AdvancedTestsUtils.sol';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/BCoWFactory.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BCoWPool} from 'contracts/BCoWPool.sol';
import {Test} from 'forge-std/Test.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BCoWPool.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BasePoolTest, SwapExactAmountInUtils} from './BPool.t.sol';
import {IERC20} from '@cowprotocol/interfaces/IERC20.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BFactory.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BMath.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BConst} from 'contracts/BConst.sol';
import {BMath, BNum} from 'contracts/BMath.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BNum.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BConst} from 'contracts/BConst.sol';
import {BNum} from 'contracts/BNum.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BPool.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BPool/BPool.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BPoolBase} from './BPoolBase.sol';
import {IBPool} from 'interfaces/IBPool.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BPool/BPoolBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {BConst} from 'contracts/BConst.sol';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BPool/BPool_Bind.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BPoolBase} from './BPoolBase.sol';
import {IBPool} from 'interfaces/IBPool.sol';
Expand Down
Loading

0 comments on commit 350c39d

Please sign in to comment.