diff --git a/.circleci/config.yml b/.circleci/config.yml index 169c3fa260..0e730dafb1 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 @@ -14,7 +14,7 @@ common: &common # this is necessary until circleci images begin using openssl>=3.0.7 name: update openssl.cnf for ripemd160 command: | - sudo tee -a /etc/ssl/openssl.cnf >/dev/null <<'EOF' + sudo tee -a /etc/ssl/openssl.cnf >/dev/null \<<'EOF' [openssl_init] providers = provider_sect @@ -41,7 +41,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: @@ -54,17 +54,42 @@ 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 - .tox - ~/.cache/pip - ~/.local - - ./eggs key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} resource_class: xlarge +orbs: + win: circleci/windows@5.0.0 + +windows_steps: &windows_steps + executor: + name: win/default + shell: bash.exe + working_directory: C:\Users\circleci\project\py-evm + 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 --upgrade pip + python -m pip install tox + - run: + name: run tox + command: python -m tox run -r + - save_cache: + paths: + - .tox + key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + jobs: docs: <<: *common @@ -127,61 +152,30 @@ jobs: - image: cimg/python:3.11 environment: TOXENV: py311-native-blockchain-petersburg - py311-native-blockchain-tangerine_whistle: + py311-native-blockchain-shanghai: <<: *common docker: - image: cimg/python:3.11 environment: - TOXENV: py311-native-blockchain-tangerine_whistle + TOXENV: py311-native-blockchain-shanghai py311-native-blockchain-spurious_dragon: <<: *common docker: - image: cimg/python:3.11 environment: TOXENV: py311-native-blockchain-spurious_dragon - py311-native-blockchain-transition: + py311-native-blockchain-tangerine_whistle: <<: *common docker: - image: cimg/python:3.11 environment: - TOXENV: py311-native-blockchain-transition - py311-native-blockchain-shanghai: + TOXENV: py311-native-blockchain-tangerine_whistle + py311-native-blockchain-transition: <<: *common docker: - image: cimg/python:3.11 environment: - TOXENV: py311-native-blockchain-shanghai - - py37-core: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-core - py37-database: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-database - py37-difficulty: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-difficulty - py37-transactions: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-transactions - py37-vm: - <<: *common - docker: - - image: cimg/python:3.7 - environment: - TOXENV: py37-vm + TOXENV: py311-native-blockchain-transition py38-core: <<: *common @@ -201,6 +195,12 @@ jobs: - image: cimg/python:3.8 environment: TOXENV: py38-difficulty + py38-lint: + <<: *common + docker: + - image: cimg/python:3.8 + environment: + TOXENV: py38-lint py38-transactions: <<: *common docker: @@ -213,12 +213,12 @@ jobs: - image: cimg/python:3.8 environment: TOXENV: py38-vm - py38-lint: + py38-wheel: <<: *common docker: - image: cimg/python:3.8 environment: - TOXENV: py38-lint + TOXENV: py38-wheel py39-core: <<: *common @@ -238,6 +238,12 @@ jobs: - image: cimg/python:3.9 environment: TOXENV: py39-difficulty + py39-lint: + <<: *common + docker: + - image: cimg/python:3.9 + environment: + TOXENV: py39-lint py39-transactions: <<: *common docker: @@ -250,12 +256,12 @@ jobs: - image: cimg/python:3.9 environment: TOXENV: py39-vm - py39-lint: + py39-wheel: <<: *common docker: - image: cimg/python:3.9 environment: - TOXENV: py39-lint + TOXENV: py39-wheel py310-core: <<: *common @@ -275,6 +281,12 @@ jobs: - image: cimg/python:3.10 environment: TOXENV: py310-difficulty + py310-lint: + <<: *common + docker: + - image: cimg/python:3.10 + environment: + TOXENV: py310-lint py310-transactions: <<: *common docker: @@ -287,12 +299,12 @@ jobs: - image: cimg/python:3.10 environment: TOXENV: py310-vm - py310-lint: + py310-wheel: <<: *common docker: - image: cimg/python:3.10 environment: - TOXENV: py310-lint + TOXENV: py310-wheel py311-core: <<: *common @@ -312,6 +324,12 @@ jobs: - image: cimg/python:3.11 environment: TOXENV: py311-difficulty + py311-lint: + <<: *common + docker: + - image: cimg/python:3.11 + environment: + TOXENV: py311-lint py311-transactions: <<: *common docker: @@ -324,57 +342,61 @@ jobs: - image: cimg/python:3.11 environment: TOXENV: py311-vm - py311-lint: + py311-wheel: <<: *common docker: - image: cimg/python:3.11 environment: - TOXENV: py311-lint + TOXENV: py311-wheel + py311-wheel-windows: + <<: *windows_steps + environment: + TOXENV: py311-wheel-windows workflows: version: 2 test: jobs: - docs - - py311-native-blockchain-shanghai - - py311-native-blockchain-merge - - py311-native-blockchain-london - py311-native-blockchain-berlin - py311-native-blockchain-byzantium - py311-native-blockchain-constantinople - py311-native-blockchain-frontier - py311-native-blockchain-homestead - py311-native-blockchain-istanbul + - py311-native-blockchain-london + - py311-native-blockchain-merge - py311-native-blockchain-petersburg - - py311-native-blockchain-tangerine_whistle + - py311-native-blockchain-shanghai - py311-native-blockchain-spurious_dragon + - py311-native-blockchain-tangerine_whistle - py311-native-blockchain-transition - - py37-vm - - py38-vm - - py39-vm - - py310-vm - - py311-vm - - py37-core - py38-core - py39-core - py310-core - py311-core - - py37-transactions - - py38-transactions - - py39-transactions - - py310-transactions - - py311-transactions - - py37-difficulty - - py38-difficulty - - py39-difficulty - - py310-difficulty - - py311-difficulty - - py37-database - py38-database - py39-database - py310-database - py311-database + - py38-difficulty + - py39-difficulty + - py310-difficulty + - py311-difficulty - py38-lint - py39-lint - py310-lint - py311-lint + - py38-transactions + - py39-transactions + - py310-transactions + - py311-transactions + - py38-vm + - py39-vm + - py310-vm + - py311-vm + - py38-wheel + - py39-wheel + - py310-wheel + - py311-wheel + - py311-wheel-windows diff --git a/.deepsource.toml b/.deepsource.toml index 0ca4912483..4233f99442 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 cb09ca2845..7ceefc8781 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/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000000..bb56c49d06 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,72 @@ +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: py-evm Version + description: Which version of py-evm 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 `python -m pip freeze` and paste the output below + render: shell + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yaml b/.github/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 0000000000..41a5d0f96d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Questions about using py-evm? + 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.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000000..041c8fd105 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -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 index 93fb355eb1..3baf402fc0 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,17 +1,18 @@ ### What was wrong? Related to Issue # -Closes Issue # +Closes # ### 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) +- [ ] Add entry to the [release notes](https://github.com/ethereum/py-evm/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/.gitignore b/.gitignore index 06918ad6d3..850a066aa6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.egg-info dist build +.build eggs .eggs parts @@ -20,6 +21,7 @@ lib lib64 pip-wheel-metadata venv* +.venv* # Installer logs pip-log.txt @@ -89,19 +91,34 @@ docs/*._utils.* # Blockchain chains -# Hypothese Property base testing +# Hypothesis Property base testing .hypothesis # tox/pytest cache .cache .pytest_cache +# pycache +__pycache__/ + # Test output logs logs # VIM temp files *.sw[op] +# mypy +.mypy_cache + +# macOS +.DS_Store + +# 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 @@ -118,9 +135,6 @@ out/ ## Plugin-specific files: -### mpeltonen/sbt-idea plugin -.idea_modules/ - ### JIRA plugin atlassian-ide-plugin.xml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..9838ad3af1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,50 @@ +exclude: '.project-template|docs/conf.py|.bumpversion.cfg' +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + - 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: + - 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/autoflake + rev: v2.2.1 + hooks: + - id: autoflake +- 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 + additional_dependencies: + - tomli # required until >= python311 +- repo: https://github.com/executablebooks/mdformat + rev: 0.7.17 + hooks: + - id: mdformat + additional_dependencies: + - mdformat-gfm +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.5.1 + hooks: + - id: mypy + files: eth/ diff --git a/.project-template/fill_template_vars.py b/.project-template/fill_template_vars.py index 4b08be8823..52ceb02b62 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): @@ -35,7 +35,7 @@ def _replace(pattern, replacement, project_root): def main(): project_root = Path(os.path.realpath(sys.argv[0])).parent.parent - module_name = input("What is your python module name (ex: What would you import (no dashes)? ") + 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 diff --git a/.pydocstyle.ini b/.pydocstyle.ini deleted file mode 100644 index 0d40aa8877..0000000000 --- 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/.readthedocs.yml b/.readthedocs.yaml similarity index 56% rename from .readthedocs.yml rename to .readthedocs.yaml index 50b9b38413..e55e07e4bd 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yaml @@ -6,7 +6,8 @@ build: python: "3.8" sphinx: - configuration: docs/conf.py + configuration: docs/conf.py + fail_on_warning: true python: install: @@ -14,3 +15,6 @@ python: path: . extra_requirements: - docs + +# Build all formats for RTD Downloads - htmlzip, pdf, epub +formats: all diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index d2029bf925..ae7bc5936a 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/MANIFEST.in b/MANIFEST.in index 22c6165d6f..a122460c5e 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 224d1ba58a..25f54f9d3d 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,13 @@ help: @echo "clean-build - remove build artifacts" @echo "clean-pyc - remove Python file artifacts" - @echo "lint - check style with flake8" + @echo "lint - fix linting issues with pre-commit" @echo "test - run tests quickly with the default Python" - @echo "testall - run tests on every Python version with tox" @echo "coverage - check code coverage quickly with the default Python" - @echo "docs - generate Sphinx HTML documentation, including API docs" - @echo "release - package and upload a release" + @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)" + @echo "dist - package" clean: clean-build clean-pyc @@ -23,18 +24,13 @@ clean-pyc: find . -name '__pycache__' -exec rm -rf {} + lint: - tox run -e lint - -lint-roll: - isort eth tests scripts - black eth tests scripts setup.py - $(MAKE) lint + @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: - py.test --tb native tests - -test-all: - tox + pytest tests coverage: coverage run --source eth @@ -42,8 +38,11 @@ coverage: coverage html open htmlcov/index.html -build-docs: clean - cd docs/; sphinx-build -W -T -E . _build/html +build-docs: + sphinx-apidoc -o docs/ . setup.py "*conftest*" + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(MAKE) -C docs doctest doctest: cd docs/; sphinx-build -T -b doctest . _build/doctest @@ -69,11 +68,14 @@ notes: 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: clean - # require that you be on a branch that's linked to upstream/master - git status -s -b | head -1 | grep "\.\.upstream/master" +release: check-bump clean + # 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 ./newsfragments/validate_files.py is-empty # verify that docs build correctly make build-docs diff --git a/README.md b/README.md index 706f2dd20d..c9581b1921 100644 --- a/README.md +++ b/README.md @@ -4,23 +4,22 @@ [![Build Status](https://circleci.com/gh/ethereum/py-evm.svg?style=shield)](https://circleci.com/gh/ethereum/py-evm) [![PyPI version](https://badge.fury.io/py/py-evm.svg)](https://badge.fury.io/py/py-evm) [![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)](http://py-evm.readthedocs.io/en/latest/?badge=latest) - +[![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 -primitives for the existing Ethereum 1.0 chain as well as emerging support for the upcoming -Ethereum 2.0 / Serenity spec. +primitives for the original proof-of-work (POW), (formerly known as Ethereum 1.0) chain +as well as emerging support for the proof-of-stake (POS) (formerly known as Ethereum 2.0) spec. ### Goals Py-EVM aims to eventually become the defacto Python implementation of the Ethereum protocol, -enabling a wide array of use cases for both public and private chains. +enabling a wide array of use cases for both public and private chains. In particular Py-EVM aims to: -- be a reference implementation of the Ethereum 1.0 and 2.0 implementation in one of the most widely used and understood languages, Python. +- be a reference implementation of the Ethereum POW and POS implementations in one of the most widely used and understood languages, Python. - be easy to understand and modifiable @@ -32,15 +31,57 @@ In particular Py-EVM aims to: - be highly flexible to support both research as well as alternate use cases like private chains. - ## Quickstart +```sh +python -m pip install py-evm +``` + [Get started in 5 minutes](https://py-evm.readthedocs.io/en/latest/guides/quickstart.html) ## Documentation Check out the [documentation on our official website](https://py-evm.readthedocs.io/en/latest/) +## Developer Setup + +If you would like to hack on py-evm, 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 +- 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 + +```sh +git clone git@github.com:ethereum/py-evm.git +cd py-evm +virtualenv -p python3 venv +. venv/bin/activate +python -m pip install -e ".[dev]" +pre-commit install +``` + +### Release setup + +To release a new version: + +```sh +make release bump=$$VERSION_PART_TO_BUMP$$ +``` + +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 +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). + ## Want to help? Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our diff --git a/docs/api/api.chain.rst b/docs/api/api.chain.rst index 1c9b3931ac..866fabd955 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 97fb44d826..8bfea882c8 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 0ef6d1e4b7..d9bf99d0e8 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 bc2459b9e5..7f1cb179c3 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 ff280346ee..c0239b7431 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 ca48246347..51e976b963 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 cf973da917..f8a4f9d8aa 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 4dd663f0dd..90d9c89673 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 2f6c63c2a4..7f9e6207ef 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 5c857c3b03..2e8c0cebbf 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 62a4e19c39..3d43bcc24e 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 857e4098c8..27a913aacc 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 38257a3a49..581a544aa5 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 109fdc3981..de4adc6cfc 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 48e8ac583a..1fb4b657aa 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 502bfbdbb7..1a66a3baa9 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 df0d2ac8fc..554e71b04f 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 665e7d683c..3513c5e6a7 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 eec084896e..7a1e1cc86c 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 4b19a71f61..d448387517 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,6 +44,7 @@ "sphinx.ext.doctest", "sphinx.ext.intersphinx", "sphinxcontrib.asyncio", + "sphinx_rtd_theme", ] autodoc_default_options = { @@ -66,9 +67,8 @@ master_doc = "index" # General information about the project. -project = about["__name__"] -copyright = "2017-2018 Ethereum Foundation" -author = about["__author__"] +project = "py-evm" +copyright = "2017-2023, The Ethereum Foundation" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -116,12 +116,12 @@ # 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"] 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 = "py-evmdoc" +htmlhelp_basename = "py-evmdocs" # -- Options for LaTeX output --------------------------------------------- diff --git a/docs/contributing.rst b/docs/contributing.rst index 926128c347..dd0ac8a3bd 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 c9571aba2a..6449b0c4f1 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 8257720c29..48e7cafef0 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 0d5da78aea..3c2c7ea8bb 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 9c24eba5d3..39ae7b0e68 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 f65585c1e6..e84c0c7191 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 e2dfed00b9..94b1be843d 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 61966a2ceb..b50de7e9d2 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 2c7cdd33e8..3d1a70587b 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 e38aee353c..172d903f57 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 4f135bf2f5..30595771df 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 254c589f7c..6638574a4a 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 fe776af97b..03448c1b88 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 04c778c7e2..da584a9e93 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 8c99519d23..c678f8b2e7 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 d24349836e..bce411b28d 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 a73f6a9311..84b33f7ea8 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 252d55428d..0947784d45 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 0d1666e73e..a59a7cab2c 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 0de96e43a5..5480f541c3 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 36124e9ed5..bd9d8fc978 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 66fe444617..eeb317e124 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 7828a7849d..390b75a77f 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 4eacb91cf4..d86b61bea2 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 afa47142ce..db1b515f42 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 a7a08f55aa..fcc22d3aba 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 5604582a72..78c5505974 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 f115990ce1..2ca637bdf1 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 018532c121..31b982d08a 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 3c04578330..b15a4ef5df 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 e18c7e95f7..e153a2ee9b 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 4f06dbc7ce..1667e4e674 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 994f2726a1..416a1775f3 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 765746a11d..a586f7b0ff 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 752c291e9a..e686d49b2d 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 e1ef3ab1af..87db689921 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 89fb588371..1c3a6f715f 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 616c109518..4b5db44897 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 b80a7076e7..26fe674d9c 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 dee2c5113b..648a6c0e19 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 49be9d0dd4..7efe1a81a1 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 aac7c08773..7d644bdb21 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 40004d0be6..fd4bea1203 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 9906c0852d..ce4097ec6e 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 c97dedb539..e6b76a4871 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 672a9c10d3..9e826d05d3 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 028186ef28..c2669010bb 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 58c45ab1c2..eebc0bd454 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 02742c7873..e98750da78 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 632248b744..1b4d5a33e6 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 f440552522..a27c1475c7 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 e9d477ee33..bdb23273d8 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 a6db4c1b03..db2615b719 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 2a7d8ab7b1..b555908dd3 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 5a82bb2e8a..6f942eddc0 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 7433825e16..f9ed715544 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 7832f2afc7..1bfa2f6adf 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 3a05f6d4dd..7b04765e3e 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 043c291512..0202119f38 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 773234330d..4db8b80825 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 cf83e548e7..df5aab2683 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/mypy.ini b/mypy.ini deleted file mode 100644 index 12decefb24..0000000000 --- a/mypy.ini +++ /dev/null @@ -1,16 +0,0 @@ -[mypy] - -; TODO: after dropping py39, try enabling this again: -warn_unused_ignores = False - -warn_unused_configs = True -warn_redundant_casts = True -; TODO: Drop ignore-missing-imports after adding type annotations for eth_utils, coincurve & cytoolz -ignore_missing_imports = True -strict_optional = False -check_untyped_defs = True -disallow_incomplete_defs = True -disallow_untyped_defs = True -disallow_untyped_calls = True -disallow_any_generics = True - diff --git a/newsfragments/2128.breaking.rst b/newsfragments/2128.breaking.rst new file mode 100644 index 0000000000..76d2ab9203 --- /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 0000000000..7482faa818 --- /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/newsfragments/README.md b/newsfragments/README.md index 9c986ebf70..177d649257 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` -* `bugfix` -* `performance` -* `docs` -* `internal` -* `removal` -* `misc` -* `breaking` +- `breaking` +- `bugfix` +- `deprecation` +- `docs` +- `feature` +- `internal` +- `misc` +- `performance` +- `removal` So for example: `123.feature.rst`, `456.bugfix.rst` @@ -25,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. diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py index 52520e65d9..02b0e3efbf 100755 --- a/newsfragments/validate_files.py +++ b/newsfragments/validate_files.py @@ -9,6 +9,7 @@ ALLOWED_EXTENSIONS = { ".breaking.rst", ".bugfix.rst", + ".deprecation.rst", ".docs.rst", ".feature.rst", ".internal.rst", @@ -30,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/pyproject.toml b/pyproject.toml index 24b5835d65..58e1726daf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,76 @@ +[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 = "eth" +multi_line_output = 3 +profile = "black" +# skip `__init__.py` files because sometimes order of initialization is important +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 +# TODO: Drop ignore-missing-imports after adding type annotations for eth_utils, coincurve & cytoolz +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 + + +[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 +# 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,D404,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" +timeout = 300 + [tool.towncrier] -# Read https://github.com/ethereum/py-evm/newsfragments/README.md for instructions +# Read https://github.com/ethereum/py-evm/blob/main/newsfragments/README.md for instructions package = "eth" filename = "docs/release_notes.rst" directory = "newsfragments" @@ -8,8 +79,8 @@ title_format = "py-evm v{version} ({project_date})" issue_format = "`#{issue} `__" [[tool.towncrier.type]] -directory = "feature" -name = "Features" +directory = "breaking" +name = "Breaking Changes" showcontent = true [[tool.towncrier.type]] @@ -18,8 +89,8 @@ name = "Bugfixes" showcontent = true [[tool.towncrier.type]] -directory = "performance" -name = "Performance improvements" +directory = "deprecation" +name = "Deprecations" showcontent = true [[tool.towncrier.type]] @@ -28,8 +99,8 @@ name = "Improved Documentation" showcontent = true [[tool.towncrier.type]] -directory = "removal" -name = "Deprecations and Removals" +directory = "feature" +name = "Features" showcontent = true [[tool.towncrier.type]] @@ -39,10 +110,15 @@ 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/pytest.ini b/pytest.ini deleted file mode 100644 index b38d4593c0..0000000000 --- a/pytest.ini +++ /dev/null @@ -1,9 +0,0 @@ -[pytest] -addopts= --showlocals --durations 50 -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/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/scripts/benchmark/_utils/reporting.py b/scripts/benchmark/_utils/reporting.py index cef6fc3245..ace292e926 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 24bed5c17d..440f206d54 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 1097f6f63b..1fa3f96571 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 a4b3502de8..8bff29f278 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 b96f7e2fc8..d64e9418b1 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 041417391a..cce9beafee 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 079a27b28f..761964a593 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 57846c4668..10dfa097b9 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 0323039bb3..127b6b162b 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 c50b137494..10a36507f9 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 74a4db78e3..633640efc1 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 348778b04a..29a7501caa 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 693c5f59ae..2913cdca9c 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 7bb3a5f9e4..7429361f78 100644 --- a/setup.py +++ b/setup.py @@ -1,88 +1,66 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- from setuptools import ( - setup, find_packages, + setup, ) - extras_require = { + "benchmark": [ + "termcolor>=1.1.0", + "web3>=6.0.0", + ], + "dev": [ + "build>=0.9.0", + "bumpversion>=0.5.3", + "ipython", + "pre-commit>=3.4.0", + "tox>=4.0.0", + "twine", + "wheel", + ], + "docs": [ + "py-evm>=0.8.0b1", + "sphinx>=6.0.0", + "sphinx_rtd_theme>=1.0.0", + "sphinxcontrib-asyncio>=0.2.0", + "towncrier>=21,<22", + ], "eth": [ - "cached-property>=1.5.1,<2", + "cached-property>=1.5.1", "eth-bloom>=1.0.3", - "eth-keys>=0.4.0,<0.5.0", - "eth-typing>=3.3.0,<4.0.0", - "eth-utils>=2.0.0,<3.0.0", + "eth-keys>=0.4.0", + "eth-typing>=3.3.0", + "eth-utils>=2.0.0", "lru-dict>=1.1.6", - "mypy-extensions>=1.0.0", - "py-ecc>=1.4.7,<7.0.0", - "rlp>=3,<4", - "trie>=2.0.0,<3", + "py-ecc>=1.4.7", + "rlp>=3.0.0", + "trie>=2.0.0", ], # The eth-extra sections is for libraries that the evm does not # explicitly need to function and hence should not depend on. # 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>=6.2.4,<7", - "pytest-asyncio>=0.10.0,<0.11", - "pytest-cov==2.5.1", - "pytest-timeout>=2.0.0,<3", - "pytest-watch>=4.1.0,<5", + "pytest>=7.0.0", + "pytest-asyncio>=0.20.0", + "pytest-cov>=4.0.0", + "pytest-timeout>=2.0.0", "pytest-xdist>=3.0", - "importlib-metadata<5.0;python_version<'3.8'", - ], - "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==1.4.0", # mypy does not follow semver, leave it pinned. - "pydocstyle>=6.0.0", - "black>=23", - "types-setuptools", - "importlib-metadata<5.0;python_version<'3.8'", - ], - "benchmark": [ - "termcolor>=1.1.0,<2.0.0", - "web3>=4.1.0,<5.0.0", - ], - "docs": [ - "py-evm>=0.2.0-a.14", - # We need to have pysha for autodoc to be able to extract API docs - "Sphinx>=1.5.5,<2", - "jinja2>=3.0.0,<3.1.0", # jinja2<3.0 or >=3.1.0 cause doc build failures. - "sphinx_rtd_theme>=0.1.9", - "sphinxcontrib-asyncio>=0.2.0,<0.4", - "towncrier>=21,<22", - ], - "dev": [ - "bumpversion>=0.5.3,<1", - "wheel", - "setuptools>=36.2.0", - # Fixing this dependency due to: requests 2.20.1 has requirement - # idna<2.8,>=2.5, but you'll have idna 2.8 which is incompatible. - "idna==2.7", - # idna 2.7 is not supported by requests 2.18 - "requests>=2.20,<3", - "tox>=4.0.0", - "twine", ], } extras_require["dev"] = ( extras_require["dev"] + + extras_require["docs"] + extras_require["eth"] + extras_require["test"] - + extras_require["lint"] - + extras_require["docs"] ) install_requires = extras_require["eth"] @@ -98,11 +76,12 @@ 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"], install_requires=install_requires, + python_requires=">=3.8, <4", extras_require=extras_require, license="MIT", zip_safe=False, @@ -114,7 +93,7 @@ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", - "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/tests/conftest.py b/tests/conftest.py index bb476d43ed..ca360ede6d 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 d71575e0c1..7a230e24e8 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 57e8c0d55e..7a931faf22 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 e14557dcaa..ef2d98a9f4 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 6773f935a1..2eb264b093 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 5a8f0526eb..06f1985a9a 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 4be5784da9..36eaa28566 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 465b3bbb41..27cf787820 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 811b073259..b2e5ddf408 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 48d63448eb..982a863cd8 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 64687a27e0..483581c0a0 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 5f58098660..0844732df0 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 55f25dcd84..20038c8b16 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 a93f3d49c4..188b921ed0 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 0be8d55774..2fd312d536 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 3bea0a1706..4982abc211 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 e7e68ff0c1..f53303c521 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 2ccf8ac285..464c847056 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 6480ebd84a..ef541268dc 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 1d495f8d0b..ead7f884fc 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 c616629e9f..87b638fbdb 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 58864d749f..68096576ae 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 ea95d9b9b9..749aeb5ca2 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 56f60930be..628375ed6e 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 92c9a62e20..6dfe325b29 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 b406bf9a1c..2b84bbe396 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 c37cc78745..6483583f07 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 56485529e2..7ffecb827b 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 4bedeb891e..d60047d238 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/test-import.py b/tests/core/test_import.py similarity index 100% rename from tests/core/test-import.py rename to tests/core/test_import.py diff --git a/tests/core/tester/test_generate_vm_configuration.py b/tests/core/tester/test_generate_vm_configuration.py index 43c24d2aea..f127bbd9b8 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 99fd4c00af..5064f17e22 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 f6a3db130d..62567d0a34 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 ac339aeb9d..b41eb08848 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 b909d44798..74a145bf67 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 7eaa1ae050..67878fdf8b 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 c28c0762a4..867ff65fae 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 bf77fc3044..e7ad0ab8ee 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 f9150ea99a..861da0f0a1 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 b11accd5b5..447a08ad6a 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 0a375aa5eb..54cabb7996 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 268b2a9296..6f17aa0781 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 998ee57f46..5c061f1af7 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 84f072cf24..2c55fde2b4 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 9b23752d43..91342576bc 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 2143aed397..190231cce9 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 436cbfc67e..caccd63ab5 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 f97a0e68af..c13d6962a9 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 e3fb8d9745..ec7d327af2 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 512c815dd8..37c80c77ac 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 5d4093ed22..370b1a2561 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 aa649df0dd..44d1acbe88 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 47613abb44..4dca10830a 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 826cfc7019..9e4c425a05 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 8ca288ece6..246f021afa 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 fc9174562c..e46ea7342a 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 4b4c287afd..a6282318e6 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 3decc25021..d2a8498a65 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 eb4e343d2b..adc216ddcf 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 e66e87f316..02e0d64233 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 ae7d3c3e71..6436800a24 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 7609044644..690149d22f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,35 +1,27 @@ [tox] envlist= - py{37,38,39,310,311}-{core,database,difficulty,transactions,vm} + py{38,39,310,311}-core + py{38,39,310,311}-database + py{38,39,310,311}-difficulty + py{38,39,310,311}-lint + py{38,39,310,311}-transactions + py{38,39,310,311}-vm + py{38,39,310,311}-wheel + py311-wheel-windows + docs py311-native-blockchain-{ \ metropolis, transition, frontier, homestead, tangerine_whistle, \ spurious_dragon, byzantium, constantinople, petersburg, istanbul, \ berlin, london, merge, shanghai \ } - py{38,39,310,311}-lint - docs - -[isort] -combine_as_imports=True -extra_standard_library=pytest -force_grid_wrap=1 -force_sort_within_sections=True -known_first_party=eth -multi_line_output=3 -profile=black -# skip `__init__.py` files because sometimes order of initialization is important -skip=__init__.py [flake8] -max-line-length= 88 exclude=venv*,.tox,docs,build -extend-ignore= E203,W503 +extend-ignore=E203 +max-line-length=88 +per-file-ignores=__init__.py:F401 [testenv] -usedevelop=True -passenv = - PYTEST_ADDOPTS - TRAVIS_EVENT_TYPE commands= core: pytest {posargs:tests/core/} docs: make validate-docs @@ -53,7 +45,6 @@ commands= native-blockchain-shanghai: pytest {posargs:tests/json-fixtures/blockchain/test_blockchain.py --fork Shanghai} basepython = docs: python - py37: python3.7 py38: python3.8 py39: python3.9 py310: python3.10 @@ -62,23 +53,39 @@ extras= docs eth-extra test -allowlist_externals=make +allowlist_externals=make,pre-commit -[common-lint] -basepython=python -extras=lint -allowlist_externals=black +[testenv:py{38,39,310,311}-lint] +deps=pre-commit commands= - flake8 {toxinidir}/eth {toxinidir}/tests {toxinidir}/scripts - mypy -p eth --config-file {toxinidir}/mypy.ini - isort --check-only --diff {toxinidir}/eth/ {toxinidir}/tests/ {toxinidir}/scripts/ - black --check {toxinidir}/eth {toxinidir}/docs {toxinidir}/tests {toxinidir}/scripts/ {toxinidir}/setup.py + pre-commit install + pre-commit run --all-files --show-diff-on-failure -[testenv:lint] -basepython: python -extras: {[common-lint]extras} -commands: {[common-lint]commands} +[testenv:py{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/py_evm-*-py3-none-any.whl)" --progress-bar off' + python -c "import eth" +skip_install=true -[testenv:py{38,39,310,311}-lint] -extras: {[common-lint]extras} -commands: {[common-lint]commands} +[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/py_evm-*-py3-none-any.whl)" --progress-bar off' + python -c "import eth" +skip_install=true