From fe19f5a77a5fbba712da052ef3d25f187257ed3c Mon Sep 17 00:00:00 2001 From: pacrob Date: Mon, 3 Apr 2023 14:01:03 -0600 Subject: [PATCH 01/44] bump docs dependencies --- .readthedocs.yml | 5 +++++ docs/conf.py | 1 + newsfragments/70.internal.rst | 1 - setup.py | 6 +++--- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .readthedocs.yml delete mode 100644 newsfragments/70.internal.rst diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 000000000..ed4fab3cb --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,5 @@ +version: 2 + +python: + install: + - requirements: requirements-docs.txt \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 8264b4569..df931f1a5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,6 +38,7 @@ "sphinx.ext.autodoc", "sphinx.ext.doctest", "sphinx.ext.intersphinx", + "sphinx_rtd_theme", ] # Add any paths that contain templates here, relative to this directory. diff --git a/newsfragments/70.internal.rst b/newsfragments/70.internal.rst deleted file mode 100644 index 2e2fd5f95..000000000 --- a/newsfragments/70.internal.rst +++ /dev/null @@ -1 +0,0 @@ -Do not invoke ``setup.py`` directly. Minor cleanup and refactors in newsfragment ``README.md`` and newsfragment validation. Minot cleanup in ``Makefile``. diff --git a/setup.py b/setup.py index 9dfbf788c..04028b110 100644 --- a/setup.py +++ b/setup.py @@ -19,9 +19,9 @@ "black>=22", ], "doc": [ - "Sphinx>=1.6.5", - "sphinx_rtd_theme>=0.1.9", - "towncrier>=21", + "sphinx>=5.0.0", + "sphinx_rtd_theme>=1.0.0", + "towncrier>=21,<22", ], "dev": [ "bumpversion>=0.5.3", From 89e5d8ef9c637c9ac8fbefa11230b3beeb4a2e54 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 5 Apr 2023 18:00:29 -0600 Subject: [PATCH 02/44] new github issue and pr templates (#75) * new issue and pr templates --- .github/ISSUE_TEMPLATE.md | 38 ------------ .github/ISSUE_TEMPLATE/bug_report.yml | 70 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 5 ++ .github/ISSUE_TEMPLATE/feature_request.yml | 11 ++++ .github/PULL_REQUEST_TEMPLATE.md | 17 ------ .github/pull_request_template.md | 17 ++++++ 6 files changed, 103 insertions(+), 55 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 5ff4880ef..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,38 +0,0 @@ - _If this is a bug report, please fill in the following sections. -If this is a feature request, delete and describe what you would like with examples._ - -## What was wrong? - -### Code that produced the error - -```py -CODE_TO_REPRODUCE -``` - -### Full error output - -```sh -ERROR_HERE -``` - -### Expected Result - -_This section may be deleted if the expectation is "don't crash"._ - -```sh -EXPECTED_RESULT -``` - -### Environment - -```sh -# run this: -$ python -m eth_utils - -# then copy the output here: -OUTPUT_HERE -``` - -## How can it be fixed? - -Fill this section in if you know how this could or should be fixed. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..5f1ddfd82 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,70 @@ +name: Bug Report +description: File a bug report +labels: ["bug"] +body: + - type: markdown + attributes: + value: "## What was wrong" + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also tell us what you expected to happen + validations: + required: true + - type: textarea + id: code-that-caused + attributes: + label: Code that produced the error + description: Formats to Python, no backticks needed + render: python + validations: + required: false + - type: textarea + id: error-output + attributes: + label: Full error output + description: Formats to shell, no backticks needed + render: shell + validations: + required: false + - type: markdown + attributes: + value: "## Potential Solutions" + - type: textarea + id: how-to-fix + attributes: + label: Fill this section in if you know how this could or should be fixed + description: Include any relevant examples or reference material + validations: + required: false + - type: input + id: lib-version + attributes: + label: Version + description: Which version of are you using? + placeholder: x.x.x + validations: + required: false + - type: input + id: py-version + attributes: + label: Python Version + description: Which version of Python are you using? + placeholder: x.x.x + validations: + required: false + - type: input + id: os + attributes: + label: Operating System + description: Which operating system are you using? + placeholder: osx/linux/win + validations: + required: false + - type: textarea + id: pip-freeze + attributes: + label: Output from pip-freeze + description: Run `pip-freeze` and paste the output below + render: shell diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..9853c7945 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Questions about using ? + url: https://discord.gg/GHryRvPB84 + about: You can ask and answer usage questions on the Ethereum Python Community Discord diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..041c8fd10 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,11 @@ +name: Feature Request +description: Request a new feature +labels: ["feature_request"] +body: + - type: textarea + id: feature-description + attributes: + label: What feature should we add? + description: Include any relevant examples or reference material + validations: + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 54da55163..000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,17 +0,0 @@ -### What was wrong? - -Related to issue # - -### How was it fixed? - -### To-Do - -[//]: # (Stay ahead of things, add list items here!) -- [ ] Clean up commit history - -[//]: # (See: https://.readthedocs.io/en/latest/contributing.html#pull-requests) -- [ ] Add entry to the [release notes](https://github.com/ethereum//blob/master/newsfragments/README.md) - -#### Cute Animal Picture - -![put a cute animal picture link inside the parentheses]() diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..93fb355eb --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +### What was wrong? + +Related to Issue # +Closes Issue # + +### How was it fixed? + +### Todo: +- [ ] Clean up commit history + +- [ ] Add or update documentation related to these changes + +- [ ] Add entry to the [release notes](https://github.com/ethereum/web3.py/blob/master/newsfragments/README.md) + +#### Cute Animal Picture + +![Put a link to a cute animal picture inside the parenthesis-->]() \ No newline at end of file From 180777d7db608b8db4a271c5502d0568107d8931 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:22:12 -0600 Subject: [PATCH 03/44] convert bash scripts to py (#77) * convert bash scripts to py --- .project-template/fill_template_vars.py | 68 +++++++++++++++++++++++ .project-template/fill_template_vars.sh | 50 ----------------- .project-template/refill_template_vars.py | 39 +++++++++++++ .project-template/refill_template_vars.sh | 2 - 4 files changed, 107 insertions(+), 52 deletions(-) create mode 100644 .project-template/fill_template_vars.py delete mode 100755 .project-template/fill_template_vars.sh create mode 100644 .project-template/refill_template_vars.py delete mode 100755 .project-template/refill_template_vars.sh diff --git a/.project-template/fill_template_vars.py b/.project-template/fill_template_vars.py new file mode 100644 index 000000000..8d4bc35f3 --- /dev/null +++ b/.project-template/fill_template_vars.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +import os +import sys +import re +from pathlib import Path + + +def _find_files(project_root): + path_exclude_pattern = r"\.git($|\/)|venv|_build" + file_exclude_pattern = r"fill_template_vars\.py|\.swp$" + filepaths = [] + for dir_path, _dir_names, file_names in os.walk(project_root): + if not re.search(path_exclude_pattern, dir_path): + for file in file_names: + if not re.search(file_exclude_pattern, file): + filepaths.append(str(Path(dir_path, file))) + + return filepaths + + +def _replace(pattern, replacement, project_root): + print(f"Replacing values: {pattern}") + for file in _find_files(project_root): + with open(file) as f: + content = f.read() + content = re.sub(pattern, replacement, content) + with open(file, "w") as f: + f.write(content) + + +def main(): + project_root = Path(os.path.realpath(sys.argv[0])).parent.parent + + module_name = input("What is your python module name? ") + + pypi_input = input(f"What is your pypi package name? (default: {module_name}) ") + pypi_name = pypi_input or module_name + + repo_input = input(f"What is your github project name? (default: {pypi_name}) ") + repo_name = repo_input or pypi_name + + rtd_input = input( + f"What is your readthedocs.org project name? (default: {pypi_name}) " + ) + rtd_name = rtd_input or pypi_name + + project_input = input( + f"What is your project name (ex: at the top of the README)? (default: {repo_name}) " + ) + project_name = project_input or repo_name + + short_description = input("What is a one-liner describing the project? ") + + _replace("", module_name, project_root) + _replace("", pypi_name, project_root) + _replace("", repo_name, project_root) + _replace("", rtd_name, project_root) + _replace("", project_name, project_root) + _replace("", short_description, project_root) + + os.makedirs(project_root / module_name, exist_ok=True) + Path(project_root / module_name / "__init__.py").touch() + Path(project_root / module_name / "py.typed").touch() + + +if __name__ == "__main__": + main() diff --git a/.project-template/fill_template_vars.sh b/.project-template/fill_template_vars.sh deleted file mode 100755 index 157c89d3d..000000000 --- a/.project-template/fill_template_vars.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o nounset -set -o pipefail - -PROJECT_ROOT=$(dirname $(dirname $(python -c 'import os, sys; sys.stdout.write(os.path.realpath(sys.argv[1]))' "$0"))) - -echo "What is your python module name?" -read MODULE_NAME - -echo "What is your pypi package name? (default: $MODULE_NAME)" -read PYPI_INPUT -PYPI_NAME=${PYPI_INPUT:-$MODULE_NAME} - -echo "What is your github project name? (default: $PYPI_NAME)" -read REPO_INPUT -REPO_NAME=${REPO_INPUT:-$PYPI_NAME} - -echo "What is your readthedocs.org project name? (default: $PYPI_NAME)" -read RTD_INPUT -RTD_NAME=${RTD_INPUT:-$PYPI_NAME} - -echo "What is your project name (ex: at the top of the README)? (default: $REPO_NAME)" -read PROJECT_INPUT -PROJECT_NAME=${PROJECT_INPUT:-$REPO_NAME} - -echo "What is a one-liner describing the project?" -read SHORT_DESCRIPTION - -_replace() { - echo "Replacing values: $1" - local find_cmd=(find "$PROJECT_ROOT" ! -perm -u=x ! -path '*/.git/*' ! -path '*/venv*/*' -type f) - - if [[ $(uname) == Darwin ]]; then - LC_ALL=C "${find_cmd[@]}" -exec sed -i '' "$1" {} + - else - "${find_cmd[@]}" -exec sed -i "$1" {} + - fi -} -_replace "s//$MODULE_NAME/g" -_replace "s//$PYPI_NAME/g" -_replace "s//$REPO_NAME/g" -_replace "s//$RTD_NAME/g" -_replace "s//$PROJECT_NAME/g" -_replace "s//$SHORT_DESCRIPTION/g" - -mkdir -p "$PROJECT_ROOT/$MODULE_NAME" -touch "$PROJECT_ROOT/$MODULE_NAME/__init__.py" -touch "$PROJECT_ROOT/$MODULE_NAME/py.typed" diff --git a/.project-template/refill_template_vars.py b/.project-template/refill_template_vars.py new file mode 100644 index 000000000..03ab7c0c0 --- /dev/null +++ b/.project-template/refill_template_vars.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +import os +import sys +from pathlib import Path +import subprocess + + +def main(): + template_dir = Path(os.path.dirname(sys.argv[0])) + template_vars_file = template_dir / "template_vars.txt" + fill_template_vars_script = template_dir / "fill_template_vars.py" + + with open(template_vars_file, "r") as input_file: + content_lines = input_file.readlines() + + process = subprocess.Popen( + [sys.executable, str(fill_template_vars_script)], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) + + for line in content_lines: + process.stdin.write(line) + process.stdin.flush() + + stdout, stderr = process.communicate() + + if process.returncode != 0: + print(f"Error occurred: {stderr}") + sys.exit(1) + + print(stdout) + + +if __name__ == "__main__": + main() diff --git a/.project-template/refill_template_vars.sh b/.project-template/refill_template_vars.sh deleted file mode 100755 index 70832d3d4..000000000 --- a/.project-template/refill_template_vars.sh +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE_DIR=$(dirname "$0") -<"$TEMPLATE_DIR/template_vars.txt" "$TEMPLATE_DIR/fill_template_vars.sh" From ffd6ad8b9fe4fce1ddd38d3212dca0b14b89a79e Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:10:15 -0600 Subject: [PATCH 04/44] Various template default updates (#74) * bump versions in dependencies and ci builds * move tox to [dev] per issue #34 * move RTD deps pointer into .readthedocs.yml * unpin flake8 add flake8-bugbear to lint deps --- .circleci/config.yml | 41 +++++++++++++++++++++++++++++++---------- .readthedocs.yml | 5 ++++- requirements-docs.txt | 1 - setup.py | 12 ++++++------ tox.ini | 22 +++++++++++++++------- 5 files changed, 56 insertions(+), 25 deletions(-) delete mode 100644 requirements-docs.txt diff --git a/.circleci/config.yml b/.circleci/config.yml index db95741cc..237a3f624 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,60 +39,81 @@ jobs: docs: <<: *common docker: - - image: cimg/python:3.7 + - image: cimg/python:3.8 environment: TOXENV: docs - lint: + py37-lint: <<: *common docker: - image: cimg/python:3.7 environment: - TOXENV: lint + TOXENV: py37-lint py37-core: <<: *common docker: - image: cimg/python:3.7 environment: TOXENV: py37-core + py38-lint: + <<: *common + docker: + - image: cimg/python:3.8 + environment: + TOXENV: py38-lint py38-core: <<: *common docker: - image: cimg/python:3.8 environment: TOXENV: py38-core + py39-lint: + <<: *common + docker: + - image: cimg/python:3.9 + environment: + TOXENV: py39-lint py39-core: <<: *common docker: - image: cimg/python:3.9 environment: TOXENV: py39-core + py310-lint: + <<: *common + docker: + - image: cimg/python:3.10 + environment: + TOXENV: py310-lint py310-core: <<: *common docker: - image: cimg/python:3.10 environment: TOXENV: py310-core - py311-core: + py311-lint: <<: *common docker: - image: cimg/python:3.11 environment: - TOXENV: py311-core - pypy3-core: + TOXENV: py311-lint + py311-core: <<: *common docker: - - image: pypy + - image: cimg/python:3.11 environment: - TOXENV: pypy3-core + TOXENV: py311-core workflows: version: 2 test: jobs: - docs - - lint + - py37-lint + - py38-lint + - py39-lint + - py310-lint + - py311-lint - py37-core - py38-core - py39-core - py310-core - py311-core - - pypy3-core diff --git a/.readthedocs.yml b/.readthedocs.yml index ed4fab3cb..959cf717c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -2,4 +2,7 @@ version: 2 python: install: - - requirements: requirements-docs.txt \ No newline at end of file + - method: pip + path: . + extra_requirements: + - doc diff --git a/requirements-docs.txt b/requirements-docs.txt deleted file mode 100644 index 1b49b7443..000000000 --- a/requirements-docs.txt +++ /dev/null @@ -1 +0,0 @@ -[doc] diff --git a/setup.py b/setup.py index 04028b110..33f942562 100644 --- a/setup.py +++ b/setup.py @@ -7,14 +7,14 @@ extras_require = { "test": [ - "pytest>=6.2.5", - "pytest-xdist>=2.4.0,<3", - "tox==3.14.6", + "pytest>=7.0.0", + "pytest-xdist>=2.4.0", ], "lint": [ - "flake8==3.7.9", + "flake8>=5.0.0", + "flake8-bugbear>=22.0.0", "isort>=5.10.1", - "mypy==0.770", + "mypy==0.971", "pydocstyle>=5.0.0", "black>=22", ], @@ -26,6 +26,7 @@ "dev": [ "bumpversion>=0.5.3", "pytest-watch>=4.1.0", + "tox>=3.18.0", "wheel", "twine", "ipython", @@ -79,6 +80,5 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: PyPy", ], ) diff --git a/tox.ini b/tox.ini index 23729cfc7..64147d4ff 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist= - py{37,38,39,310,311,py3}-core - lint + py{37,38,39,310,311}-core + py{37,38,39,310,311}-lint docs [isort] @@ -14,7 +14,7 @@ multi_line_output=3 profile=black [flake8] -max-line-length= 100 +max-line-length= 88 exclude= venv*,.tox,docs,build extend-ignore= E203 @@ -30,19 +30,27 @@ basepython = py39: python3.9 py310: python3.10 py311: python3.11 - pypy3: pypy3 extras= test docs: doc -whitelist_externals=make +allowlist_externals=make -[testenv:lint] +[common-lint] basepython=python extras=lint -whitelist_externals=black +allowlist_externals=black commands= mypy -p --config-file {toxinidir}/mypy.ini flake8 {toxinidir}/ {toxinidir}/tests isort --check-only --diff {toxinidir}/ {toxinidir}/tests pydocstyle --explain {toxinidir}/ {toxinidir}/tests black --check {toxinidir}/ {toxinidir}/docs {toxinidir}/tests {toxinidir}/setup.py + +[testenv:lint] +basepython: python +extras: {[common-lint]extras} +commands: {[common-lint]commands} + +[testenv:py{37,38,39,310,311}-lint] +extras: {[common-lint]extras} +commands: {[common-lint]commands} From 91d93efdd09189d841a733ce0329f234c73a908c Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:11:35 -0600 Subject: [PATCH 05/44] remove outdated sections of README (#76) * remove gitter, testing setup, and pandoc sections, add quotes to dev install --- README.md | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/README.md b/README.md index 92b70beaf..a3bc2c7cd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # -[![Join the chat at https://gitter.im/ethereum/](https://badges.gitter.im/ethereum/.svg)](https://gitter.im/ethereum/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://circleci.com/gh/ethereum/.svg?style=shield)](https://circleci.com/gh/ethereum/) [![PyPI version](https://badge.fury.io/py/.svg)](https://badge.fury.io/py/) [![Python versions](https://img.shields.io/pypi/pyversions/.svg)](https://pypi.python.org/pypi/) @@ -37,43 +36,11 @@ git clone git@github.com:ethereum/.git cd virtualenv -p python3 venv . venv/bin/activate -pip install -e .[dev] -``` - -### Testing Setup - -During development, you might like to have tests run on every file save. - -Show flake8 errors on file change: - -```sh -# Test flake8 -when-changed -v -s -r -1 / tests/ -c "clear; flake8 tests && echo 'flake8 success' || echo 'error'" -``` - -Run multi-process tests in one command, but without color: - -```sh -# in the project root: -pytest --numprocesses=4 --looponfail --maxfail=1 -# the same thing, succinctly: -pytest -n 4 -f --maxfail=1 -``` - -Run in one thread, with color and desktop notifications: - -```sh -cd venv -ptw --onfail "notify-send -t 5000 'Test failure ⚠⚠⚠⚠⚠' 'python 3 test on failed'" ../tests ../ +pip install -e ".[dev]" ``` ### Release setup -For Debian-like systems: -``` -apt install pandoc -``` - To release a new version: ```sh From 68d37fa50ff45980823c2259178d1339520870d8 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Mon, 10 Apr 2023 14:02:45 -0600 Subject: [PATCH 06/44] repin flake8 and misc updates (#79) * repin flake8, bump tox to >=4.0.0 as that's where whitelist was deprecated, misc updates --- .circleci/config.yml | 1 + .project-template/fill_template_vars.py | 2 +- MANIFEST.in | 1 - setup.py | 6 +++--- tox.ini | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 237a3f624..eb10bbe39 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -102,6 +102,7 @@ jobs: - image: cimg/python:3.11 environment: TOXENV: py311-core + workflows: version: 2 test: diff --git a/.project-template/fill_template_vars.py b/.project-template/fill_template_vars.py index 8d4bc35f3..bbbe2f7f4 100644 --- a/.project-template/fill_template_vars.py +++ b/.project-template/fill_template_vars.py @@ -7,7 +7,7 @@ def _find_files(project_root): - path_exclude_pattern = r"\.git($|\/)|venv|_build" + path_exclude_pattern = r"\.git($|\/)|venv|_build|\.tox" file_exclude_pattern = r"fill_template_vars\.py|\.swp$" filepaths = [] for dir_path, _dir_names, file_names in os.walk(project_root): diff --git a/MANIFEST.in b/MANIFEST.in index e870a4111..22c6165d6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,5 @@ include LICENSE include README.md -include requirements-docs.txt global-include *.pyi diff --git a/setup.py b/setup.py index 33f942562..a18d9bc4c 100644 --- a/setup.py +++ b/setup.py @@ -11,8 +11,8 @@ "pytest-xdist>=2.4.0", ], "lint": [ - "flake8>=5.0.0", - "flake8-bugbear>=22.0.0", + "flake8==6.0.0", + "flake8-bugbear==23.3.23", "isort>=5.10.1", "mypy==0.971", "pydocstyle>=5.0.0", @@ -26,7 +26,7 @@ "dev": [ "bumpversion>=0.5.3", "pytest-watch>=4.1.0", - "tox>=3.18.0", + "tox>=4.0.0", "wheel", "twine", "ipython", diff --git a/tox.ini b/tox.ini index 64147d4ff..e5255baae 100644 --- a/tox.ini +++ b/tox.ini @@ -14,16 +14,16 @@ multi_line_output=3 profile=black [flake8] -max-line-length= 88 -exclude= venv*,.tox,docs,build -extend-ignore= E203 +max-line-length=88 +exclude=venv*,.tox,docs,build +extend-ignore=E203 [testenv] usedevelop=True commands= core: pytest {posargs:tests/core} docs: make check-docs -basepython = +basepython= docs: python py37: python3.7 py38: python3.8 From 431db897535642e3b4f1616e3cb393171ae1c063 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:35:34 -0600 Subject: [PATCH 07/44] template cleanup following initial merge with py-evm (#80) * template cleanup following initial merge with py-evm * add flake8 pin comment * correct license years * add pin note to mypy --- .circleci/config.yml | 4 ++-- .project-template/fill_template_vars.py | 15 +++++++++------ LICENSE | 2 +- README.md | 3 ++- docs/_static/.suppress-sphinx-build-warning | 0 newsfragments/validate_files.py | 1 - pytest.ini | 5 ++++- setup.py | 8 ++++---- tests/core/conftest.py | 0 tests/core/test_import.py | 2 -- 10 files changed, 22 insertions(+), 18 deletions(-) delete mode 100644 docs/_static/.suppress-sphinx-build-warning delete mode 100644 tests/core/conftest.py diff --git a/.circleci/config.yml b/.circleci/config.yml index eb10bbe39..b4b822add 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,7 +19,7 @@ common: &common when: on_fail - restore_cache: keys: - - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} - run: name: install dependencies command: pip install --user tox @@ -33,7 +33,7 @@ common: &common - ~/.cache/pip - ~/.local - ./eggs - key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} jobs: docs: diff --git a/.project-template/fill_template_vars.py b/.project-template/fill_template_vars.py index bbbe2f7f4..52ceb02b6 100644 --- a/.project-template/fill_template_vars.py +++ b/.project-template/fill_template_vars.py @@ -7,7 +7,7 @@ def _find_files(project_root): - path_exclude_pattern = r"\.git($|\/)|venv|_build|\.tox" + path_exclude_pattern = r"\.git($|\/)|venv|_build" file_exclude_pattern = r"fill_template_vars\.py|\.swp$" filepaths = [] for dir_path, _dir_names, file_names in os.walk(project_root): @@ -22,11 +22,14 @@ def _find_files(project_root): def _replace(pattern, replacement, project_root): print(f"Replacing values: {pattern}") for file in _find_files(project_root): - with open(file) as f: - content = f.read() - content = re.sub(pattern, replacement, content) - with open(file, "w") as f: - f.write(content) + try: + with open(file) as f: + content = f.read() + content = re.sub(pattern, replacement, content) + with open(file, "w") as f: + f.write(content) + except UnicodeDecodeError: + pass def main(): diff --git a/LICENSE b/LICENSE index 17bc694e4..b76b24d47 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 The Ethereum Foundation +Copyright (c) 2019-2023 The Ethereum Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a3bc2c7cd..86b1e4107 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # +[![Join the conversation on Discord](https://img.shields.io/discord/809793915578089484?color=blue&label=chat&logo=discord&logoColor=white)](https://discord.gg/GHryRvPB84) [![Build Status](https://circleci.com/gh/ethereum/.svg?style=shield)](https://circleci.com/gh/ethereum/) [![PyPI version](https://badge.fury.io/py/.svg)](https://badge.fury.io/py/) [![Python versions](https://img.shields.io/pypi/pyversions/.svg)](https://pypi.python.org/pypi/) -[![Docs build](https://readthedocs.org/projects//badge/?version=latest)](http://.readthedocs.io/en/latest/?badge=latest) +[![Docs build](https://readthedocs.org/projects//badge/?version=latest)](https://.readthedocs.io/en/latest/?badge=latest) diff --git a/docs/_static/.suppress-sphinx-build-warning b/docs/_static/.suppress-sphinx-build-warning deleted file mode 100644 index e69de29bb..000000000 diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py index 684c79872..c4bd29f69 100755 --- a/newsfragments/validate_files.py +++ b/newsfragments/validate_files.py @@ -3,7 +3,6 @@ # Towncrier silently ignores files that do not match the expected ending. # We use this script to ensure we catch these as errors in CI. -import os import pathlib import sys diff --git a/pytest.ini b/pytest.ini index ae90934f5..95a6b2d6e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,9 @@ [pytest] -addopts= -v --showlocals --durations 10 +addopts= -v --showlocals --durations 10 xfail_strict=true +log_format = %(levelname)8s %(asctime)s %(filename)20s %(message)s +log_date_format = %m-%d %H:%M:%S +timeout = 300 [pytest-watch] runner= pytest --failed-first --maxfail=1 --no-success-flaky-report diff --git a/setup.py b/setup.py index a18d9bc4c..c359d0be4 100644 --- a/setup.py +++ b/setup.py @@ -11,11 +11,11 @@ "pytest-xdist>=2.4.0", ], "lint": [ - "flake8==6.0.0", - "flake8-bugbear==23.3.23", + "flake8==6.0.0", # flake8 claims semver but adds new warnings at minor releases, leave it pinned. + "flake8-bugbear==23.3.23", # flake8-bugbear does not follow semver, leave it pinned. "isort>=5.10.1", - "mypy==0.971", - "pydocstyle>=5.0.0", + "mypy==0.971", # mypy does not follow semver, leave it pinned. + "pydocstyle>=6.0.0", "black>=22", ], "doc": [ diff --git a/tests/core/conftest.py b/tests/core/conftest.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/core/test_import.py b/tests/core/test_import.py index f146ae798..07b2a18e9 100644 --- a/tests/core/test_import.py +++ b/tests/core/test_import.py @@ -1,4 +1,2 @@ - - def test_import(): import # noqa: F401 From 3314247037b6e686f372aae98ff0f32cffb5b48a Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Thu, 13 Apr 2023 12:47:12 -0600 Subject: [PATCH 08/44] apply template updates found following merge with eth-typing (#81) * apply template updates found following merge with eth-typing * add build as a dev dependency * remove timeout from pytest.ini, it doesn't do anything without pytest-timeout as a dep --- .github/pull_request_template.md | 4 ++-- docs/conf.py | 2 +- pyproject.toml | 2 +- pytest.ini | 3 +-- setup.py | 5 ++--- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 93fb355eb..b32988521 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,7 +1,7 @@ ### What was wrong? Related to Issue # -Closes Issue # +Closes # ### How was it fixed? @@ -10,7 +10,7 @@ Closes Issue # - [ ] Add or update documentation related to these changes -- [ ] Add entry to the [release notes](https://github.com/ethereum/web3.py/blob/master/newsfragments/README.md) +- [ ] Add entry to the [release notes](https://github.com/ethereum//blob/master/newsfragments/README.md) #### Cute Animal Picture diff --git a/docs/conf.py b/docs/conf.py index df931f1a5..6469208cc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,7 +55,7 @@ # General information about the project. project = "" -copyright = "2020, The Ethereum Foundation" +copyright = "2019-2023, The Ethereum Foundation" __version__ = setup_version # The version info for the project you're documenting, acts as replacement for diff --git a/pyproject.toml b/pyproject.toml index 314331404..734835045 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.towncrier] -# Read https://github.com/ethereum//newsfragments/README.md for instructions +# Read https://github.com/ethereum//blob/master/newsfragments/README.md for instructions package = "" filename = "docs/release_notes.rst" directory = "newsfragments" diff --git a/pytest.ini b/pytest.ini index 95a6b2d6e..fd5ea7cb6 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,9 +1,8 @@ [pytest] -addopts= -v --showlocals --durations 10 +addopts= -v --showlocals --durations 10 xfail_strict=true log_format = %(levelname)8s %(asctime)s %(filename)20s %(message)s log_date_format = %m-%d %H:%M:%S -timeout = 300 [pytest-watch] runner= pytest --failed-first --maxfail=1 --no-success-flaky-report diff --git a/setup.py b/setup.py index c359d0be4..e4d82fac6 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ "bumpversion>=0.5.3", "pytest-watch>=4.1.0", "tox>=4.0.0", + "build>=0.9.0", "wheel", "twine", "ipython", @@ -59,7 +60,7 @@ install_requires=[ "eth-utils>=2", ], - python_requires=">=3.7, <4", + python_requires=">=3.7.2, <4", extras_require=extras_require, py_modules=[""], license="MIT", @@ -72,8 +73,6 @@ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", - "Operating System :: MacOS", - "Operating System :: POSIX", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", From 484b6b55cd09757c9721fcaa50e6c39d8cee34af Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 19 Apr 2023 14:00:40 -0600 Subject: [PATCH 09/44] Template updates post ssz and ethabi (#82) * add updates found when merging template with py-ssz and eth-abi * add wheel and wheel-windows to ci and reorg --- .circleci/config.yml | 130 ++++++++++++++++++++++++-------- .gitignore | 9 ++- docs/conf.py | 2 +- newsfragments/README.md | 9 ++- newsfragments/validate_files.py | 1 + pyproject.toml | 27 ++++--- setup.py | 4 +- tox.ini | 31 ++++++++ 8 files changed, 161 insertions(+), 52 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b4b822add..0eb6f4aee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -version: 2.0 +version: 2.1 # heavily inspired by https://raw.githubusercontent.com/pinax/pinax-wiki/6bd2a99ab6f702e300d708532a6d1d9aa638b9f8/.circleci/config.yml @@ -22,7 +22,7 @@ common: &common - cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} - run: name: install dependencies - command: pip install --user tox + command: python -m pip install --user tox - run: name: run tox command: python -m tox -r @@ -35,6 +35,30 @@ common: &common - ./eggs key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} +orbs: + win: circleci/windows@5.0.0 + +windows_steps: &windows_steps + executor: + name: win/default + shell: bash.exe + working_directory: C:\Users\circleci\project\ + steps: + - checkout + - restore_cache: + keys: + - cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - run: + name: install dependencies + command: python -m pip install --user tox + - run: + name: run tox + command: python -m tox -r + - save_cache: + paths: + - .tox + key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + jobs: docs: <<: *common @@ -42,79 +66,123 @@ jobs: - image: cimg/python:3.8 environment: TOXENV: docs - py37-lint: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-lint + py37-core: <<: *common docker: - image: cimg/python:3.7 environment: TOXENV: py37-core - py38-lint: - <<: *common - docker: - - image: cimg/python:3.8 - environment: - TOXENV: py38-lint py38-core: <<: *common docker: - image: cimg/python:3.8 environment: TOXENV: py38-core - py39-lint: - <<: *common - docker: - - image: cimg/python:3.9 - environment: - TOXENV: py39-lint py39-core: <<: *common docker: - image: cimg/python:3.9 environment: TOXENV: py39-core - py310-lint: + py310-core: <<: *common docker: - image: cimg/python:3.10 environment: - TOXENV: py310-lint - py310-core: + TOXENV: py310-core + py311-core: + <<: *common + docker: + - image: cimg/python:3.11 + environment: + TOXENV: py311-core + + py37-lint: + <<: *common + docker: + - image: cimg/python:3.7 + environment: + TOXENV: py37-lint + py38-lint: + <<: *common + docker: + - image: cimg/python:3.8 + environment: + TOXENV: py38-lint + py39-lint: + <<: *common + docker: + - image: cimg/python:3.9 + environment: + TOXENV: py39-lint + py310-lint: <<: *common docker: - image: cimg/python:3.10 environment: - TOXENV: py310-core + TOXENV: py310-lint py311-lint: <<: *common docker: - image: cimg/python:3.11 environment: TOXENV: py311-lint - py311-core: + + py37-wheel: + <<: *common + docker: + - image: cimg/python:3.7 + environment: + TOXENV: py37-wheel + py38-wheel: + <<: *common + docker: + - image: cimg/python:3.8 + environment: + TOXENV: py38-wheel + py39-wheel: + <<: *common + docker: + - image: cimg/python:3.9 + environment: + TOXENV: py39-wheel + py310-wheel: + <<: *common + docker: + - image: cimg/python:3.10 + environment: + TOXENV: py310-wheel + py311-wheel: <<: *common docker: - image: cimg/python:3.11 environment: - TOXENV: py311-core + TOXENV: py311-wheel + + py311-wheel-windows: + <<: *windows_steps + environment: + TOXENV: py311-wheel-windows workflows: version: 2 test: jobs: - docs - - py37-lint - - py38-lint - - py39-lint - - py310-lint - - py311-lint - py37-core - py38-core - py39-core - py310-core - py311-core + - py37-lint + - py38-lint + - py39-lint + - py310-lint + - py311-lint + - py37-wheel + - py38-wheel + - py39-wheel + - py310-wheel + - py311-wheel + - py311-wheel-windows diff --git a/.gitignore b/.gitignore index 011ac1c82..e0e2be56e 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,12 @@ logs # mypy .mypy_cache +# macOS +.DS_Store + +# pyenv +.python-version + # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm # For a more precise, explicit template, see: # https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 @@ -83,9 +89,6 @@ out/ ## Plugin-specific files: -### mpeltonen/sbt-idea plugin -.idea_modules/ - ### JIRA plugin atlassian-ide-plugin.xml diff --git a/docs/conf.py b/docs/conf.py index 6469208cc..db3f34924 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -141,7 +141,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] +# html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/newsfragments/README.md b/newsfragments/README.md index e4740e4bc..0e9b74a2d 100644 --- a/newsfragments/README.md +++ b/newsfragments/README.md @@ -8,14 +8,15 @@ relevant to people working on the code itself.) Each file should be named like `..rst`, where `` is an issue number, and `` is one of: -* `feature` +* `breaking` * `bugfix` -* `performance` +* `deprecation`, * `doc` +* `feature` * `internal` -* `removal` * `misc` -* `breaking` +* `performance` +* `removal` So for example: `123.feature.rst`, `456.bugfix.rst` diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py index c4bd29f69..edd5e0503 100755 --- a/newsfragments/validate_files.py +++ b/newsfragments/validate_files.py @@ -9,6 +9,7 @@ ALLOWED_EXTENSIONS = { ".breaking.rst", ".bugfix.rst", + ".deprecation.rst", ".doc.rst", ".feature.rst", ".internal.rst", diff --git a/pyproject.toml b/pyproject.toml index 734835045..64f8b8af7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,12 +4,12 @@ package = "" filename = "docs/release_notes.rst" directory = "newsfragments" underlines = ["-", "~", "^"] -title_format = " v{version} ({project_date})" +title_format = " v{version} ({project_date})" issue_format = "`#{issue} /issues/{issue}>`__" [[tool.towncrier.type]] -directory = "feature" -name = "Features" +directory = "breaking" +name = "Breaking Changes" showcontent = true [[tool.towncrier.type]] @@ -18,8 +18,8 @@ name = "Bugfixes" showcontent = true [[tool.towncrier.type]] -directory = "performance" -name = "Performance improvements" +directory = "deprecation" +name = "Deprecations" showcontent = true [[tool.towncrier.type]] @@ -28,21 +28,26 @@ name = "Improved Documentation" showcontent = true [[tool.towncrier.type]] -directory = "removal" -name = "Deprecations and Removals" +directory = "feature" +name = "Features" showcontent = true [[tool.towncrier.type]] directory = "internal" -name = "Internal Changes - for Contributors" +name = "Internal Changes - for Contributors" showcontent = true [[tool.towncrier.type]] directory = "misc" -name = "Miscellaneous changes" +name = "Miscellaneous Changes" showcontent = false [[tool.towncrier.type]] -directory = "breaking" -name = "Breaking changes" +directory = "performance" +name = "Performance Improvements" +showcontent = true + +[[tool.towncrier.type]] +directory = "removal" +name = "Removals" showcontent = true diff --git a/setup.py b/setup.py index e4d82fac6..00994c255 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ "isort>=5.10.1", "mypy==0.971", # mypy does not follow semver, leave it pinned. "pydocstyle>=6.0.0", - "black>=22", + "black>=23", ], "doc": [ "sphinx>=5.0.0", @@ -60,7 +60,7 @@ install_requires=[ "eth-utils>=2", ], - python_requires=">=3.7.2, <4", + python_requires=">=3.7, <4", extras_require=extras_require, py_modules=[""], license="MIT", diff --git a/tox.ini b/tox.ini index e5255baae..35503e263 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,8 @@ envlist= py{37,38,39,310,311}-core py{37,38,39,310,311}-lint + py{37,38,39,310,311}-wheel + py311-wheel-windows docs [isort] @@ -54,3 +56,32 @@ commands: {[common-lint]commands} [testenv:py{37,38,39,310,311}-lint] extras: {[common-lint]extras} commands: {[common-lint]commands} + +[testenv:py{37,38,39,310,311}-wheel] +deps= + wheel + build[virtualenv] +allowlist_externals= + /bin/rm + /bin/bash +commands= + python -m pip install --upgrade pip + /bin/rm -rf build dist + python -m build + /bin/bash -c 'python -m pip install --upgrade "$(ls dist/-*-py3-none-any.whl)" --progress-bar off' + python -c "import " +skip_install=true + +[testenv:py311-wheel-windows] +deps= + wheel + build[virtualenv] +allowlist_externals= + bash.exe +commands= + python -m pip install --upgrade pip + bash.exe -c "rm -rf build dist" + python -m build + bash.exe -c 'python -m pip install --upgrade "$(ls dist/-*-py3-none-any.whl)" --progress-bar off' + python -c "import " +skip_install=true From 28dbedcbfad5b03f50505e0d990c4d63dba27c36 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Mon, 24 Apr 2023 17:21:09 -0600 Subject: [PATCH 10/44] upgrade pip and remove --user from tox install during ci (#85) --- .circleci/config.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0eb6f4aee..b00ff6b82 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,9 @@ common: &common - cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} - run: name: install dependencies - command: python -m pip install --user tox + command: | + python -m pip install --upgrade pip + python -m pip install tox - run: name: run tox command: python -m tox -r @@ -50,7 +52,9 @@ windows_steps: &windows_steps - cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} - run: name: install dependencies - command: python -m pip install --user tox + command: | + python -m pip install --upgrade pip + python -m pip install tox - run: name: run tox command: python -m tox -r From da9b95f37c2b9c33582e430d0e7b4d858dec2212 Mon Sep 17 00:00:00 2001 From: Marc Garreau <3621728+wolovim@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:45:59 -0600 Subject: [PATCH 11/44] introduce contributing doc + main branch convention (#84) --- Makefile | 4 +- README.md | 11 +- docs/contributing.rst | 161 ++++++++++++++++++++++++ docs/fragments/virtualenv_explainer.rst | 25 ++++ docs/index.rst | 6 + pyproject.toml | 2 +- 6 files changed, 200 insertions(+), 9 deletions(-) create mode 100644 docs/contributing.rst create mode 100644 docs/fragments/virtualenv_explainer.rst diff --git a/Makefile b/Makefile index a8af4ebac..5f7318935 100644 --- a/Makefile +++ b/Makefile @@ -74,8 +74,8 @@ notes: check-bump git commit -m "Compile release notes" release: check-bump clean - # require that you be on a branch that's linked to upstream/master - git status -s -b | head -1 | grep "\.\.upstream/master" + # require that you be on a branch that's linked to upstream/main + git status -s -b | head -1 | grep "\.\.upstream/main" # verify that docs build correctly ./newsfragments/validate_files.py is-empty make build-docs diff --git a/README.md b/README.md index 86b1e4107..7d126455a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ [![PyPI version](https://badge.fury.io/py/.svg)](https://badge.fury.io/py/) [![Python versions](https://img.shields.io/pypi/pyversions/.svg)](https://pypi.python.org/pypi/) [![Docs build](https://readthedocs.org/projects//badge/?version=latest)](https://.readthedocs.io/en/latest/?badge=latest) - @@ -23,10 +22,10 @@ If you would like to hack on , please check out the [Snake Charmers Tactical Manual](https://github.com/ethereum/snake-charmers-tactical-manual) for information on how we do: -- Testing -- Pull Requests -- Code Style -- Documentation +- Testing +- Pull Requests +- Code Style +- Documentation ### Development Environment Setup @@ -55,7 +54,7 @@ The version format for this repo is `{major}.{minor}.{patch}` for stable, and To issue the next version in line, specify which part to bump, like `make release bump=minor` or `make release bump=devnum`. This is typically done from the -master branch, except when releasing a beta (in which case the beta is released from master, +main branch, except when releasing a beta (in which case the beta is released from main, and the previous stable branch is released from said branch). If you are in a beta version, `make release bump=stage` will switch to a stable. diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 000000000..926b87ce3 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1,161 @@ +Contributing +------------ + +Thank you for your interest in contributing! We welcome all contributions no matter their size. Please read along to learn how to get started. + + +Setting the stage +~~~~~~~~~~~~~~~~~ + +First, we need to clone the repository: + +.. code:: sh + + $ git clone https://github.com/ethereum/.git + + +.. include:: /fragments/virtualenv_explainer.rst + +After we have activated our virtual environment, we need to install all dependencies that are needed to run, develop, and test. +This is as easy as navigating to the directory and running: + +.. code:: sh + + pip install -e ".[dev]" + + +Running the tests +~~~~~~~~~~~~~~~~~ + +A great way to explore the code base is to run the tests. + +We can run all tests with: + +.. code:: sh + + pytest tests + +However, you may just want to run a subset instead, like: + +.. code:: sh + + pytest tests/core/padding-utils/test_padding.py + + +We can also install ``tox`` to run the full test suite which also covers things like testing the code against different Python versions, linting etc. + +It is important to understand that each Pull Request must pass the full test suite as part of the CI check, hence it is often convenient to have ``tox`` installed locally as well. + + +Code Style +~~~~~~~~~~ + +When multiple people are working on the same body of code, it is important that they write code that conforms to a similar style. It often doesn't matter as much which style, but rather that they conform to one style. + +To ensure your contribution conforms to the style being used in this project, we encourage you to read our `style guide `_. + + +Type Hints +~~~~~~~~~~ + +This codebase uses `type hints `_. Type hints make it easy to prevent certain types of bugs, enable richer tooling, and enhance the documentation, making the code easier to follow. + +All new code is required to land with type hints, with the exception of test code that is not expected to use type hints. + +All parameters, as well as the return type of defs, are expected to be typed, with the exception of ``self`` and ``cls`` as seen in the following example. + +.. code:: python + + def __init__(self, wrapped_db: DatabaseAPI) -> None: + self.wrapped_db = wrapped_db + self.reset() + + +Documentation +~~~~~~~~~~~~~ + +Good documentation will lead to quicker adoption and happier users. Please check out our guide +on `how to create documentation for the Python Ethereum ecosystem `_. + + +Pull Requests +~~~~~~~~~~~~~ + +It's a good idea to make pull requests early on. A pull request represents the +start of a discussion, and doesn't necessarily need to be the final, finished +submission. + +GitHub's documentation for working on pull requests is `available here `_. + +Once you've made a pull request, take a look at the Circle CI build status in the +GitHub interface and make sure all tests are passing. In general pull requests that +do not pass the CI build yet won't get reviewed unless explicitly requested. + +If the pull request introduces changes that should be reflected in the release notes, +please add a `newsfragment` file as explained +`here /blob/main/newsfragments/README.md>`_. + +If possible, the change to the release notes file should be included in the commit that introduces the +feature or bugfix. + + +Releasing +~~~~~~~~~ + + +Final test before each release +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Before releasing a new version, build and test the package that will be released: + +.. code:: sh + + git checkout main && git pull + + make package + + + # Preview the upcoming release notes + towncrier --draft + + +Build the release notes +^^^^^^^^^^^^^^^^^^^^^^^ + +Before bumping the version number, build the release notes. +You must include the part of the version to bump (see below), +which changes how the version number will show in the release notes. + +.. code:: sh + + make notes bump=$$VERSION_PART_TO_BUMP$$ + +If there are any errors, be sure to re-run ``make notes`` until it works. + + +Push the release to github & pypi +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +After confirming that the release package looks okay, release a new version: + +.. code:: sh + + make release bump=$$VERSION_PART_TO_BUMP$$ + + +Which version part to bump +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The version format for this repo is ``{major}.{minor}.{patch}`` for +stable, and ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable +(``stage`` can be alpha or beta). + +During a release, specify which part to bump, like +``make release bump=minor`` or ``make release bump=devnum``. + +If you are in a beta version, ``make release bump=stage`` will switch to a +stable. + +To issue an unstable version when the current version is stable, specify +the new version explicitly, like +``make release bump="--new-version 4.0.0-alpha.1 devnum"`` diff --git a/docs/fragments/virtualenv_explainer.rst b/docs/fragments/virtualenv_explainer.rst new file mode 100644 index 000000000..ecc6d4c64 --- /dev/null +++ b/docs/fragments/virtualenv_explainer.rst @@ -0,0 +1,25 @@ +**Optional:** Often, the best way to guarantee a clean Python 3 environment is with +`virtualenv `_. If we don't have ``virtualenv`` installed +already, we first need to install it via pip. + +.. code:: sh + + pip install virtualenv + +Then, we can initialize a new virtual environment ``venv``, like: + +.. code:: sh + + virtualenv -p python3 venv + +This creates a new directory ``venv`` where packages are installed isolated from any other global +packages. + +To activate the virtual directory we have to *source* it + +.. code:: sh + + . venv/bin/activate + + # and when leaving this context: + deactivate diff --git a/docs/index.rst b/docs/index.rst index 89815efac..4f1f0b314 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,6 +11,12 @@ Contents release_notes + +.. toctree:: + :maxdepth: 1 + :caption: Community + + contributing Indices and tables diff --git a/pyproject.toml b/pyproject.toml index 64f8b8af7..aa7ddcd0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.towncrier] -# Read https://github.com/ethereum//blob/master/newsfragments/README.md for instructions +# Read https://github.com/ethereum//blob/main/newsfragments/README.md for instructions package = "" filename = "docs/release_notes.rst" directory = "newsfragments" From cc24e7e468d652f59ac9f484f9600460f6b8a295 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:20:55 -0600 Subject: [PATCH 12/44] update tox calls to use run, update all pip calls to use python -m (#86) --- .circleci/config.yml | 4 ++-- .github/ISSUE_TEMPLATE/bug_report.yml | 6 ++++-- Makefile | 4 ++-- README.md | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b00ff6b82..791a433d0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ common: &common python -m pip install tox - run: name: run tox - command: python -m tox -r + command: python -m tox run -r - save_cache: paths: - .hypothesis @@ -57,7 +57,7 @@ windows_steps: &windows_steps python -m pip install tox - run: name: run tox - command: python -m tox -r + command: python -m tox run -r - save_cache: paths: - .tox diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 5f1ddfd82..a0c80c071 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -65,6 +65,8 @@ body: - type: textarea id: pip-freeze attributes: - label: Output from pip-freeze - description: Run `pip-freeze` and paste the output below + label: Output from `pip freeze` + description: Run `python -m pip freeze` and paste the output below render: shell + validations: + required: false diff --git a/Makefile b/Makefile index 5f7318935..b674c553b 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ clean-pyc: find . -name '__pycache__' -exec rm -rf {} + lint: - tox -e lint + tox run -e lint lint-roll: isort tests @@ -39,7 +39,7 @@ test: pytest tests test-all: - tox + tox run build-docs: sphinx-apidoc -o docs/ . setup.py "*conftest*" diff --git a/README.md b/README.md index 7d126455a..b3be7487e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Read more in the [documentation on ReadTheDocs](https://.readthedocs.i ## Quickstart ```sh -pip install +python -m pip install ``` ## Developer Setup @@ -36,7 +36,7 @@ git clone git@github.com:ethereum/.git cd virtualenv -p python3 venv . venv/bin/activate -pip install -e ".[dev]" +python -m pip install -e ".[dev]" ``` ### Release setup From 1f5fc7208bbd7d86a35ef466cf58d5129d4852f9 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Thu, 27 Apr 2023 14:02:54 -0600 Subject: [PATCH 13/44] Remove testall (#88) * remove testall because it doesnt work --- .github/pull_request_template.md | 2 +- Makefile | 4 ---- newsfragments/README.md | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b32988521..2ff2e0717 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -10,7 +10,7 @@ Closes # - [ ] Add or update documentation related to these changes -- [ ] Add entry to the [release notes](https://github.com/ethereum//blob/master/newsfragments/README.md) +- [ ] Add entry to the [release notes](https://github.com/ethereum//blob/main/newsfragments/README.md) #### Cute Animal Picture diff --git a/Makefile b/Makefile index b674c553b..67a757326 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,6 @@ help: @echo "lint - check style with flake8" @echo "lint-roll - automatically fix problems with isort, flake8, etc" @echo "test - run tests quickly with the default Python" - @echo "testall - run tests on every Python version with tox" @echo "docs - generate docs and open in browser (linux-docs for version on linux)" @echo "notes - consume towncrier newsfragments/ and update release notes in docs/" @echo "release - package and upload a release (does not run notes target)" @@ -38,9 +37,6 @@ lint-roll: test: pytest tests -test-all: - tox run - build-docs: sphinx-apidoc -o docs/ . setup.py "*conftest*" $(MAKE) -C docs clean diff --git a/newsfragments/README.md b/newsfragments/README.md index 0e9b74a2d..93ae2c0a8 100644 --- a/newsfragments/README.md +++ b/newsfragments/README.md @@ -26,4 +26,4 @@ then open up the PR first and use the PR number for the newsfragment. Note that the `towncrier` tool will automatically reflow your text, so don't try to do any fancy formatting. Run `towncrier build --draft` to get a preview of what the release notes entry - will look like in the final release notes. +will look like in the final release notes. From 2a1c8f83b49c97c57838098fef30f3b59baf755a Mon Sep 17 00:00:00 2001 From: pacrob Date: Mon, 1 May 2023 16:25:14 -0600 Subject: [PATCH 14/44] minor formatting updates, remove contributing docs --- README.md | 8 +- docs/contributing.rst | 161 ------------------------ docs/fragments/virtualenv_explainer.rst | 25 ---- docs/index.rst | 6 - newsfragments/README.md | 2 +- 5 files changed, 5 insertions(+), 197 deletions(-) delete mode 100644 docs/contributing.rst delete mode 100644 docs/fragments/virtualenv_explainer.rst diff --git a/README.md b/README.md index b3be7487e..5acd94db0 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ If you would like to hack on , please check out the [Snake Charmers Tactical Manual](https://github.com/ethereum/snake-charmers-tactical-manual) for information on how we do: -- Testing -- Pull Requests -- Code Style -- Documentation +- Testing +- Pull Requests +- Code Style +- Documentation ### Development Environment Setup diff --git a/docs/contributing.rst b/docs/contributing.rst deleted file mode 100644 index 926b87ce3..000000000 --- a/docs/contributing.rst +++ /dev/null @@ -1,161 +0,0 @@ -Contributing ------------- - -Thank you for your interest in contributing! We welcome all contributions no matter their size. Please read along to learn how to get started. - - -Setting the stage -~~~~~~~~~~~~~~~~~ - -First, we need to clone the repository: - -.. code:: sh - - $ git clone https://github.com/ethereum/.git - - -.. include:: /fragments/virtualenv_explainer.rst - -After we have activated our virtual environment, we need to install all dependencies that are needed to run, develop, and test. -This is as easy as navigating to the directory and running: - -.. code:: sh - - pip install -e ".[dev]" - - -Running the tests -~~~~~~~~~~~~~~~~~ - -A great way to explore the code base is to run the tests. - -We can run all tests with: - -.. code:: sh - - pytest tests - -However, you may just want to run a subset instead, like: - -.. code:: sh - - pytest tests/core/padding-utils/test_padding.py - - -We can also install ``tox`` to run the full test suite which also covers things like testing the code against different Python versions, linting etc. - -It is important to understand that each Pull Request must pass the full test suite as part of the CI check, hence it is often convenient to have ``tox`` installed locally as well. - - -Code Style -~~~~~~~~~~ - -When multiple people are working on the same body of code, it is important that they write code that conforms to a similar style. It often doesn't matter as much which style, but rather that they conform to one style. - -To ensure your contribution conforms to the style being used in this project, we encourage you to read our `style guide `_. - - -Type Hints -~~~~~~~~~~ - -This codebase uses `type hints `_. Type hints make it easy to prevent certain types of bugs, enable richer tooling, and enhance the documentation, making the code easier to follow. - -All new code is required to land with type hints, with the exception of test code that is not expected to use type hints. - -All parameters, as well as the return type of defs, are expected to be typed, with the exception of ``self`` and ``cls`` as seen in the following example. - -.. code:: python - - def __init__(self, wrapped_db: DatabaseAPI) -> None: - self.wrapped_db = wrapped_db - self.reset() - - -Documentation -~~~~~~~~~~~~~ - -Good documentation will lead to quicker adoption and happier users. Please check out our guide -on `how to create documentation for the Python Ethereum ecosystem `_. - - -Pull Requests -~~~~~~~~~~~~~ - -It's a good idea to make pull requests early on. A pull request represents the -start of a discussion, and doesn't necessarily need to be the final, finished -submission. - -GitHub's documentation for working on pull requests is `available here `_. - -Once you've made a pull request, take a look at the Circle CI build status in the -GitHub interface and make sure all tests are passing. In general pull requests that -do not pass the CI build yet won't get reviewed unless explicitly requested. - -If the pull request introduces changes that should be reflected in the release notes, -please add a `newsfragment` file as explained -`here /blob/main/newsfragments/README.md>`_. - -If possible, the change to the release notes file should be included in the commit that introduces the -feature or bugfix. - - -Releasing -~~~~~~~~~ - - -Final test before each release -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Before releasing a new version, build and test the package that will be released: - -.. code:: sh - - git checkout main && git pull - - make package - - - # Preview the upcoming release notes - towncrier --draft - - -Build the release notes -^^^^^^^^^^^^^^^^^^^^^^^ - -Before bumping the version number, build the release notes. -You must include the part of the version to bump (see below), -which changes how the version number will show in the release notes. - -.. code:: sh - - make notes bump=$$VERSION_PART_TO_BUMP$$ - -If there are any errors, be sure to re-run ``make notes`` until it works. - - -Push the release to github & pypi -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -After confirming that the release package looks okay, release a new version: - -.. code:: sh - - make release bump=$$VERSION_PART_TO_BUMP$$ - - -Which version part to bump -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The version format for this repo is ``{major}.{minor}.{patch}`` for -stable, and ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable -(``stage`` can be alpha or beta). - -During a release, specify which part to bump, like -``make release bump=minor`` or ``make release bump=devnum``. - -If you are in a beta version, ``make release bump=stage`` will switch to a -stable. - -To issue an unstable version when the current version is stable, specify -the new version explicitly, like -``make release bump="--new-version 4.0.0-alpha.1 devnum"`` diff --git a/docs/fragments/virtualenv_explainer.rst b/docs/fragments/virtualenv_explainer.rst deleted file mode 100644 index ecc6d4c64..000000000 --- a/docs/fragments/virtualenv_explainer.rst +++ /dev/null @@ -1,25 +0,0 @@ -**Optional:** Often, the best way to guarantee a clean Python 3 environment is with -`virtualenv `_. If we don't have ``virtualenv`` installed -already, we first need to install it via pip. - -.. code:: sh - - pip install virtualenv - -Then, we can initialize a new virtual environment ``venv``, like: - -.. code:: sh - - virtualenv -p python3 venv - -This creates a new directory ``venv`` where packages are installed isolated from any other global -packages. - -To activate the virtual directory we have to *source* it - -.. code:: sh - - . venv/bin/activate - - # and when leaving this context: - deactivate diff --git a/docs/index.rst b/docs/index.rst index 4f1f0b314..472a482a8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,12 +12,6 @@ Contents release_notes -.. toctree:: - :maxdepth: 1 - :caption: Community - - contributing - Indices and tables ------------------ diff --git a/newsfragments/README.md b/newsfragments/README.md index 93ae2c0a8..2ef923e83 100644 --- a/newsfragments/README.md +++ b/newsfragments/README.md @@ -10,7 +10,7 @@ Each file should be named like `..rst`, where * `breaking` * `bugfix` -* `deprecation`, +* `deprecation` * `doc` * `feature` * `internal` From f802bd04398df7f915916dabbc1ba2b129796be0 Mon Sep 17 00:00:00 2001 From: pacrob Date: Wed, 3 May 2023 10:53:12 -0600 Subject: [PATCH 15/44] bump sphinx version and set py version rtd uses to 3.8 --- .readthedocs.yml | 8 ++++++++ setup.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 959cf717c..bb96642ad 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,5 +1,13 @@ version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.8" + +sphinx: + configuration: docs/conf.py + python: install: - method: pip diff --git a/setup.py b/setup.py index 00994c255..dc1a39f1f 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "black>=23", ], "doc": [ - "sphinx>=5.0.0", + "sphinx>=6.0.0", "sphinx_rtd_theme>=1.0.0", "towncrier>=21,<22", ], From 23a192f62c6ad5bff2beb54284652c215971dfa6 Mon Sep 17 00:00:00 2001 From: pacrob Date: Wed, 3 May 2023 14:05:29 -0600 Subject: [PATCH 16/44] change references to doc to all be docs --- .readthedocs.yml | 2 +- docs/conf.py | 2 +- newsfragments/README.md | 2 +- newsfragments/validate_files.py | 2 +- pyproject.toml | 2 +- setup.py | 4 ++-- tox.ini | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index bb96642ad..50b9b3841 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -13,4 +13,4 @@ python: - method: pip path: . extra_requirements: - - doc + - docs diff --git a/docs/conf.py b/docs/conf.py index db3f34924..1d0560df2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -190,7 +190,7 @@ # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = "doc" +htmlhelp_basename = "docs" # -- Options for LaTeX output --------------------------------------------- diff --git a/newsfragments/README.md b/newsfragments/README.md index 2ef923e83..7c8981fa4 100644 --- a/newsfragments/README.md +++ b/newsfragments/README.md @@ -11,7 +11,7 @@ Each file should be named like `..rst`, where * `breaking` * `bugfix` * `deprecation` -* `doc` +* `docs` * `feature` * `internal` * `misc` diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py index edd5e0503..bc68bfe50 100755 --- a/newsfragments/validate_files.py +++ b/newsfragments/validate_files.py @@ -10,7 +10,7 @@ ".breaking.rst", ".bugfix.rst", ".deprecation.rst", - ".doc.rst", + ".docs.rst", ".feature.rst", ".internal.rst", ".misc.rst", diff --git a/pyproject.toml b/pyproject.toml index aa7ddcd0c..d94ebfd9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ name = "Deprecations" showcontent = true [[tool.towncrier.type]] -directory = "doc" +directory = "docs" name = "Improved Documentation" showcontent = true diff --git a/setup.py b/setup.py index dc1a39f1f..859008ecb 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ "pydocstyle>=6.0.0", "black>=23", ], - "doc": [ + "docs": [ "sphinx>=6.0.0", "sphinx_rtd_theme>=1.0.0", "towncrier>=21,<22", @@ -38,7 +38,7 @@ extras_require["dev"] + extras_require["test"] + extras_require["lint"] - + extras_require["doc"] + + extras_require["docs"] ) diff --git a/tox.ini b/tox.ini index 35503e263..b1dae72ad 100644 --- a/tox.ini +++ b/tox.ini @@ -34,7 +34,7 @@ basepython= py311: python3.11 extras= test - docs: doc + docs allowlist_externals=make [common-lint] From 86b5d52149e561080c2c5629e68a9810f8552090 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Fri, 12 May 2023 14:47:15 -0600 Subject: [PATCH 17/44] Update .gitignore spelling error --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e0e2be56e..0d725c742 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,7 @@ docs/*._utils.* # Blockchain chains -# Hypothese Property base testing +# Hypothesis Property base testing .hypothesis # tox/pytest cache From 42be4de76cba63fddccd95fb0f4c5289b777b403 Mon Sep 17 00:00:00 2001 From: pacrob Date: Thu, 25 May 2023 14:33:14 -0600 Subject: [PATCH 18/44] fix typos in ci config and Makefile --- .circleci/config.yml | 2 +- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 791a433d0..0f1436c03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,7 @@ common: &common command: ./.circleci/merge_pr.sh when: on_fail - run: - name: merge pull request base (3nd try) + name: merge pull request base (3rd try) command: ./.circleci/merge_pr.sh when: on_fail - restore_cache: diff --git a/Makefile b/Makefile index 67a757326..06d85b7cb 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ CURRENT_SIGN_SETTING := $(shell git config commit.gpgSign) help: @echo "clean-build - remove build artifacts" @echo "clean-pyc - remove Python file artifacts" - @echo "lint - check style with flake8" - @echo "lint-roll - automatically fix problems with isort, flake8, etc" + @echo "lint - check style with mypy, flake8, isort, pydocstyle, and black" + @echo "lint-roll - automatically fix problems with flake8 and black" @echo "test - run tests quickly with the default Python" @echo "docs - generate docs and open in browser (linux-docs for version on linux)" @echo "notes - consume towncrier newsfragments/ and update release notes in docs/" From 024f9dbd54735d7d00b0c537bb9976bcb08c813d Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 14 Jun 2023 07:59:07 -0600 Subject: [PATCH 19/44] Add tests to distribution by default (#97) --- MANIFEST.in | 2 ++ Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 22c6165d6..a122460c5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,8 @@ include LICENSE include README.md +recursive-include tests * + global-include *.pyi recursive-exclude * __pycache__ diff --git a/Makefile b/Makefile index 06d85b7cb..f91dd7200 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ notes: check-bump make build-docs git commit -m "Compile release notes" -release: check-bump clean +release: check-bump test clean # require that you be on a branch that's linked to upstream/main git status -s -b | head -1 | grep "\.\.upstream/main" # verify that docs build correctly From 37841d57ed4d8fa89973414d68a5e4e738812100 Mon Sep 17 00:00:00 2001 From: Stuart Reed Date: Tue, 13 Jun 2023 09:46:18 -0600 Subject: [PATCH 20/44] Update release command to check remote for upstream --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f91dd7200..60ed00e42 100644 --- a/Makefile +++ b/Makefile @@ -69,9 +69,9 @@ notes: check-bump make build-docs git commit -m "Compile release notes" -release: check-bump test clean - # require that you be on a branch that's linked to upstream/main - git status -s -b | head -1 | grep "\.\.upstream/main" +release: check-bump clean + # require that upstream is configured for ethereum/ + git remote -v | grep "upstream\tgit@github.com:ethereum/.git (push)\|upstream\thttps://github.com/ethereum/ (push)" # verify that docs build correctly ./newsfragments/validate_files.py is-empty make build-docs From 8a57adf9503919c9f273d742ce257042211ae082 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:29:30 -0600 Subject: [PATCH 21/44] Update .gitignore add `.venv*` to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0d725c742..7d6b0b06c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ lib lib64 pip-wheel-metadata venv* +.venv* # Installer logs pip-log.txt From 4245675648f6e0937e5865c31fc2176344af3a80 Mon Sep 17 00:00:00 2001 From: pacrob Date: Thu, 14 Sep 2023 12:11:55 -0600 Subject: [PATCH 22/44] ignore flake8 F401 errors in __init__.py files --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b1dae72ad..cdb3560c1 100644 --- a/tox.ini +++ b/tox.ini @@ -16,9 +16,10 @@ multi_line_output=3 profile=black [flake8] -max-line-length=88 exclude=venv*,.tox,docs,build extend-ignore=E203 +max-line-length=88 +per-file-ignores=__init__.py:F401 [testenv] usedevelop=True From 26005569ce71ab26ce1e847ea2122a860bbb9b2d Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:40:01 -0600 Subject: [PATCH 23/44] Update .gitignore add `.build` to be ignored --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7d6b0b06c..f9dcb54c8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.egg-info dist build +.build eggs .eggs parts From 23d8fb5bf77a62d6472b29758f1b8424bfab7aa6 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:40:49 -0600 Subject: [PATCH 24/44] Update .readthedocs.yml fix indent, add sphinx fail_on_warning --- .readthedocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 50b9b3841..593793c27 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,7 +6,8 @@ build: python: "3.8" sphinx: - configuration: docs/conf.py + configuration: docs/conf.py + fail_on_warning: true python: install: From efcb97c348892b7e85a6300226e26e41bcceb4b9 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 4 Oct 2023 12:13:56 -0600 Subject: [PATCH 25/44] Update .gitignore gitignore local vs-code settings --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f9dcb54c8..5127a4df1 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,9 @@ logs # pyenv .python-version +# vs-code +.vscode + # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm # For a more precise, explicit template, see: # https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 From 7099bbaaa48504ec9609d3b34648f0177dbccba8 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:32:07 -0600 Subject: [PATCH 26/44] Add pre commit (#103) * add pre-commit * run pre-commit * skip lint on README.md as it breaks template filling --- .bumpversion.cfg | 1 - .circleci/config.yml | 9 ++--- .../{bug_report.yml => bug_report.yaml} | 0 .../{config.yml => config.yaml} | 0 ...ature_request.yml => feature_request.yaml} | 0 .github/pull_request_template.md | 9 +++-- .pre-commit-config.yaml | 37 ++++++++++++++++++ .readthedocs.yml => .readthedocs.yaml | 0 Makefile | 10 +---- README.md | 7 +++- docs/index.rst | 2 +- newsfragments/README.md | 18 ++++----- newsfragments/validate_files.py | 1 - setup.py | 38 +++++++------------ tox.ini | 17 +++------ 15 files changed, 82 insertions(+), 67 deletions(-) rename .github/ISSUE_TEMPLATE/{bug_report.yml => bug_report.yaml} (100%) rename .github/ISSUE_TEMPLATE/{config.yml => config.yaml} (100%) rename .github/ISSUE_TEMPLATE/{feature_request.yml => feature_request.yaml} (100%) create mode 100644 .pre-commit-config.yaml rename .readthedocs.yml => .readthedocs.yaml (100%) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index f683001f4..39ae22d42 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -20,4 +20,3 @@ values = [bumpversion:file:setup.py] search = version="{current_version}", replace = version="{new_version}", - diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f1436c03..bbc90296e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,9 @@ common: &common command: | python -m pip install --upgrade pip python -m pip install tox + - run: + name: install pre-commit + command: python -m pip install --progress-bar=off pre-commit - run: name: run tox command: python -m tox run -r @@ -102,12 +105,6 @@ jobs: environment: TOXENV: py311-core - py37-lint: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-lint py38-lint: <<: *common docker: diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yaml similarity index 100% rename from .github/ISSUE_TEMPLATE/bug_report.yml rename to .github/ISSUE_TEMPLATE/bug_report.yaml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yaml similarity index 100% rename from .github/ISSUE_TEMPLATE/config.yml rename to .github/ISSUE_TEMPLATE/config.yaml diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yaml similarity index 100% rename from .github/ISSUE_TEMPLATE/feature_request.yml rename to .github/ISSUE_TEMPLATE/feature_request.yaml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 2ff2e0717..3691f6b9b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,12 +6,13 @@ Closes # ### How was it fixed? ### Todo: -- [ ] Clean up commit history -- [ ] Add or update documentation related to these changes +- \[ \] Clean up commit history -- [ ] Add entry to the [release notes](https://github.com/ethereum//blob/main/newsfragments/README.md) +- \[ \] Add or update documentation related to these changes + +- \[ \] Add entry to the [release notes](https://github.com/ethereum/%3CREPO_NAME%3E/blob/main/newsfragments/README.md) #### Cute Animal Picture -![Put a link to a cute animal picture inside the parenthesis-->]() \ No newline at end of file +![Put a link to a cute animal picture inside the parenthesis-->](<>) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..58f9e1d87 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,37 @@ +exclude: '.project-template|docs/conf.py' +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-yaml + - id: check-toml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/psf/black + rev: 23.9.1 + hooks: + - id: black +- repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + additional_dependencies: + - flake8-bugbear==23.9.16 + exclude: setup.py +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort +- repo: https://github.com/pycqa/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle +- repo: https://github.com/executablebooks/mdformat + rev: 0.7.17 + hooks: + - id: mdformat +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.5.1 + hooks: + - id: mypy + exclude: tests/ diff --git a/.readthedocs.yml b/.readthedocs.yaml similarity index 100% rename from .readthedocs.yml rename to .readthedocs.yaml diff --git a/Makefile b/Makefile index 60ed00e42..28d7fa466 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,7 @@ CURRENT_SIGN_SETTING := $(shell git config commit.gpgSign) help: @echo "clean-build - remove build artifacts" @echo "clean-pyc - remove Python file artifacts" - @echo "lint - check style with mypy, flake8, isort, pydocstyle, and black" - @echo "lint-roll - automatically fix problems with flake8 and black" + @echo "lint - fix linting issues with pre-commit @echo "test - run tests quickly with the default Python" @echo "docs - generate docs and open in browser (linux-docs for version on linux)" @echo "notes - consume towncrier newsfragments/ and update release notes in docs/" @@ -27,12 +26,7 @@ clean-pyc: find . -name '__pycache__' -exec rm -rf {} + lint: - tox run -e lint - -lint-roll: - isort tests - black tests setup.py - $(MAKE) lint + pre-commit run --all-files --show-diff-on-failure test: pytest tests diff --git a/README.md b/README.md index 5acd94db0..fa56f2e35 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,13 @@ for information on how we do: - Testing - Pull Requests -- Code Style - Documentation +We use [pre-commit](https://pre-commit.com/) to maintain consistent code style. Once +installed, it will run automatically with every commit. You can also run it manually +with `make lint`. If you need to make a commit that skips the `pre-commit` checks, you +can do so with `git commit --no-verify`. + ### Development Environment Setup You can set up your dev environment with: @@ -37,6 +41,7 @@ cd virtualenv -p python3 venv . venv/bin/activate python -m pip install -e ".[dev]" +pre-commit install ``` ### Release setup diff --git a/docs/index.rst b/docs/index.rst index 472a482a8..89815efac 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,7 @@ Contents release_notes - + Indices and tables ------------------ diff --git a/newsfragments/README.md b/newsfragments/README.md index 7c8981fa4..177d64925 100644 --- a/newsfragments/README.md +++ b/newsfragments/README.md @@ -8,15 +8,15 @@ relevant to people working on the code itself.) Each file should be named like `..rst`, where `` is an issue number, and `` is one of: -* `breaking` -* `bugfix` -* `deprecation` -* `docs` -* `feature` -* `internal` -* `misc` -* `performance` -* `removal` +- `breaking` +- `bugfix` +- `deprecation` +- `docs` +- `feature` +- `internal` +- `misc` +- `performance` +- `removal` So for example: `123.feature.rst`, `456.bugfix.rst` diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py index bc68bfe50..02b0e3efb 100755 --- a/newsfragments/validate_files.py +++ b/newsfragments/validate_files.py @@ -31,7 +31,6 @@ assert sys.argv[1] in ("is-empty",) for fragment_file in THIS_DIR.iterdir(): - if fragment_file.name in ALLOWED_FILES: continue elif num_args == 0: diff --git a/setup.py b/setup.py index 859008ecb..5efcc3cd8 100644 --- a/setup.py +++ b/setup.py @@ -1,44 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- from setuptools import ( - setup, find_packages, + setup, ) extras_require = { - "test": [ - "pytest>=7.0.0", - "pytest-xdist>=2.4.0", - ], - "lint": [ - "flake8==6.0.0", # flake8 claims semver but adds new warnings at minor releases, leave it pinned. - "flake8-bugbear==23.3.23", # flake8-bugbear does not follow semver, leave it pinned. - "isort>=5.10.1", - "mypy==0.971", # mypy does not follow semver, leave it pinned. - "pydocstyle>=6.0.0", - "black>=23", + "dev": [ + "build>=0.9.0", + "bumpversion>=0.5.3", + "ipython", + "pre-commit>=3.4.0", + "pytest-watch>=4.1.0", + "tox>=4.0.0", + "twine", + "wheel", ], "docs": [ "sphinx>=6.0.0", "sphinx_rtd_theme>=1.0.0", "towncrier>=21,<22", ], - "dev": [ - "bumpversion>=0.5.3", - "pytest-watch>=4.1.0", - "tox>=4.0.0", - "build>=0.9.0", - "wheel", - "twine", - "ipython", + "test": [ + "pytest>=7.0.0", + "pytest-xdist>=2.4.0", ], } extras_require["dev"] = ( - extras_require["dev"] - + extras_require["test"] - + extras_require["lint"] - + extras_require["docs"] + extras_require["dev"] + extras_require["docs"] + extras_require["test"] ) diff --git a/tox.ini b/tox.ini index cdb3560c1..cf23aa2e2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist= py{37,38,39,310,311}-core - py{37,38,39,310,311}-lint + py{38,39,310,311}-lint py{37,38,39,310,311}-wheel py311-wheel-windows docs @@ -36,26 +36,19 @@ basepython= extras= test docs -allowlist_externals=make +allowlist_externals=make,pre-commit [common-lint] basepython=python -extras=lint -allowlist_externals=black +deps=pre-commit commands= - mypy -p --config-file {toxinidir}/mypy.ini - flake8 {toxinidir}/ {toxinidir}/tests - isort --check-only --diff {toxinidir}/ {toxinidir}/tests - pydocstyle --explain {toxinidir}/ {toxinidir}/tests - black --check {toxinidir}/ {toxinidir}/docs {toxinidir}/tests {toxinidir}/setup.py + pre-commit run --all-files --show-diff-on-failure [testenv:lint] basepython: python -extras: {[common-lint]extras} commands: {[common-lint]commands} -[testenv:py{37,38,39,310,311}-lint] -extras: {[common-lint]extras} +[testenv:py{38,39,310,311}-lint] commands: {[common-lint]commands} [testenv:py{37,38,39,310,311}-wheel] From 2ed5fba28d19109150175cd37394ab1e745d6633 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:51:01 -0600 Subject: [PATCH 27/44] Update pull_request_template.md fix linting broke template formatting --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3691f6b9b..3f52eebd9 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -11,7 +11,7 @@ Closes # - \[ \] Add or update documentation related to these changes -- \[ \] Add entry to the [release notes](https://github.com/ethereum/%3CREPO_NAME%3E/blob/main/newsfragments/README.md) +- \[ \] Add entry to the [release notes](https://github.com/ethereum//blob/main/newsfragments/README.md) #### Cute Animal Picture From 0065691db7c072eb818f125e7595afb59db205f9 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:55:19 -0600 Subject: [PATCH 28/44] Update Makefile missing doublequote --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 28d7fa466..74f1640c5 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ CURRENT_SIGN_SETTING := $(shell git config commit.gpgSign) help: @echo "clean-build - remove build artifacts" @echo "clean-pyc - remove Python file artifacts" - @echo "lint - fix linting issues with pre-commit + @echo "lint - fix linting issues with pre-commit" @echo "test - run tests quickly with the default Python" @echo "docs - generate docs and open in browser (linux-docs for version on linux)" @echo "notes - consume towncrier newsfragments/ and update release notes in docs/" From 82425694f63c6eb610e10451cb1c93317dbb6eeb Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:36:57 -0600 Subject: [PATCH 29/44] drop py37 support (#104) --- .circleci/config.yml | 15 --------------- setup.py | 3 +-- tox.ini | 7 +++---- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bbc90296e..2a438f574 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,12 +74,6 @@ jobs: environment: TOXENV: docs - py37-core: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-core py38-core: <<: *common docker: @@ -130,12 +124,6 @@ jobs: environment: TOXENV: py311-lint - py37-wheel: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-wheel py38-wheel: <<: *common docker: @@ -171,17 +159,14 @@ workflows: test: jobs: - docs - - py37-core - py38-core - py39-core - py310-core - py311-core - - py37-lint - py38-lint - py39-lint - py310-lint - py311-lint - - py37-wheel - py38-wheel - py39-wheel - py310-wheel diff --git a/setup.py b/setup.py index 5efcc3cd8..ad552d5d1 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ install_requires=[ "eth-utils>=2", ], - python_requires=">=3.7, <4", + python_requires=">=3.8, <4", extras_require=extras_require, py_modules=[""], license="MIT", @@ -64,7 +64,6 @@ "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/tox.ini b/tox.ini index cf23aa2e2..df00ee6d6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] envlist= - py{37,38,39,310,311}-core + py{38,39,310,311}-core py{38,39,310,311}-lint - py{37,38,39,310,311}-wheel + py{38,39,310,311}-wheel py311-wheel-windows docs @@ -28,7 +28,6 @@ commands= docs: make check-docs basepython= docs: python - py37: python3.7 py38: python3.8 py39: python3.9 py310: python3.10 @@ -51,7 +50,7 @@ commands: {[common-lint]commands} [testenv:py{38,39,310,311}-lint] commands: {[common-lint]commands} -[testenv:py{37,38,39,310,311}-wheel] +[testenv:py{38,39,310,311}-wheel] deps= wheel build[virtualenv] From 146a3a9b020b87ccbbf44b783c254a84be1b34b2 Mon Sep 17 00:00:00 2001 From: pacrob Date: Wed, 11 Oct 2023 10:11:13 -0600 Subject: [PATCH 30/44] drop egg references --- .circleci/config.yml | 1 - Makefile | 1 - 2 files changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a438f574..5dcf00106 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,7 +37,6 @@ common: &common - .tox - ~/.cache/pip - ~/.local - - ./eggs key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} orbs: diff --git a/Makefile b/Makefile index 74f1640c5..9deaab82f 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,6 @@ clean: clean-build clean-pyc clean-build: rm -fr build/ rm -fr dist/ - rm -fr *.egg-info clean-pyc: find . -name '*.pyc' -exec rm -f {} + From c3c29ddf43ed091d7e3bd92841503d3a15f564ee Mon Sep 17 00:00:00 2001 From: pacrob Date: Wed, 11 Oct 2023 08:31:24 -0600 Subject: [PATCH 31/44] bump pre-commit to 4.5 and add github-flavored markdown linting extension --- .github/pull_request_template.md | 6 +++--- .pre-commit-config.yaml | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3f52eebd9..18c01e24e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,11 +7,11 @@ Closes # ### Todo: -- \[ \] Clean up commit history +- [ ] Clean up commit history -- \[ \] Add or update documentation related to these changes +- [ ] Add or update documentation related to these changes -- \[ \] Add entry to the [release notes](https://github.com/ethereum//blob/main/newsfragments/README.md) +- [ ] Add entry to the [release notes](https://github.com/ethereum//blob/main/newsfragments/README.md) #### Cute Animal Picture diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 58f9e1d87..3ad4843d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: '.project-template|docs/conf.py' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.5.0 hooks: - id: check-yaml - id: check-toml @@ -30,6 +30,8 @@ repos: rev: 0.7.17 hooks: - id: mdformat + additional_dependencies: + - mdformat-gfm - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.5.1 hooks: From 86440ee879a96dfc9410010ae3fad829c21277fa Mon Sep 17 00:00:00 2001 From: pacrob Date: Thu, 12 Oct 2023 08:57:17 -0600 Subject: [PATCH 32/44] add autoflake to lint and move config to pyproject.toml --- .pre-commit-config.yaml | 6 ++++ .pydocstyle.ini | 30 ------------------ Makefile | 5 ++- mypy.ini | 16 ---------- pyproject.toml | 68 +++++++++++++++++++++++++++++++++++++++++ pytest.ini | 8 ----- tox.ini | 9 ------ 7 files changed, 78 insertions(+), 64 deletions(-) delete mode 100644 .pydocstyle.ini delete mode 100644 mypy.ini delete mode 100644 pytest.ini diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ad4843d4..d2fae1c9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,10 @@ repos: additional_dependencies: - flake8-bugbear==23.9.16 exclude: setup.py +- repo: https://github.com/PyCQA/autoflake + rev: v2.2.1 + hooks: + - id: autoflake - repo: https://github.com/pycqa/isort rev: 5.12.0 hooks: @@ -26,6 +30,8 @@ repos: rev: 6.3.0 hooks: - id: pydocstyle + additional_dependencies: + - tomli # required until >= python311 - repo: https://github.com/executablebooks/mdformat rev: 0.7.17 hooks: diff --git a/.pydocstyle.ini b/.pydocstyle.ini deleted file mode 100644 index 0d40aa887..000000000 --- a/.pydocstyle.ini +++ /dev/null @@ -1,30 +0,0 @@ -[pydocstyle] -; All error codes found here: -; http://www.pydocstyle.org/en/3.0.0/error_codes.html -; -; Ignored: -; D1 - Missing docstring error codes -; -; Selected: -; D2 - Whitespace error codes -; D3 - Quote error codes -; D4 - Content related error codes -select=D2,D3,D4 - -; Extra ignores: -; D200 - One-line docstring should fit on one line with quotes -; D203 - 1 blank line required before class docstring -; D204 - 1 blank line required after class docstring -; D205 - 1 blank line required between summary line and description -; D212 - Multi-line docstring summary should start at the first line -; D302 - Use u""" for Unicode docstrings -; D400 - First line should end with a period -; D401 - First line should be in imperative mood -; D412 - No blank lines allowed between a section header and its content -add-ignore=D200,D203,D204,D205,D212,D302,D400,D401,D412 - -; Explanation: -; D400 - Enabling this error code seems to make it a requirement that the first -; sentence in a docstring is not split across two lines. It also makes it a -; requirement that no docstring can have a multi-sentence description without a -; summary line. Neither one of those requirements seem appropriate. diff --git a/Makefile b/Makefile index 9deaab82f..fd94b2cef 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,10 @@ clean-pyc: find . -name '__pycache__' -exec rm -rf {} + lint: - pre-commit run --all-files --show-diff-on-failure + @pre-commit run --all-files --show-diff-on-failure || ( \ + echo "\n\n\n * pre-commit should have fixed the errors above. Running again to make sure everything is good..." \ + && pre-commit run --all-files --show-diff-on-failure \ + ) test: pytest tests diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 1fcbd14c0..000000000 --- a/mypy.ini +++ /dev/null @@ -1,16 +0,0 @@ -[mypy] - -check_untyped_defs = True -disallow_incomplete_defs = True -disallow_untyped_defs = True -disallow_any_generics = True -disallow_untyped_calls = True -disallow_untyped_decorators = True -disallow_subclassing_any = True -ignore_missing_imports = True -strict_optional = True -strict_equality = True -warn_redundant_casts = True -warn_return_any = True -warn_unused_configs = True -warn_unused_ignores = True diff --git a/pyproject.toml b/pyproject.toml index d94ebfd9b..5abd4c29d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,71 @@ +[tool.autoflake] +remove_all_unused_imports = "True" +exclude = "__init__.py" + +[tool.isort] +combine_as_imports = "True" +extra_standard_library = "pytest" +force_grid_wrap = 1 +force_sort_within_sections = "True" +known_third_party = "hypothesis,pytest" +known_first_party = "" +multi_line_output = 3 +profile = "black" + +[tool.mypy] +check_untyped_defs = "True" +disallow_incomplete_defs = "True" +disallow_untyped_defs = "True" +disallow_any_generics = "True" +disallow_untyped_calls = "True" +disallow_untyped_decorators = "True" +disallow_subclassing_any = "True" +ignore_missing_imports = "True" +strict_optional = "True" +strict_equality = "True" +warn_redundant_casts = "True" +warn_return_any = "True" +warn_unused_configs = "True" +warn_unused_ignores = "True" + + +[tool.pydocstyle] +# All error codes found here: +# http://www.pydocstyle.org/en/3.0.0/error_codes.html +# +# Ignored: +# D1 - Missing docstring error codes +# +# Selected: +# D2 - Whitespace error codes +# D3 - Quote error codes +# D4 - Content related error codes +select = "D2,D3,D4" + +# Extra ignores: +# D200 - One-line docstring should fit on one line with quotes +# D203 - 1 blank line required before class docstring +# D204 - 1 blank line required after class docstring +# D205 - 1 blank line required between summary line and description +# D212 - Multi-line docstring summary should start at the first line +# D302 - Use u""" for Unicode docstrings +# D400 - First line should end with a period +# D401 - First line should be in imperative mood +# D412 - No blank lines allowed between a section header and its content +add-ignore = "D200,D203,D204,D205,D212,D302,D400,D401,D412,D415" + +# Explanation: +# D400 - Enabling this error code seems to make it a requirement that the first +# sentence in a docstring is not split across two lines. It also makes it a +# requirement that no docstring can have a multi-sentence description without a +# summary line. Neither one of those requirements seem appropriate. + +[tool.pytest.ini_options] +addopts = "-v --showlocals --durations 10" +xfail_strict = "True" +log_format = "%(levelname)8s %(asctime)s %(filename)20s %(message)s" +log_date_format = "%m-%d %H:%M:%S" + [tool.towncrier] # Read https://github.com/ethereum//blob/main/newsfragments/README.md for instructions package = "" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index fd5ea7cb6..000000000 --- a/pytest.ini +++ /dev/null @@ -1,8 +0,0 @@ -[pytest] -addopts= -v --showlocals --durations 10 -xfail_strict=true -log_format = %(levelname)8s %(asctime)s %(filename)20s %(message)s -log_date_format = %m-%d %H:%M:%S - -[pytest-watch] -runner= pytest --failed-first --maxfail=1 --no-success-flaky-report diff --git a/tox.ini b/tox.ini index df00ee6d6..2742f06a2 100644 --- a/tox.ini +++ b/tox.ini @@ -6,15 +6,6 @@ envlist= py311-wheel-windows docs -[isort] -combine_as_imports=True -force_grid_wrap=1 -force_sort_within_sections=True -known_third_party=hypothesis,pytest -known_first_party= -multi_line_output=3 -profile=black - [flake8] exclude=venv*,.tox,docs,build extend-ignore=E203 From 662b35d09a8e33bd5bd4cbc611142fd06b0d1956 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:14:28 -0600 Subject: [PATCH 33/44] Update pyproject.toml Add description of pydocstyle D415 rule --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 5abd4c29d..8c23be362 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,7 @@ select = "D2,D3,D4" # D400 - First line should end with a period # D401 - First line should be in imperative mood # D412 - No blank lines allowed between a section header and its content +# D415 - First line should end with a period, question mark, or exclamation point add-ignore = "D200,D203,D204,D205,D212,D302,D400,D401,D412,D415" # Explanation: From 8d5d92ddd8fe0cb45f648fd7fa276c16987b5d82 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:54:07 -0600 Subject: [PATCH 34/44] Update setup.py drop pytest-watch from dev dependencies --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index ad552d5d1..193ed7be7 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,6 @@ "bumpversion>=0.5.3", "ipython", "pre-commit>=3.4.0", - "pytest-watch>=4.1.0", "tox>=4.0.0", "twine", "wheel", From 885bef7b5e7792af12fbe8f365e6410035f07fc5 Mon Sep 17 00:00:00 2001 From: pacrob Date: Fri, 27 Oct 2023 12:13:12 -0600 Subject: [PATCH 35/44] condense tox lint envs as linting now a pre-commit call, not tox --- tox.ini | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tox.ini b/tox.ini index 2742f06a2..f52da5f83 100644 --- a/tox.ini +++ b/tox.ini @@ -28,19 +28,11 @@ extras= docs allowlist_externals=make,pre-commit -[common-lint] -basepython=python +[testenv:py{38,39,310,311}-lint] deps=pre-commit commands= pre-commit run --all-files --show-diff-on-failure -[testenv:lint] -basepython: python -commands: {[common-lint]commands} - -[testenv:py{38,39,310,311}-lint] -commands: {[common-lint]commands} - [testenv:py{38,39,310,311}-wheel] deps= wheel From 3c654831215dafd772e220d314b3c9221417f461 Mon Sep 17 00:00:00 2001 From: fselmo Date: Tue, 7 Nov 2023 12:07:54 -0700 Subject: [PATCH 36/44] update the grep command for upstream branch check - Sometimes 'www.' is used in the url for https --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fd94b2cef..29815fadf 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,9 @@ notes: check-bump release: check-bump clean # require that upstream is configured for ethereum/ - git remote -v | grep "upstream\tgit@github.com:ethereum/.git (push)\|upstream\thttps://github.com/ethereum/ (push)" + @git remote -v | grep \ + -e "upstream\tgit@github.com:ethereum/.git (push)" \ + -Ee "upstream\thttps://(www.)?github.com/ethereum/ \(push\)" # verify that docs build correctly ./newsfragments/validate_files.py is-empty make build-docs From 7f75b270a530924a91c776f32c708c9a82881771 Mon Sep 17 00:00:00 2001 From: fselmo Date: Tue, 7 Nov 2023 12:13:48 -0700 Subject: [PATCH 37/44] Use upcoming version in make notes commit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 29815fadf..6afbaf3ac 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ notes: check-bump towncrier build --yes --version $(UPCOMING_VERSION) # Before we bump the version, make sure that the towncrier-generated docs will build make build-docs - git commit -m "Compile release notes" + git commit -m "Compile release notes for v$(UPCOMING_VERSION)" release: check-bump clean # require that upstream is configured for ethereum/ From 4d17820fca41d23d1e69cfd21282cd6e89f03231 Mon Sep 17 00:00:00 2001 From: fselmo Date: Mon, 27 Nov 2023 13:02:31 -0700 Subject: [PATCH 38/44] Further generalize the grep command for remote check --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6afbaf3ac..c5956da19 100644 --- a/Makefile +++ b/Makefile @@ -67,9 +67,7 @@ notes: check-bump release: check-bump clean # require that upstream is configured for ethereum/ - @git remote -v | grep \ - -e "upstream\tgit@github.com:ethereum/.git (push)" \ - -Ee "upstream\thttps://(www.)?github.com/ethereum/ \(push\)" + @git remote -v | grep -E "upstream\tgit@github.com:ethereum/.git \(push\)|upstream\thttps://(www.)?github.com/ethereum/ \(push\)" # verify that docs build correctly ./newsfragments/validate_files.py is-empty make build-docs From 67c0fb4f7b2e72be5161942af68b27a11a7b0e9d Mon Sep 17 00:00:00 2001 From: Stuart Reed Date: Mon, 27 Nov 2023 15:51:31 -0700 Subject: [PATCH 39/44] Ignore all __pycache__ directories (#114) * Ignore all __pycache__ directories * Newsfragment * Revert Newsfragment --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5127a4df1..57eac5299 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,9 @@ chains .cache .pytest_cache +# pycache +__pycache__/ + # Test output logs logs From 0b0593880dbcebbfd6ae496b08e63f01ad814418 Mon Sep 17 00:00:00 2001 From: pacrob Date: Tue, 28 Nov 2023 09:21:12 -0700 Subject: [PATCH 40/44] add formats key to RTD to make downloadable docs available --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 593793c27..e55e07e4b 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -15,3 +15,6 @@ python: path: . extra_requirements: - docs + +# Build all formats for RTD Downloads - htmlzip, pdf, epub +formats: all From d1395aaad2b26dffc61aec7ee821c597784ae816 Mon Sep 17 00:00:00 2001 From: Paul Robinson <5199899+pacrob@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:01:08 -0700 Subject: [PATCH 41/44] add .bumpversion.cfg to pre-commit ignore Causes problems with releasing when pre-commit changes the file after bumpversion updates it --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2fae1c9e..789b16cdc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -exclude: '.project-template|docs/conf.py' +exclude: '.project-template|docs/conf.py|.bumpversion.cfg' repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 From 621cd56059b73ea60f315ebef437a998d15481be Mon Sep 17 00:00:00 2001 From: pacrob Date: Thu, 7 Dec 2023 14:39:09 -0700 Subject: [PATCH 42/44] add pyupgrade to pre-commit hooks --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 789b16cdc..d1aa72ceb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,3 +43,8 @@ repos: hooks: - id: mypy exclude: tests/ +- repo: https://github.com/asottile/pyupgrade + rev: v3.15.0 + hooks: + - id: pyupgrade + args: [--py38-plus] From cb3f556315ba864450c975b88058f08da0a9c399 Mon Sep 17 00:00:00 2001 From: pacrob Date: Sat, 9 Dec 2023 12:12:52 -0700 Subject: [PATCH 43/44] move pyupgrade before black --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d1aa72ceb..82b01b7cb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,11 @@ repos: - id: check-toml - id: end-of-file-fixer - id: trailing-whitespace +- repo: https://github.com/asottile/pyupgrade + rev: v3.15.0 + hooks: + - id: pyupgrade + args: [--py38-plus] - repo: https://github.com/psf/black rev: 23.9.1 hooks: @@ -43,8 +48,3 @@ repos: hooks: - id: mypy exclude: tests/ -- repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 - hooks: - - id: pyupgrade - args: [--py38-plus] From 87b9415079717d200f302da02d25b0ce64506509 Mon Sep 17 00:00:00 2001 From: pacrob Date: Mon, 18 Dec 2023 12:56:31 -0700 Subject: [PATCH 44/44] run lint and clean up __init__ files convert .format and % strings that pyupgrade can't do drop unnecessary deps, remove unnecessary upper pins remove pre-commit install from ci, it's handled by tox --- .circleci/config.yml | 3 - .deepsource.toml | 2 +- .git-blame-ignore-revs | 2 +- .pre-commit-config.yaml | 2 +- DEVELOPMENT.md | 37 ++++++----- Makefile | 4 +- README.md | 1 - docs/api/api.chain.rst | 2 +- docs/api/api.vm.rst | 2 +- docs/api/db/api.db.atomic.rst | 1 - docs/api/db/api.db.backends.rst | 2 +- docs/api/db/api.db.diff.rst | 2 - docs/api/db/api.db.journal.rst | 2 +- docs/api/db/api.db.schema.rst | 2 +- docs/api/index.rst | 2 +- docs/api/rlp/api.rlp.transactions.rst | 1 - docs/api/tools/api.tools.fixtures.rst | 7 +-- docs/api/vm/api.vm.code_stream.rst | 1 - docs/api/vm/api.vm.execution_context.rst | 1 - docs/api/vm/api.vm.gas_meter.rst | 1 - docs/api/vm/api.vm.memory.rst | 1 - docs/api/vm/api.vm.message.rst | 1 - docs/api/vm/api.vm.opcode.rst | 1 - docs/api/vm/api.vm.stack.rst | 1 - docs/api/vm/api.vm.transaction_context.rst | 1 - docs/api/vm/api.vm.vm.rst | 1 - docs/conf.py | 6 +- docs/contributing.rst | 8 +-- docs/cookbook/index.rst | 4 +- docs/fragments/virtualenv_explainer.rst | 2 +- docs/guides/architecture.rst | 2 +- .../building_an_app_that_uses_pyevm.rst | 5 +- docs/guides/creating_opcodes.rst | 2 +- docs/guides/quickstart.rst | 2 - eth/__init__.py | 9 ++- eth/_utils/blake2/compression.py | 3 +- eth/_utils/env.py | 20 +++--- eth/_utils/headers.py | 12 ++-- eth/_utils/version.py | 1 - eth/abc.py | 10 +-- eth/chains/base.py | 5 +- eth/chains/tester/__init__.py | 6 +- eth/consensus/__init__.py | 10 +-- eth/consensus/clique/__init__.py | 6 +- eth/consensus/clique/_utils.py | 3 - eth/consensus/clique/clique.py | 1 - eth/consensus/clique/snapshot_manager.py | 14 ++--- eth/db/account.py | 36 +++++------ eth/db/atomic.py | 4 +- eth/db/backends/base.py | 2 - eth/db/chain.py | 5 +- eth/db/chain_gaps.py | 1 - eth/db/header.py | 1 - eth/db/schema.py | 8 +-- eth/db/slow_journal.py | 2 +- eth/db/storage.py | 6 +- eth/exceptions.py | 44 ------------- eth/precompiles/__init__.py | 18 +++--- eth/tools/_utils/mappings.py | 3 +- eth/tools/_utils/normalization.py | 23 +++---- eth/tools/builder/chain/__init__.py | 4 +- eth/tools/builder/chain/builders.py | 9 ++- eth/tools/db/atomic.py | 3 +- eth/tools/fixtures/__init__.py | 8 +-- eth/tools/fixtures/fillers/__init__.py | 8 +-- eth/tools/fixtures/fillers/common.py | 11 ++-- eth/tools/fixtures/fillers/main.py | 9 ++- eth/tools/fixtures/fillers/vm.py | 7 ++- eth/tools/fixtures/helpers.py | 2 - eth/typing.py | 53 ++++++++-------- eth/vm/base.py | 23 +++---- eth/vm/computation.py | 61 ++++++++----------- eth/vm/forks/__init__.py | 30 ++++----- eth/vm/forks/arrow_glacier/computation.py | 2 - eth/vm/forks/berlin/logic.py | 1 - eth/vm/forks/byzantium/headers.py | 3 +- eth/vm/forks/frontier/computation.py | 13 ++-- eth/vm/forks/frontier/state.py | 38 +++++------- eth/vm/forks/gray_glacier/computation.py | 2 - eth/vm/forks/homestead/computation.py | 7 +-- eth/vm/forks/london/receipts.py | 5 +- eth/vm/forks/london/state.py | 9 ++- eth/vm/forks/spurious_dragon/computation.py | 8 +-- eth/vm/forks/spurious_dragon/state.py | 3 +- eth/vm/gas_meter.py | 19 ++---- eth/vm/logic/call.py | 12 +--- eth/vm/logic/system.py | 20 +++--- eth/vm/stack.py | 4 +- newsfragments/2128.breaking.rst | 1 + newsfragments/2128.internal.rst | 1 + pyproject.toml | 35 +++++------ scripts/__init__.py | 0 scripts/benchmark/_utils/reporting.py | 2 +- scripts/benchmark/checks/__init__.py | 6 +- scripts/benchmark/checks/base_benchmark.py | 6 +- scripts/benchmark/checks/deploy_dos.py | 23 ++++--- scripts/benchmark/checks/erc20_interact.py | 27 ++++---- .../benchmark/checks/import_empty_blocks.py | 13 ++-- scripts/benchmark/checks/mine_empty_blocks.py | 13 ++-- .../checks/simple_value_transfers.py | 30 ++++----- .../benchmark/contract_data/DOSContract.sol | 4 +- .../DOSContract.sol-compiled/combined.json | 8 +-- scripts/benchmark/contract_data/erc20.sol | 2 +- .../erc20.sol-compiled/combined.json | 16 ++--- scripts/benchmark/run.py | 22 +++---- setup.py | 25 +++----- tests/conftest.py | 2 +- .../address-utils/test_address_generation.py | 3 +- .../core/builder-tools/test_chain_builder.py | 3 +- .../builder-tools/test_chain_construction.py | 3 +- .../builder-tools/test_chain_initializer.py | 2 +- tests/core/chain-object/test_chain.py | 3 +- .../chain-object/test_chain_get_ancestors.py | 10 +-- tests/core/chain-object/test_contract_call.py | 3 +- .../chain-object/test_create_transaction.py | 3 +- tests/core/code-stream/test_code_stream.py | 2 +- tests/core/consensus/test_clique_consensus.py | 3 +- tests/core/consensus/test_clique_utils.py | 3 +- tests/core/consensus/test_consensus_engine.py | 3 +- tests/core/consensus/test_pow_mining.py | 3 +- tests/core/env-utils/test_env_bool.py | 1 + tests/core/env-utils/test_env_float.py | 1 + tests/core/env-utils/test_env_int.py | 1 + tests/core/env-utils/test_env_list.py | 1 + tests/core/env-utils/test_env_string.py | 1 + .../fixture-tools/test_normalize_state.py | 3 +- tests/core/gas_meter/test_gas_meter.py | 3 +- tests/core/helpers.py | 3 +- .../test_encode_and_decode.py | 3 +- tests/core/memory/test_memory.py | 3 +- .../message-object/test_message_object.py | 3 +- .../numeric-utils/test_integer_squareroot.py | 3 +- tests/core/opcodes/test_opcodes.py | 2 +- tests/core/precompiles/test_blake2.py | 3 +- tests/core/stack/test_stack.py | 3 +- .../tester/test_generate_vm_configuration.py | 1 + .../test_receipt_encoding.py | 3 +- .../test_transaction_encoding.py | 3 +- .../test_transaction_signature_validation.py | 3 +- tests/core/validation/test_eth1_validation.py | 3 +- .../validation/test_transaction_validation.py | 3 +- .../validation/test_withdrawal_validation.py | 3 +- tests/core/vm/conftest.py | 3 +- tests/core/vm/test_base_computation.py | 3 +- tests/core/vm/test_clique_validation.py | 3 +- tests/core/vm/test_computation.py | 3 +- .../core/vm/test_contract_code_size_limit.py | 3 +- tests/core/vm/test_interrupt.py | 3 +- tests/core/vm/test_london.py | 3 +- tests/core/vm/test_mainnet_dao_fork.py | 5 +- tests/core/vm/test_modexp_precompile.py | 2 +- tests/core/vm/test_rewards.py | 3 +- tests/core/vm/test_validate_transaction.py | 3 +- tests/core/vm/test_vm.py | 3 +- tests/core/vm/test_vm_class_configurations.py | 3 +- tests/core/vm/test_vm_state.py | 3 +- tests/database/test_accesslog.py | 3 +- tests/database/test_account_db.py | 3 +- tests/database/test_batch_db.py | 3 +- tests/database/test_eth1_chaindb.py | 3 +- tests/database/test_header_db.py | 2 +- tests/database/test_journal_db.py | 5 +- .../blockchain/test_blockchain.py | 2 +- tests/json-fixtures/test_difficulty.py | 2 +- tests/json-fixtures/test_transactions.py | 2 +- tests/json-fixtures/test_virtual_machine.py | 2 +- tox.ini | 6 +- 167 files changed, 486 insertions(+), 664 deletions(-) create mode 100644 newsfragments/2128.breaking.rst create mode 100644 newsfragments/2128.internal.rst create mode 100644 scripts/__init__.py diff --git a/.circleci/config.yml b/.circleci/config.yml index a2e53261d..0e730dafb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,9 +52,6 @@ common: &common command: | python -m pip install --upgrade pip python -m pip install tox - - run: - name: install pre-commit - command: python -m pip install --progress-bar=off pre-commit - run: name: run tox command: python -m tox run -r diff --git a/.deepsource.toml b/.deepsource.toml index 0ca491248..4233f9944 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -9,4 +9,4 @@ name = "python" enabled = true [analyzers.meta] - runtime_version = "3.x.x" \ No newline at end of file + runtime_version = "3.x.x" diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index cb09ca284..7ceefc878 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -3,4 +3,4 @@ e9049224a98439cc27522e322cc09e402503565a 1ee3cce389e48b37895e812692f87aaf4f96e27f # ignore SHA that added black -6c958538082fcf6e6d9165c30f289e3c64dbfc5a \ No newline at end of file +6c958538082fcf6e6d9165c30f289e3c64dbfc5a diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 82b01b7cb..9838ad3af 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,4 +47,4 @@ repos: rev: v1.5.1 hooks: - id: mypy - exclude: tests/ + files: eth/ diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index d2029bf92..ae7bc5936 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -7,27 +7,26 @@ The following workflows are supported for blocks. Incremental creation 1. Initialize Block - `Header.from_parent(...)`: - - `coinbase` - - `parent_hash` - - `difficulty` - - `block_number` - - `gas_limit` - - `timestamp` -2. Apply Transaction(s) - `Block.apply_transaction(...)`: -3. Mine Block - `Block.mine(...)`: - - `uncles_hash` - - `state_root` - - `transaction_root` - - `receipts_root` - - `bloom` - - `gas_used` - - `extra_data` - - `mix_hash` - - `nonce` - + - `coinbase` + - `parent_hash` + - `difficulty` + - `block_number` + - `gas_limit` + - `timestamp` +1. Apply Transaction(s) - `Block.apply_transaction(...)`: +1. Mine Block - `Block.mine(...)`: + - `uncles_hash` + - `state_root` + - `transaction_root` + - `receipts_root` + - `bloom` + - `gas_used` + - `extra_data` + - `mix_hash` + - `nonce` ## 2. Block Ingestion > (This is actually just a special case of use case #1.) -Full ingestion of a complete block. +Full ingestion of a complete block. diff --git a/Makefile b/Makefile index d39b7db47..25f54f9d3 100644 --- a/Makefile +++ b/Makefile @@ -71,8 +71,8 @@ notes: git commit -m "Compile release notes for v$(UPCOMING_VERSION)" release: check-bump clean - # require that you be on a branch that's linked to upstream/master - git status -s -b | head -1 | grep "\.\.upstream/master" + # require that you be on a branch that's linked to upstream/main + git status -s -b | head -1 | grep "\.\.upstream/main" # require that upstream is configured for ethereum/py-evm @git remote -v | grep -E "upstream\tgit@github.com:ethereum/py-evm.git \(push\)|upstream\thttps://(www.)?github.com/ethereum/py-evm \(push\)" # verify that docs build correctly diff --git a/README.md b/README.md index be3981c81..c9581b192 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ [![Python versions](https://img.shields.io/pypi/pyversions/py-evm.svg)](https://pypi.python.org/pypi/py-evm) [![Docs build](https://readthedocs.org/projects/py-evm/badge/?version=latest)](https://py-evm.readthedocs.io/en/latest/?badge=latest) - ## Py-EVM Py-EVM is an implementation of the Ethereum protocol in Python. It contains the low level diff --git a/docs/api/api.chain.rst b/docs/api/api.chain.rst index 1c9b3931a..866fabd95 100644 --- a/docs/api/api.chain.rst +++ b/docs/api/api.chain.rst @@ -17,4 +17,4 @@ MiningChain ----------- .. autoclass:: eth.chains.base.MiningChain - :members: \ No newline at end of file + :members: diff --git a/docs/api/api.vm.rst b/docs/api/api.vm.rst index 97fb44d82..8bfea882c 100644 --- a/docs/api/api.vm.rst +++ b/docs/api/api.vm.rst @@ -18,4 +18,4 @@ Virtual Machine vm/api.vm.stack vm/api.vm.state vm/api.vm.transaction_context - vm/api.vm.forks \ No newline at end of file + vm/api.vm.forks diff --git a/docs/api/db/api.db.atomic.rst b/docs/api/db/api.db.atomic.rst index 0ef6d1e4b..d9bf99d0e 100644 --- a/docs/api/db/api.db.atomic.rst +++ b/docs/api/db/api.db.atomic.rst @@ -10,4 +10,3 @@ AtomicDB .. autoclass:: eth.db.atomic.AtomicDBWriteBatch :members: - diff --git a/docs/api/db/api.db.backends.rst b/docs/api/db/api.db.backends.rst index bc2459b9e..7f1cb179c 100644 --- a/docs/api/db/api.db.backends.rst +++ b/docs/api/db/api.db.backends.rst @@ -11,4 +11,4 @@ MemoryDB -------- .. autoclass:: eth.db.backends.memory.MemoryDB - :members: \ No newline at end of file + :members: diff --git a/docs/api/db/api.db.diff.rst b/docs/api/db/api.db.diff.rst index ff280346e..c0239b743 100644 --- a/docs/api/db/api.db.diff.rst +++ b/docs/api/db/api.db.diff.rst @@ -18,5 +18,3 @@ DiffMissingError .. autoclass:: eth.db.diff.DiffMissingError :members: - - diff --git a/docs/api/db/api.db.journal.rst b/docs/api/db/api.db.journal.rst index ca4824634..51e976b96 100644 --- a/docs/api/db/api.db.journal.rst +++ b/docs/api/db/api.db.journal.rst @@ -5,4 +5,4 @@ JournalDB --------- .. autoclass:: eth.db.journal.JournalDB - :members: \ No newline at end of file + :members: diff --git a/docs/api/db/api.db.schema.rst b/docs/api/db/api.db.schema.rst index cf973da91..f8a4f9d8a 100644 --- a/docs/api/db/api.db.schema.rst +++ b/docs/api/db/api.db.schema.rst @@ -5,4 +5,4 @@ SchemaV1 -------- .. autoclass:: eth.db.schema.SchemaV1 - :members: \ No newline at end of file + :members: diff --git a/docs/api/index.rst b/docs/api/index.rst index 4dd663f0d..90d9c8967 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -11,7 +11,7 @@ This section aims to provide a detailed description of all APIs. If you are look :maxdepth: 4 :name: toc-api-eth - + api.abc api.chain api.db diff --git a/docs/api/rlp/api.rlp.transactions.rst b/docs/api/rlp/api.rlp.transactions.rst index 2f6c63c2a..7f9e6207e 100644 --- a/docs/api/rlp/api.rlp.transactions.rst +++ b/docs/api/rlp/api.rlp.transactions.rst @@ -24,4 +24,3 @@ BaseUnsignedTransaction .. autoclass:: eth.rlp.transactions.BaseUnsignedTransaction :members: - diff --git a/docs/api/tools/api.tools.fixtures.rst b/docs/api/tools/api.tools.fixtures.rst index 5c857c3b0..2e8c0cebb 100644 --- a/docs/api/tools/api.tools.fixtures.rst +++ b/docs/api/tools/api.tools.fixtures.rst @@ -4,7 +4,7 @@ Builder Tools The JSON test fillers found in `eth.tools.fixtures` is a set of tools which facilitate creating standard JSON consensus tests as found in the -`ethereum/tests repository `_. +`ethereum/tests repository `_. .. note:: Only VM and state tests are supported right now. @@ -12,7 +12,7 @@ creating standard JSON consensus tests as found in the State Test Fillers ------------------ -Tests are generated in two steps. +Tests are generated in two steps. * First, a *test filler* is written that contains a high level description of the test case. * Subsequently, the filler is compiled to the actual test in a process called @@ -52,7 +52,7 @@ sequence of functions. ) ) -.. note:: +.. note:: Note that :func:`~eth.tools.fixtures.setup_filler` returns a dictionary, whereas all of the following functions such as @@ -68,4 +68,3 @@ sequence of functions. .. autofunction:: eth.tools.fixtures.fillers.execution .. autofunction:: eth.tools.fixtures.fillers.expect - diff --git a/docs/api/vm/api.vm.code_stream.rst b/docs/api/vm/api.vm.code_stream.rst index 62a4e19c3..3d43bcc24 100644 --- a/docs/api/vm/api.vm.code_stream.rst +++ b/docs/api/vm/api.vm.code_stream.rst @@ -3,4 +3,3 @@ CodeStream .. autoclass:: eth.vm.code_stream.CodeStream :members: - diff --git a/docs/api/vm/api.vm.execution_context.rst b/docs/api/vm/api.vm.execution_context.rst index 857e4098c..27a913aac 100644 --- a/docs/api/vm/api.vm.execution_context.rst +++ b/docs/api/vm/api.vm.execution_context.rst @@ -3,4 +3,3 @@ ExecutionContext .. autoclass:: eth.vm.execution_context.ExecutionContext :members: - diff --git a/docs/api/vm/api.vm.gas_meter.rst b/docs/api/vm/api.vm.gas_meter.rst index 38257a3a4..581a544aa 100644 --- a/docs/api/vm/api.vm.gas_meter.rst +++ b/docs/api/vm/api.vm.gas_meter.rst @@ -3,4 +3,3 @@ GasMeter .. autoclass:: eth.vm.gas_meter.GasMeter :members: - diff --git a/docs/api/vm/api.vm.memory.rst b/docs/api/vm/api.vm.memory.rst index 109fdc398..de4adc6cf 100644 --- a/docs/api/vm/api.vm.memory.rst +++ b/docs/api/vm/api.vm.memory.rst @@ -3,4 +3,3 @@ Memory .. autoclass:: eth.vm.memory.Memory :members: - diff --git a/docs/api/vm/api.vm.message.rst b/docs/api/vm/api.vm.message.rst index 48e8ac583..1fb4b657a 100644 --- a/docs/api/vm/api.vm.message.rst +++ b/docs/api/vm/api.vm.message.rst @@ -3,4 +3,3 @@ Message .. autoclass:: eth.vm.message.Message :members: - diff --git a/docs/api/vm/api.vm.opcode.rst b/docs/api/vm/api.vm.opcode.rst index 502bfbdbb..1a66a3baa 100644 --- a/docs/api/vm/api.vm.opcode.rst +++ b/docs/api/vm/api.vm.opcode.rst @@ -3,4 +3,3 @@ Opcode .. autoclass:: eth.vm.opcode.Opcode :members: - diff --git a/docs/api/vm/api.vm.stack.rst b/docs/api/vm/api.vm.stack.rst index df0d2ac8f..554e71b04 100644 --- a/docs/api/vm/api.vm.stack.rst +++ b/docs/api/vm/api.vm.stack.rst @@ -3,4 +3,3 @@ Stack .. autoclass:: eth.vm.stack.Stack :members: - diff --git a/docs/api/vm/api.vm.transaction_context.rst b/docs/api/vm/api.vm.transaction_context.rst index 665e7d683..3513c5e6a 100644 --- a/docs/api/vm/api.vm.transaction_context.rst +++ b/docs/api/vm/api.vm.transaction_context.rst @@ -3,4 +3,3 @@ BaseTransactionContext .. autoclass:: eth.vm.transaction_context.BaseTransactionContext :members: - diff --git a/docs/api/vm/api.vm.vm.rst b/docs/api/vm/api.vm.vm.rst index eec084896..7a1e1cc86 100644 --- a/docs/api/vm/api.vm.vm.rst +++ b/docs/api/vm/api.vm.vm.rst @@ -9,4 +9,3 @@ VM .. autoclass:: eth.vm.base.VM :members: :exclude-members: get_prev_hashes - diff --git a/docs/conf.py b/docs/conf.py index 434d4cb71..d44838751 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -120,8 +120,8 @@ def setup(app): - app.add_stylesheet("css/custom.css") - app.add_javascript("js/matomo.js") + app.add_css_file("css/custom.css") + app.add_js_file("js/matomo.js") # Allows the mod index to function more helpfully (not everything under 'e') @@ -133,7 +133,7 @@ def setup(app): # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = "ethdocs" +htmlhelp_basename = "py-evmdocs" # -- Options for LaTeX output --------------------------------------------- diff --git a/docs/contributing.rst b/docs/contributing.rst index 926128c34..dd0ac8a3b 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -51,7 +51,7 @@ Code Style When multiple people are working on the same body of code, it is important that they write code that conforms to a similar style. It often doesn't matter as much which style, but rather that they conform to one style. -To ensure your contribution conforms to the style being used in this project, we encourage you to read our `style guide `_. +To ensure your contribution conforms to the style being used in this project, we encourage you to read our `style guide `_. @@ -74,7 +74,7 @@ Documentation ~~~~~~~~~~~~~ Good documentation will lead to quicker adoption and happier users. Please check out our guide -on `how to create documentation for the Python Ethereum ecosystem `_. +on `how to create documentation for the Python Ethereum ecosystem `_. Pull Requests @@ -92,7 +92,7 @@ do not pass the CI build yet won't get reviewed unless explicitly requested. If the pull request introduces changes that should be reflected in the release notes, please add a `newsfragment` file as explained -`here `_. +`here `_. If possible, the change to the release notes file should be included in the commit that introduces the feature or bugfix. @@ -107,7 +107,7 @@ Before releasing a new version, build and test the package that will be released .. code:: sh - git checkout master && git pull + git checkout main && git pull make package diff --git a/docs/cookbook/index.rst b/docs/cookbook/index.rst index c9571aba2..6449b0c4f 100644 --- a/docs/cookbook/index.rst +++ b/docs/cookbook/index.rst @@ -104,7 +104,7 @@ Building blocks incrementally ------------------------------ The default :class:`~eth.chains.chain.Chain` is stateless and thus does not keep a tip block open -that would allow us to incrementally build a block. However, we can import the +that would allow us to incrementally build a block. However, we can import the :class:`~eth.chains.chain.MiningChain` which does allow exactly that. .. doctest:: @@ -112,5 +112,5 @@ that would allow us to incrementally build a block. However, we can import the >>> from eth.chains.base import MiningChain Please check out the :doc:`Understanding the mining process -` guide for a full example that demonstrates how +` guide for a full example that demonstrates how to use the :class:`~eth.chains.chain.MiningChain`. diff --git a/docs/fragments/virtualenv_explainer.rst b/docs/fragments/virtualenv_explainer.rst index 8257720c2..48e7cafef 100644 --- a/docs/fragments/virtualenv_explainer.rst +++ b/docs/fragments/virtualenv_explainer.rst @@ -19,4 +19,4 @@ To activate the virtual directory we have to *source* it .. code:: sh - . venv/bin/activate \ No newline at end of file + . venv/bin/activate diff --git a/docs/guides/architecture.rst b/docs/guides/architecture.rst index 0d5da78ae..3c2c7ea8b 100644 --- a/docs/guides/architecture.rst +++ b/docs/guides/architecture.rst @@ -90,7 +90,7 @@ The term **Computation** is used to encapsulate: - The computational state during VM execution (e.g. memory, stack, gas metering) - The computational results of VM execution (e.g. return data, gas consumption and refunds, execution errors) - + This abstraction is the interface through which opcode logic is implemented. diff --git a/docs/guides/building_an_app_that_uses_pyevm.rst b/docs/guides/building_an_app_that_uses_pyevm.rst index 9c24eba5d..39ae7b0e6 100644 --- a/docs/guides/building_an_app_that_uses_pyevm.rst +++ b/docs/guides/building_an_app_that_uses_pyevm.rst @@ -99,10 +99,7 @@ Next, we'll create a new directory ``app`` and create a file ``main.py`` inside. >>> mock_address_balance = chain.get_vm().state.get_balance(MOCK_ADDRESS) - >>> print("The balance of address {} is {} wei".format( - ... encode_hex(MOCK_ADDRESS), - ... mock_address_balance) - ... ) + >>> print(f"The balance of address {encode_hex(MOCK_ADDRESS)} is {mock_address_balance} wei") The balance of address 0x0000000000000000000000000000000000000000 is 10000000000000000000000 wei Running the script diff --git a/docs/guides/creating_opcodes.rst b/docs/guides/creating_opcodes.rst index f65585c1e..e84c0c719 100644 --- a/docs/guides/creating_opcodes.rst +++ b/docs/guides/creating_opcodes.rst @@ -51,7 +51,7 @@ Usage of the :func:`~eth.vm.opcode.as_opcode` helper: def custom_op(computation): ... # opcode logic here - + class ExampleComputation(BaseComputation): opcodes = { b'\x01': as_opcode(custom_op, 'CUSTOM_OP', 10), diff --git a/docs/guides/quickstart.rst b/docs/guides/quickstart.rst index e2dfed00b..94b1be843 100644 --- a/docs/guides/quickstart.rst +++ b/docs/guides/quickstart.rst @@ -58,5 +58,3 @@ Finally, install the ``py-evm`` package via pip: :doc:`Build a first app ` on top of Py-EVM in under 5 minutes - - diff --git a/eth/__init__.py b/eth/__init__.py index 61966a2ce..b50de7e9d 100644 --- a/eth/__init__.py +++ b/eth/__init__.py @@ -1,7 +1,10 @@ -import pkg_resources import sys -from eth.chains import ( # noqa: F401 +from importlib.metadata import ( + version as __version, +) + +from eth.chains import ( Chain, MainnetChain, MainnetTesterChain, @@ -15,4 +18,4 @@ sys.setrecursionlimit(max(EVM_RECURSION_LIMIT, sys.getrecursionlimit())) -__version__ = pkg_resources.get_distribution("py-evm").version +__version__ = __version("py-evm") diff --git a/eth/_utils/blake2/compression.py b/eth/_utils/blake2/compression.py index 2c7cdd33e..3d1a70587 100755 --- a/eth/_utils/blake2/compression.py +++ b/eth/_utils/blake2/compression.py @@ -83,7 +83,6 @@ def blake2b_compress( 'F Compression' from section 3.2 of RFC 7693: https://tools.ietf.org/html/rfc7693#section-3.2 """ - # Dereference these for [very small] speed improvement. # Perhaps more than anything, this makes the code # easier to read. @@ -107,7 +106,7 @@ def blake2b_compress( m = ( block if isinstance(block, tuple) - else struct.unpack_from("<16%s" % Blake2b.WORDFMT, bytes(block)) + else struct.unpack_from(f"<16{Blake2b.WORDFMT}", bytes(block)) ) v = [0] * 16 diff --git a/eth/_utils/env.py b/eth/_utils/env.py index e38aee353..172d903f5 100644 --- a/eth/_utils/env.py +++ b/eth/_utils/env.py @@ -29,8 +29,6 @@ class empty: for a default in real Python code. """ - pass - def get_env_value(name: str, required: bool = False, default: Any = empty) -> str: """ @@ -56,7 +54,8 @@ def get_env_value(name: str, required: bool = False, default: Any = empty) -> st def env_int( name: str, required: bool = False, default: Union[Type[empty], int] = empty ) -> int: - """Pulls an environment variable out of the environment and casts it to an + """ + Pulls an environment variable out of the environment and casts it to an integer. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an integer, a ``ValueError`` will be @@ -86,7 +85,8 @@ def env_int( def env_float( name: str, required: bool = False, default: Union[Type[empty], float] = empty ) -> float: - """Pulls an environment variable out of the environment and casts it to an + """ + Pulls an environment variable out of the environment and casts it to an float. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an float, a ``ValueError`` will be @@ -119,7 +119,8 @@ def env_bool( required: bool = False, default: Union[Type[empty], bool] = empty, ) -> bool: - """Pulls an environment variable out of the environment returning it as a + """ + Pulls an environment variable out of the environment returning it as a boolean. The strings ``'True'`` and ``'true'`` are the default *truthy* values. If not present in the environment and no default is specified, ``None`` is returned. @@ -149,7 +150,8 @@ def env_bool( def env_string( name: str, required: bool = False, default: Union[Type[empty], str] = empty ) -> str: - """Pulls an environment variable out of the environment returning it as a + """ + Pulls an environment variable out of the environment returning it as a string. If not present in the environment and no default is specified, an empty string is returned. @@ -177,7 +179,8 @@ def env_list( required: bool = False, default: Union[Type[empty], List[Any]] = empty, ) -> List[Any]: - """Pulls an environment variable out of the environment, splitting it on a + """ + Pulls an environment variable out of the environment, splitting it on a separator, and returning it as a list. Extra whitespace on the list values is stripped. List values that evaluate as falsy are removed. If not present and no default specified, an empty list is returned. @@ -213,7 +216,8 @@ def get( default: Union[Type[empty], T] = empty, type: Type[T] = None, ) -> T: - """Generic getter for environment variables. Handles defaults, + """ + Generic getter for environment variables. Handles defaults, required-ness, and what type to expect. :param name: The name of the environment variable be pulled diff --git a/eth/_utils/headers.py b/eth/_utils/headers.py index 4f135bf2f..30595771d 100644 --- a/eth/_utils/headers.py +++ b/eth/_utils/headers.py @@ -61,12 +61,12 @@ def fill_header_params_from_parent( difficulty: int, timestamp: int, coinbase: Address = ZERO_ADDRESS, - nonce: bytes = None, - extra_data: bytes = None, - transaction_root: bytes = None, - state_root: bytes = None, - mix_hash: bytes = None, - receipt_root: bytes = None, + nonce: Optional[bytes] = None, + extra_data: Optional[bytes] = None, + transaction_root: Optional[bytes] = None, + state_root: Optional[bytes] = None, + mix_hash: Optional[bytes] = None, + receipt_root: Optional[bytes] = None, ) -> Dict[str, HeaderParams]: if parent is None: parent_hash = GENESIS_PARENT_HASH diff --git a/eth/_utils/version.py b/eth/_utils/version.py index 254c589f7..6638574a4 100644 --- a/eth/_utils/version.py +++ b/eth/_utils/version.py @@ -11,7 +11,6 @@ def construct_evm_runtime_identifier() -> str: e.g. 'Py-EVM/v1.2.3/darwin-amd64/python3.9.13' """ - platform = sys.platform v = sys.version_info imp = sys.implementation diff --git a/eth/abc.py b/eth/abc.py index fe776af97..03448c1b8 100644 --- a/eth/abc.py +++ b/eth/abc.py @@ -471,7 +471,6 @@ def v(self) -> int: class UnsignedTransactionAPI(BaseTransactionAPI): - """ A class representing a transaction before it is signed. """ @@ -654,7 +653,6 @@ def validate(self) -> None: Hook called during instantiation to ensure that all transaction parameters pass validation rules. """ - ... # @@ -815,7 +813,9 @@ def __init__( header: BlockHeaderAPI, transactions: Sequence[SignedTransactionAPI], uncles: Sequence[BlockHeaderAPI], - withdrawals: Sequence[WithdrawalAPI] = None, # only present post-Shanghai + withdrawals: Optional[ + Sequence[WithdrawalAPI] + ] = None, # only present post-Shanghai ) -> None: ... @@ -1040,8 +1040,6 @@ class AtomicWriteBatchAPI(DatabaseAPI): but the writes will not actually persist until this object is committed. """ - pass - class AtomicDatabaseAPI(DatabaseAPI): """ @@ -2758,7 +2756,6 @@ def build_computation( Apply the ``message`` to the VM and use the given ``transaction`` to retrieve the context from. """ - ... @abstractmethod @@ -3398,7 +3395,6 @@ def transaction_applied_hook( This only gets triggered as part of `apply_all_transactions`, which is called by `block_import`. """ - pass # # Execution diff --git a/eth/chains/base.py b/eth/chains/base.py index 04c778c7e..da584a9e9 100644 --- a/eth/chains/base.py +++ b/eth/chains/base.py @@ -6,6 +6,7 @@ Callable, Dict, Iterable, + Optional, Sequence, Tuple, Type, @@ -714,8 +715,8 @@ def mine_all( self, transactions: Sequence[SignedTransactionAPI], *args: Any, - parent_header: BlockHeaderAPI = None, - withdrawals: Sequence[WithdrawalAPI] = None, + parent_header: Optional[BlockHeaderAPI] = None, + withdrawals: Optional[Sequence[WithdrawalAPI]] = None, **kwargs: Any, ) -> Tuple[BlockImportResult, Tuple[ReceiptAPI, ...], Tuple[ComputationAPI, ...]]: if parent_header is None: diff --git a/eth/chains/tester/__init__.py b/eth/chains/tester/__init__.py index 8c99519d2..c678f8b2e 100644 --- a/eth/chains/tester/__init__.py +++ b/eth/chains/tester/__init__.py @@ -3,6 +3,7 @@ from typing import ( Any, Generator, + Optional, Sequence, Tuple, Type, @@ -58,7 +59,8 @@ def create_header_from_parent( @to_tuple def _generate_vm_configuration( - *fork_start_blocks: ForkStartBlocks, dao_start_block: Union[int, bool] = None + *fork_start_blocks: ForkStartBlocks, + dao_start_block: Optional[Union[int, bool]] = None, ) -> Generator[VMStartBlock, None, None]: """ fork_start_blocks should be 2-tuples of (start_block, fork_name_or_vm_class) @@ -157,7 +159,7 @@ def validate_seal(self, header: BlockHeaderAPI) -> None: def configure_forks( self, *fork_start_blocks: ForkStartBlocks, - dao_start_block: Union[int, bool] = None, + dao_start_block: Optional[Union[int, bool]] = None, ) -> None: """ On demand configuration of fork rules. This is a foot gun that if used diff --git a/eth/consensus/__init__.py b/eth/consensus/__init__.py index d24349836..bce411b28 100644 --- a/eth/consensus/__init__.py +++ b/eth/consensus/__init__.py @@ -1,9 +1,9 @@ -from .applier import ConsensusApplier # noqa: F401 -from .clique.clique import ( # noqa: F401 +from .applier import ConsensusApplier +from .clique.clique import ( CliqueApplier, CliqueConsensus, CliqueConsensusContext, ) -from .context import ConsensusContext # noqa: F401 -from .noproof import NoProofConsensus # noqa: F401 -from .pow import PowConsensus # noqa: F401 +from .context import ConsensusContext +from .noproof import NoProofConsensus +from .pow import PowConsensus diff --git a/eth/consensus/clique/__init__.py b/eth/consensus/clique/__init__.py index a73f6a931..84b33f7ea 100644 --- a/eth/consensus/clique/__init__.py +++ b/eth/consensus/clique/__init__.py @@ -1,13 +1,13 @@ -from .clique import ( # noqa: F401 +from .clique import ( CliqueApplier, CliqueConsensus, CliqueConsensusContext, ) -from .constants import ( # noqa: F401 +from .constants import ( NONCE_AUTH, NONCE_DROP, ) -from .datatypes import ( # noqa: F401 +from .datatypes import ( Snapshot, Tally, Vote, diff --git a/eth/consensus/clique/_utils.py b/eth/consensus/clique/_utils.py index 252d55428..0947784d4 100644 --- a/eth/consensus/clique/_utils.py +++ b/eth/consensus/clique/_utils.py @@ -48,7 +48,6 @@ def get_signers_at_checkpoint(header: BlockHeaderAPI) -> Iterable[Address]: """ Read the list of signers from a checkpoint header. """ - signers_length = len(header.extra_data) - VANITY_LENGTH - SIGNATURE_LENGTH if signers_length % COMMON_ADDRESS_LENGTH != 0: @@ -73,7 +72,6 @@ def get_signature_hash(header: BlockHeaderAPI) -> Hash32: the ``header`` except that the last 65 bytes of the ``extra_data`` (the signature) are removed before calculating the hash. """ - if len(header.extra_data) < SIGNATURE_LENGTH: raise ValueError("header.extra_data too short to contain signature") @@ -87,7 +85,6 @@ def get_block_signer(header: BlockHeaderAPI) -> Address: """ Return the address of the signer of the ``header``. """ - signature_hash = get_signature_hash(header) signature_bytes = header.extra_data[-SIGNATURE_LENGTH:] diff --git a/eth/consensus/clique/clique.py b/eth/consensus/clique/clique.py index 0d1666e73..a59a7cab2 100644 --- a/eth/consensus/clique/clique.py +++ b/eth/consensus/clique/clique.py @@ -126,7 +126,6 @@ def validate_seal_extension( Validate the seal of the given ``header`` according to the Clique consensus rules. """ - if header.block_number == 0: return diff --git a/eth/consensus/clique/snapshot_manager.py b/eth/consensus/clique/snapshot_manager.py index 0de96e43a..5480f541c 100644 --- a/eth/consensus/clique/snapshot_manager.py +++ b/eth/consensus/clique/snapshot_manager.py @@ -48,7 +48,7 @@ def make_snapshot_lookup_key(block_hash: Hash32) -> bytes: - return b"block-hash-to-snapshot:%s" % block_hash + return f"block-hash-to-snapshot:{block_hash}".encode() class SnapshotManager: @@ -77,13 +77,13 @@ def _lookup_header( try: return self._chain_db.get_block_header_by_hash(block_hash) except HeaderNotFound: - raise ValidationError("Unknown ancestor %s", encode_hex(block_hash)) + raise ValidationError(f"Unknown ancestor {encode_hex(block_hash)}") def _create_snapshot_from_checkpoint_header( self, header: BlockHeaderAPI ) -> Snapshot: signers = get_signers_at_checkpoint(header) - self.logger.debug2("Created snapshot from checkpoint at %s", header) + self.logger.debug2(f"Created snapshot from checkpoint at {header}") snapshot = MutableSnapshot( signers=list(signers), block_hash=header.hash, votes=[], tallies={} @@ -94,7 +94,6 @@ def apply(self, current_snapshot: Snapshot, header: BlockHeaderAPI) -> Snapshot: """ Apply the given header on top of the current snapshot to create a new snapshot. """ - if is_checkpoint(header.block_number, self._epoch_length): return self._create_snapshot_from_checkpoint_header(header) @@ -124,11 +123,11 @@ def apply(self, current_snapshot: Snapshot, header: BlockHeaderAPI) -> Snapshot: if tally.votes > len(snapshot.signers) / 2: if tally.action is VoteAction.NOMINATE: snapshot.signers.append(header.coinbase) - self.logger.debug("New signer added: %s", header.coinbase) + self.logger.debug(f"New signer added: {header.coinbase}") else: if header.coinbase in snapshot.signers: snapshot.signers.remove(header.coinbase) - self.logger.debug("Signer removed: %s", header.coinbase) + self.logger.debug(f"Signer removed: {header.coinbase}") for vote in snapshot.votes.copy(): # Discard any pending votes *from* the added or removed member @@ -209,7 +208,7 @@ def create_snapshot_for( if is_checkpoint(header.block_number, self._epoch_length): self.logger.debug2( - "Persisting checkpoint snapshot at %s", header.block_number + f"Persisting checkpoint snapshot at {header.block_number}", ) self.persist_snapshot(new_snapshot) @@ -221,7 +220,6 @@ def get_snapshot(self, block_number: int, block_hash: Hash32) -> Snapshot: directly from a header that serves as a checkpoint. Otherwise raise a ``SnapshotNotFound`` error. """ - # We first try to find the snapshot in memory if block_hash in self._snapshots: return self._snapshots[block_hash] diff --git a/eth/db/account.py b/eth/db/account.py index 36124e9ed..bd9d8fc97 100644 --- a/eth/db/account.py +++ b/eth/db/account.py @@ -462,9 +462,8 @@ def make_state_root(self) -> Hash32: for address, storage_root in self._get_changed_roots(): if self.account_exists(address) or storage_root != BLANK_ROOT_HASH: self.logger.debug2( - "Updating account 0x%s to storage root 0x%s", - address.hex(), - storage_root.hex(), + f"Updating account 0x{address.hex()} to storage root " + f"0x{storage_root.hex()}", ) self._set_storage_root(address, storage_root) @@ -520,7 +519,7 @@ def persist(self) -> MetaWitnessAPI: # persist accounts self._validate_generated_root() new_root_hash = self.state_root - self.logger.debug2("Persisting new state root: 0x%s", new_root_hash.hex()) + self.logger.debug2(f"Persisting new state root: 0x{new_root_hash.hex()}") with self._raw_store_db.atomic_batch() as write_batch: self._batchtrie.commit_to(write_batch, apply_deletes=False) self._batchdb.commit_to(write_batch, apply_deletes=False) @@ -579,12 +578,11 @@ def _log_pending_accounts(self) -> None: for address in sorted(diff.pending_keys()): account = self._get_account(Address(address)) self.logger.debug2( - "Pending Account %s: balance %d, nonce %d, storage root %s, code hash %s", # noqa: E501 - to_checksum_address(address), - account.balance, - account.nonce, - encode_hex(account.storage_root), - encode_hex(account.code_hash), + f"Pending Account {to_checksum_address(address)}: " + f"balance {account.balance}, " + f"nonce {account.nonce}, " + f"storage root {encode_hex(account.storage_root)}, " + f"code hash {encode_hex(account.code_hash)}" ) for deleted_address in sorted(diff.deleted_keys()): # Check if the account was accessed before accessing/logging @@ -592,10 +590,9 @@ def _log_pending_accounts(self) -> None: was_account_accessed = deleted_address in self._accessed_accounts cast_deleted_address = Address(deleted_address) self.logger.debug2( - "Deleted Account %s, empty? %s, exists? %s", - to_checksum_address(deleted_address), - self.account_is_empty(cast_deleted_address), - self.account_exists(cast_deleted_address), + f"Deleted Account {to_checksum_address(deleted_address)}, " + f"empty? {self.account_is_empty(cast_deleted_address)}, " + f"exists? {self.account_exists(cast_deleted_address)}" ) # If the account was not accessed previous to the log, # (re)mark it as not accessed @@ -619,9 +616,8 @@ def _apply_account_diff_without_proof( del trie[delete_key] except trie_exceptions.MissingTrieNode as exc: self.logger.debug( - "Missing node while deleting account with key %s: %s", - encode_hex(delete_key), - exc, + "Missing node while deleting account with key " + f"{encode_hex(delete_key)}: {exc}" ) raise MissingAccountTrieNode( exc.missing_node_hash, @@ -649,10 +645,8 @@ def _apply_account_diff_without_proof( trie[key] = val except trie_exceptions.MissingTrieNode as exc: self.logger.debug( - "Missing node on account update key %s to %s: %s", - encode_hex(key), - encode_hex(val), - exc, + f"Missing node on account update key {encode_hex(key)} to " + f"{encode_hex(val)}: {exc}" ) raise MissingAccountTrieNode( exc.missing_node_hash, diff --git a/eth/db/atomic.py b/eth/db/atomic.py index 66fe44461..eeb317e12 100644 --- a/eth/db/atomic.py +++ b/eth/db/atomic.py @@ -138,8 +138,8 @@ def _commit_unless_raises( yield readable_write_batch except Exception: cls.logger.exception( - "Unexpected error in atomic db write, dropped partial writes: %r", - readable_write_batch._diff(), + "Unexpected error in atomic db write, dropped partial writes: " + f"{repr(readable_write_batch._diff())}" ) raise else: diff --git a/eth/db/backends/base.py b/eth/db/backends/base.py index 7828a7849..390b75a77 100644 --- a/eth/db/backends/base.py +++ b/eth/db/backends/base.py @@ -77,5 +77,3 @@ class BaseAtomicDB(BaseDB, AtomicDatabaseAPI): # when exiting the context, the values are saved either key and key2 will # both be saved, or neither will """ - - pass diff --git a/eth/db/chain.py b/eth/db/chain.py index 4eacb91cf..d86b61bea 100644 --- a/eth/db/chain.py +++ b/eth/db/chain.py @@ -297,9 +297,8 @@ def _persist_block( uncles_hash = EMPTY_UNCLE_HASH if uncles_hash != block.header.uncles_hash: raise ValidationError( - "Block's uncles_hash (%s) does not match actual uncles' hash (%s)", - block.header.uncles_hash, - uncles_hash, + f"Block's uncles_hash ({block.header.uncles_hash}) does not match " + f"actual uncles' hash ({uncles_hash})" ) new_canonical_hashes = tuple(header.hash for header in new_canonical_headers) old_canonical_hashes = tuple(header.hash for header in old_canonical_headers) diff --git a/eth/db/chain_gaps.py b/eth/db/chain_gaps.py index afa47142c..db1b515f4 100644 --- a/eth/db/chain_gaps.py +++ b/eth/db/chain_gaps.py @@ -109,7 +109,6 @@ def fill_gap(newly_persisted: BlockNumber, base_gaps: ChainGaps) -> GapInfo: """ Remove a gap, for a new header that was canonicalized. """ - current_gaps, tip_child = base_gaps if newly_persisted == tip_child: diff --git a/eth/db/header.py b/eth/db/header.py index a7a08f55a..fcc22d3ab 100644 --- a/eth/db/header.py +++ b/eth/db/header.py @@ -348,7 +348,6 @@ def _decanonicalize_single( So de-canonicalize this block number and insert a gap in the tracked chain gaps. """ - db.delete(SchemaV1.make_block_number_to_hash_lookup_key(block_num)) new_gaps = reopen_gap(block_num, base_gaps) diff --git a/eth/db/schema.py b/eth/db/schema.py index 5604582a7..78c550597 100644 --- a/eth/db/schema.py +++ b/eth/db/schema.py @@ -15,12 +15,12 @@ def make_canonical_head_hash_lookup_key() -> bytes: @staticmethod def make_block_number_to_hash_lookup_key(block_number: BlockNumber) -> bytes: - number_to_hash_key = b"block-number-to-hash:%d" % block_number + number_to_hash_key = f"block-number-to-hash:{block_number}".encode() return number_to_hash_key @staticmethod def make_block_hash_to_score_lookup_key(block_hash: Hash32) -> bytes: - return b"block-hash-to-score:%s" % block_hash + return f"block-hash-to-score:{block_hash}".encode() @staticmethod def make_header_chain_gaps_lookup_key() -> bytes: @@ -39,8 +39,8 @@ def make_checkpoint_headers_key() -> bytes: @staticmethod def make_transaction_hash_to_block_lookup_key(transaction_hash: Hash32) -> bytes: - return b"transaction-hash-to-block:%s" % transaction_hash + return f"transaction-hash-to-block:{transaction_hash}".encode() @staticmethod def make_withdrawal_hash_to_block_lookup_key(withdrawal_hash: Hash32) -> bytes: - return b"withdrawal-hash-to-block:%s" % withdrawal_hash + return f"withdrawal-hash-to-block:{withdrawal_hash}".encode() diff --git a/eth/db/slow_journal.py b/eth/db/slow_journal.py index f115990ce..2ca637bdf 100644 --- a/eth/db/slow_journal.py +++ b/eth/db/slow_journal.py @@ -184,7 +184,7 @@ def has_clear(self, check_changeset_id: uuid.UUID) -> bool: elif check_changeset_id == changeset_id: return False raise ValidationError( - "Changeset ID %s is not in the journal" % check_changeset_id + f"Changeset ID {check_changeset_id} is not in the journal" ) def commit_changeset( diff --git a/eth/db/storage.py b/eth/db/storage.py index 018532c12..31b982d08 100644 --- a/eth/db/storage.py +++ b/eth/db/storage.py @@ -238,7 +238,6 @@ def rollback_trie(self, trie_index: int) -> None: :param trie_index: index for reviving the previous trie """ - if trie_index >= len(self._historical_write_tries): raise ValidationError( f"Trying to roll back a delete to index {trie_index}, but there are " @@ -345,8 +344,7 @@ def set(self, slot: int, value: int) -> None: def delete(self) -> None: self.logger.debug2( - "Deleting all storage in account 0x%s", - self._address.hex(), + f"Deleting all storage in account 0x{self._address.hex()}", ) self._journal_storage.clear() self._storage_cache.reset_cache() @@ -374,7 +372,7 @@ def record(self, checkpoint: JournalDBCheckpoint) -> None: self._clear_count.record(checkpoint) def discard(self, checkpoint: JournalDBCheckpoint) -> None: - self.logger.debug2("discard checkpoint %r", checkpoint) + self.logger.debug2(f"discard checkpoint {repr(checkpoint)}") latest_clear_count = to_int(self._clear_count[CLEAR_COUNT_KEY_NAME]) if self._journal_storage.has_checkpoint(checkpoint): diff --git a/eth/exceptions.py b/eth/exceptions.py index 3c0457833..b15a4ef5d 100644 --- a/eth/exceptions.py +++ b/eth/exceptions.py @@ -8,16 +8,12 @@ class PyEVMError(Exception): Base class for all py-evm errors. """ - pass - class VMNotFound(PyEVMError): """ Raised when no VM is available for the provided block number. """ - pass - class StateRootNotFound(PyEVMError): """ @@ -42,16 +38,12 @@ class BlockNotFound(PyEVMError): saved in the database. """ - pass - class TransactionNotFound(PyEVMError): """ Raised when the transaction with the given hash or block index does not exist. """ - pass - class UnrecognizedTransactionType(PyEVMError): """ @@ -71,24 +63,18 @@ class ReceiptNotFound(PyEVMError): Raised when the Receipt with the given receipt index does not exist. """ - pass - class ParentNotFound(HeaderNotFound): """ Raised when the parent of a given block does not exist. """ - pass - class CanonicalHeadNotFound(PyEVMError): """ Raised when the chain has no canonical head. """ - pass - class GapTrackingCorrupted(PyEVMError): """ @@ -96,24 +82,18 @@ class GapTrackingCorrupted(PyEVMError): (e.g. overlapping gaps) """ - pass - class CheckpointsMustBeCanonical(PyEVMError): """ Raised when a persisted header attempts to de-canonicalize a checkpoint """ - pass - class Halt(PyEVMError): """ Raised when an opcode function halts vm execution. """ - pass - class VMError(PyEVMError): """ @@ -129,40 +109,30 @@ class OutOfGas(VMError): Raised when a VM execution has run out of gas. """ - pass - class InsufficientStack(VMError): """ Raised when the stack is empty. """ - pass - class FullStack(VMError): """ Raised when the stack is full. """ - pass - class InvalidJumpDestination(VMError): """ Raised when the jump destination for a JUMPDEST operation is invalid. """ - pass - class InvalidInstruction(VMError): """ Raised when an opcode is invalid. """ - pass - class InsufficientFunds(VMError): """ @@ -170,24 +140,18 @@ class InsufficientFunds(VMError): requested value. """ - pass - class StackDepthLimit(VMError): """ Raised when the call stack has exceeded it's maximum allowed depth. """ - pass - class ContractCreationCollision(VMError): """ Raised when there was an address collision during contract creation. """ - pass - class IncorrectContractCreationAddress(VMError): """ @@ -195,8 +159,6 @@ class IncorrectContractCreationAddress(VMError): match the calculated contract creation address. """ - pass - class Revert(VMError): """ @@ -213,8 +175,6 @@ class WriteProtection(VMError): operating inside of a STATICCALL context. """ - pass - class OutOfBoundsRead(VMError): """ @@ -222,13 +182,9 @@ class OutOfBoundsRead(VMError): boundaries of the buffer (such as with RETURNDATACOPY) """ - pass - class ReservedBytesInCode(VMError): """ Raised when bytes for the code to be deployed are reserved for a particular reason. """ - - pass diff --git a/eth/precompiles/__init__.py b/eth/precompiles/__init__.py index e18c7e95f..e153a2ee9 100644 --- a/eth/precompiles/__init__.py +++ b/eth/precompiles/__init__.py @@ -1,9 +1,9 @@ -from .sha256 import sha256 # noqa: F401 -from .identity import identity # noqa: F401 -from .ecrecover import ecrecover # noqa: F401 -from .ripemd160 import ripemd160 # noqa: F401 -from .modexp import modexp # noqa: F401 -from .ecadd import ecadd # noqa: F401 -from .ecmul import ecmul # noqa: F401 -from .ecpairing import ecpairing # noqa: F401 -from .blake2 import blake2b_fcompress # noqa: F401 +from .sha256 import sha256 +from .identity import identity +from .ecrecover import ecrecover +from .ripemd160 import ripemd160 +from .modexp import modexp +from .ecadd import ecadd +from .ecmul import ecmul +from .ecpairing import ecpairing +from .blake2 import blake2b_fcompress diff --git a/eth/tools/_utils/mappings.py b/eth/tools/_utils/mappings.py index 4f06dbc7c..1667e4e67 100644 --- a/eth/tools/_utils/mappings.py +++ b/eth/tools/_utils/mappings.py @@ -29,7 +29,8 @@ def is_cleanly_mergable(*dicts: Dict[Any, Any]) -> bool: Check that nothing will be overwritten when dictionaries are merged using `deep_merge`. - Examples: + Examples + -------- >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"c": 3}) True diff --git a/eth/tools/_utils/normalization.py b/eth/tools/_utils/normalization.py index 994f2726a..416a1775f 100644 --- a/eth/tools/_utils/normalization.py +++ b/eth/tools/_utils/normalization.py @@ -10,6 +10,7 @@ Mapping, Sequence, Tuple, + TypedDict, Union, cast, ) @@ -45,9 +46,6 @@ identity, merge, ) -from mypy_extensions import ( - TypedDict, -) from eth.constants import ( CREATE_CONTRACT_ADDRESS, @@ -183,7 +181,8 @@ def normalize(d: Dict[Any, Any]) -> Dict[str, Any]: # Composition # def state_definition_to_dict(state_definition: GeneralState) -> AccountState: - """Convert a state definition to the canonical dict form. + """ + Convert a state definition to the canonical dict form. State can either be defined in the canonical form, or as a list of sub states that are then merged to one. Sub states can either be given as dictionaries themselves, @@ -382,15 +381,13 @@ def normalize_unsigned_transaction( ) -FixtureAccountDetails = TypedDict( - "FixtureAccountDetails", - { - "balance": HexStr, - "nonce": HexStr, - "code": HexStr, - "storage": Dict[HexStr, HexStr], - }, -) +class FixtureAccountDetails(TypedDict): + balance: HexStr + nonce: HexStr + code: HexStr + storage: Dict[HexStr, HexStr] + + FixtureAccountState = Dict[Address, FixtureAccountDetails] diff --git a/eth/tools/builder/chain/__init__.py b/eth/tools/builder/chain/__init__.py index 765746a11..a586f7b0f 100644 --- a/eth/tools/builder/chain/__init__.py +++ b/eth/tools/builder/chain/__init__.py @@ -1,4 +1,4 @@ -from .builders import ( # noqa: F401 +from .builders import ( at_block_number, build, chain_id, @@ -16,7 +16,7 @@ mine_blocks, name, ) -from .builders import ( # noqa: F401 +from .builders import ( byzantium_at, frontier_at, homestead_at, diff --git a/eth/tools/builder/chain/builders.py b/eth/tools/builder/chain/builders.py index 752c291e9..e686d49b2 100644 --- a/eth/tools/builder/chain/builders.py +++ b/eth/tools/builder/chain/builders.py @@ -5,6 +5,7 @@ Callable, Dict, Iterable, + Optional, Tuple, Type, Union, @@ -361,9 +362,9 @@ def _fill_and_normalize_state(simple_state: GeneralState) -> AccountState: @curry def genesis( chain_class: ChainAPI, - db: AtomicDatabaseAPI = None, - params: Dict[str, HeaderParams] = None, - state: GeneralState = None, + db: Optional[AtomicDatabaseAPI] = None, + params: Optional[Dict[str, HeaderParams]] = None, + state: Optional[GeneralState] = None, ) -> ChainAPI: """ Initialize the given chain class with the given genesis header parameters @@ -397,9 +398,7 @@ def mine_block(chain: MiningChainAPI, **kwargs: Any) -> MiningChainAPI: """ Mine a new block on the chain. Header parameters for the new block can be overridden using keyword arguments. - """ - if not isinstance(chain, MiningChainAPI): raise ValidationError("`mine_block` may only be used on MiningChain instances") diff --git a/eth/tools/db/atomic.py b/eth/tools/db/atomic.py index e1ef3ab1a..87db68992 100644 --- a/eth/tools/db/atomic.py +++ b/eth/tools/db/atomic.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.abc import ( AtomicDatabaseAPI, diff --git a/eth/tools/fixtures/__init__.py b/eth/tools/fixtures/__init__.py index 89fb58837..1c3a6f715 100644 --- a/eth/tools/fixtures/__init__.py +++ b/eth/tools/fixtures/__init__.py @@ -1,12 +1,12 @@ -from .loading import ( # noqa: F401 +from .loading import ( find_fixtures, filter_fixtures, load_fixture, ) -from .generation import ( # noqa: F401 +from .generation import ( generate_fixture_tests, ) -from .helpers import ( # noqa: F401 +from .helpers import ( new_chain_from_fixture, genesis_fields_from_fixture, genesis_params_from_fixture, @@ -15,7 +15,7 @@ should_run_slow_tests, verify_state, ) -from eth.tools._utils.normalization import ( # noqa: F401 +from eth.tools._utils.normalization import ( normalize_block, normalize_blockchain_fixtures, normalize_statetest_fixture, diff --git a/eth/tools/fixtures/fillers/__init__.py b/eth/tools/fixtures/fillers/__init__.py index 616c10951..4b5db4489 100644 --- a/eth/tools/fixtures/fillers/__init__.py +++ b/eth/tools/fixtures/fillers/__init__.py @@ -1,16 +1,16 @@ -from .vm import ( # noqa: F401 +from .vm import ( fill_vm_test, ) -from .state import ( # noqa: F401 +from .state import ( fill_state_test, ) -from .common import ( # noqa: F401 +from .common import ( execution, expect, pre_state, setup_filler, setup_main_filler, ) -from .main import ( # noqa: F401 +from .main import ( fill_test, ) diff --git a/eth/tools/fixtures/fillers/common.py b/eth/tools/fixtures/fillers/common.py index b80a7076e..26fe674d9 100644 --- a/eth/tools/fixtures/fillers/common.py +++ b/eth/tools/fixtures/fillers/common.py @@ -9,6 +9,7 @@ Any, Callable, Dict, + Optional, ) from eth_utils import ( @@ -106,7 +107,7 @@ def get_default_transaction(networks: Any) -> TransactionDict: def setup_filler( - name: str, environment: Dict[Any, Any] = None + name: str, environment: Optional[Dict[Any, Any]] = None ) -> Dict[str, Dict[str, Any]]: environment = normalize_environment(environment or {}) return { @@ -118,7 +119,7 @@ def setup_filler( def setup_main_filler( - name: str, environment: Dict[Any, Any] = None + name: str, environment: Optional[Dict[Any, Any]] = None ) -> Dict[str, Dict[str, Any]]: """ Kick off the filler generation process by creating the general filler scaffold with @@ -265,9 +266,9 @@ def _expect( def expect( - post_state: Dict[str, Any] = None, - networks: Any = None, - transaction: TransactionDict = None, + post_state: Optional[Dict[str, Any]] = None, + networks: Optional[Any] = None, + transaction: Optional[TransactionDict] = None, ) -> Callable[..., Dict[str, Any]]: """ Specify the expected result for the test. diff --git a/eth/tools/fixtures/fillers/main.py b/eth/tools/fixtures/fillers/main.py index dee2c5113..648a6c0e1 100644 --- a/eth/tools/fixtures/fillers/main.py +++ b/eth/tools/fixtures/fillers/main.py @@ -1,6 +1,7 @@ from typing import ( Any, Dict, + Optional, ) from eth_utils.toolz import ( @@ -26,17 +27,15 @@ fill_vm_test, ) -FILLED_WITH_TEMPLATE = "py-evm-{version}" - # # Primary test filler # def fill_test( filler: Dict[str, Any], - info: Dict[str, Any] = None, + info: Optional[Dict[str, Any]] = None, apply_formatter: bool = True, - **kwargs: Any + **kwargs: Any, ) -> Dict[str, Any]: test_name = get_test_name(filler) test = filler[test_name] @@ -51,7 +50,7 @@ def fill_test( raise ValueError("Given filler does not appear to be for VM or state test") info = merge( - {"filledwith": FILLED_WITH_TEMPLATE.format(version=get_version_from_git())}, + {"filledwith": f"py-evm-{get_version_from_git()}"}, info if info else {}, ) filled = assoc_in(filled, [test_name, "_info"], info) diff --git a/eth/tools/fixtures/fillers/vm.py b/eth/tools/fixtures/fillers/vm.py index 49be9d0dd..7efe1a81a 100644 --- a/eth/tools/fixtures/fillers/vm.py +++ b/eth/tools/fixtures/fillers/vm.py @@ -2,6 +2,7 @@ Any, Dict, Iterable, + Optional, Tuple, Union, ) @@ -29,10 +30,10 @@ def fill_vm_test( filler: Dict[str, Any], *, - call_creates: Any = None, - gas_price: Union[int, str] = None, + call_creates: Optional[Any] = None, + gas_price: Optional[Union[int, str]] = None, gas_remaining: Union[int, str] = 0, - logs: Iterable[Tuple[bytes, Tuple[int, ...], bytes]] = None, + logs: Optional[Iterable[Tuple[bytes, Tuple[int, ...], bytes]]] = None, output: bytes = b"" ) -> Dict[str, Dict[str, Any]]: test_name = get_test_name(filler) diff --git a/eth/tools/fixtures/helpers.py b/eth/tools/fixtures/helpers.py index aac7c0877..7d644bdb2 100644 --- a/eth/tools/fixtures/helpers.py +++ b/eth/tools/fixtures/helpers.py @@ -187,7 +187,6 @@ def genesis_fields_from_fixture(fixture: Dict[str, Any]) -> Dict[str, Any]: """ Convert all genesis fields in a fixture to a dictionary of header fields and values. """ - header_fields = fixture["genesisBlockHeader"] base_fields = { "parent_hash": header_fields["parentHash"], @@ -219,7 +218,6 @@ def genesis_params_from_fixture(fixture: Dict[str, Any]) -> Dict[str, Any]: Some fields cannot be explicitly set when creating a new header, like parent_hash, which is automatically set to the empty hash. """ - params = genesis_fields_from_fixture(fixture) # Confirm that (currently) non-configurable defaults are set correctly, diff --git a/eth/typing.py b/eth/typing.py index 40004d0be..fd4bea120 100644 --- a/eth/typing.py +++ b/eth/typing.py @@ -11,6 +11,7 @@ Sequence, Tuple, Type, + TypedDict, TypeVar, Union, ) @@ -21,9 +22,6 @@ Hash32, HexStr, ) -from mypy_extensions import ( - TypedDict, -) if TYPE_CHECKING: from eth.abc import ( # noqa: F401 @@ -36,10 +34,14 @@ JournalDBCheckpoint = NewType("JournalDBCheckpoint", int) -AccountDetails = TypedDict( - "AccountDetails", - {"balance": int, "nonce": int, "code": bytes, "storage": Dict[int, int]}, -) + +class AccountDetails(TypedDict): + balance: int + nonce: int + code: bytes + storage: Dict[int, int] + + AccountState = Dict[Address, AccountDetails] AccountDiff = Iterable[Tuple[Address, str, Union[int, bytes], Union[int, bytes]]] @@ -70,28 +72,23 @@ class Block(TypedDict, total=False): Normalizer = Callable[[Dict[Any, Any]], Dict[str, Any]] -RawAccountDetails = TypedDict( - "RawAccountDetails", - { - "balance": HexStr, - "nonce": HexStr, - "code": HexStr, - "storage": Dict[HexStr, HexStr], - }, -) -TransactionDict = TypedDict( - "TransactionDict", - { - "nonce": int, - "gasLimit": int, - "gasPrice": int, - "to": Address, - "value": int, - "data": bytes, - "secretKey": bytes, - }, -) +class RawAccountDetails(TypedDict): + balance: HexStr + nonce: HexStr + code: HexStr + storage: Dict[HexStr, HexStr] + + +class TransactionDict(TypedDict): + nonce: int + gasLimit: int + gasPrice: int + to: Address + value: int + data: bytes + secretKey: bytes + TransactionNormalizer = Callable[[TransactionDict], TransactionDict] diff --git a/eth/vm/base.py b/eth/vm/base.py index 9906c0852..ce4097ec6 100644 --- a/eth/vm/base.py +++ b/eth/vm/base.py @@ -460,17 +460,13 @@ def _assign_block_rewards(self, block: BlockAPI) -> None: # computation and thus should be marked for deletion since it was touched. self.state.delta_balance(block.header.coinbase, block_reward) self.logger.debug( - "BLOCK REWARD: %s -> %s", - block_reward, - encode_hex(block.header.coinbase), + f"BLOCK REWARD: {block_reward} -> {encode_hex(block.header.coinbase)}" ) for uncle in block.uncles: uncle_reward = self.get_uncle_reward(block.number, uncle) self.logger.debug( - "UNCLE REWARD REWARD: %s -> %s", - uncle_reward, - encode_hex(uncle.coinbase), + f"UNCLE REWARD REWARD: {uncle_reward} -> {encode_hex(uncle.coinbase)}" ) self.state.delta_balance(uncle.coinbase, uncle_reward) @@ -494,12 +490,10 @@ def finalize_block(self, block: BlockAPI) -> BlockAndMetaWitness: ) self.logger.debug( - "%s reads %d unique node hashes, %d addresses, %d bytecodes, and %d storage slots", # noqa: E501 - final_block, - len(meta_witness.hashes), - len(meta_witness.accounts_queried), - len(meta_witness.account_bytecodes_queried), - meta_witness.total_slots_queried, + f"{final_block} reads {len(meta_witness.hashes)} unique node hashes, " + f"{len(meta_witness.accounts_queried)} addresses, " + f"{len(meta_witness.account_bytecodes_queried)} bytecodes, and " + f"{meta_witness.total_slots_queried} storage slots" ) return BlockAndMetaWitness(final_block, meta_witness) @@ -724,9 +718,8 @@ def validate_seal(self, header: BlockHeaderAPI) -> None: self._consensus.validate_seal(header) except ValidationError as exc: self.cls_logger.debug( - "Failed to validate seal on header: %r. Error: %s", - header.as_dict(), - exc, + f"Failed to validate seal on header: {repr(header.as_dict())}. " + f"Error: {exc}" ) raise diff --git a/eth/vm/computation.py b/eth/vm/computation.py index c97dedb53..e6b76a487 100644 --- a/eth/vm/computation.py +++ b/eth/vm/computation.py @@ -351,11 +351,9 @@ def apply_computation( # We dig into some internals for debug logs base_comp = cast(BaseComputation, computation) computation.logger.debug2( - "OPCODE: 0x%x (%s) | pc: %s | stack: %s", - opcode, - opcode_fn.mnemonic, - max(0, computation.code.program_counter - 1), - base_comp._stack, + f"OPCODE: 0x{opcode:x} ({opcode_fn.mnemonic}) | " + f"pc: {max(0, computation.code.program_counter - 1)} | " + f"stack: {base_comp._stack}" ) try: @@ -415,11 +413,8 @@ def extend_memory(self, start_position: int, size: int) -> None: if self.logger.show_debug2: self.logger.debug2( - "MEMORY: size (%s -> %s) | cost (%s -> %s)", - before_size, - after_size, - before_cost, - after_cost, + f"MEMORY: size ({before_size} -> {after_size}) | " + f"cost ({before_cost} -> {after_cost})" ) if size: @@ -482,7 +477,6 @@ def consume_initcode_gas_cost(cls, computation: ComputationAPI) -> None: """ Before starting the computation, consume initcode gas cost. """ - pass # -- stack management -- # def stack_swap(self, position: int) -> None: @@ -566,14 +560,13 @@ def __enter__(self) -> ComputationAPI: self.logger.debug2( ( "MESSAGE COMPUTATION STARTING: " - "from: %s | to: %s | value: %s | depth %s | static: %s | gas: %s" + f"from: {encode_hex(self.msg.sender)} | " + f"to: {encode_hex(self.msg.to)} | " + f"value: {self.msg.value} | " + f"depth: {self.msg.depth} | " + f"static: {'y' if self.msg.is_static else 'n'} | " + f"gas: {self.msg.gas}" ), - encode_hex(self.msg.sender), - encode_hex(self.msg.to), - self.msg.value, - self.msg.depth, - "y" if self.msg.is_static else "n", - self.msg.gas, ) return self @@ -588,16 +581,14 @@ def __exit__( self.logger.debug2( ( "COMPUTATION ERROR: " - "gas: %s | from: %s | to: %s | value: %s | " - "depth: %s | static: %s | error: %s" + f"gas: {self.msg.gas} | " + f"from: {encode_hex(self.msg.sender)} | " + f"to: {encode_hex(self.msg.to)} | " + f"value: {self.msg.value} | " + f"depth: {self.msg.depth} | " + f"static: {'y' if self.msg.is_static else 'n'} | " + f"error: {exc_value}" ), - self.msg.gas, - encode_hex(self.msg.sender), - encode_hex(self.msg.to), - self.msg.value, - self.msg.depth, - "y" if self.msg.is_static else "n", - exc_value, ) self._error = exc_value @@ -623,16 +614,14 @@ def __exit__( self.logger.debug2( ( "COMPUTATION SUCCESS: " - "from: %s | to: %s | value: %s | depth: %s | static: %s " - "| gas-used: %s | gas-remaining: %s" + f"from: {encode_hex(self.msg.sender)} | " + f"to: {encode_hex(self.msg.to)} | " + f"value: {self.msg.value} | " + f"depth: {self.msg.depth} | " + f"static: {'y' if self.msg.is_static else 'n'} | " + f"gas-used: {self.get_gas_used()} | " + f"gas-remaining: {self._gas_meter.gas_remaining}" ), - encode_hex(self.msg.sender), - encode_hex(self.msg.to), - self.msg.value, - self.msg.depth, - "y" if self.msg.is_static else "n", - self.get_gas_used(), - self._gas_meter.gas_remaining, ) return None diff --git a/eth/vm/forks/__init__.py b/eth/vm/forks/__init__.py index 672a9c10d..9e826d05d 100644 --- a/eth/vm/forks/__init__.py +++ b/eth/vm/forks/__init__.py @@ -1,45 +1,45 @@ -from .tangerine_whistle import ( # noqa: F401 +from .tangerine_whistle import ( TangerineWhistleVM, ) -from .frontier import ( # noqa: F401 +from .frontier import ( FrontierVM, ) -from .homestead import ( # noqa: F401 +from .homestead import ( HomesteadVM, ) -from .spurious_dragon import ( # noqa: F401 +from .spurious_dragon import ( SpuriousDragonVM, ) -from .byzantium import ( # noqa: F401 +from .byzantium import ( ByzantiumVM, ) -from .constantinople import ( # noqa: F401 +from .constantinople import ( ConstantinopleVM, ) -from .petersburg import ( # noqa: F401 +from .petersburg import ( PetersburgVM, ) -from .istanbul import ( # noqa: F401 +from .istanbul import ( IstanbulVM, ) -from .muir_glacier import ( # noqa: F401 +from .muir_glacier import ( MuirGlacierVM, ) -from .berlin import ( # noqa: F401 +from .berlin import ( BerlinVM, ) -from .london import ( # noqa: F401 +from .london import ( LondonVM, ) -from .arrow_glacier import ( # noqa: F401 +from .arrow_glacier import ( ArrowGlacierVM, ) -from .gray_glacier import ( # noqa: F401 +from .gray_glacier import ( GrayGlacierVM, ) -from .paris import ( # noqa: F401 +from .paris import ( ParisVM, ) -from .shanghai import ( # noqa: F401 +from .shanghai import ( ShanghaiVM, ) diff --git a/eth/vm/forks/arrow_glacier/computation.py b/eth/vm/forks/arrow_glacier/computation.py index 028186ef2..c2669010b 100644 --- a/eth/vm/forks/arrow_glacier/computation.py +++ b/eth/vm/forks/arrow_glacier/computation.py @@ -8,5 +8,3 @@ class ArrowGlacierComputation(LondonComputation): A class for all execution *message* computations in the ``ArrowGlacier`` fork. Inherits from :class:`~eth.vm.forks.london.LondonComputation` """ - - pass diff --git a/eth/vm/forks/berlin/logic.py b/eth/vm/forks/berlin/logic.py index 58c45ab1c..eebc0bd45 100644 --- a/eth/vm/forks/berlin/logic.py +++ b/eth/vm/forks/berlin/logic.py @@ -54,7 +54,6 @@ def _mark_address_warm(computation: ComputationAPI, address: Address) -> bool: :return was_cold: True if the account was not previously accessed during this transaction """ - if computation.state.is_address_warm(address): return False else: diff --git a/eth/vm/forks/byzantium/headers.py b/eth/vm/forks/byzantium/headers.py index 02742c787..e98750da7 100644 --- a/eth/vm/forks/byzantium/headers.py +++ b/eth/vm/forks/byzantium/headers.py @@ -1,6 +1,7 @@ from typing import ( Any, Callable, + Optional, ) from eth_utils.toolz import ( @@ -93,7 +94,7 @@ def create_header_from_parent( @curry def configure_header( vm: VirtualMachineAPI, - difficulty_fn: Callable[[BlockHeaderAPI, int], int] = None, + difficulty_fn: Optional[Callable[[BlockHeaderAPI, int], int]] = None, **header_params: Any, ) -> BlockHeaderAPI: validate_header_params_for_configuration(header_params) diff --git a/eth/vm/forks/frontier/computation.py b/eth/vm/forks/frontier/computation.py index 632248b74..1b4d5a33e 100644 --- a/eth/vm/forks/frontier/computation.py +++ b/eth/vm/forks/frontier/computation.py @@ -76,10 +76,8 @@ def apply_message( state.delta_balance(message.storage_address, message.value) cls.logger.debug2( - "TRANSFERRED: %s from %s -> %s", - message.value, - encode_hex(message.sender), - encode_hex(message.storage_address), + f"TRANSFERRED: {message.value} from {encode_hex(message.sender)} -> " + f"{encode_hex(message.storage_address)}" ) state.touch_account(message.storage_address) @@ -122,10 +120,9 @@ def apply_create_message( computation.output = b"" else: cls.logger.debug2( - "SETTING CODE: %s -> length: %s | hash: %s", - encode_hex(message.storage_address), - len(contract_code), - encode_hex(keccak(contract_code)), + f"SETTING CODE: {encode_hex(message.storage_address)} -> " + f"length: {len(contract_code)} | " + f"hash: {encode_hex(keccak(contract_code))}" ) state.set_code(message.storage_address, contract_code) return computation diff --git a/eth/vm/forks/frontier/state.py b/eth/vm/forks/frontier/state.py index f44055252..a27c1475c 100644 --- a/eth/vm/forks/frontier/state.py +++ b/eth/vm/forks/frontier/state.py @@ -90,19 +90,15 @@ def build_evm_message(self, transaction: SignedTransactionAPI) -> MessageAPI: code = self.vm_state.get_code(transaction.to) self.vm_state.logger.debug2( - ( - "TRANSACTION: sender: %s | to: %s | value: %s | gas: %s | " - "gas-price: %s | s: %s | r: %s | y_parity: %s | data-hash: %s" - ), - encode_hex(transaction.sender), - encode_hex(transaction.to), - transaction.value, - transaction.gas, - transaction.gas_price, - transaction.s, - transaction.r, - transaction.y_parity, - encode_hex(keccak(transaction.data)), + f"TRANSACTION: sender: {encode_hex(transaction.sender)} | " + f"to: {encode_hex(transaction.to)} | " + f"value: {transaction.value} | " + f"gas: {transaction.gas} | " + f"gas-price: {transaction.gas_price} | " + f"s: {transaction.s} | " + f"r: {transaction.r} | " + f"y_parity: {transaction.y_parity} | " + f"data-hash: {encode_hex(keccak(transaction.data))}" ) message = Message( @@ -134,8 +130,8 @@ def build_computation( f"{encode_hex(message.storage_address)}" ) self.vm_state.logger.debug2( - "Address collision while creating contract: %s", - encode_hex(message.storage_address), + "Address collision while creating contract: " + f"{encode_hex(message.storage_address)}" ) else: computation = self.vm_state.computation_class.apply_create_message( @@ -176,9 +172,8 @@ def finalize_computation( if gas_refund_amount: self.vm_state.logger.debug2( - "TRANSACTION REFUND: %s -> %s", - gas_refund_amount, - encode_hex(computation.msg.sender), + f"TRANSACTION REFUND: {gas_refund_amount} -> " + f"{encode_hex(computation.msg.sender)}" ) self.vm_state.delta_balance(computation.msg.sender, gas_refund_amount) @@ -192,15 +187,14 @@ def finalize_computation( # coinbase may end up zeroed after the computation and thus should be marked # for deletion since it was touched. self.vm_state.logger.debug2( - "TRANSACTION FEE: %s -> %s", - transaction_fee, - encode_hex(self.vm_state.coinbase), + f"TRANSACTION FEE: {transaction_fee} -> " + f"{encode_hex(self.vm_state.coinbase)}" ) self.vm_state.delta_balance(self.vm_state.coinbase, transaction_fee) # Process Self Destructs for account, _ in computation.get_accounts_for_deletion(): - self.vm_state.logger.debug2("DELETING ACCOUNT: %s", encode_hex(account)) + self.vm_state.logger.debug2(f"DELETING ACCOUNT: {encode_hex(account)}") self.vm_state.delete_account(account) return computation diff --git a/eth/vm/forks/gray_glacier/computation.py b/eth/vm/forks/gray_glacier/computation.py index e9d477ee3..bdb23273d 100644 --- a/eth/vm/forks/gray_glacier/computation.py +++ b/eth/vm/forks/gray_glacier/computation.py @@ -8,5 +8,3 @@ class GrayGlacierComputation(ArrowGlacierComputation): A class for all execution *message* computations in the ``GrayGlacier`` fork. Inherits from :class:`~eth.vm.forks.arrow_glacier.ArrowGlacierComputation` """ - - pass diff --git a/eth/vm/forks/homestead/computation.py b/eth/vm/forks/homestead/computation.py index a6db4c1b0..db2615b71 100644 --- a/eth/vm/forks/homestead/computation.py +++ b/eth/vm/forks/homestead/computation.py @@ -67,10 +67,9 @@ def apply_create_message( else: if cls.logger: cls.logger.debug2( - "SETTING CODE: %s -> length: %s | hash: %s", - encode_hex(message.storage_address), - len(contract_code), - encode_hex(keccak(contract_code)), + f"SETTING CODE: {encode_hex(message.storage_address)} -> " + f"length: {len(contract_code)} | " + f"hash: {encode_hex(keccak(contract_code))}" ) state.set_code(message.storage_address, contract_code) diff --git a/eth/vm/forks/london/receipts.py b/eth/vm/forks/london/receipts.py index 2a7d8ab7b..b555908dd 100644 --- a/eth/vm/forks/london/receipts.py +++ b/eth/vm/forks/london/receipts.py @@ -21,8 +21,9 @@ class LondonTypedReceipt(BerlinTypedReceipt): codecs: Dict[int, Type[Receipt]] = { - ACCESS_LIST_TRANSACTION_TYPE: Receipt, - DYNAMIC_FEE_TRANSACTION_TYPE: Receipt, + # mypy errors due to Receipt inheriting but not defining abstractmethods + ACCESS_LIST_TRANSACTION_TYPE: Receipt, # type: ignore + DYNAMIC_FEE_TRANSACTION_TYPE: Receipt, # type: ignore } diff --git a/eth/vm/forks/london/state.py b/eth/vm/forks/london/state.py index 5a82bb2e8..6f942eddc 100644 --- a/eth/vm/forks/london/state.py +++ b/eth/vm/forks/london/state.py @@ -75,11 +75,10 @@ def build_evm_message(self, transaction: SignedTransactionAPI) -> MessageAPI: code = self.vm_state.get_code(transaction.to) self.vm_state.logger.debug2( - ("TRANSACTION: %r; sender: %s | to: %s | data-hash: %s"), - transaction, - encode_hex(transaction.sender), - encode_hex(transaction.to), - encode_hex(keccak(transaction.data)), + f"TRANSACTION: {repr(transaction)}; " + f"sender: {encode_hex(transaction.sender)} | " + f"to: {encode_hex(transaction.to)} | " + f"data-hash: {encode_hex(keccak(transaction.data))}" ) message = Message( diff --git a/eth/vm/forks/spurious_dragon/computation.py b/eth/vm/forks/spurious_dragon/computation.py index 7433825e1..f9ed71554 100644 --- a/eth/vm/forks/spurious_dragon/computation.py +++ b/eth/vm/forks/spurious_dragon/computation.py @@ -82,10 +82,9 @@ def apply_create_message( else: if cls.logger: cls.logger.debug2( - "SETTING CODE: %s -> length: %s | hash: %s", - encode_hex(message.storage_address), - len(contract_code), - encode_hex(keccak(contract_code)), + f"SETTING CODE: {encode_hex(message.storage_address)} -> " + f"length: {len(contract_code)} | " + f"hash: {encode_hex(keccak(contract_code))}" ) state.set_code(message.storage_address, contract_code) @@ -100,7 +99,6 @@ def validate_create_message(cls, message: MessageAPI) -> None: """ Class method for validating a create message. """ - pass @classmethod def validate_contract_code(cls, contract_code: bytes) -> None: diff --git a/eth/vm/forks/spurious_dragon/state.py b/eth/vm/forks/spurious_dragon/state.py index 7832f2afc..1bfa2f6ad 100644 --- a/eth/vm/forks/spurious_dragon/state.py +++ b/eth/vm/forks/spurious_dragon/state.py @@ -41,8 +41,7 @@ def finalize_computation( ) and self.vm_state.account_is_empty(account) if should_delete: self.vm_state.logger.debug2( - "CLEARING EMPTY ACCOUNT: %s", - encode_hex(account), + f"CLEARING EMPTY ACCOUNT: {encode_hex(account)}" ) self.vm_state.delete_account(account) diff --git a/eth/vm/gas_meter.py b/eth/vm/gas_meter.py index 3a05f6d4d..7b04765e3 100644 --- a/eth/vm/gas_meter.py +++ b/eth/vm/gas_meter.py @@ -69,11 +69,8 @@ def consume_gas(self, amount: int, reason: str) -> None: if self.logger.show_debug2: self.logger.debug2( - "GAS CONSUMPTION: %s - %s -> %s (%s)", - self.gas_remaining + amount, - amount, - self.gas_remaining, - reason, + f"GAS CONSUMPTION: {self.gas_remaining + amount} - {amount} -> " + f"{self.gas_remaining} ({reason})" ) def return_gas(self, amount: int) -> None: @@ -84,10 +81,8 @@ def return_gas(self, amount: int) -> None: if self.logger.show_debug2: self.logger.debug2( - "GAS RETURNED: %s + %s -> %s", - self.gas_remaining - amount, - amount, - self.gas_remaining, + f"GAS RETURNED: {self.gas_remaining - amount} + {amount} -> " + f"{self.gas_remaining}" ) def refund_gas(self, amount: int) -> None: @@ -95,8 +90,6 @@ def refund_gas(self, amount: int) -> None: if self.logger.show_debug2: self.logger.debug2( - "GAS REFUND: %s + %s -> %s", - self.gas_refunded - amount, - amount, - self.gas_refunded, + f"GAS REFUND: {self.gas_refunded - amount} + {amount} -> " + f"{self.gas_refunded}" ) diff --git a/eth/vm/logic/call.py b/eth/vm/logic/call.py index 043c29151..0202119f3 100644 --- a/eth/vm/logic/call.py +++ b/eth/vm/logic/call.py @@ -102,10 +102,8 @@ def __call__(self, computation: ComputationAPI) -> None: ) if self.logger.show_debug2: self.logger.debug2( - "%s is charged %d for invoking code at account 0x%s", - self.mnemonic, - load_account_fee, - code_source.hex(), + f"{self.mnemonic} is charged {load_account_fee} for invoking " + f"code at account 0x{code_source.hex()}" ) # This must be computed *after* the load account fee is charged, so @@ -132,11 +130,7 @@ def __call__(self, computation: ComputationAPI) -> None: else: raise Exception("Invariant: Unreachable code path") - self.logger.debug2( - "%s failure: %s", - self.mnemonic, - err_message, - ) + self.logger.debug2(f"{self.mnemonic} failure: {err_message}") computation.return_gas(child_msg_gas) computation.stack_push_int(0) else: diff --git a/eth/vm/logic/system.py b/eth/vm/logic/system.py index 773234330..4db8b8082 100644 --- a/eth/vm/logic/system.py +++ b/eth/vm/logic/system.py @@ -1,3 +1,7 @@ +from typing import ( + Optional, +) + from eth_typing import ( Address, ) @@ -102,10 +106,8 @@ def _selfdestruct(computation: ComputationAPI, beneficiary: Address) -> None: computation.state.set_balance(computation.msg.storage_address, 0) computation.logger.debug2( - "SELFDESTRUCT: %s (%s) -> %s", - encode_hex(computation.msg.storage_address), - local_balance, - encode_hex(beneficiary), + f"SELFDESTRUCT: {encode_hex(computation.msg.storage_address)} " + f"({local_balance}) -> {encode_hex(beneficiary)}" ) # 3rd: Register the account to be deleted @@ -115,7 +117,11 @@ def _selfdestruct(computation: ComputationAPI, beneficiary: Address) -> None: class CreateOpcodeStackData: def __init__( - self, endowment: int, memory_start: int, memory_length: int, salt: int = None + self, + endowment: int, + memory_start: int, + memory_length: int, + salt: Optional[int] = None, ) -> None: self.endowment = endowment self.memory_start = memory_start @@ -202,8 +208,8 @@ def __call__(self, computation: ComputationAPI) -> None: computation.stack_push_int(0) computation.return_data = b"" self.logger.debug2( - "Address collision while creating contract: %s", - encode_hex(contract_address), + f"Address collision while creating contract: " + f"{encode_hex(contract_address)}" ) return diff --git a/eth/vm/stack.py b/eth/vm/stack.py index cf83e548e..df5aab268 100644 --- a/eth/vm/stack.py +++ b/eth/vm/stack.py @@ -103,9 +103,7 @@ def pop_any(self, num_items: int) -> Tuple[Union[int, bytes], ...]: # if num_items > len(self.values): raise InsufficientStack( - "Wanted %d stack items, only had %d", - num_items, - len(self.values), + f"Wanted {num_items} stack items, only had {len(self.values)}" ) # Quickest way to pop off multiple values from the end, in place diff --git a/newsfragments/2128.breaking.rst b/newsfragments/2128.breaking.rst new file mode 100644 index 000000000..76d2ab920 --- /dev/null +++ b/newsfragments/2128.breaking.rst @@ -0,0 +1 @@ +Drop python 3.7 support diff --git a/newsfragments/2128.internal.rst b/newsfragments/2128.internal.rst new file mode 100644 index 000000000..7482faa81 --- /dev/null +++ b/newsfragments/2128.internal.rst @@ -0,0 +1 @@ +Merge updates from the project template, including using ``pre-commit`` for linting and changing the name of the ``master`` branch to ``main`` diff --git a/pyproject.toml b/pyproject.toml index 50c7f1f6a..58e1726da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.autoflake] -remove_all_unused_imports = "True" +remove_all_unused_imports = true exclude = "__init__.py" [tool.isort] -combine_as_imports = "True" +combine_as_imports = true extra_standard_library = "pytest" force_grid_wrap = 1 -force_sort_within_sections = "True" +force_sort_within_sections = true known_third_party = "hypothesis,pytest" known_first_party = "eth" multi_line_output = 3 @@ -15,22 +15,18 @@ profile = "black" skip = "__init__.py" [tool.mypy] -check_untyped_defs = "True" -disallow_incomplete_defs = "True" -disallow_untyped_defs = "True" -disallow_any_generics = "True" -disallow_untyped_calls = "True" -disallow_untyped_decorators = "True" -disallow_subclassing_any = "True" +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_untyped_defs = true +disallow_any_generics = true +disallow_untyped_calls = true # TODO: Drop ignore-missing-imports after adding type annotations for eth_utils, coincurve & cytoolz -ignore_missing_imports = "True" -strict_optional = "True" -strict_equality = "True" -warn_redundant_casts = "True" -warn_return_any = "True" -warn_unused_configs = "True" +ignore_missing_imports = true +strict_optional = false +warn_redundant_casts = true +warn_unused_configs = true # TODO: after dropping py39, try enabling this again: -warn_unused_ignores = "False" +warn_unused_ignores = false [tool.pydocstyle] @@ -55,9 +51,10 @@ select = "D2,D3,D4" # D302 - Use u""" for Unicode docstrings # D400 - First line should end with a period # D401 - First line should be in imperative mood +# D404 - First word of the docstring should not be `This` # D412 - No blank lines allowed between a section header and its content # D415 - First line should end with a period, question mark, or exclamation point -add-ignore = "D200,D203,D204,D205,D212,D302,D400,D401,D412,D415" +add-ignore = "D200,D203,D204,D205,D212,D302,D400,D401,D404,D412,D415" # Explanation: # D400 - Enabling this error code seems to make it a requirement that the first @@ -67,7 +64,7 @@ add-ignore = "D200,D203,D204,D205,D212,D302,D400,D401,D412,D415" [tool.pytest.ini_options] addopts = "-v --showlocals --durations 10" -xfail_strict = "True" +xfail_strict = true log_format = "%(levelname)8s %(asctime)s %(filename)20s %(message)s" log_date_format = "%m-%d %H:%M:%S" timeout = 300 diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/benchmark/_utils/reporting.py b/scripts/benchmark/_utils/reporting.py index cef6fc324..ace292e92 100644 --- a/scripts/benchmark/_utils/reporting.py +++ b/scripts/benchmark/_utils/reporting.py @@ -3,7 +3,7 @@ NamedTuple, ) -from _utils.shellart import ( +from scripts.benchmark._utils.shellart import ( bold_white, ) diff --git a/scripts/benchmark/checks/__init__.py b/scripts/benchmark/checks/__init__.py index 24bed5c17..440f206d5 100644 --- a/scripts/benchmark/checks/__init__.py +++ b/scripts/benchmark/checks/__init__.py @@ -1,7 +1,7 @@ -from .mine_empty_blocks import MineEmptyBlocksBenchmark # noqa: F401 +from .mine_empty_blocks import MineEmptyBlocksBenchmark -from .import_empty_blocks import ImportEmptyBlocksBenchmark # noqa: F401 +from .import_empty_blocks import ImportEmptyBlocksBenchmark -from .simple_value_transfers import ( # noqa: F401 +from .simple_value_transfers import ( SimpleValueTransferBenchmark, ) diff --git a/scripts/benchmark/checks/base_benchmark.py b/scripts/benchmark/checks/base_benchmark.py index 1097f6f63..1fa3f9657 100644 --- a/scripts/benchmark/checks/base_benchmark.py +++ b/scripts/benchmark/checks/base_benchmark.py @@ -8,17 +8,17 @@ Callable, ) -from _utils.meters import ( +from scripts.benchmark._utils.meters import ( TimedResult, time_call, ) -from _utils.reporting import ( +from scripts.benchmark._utils.reporting import ( DefaultStat, print_default_benchmark_result_header, print_default_benchmark_stat_line, print_default_benchmark_total_line, ) -from _utils.shellart import ( +from scripts.benchmark._utils.shellart import ( bold_yellow, ) diff --git a/scripts/benchmark/checks/deploy_dos.py b/scripts/benchmark/checks/deploy_dos.py index a4b3502de..8bff29f27 100644 --- a/scripts/benchmark/checks/deploy_dos.py +++ b/scripts/benchmark/checks/deploy_dos.py @@ -7,17 +7,6 @@ Tuple, ) -from _utils.chain_plumbing import ( - FUNDED_ADDRESS, - FUNDED_ADDRESS_PRIVATE_KEY, - get_all_chains, -) -from _utils.compile import ( - get_compiled_contract, -) -from _utils.reporting import ( - DefaultStat, -) from eth_utils import ( decode_hex, encode_hex, @@ -38,6 +27,17 @@ from eth.tools.factories.transaction import ( new_transaction, ) +from scripts.benchmark._utils.chain_plumbing import ( + FUNDED_ADDRESS, + FUNDED_ADDRESS_PRIVATE_KEY, + get_all_chains, +) +from scripts.benchmark._utils.compile import ( + get_compiled_contract, +) +from scripts.benchmark._utils.reporting import ( + DefaultStat, +) from .base_benchmark import ( BaseBenchmark, @@ -73,7 +73,6 @@ def _setup_benchmark(self, chain: MiningChain) -> None: This hook can be overwritten to perform preparations on the chain that do not count into the measured benchmark time """ - pass @abstractmethod def _apply_transaction(self, chain: MiningChain) -> None: diff --git a/scripts/benchmark/checks/erc20_interact.py b/scripts/benchmark/checks/erc20_interact.py index b96f7e2fc..d64e9418b 100644 --- a/scripts/benchmark/checks/erc20_interact.py +++ b/scripts/benchmark/checks/erc20_interact.py @@ -6,19 +6,6 @@ Tuple, ) -from _utils.chain_plumbing import ( - FUNDED_ADDRESS, - FUNDED_ADDRESS_PRIVATE_KEY, - SECOND_ADDRESS, - SECOND_ADDRESS_PRIVATE_KEY, - get_all_chains, -) -from _utils.compile import ( - get_compiled_contract, -) -from _utils.reporting import ( - DefaultStat, -) from eth_utils import ( decode_hex, encode_hex, @@ -39,6 +26,19 @@ from eth.tools.factories.transaction import ( new_transaction, ) +from scripts.benchmark._utils.chain_plumbing import ( + FUNDED_ADDRESS, + FUNDED_ADDRESS_PRIVATE_KEY, + SECOND_ADDRESS, + SECOND_ADDRESS_PRIVATE_KEY, + get_all_chains, +) +from scripts.benchmark._utils.compile import ( + get_compiled_contract, +) +from scripts.benchmark._utils.reporting import ( + DefaultStat, +) from .base_benchmark import ( BaseBenchmark, @@ -73,7 +73,6 @@ def _setup_benchmark(self, chain: MiningChain) -> None: This hook can be overwritten to perform preparations on the chain that do not count into the measured benchmark time """ - pass @abstractmethod def _next_transaction(self, chain: MiningChain) -> None: diff --git a/scripts/benchmark/checks/import_empty_blocks.py b/scripts/benchmark/checks/import_empty_blocks.py index 041417391..cce9beafe 100644 --- a/scripts/benchmark/checks/import_empty_blocks.py +++ b/scripts/benchmark/checks/import_empty_blocks.py @@ -1,19 +1,18 @@ import logging -from _utils.chain_plumbing import ( +from eth.chains.base import ( + Chain, +) +from scripts.benchmark._utils.chain_plumbing import ( get_all_chains, ) -from _utils.format import ( +from scripts.benchmark._utils.format import ( format_block, ) -from _utils.reporting import ( +from scripts.benchmark._utils.reporting import ( DefaultStat, ) -from eth.chains.base import ( - Chain, -) - from .base_benchmark import ( BaseBenchmark, ) diff --git a/scripts/benchmark/checks/mine_empty_blocks.py b/scripts/benchmark/checks/mine_empty_blocks.py index 079a27b28..761964a59 100644 --- a/scripts/benchmark/checks/mine_empty_blocks.py +++ b/scripts/benchmark/checks/mine_empty_blocks.py @@ -1,19 +1,18 @@ import logging -from _utils.chain_plumbing import ( +from eth.chains.base import ( + MiningChain, +) +from scripts.benchmark._utils.chain_plumbing import ( get_all_chains, ) -from _utils.format import ( +from scripts.benchmark._utils.format import ( format_block, ) -from _utils.reporting import ( +from scripts.benchmark._utils.reporting import ( DefaultStat, ) -from eth.chains.base import ( - MiningChain, -) - from .base_benchmark import ( BaseBenchmark, ) diff --git a/scripts/benchmark/checks/simple_value_transfers.py b/scripts/benchmark/checks/simple_value_transfers.py index 57846c466..10dfa097b 100644 --- a/scripts/benchmark/checks/simple_value_transfers.py +++ b/scripts/benchmark/checks/simple_value_transfers.py @@ -4,21 +4,6 @@ Tuple, ) -from _utils.address import ( - generate_random_address, -) -from _utils.chain_plumbing import ( - FUNDED_ADDRESS, - FUNDED_ADDRESS_PRIVATE_KEY, - SECOND_ADDRESS, - get_all_chains, -) -from _utils.reporting import ( - DefaultStat, -) -from _utils.shellart import ( - bold_yellow, -) from eth_typing import ( Address, ) @@ -32,6 +17,21 @@ from eth.tools.factories.transaction import ( new_transaction, ) +from scripts.benchmark._utils.address import ( + generate_random_address, +) +from scripts.benchmark._utils.chain_plumbing import ( + FUNDED_ADDRESS, + FUNDED_ADDRESS_PRIVATE_KEY, + SECOND_ADDRESS, + get_all_chains, +) +from scripts.benchmark._utils.reporting import ( + DefaultStat, +) +from scripts.benchmark._utils.shellart import ( + bold_yellow, +) from .base_benchmark import ( BaseBenchmark, diff --git a/scripts/benchmark/contract_data/DOSContract.sol b/scripts/benchmark/contract_data/DOSContract.sol index 0323039bb..127b6b162 100644 --- a/scripts/benchmark/contract_data/DOSContract.sol +++ b/scripts/benchmark/contract_data/DOSContract.sol @@ -3,7 +3,7 @@ pragma solidity ^0.4.23; contract DOSContract{ address[] deployedContracts; uint64[] liste; - + function createEmptyContract() public{ address newContract = new EmptyContract(); deployedContracts.push(newContract); @@ -27,4 +27,4 @@ contract DOSContract{ contract EmptyContract{ -} \ No newline at end of file +} diff --git a/scripts/benchmark/contract_data/DOSContract.sol-compiled/combined.json b/scripts/benchmark/contract_data/DOSContract.sol-compiled/combined.json index c50b13749..10a36507f 100644 --- a/scripts/benchmark/contract_data/DOSContract.sol-compiled/combined.json +++ b/scripts/benchmark/contract_data/DOSContract.sol-compiled/combined.json @@ -1,16 +1,16 @@ { - "contracts" : + "contracts" : { - "scripts/benchmark/contract_data/DOSContract.sol:DOSContract" : + "scripts/benchmark/contract_data/DOSContract.sol:DOSContract" : { "abi" : "[{\"constant\":false,\"inputs\":[],\"name\":\"createEmptyContract\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"storageEntropy\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"createEmptyContractRevert\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"storageEntropyRevert\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", "bin" : "608060405234801561001057600080fd5b50610398806100206000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631c138fb114610067578063411426dc1461007e5780634660963914610095578063ae30a51f146100ac575b600080fd5b34801561007357600080fd5b5061007c6100c3565b005b34801561008a57600080fd5b50610093610155565b005b3480156100a157600080fd5b506100aa6101b0565b005b3480156100b857600080fd5b506100c1610244565b005b60006100cd61030b565b604051809103906000f0801580156100e9573d6000803e3d6000fd5b50905060008190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600180908060018154018082558091505090600182039060005260206000209060049182820401919006600802909192909190916101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555050565b60006101ba61030b565b604051809103906000f0801580156101d6573d6000803e3d6000fd5b50905060008190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050600080fd5b600180908060018154018082558091505090600182039060005260206000209060049182820401919006600802909192909190916101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f4572726f7200000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60405160528061031b8339019056006080604052348015600f57600080fd5b50603580601d6000396000f3006080604052600080fd00a165627a7a72305820380024be49f6252eb658404f967733d0f5dedd55afadb0907757472a1dfc3a110029a165627a7a72305820ea75b78be833699c8aaaa51d54faf1aaed3f9b4bc0d11ff36a8791b45a17dd760029" }, - "scripts/benchmark/contract_data/DOSContract.sol:EmptyContract" : + "scripts/benchmark/contract_data/DOSContract.sol:EmptyContract" : { "abi" : "[]", "bin" : "6080604052348015600f57600080fd5b50603580601d6000396000f3006080604052600080fd00a165627a7a72305820380024be49f6252eb658404f967733d0f5dedd55afadb0907757472a1dfc3a110029" } }, "version" : "0.4.25-develop.2018.6.6+commit.59b35fa5.Linux.g++" -} \ No newline at end of file +} diff --git a/scripts/benchmark/contract_data/erc20.sol b/scripts/benchmark/contract_data/erc20.sol index 74a4db78e..633640efc 100644 --- a/scripts/benchmark/contract_data/erc20.sol +++ b/scripts/benchmark/contract_data/erc20.sol @@ -271,4 +271,4 @@ contract SimpleToken is StandardToken { emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } -} \ No newline at end of file +} diff --git a/scripts/benchmark/contract_data/erc20.sol-compiled/combined.json b/scripts/benchmark/contract_data/erc20.sol-compiled/combined.json index 348778b04..29a7501ca 100644 --- a/scripts/benchmark/contract_data/erc20.sol-compiled/combined.json +++ b/scripts/benchmark/contract_data/erc20.sol-compiled/combined.json @@ -1,36 +1,36 @@ { - "contracts" : + "contracts" : { - "scripts/benchmark/contract_data/erc20.sol:BasicToken" : + "scripts/benchmark/contract_data/erc20.sol:BasicToken" : { "abi" : "[{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]", "bin" : "608060405234801561001057600080fd5b50610415806100206000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806318160ddd1461005c57806370a0823114610087578063a9059cbb146100de575b600080fd5b34801561006857600080fd5b50610071610143565b6040518082815260200191505060405180910390f35b34801561009357600080fd5b506100c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061014d565b6040518082815260200191505060405180910390f35b3480156100ea57600080fd5b50610129600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610195565b604051808215151515815260200191505060405180910390f35b6000600154905090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156101d257600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561021f57600080fd5b610270826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546103b490919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610303826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546103cd90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008282111515156103c257fe5b818303905092915050565b600081830190508281101515156103e057fe5b809050929150505600a165627a7a72305820f4569b6622329714152f6131d772f9f14407ab2d839b3b0fe9d5a259a09a0b3b0029" }, - "scripts/benchmark/contract_data/erc20.sol:ERC20" : + "scripts/benchmark/contract_data/erc20.sol:ERC20" : { "abi" : "[{\"constant\":false,\"inputs\":[{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"who\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]", "bin" : "" }, - "scripts/benchmark/contract_data/erc20.sol:ERC20Basic" : + "scripts/benchmark/contract_data/erc20.sol:ERC20Basic" : { "abi" : "[{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"who\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]", "bin" : "" }, - "scripts/benchmark/contract_data/erc20.sol:SafeMath" : + "scripts/benchmark/contract_data/erc20.sol:SafeMath" : { "abi" : "[]", "bin" : "604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a72305820c5bdeb240fbc6a78fdd41dbc4761cc43cc1c9dfb307b6d3f84a4392e5cc6d59c0029" }, - "scripts/benchmark/contract_data/erc20.sol:SimpleToken" : + "scripts/benchmark/contract_data/erc20.sol:SimpleToken" : { "abi" : "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"INITIAL_SUPPLY\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseApproval\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseApproval\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]", "bin" : "608060405234801561001057600080fd5b50601260ff16600a0a61271002600181905550601260ff16600a0a612710026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef601260ff16600a0a612710026040518082815260200191505060405180910390a3611265806100db6000396000f3006080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b457806323b872dd146101df5780632ff2e9dc14610264578063313ce5671461028f57806366188463146102c057806370a082311461032557806395d89b411461037c578063a9059cbb1461040c578063d73dd62314610471578063dd62ed3e146104d6575b600080fd5b3480156100cb57600080fd5b506100d461054d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610586565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c9610678565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b5061024a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610682565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b50610279610a3c565b6040518082815260200191505060405180910390f35b34801561029b57600080fd5b506102a4610a4b565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102cc57600080fd5b5061030b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a50565b604051808215151515815260200191505060405180910390f35b34801561033157600080fd5b50610366600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ce1565b6040518082815260200191505060405180910390f35b34801561038857600080fd5b50610391610d29565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d15780820151818401526020810190506103b6565b50505050905090810190601f1680156103fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041857600080fd5b50610457600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d62565b604051808215151515815260200191505060405180910390f35b34801561047d57600080fd5b506104bc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f81565b604051808215151515815260200191505060405180910390f35b3480156104e257600080fd5b50610537600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061117d565b6040518082815260200191505060405180910390f35b6040805190810160405280600b81526020017f53696d706c65546f6b656e00000000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156106bf57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561070c57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561079757600080fd5b6107e8826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461120490919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061087b826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461121d90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061094c82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461120490919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601260ff16600a0a6127100281565b601281565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610b61576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bf5565b610b74838261120490919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600381526020017f53494d000000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610d9f57600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610dec57600080fd5b610e3d826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461120490919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ed0826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461121d90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061101282600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461121d90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561121257fe5b818303905092915050565b6000818301905082811015151561123057fe5b809050929150505600a165627a7a7230582089c231b0f977af633ac3bf3b497b58ed88269696512d6856229f1621c2656e610029" }, - "scripts/benchmark/contract_data/erc20.sol:StandardToken" : + "scripts/benchmark/contract_data/erc20.sol:StandardToken" : { "abi" : "[{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseApproval\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseApproval\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]", "bin" : "608060405234801561001057600080fd5b50611037806100206000396000f30060806040526004361061008e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461009357806318160ddd146100f857806323b872dd1461012357806366188463146101a857806370a082311461020d578063a9059cbb14610264578063d73dd623146102c9578063dd62ed3e1461032e575b600080fd5b34801561009f57600080fd5b506100de600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103a5565b604051808215151515815260200191505060405180910390f35b34801561010457600080fd5b5061010d610497565b6040518082815260200191505060405180910390f35b34801561012f57600080fd5b5061018e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104a1565b604051808215151515815260200191505060405180910390f35b3480156101b457600080fd5b506101f3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061085b565b604051808215151515815260200191505060405180910390f35b34801561021957600080fd5b5061024e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aec565b6040518082815260200191505060405180910390f35b34801561027057600080fd5b506102af600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b34565b604051808215151515815260200191505060405180910390f35b3480156102d557600080fd5b50610314600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d53565b604051808215151515815260200191505060405180910390f35b34801561033a57600080fd5b5061038f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f4f565b6040518082815260200191505060405180910390f35b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156104de57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561052b57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156105b657600080fd5b610607826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fd690919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061069a826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fef90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061076b82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fd690919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508083111561096c576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a00565b61097f8382610fd690919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610b7157600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610bbe57600080fd5b610c0f826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fd690919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca2826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fef90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000610de482600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fef90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000828211151515610fe457fe5b818303905092915050565b6000818301905082811015151561100257fe5b809050929150505600a165627a7a72305820f5e9cbbcf4148602338663576ad7f71bd475069a850e696dbaed33953ffdb3c90029" } }, "version" : "0.4.25-develop.2018.6.6+commit.59b35fa5.Linux.g++" -} \ No newline at end of file +} diff --git a/scripts/benchmark/run.py b/scripts/benchmark/run.py index 693c5f59a..2913cdca9 100755 --- a/scripts/benchmark/run.py +++ b/scripts/benchmark/run.py @@ -3,17 +3,6 @@ import logging import sys -from _utils.compile import ( - compile_contracts, -) -from _utils.reporting import ( - DefaultStat, - print_final_benchmark_total_line, -) -from _utils.shellart import ( - bold_green, - bold_red, -) from checks import ( ImportEmptyBlocksBenchmark, MineEmptyBlocksBenchmark, @@ -43,6 +32,17 @@ from eth._utils.version import ( construct_evm_runtime_identifier, ) +from scripts.benchmark._utils.compile import ( + compile_contracts, +) +from scripts.benchmark._utils.reporting import ( + DefaultStat, + print_final_benchmark_total_line, +) +from scripts.benchmark._utils.shellart import ( + bold_green, + bold_red, +) HEADER = ( "\n" diff --git a/setup.py b/setup.py index cd93510d1..7429361f7 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,13 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- from setuptools import ( find_packages, setup, ) - extras_require = { "benchmark": [ - "termcolor>=1.1.0,<2.0.0", - "web3>=4.1.0,<5.0.0", + "termcolor>=1.1.0", + "web3>=6.0.0", ], "dev": [ "build>=0.9.0", @@ -21,12 +19,10 @@ "wheel", ], "docs": [ - "py-evm>=0.2.0-a.14", - # We need to have pysha for autodoc to be able to extract API docs + "py-evm>=0.8.0b1", "sphinx>=6.0.0", - "jinja2>=3.0.0,<3.1.0", # jinja2<3.0 or >=3.1.0 cause doc build failures. "sphinx_rtd_theme>=1.0.0", - "sphinxcontrib-asyncio>=0.2.0,<0.4", + "sphinxcontrib-asyncio>=0.2.0", "towncrier>=21,<22", ], "eth": [ @@ -45,17 +41,16 @@ # Installing these libraries may make the evm perform better than # using the default fallbacks though. "eth-extra": [ - "blake2b-py>=0.2.0,<0.3.0", + "blake2b-py>=0.2.0", "coincurve>=18.0.0", ], "test": [ - "factory-boy==2.11.1", + "factory-boy>=3.0.0", "hypothesis>=5,<6", - "pexpect>=4.6,<5", "pytest>=7.0.0", - "pytest-asyncio>=0.10.0,<0.11", - "pytest-cov==2.5.1", - "pytest-timeout>=2.0.0,<3", + "pytest-asyncio>=0.20.0", + "pytest-cov>=4.0.0", + "pytest-timeout>=2.0.0", "pytest-xdist>=3.0", ], } @@ -81,7 +76,7 @@ long_description=long_description, long_description_content_type="text/markdown", author="Ethereum Foundation", - author_email="piper@pipermerriam.com", + author_email="snakecharmers@ethereum.org", url="https://github.com/ethereum/py-evm", include_package_data=True, py_modules=["eth"], diff --git a/tests/conftest.py b/tests/conftest.py index bb476d43e..ca360ede6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ from pathlib import ( Path, ) -import pytest from eth_keys import ( keys, @@ -12,6 +11,7 @@ to_tuple, to_wei, ) +import pytest import rlp from eth import ( diff --git a/tests/core/address-utils/test_address_generation.py b/tests/core/address-utils/test_address_generation.py index d71575e0c..7a230e24e 100644 --- a/tests/core/address-utils/test_address_generation.py +++ b/tests/core/address-utils/test_address_generation.py @@ -1,10 +1,9 @@ -import pytest - from eth_utils import ( big_endian_to_int, decode_hex, is_same_address, ) +import pytest from eth._utils.address import ( generate_safe_contract_address, diff --git a/tests/core/builder-tools/test_chain_builder.py b/tests/core/builder-tools/test_chain_builder.py index 57e8c0d55..7a931faf2 100644 --- a/tests/core/builder-tools/test_chain_builder.py +++ b/tests/core/builder-tools/test_chain_builder.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, to_wei, ) +import pytest from eth.chains.base import ( Chain, diff --git a/tests/core/builder-tools/test_chain_construction.py b/tests/core/builder-tools/test_chain_construction.py index e14557dca..ef2d98a9f 100644 --- a/tests/core/builder-tools/test_chain_construction.py +++ b/tests/core/builder-tools/test_chain_construction.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.chains.base import ( MiningChain, diff --git a/tests/core/builder-tools/test_chain_initializer.py b/tests/core/builder-tools/test_chain_initializer.py index 6773f935a..2eb264b09 100644 --- a/tests/core/builder-tools/test_chain_initializer.py +++ b/tests/core/builder-tools/test_chain_initializer.py @@ -1,9 +1,9 @@ -import pytest import time from eth_utils.toolz import ( pipe, ) +import pytest from eth import ( constants, diff --git a/tests/core/chain-object/test_chain.py b/tests/core/chain-object/test_chain.py index 5a8f0526e..06f1985a9 100644 --- a/tests/core/chain-object/test_chain.py +++ b/tests/core/chain-object/test_chain.py @@ -1,11 +1,10 @@ -import pytest - from eth_utils import ( decode_hex, ) from eth_utils.toolz import ( sliding_window, ) +import pytest import rlp from eth import ( diff --git a/tests/core/chain-object/test_chain_get_ancestors.py b/tests/core/chain-object/test_chain_get_ancestors.py index 4be5784da..36eaa2856 100644 --- a/tests/core/chain-object/test_chain_get_ancestors.py +++ b/tests/core/chain-object/test_chain_get_ancestors.py @@ -59,7 +59,7 @@ def test_chain_get_ancestors_from_block_5(chain): block_3, block_4, block_5, - ) = [chain.mine_block() for _ in range(5)] + ) = (chain.mine_block() for _ in range(5)) header = block_5.header assert header.block_number == 5 @@ -98,12 +98,12 @@ def test_chain_get_ancestors_for_fork_chains(chain, fork_chain): block_1, block_2, block_3, - ) = [chain.mine_block() for _ in range(3)] + ) = (chain.mine_block() for _ in range(3)) ( f_block_1, f_block_2, f_block_3, - ) = [fork_chain.mine_block() for _ in range(3)] + ) = (fork_chain.mine_block() for _ in range(3)) assert block_1 == f_block_1 assert block_2 == f_block_2 @@ -117,12 +117,12 @@ def test_chain_get_ancestors_for_fork_chains(chain, fork_chain): block_4, block_5, block_6, - ) = [chain.mine_block() for _ in range(3)] + ) = (chain.mine_block() for _ in range(3)) ( f_block_4, f_block_5, f_block_6, - ) = [fork_chain.mine_block() for _ in range(3)] + ) = (fork_chain.mine_block() for _ in range(3)) # import the fork blocks into the main chain (ensuring they don't cause a reorg) block_import_result = chain.import_block(f_block_4) diff --git a/tests/core/chain-object/test_contract_call.py b/tests/core/chain-object/test_contract_call.py index 465b3bbb4..27cf78782 100644 --- a/tests/core/chain-object/test_contract_call.py +++ b/tests/core/chain-object/test_contract_call.py @@ -1,5 +1,3 @@ -import pytest - from eth_utils import ( decode_hex, function_signature_to_4byte_selector, @@ -8,6 +6,7 @@ from eth_utils.toolz import ( assoc, ) +import pytest from eth.exceptions import ( InvalidInstruction, diff --git a/tests/core/chain-object/test_create_transaction.py b/tests/core/chain-object/test_create_transaction.py index 811b07325..b2e5ddf40 100644 --- a/tests/core/chain-object/test_create_transaction.py +++ b/tests/core/chain-object/test_create_transaction.py @@ -1,8 +1,7 @@ -import pytest - from eth_keys import ( keys, ) +import pytest from eth.chains.base import ( MiningChain, diff --git a/tests/core/code-stream/test_code_stream.py b/tests/core/code-stream/test_code_stream.py index 48d63448e..982a863cd 100644 --- a/tests/core/code-stream/test_code_stream.py +++ b/tests/core/code-stream/test_code_stream.py @@ -1,5 +1,4 @@ import itertools -import pytest import sys from eth_utils import ( @@ -12,6 +11,7 @@ given, strategies as st, ) +import pytest from eth.tools._utils.slow_code_stream import ( SlowCodeStream, diff --git a/tests/core/consensus/test_clique_consensus.py b/tests/core/consensus/test_clique_consensus.py index 64687a27e..483581c0a 100644 --- a/tests/core/consensus/test_clique_consensus.py +++ b/tests/core/consensus/test_clique_consensus.py @@ -1,5 +1,3 @@ -import pytest - from eth_keys import ( keys, ) @@ -8,6 +6,7 @@ decode_hex, to_tuple, ) +import pytest from eth.chains.base import ( MiningChain, diff --git a/tests/core/consensus/test_clique_utils.py b/tests/core/consensus/test_clique_utils.py index 5f5809866..0844732df 100644 --- a/tests/core/consensus/test_clique_utils.py +++ b/tests/core/consensus/test_clique_utils.py @@ -1,5 +1,3 @@ -import pytest - from eth_keys import ( keys, ) @@ -9,6 +7,7 @@ from eth_utils import ( decode_hex, ) +import pytest from eth.chains.goerli import ( GOERLI_GENESIS_HEADER, diff --git a/tests/core/consensus/test_consensus_engine.py b/tests/core/consensus/test_consensus_engine.py index 55f25dcd8..20038c8b1 100644 --- a/tests/core/consensus/test_consensus_engine.py +++ b/tests/core/consensus/test_consensus_engine.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.abc import ( ConsensusAPI, diff --git a/tests/core/consensus/test_pow_mining.py b/tests/core/consensus/test_pow_mining.py index a93f3d49c..188b921ed 100644 --- a/tests/core/consensus/test_pow_mining.py +++ b/tests/core/consensus/test_pow_mining.py @@ -1,8 +1,9 @@ -import pytest import random import threading import time +import pytest + from eth.chains.base import ( MiningChain, ) diff --git a/tests/core/env-utils/test_env_bool.py b/tests/core/env-utils/test_env_bool.py index 0be8d5577..2fd312d53 100644 --- a/tests/core/env-utils/test_env_bool.py +++ b/tests/core/env-utils/test_env_bool.py @@ -1,4 +1,5 @@ import os + import pytest from eth._utils.env import ( diff --git a/tests/core/env-utils/test_env_float.py b/tests/core/env-utils/test_env_float.py index 3bea0a170..4982abc21 100644 --- a/tests/core/env-utils/test_env_float.py +++ b/tests/core/env-utils/test_env_float.py @@ -1,4 +1,5 @@ import os + import pytest from eth._utils.env import ( diff --git a/tests/core/env-utils/test_env_int.py b/tests/core/env-utils/test_env_int.py index e7e68ff0c..f53303c52 100644 --- a/tests/core/env-utils/test_env_int.py +++ b/tests/core/env-utils/test_env_int.py @@ -1,4 +1,5 @@ import os + import pytest from eth._utils.env import ( diff --git a/tests/core/env-utils/test_env_list.py b/tests/core/env-utils/test_env_list.py index 2ccf8ac28..464c84705 100644 --- a/tests/core/env-utils/test_env_list.py +++ b/tests/core/env-utils/test_env_list.py @@ -1,4 +1,5 @@ import os + import pytest from eth._utils.env import ( diff --git a/tests/core/env-utils/test_env_string.py b/tests/core/env-utils/test_env_string.py index 6480ebd84..ef541268d 100644 --- a/tests/core/env-utils/test_env_string.py +++ b/tests/core/env-utils/test_env_string.py @@ -1,4 +1,5 @@ import os + import pytest from eth._utils.env import ( diff --git a/tests/core/fixture-tools/test_normalize_state.py b/tests/core/fixture-tools/test_normalize_state.py index 1d495f8d0..ead7f884f 100644 --- a/tests/core/fixture-tools/test_normalize_state.py +++ b/tests/core/fixture-tools/test_normalize_state.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, big_endian_to_int, ) +import pytest from eth.tools._utils.normalization import ( normalize_state, diff --git a/tests/core/gas_meter/test_gas_meter.py b/tests/core/gas_meter/test_gas_meter.py index c616629e9..87b638fbd 100644 --- a/tests/core/gas_meter/test_gas_meter.py +++ b/tests/core/gas_meter/test_gas_meter.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.exceptions import ( OutOfGas, diff --git a/tests/core/helpers.py b/tests/core/helpers.py index 58864d749..68096576a 100644 --- a/tests/core/helpers.py +++ b/tests/core/helpers.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, decode_hex, ) +import pytest from eth.chains.base import ( MiningChain, diff --git a/tests/core/hexadecimal-utils/test_encode_and_decode.py b/tests/core/hexadecimal-utils/test_encode_and_decode.py index ea95d9b9b..749aeb5ca 100644 --- a/tests/core/hexadecimal-utils/test_encode_and_decode.py +++ b/tests/core/hexadecimal-utils/test_encode_and_decode.py @@ -1,5 +1,3 @@ -import pytest - from eth_utils import ( decode_hex, encode_hex, @@ -8,6 +6,7 @@ given, strategies as st, ) +import pytest @pytest.mark.parametrize( diff --git a/tests/core/memory/test_memory.py b/tests/core/memory/test_memory.py index 56f60930b..628375ed6 100644 --- a/tests/core/memory/test_memory.py +++ b/tests/core/memory/test_memory.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.vm.memory import ( Memory, diff --git a/tests/core/message-object/test_message_object.py b/tests/core/message-object/test_message_object.py index 92c9a62e2..6dfe325b2 100644 --- a/tests/core/message-object/test_message_object.py +++ b/tests/core/message-object/test_message_object.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, to_normalized_address, ) +import pytest from eth.constants import ( CREATE_CONTRACT_ADDRESS, diff --git a/tests/core/numeric-utils/test_integer_squareroot.py b/tests/core/numeric-utils/test_integer_squareroot.py index b406bf9a1..2b84bbe39 100644 --- a/tests/core/numeric-utils/test_integer_squareroot.py +++ b/tests/core/numeric-utils/test_integer_squareroot.py @@ -1,9 +1,8 @@ -import pytest - from hypothesis import ( given, strategies as st, ) +import pytest from eth._utils.numeric import ( integer_squareroot, diff --git a/tests/core/opcodes/test_opcodes.py b/tests/core/opcodes/test_opcodes.py index c37cc7874..6483583f0 100644 --- a/tests/core/opcodes/test_opcodes.py +++ b/tests/core/opcodes/test_opcodes.py @@ -1,4 +1,3 @@ -import pytest import warnings from eth_utils import ( @@ -10,6 +9,7 @@ to_bytes, to_canonical_address, ) +import pytest from eth import ( constants, diff --git a/tests/core/precompiles/test_blake2.py b/tests/core/precompiles/test_blake2.py index 56485529e..7ffecb827 100644 --- a/tests/core/precompiles/test_blake2.py +++ b/tests/core/precompiles/test_blake2.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, to_bytes, ) +import pytest from eth._utils.blake2.coders import ( extract_blake2b_parameters, diff --git a/tests/core/stack/test_stack.py b/tests/core/stack/test_stack.py index 4bedeb891..d60047d23 100644 --- a/tests/core/stack/test_stack.py +++ b/tests/core/stack/test_stack.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.exceptions import ( FullStack, diff --git a/tests/core/tester/test_generate_vm_configuration.py b/tests/core/tester/test_generate_vm_configuration.py index 43c24d2ae..f127bbd9b 100644 --- a/tests/core/tester/test_generate_vm_configuration.py +++ b/tests/core/tester/test_generate_vm_configuration.py @@ -1,4 +1,5 @@ import enum + import pytest from eth.chains.tester import ( diff --git a/tests/core/transaction-utils/test_receipt_encoding.py b/tests/core/transaction-utils/test_receipt_encoding.py index 99fd4c00a..5064f17e2 100644 --- a/tests/core/transaction-utils/test_receipt_encoding.py +++ b/tests/core/transaction-utils/test_receipt_encoding.py @@ -1,10 +1,9 @@ -import pytest - from eth_utils import ( ValidationError, decode_hex, to_bytes, ) +import pytest import rlp from eth.exceptions import ( diff --git a/tests/core/transaction-utils/test_transaction_encoding.py b/tests/core/transaction-utils/test_transaction_encoding.py index f6a3db130..62567d0a3 100644 --- a/tests/core/transaction-utils/test_transaction_encoding.py +++ b/tests/core/transaction-utils/test_transaction_encoding.py @@ -1,11 +1,10 @@ -import pytest - from eth_utils import ( ValidationError, decode_hex, to_bytes, to_int, ) +import pytest import rlp from eth.exceptions import ( diff --git a/tests/core/transaction-utils/test_transaction_signature_validation.py b/tests/core/transaction-utils/test_transaction_signature_validation.py index ac339aeb9..b41eb0884 100644 --- a/tests/core/transaction-utils/test_transaction_signature_validation.py +++ b/tests/core/transaction-utils/test_transaction_signature_validation.py @@ -1,5 +1,3 @@ -import pytest - from eth_keys import ( keys, ) @@ -8,6 +6,7 @@ is_same_address, to_canonical_address, ) +import pytest import rlp from eth._utils.transactions import ( diff --git a/tests/core/validation/test_eth1_validation.py b/tests/core/validation/test_eth1_validation.py index b909d4479..74a145bf6 100644 --- a/tests/core/validation/test_eth1_validation.py +++ b/tests/core/validation/test_eth1_validation.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.constants import ( SECPK1_N, diff --git a/tests/core/validation/test_transaction_validation.py b/tests/core/validation/test_transaction_validation.py index 7eaa1ae05..67878fdf8 100644 --- a/tests/core/validation/test_transaction_validation.py +++ b/tests/core/validation/test_transaction_validation.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.vm.forks.berlin.transactions import ( UnsignedAccessListTransaction, diff --git a/tests/core/validation/test_withdrawal_validation.py b/tests/core/validation/test_withdrawal_validation.py index c28c0762a..867ff65fa 100644 --- a/tests/core/validation/test_withdrawal_validation.py +++ b/tests/core/validation/test_withdrawal_validation.py @@ -1,5 +1,3 @@ -import pytest - from eth_typing import ( Address, ) @@ -7,6 +5,7 @@ ValidationError, to_hex, ) +import pytest from eth.validation import ( UINT_64_MAX, diff --git a/tests/core/vm/conftest.py b/tests/core/vm/conftest.py index bf77fc304..e7ad0ab8e 100644 --- a/tests/core/vm/conftest.py +++ b/tests/core/vm/conftest.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( to_canonical_address, ) +import pytest from eth.vm.transaction_context import ( BaseTransactionContext, diff --git a/tests/core/vm/test_base_computation.py b/tests/core/vm/test_base_computation.py index f9150ea99..861da0f0a 100644 --- a/tests/core/vm/test_base_computation.py +++ b/tests/core/vm/test_base_computation.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.exceptions import ( Revert, diff --git a/tests/core/vm/test_clique_validation.py b/tests/core/vm/test_clique_validation.py index b11accd5b..447a08ad6 100644 --- a/tests/core/vm/test_clique_validation.py +++ b/tests/core/vm/test_clique_validation.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, decode_hex, ) +import pytest from eth.chains.base import ( MiningChain, diff --git a/tests/core/vm/test_computation.py b/tests/core/vm/test_computation.py index 0a375aa5e..54cabb799 100644 --- a/tests/core/vm/test_computation.py +++ b/tests/core/vm/test_computation.py @@ -1,12 +1,11 @@ # test computation class behavior across VMs -import pytest - from eth_typing import ( Address, ) from eth_utils import ( decode_hex, ) +import pytest from eth import ( constants, diff --git a/tests/core/vm/test_contract_code_size_limit.py b/tests/core/vm/test_contract_code_size_limit.py index 268b2a929..6f17aa078 100644 --- a/tests/core/vm/test_contract_code_size_limit.py +++ b/tests/core/vm/test_contract_code_size_limit.py @@ -1,10 +1,9 @@ -import pytest - from eth_utils import ( hexstr_if_str, to_bytes, to_wei, ) +import pytest from eth._utils.address import ( generate_contract_address, diff --git a/tests/core/vm/test_interrupt.py b/tests/core/vm/test_interrupt.py index 998ee57f4..5c061f1af 100644 --- a/tests/core/vm/test_interrupt.py +++ b/tests/core/vm/test_interrupt.py @@ -1,11 +1,10 @@ -import pytest - from eth_hash.auto import ( keccak, ) from eth_utils import ( int_to_big_endian, ) +import pytest from eth.vm.interrupt import ( MissingAccountTrieNode, diff --git a/tests/core/vm/test_london.py b/tests/core/vm/test_london.py index 84f072cf2..2c55fde2b 100644 --- a/tests/core/vm/test_london.py +++ b/tests/core/vm/test_london.py @@ -1,11 +1,10 @@ -import pytest - from eth_typing import ( Address, ) from eth_utils import ( decode_hex, ) +import pytest from eth import ( constants, diff --git a/tests/core/vm/test_mainnet_dao_fork.py b/tests/core/vm/test_mainnet_dao_fork.py index 9b23752d4..91342576b 100644 --- a/tests/core/vm/test_mainnet_dao_fork.py +++ b/tests/core/vm/test_mainnet_dao_fork.py @@ -1,5 +1,3 @@ -import pytest - from eth_utils import ( ValidationError, to_tuple, @@ -7,6 +5,7 @@ from eth_utils.toolz import ( sliding_window, ) +import pytest from eth.chains.mainnet import ( MainnetHomesteadVM, @@ -292,4 +291,4 @@ def test_mainnet_dao_fork_header_validation(VM, header, previous_header, valid): except ValidationError: pass else: - raise AssertionError("The invalid header %r must fail" % header) + raise AssertionError(f"The invalid header {repr(header)} must fail") diff --git a/tests/core/vm/test_modexp_precompile.py b/tests/core/vm/test_modexp_precompile.py index 2143aed39..190231cce 100644 --- a/tests/core/vm/test_modexp_precompile.py +++ b/tests/core/vm/test_modexp_precompile.py @@ -1,10 +1,10 @@ import json import os -import pytest from eth_utils import ( decode_hex, ) +import pytest from eth.precompiles.modexp import ( _compute_modexp_gas_fee_eip_198, diff --git a/tests/core/vm/test_rewards.py b/tests/core/vm/test_rewards.py index 436cbfc67..caccd63ab 100644 --- a/tests/core/vm/test_rewards.py +++ b/tests/core/vm/test_rewards.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, to_wei, ) +import pytest from eth.chains.base import ( MiningChain, diff --git a/tests/core/vm/test_validate_transaction.py b/tests/core/vm/test_validate_transaction.py index f97a0e68a..c13d6962a 100644 --- a/tests/core/vm/test_validate_transaction.py +++ b/tests/core/vm/test_validate_transaction.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth._utils.address import ( force_bytes_to_address, diff --git a/tests/core/vm/test_vm.py b/tests/core/vm/test_vm.py index e3fb8d974..ec7d327af 100644 --- a/tests/core/vm/test_vm.py +++ b/tests/core/vm/test_vm.py @@ -1,9 +1,8 @@ -import pytest - from eth_utils import ( ValidationError, decode_hex, ) +import pytest import rlp from eth import ( diff --git a/tests/core/vm/test_vm_class_configurations.py b/tests/core/vm/test_vm_class_configurations.py index 512c815dd..37c80c77a 100644 --- a/tests/core/vm/test_vm_class_configurations.py +++ b/tests/core/vm/test_vm_class_configurations.py @@ -1,8 +1,7 @@ -import pytest - from eth_bloom import ( BloomFilter, ) +import pytest from eth.abc import ( ReceiptBuilderAPI, diff --git a/tests/core/vm/test_vm_state.py b/tests/core/vm/test_vm_state.py index 5d4093ed2..370b1a256 100644 --- a/tests/core/vm/test_vm_state.py +++ b/tests/core/vm/test_vm_state.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.tools.factories.transaction import ( new_transaction, diff --git a/tests/database/test_accesslog.py b/tests/database/test_accesslog.py index aa649df0d..44d1acbe8 100644 --- a/tests/database/test_accesslog.py +++ b/tests/database/test_accesslog.py @@ -1,9 +1,8 @@ -import pytest - from hypothesis import ( given, strategies as st, ) +import pytest from eth.db.accesslog import ( KeyAccessLoggerAtomicDB, diff --git a/tests/database/test_account_db.py b/tests/database/test_account_db.py index 47613abb4..4dca10830 100644 --- a/tests/database/test_account_db.py +++ b/tests/database/test_account_db.py @@ -1,11 +1,10 @@ -import pytest - from eth_hash.auto import ( keccak, ) from eth_utils import ( ValidationError, ) +import pytest from eth.constants import ( EMPTY_SHA3, diff --git a/tests/database/test_batch_db.py b/tests/database/test_batch_db.py index 826cfc701..9e4c425a0 100644 --- a/tests/database/test_batch_db.py +++ b/tests/database/test_batch_db.py @@ -1,8 +1,7 @@ -import pytest - from eth_utils import ( ValidationError, ) +import pytest from eth.db.backends.memory import ( MemoryDB, diff --git a/tests/database/test_eth1_chaindb.py b/tests/database/test_eth1_chaindb.py index 8ca288ece..246f021af 100644 --- a/tests/database/test_eth1_chaindb.py +++ b/tests/database/test_eth1_chaindb.py @@ -1,5 +1,3 @@ -import pytest - from eth_hash.auto import ( keccak, ) @@ -7,6 +5,7 @@ given, strategies as st, ) +import pytest import rlp from eth._utils.address import ( diff --git a/tests/database/test_header_db.py b/tests/database/test_header_db.py index fc9174562..e46ea7342 100644 --- a/tests/database/test_header_db.py +++ b/tests/database/test_header_db.py @@ -3,7 +3,6 @@ partial, ) import operator -import pytest import random from eth_utils import ( @@ -23,6 +22,7 @@ settings, strategies as st, ) +import pytest from eth.constants import ( GENESIS_BLOCK_NUMBER, diff --git a/tests/database/test_journal_db.py b/tests/database/test_journal_db.py index 4b4c287af..a6282318e 100644 --- a/tests/database/test_journal_db.py +++ b/tests/database/test_journal_db.py @@ -1,5 +1,3 @@ -import pytest - from eth_utils import ( ValidationError, ) @@ -13,6 +11,7 @@ RuleBasedStateMachine, rule, ) +import pytest from eth.db.backends.memory import ( MemoryDB, @@ -485,7 +484,7 @@ def test_journal_db_diff_application_mimics_persist(journal_db, memory_db, actio key, val = action journal_db.set(key, val) else: - raise Exception("Incorrectly formatted fixture input: %r" % action) + raise Exception(f"Incorrectly formatted fixture input: {repr(action)}") assert MemoryDB({}) == memory_db diff = journal_db.diff() diff --git a/tests/json-fixtures/blockchain/test_blockchain.py b/tests/json-fixtures/blockchain/test_blockchain.py index 3decc2502..d2a8498a6 100644 --- a/tests/json-fixtures/blockchain/test_blockchain.py +++ b/tests/json-fixtures/blockchain/test_blockchain.py @@ -2,12 +2,12 @@ from pathlib import ( Path, ) -import pytest from eth_utils import ( ValidationError, to_tuple, ) +import pytest import rlp from eth.tools._utils.normalization import ( diff --git a/tests/json-fixtures/test_difficulty.py b/tests/json-fixtures/test_difficulty.py index eb4e343d2..adc216ddc 100644 --- a/tests/json-fixtures/test_difficulty.py +++ b/tests/json-fixtures/test_difficulty.py @@ -1,5 +1,4 @@ import os -import pytest from eth_typing.enums import ( ForkName, @@ -7,6 +6,7 @@ from eth_utils import ( to_int, ) +import pytest from eth.constants import ( EMPTY_UNCLE_HASH, diff --git a/tests/json-fixtures/test_transactions.py b/tests/json-fixtures/test_transactions.py index e66e87f31..02e0d6423 100644 --- a/tests/json-fixtures/test_transactions.py +++ b/tests/json-fixtures/test_transactions.py @@ -1,5 +1,4 @@ import os -import pytest from eth_typing.enums import ( ForkName, @@ -9,6 +8,7 @@ is_same_address, to_tuple, ) +import pytest import rlp from eth.exceptions import ( diff --git a/tests/json-fixtures/test_virtual_machine.py b/tests/json-fixtures/test_virtual_machine.py index ae7d3c3e7..6436800a2 100644 --- a/tests/json-fixtures/test_virtual_machine.py +++ b/tests/json-fixtures/test_virtual_machine.py @@ -1,5 +1,4 @@ import os -import pytest from eth_hash.auto import ( keccak, @@ -7,6 +6,7 @@ from eth_utils import ( to_bytes, ) +import pytest from eth.consensus import ( ConsensusContext, diff --git a/tox.ini b/tox.ini index f34e3ac62..690149d22 100644 --- a/tox.ini +++ b/tox.ini @@ -21,6 +21,7 @@ extend-ignore=E203 max-line-length=88 per-file-ignores=__init__.py:F401 +[testenv] commands= core: pytest {posargs:tests/core/} docs: make validate-docs @@ -57,6 +58,7 @@ allowlist_externals=make,pre-commit [testenv:py{38,39,310,311}-lint] deps=pre-commit commands= + pre-commit install pre-commit run --all-files --show-diff-on-failure [testenv:py{38,39,310,311}-wheel] @@ -70,7 +72,7 @@ commands= python -m pip install --upgrade pip /bin/rm -rf build dist python -m build - /bin/bash -c 'python -m pip install --upgrade "$(ls dist/eth-*-py3-none-any.whl)" --progress-bar off' + /bin/bash -c 'python -m pip install --upgrade "$(ls dist/py_evm-*-py3-none-any.whl)" --progress-bar off' python -c "import eth" skip_install=true @@ -84,6 +86,6 @@ commands= python -m pip install --upgrade pip bash.exe -c "rm -rf build dist" python -m build - bash.exe -c 'python -m pip install --upgrade "$(ls dist/eth-*-py3-none-any.whl)" --progress-bar off' + bash.exe -c 'python -m pip install --upgrade "$(ls dist/py_evm-*-py3-none-any.whl)" --progress-bar off' python -c "import eth" skip_install=true