From 4e7174cd5da1e643ac421453d97d53e84c626602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Wed, 8 Nov 2023 13:08:00 -0300 Subject: [PATCH 1/5] crytic_compile: replace pkg_resources dependency with importlib setuptools is no longer bundled: https://github.com/python/cpython/issues/95299 We can use importlib from the standard library on Python 3.8+ instead. --- crytic_compile/__main__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crytic_compile/__main__.py b/crytic_compile/__main__.py index 7ee5984d..7bdad337 100644 --- a/crytic_compile/__main__.py +++ b/crytic_compile/__main__.py @@ -2,14 +2,13 @@ This is the Slither cli script """ import argparse +from importlib.metadata import version import json import logging import os import sys from typing import TYPE_CHECKING, Any, Optional -from pkg_resources import require - from crytic_compile.crytic_compile import compile_all, get_platforms from crytic_compile.cryticparser import DEFAULTS_FLAG_IN_CONFIG, cryticparser from crytic_compile.platform import InvalidCompilation @@ -109,7 +108,7 @@ def parse_args() -> argparse.Namespace: parser.add_argument( "--version", help="displays the current version", - version=require("crytic-compile")[0].version, + version=version("crytic-compile"), action="version", ) From e66fab64206e930beb2905141cba0a68eb02fb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Wed, 8 Nov 2023 13:15:03 -0300 Subject: [PATCH 2/5] ci: test on multiple Python versions --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fb93d05..34fa15a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest", "windows-2022"] + python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.12"]')) || fromJSON('["3.8", "3.9", "3.10", "3.11", "3.12"]') }} type: ["brownie", "buidler", "dapp", "embark", "hardhat", "solc", "truffle", "waffle", "foundry", "standard", "vyper", "solc_multi_file", "hardhat_multi_file"] exclude: # Currently broken, tries to pull git:// which is blocked by GH @@ -43,10 +44,10 @@ jobs: uses: actions/setup-node@v4 with: node-version: 18.15 - - name: Set up Python 3.8 + - name: Set up Python ${{ matrix.python }} uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: ${{ matrix.python }} - name: Install dependencies run: | pip install "solc-select>=v1.0.0b1" From 7135957c83e06e82e7b5c5feef9a25fa7a75edd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Wed, 8 Nov 2023 13:29:50 -0300 Subject: [PATCH 3/5] ci: disable known-broken tests with Python 3.12 --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34fa15a6..f7e17fd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,15 @@ jobs: # Explore foundry support in windows - os: windows-2022 type: foundry + # Deprecation alerts in vyper with newer python, which trip tests + - python: 3.12 + type: vyper + # brownie does not install correctly with Python 3.12 + - python: 3.12 + type: brownie + # TODO: review failure executing npx on Windows + - os: windows-2022 + python: 3.12 steps: - uses: actions/checkout@v4 - name: Set up shell From bda2f34aded6f23702900ec021fd541629a5501d Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Wed, 10 Jan 2024 21:43:52 -0600 Subject: [PATCH 4/5] fix(vyper): only raise InvalidCompilation on hard errors --- .github/workflows/ci.yml | 6 +----- crytic_compile/platform/vyper.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7e17fd0..22df63f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,9 +33,6 @@ jobs: # Explore foundry support in windows - os: windows-2022 type: foundry - # Deprecation alerts in vyper with newer python, which trip tests - - python: 3.12 - type: vyper # brownie does not install correctly with Python 3.12 - python: 3.12 type: brownie @@ -59,9 +56,8 @@ jobs: python-version: ${{ matrix.python }} - name: Install dependencies run: | - pip install "solc-select>=v1.0.0b1" - solc-select use 0.5.7 --always-install pip install . + solc-select use 0.5.7 --always-install - name: Set up nix if: matrix.type == 'dapp' uses: cachix/install-nix-action@v23 diff --git a/crytic_compile/platform/vyper.py b/crytic_compile/platform/vyper.py index 4d6fc13f..15b354af 100644 --- a/crytic_compile/platform/vyper.py +++ b/crytic_compile/platform/vyper.py @@ -206,9 +206,21 @@ def _run_vyper_standard_json( ) # convert bytestrings to unicode strings vyper_standard_output = json.loads(stdout) + if "errors" in vyper_standard_output: - # TODO format errors - raise InvalidCompilation(vyper_standard_output["errors"]) + + has_errors = False + for diagnostic in vyper_standard_output["errors"]: + + if diagnostic["severity"] == "warning": + continue + + msg = diagnostic.get("formattedMessage", diagnostic["message"]) + LOGGER.error(msg) + has_errors = True + + if has_errors: + raise InvalidCompilation("Vyper compilation errored") return vyper_standard_output From 2ba56ed462fa86861782610fd8d9e8f7da59c4ae Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Thu, 11 Jan 2024 12:29:13 -0600 Subject: [PATCH 5/5] revert bad merge --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cddcb604..17e6c43a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: with: node-version: 18.15 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - name: Install dependencies