Skip to content

Commit 45a551d

Browse files
bowdbayologicalchapati23philbow61
authored
THE BIG ONE 🐘 πŸ’£ 🚝 (#501)
## Description As I told some of you at dinner, I've had a bad case of insomnia over the last week. This PR resulted from a couple of late night coding sessions and the incessant need to make things nicer in our repos. It's a big PR but 𝚫code is negative so 🀷 . What happens in this mondo-PR: 1. All `celo` contracts are removed form the repo and replaced with the `@celo/contracts` NPM package. With a small caveat. 2. All `interfaces` are made to work with `0.8` and cover more of the contract functions. 3. All `tests` contracts are updated to `0.8` and use `deployCode` helpers to deploy lower-version contracts, and the use the interfaces to interact with them. 4. ~We make use of this foundry-rs/foundry#8668 to improve compile time.~ 5. Update `solhint` and `prettier` to a recent version and fix/ignore all issues. 6. Fix solc compiler warnings. 7. Fix/ignore slither > informational warnings. 8. Slight Refactor of ForkTests to make them better to work with. 9. Restructuring of the tests folder. #### `@celo/contracts` The only caveat of using the `@celo/contracts` package is that `UsingRegistry.sol` in there needs to import things from `mento-core` and I didn't manage to get it working ok with remappings, so I kept a copy of `UsingRegistry.sol` in `contracts/common`. It's only used in `swap/Reserve.sol` and when we remove it from there we can completely kill `common`. #### The foundry WIP PR A better solution was found here #502, which removes the need for `via-ir` completely. ~The reason it takes so long to compile our code is because we need `via-ir` for `Airgrab.sol` and `StableTokenV2.sol`, and `via-ir` is super slow. But with the compiler restrictions implemented in foundry-rs/foundry#8668 we can have multiple compiler profile settings for subgraphs of the source-graph, which compile in parallel with different settings.~ ~You can easily install that version of foundry locally, (you have to have rust installed tho):~ ``` foundryup -P 8668 ``` ~With this version of foundry and the settings in `foundry.toml`, if you're not working in a part of the source graph that contains `Airgrab.sol` or `StableTokenV2.sol`, compilation will happen without `via-ir` and will be super snappy. However if you do touch that source graph it will still take noticeably long. Right now on my machine full clean compilation takes 80seconds. It used to take >3minutes.~ #### ForkTest Refactoring Our fork tests can get a bit heavy because they're running test assertions for all the exchanges in a single test call. I've refactor it a bit and split out exchange assertions into their own tests contracts that need to be manually created when new exchanges are deployed. There's a chain-level assertion on the number of exchanges that helps us catch this and keep them up to date. This work was continued here #503 for a much cleaner solution. ### Other changes > _Describe any minor or "drive-by" changes here._ no minor changes here, no :)) ### Tested Tested? Tested! ### Related issues Fixes the issues in my head. ### Backwards compatibility What even is that? ### Documentation Holy Bible --------- Co-authored-by: Bayological <[email protected]> Co-authored-by: chapati <[email protected]> Co-authored-by: philbow61 <[email protected]>
1 parent f0d5316 commit 45a551d

File tree

211 files changed

+3754
-11903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+3754
-11903
lines changed

β€Ž.github/workflows/echidna.yamlβ€Ž

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,32 @@ jobs:
3636
- uses: actions/checkout@v3
3737
with:
3838
submodules: recursive
39+
40+
- name: "Install Node.js"
41+
uses: "actions/setup-node@v3"
42+
with:
43+
cache: "yarn"
44+
node-version: "20"
45+
46+
- name: "Install the Node.js dependencies"
47+
run: "yarn install --immutable"
48+
3949
- name: Install Foundry
4050
uses: foundry-rs/foundry-toolchain@v1
51+
4152
- name: "Build for echidna"
42-
run: forge build --build-info --skip */test/**/*.t.sol */script/**
53+
run: |
54+
forge build --build-info --skip \
55+
"test/fork/**/*" \
56+
"test/integration/**/*" \
57+
"test/unit/**/*" \
58+
"test/utils/**/*" \
59+
"script/**/"
60+
4361
- name: "Run Echidna"
4462
uses: crytic/echidna-action@v2
4563
with:
4664
files: .
47-
solc-version: 0.5.17
4865
contract: ${{ matrix.contract }}
4966
config: echidna.yaml
5067
test-mode: assertion

β€Ž.github/workflows/lint_test.yamlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: "yarn install --immutable"
3535

3636
- name: "Lint the contracts"
37-
run: "yarn lint:check"
37+
run: "yarn lint"
3838

3939
- name: "Add lint summary"
4040
run: |
@@ -50,7 +50,7 @@ jobs:
5050
- name: "Build the contracts"
5151
run: |
5252
forge --version
53-
forge build --sizes
53+
forge build --sizes --skip test/**/*
5454
5555
- name: "Add test summary"
5656
run: |

β€Ž.github/workflows/slither.yamlβ€Ž

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,20 @@ jobs:
2020
uses: "actions/checkout@v3"
2121
with:
2222
submodules: "recursive"
23+
- name: "Install Node.js"
24+
uses: "actions/setup-node@v3"
25+
with:
26+
cache: "yarn"
27+
node-version: "20"
28+
29+
- name: "Install the Node.js dependencies"
30+
run: "yarn install --immutable"
2331
- name: Run Slither
24-
uses: crytic/slither-action@v0.3.1
32+
uses: crytic/slither-action@v0.4.0
2533
id: slither
2634
with:
2735
sarif: results.sarif
36+
fail-on: "low"
2837
# continue-on-error: true
2938
# -----------------------
3039
# Ideally, we'd like to continue on error to allow uploading the SARIF file here.
@@ -36,6 +45,6 @@ jobs:
3645
# know it failed.
3746
# -----------------------
3847
- name: Upload SARIF file
39-
uses: github/codeql-action/upload-sarif@v2
48+
uses: github/codeql-action/upload-sarif@v3
4049
with:
4150
sarif_file: ${{ steps.slither.outputs.sarif }}

β€Ž.github/workflows/storage-layout.yamlβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
name: "Storage Layout"
2+
3+
env:
4+
FOUNDRY_PROFILE: "ci"
5+
26
on:
37
workflow_dispatch:
48
push:
@@ -32,6 +36,14 @@ jobs:
3236
uses: onbjerg/foundry-toolchain@v1
3337
with:
3438
version: "nightly"
39+
- name: "Install Node.js"
40+
uses: "actions/setup-node@v3"
41+
with:
42+
cache: "yarn"
43+
node-version: "20"
44+
45+
- name: "Install the Node.js dependencies"
46+
run: "yarn install --immutable"
3547
- name: Check storage layout
3648
uses: Rubilmax/[email protected]
3749
with:

β€Ž.gitmodulesβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
[submodule "lib/openzeppelin-contracts"]
22
path = lib/openzeppelin-contracts
33
url = https://github.com/OpenZeppelin/openzeppelin-contracts
4-
[submodule "lib/celo-foundry"]
5-
path = lib/celo-foundry
6-
url = https://github.com/bowd/celo-foundry
74
[submodule "lib/openzeppelin-contracts-next"]
85
path = lib/openzeppelin-contracts-next
96
url = https://github.com/OpenZeppelin/openzeppelin-contracts
107
[submodule "lib/openzeppelin-contracts-upgradeable"]
118
path = lib/openzeppelin-contracts-upgradeable
129
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
13-
[submodule "lib/forge-std-next"]
14-
path = lib/forge-std-next
15-
url = https://github.com/foundry-rs/forge-std
1610
[submodule "lib/safe-contracts"]
1711
path = lib/safe-contracts
1812
url = https://github.com/safe-global/safe-contracts
@@ -23,3 +17,9 @@
2317
branch = "release-v4"
2418
path = lib/prb-math
2519
url = https://github.com/PaulRBerg/prb-math
20+
[submodule "lib/mento-std"]
21+
path = lib/mento-std
22+
url = https://github.com/mento-protocol/mento-std
23+
[submodule "lib/forge-std"]
24+
path = lib/forge-std
25+
url = https://github.com/foundry-rs/forge-std

β€Ž.husky/pre-pushβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
yarn lint:check
4+
yarn lint

β€Ž.prettierrc.ymlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ singleQuote: false
66
tabWidth: 2
77
trailingComma: all
88

9+
plugins: ["prettier-plugin-solidity"]
10+
911
overrides:
1012
- files: ["*.sol"]
1113
options:
1214
compiler: 0.5.17
13-
tabWidth: 2
14-
printWidth: 120
1515
- files: [contracts/tokens/patched/*.sol]
1616
options:
1717
compiler: 0.8.18

β€Ž.solhint.jsonβ€Ž

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
"extends": "solhint:recommended",
33
"plugins": ["prettier"],
44
"rules": {
5+
"no-global-import": "off",
6+
"no-console": "off",
57
"code-complexity": ["error", 8],
68
"compiler-version": ["error", ">=0.5.13"],
7-
"func-visibility": ["error", { "ignoreConstructors": true }],
8-
"max-line-length": ["error", 120],
9+
"func-visibility": [
10+
"error",
11+
{
12+
"ignoreConstructors": true
13+
}
14+
],
15+
"max-line-length": ["error", 121],
916
"not-rely-on-time": "off",
1017
"function-max-lines": ["error", 120],
1118
"no-empty-blocks": "off",
@@ -15,6 +22,11 @@
1522
"endOfLine": "auto"
1623
}
1724
],
18-
"reason-string": ["warn", { "maxLength": 64 }]
25+
"reason-string": [
26+
"warn",
27+
{
28+
"maxLength": 64
29+
}
30+
]
1931
}
2032
}

β€Ž.solhint.test.jsonβ€Ž

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
"extends": "solhint:recommended",
33
"plugins": ["prettier"],
44
"rules": {
5+
"one-contract-per-file": "off",
6+
"no-global-import": "off",
7+
"no-console": "off",
58
"code-complexity": ["error", 8],
69
"compiler-version": ["error", ">=0.5.13"],
7-
"func-visibility": ["error", { "ignoreConstructors": true }],
8-
"max-line-length": ["error", 120],
10+
"func-visibility": [
11+
"error",
12+
{
13+
"ignoreConstructors": true
14+
}
15+
],
16+
"max-line-length": ["error", 121],
917
"not-rely-on-time": "off",
10-
"function-max-lines": ["error", 120],
18+
"function-max-lines": ["error", 121],
19+
"gas-custom-errors": "off",
1120
"max-states-count": "off",
1221
"var-name-mixedcase": "off",
1322
"func-name-mixedcase": "off",
@@ -21,6 +30,11 @@
2130
"endOfLine": "auto"
2231
}
2332
],
24-
"reason-string": ["warn", { "maxLength": 64 }]
33+
"reason-string": [
34+
"warn",
35+
{
36+
"maxLength": 64
37+
}
38+
]
2539
}
2640
}

β€Žcontracts/common/CalledByVm.solβ€Ž

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
Β (0)