Skip to content

Commit 35d95d6

Browse files
committed
Merge branch 'dev'
2 parents 8a924e4 + 3045b4c commit 35d95d6

38 files changed

+259
-140
lines changed

.github/workflows/black.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
cp pyproject.toml .github/linters
3434
3535
- name: Black
36-
uses: docker://github/super-linter:v3
36+
uses: github/super-linter/[email protected]
3737
if: always()
3838
env:
3939
# run linter on everything to catch preexisting problems

.github/workflows/ci.yml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: CI
23

34
on:
@@ -8,28 +9,62 @@ on:
89
pull_request:
910
schedule:
1011
# run CI every day even if no PRs/merges occur
11-
- cron: '0 12 * * *'
12+
- cron: '0 12 * * *'
1213

1314
jobs:
1415
tests:
15-
runs-on: ubuntu-latest
16+
runs-on: ${{ matrix.os }}
1617
strategy:
1718
matrix:
18-
type: ["solc", "truffle", "embark", "etherlime", "brownie", "waffle", "buidler", "hardhat"]
19+
os: ["ubuntu-latest", "windows-2022"]
20+
type: ["brownie", "buidler", "dapp", "embark", "etherlime", "hardhat", "solc", "truffle", "waffle"]
21+
exclude:
22+
# Currently broken, tries to pull git:// which is blocked by GH
23+
- type: embark
24+
# Requires nix
25+
- os: windows-2022
26+
type: dapp
1927
steps:
20-
- uses: actions/checkout@v1
28+
- uses: actions/checkout@v3
29+
- name: Set up shell
30+
if: runner.os == 'Windows'
31+
run: |
32+
echo 'C:\msys64\mingw64\bin' >> "$GITHUB_PATH"
33+
echo 'C:\msys64\usr\bin' >> "$GITHUB_PATH"
34+
- name: Choose Node version
35+
id: node
36+
shell: bash
37+
run: |
38+
if [ ${{ matrix.type }} = etherlime ]; then
39+
echo '::set-output name=version::10.17.0'
40+
else
41+
echo '::set-output name=version::lts/*'
42+
fi
43+
- name: Set up Node
44+
uses: actions/setup-node@v2
45+
with:
46+
node-version: ${{ steps.node.outputs.version }}
2147
- name: Set up Python 3.6
22-
uses: actions/setup-python@v1
48+
uses: actions/setup-python@v3
2349
with:
2450
python-version: 3.6
2551
- name: Install dependencies
2652
run: |
27-
sudo wget -O /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.5.7/solc-static-linux
28-
sudo chmod +x /usr/bin/solc
53+
pip install "solc-select>=v1.0.0b1"
54+
solc-select use 0.5.7 --always-install
2955
pip install .
56+
- name: Set up nix
57+
if: matrix.type == 'dapp'
58+
uses: cachix/install-nix-action@v16
59+
- name: Set up cachix
60+
if: matrix.type == 'dapp'
61+
uses: cachix/cachix-action@v10
62+
with:
63+
name: dapp
3064
- name: Run Tests
3165
env:
3266
TEST_TYPE: ${{ matrix.type }}
3367
GITHUB_ETHERSCAN: ${{ secrets.GITHUB_ETHERSCAN }}
68+
shell: bash
3469
run: |
35-
bash scripts/travis_test_${TEST_TYPE}.sh
70+
bash "scripts/travis_test_${TEST_TYPE}.sh"

.github/workflows/darglint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Darglint
23

34
on:

.github/workflows/etherscan.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: CI
23

34
on:
@@ -7,28 +8,35 @@ on:
78
- dev
89
schedule:
910
# run CI every day even if no PRs/merges occur
10-
- cron: '0 12 * * *'
11+
- cron: '0 12 * * *'
1112

1213
jobs:
1314
tests:
14-
runs-on: ubuntu-latest
15+
runs-on: ${{ matrix.os }}
1516
strategy:
1617
matrix:
18+
os: ["ubuntu-latest", "windows-2022"]
1719
type: ["etherscan"]
1820
steps:
19-
- uses: actions/checkout@v1
21+
- uses: actions/checkout@v3
22+
- name: Set up shell
23+
if: runner.os == 'Windows'
24+
run: |
25+
echo 'C:\msys64\mingw64\bin' >> "$GITHUB_PATH"
26+
echo 'C:\msys64\usr\bin' >> "$GITHUB_PATH"
2027
- name: Set up Python 3.6
21-
uses: actions/setup-python@v1
28+
uses: actions/setup-python@v3
2229
with:
2330
python-version: 3.6
2431
- name: Install dependencies
2532
run: |
26-
sudo wget -O /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.5.7/solc-static-linux
27-
sudo chmod +x /usr/bin/solc
33+
pip install "solc-select>=v1.0.0b1"
34+
solc-select use 0.5.7 --always-install
2835
pip install .
2936
- name: Run Tests
3037
env:
3138
TEST_TYPE: ${{ matrix.type }}
3239
GITHUB_ETHERSCAN: ${{ secrets.GITHUB_ETHERSCAN }}
40+
shell: bash
3341
run: |
34-
bash scripts/travis_test_${TEST_TYPE}.sh
42+
bash "scripts/travis_test_${TEST_TYPE}.sh"

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
cp pyproject.toml .github/linters
3434
3535
- name: Lint everything else
36-
uses: docker://github/super-linter:v3
36+
uses: github/super-linter/[email protected]
3737
if: always()
3838
env:
3939
# run linter on everything to catch preexisting problems

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
cp mypy.ini .github/linters
3434
3535
- name: Mypy
36-
uses: docker://github/super-linter:v3
36+
uses: github/super-linter/[email protected]
3737
if: always()
3838
env:
3939
# run linter on everything to catch preexisting problems

.github/workflows/pylint.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
cp pyproject.toml .github/linters
3434
3535
- name: Pylint
36-
uses: docker://github/super-linter:v3
36+
uses: github/super-linter/[email protected]
3737
if: always()
3838
env:
3939
# run linter on everything to catch preexisting problems
@@ -44,4 +44,3 @@ jobs:
4444
VALIDATE_PYTHON: true
4545
VALIDATE_PYTHON_PYLINT: true
4646
PYTHON_PYLINT_CONFIG_FILE: pyproject.toml
47-

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ crytic-compile uses the pull request contribution model. Please make an account
1414

1515
Some pull request guidelines:
1616

17-
- Work from the [`dev`](https://github.com/crytic/crytic-compile/tree/dev) branch. We performed extensive tests prior to merging anything to `master`, working from `dev` will allow us to merge your work faster.
17+
- Work from the [`dev`](https://github.com/crytic/crytic-compile/tree/dev) branch. We perform extensive tests prior to merging anything to `master`, working from `dev` will allow us to merge your work faster.
1818
- Minimize irrelevant changes (formatting, whitespace, etc) to code that would otherwise not be touched by this patch. Save formatting or style corrections for a separate pull request that does not make any semantic changes.
1919
- When possible, large changes should be split up into smaller focused pull requests.
2020
- Fill out the pull request description with a summary of what your patch does, key changes that have been made, and any further points of discussion, if applicable.
@@ -35,7 +35,7 @@ To run them locally:
3535
- `darglint crytic_compile`
3636

3737

38-
We use pylint `2.8.2`, black `20.8b1`, mypy `0.812` and dargling `1.8.0`.
38+
We use pylint `2.13.4`, black `22.3.0`, mypy `0.942` and darglint `1.8.0`.
3939

4040
## Development Environment
4141
Instructions for installing a development version of crytic-compile can be found in our [wiki](https://github.com/crytic/crytic-compile/wiki/Developer-installation).

crytic_compile/compilation_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def _update_bytecode_with_libraries(
618618
if library_found in libraries:
619619
bytecode = re.sub(
620620
re.escape(library_found),
621-
"{:040x}".format(int(libraries[library_found])),
621+
f"{libraries[library_found]:0>40x}",
622622
bytecode,
623623
)
624624
return bytecode

crytic_compile/crytic_compile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ def __init__(self, target: Union[str, AbstractPlatform], **kwargs: str):
9191
# This is not memory optimized, but allow an offset lookup in O(1)
9292
# Because we frequently do this lookup in Slither during the AST parsing
9393
# We decided to favor the running time versus memory
94-
self._cached_offset_to_line: Dict[Filename, Dict[int, Tuple[int, int]]] = dict()
94+
self._cached_offset_to_line: Dict[Filename, Dict[int, Tuple[int, int]]] = {}
9595
# Lines are indexed from 1
9696
self._cached_line_to_offset: Dict[Filename, Dict[int, int]] = defaultdict(dict)
9797

9898
# Return the line from the line number
9999
# Note: line 1 is at index 0
100-
self._cached_line_to_code: Dict[Filename, List[bytes]] = dict()
100+
self._cached_line_to_code: Dict[Filename, List[bytes]] = {}
101101

102102
self._working_dir = Path.cwd()
103103

@@ -259,7 +259,7 @@ def _get_cached_offset_to_line(self, file: Filename) -> None:
259259

260260
source_code = self._cached_line_to_code[file]
261261
acc = 0
262-
lines_delimiters: Dict[int, Tuple[int, int]] = dict()
262+
lines_delimiters: Dict[int, Tuple[int, int]] = {}
263263
for line_number, x in enumerate(source_code):
264264
self._cached_line_to_offset[file][line_number + 1] = acc
265265

@@ -630,7 +630,7 @@ def compile_all(target: str, **kwargs: str) -> List[CryticCompile]:
630630
compilations = load_from_zip(target)
631631
elif target.endswith(".zip.base64"):
632632
with tempfile.NamedTemporaryFile() as tmp:
633-
with open(target) as target_file:
633+
with open(target, encoding="base64") as target_file:
634634
tmp.write(base64.b64decode(target_file.read()))
635635
compilations = load_from_zip(tmp.name)
636636
else:

0 commit comments

Comments
 (0)