From dfcea1abd1b98b526d53ad10cfa4637418ae041e Mon Sep 17 00:00:00 2001 From: Prathmesh Ranaut Date: Sun, 23 Apr 2023 13:05:21 +0530 Subject: [PATCH] Linted files in ETH and tests directory --- .isort.cfg | 2 +- Makefile | 2 +- eth/_utils/address.py | 9 +- eth/_utils/blake2/coders.py | 4 +- eth/_utils/bn128.py | 15 +-- eth/_utils/datatypes.py | 22 +++-- eth/_utils/env.py | 2 - eth/_utils/generator.py | 1 - eth/_utils/headers.py | 12 ++- eth/_utils/module_loading.py | 5 +- eth/_utils/numeric.py | 8 +- eth/_utils/padding.py | 1 - eth/_utils/rlp.py | 11 +-- eth/_utils/spoof.py | 11 +-- eth/_utils/state.py | 4 +- eth/_utils/transactions.py | 30 +++--- eth/_utils/version.py | 4 +- eth/_warnings.py | 8 +- eth/abc.py | 29 +++--- eth/chains/base.py | 38 ++++---- eth/chains/goerli/constants.py | 5 +- eth/chains/header.py | 8 +- eth/chains/mainnet/constants.py | 5 +- eth/chains/ropsten/constants.py | 5 +- eth/consensus/clique/_utils.py | 14 ++- eth/consensus/clique/clique.py | 29 +++--- eth/consensus/clique/constants.py | 4 +- eth/consensus/clique/datatypes.py | 6 +- eth/consensus/clique/encoding.py | 8 +- eth/consensus/clique/exceptions.py | 4 +- eth/consensus/clique/snapshot_manager.py | 41 +++++---- eth/consensus/noproof.py | 1 + eth/consensus/pos.py | 1 + eth/consensus/pow.py | 15 ++- eth/constants.py | 16 +++- eth/db/accesslog.py | 14 +-- eth/db/account.py | 41 +++++---- eth/db/atomic.py | 14 ++- eth/db/backends/level.py | 20 ++-- eth/db/batch.py | 8 +- eth/db/cache.py | 12 ++- eth/db/chain.py | 55 +++++++---- eth/db/chain_gaps.py | 18 +++- eth/db/diff.py | 14 ++- eth/db/hash_trie.py | 10 +- eth/db/header.py | 43 +++++---- eth/db/journal.py | 32 +++++-- eth/db/keymap.py | 9 +- eth/db/schema.py | 4 +- eth/db/slow_journal.py | 26 ++++-- eth/db/storage.py | 10 +- eth/db/trie.py | 12 ++- eth/estimators/gas.py | 18 +++- eth/exceptions.py | 4 +- eth/precompiles/blake2.py | 12 ++- eth/precompiles/ecadd.py | 19 ++-- eth/precompiles/ecmul.py | 21 +++-- eth/precompiles/ecpairing.py | 27 +++--- eth/precompiles/ecrecover.py | 15 +-- eth/precompiles/identity.py | 5 +- eth/precompiles/modexp.py | 8 +- eth/precompiles/ripemd160.py | 5 +- eth/precompiles/sha256.py | 6 +- eth/rlp/accounts.py | 14 ++- eth/rlp/headers.py | 29 +++--- eth/rlp/logs.py | 13 +-- eth/rlp/receipts.py | 14 ++- eth/rlp/sedes.py | 1 - eth/rlp/transactions.py | 24 +++-- eth/tools/_utils/deprecation.py | 3 +- eth/tools/_utils/git.py | 4 +- eth/tools/_utils/hashing.py | 8 +- eth/tools/_utils/mappings.py | 9 +- eth/tools/_utils/normalization.py | 33 +++---- eth/tools/_utils/slow_code_stream.py | 6 +- eth/tools/_utils/vyper.py | 7 +- eth/tools/builder/chain/builders.py | 56 +++++++----- eth/tools/db/atomic.py | 8 +- eth/tools/db/base.py | 4 +- eth/tools/factories/keys.py | 12 ++- eth/tools/factories/transaction.py | 4 +- eth/tools/fixtures/_utils.py | 5 +- eth/tools/fixtures/fillers/_utils.py | 12 ++- eth/tools/fixtures/fillers/common.py | 25 +++-- eth/tools/fixtures/fillers/formatters.py | 6 +- eth/tools/fixtures/fillers/main.py | 13 ++- eth/tools/fixtures/fillers/state.py | 49 +++++++--- eth/tools/fixtures/fillers/vm.py | 12 ++- eth/tools/fixtures/generation.py | 1 - eth/tools/fixtures/helpers.py | 39 ++++---- eth/tools/fixtures/loading.py | 6 +- eth/tools/mining.py | 2 +- eth/tools/rlp.py | 3 +- eth/typing.py | 4 +- eth/validation.py | 23 +++-- eth/vm/base.py | 32 ++++--- eth/vm/chain_context.py | 8 +- eth/vm/code_stream.py | 6 +- eth/vm/computation/base_computation.py | 17 ++-- eth/vm/computation/message_computation.py | 12 ++- eth/vm/execution_context.py | 8 +- eth/vm/forks/arrow_glacier/blocks.py | 18 ++-- eth/vm/forks/arrow_glacier/computation.py | 4 +- eth/vm/forks/arrow_glacier/headers.py | 27 ++++-- eth/vm/forks/arrow_glacier/state.py | 21 ++++- eth/vm/forks/arrow_glacier/transactions.py | 8 +- eth/vm/forks/berlin/blocks.py | 4 +- eth/vm/forks/berlin/computation.py | 20 ++-- eth/vm/forks/berlin/headers.py | 3 +- eth/vm/forks/berlin/logic.py | 18 +++- eth/vm/forks/berlin/opcodes.py | 32 ++++--- eth/vm/forks/berlin/receipts.py | 17 +++- eth/vm/forks/berlin/state.py | 12 ++- eth/vm/forks/berlin/transactions.py | 51 +++++++---- eth/vm/forks/byzantium/blocks.py | 1 + eth/vm/forks/byzantium/computation.py | 16 +++- eth/vm/forks/byzantium/constants.py | 4 +- eth/vm/forks/byzantium/headers.py | 21 +++-- eth/vm/forks/byzantium/opcodes.py | 37 +++++--- eth/vm/forks/byzantium/state.py | 8 +- eth/vm/forks/byzantium/transactions.py | 9 +- eth/vm/forks/constantinople/blocks.py | 1 + eth/vm/forks/constantinople/computation.py | 12 +-- eth/vm/forks/constantinople/constants.py | 5 +- eth/vm/forks/constantinople/headers.py | 3 +- eth/vm/forks/constantinople/opcodes.py | 12 +-- eth/vm/forks/constantinople/state.py | 6 +- eth/vm/forks/constantinople/storage.py | 6 +- eth/vm/forks/constantinople/transactions.py | 15 +-- eth/vm/forks/frontier/blocks.py | 9 +- eth/vm/forks/frontier/computation.py | 25 ++--- eth/vm/forks/frontier/headers.py | 37 ++++---- eth/vm/forks/frontier/opcodes.py | 20 ++-- eth/vm/forks/frontier/state.py | 35 ++++--- eth/vm/forks/frontier/transaction_context.py | 4 +- eth/vm/forks/frontier/transactions.py | 51 ++++++----- eth/vm/forks/gray_glacier/blocks.py | 22 +++-- eth/vm/forks/gray_glacier/computation.py | 4 +- eth/vm/forks/gray_glacier/headers.py | 19 ++-- eth/vm/forks/gray_glacier/state.py | 21 ++++- eth/vm/forks/gray_glacier/transactions.py | 8 +- eth/vm/forks/homestead/blocks.py | 2 + eth/vm/forks/homestead/computation.py | 19 ++-- eth/vm/forks/homestead/headers.py | 22 +++-- eth/vm/forks/homestead/opcodes.py | 28 ++++-- eth/vm/forks/homestead/state.py | 12 ++- eth/vm/forks/homestead/transactions.py | 31 ++++--- eth/vm/forks/homestead/validation.py | 7 +- eth/vm/forks/istanbul/blocks.py | 1 + eth/vm/forks/istanbul/computation.py | 14 +-- eth/vm/forks/istanbul/headers.py | 3 +- eth/vm/forks/istanbul/opcodes.py | 24 +++-- eth/vm/forks/istanbul/state.py | 6 +- eth/vm/forks/istanbul/storage.py | 14 ++- eth/vm/forks/istanbul/transactions.py | 21 +++-- eth/vm/forks/london/blocks.py | 14 +-- eth/vm/forks/london/computation.py | 12 ++- eth/vm/forks/london/headers.py | 17 +++- eth/vm/forks/london/opcodes.py | 29 +++--- eth/vm/forks/london/receipts.py | 10 +- eth/vm/forks/london/state.py | 32 ++++--- eth/vm/forks/london/storage.py | 9 +- eth/vm/forks/london/transactions.py | 36 ++++++-- eth/vm/forks/london/validation.py | 6 +- eth/vm/forks/muir_glacier/blocks.py | 1 + eth/vm/forks/muir_glacier/computation.py | 8 +- eth/vm/forks/muir_glacier/headers.py | 7 +- eth/vm/forks/muir_glacier/opcodes.py | 2 +- eth/vm/forks/muir_glacier/state.py | 6 +- eth/vm/forks/muir_glacier/transactions.py | 15 +-- eth/vm/forks/paris/blocks.py | 19 ++-- eth/vm/forks/paris/computation.py | 9 +- eth/vm/forks/paris/headers.py | 26 ++++-- eth/vm/forks/paris/opcodes.py | 32 +++++-- eth/vm/forks/paris/state.py | 22 ++++- eth/vm/forks/paris/transactions.py | 8 +- eth/vm/forks/petersburg/blocks.py | 1 + eth/vm/forks/petersburg/computation.py | 10 +- eth/vm/forks/petersburg/constants.py | 5 +- eth/vm/forks/petersburg/headers.py | 3 +- eth/vm/forks/petersburg/opcodes.py | 17 ++-- eth/vm/forks/petersburg/state.py | 6 +- eth/vm/forks/petersburg/transactions.py | 15 +-- eth/vm/forks/shanghai/blocks.py | 91 +++++++++++++------ eth/vm/forks/shanghai/computation.py | 19 ++-- eth/vm/forks/shanghai/constants.py | 4 +- eth/vm/forks/shanghai/headers.py | 22 +++-- eth/vm/forks/shanghai/logic.py | 9 +- eth/vm/forks/shanghai/opcodes.py | 41 ++++++--- eth/vm/forks/shanghai/state.py | 17 +++- eth/vm/forks/shanghai/transactions.py | 8 +- eth/vm/forks/shanghai/withdrawals.py | 32 +++++-- eth/vm/forks/spurious_dragon/_utils.py | 24 +++-- eth/vm/forks/spurious_dragon/blocks.py | 2 + eth/vm/forks/spurious_dragon/computation.py | 19 ++-- eth/vm/forks/spurious_dragon/opcodes.py | 33 ++++--- eth/vm/forks/spurious_dragon/state.py | 12 ++- eth/vm/forks/spurious_dragon/transactions.py | 22 +++-- eth/vm/forks/tangerine_whistle/computation.py | 9 +- eth/vm/forks/tangerine_whistle/opcodes.py | 27 ++++-- eth/vm/forks/tangerine_whistle/state.py | 8 +- eth/vm/gas_meter.py | 5 +- eth/vm/header.py | 4 +- eth/vm/logic/arithmetic.py | 14 +-- eth/vm/logic/block.py | 4 +- eth/vm/logic/call.py | 16 ++-- eth/vm/logic/comparison.py | 10 +- eth/vm/logic/context.py | 25 ++--- eth/vm/logic/duplication.py | 4 +- eth/vm/logic/flow.py | 9 +- eth/vm/logic/invalid.py | 12 ++- eth/vm/logic/logging.py | 14 ++- eth/vm/logic/memory.py | 4 +- eth/vm/logic/sha3.py | 12 ++- eth/vm/logic/stack.py | 4 +- eth/vm/logic/storage.py | 12 ++- eth/vm/logic/swap.py | 4 +- eth/vm/logic/system.py | 28 ++++-- eth/vm/memory.py | 11 ++- eth/vm/message.py | 12 ++- eth/vm/opcode.py | 6 +- eth/vm/spoof.py | 14 ++- eth/vm/stack.py | 10 +- eth/vm/state.py | 16 ++-- eth/vm/transaction_context.py | 8 +- tests/conftest.py | 50 ++++++---- .../address-utils/test_address_generation.py | 3 +- .../core/builder-tools/test_chain_builder.py | 13 ++- .../builder-tools/test_chain_construction.py | 30 +++--- .../builder-tools/test_chain_initializer.py | 15 ++- .../test_build_block_incrementally.py | 11 ++- tests/core/chain-object/test_chain.py | 37 +++++--- .../chain-object/test_chain_get_ancestors.py | 12 ++- .../chain-object/test_chain_reorganization.py | 9 +- .../test_chain_retrieval_of_vm_class.py | 9 +- tests/core/chain-object/test_contract_call.py | 29 +++--- .../chain-object/test_create_transaction.py | 16 +++- .../core/chain-object/test_gas_estimation.py | 28 +++--- tests/core/code-stream/test_code_stream.py | 25 +++-- tests/core/consensus/test_clique_consensus.py | 47 ++++++---- tests/core/consensus/test_clique_encoding.py | 14 ++- tests/core/consensus/test_clique_utils.py | 22 +++-- tests/core/consensus/test_consensus_engine.py | 16 ++-- tests/core/consensus/test_pow_mining.py | 12 ++- .../fixture-tools/test_normalize_state.py | 7 +- tests/core/fixtures.py | 1 - tests/core/gas_meter/test_gas_meter.py | 8 +- .../generator-utils/test_cached_iterable.py | 7 +- tests/core/helpers.py | 10 +- .../test_encode_and_decode.py | 3 +- .../message-object/test_message_object.py | 9 +- .../core/numeric-utils/test_int_to_bytes32.py | 7 +- .../numeric-utils/test_integer_squareroot.py | 1 + tests/core/opcodes/test_opcodes.py | 61 +++++++------ tests/core/padding-utils/test_padding.py | 2 +- tests/core/precompiles/test_blake2.py | 10 +- tests/core/stack/test_stack.py | 6 +- .../tester/test_generate_vm_configuration.py | 7 +- tests/core/transaction-utils/conftest.py | 1 - .../test_receipt_encoding.py | 11 ++- .../test_transaction_encoding.py | 7 +- .../test_transaction_signature_validation.py | 23 +++-- tests/core/validation/test_eth1_validation.py | 4 +- .../validation/test_transaction_validation.py | 12 ++- .../validation/test_withdrawal_validation.py | 13 ++- tests/core/vm/conftest.py | 9 +- tests/core/vm/test_base_computation.py | 8 +- tests/core/vm/test_clique_validation.py | 13 +-- tests/core/vm/test_computation.py | 25 +++-- tests/core/vm/test_frontier_computation.py | 6 +- tests/core/vm/test_interrupt.py | 4 +- tests/core/vm/test_london.py | 31 +++++-- tests/core/vm/test_mainnet_dao_fork.py | 11 ++- tests/core/vm/test_modexp_precompile.py | 2 +- tests/core/vm/test_rewards.py | 24 ++--- tests/core/vm/test_shanghai.py | 16 +++- tests/core/vm/test_validate_transaction.py | 25 +++-- tests/core/vm/test_vm.py | 14 ++- tests/core/vm/test_vm_state.py | 11 ++- tests/database/test_accesslog.py | 9 +- tests/database/test_account_db.py | 19 ++-- tests/database/test_atomic_database_api.py | 17 +++- tests/database/test_batch_db.py | 9 +- tests/database/test_database_api.py | 26 ++++-- tests/database/test_eth1_chaindb.py | 43 +++++---- tests/database/test_hash_trie.py | 9 +- tests/database/test_header_db.py | 46 +++++----- tests/database/test_journal_db.py | 29 ++++-- tests/database/test_leveldb_db_backend.py | 9 +- tests/fillers/build_json.py | 15 +-- .../blockchain/test_blockchain.py | 21 +++-- tests/json-fixtures/test_difficulty.py | 27 ++++-- tests/json-fixtures/test_transactions.py | 65 ++++++------- tests/json-fixtures/test_virtual_machine.py | 33 ++++--- 294 files changed, 2786 insertions(+), 1676 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index 46b3001233..95cfb2bf09 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -8,7 +8,7 @@ combine_as_imports=true force_sort_within_sections=true include_trailing_comma=true extra_standard_library=pytest -known_first_party=eth +known_first_party=eth tests line_length=88 use_parentheses=true # skip `__init__.py` files because sometimes order of initialization is important diff --git a/Makefile b/Makefile index 92e9582d36..652d4a6c23 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ lint: tox run -e lint lint-roll: - isort eth + isort eth tests $(MAKE) lint test: diff --git a/eth/_utils/address.py b/eth/_utils/address.py index 54f6943c57..66a5a3925d 100644 --- a/eth/_utils/address.py +++ b/eth/_utils/address.py @@ -1,8 +1,11 @@ +from eth_hash.auto import ( + keccak, +) +from eth_typing import ( + Address, +) import rlp -from eth_hash.auto import keccak -from eth_typing import Address - from eth._utils.numeric import ( int_to_bytes32, ) diff --git a/eth/_utils/blake2/coders.py b/eth/_utils/blake2/coders.py index 02a9520314..9c40168587 100644 --- a/eth/_utils/blake2/coders.py +++ b/eth/_utils/blake2/coders.py @@ -1,13 +1,13 @@ from typing import ( - cast, Iterable, Tuple, + cast, ) from eth_utils import ( + ValidationError, to_int, to_tuple, - ValidationError, ) from .compression import ( diff --git a/eth/_utils/bn128.py b/eth/_utils/bn128.py index a1a31a4092..d117dd7588 100644 --- a/eth/_utils/bn128.py +++ b/eth/_utils/bn128.py @@ -1,17 +1,18 @@ +from typing import ( + Tuple, +) + +from eth_utils import ( + ValidationError, +) from py_ecc import ( optimized_bn128 as bn128, ) from py_ecc.optimized_bn128 import ( - FQP, FQ2, + FQP, ) -from eth_utils import ( - ValidationError, -) - -from typing import Tuple - def validate_point(x: int, y: int) -> Tuple[bn128.FQ, bn128.FQ, bn128.FQ]: FQ = bn128.FQ diff --git a/eth/_utils/datatypes.py b/eth/_utils/datatypes.py index 8dd7b84d09..87894c134d 100644 --- a/eth/_utils/datatypes.py +++ b/eth/_utils/datatypes.py @@ -1,17 +1,25 @@ -from eth_utils.toolz import ( - assoc, - groupby, +from typing import ( + Any, + Dict, + Iterator, + List, + Tuple, + Type, + TypeVar, ) from eth_utils import ( to_dict, to_set, ) +from eth_utils.toolz import ( + assoc, + groupby, +) - -from typing import Any, Dict, Tuple, Type, TypeVar, Iterator, List - -from eth.abc import ConfigurableAPI +from eth.abc import ( + ConfigurableAPI, +) def _is_local_prop(prop: str) -> bool: diff --git a/eth/_utils/env.py b/eth/_utils/env.py index 8e049b7a27..9ad130829b 100644 --- a/eth/_utils/env.py +++ b/eth/_utils/env.py @@ -4,7 +4,6 @@ """ import os - from typing import ( Any, Callable, @@ -16,7 +15,6 @@ Union, ) - # No set literals because we support Python 2.6. TRUE_VALUES = { True, diff --git a/eth/_utils/generator.py b/eth/_utils/generator.py index 5f1b52276f..0cb26fbe96 100644 --- a/eth/_utils/generator.py +++ b/eth/_utils/generator.py @@ -7,7 +7,6 @@ TypeVar, ) - TItem = TypeVar('TItem') diff --git a/eth/_utils/headers.py b/eth/_utils/headers.py index a91dec309b..0252b6a990 100644 --- a/eth/_utils/headers.py +++ b/eth/_utils/headers.py @@ -9,17 +9,19 @@ Address, ) -from eth.abc import BlockHeaderAPI +from eth.abc import ( + BlockHeaderAPI, +) from eth.constants import ( BLANK_ROOT_HASH, - GENESIS_BLOCK_NUMBER, - GENESIS_PARENT_HASH, - GAS_LIMIT_EMA_DENOMINATOR, GAS_LIMIT_ADJUSTMENT_FACTOR, + GAS_LIMIT_EMA_DENOMINATOR, GAS_LIMIT_MAXIMUM, GAS_LIMIT_MINIMUM, - GAS_LIMIT_USAGE_ADJUSTMENT_NUMERATOR, GAS_LIMIT_USAGE_ADJUSTMENT_DENOMINATOR, + GAS_LIMIT_USAGE_ADJUSTMENT_NUMERATOR, + GENESIS_BLOCK_NUMBER, + GENESIS_PARENT_HASH, ZERO_ADDRESS, ) from eth.typing import ( diff --git a/eth/_utils/module_loading.py b/eth/_utils/module_loading.py index d824a3db84..1bae37d5ab 100644 --- a/eth/_utils/module_loading.py +++ b/eth/_utils/module_loading.py @@ -1,6 +1,7 @@ +from importlib import ( + import_module, +) import operator -from importlib import import_module - from types import ( ModuleType, ) diff --git a/eth/_utils/numeric.py b/eth/_utils/numeric.py index 80819b9217..e6a25a11ed 100644 --- a/eth/_utils/numeric.py +++ b/eth/_utils/numeric.py @@ -5,17 +5,17 @@ Union, ) -from eth_utils.toolz import ( - curry, -) from eth_typing import ( Hash32, ) +from eth_utils.toolz import ( + curry, +) from eth.constants import ( UINT_255_MAX, - UINT_256_MAX, UINT_256_CEILING, + UINT_256_MAX, ) diff --git a/eth/_utils/padding.py b/eth/_utils/padding.py index 977963ef8e..30b21c39d0 100644 --- a/eth/_utils/padding.py +++ b/eth/_utils/padding.py @@ -2,7 +2,6 @@ curry, ) - ZERO_BYTE = b'\x00' diff --git a/eth/_utils/rlp.py b/eth/_utils/rlp.py index f737dd83b9..9c8edde72e 100644 --- a/eth/_utils/rlp.py +++ b/eth/_utils/rlp.py @@ -1,18 +1,17 @@ -import rlp from typing import ( Iterable, Optional, Tuple, ) -from eth_utils.toolz import ( - curry, -) - from eth_utils import ( - to_tuple, ValidationError, + to_tuple, ) +from eth_utils.toolz import ( + curry, +) +import rlp from eth.rlp.blocks import ( BaseBlock, diff --git a/eth/_utils/spoof.py b/eth/_utils/spoof.py index 9689b59ed5..97bd957770 100644 --- a/eth/_utils/spoof.py +++ b/eth/_utils/spoof.py @@ -8,16 +8,15 @@ merge, ) -from eth.constants import ( - DEFAULT_SPOOF_Y_PARITY, - DEFAULT_SPOOF_R, - DEFAULT_SPOOF_S, -) - from eth.abc import ( SignedTransactionAPI, UnsignedTransactionAPI, ) +from eth.constants import ( + DEFAULT_SPOOF_R, + DEFAULT_SPOOF_S, + DEFAULT_SPOOF_Y_PARITY, +) SPOOF_ATTRIBUTES_DEFAULTS = { 'y_parity': DEFAULT_SPOOF_Y_PARITY, diff --git a/eth/_utils/state.py b/eth/_utils/state.py index 26e5fd2455..71b906c16e 100644 --- a/eth/_utils/state.py +++ b/eth/_utils/state.py @@ -6,7 +6,9 @@ AccountDiff, AccountState, ) -from eth.vm.state import BaseState +from eth.vm.state import ( + BaseState, +) @to_tuple diff --git a/eth/_utils/transactions.py b/eth/_utils/transactions.py index 3b8ee67706..db683e0d09 100644 --- a/eth/_utils/transactions.py +++ b/eth/_utils/transactions.py @@ -1,18 +1,23 @@ -from typing import NamedTuple - -import rlp +from typing import ( + NamedTuple, +) -from eth_keys import keys -from eth_keys import datatypes +from eth_keys import ( + datatypes, + keys, +) from eth_keys.exceptions import ( BadSignature, ) - from eth_utils import ( - int_to_big_endian, ValidationError, + int_to_big_endian, ) +import rlp +from eth._utils.numeric import ( + is_even, +) from eth.abc import ( SignedTransactionAPI, UnsignedTransactionAPI, @@ -20,16 +25,13 @@ from eth.constants import ( CREATE_CONTRACT_ADDRESS, ) +from eth.rlp.transactions import ( + BaseTransaction, +) from eth.typing import ( - Address, VRS, + Address, ) -from eth._utils.numeric import ( - is_even, -) - -from eth.rlp.transactions import BaseTransaction - EIP155_CHAIN_ID_OFFSET = 35 # Add this offset to y_parity to get "v" for legacy transactions, from Frontier diff --git a/eth/_utils/version.py b/eth/_utils/version.py index 1077df56f7..254c589f7c 100644 --- a/eth/_utils/version.py +++ b/eth/_utils/version.py @@ -1,6 +1,8 @@ import sys -from eth import __version__ +from eth import ( + __version__, +) def construct_evm_runtime_identifier() -> str: diff --git a/eth/_warnings.py b/eth/_warnings.py index 366d25aa75..4f7b2688f3 100644 --- a/eth/_warnings.py +++ b/eth/_warnings.py @@ -1,5 +1,9 @@ -from contextlib import contextmanager -from typing import Iterator +from contextlib import ( + contextmanager, +) +from typing import ( + Iterator, +) import warnings diff --git a/eth/abc.py b/eth/abc.py index cca3901c3d..0192edab48 100644 --- a/eth/abc.py +++ b/eth/abc.py @@ -1,6 +1,6 @@ from abc import ( ABC, - abstractmethod + abstractmethod, ) from typing import ( Any, @@ -9,6 +9,7 @@ ContextManager, Dict, FrozenSet, + Hashable, Iterable, Iterator, List, @@ -20,36 +21,38 @@ Type, TypeVar, Union, - Hashable, ) -from eth_bloom import BloomFilter - +from eth_bloom import ( + BloomFilter, +) +from eth_keys.datatypes import ( + PrivateKey, +) from eth_typing import ( Address, BlockNumber, Hash32, ) - -from eth_utils import ExtendedDebugLogger - -from eth_keys.datatypes import PrivateKey +from eth_utils import ( + ExtendedDebugLogger, +) from eth.constants import ( BLANK_ROOT_HASH, ) - -from eth.exceptions import VMError +from eth.exceptions import ( + VMError, +) from eth.typing import ( + AccountState, BytesOrView, ChainGaps, - JournalDBCheckpoint, - AccountState, HeaderParams, + JournalDBCheckpoint, VMConfiguration, ) - T = TypeVar('T') # A decoded RLP object of unknown interpretation, with a maximum "depth" of 1. diff --git a/eth/chains/base.py b/eth/chains/base.py index 67e9e88d14..a4b0990db4 100644 --- a/eth/chains/base.py +++ b/eth/chains/base.py @@ -1,3 +1,4 @@ +import logging import operator import random from typing import ( @@ -10,8 +11,6 @@ Type, ) -import logging - from eth_typing import ( Address, BlockNumber, @@ -25,32 +24,35 @@ sliding_window, ) -from eth._utils.db import ( - apply_state_dict, -) from eth._utils.datatypes import ( Configurable, ) +from eth._utils.db import ( + apply_state_dict, +) from eth._utils.rlp import ( validate_imported_block_unchanged, ) +from eth._warnings import ( + catch_and_ignore_import_warning, +) from eth.abc import ( - BlockAPI, - BlockAndMetaWitness, - MiningChainAPI, AtomicDatabaseAPI, + BlockAndMetaWitness, + BlockAPI, BlockHeaderAPI, BlockImportResult, BlockPersistResult, ChainAPI, ChainDatabaseAPI, ConsensusContextAPI, - VirtualMachineAPI, - ReceiptAPI, MessageComputationAPI, - StateAPI, + MiningChainAPI, + ReceiptAPI, SignedTransactionAPI, + StateAPI, UnsignedTransactionAPI, + VirtualMachineAPI, WithdrawalAPI, ) from eth.consensus import ( @@ -60,14 +62,12 @@ EMPTY_UNCLE_HASH, MAX_UNCLE_DEPTH, ) - from eth.db.chain import ( ChainDB, ) from eth.db.header import ( HeaderDB, ) - from eth.estimators import ( get_gas_estimator, ) @@ -76,30 +76,28 @@ TransactionNotFound, VMNotFound, ) - from eth.rlp.headers import ( BlockHeader, ) - from eth.typing import ( AccountState, HeaderParams, StaticMethod, ) - from eth.validation import ( validate_block_number, validate_uint256, - validate_word, validate_vm_configuration, + validate_word, +) +from eth.vm.chain_context import ( + ChainContext, ) -from eth.vm.chain_context import ChainContext -from eth._warnings import catch_and_ignore_import_warning with catch_and_ignore_import_warning(): from eth_utils import ( - to_set, ValidationError, + to_set, ) from eth_utils.toolz import ( assoc, diff --git a/eth/chains/goerli/constants.py b/eth/chains/goerli/constants.py index 807096a9bb..f91a96e5c7 100644 --- a/eth/chains/goerli/constants.py +++ b/eth/chains/goerli/constants.py @@ -1,5 +1,6 @@ -from eth_typing import BlockNumber - +from eth_typing import ( + BlockNumber, +) GOERLI_CHAIN_ID = 5 diff --git a/eth/chains/header.py b/eth/chains/header.py index de8a5c416f..95a3985f82 100644 --- a/eth/chains/header.py +++ b/eth/chains/header.py @@ -1,7 +1,7 @@ from typing import ( - cast, Tuple, Type, + cast, ) from eth_typing import ( @@ -9,6 +9,9 @@ Hash32, ) +from eth._utils.datatypes import ( + Configurable, +) from eth.abc import ( AtomicDatabaseAPI, BlockHeaderAPI, @@ -21,9 +24,6 @@ from eth.db.header import ( HeaderDB, ) -from eth._utils.datatypes import ( - Configurable, -) class HeaderChain(Configurable, HeaderChainAPI): diff --git a/eth/chains/mainnet/constants.py b/eth/chains/mainnet/constants.py index 4a42c06c8e..a75d3c9b34 100644 --- a/eth/chains/mainnet/constants.py +++ b/eth/chains/mainnet/constants.py @@ -1,5 +1,6 @@ -from eth_typing import BlockNumber - +from eth_typing import ( + BlockNumber, +) # https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md MAINNET_CHAIN_ID = 1 diff --git a/eth/chains/ropsten/constants.py b/eth/chains/ropsten/constants.py index 9fe0bbe456..67498c066c 100644 --- a/eth/chains/ropsten/constants.py +++ b/eth/chains/ropsten/constants.py @@ -1,5 +1,6 @@ -from eth_typing import BlockNumber - +from eth_typing import ( + BlockNumber, +) # https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md ROPSTEN_CHAIN_ID = 3 diff --git a/eth/consensus/clique/_utils.py b/eth/consensus/clique/_utils.py index 4473401187..368bdf75f2 100644 --- a/eth/consensus/clique/_utils.py +++ b/eth/consensus/clique/_utils.py @@ -2,19 +2,25 @@ Iterable, ) -from eth_keys import keys -from eth_keys.datatypes import PrivateKey +from eth_keys import ( + keys, +) +from eth_keys.datatypes import ( + PrivateKey, +) from eth_typing import ( Address, Hash32, ) from eth_utils import ( + ValidationError, encode_hex, to_tuple, - ValidationError, ) -from eth._utils.headers import eth_now +from eth._utils.headers import ( + eth_now, +) from eth.abc import ( BlockHeaderAPI, ) diff --git a/eth/consensus/clique/clique.py b/eth/consensus/clique/clique.py index 5c6e640386..bee4c16acd 100644 --- a/eth/consensus/clique/clique.py +++ b/eth/consensus/clique/clique.py @@ -4,26 +4,25 @@ Sequence, ) -from eth.abc import ( - AtomicDatabaseAPI, - BlockHeaderAPI, - VirtualMachineAPI, - VirtualMachineModifierAPI, -) -from eth.db.chain import ChainDB - from eth_typing import ( Address, ) from eth_utils import ( + ValidationError, encode_hex, to_tuple, - ValidationError, ) from eth.abc import ( + AtomicDatabaseAPI, + BlockHeaderAPI, ConsensusAPI, ConsensusContextAPI, + VirtualMachineAPI, + VirtualMachineModifierAPI, +) +from eth.db.chain import ( + ChainDB, ) from eth.typing import ( HeaderParams, @@ -31,17 +30,19 @@ VMFork, ) +from ._utils import ( + get_block_signer, + is_in_turn, + validate_header_integrity, +) from .constants import ( EPOCH_LENGTH, ) from .datatypes import ( Snapshot, ) -from .snapshot_manager import SnapshotManager -from ._utils import ( - get_block_signer, - is_in_turn, - validate_header_integrity, +from .snapshot_manager import ( + SnapshotManager, ) diff --git a/eth/consensus/clique/constants.py b/eth/consensus/clique/constants.py index 474bde958c..44d7f1a886 100644 --- a/eth/consensus/clique/constants.py +++ b/eth/consensus/clique/constants.py @@ -1,4 +1,6 @@ -from eth_utils import decode_hex +from eth_utils import ( + decode_hex, +) ALLOWED_CLIQUE_DIFFICULTIES = {1, 2} diff --git a/eth/consensus/clique/datatypes.py b/eth/consensus/clique/datatypes.py index 554d1e0c03..d3b3955def 100644 --- a/eth/consensus/clique/datatypes.py +++ b/eth/consensus/clique/datatypes.py @@ -1,5 +1,5 @@ from enum import ( - Enum + Enum, ) from typing import ( Dict, @@ -11,7 +11,7 @@ from eth_typing import ( Address, - Hash32 + Hash32, ) from eth_utils import ( ValidationError, @@ -19,7 +19,7 @@ from .constants import ( NONCE_AUTH, - NONCE_DROP + NONCE_DROP, ) diff --git a/eth/consensus/clique/encoding.py b/eth/consensus/clique/encoding.py index a67faaf6ef..c8cb2bfb8d 100644 --- a/eth/consensus/clique/encoding.py +++ b/eth/consensus/clique/encoding.py @@ -1,4 +1,3 @@ -import rlp from typing import ( Tuple, ) @@ -6,16 +5,17 @@ from eth_typing import ( Address, ) +import rlp -from eth.rlp.sedes import ( - uint256, -) from eth.consensus.clique.datatypes import ( Snapshot, Tally, Vote, VoteAction, ) +from eth.rlp.sedes import ( + uint256, +) ADDRESS_TALLY_SEDES = rlp.sedes.List((rlp.sedes.binary, rlp.sedes.binary)) VOTE_SEDES = rlp.sedes.List( diff --git a/eth/consensus/clique/exceptions.py b/eth/consensus/clique/exceptions.py index 843a65cdee..fcd90a8e18 100644 --- a/eth/consensus/clique/exceptions.py +++ b/eth/consensus/clique/exceptions.py @@ -1,4 +1,6 @@ -from eth.exceptions import PyEVMError +from eth.exceptions import ( + PyEVMError, +) class SnapshotNotFound(PyEVMError): diff --git a/eth/consensus/clique/snapshot_manager.py b/eth/consensus/clique/snapshot_manager.py index cb66d83a4e..434fd572a2 100644 --- a/eth/consensus/clique/snapshot_manager.py +++ b/eth/consensus/clique/snapshot_manager.py @@ -1,12 +1,5 @@ -import lru -from typing import Iterable - -from eth.abc import ( - BlockHeaderAPI, - ChainDatabaseAPI, -) -from eth.exceptions import ( - HeaderNotFound, +from typing import ( + Iterable, ) from eth_typing import ( @@ -14,17 +7,24 @@ Hash32, ) from eth_utils import ( + ValidationError, encode_hex, get_extended_debug_logger, - ValidationError, ) +import lru -from .encoding import ( - decode_snapshot, - encode_snapshot, +from eth.abc import ( + BlockHeaderAPI, + ChainDatabaseAPI, ) -from .exceptions import ( - SnapshotNotFound, +from eth.exceptions import ( + HeaderNotFound, +) + +from ._utils import ( + get_block_signer, + get_signers_at_checkpoint, + is_checkpoint, ) from .constants import ( IN_MEMORY_SNAPSHOTS, @@ -38,11 +38,12 @@ Vote, VoteAction, ) - -from ._utils import ( - get_signers_at_checkpoint, - get_block_signer, - is_checkpoint, +from .encoding import ( + decode_snapshot, + encode_snapshot, +) +from .exceptions import ( + SnapshotNotFound, ) diff --git a/eth/consensus/noproof.py b/eth/consensus/noproof.py index 06fb9e3870..40a174a984 100644 --- a/eth/consensus/noproof.py +++ b/eth/consensus/noproof.py @@ -1,6 +1,7 @@ from typing import ( Iterable, ) + from eth.abc import ( AtomicDatabaseAPI, BlockHeaderAPI, diff --git a/eth/consensus/pos.py b/eth/consensus/pos.py index 12b1fcd3ad..c38183fdf5 100644 --- a/eth/consensus/pos.py +++ b/eth/consensus/pos.py @@ -1,6 +1,7 @@ from typing import ( Iterable, ) + from eth.abc import ( AtomicDatabaseAPI, BlockHeaderAPI, diff --git a/eth/consensus/pow.py b/eth/consensus/pow.py index bf5228f6f0..7b636a65f8 100644 --- a/eth/consensus/pow.py +++ b/eth/consensus/pow.py @@ -1,29 +1,29 @@ -from collections import OrderedDict +from collections import ( + OrderedDict, +) from typing import ( Iterable, Tuple, ) +from eth_hash.auto import ( + keccak, +) from eth_typing import ( Address, Hash32, ) - from eth_utils import ( - big_endian_to_int, ValidationError, + big_endian_to_int, encode_hex, ) - -from eth_hash.auto import keccak - from pyethash import ( EPOCH_LENGTH, hashimoto_light, mkcache_bytes, ) - from eth.abc import ( AtomicDatabaseAPI, BlockHeaderAPI, @@ -34,7 +34,6 @@ validate_lte, ) - # Type annotation here is to ensure we don't accidentally use strings instead of bytes. cache_by_epoch: 'OrderedDict[int, bytearray]' = OrderedDict() CACHE_MAX_ITEMS = 10 diff --git a/eth/constants.py b/eth/constants.py index 762a46353d..f5262943c2 100644 --- a/eth/constants.py +++ b/eth/constants.py @@ -1,16 +1,22 @@ +from typing import ( + List, + Optional, +) + from eth_typing import ( Address, BlockNumber, Hash32, ) -from typing import ( - List, - Optional, + +from eth._warnings import ( + catch_and_ignore_import_warning, ) -from eth._warnings import catch_and_ignore_import_warning with catch_and_ignore_import_warning(): - from eth_utils import denoms + from eth_utils import ( + denoms, + ) ANY = 'any' diff --git a/eth/db/accesslog.py b/eth/db/accesslog.py index c4f0d84caf..074c50fe6c 100644 --- a/eth/db/accesslog.py +++ b/eth/db/accesslog.py @@ -1,22 +1,24 @@ -from contextlib import contextmanager +from contextlib import ( + contextmanager, +) import logging from typing import ( - Iterator, FrozenSet, + Iterator, Set, ) from eth.abc import ( - AtomicWriteBatchAPI, AtomicDatabaseAPI, + AtomicWriteBatchAPI, DatabaseAPI, ) -from eth.db.backends.base import ( - BaseDB, -) from eth.db.atomic import ( BaseAtomicDB, ) +from eth.db.backends.base import ( + BaseDB, +) class KeyAccessLoggerDB(BaseDB): diff --git a/eth/db/account.py b/eth/db/account.py index 5ada5c89be..084bb1ea0e 100644 --- a/eth/db/account.py +++ b/eth/db/account.py @@ -1,26 +1,29 @@ -from lru import LRU from typing import ( - cast, Dict, Iterable, Set, Tuple, + cast, ) -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_typing import ( Address, - Hash32 + Hash32, ) - from eth_utils import ( + ValidationError, encode_hex, get_extended_debug_logger, int_to_big_endian, to_checksum_address, to_dict, to_tuple, - ValidationError, +) +from lru import ( + LRU, ) import rlp from trie import ( @@ -43,6 +46,9 @@ KeyAccessLoggerAtomicDB, KeyAccessLoggerDB, ) +from eth.db.backends.memory import ( + MemoryDB, +) from eth.db.batch import ( BatchDB, ) @@ -55,9 +61,6 @@ from eth.db.journal import ( JournalDB, ) -from eth.db.backends.memory import ( - MemoryDB, -) from eth.db.storage import ( AccountStorageDB, ) @@ -65,23 +68,25 @@ AccountQueryTracker, MetaWitness, ) -from eth.typing import ( - JournalDBCheckpoint, -) -from eth.vm.interrupt import ( - MissingAccountTrieNode, - MissingBytecode, -) from eth.rlp.accounts import ( Account, ) +from eth.typing import ( + JournalDBCheckpoint, +) from eth.validation import ( + validate_canonical_address, validate_is_bytes, validate_uint256, - validate_canonical_address, +) +from eth.vm.interrupt import ( + MissingAccountTrieNode, + MissingBytecode, ) -from .hash_trie import HashTrie +from .hash_trie import ( + HashTrie, +) IS_PRESENT_VALUE = b'' diff --git a/eth/db/atomic.py b/eth/db/atomic.py index 4bfe8de9f0..70df739afa 100644 --- a/eth/db/atomic.py +++ b/eth/db/atomic.py @@ -1,4 +1,6 @@ -from contextlib import contextmanager +from contextlib import ( + contextmanager, +) import logging from typing import ( Iterator, @@ -12,14 +14,18 @@ AtomicWriteBatchAPI, DatabaseAPI, ) - +from eth.db.backends.base import ( + BaseAtomicDB, + BaseDB, +) +from eth.db.backends.memory import ( + MemoryDB, +) from eth.db.diff import ( DBDiff, DBDiffTracker, DiffMissingError, ) -from eth.db.backends.base import BaseAtomicDB, BaseDB -from eth.db.backends.memory import MemoryDB class AtomicDB(BaseAtomicDB): diff --git a/eth/db/backends/level.py b/eth/db/backends/level.py index fb5763fed9..0ac6eef425 100644 --- a/eth/db/backends/level.py +++ b/eth/db/backends/level.py @@ -1,13 +1,22 @@ -from contextlib import contextmanager +from contextlib import ( + contextmanager, +) import logging -from pathlib import Path +from pathlib import ( + Path, +) from typing import ( - Iterator, TYPE_CHECKING, + Iterator, ) -from eth_utils import ValidationError +from eth_utils import ( + ValidationError, +) +from eth._warnings import ( + catch_and_ignore_import_warning, +) from eth.abc import ( AtomicWriteBatchAPI, DatabaseAPI, @@ -16,13 +25,12 @@ DBDiffTracker, DiffMissingError, ) + from .base import ( BaseAtomicDB, BaseDB, ) -from eth._warnings import catch_and_ignore_import_warning - if TYPE_CHECKING: with catch_and_ignore_import_warning(): import plyvel # noqa: F401 diff --git a/eth/db/batch.py b/eth/db/batch.py index a9835812e8..aee439caf3 100644 --- a/eth/db/batch.py +++ b/eth/db/batch.py @@ -4,13 +4,17 @@ ValidationError, ) -from eth.abc import DatabaseAPI +from eth.abc import ( + DatabaseAPI, +) +from eth.db.backends.base import ( + BaseDB, +) from eth.db.diff import ( DBDiff, DBDiffTracker, DiffMissingError, ) -from eth.db.backends.base import BaseDB class BatchDB(BaseDB): diff --git a/eth/db/cache.py b/eth/db/cache.py index a4dba2ae36..e9967dbfb8 100644 --- a/eth/db/cache.py +++ b/eth/db/cache.py @@ -1,7 +1,13 @@ -from lru import LRU +from lru import ( + LRU, +) -from eth.abc import DatabaseAPI -from eth.db.backends.base import BaseDB +from eth.abc import ( + DatabaseAPI, +) +from eth.db.backends.base import ( + BaseDB, +) class CacheDB(BaseDB): diff --git a/eth/db/chain.py b/eth/db/chain.py index 6db784b90b..a1aca85505 100644 --- a/eth/db/chain.py +++ b/eth/db/chain.py @@ -1,6 +1,5 @@ import functools import itertools - from typing import ( Dict, Iterable, @@ -10,28 +9,29 @@ cast, ) -from eth.vm.forks.shanghai.withdrawals import ( - Withdrawal, +from eth_hash.auto import ( + keccak, ) from eth_typing import ( BlockNumber, - Hash32 + Hash32, ) from eth_utils import ( encode_hex, ) - -from eth_hash.auto import keccak from trie.exceptions import ( MissingTrieNode, ) +from eth._warnings import ( + catch_and_ignore_import_warning, +) from eth.abc import ( + AtomicDatabaseAPI, BlockAPI, BlockHeaderAPI, ChainDatabaseAPI, DatabaseAPI, - AtomicDatabaseAPI, ReceiptAPI, ReceiptDecoderAPI, SignedTransactionAPI, @@ -43,37 +43,52 @@ GENESIS_PARENT_HASH, ) from eth.db.chain_gaps import ( - fill_gap, + GENESIS_CHAIN_GAPS, GapChange, GapInfo, - GENESIS_CHAIN_GAPS, + fill_gap, is_block_number_in_gap, reopen_gap, ) -from eth.db.trie import make_trie_root_and_nodes +from eth.db.header import ( + HeaderDB, +) +from eth.db.schema import ( + SchemaV1, +) +from eth.db.trie import ( + make_trie_root_and_nodes, +) from eth.exceptions import ( HeaderNotFound, ReceiptNotFound, TransactionNotFound, ) -from eth.db.header import HeaderDB -from eth.db.schema import SchemaV1 -from eth.rlp.sedes import chain_gaps -from eth.typing import ChainGaps +from eth.rlp.sedes import ( + chain_gaps, +) +from eth.typing import ( + ChainGaps, +) from eth.validation import ( validate_word, ) -from eth.vm.header import HeaderSedes -from eth._warnings import catch_and_ignore_import_warning +from eth.vm.forks.shanghai.withdrawals import ( + Withdrawal, +) +from eth.vm.header import ( + HeaderSedes, +) + with catch_and_ignore_import_warning(): + from eth_utils import ( + ValidationError, + to_tuple, + ) import rlp from trie import ( HexaryTrie, ) - from eth_utils import ( - to_tuple, - ValidationError, - ) class BlockDataKey(rlp.Serializable): diff --git a/eth/db/chain_gaps.py b/eth/db/chain_gaps.py index 4ab125d11c..93c0423048 100644 --- a/eth/db/chain_gaps.py +++ b/eth/db/chain_gaps.py @@ -1,14 +1,24 @@ import enum -from typing import Iterable, Tuple +from typing import ( + Iterable, + Tuple, +) -from eth_typing import BlockNumber +from eth_typing import ( + BlockNumber, +) from eth_utils import ( ValidationError, to_tuple, ) -from eth.exceptions import GapTrackingCorrupted -from eth.typing import BlockRange, ChainGaps +from eth.exceptions import ( + GapTrackingCorrupted, +) +from eth.typing import ( + BlockRange, + ChainGaps, +) class GapChange(enum.Enum): diff --git a/eth/db/diff.py b/eth/db/diff.py index d94553f62a..060437789c 100644 --- a/eth/db/diff.py +++ b/eth/db/diff.py @@ -3,12 +3,12 @@ MutableMapping, ) from typing import ( - cast, + TYPE_CHECKING, Dict, Iterable, - Union, Tuple, - TYPE_CHECKING, + Union, + cast, ) from eth_utils import ( @@ -16,8 +16,12 @@ to_tuple, ) -from eth.abc import DatabaseAPI -from eth.vm.interrupt import EVMMissingData +from eth.abc import ( + DatabaseAPI, +) +from eth.vm.interrupt import ( + EVMMissingData, +) if TYPE_CHECKING: ABC_Mutable_Mapping = MutableMapping[bytes, Union[bytes, 'MissingReason']] diff --git a/eth/db/hash_trie.py b/eth/db/hash_trie.py index 7b94c79530..6f218d56e0 100644 --- a/eth/db/hash_trie.py +++ b/eth/db/hash_trie.py @@ -1,11 +1,15 @@ import contextlib from typing import ( - cast, Iterator, + cast, ) -from eth_hash.auto import keccak -from trie import HexaryTrie +from eth_hash.auto import ( + keccak, +) +from trie import ( + HexaryTrie, +) from eth.db.keymap import ( KeyMapDB, diff --git a/eth/db/header.py b/eth/db/header.py index 862dba1a75..e9c72cc26e 100644 --- a/eth/db/header.py +++ b/eth/db/header.py @@ -1,29 +1,26 @@ import functools from typing import ( - cast, Iterable, Sequence, Tuple, + cast, ) -import rlp - -from eth_utils.toolz import ( - concat, - first, - sliding_window, +from eth_typing import ( + BlockNumber, + Hash32, ) - from eth_utils import ( + ValidationError, encode_hex, to_tuple, - ValidationError, ) - -from eth_typing import ( - Hash32, - BlockNumber, +from eth_utils.toolz import ( + concat, + first, + sliding_window, ) +import rlp from eth.abc import ( AtomicDatabaseAPI, @@ -35,27 +32,35 @@ GENESIS_PARENT_HASH, ) from eth.db.chain_gaps import ( - GapChange, - GapInfo, GAP_WRITES, GENESIS_CHAIN_GAPS, + GapChange, + GapInfo, fill_gap, reopen_gap, ) +from eth.db.schema import ( + SchemaV1, +) from eth.exceptions import ( CanonicalHeadNotFound, CheckpointsMustBeCanonical, HeaderNotFound, ParentNotFound, ) -from eth.db.schema import SchemaV1 -from eth.rlp.sedes import chain_gaps -from eth.typing import ChainGaps +from eth.rlp.sedes import ( + chain_gaps, +) +from eth.typing import ( + ChainGaps, +) from eth.validation import ( validate_block_number, validate_word, ) -from eth.vm.header import HeaderSedes +from eth.vm.header import ( + HeaderSedes, +) class HeaderDB(HeaderDatabaseAPI): diff --git a/eth/db/journal.py b/eth/db/journal.py index 033c079170..5b0e33a8db 100644 --- a/eth/db/journal.py +++ b/eth/db/journal.py @@ -2,21 +2,37 @@ from itertools import ( count, ) -from typing import Callable, cast, Dict, List, Set, Union +from typing import ( + Callable, + Dict, + List, + Set, + Union, + cast, +) +from eth_utils import ( + ValidationError, +) from eth_utils.toolz import ( first, nth, ) -from eth_utils import ( - ValidationError, -) -from eth.abc import DatabaseAPI -from eth.typing import JournalDBCheckpoint +from eth.abc import ( + DatabaseAPI, +) +from eth.typing import ( + JournalDBCheckpoint, +) -from .backends.base import BaseDB -from .diff import DBDiff, DBDiffTracker +from .backends.base import ( + BaseDB, +) +from .diff import ( + DBDiff, + DBDiffTracker, +) class DeletedEntry: diff --git a/eth/db/keymap.py b/eth/db/keymap.py index e65d1bcd2a..9481522dfd 100644 --- a/eth/db/keymap.py +++ b/eth/db/keymap.py @@ -1,13 +1,16 @@ from abc import ( abstractmethod, ) - from typing import ( Any, ) -from eth.abc import DatabaseAPI -from eth.db.backends.base import BaseDB +from eth.abc import ( + DatabaseAPI, +) +from eth.db.backends.base import ( + BaseDB, +) class KeyMapDB(BaseDB): diff --git a/eth/db/schema.py b/eth/db/schema.py index 760d763b4a..6abdeb1fa8 100644 --- a/eth/db/schema.py +++ b/eth/db/schema.py @@ -3,7 +3,9 @@ Hash32, ) -from eth.abc import SchemaAPI +from eth.abc import ( + SchemaAPI, +) class SchemaV1(SchemaAPI): diff --git a/eth/db/slow_journal.py b/eth/db/slow_journal.py index 4101dea216..5585e92d4a 100644 --- a/eth/db/slow_journal.py +++ b/eth/db/slow_journal.py @@ -1,19 +1,31 @@ import collections -from typing import cast, Dict, Set, Union +from typing import ( + Dict, + Set, + Union, + cast, +) import uuid +from eth_utils import ( + ValidationError, +) from eth_utils.toolz import ( first, merge, nth, ) -from eth_utils import ( - ValidationError, -) -from eth.abc import DatabaseAPI -from eth.db.backends.base import BaseDB -from eth.db.diff import DBDiff, DBDiffTracker +from eth.abc import ( + DatabaseAPI, +) +from eth.db.backends.base import ( + BaseDB, +) +from eth.db.diff import ( + DBDiff, + DBDiffTracker, +) class DeletedEntry: diff --git a/eth/db/storage.py b/eth/db/storage.py index e3c87bb9ce..ade294a723 100644 --- a/eth/db/storage.py +++ b/eth/db/storage.py @@ -5,7 +5,9 @@ Set, ) -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_typing import ( Address, Hash32, @@ -50,12 +52,12 @@ from eth.db.journal import ( JournalDB, ) -from eth.vm.interrupt import ( - MissingStorageTrieNode, -) from eth.typing import ( JournalDBCheckpoint, ) +from eth.vm.interrupt import ( + MissingStorageTrieNode, +) class PendingWrites(NamedTuple): diff --git a/eth/db/trie.py b/eth/db/trie.py index f529a5b848..e637094930 100644 --- a/eth/db/trie.py +++ b/eth/db/trie.py @@ -1,13 +1,19 @@ import functools -from typing import Dict, Sequence, Tuple, Union +from typing import ( + Dict, + Sequence, + Tuple, + Union, +) +from eth_typing import ( + Hash32, +) import rlp from trie import ( HexaryTrie, ) -from eth_typing import Hash32 - from eth.abc import ( ReceiptAPI, SignedTransactionAPI, diff --git a/eth/estimators/gas.py b/eth/estimators/gas.py index b2b0481e71..2a27d2e962 100644 --- a/eth/estimators/gas.py +++ b/eth/estimators/gas.py @@ -1,14 +1,22 @@ -from typing import cast, Optional - -from eth_utils.toolz import curry +from typing import ( + Optional, + cast, +) -from eth.exceptions import VMError +from eth_utils.toolz import ( + curry, +) from eth.abc import ( SignedTransactionAPI, StateAPI, ) -from eth.vm.spoof import SpoofTransaction +from eth.exceptions import ( + VMError, +) +from eth.vm.spoof import ( + SpoofTransaction, +) def _get_computation_error(state: StateAPI, transaction: SignedTransactionAPI) -> Optional[VMError]: diff --git a/eth/exceptions.py b/eth/exceptions.py index 10b7e51870..ca207c85ca 100644 --- a/eth/exceptions.py +++ b/eth/exceptions.py @@ -1,4 +1,6 @@ -from eth_typing import Hash32 +from eth_typing import ( + Hash32, +) class PyEVMError(Exception): diff --git a/eth/precompiles/blake2.py b/eth/precompiles/blake2.py index ac6a16cd7e..7d29c1c709 100644 --- a/eth/precompiles/blake2.py +++ b/eth/precompiles/blake2.py @@ -2,7 +2,9 @@ ValidationError, ) -from eth._utils.blake2.coders import extract_blake2b_parameters +from eth._utils.blake2.coders import ( + extract_blake2b_parameters, +) from eth.exceptions import ( VMError, ) @@ -11,9 +13,13 @@ ) try: - from blake2b import compress as blake2b_compress + from blake2b import ( + compress as blake2b_compress, + ) except ImportError: - from eth._utils.blake2.compression import blake2b_compress + from eth._utils.blake2.compression import ( + blake2b_compress, + ) GAS_COST_PER_ROUND = 1 diff --git a/eth/precompiles/ecadd.py b/eth/precompiles/ecadd.py index eecf18813c..d6497e26a6 100644 --- a/eth/precompiles/ecadd.py +++ b/eth/precompiles/ecadd.py @@ -1,7 +1,5 @@ -from typing import Tuple - -from py_ecc import ( - optimized_bn128 as bn128, +from typing import ( + Tuple, ) from eth_utils import ( @@ -12,11 +10,12 @@ from eth_utils.toolz import ( curry, ) +from py_ecc import ( + optimized_bn128 as bn128, +) -from eth import constants - -from eth.exceptions import ( - VMError, +from eth import ( + constants, ) from eth._utils.bn128 import ( validate_point, @@ -25,7 +24,9 @@ pad32, pad32r, ) - +from eth.exceptions import ( + VMError, +) from eth.vm.computation import ( MessageComputation, ) diff --git a/eth/precompiles/ecmul.py b/eth/precompiles/ecmul.py index 506815dfec..1d0b0d5b23 100644 --- a/eth/precompiles/ecmul.py +++ b/eth/precompiles/ecmul.py @@ -1,22 +1,21 @@ -from typing import Tuple - -from py_ecc import ( - optimized_bn128 as bn128, +from typing import ( + Tuple, ) from eth_utils import ( + ValidationError, big_endian_to_int, int_to_big_endian, - ValidationError, ) from eth_utils.toolz import ( curry, ) +from py_ecc import ( + optimized_bn128 as bn128, +) -from eth import constants - -from eth.exceptions import ( - VMError, +from eth import ( + constants, ) from eth._utils.bn128 import ( validate_point, @@ -25,7 +24,9 @@ pad32, pad32r, ) - +from eth.exceptions import ( + VMError, +) from eth.vm.computation import ( MessageComputation, ) diff --git a/eth/precompiles/ecpairing.py b/eth/precompiles/ecpairing.py index 971c86694d..9d75b97338 100644 --- a/eth/precompiles/ecpairing.py +++ b/eth/precompiles/ecpairing.py @@ -1,8 +1,10 @@ -from typing import Tuple +from typing import ( + Tuple, +) from eth_utils import ( - big_endian_to_int, ValidationError, + big_endian_to_int, ) from eth_utils.toolz import ( curry, @@ -12,29 +14,26 @@ optimized_bn128 as bn128, ) -from eth import constants - -from eth.exceptions import ( - VMError, +from eth import ( + constants, ) - -from eth.typing import ( - BytesOrView, -) - from eth._utils.bn128 import ( - validate_point, FQP_point_to_FQ2_point, + validate_point, ) from eth._utils.padding import ( pad32, ) - +from eth.exceptions import ( + VMError, +) +from eth.typing import ( + BytesOrView, +) from eth.vm.computation import ( MessageComputation, ) - ZERO = bn128.Z2 EXPONENT = bn128.FQ12.one() diff --git a/eth/precompiles/ecrecover.py b/eth/precompiles/ecrecover.py index 2a1b0e83bd..37905ddf4b 100644 --- a/eth/precompiles/ecrecover.py +++ b/eth/precompiles/ecrecover.py @@ -1,23 +1,24 @@ -from eth_keys import keys +from eth_keys import ( + keys, +) from eth_keys.exceptions import ( BadSignature, ) - from eth_utils import ( - big_endian_to_int, ValidationError, + big_endian_to_int, ) -from eth import constants - +from eth import ( + constants, +) from eth._utils.padding import ( pad32, pad32r, ) - from eth.validation import ( - validate_lt_secpk1n, validate_gte, + validate_lt_secpk1n, validate_lte, ) from eth.vm.computation import ( diff --git a/eth/precompiles/identity.py b/eth/precompiles/identity.py index 22b76cbe05..672369d0a1 100644 --- a/eth/precompiles/identity.py +++ b/eth/precompiles/identity.py @@ -1,8 +1,9 @@ -from eth import constants +from eth import ( + constants, +) from eth._utils.numeric import ( ceil32, ) - from eth.vm.computation import ( MessageComputation, ) diff --git a/eth/precompiles/modexp.py b/eth/precompiles/modexp.py index 9cad85a7ff..5c690f26f7 100644 --- a/eth/precompiles/modexp.py +++ b/eth/precompiles/modexp.py @@ -11,17 +11,17 @@ curry, ) -from eth import constants - +from eth import ( + constants, +) from eth._utils.numeric import ( get_highest_bit_index, ) from eth._utils.padding import ( pad32r, - zpad_right, zpad_left, + zpad_right, ) - from eth.vm.computation import ( MessageComputation, ) diff --git a/eth/precompiles/ripemd160.py b/eth/precompiles/ripemd160.py index 573c0d550a..ff98bee0dc 100644 --- a/eth/precompiles/ripemd160.py +++ b/eth/precompiles/ripemd160.py @@ -1,7 +1,8 @@ import hashlib -from eth import constants - +from eth import ( + constants, +) from eth._utils.numeric import ( ceil32, ) diff --git a/eth/precompiles/sha256.py b/eth/precompiles/sha256.py index 73960e9440..dd9c353d90 100644 --- a/eth/precompiles/sha256.py +++ b/eth/precompiles/sha256.py @@ -1,11 +1,11 @@ import hashlib -from eth import constants - +from eth import ( + constants, +) from eth._utils.numeric import ( ceil32, ) - from eth.vm.computation import ( MessageComputation, ) diff --git a/eth/rlp/accounts.py b/eth/rlp/accounts.py index ce4ae4658e..83e8efeeaf 100644 --- a/eth/rlp/accounts.py +++ b/eth/rlp/accounts.py @@ -1,21 +1,25 @@ +from typing import ( + Any, +) + import rlp from rlp.sedes import ( big_endian_int, ) -from eth.abc import AccountAPI +from eth.abc import ( + AccountAPI, +) from eth.constants import ( - EMPTY_SHA3, BLANK_ROOT_HASH, + EMPTY_SHA3, ) from .sedes import ( - trie_root, hash32, + trie_root, ) -from typing import Any - class Account(rlp.Serializable, AccountAPI): """ diff --git a/eth/rlp/headers.py b/eth/rlp/headers.py index 2add9f5387..fc5a8d6c47 100644 --- a/eth/rlp/headers.py +++ b/eth/rlp/headers.py @@ -4,24 +4,23 @@ overload, ) -import rlp -from rlp.sedes import ( - big_endian_int, - Binary, - binary, +from eth_hash.auto import ( + keccak, ) - from eth_typing import ( Address, BlockNumber, Hash32, ) - -from eth_hash.auto import keccak - from eth_utils import ( encode_hex, ) +import rlp +from rlp.sedes import ( + Binary, + big_endian_int, + binary, +) from eth._utils.headers import ( new_timestamp_from_parent, @@ -31,20 +30,22 @@ MiningHeaderAPI, ) from eth.constants import ( - ZERO_ADDRESS, - ZERO_HASH32, + BLANK_ROOT_HASH, EMPTY_UNCLE_HASH, GENESIS_NONCE, GENESIS_PARENT_HASH, - BLANK_ROOT_HASH, + ZERO_ADDRESS, + ZERO_HASH32, +) +from eth.typing import ( + HeaderParams, ) -from eth.typing import HeaderParams from .sedes import ( address, hash32, - uint256, trie_root, + uint256, ) diff --git a/eth/rlp/logs.py b/eth/rlp/logs.py index ea4f0db58f..649075aa6e 100644 --- a/eth/rlp/logs.py +++ b/eth/rlp/logs.py @@ -1,15 +1,16 @@ -from rlp.sedes import ( - CountableList, - binary, -) - from typing import ( Tuple, ) import rlp +from rlp.sedes import ( + CountableList, + binary, +) -from eth.abc import LogAPI +from eth.abc import ( + LogAPI, +) from .sedes import ( address, diff --git a/eth/rlp/receipts.py b/eth/rlp/receipts.py index 44af73f852..dcd1fd593a 100644 --- a/eth/rlp/receipts.py +++ b/eth/rlp/receipts.py @@ -1,11 +1,15 @@ import itertools -from typing import Iterable +from typing import ( + Iterable, +) -from eth_bloom import BloomFilter +from eth_bloom import ( + BloomFilter, +) import rlp from rlp.sedes import ( - big_endian_int, CountableList, + big_endian_int, binary, ) @@ -14,7 +18,9 @@ ReceiptBuilderAPI, ) -from .logs import Log +from .logs import ( + Log, +) from .sedes import ( uint256, ) diff --git a/eth/rlp/sedes.py b/eth/rlp/sedes.py index 333bfd039a..1aac26bd3d 100644 --- a/eth/rlp/sedes.py +++ b/eth/rlp/sedes.py @@ -4,7 +4,6 @@ Binary, ) - address = Binary.fixed_length(20, allow_empty=True) hash32 = Binary.fixed_length(32) uint32 = BigEndianInt(32) diff --git a/eth/rlp/transactions.py b/eth/rlp/transactions.py index 14f6780a19..273088f388 100644 --- a/eth/rlp/transactions.py +++ b/eth/rlp/transactions.py @@ -5,34 +5,38 @@ cast, ) -from cached_property import cached_property -import rlp -from rlp.sedes import ( - big_endian_int, - binary, +from cached_property import ( + cached_property, +) +from eth_hash.auto import ( + keccak, ) - from eth_typing import ( Address, Hash32, ) - -from eth_hash.auto import keccak from eth_utils import ( ValidationError, ) +import rlp +from rlp.sedes import ( + big_endian_int, + binary, +) from eth.abc import ( BaseTransactionAPI, - MessageComputationAPI, LegacyTransactionFieldsAPI, + MessageComputationAPI, SignedTransactionAPI, TransactionBuilderAPI, TransactionFieldsAPI, UnsignedTransactionAPI, ) -from .sedes import address +from .sedes import ( + address, +) class BaseTransactionMethods(BaseTransactionAPI): diff --git a/eth/tools/_utils/deprecation.py b/eth/tools/_utils/deprecation.py index 44710a20e0..49960c7a4d 100644 --- a/eth/tools/_utils/deprecation.py +++ b/eth/tools/_utils/deprecation.py @@ -1,12 +1,11 @@ import functools -import warnings from typing import ( Any, Callable, TypeVar, cast, ) - +import warnings TFunc = TypeVar("TFunc", bound=Callable[..., Any]) diff --git a/eth/tools/_utils/git.py b/eth/tools/_utils/git.py index d45eb91340..a2e3a2a2c8 100644 --- a/eth/tools/_utils/git.py +++ b/eth/tools/_utils/git.py @@ -1,6 +1,8 @@ import subprocess -from eth_utils import to_text +from eth_utils import ( + to_text, +) def get_version_from_git() -> str: diff --git a/eth/tools/_utils/hashing.py b/eth/tools/_utils/hashing.py index 1dcacdb20b..8744e1a852 100644 --- a/eth/tools/_utils/hashing.py +++ b/eth/tools/_utils/hashing.py @@ -4,13 +4,17 @@ cast, ) -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_typing import ( Hash32, ) import rlp -from eth.rlp.logs import Log +from eth.rlp.logs import ( + Log, +) def hash_log_entries(log_entries: Iterable[Tuple[bytes, Tuple[int, ...], bytes]]) -> Hash32: diff --git a/eth/tools/_utils/mappings.py b/eth/tools/_utils/mappings.py index 1a0483e25f..de449a3762 100644 --- a/eth/tools/_utils/mappings.py +++ b/eth/tools/_utils/mappings.py @@ -1,13 +1,16 @@ -from collections.abc import Mapping +from collections.abc import ( + Mapping, +) import itertools - from typing import ( Any, Dict, Sequence, ) -from eth_utils.toolz import merge_with +from eth_utils.toolz import ( + merge_with, +) def merge_if_dicts(values: Sequence[Dict[Any, Any]]) -> Any: diff --git a/eth/tools/_utils/normalization.py b/eth/tools/_utils/normalization.py index 27351a3437..04a8762b6e 100644 --- a/eth/tools/_utils/normalization.py +++ b/eth/tools/_utils/normalization.py @@ -4,7 +4,6 @@ Any, AnyStr, Callable, - cast, Dict, Iterable, List, @@ -12,28 +11,15 @@ Sequence, Tuple, Union, + cast, ) -from mypy_extensions import ( - TypedDict, -) - -from eth_utils.toolz import ( - assoc_in, - compose, - concat, - curry, - identity, - merge, -) -from eth_utils.toolz import curried - from eth_typing import ( Address, HexStr, ) - from eth_utils.curried import ( + ValidationError, apply_formatter_if, apply_formatter_to_array, apply_formatters_to_dict, @@ -49,18 +35,27 @@ to_bytes, to_canonical_address, to_dict, - ValidationError, +) +from eth_utils.toolz import ( + assoc_in, + compose, + concat, + curried, + curry, + identity, + merge, +) +from mypy_extensions import ( + TypedDict, ) from eth.constants import ( CREATE_CONTRACT_ADDRESS, ) - from eth.tools._utils.mappings import ( deep_merge, is_cleanly_mergable, ) - from eth.typing import ( AccountState, GeneralState, diff --git a/eth/tools/_utils/slow_code_stream.py b/eth/tools/_utils/slow_code_stream.py index 4547efdfd7..d459f6278c 100644 --- a/eth/tools/_utils/slow_code_stream.py +++ b/eth/tools/_utils/slow_code_stream.py @@ -3,13 +3,15 @@ import logging from typing import ( Iterator, - Set + Set, ) from eth.validation import ( validate_is_bytes, ) -from eth.vm import opcode_values +from eth.vm import ( + opcode_values, +) PUSH1, PUSH32, STOP = opcode_values.PUSH1, opcode_values.PUSH32, opcode_values.STOP diff --git a/eth/tools/_utils/vyper.py b/eth/tools/_utils/vyper.py index b1717e32fd..17e816fcb3 100644 --- a/eth/tools/_utils/vyper.py +++ b/eth/tools/_utils/vyper.py @@ -1,5 +1,4 @@ import functools - from typing import ( Any, Callable, @@ -10,10 +9,12 @@ try: from vyper.compile_lll import ( - compile_to_assembly, assembly_to_evm, + compile_to_assembly, + ) + from vyper.parser.parser_utils import ( + LLLnode, ) - from vyper.parser.parser_utils import LLLnode except ImportError: vyper_available = False else: diff --git a/eth/tools/builder/chain/builders.py b/eth/tools/builder/chain/builders.py index c3fa727a1f..f7540395b4 100644 --- a/eth/tools/builder/chain/builders.py +++ b/eth/tools/builder/chain/builders.py @@ -1,7 +1,6 @@ import functools import time from typing import ( - cast, Any, Callable, Dict, @@ -9,12 +8,7 @@ Tuple, Type, Union, -) - -from eth_utils.toolz import ( - curry, - merge, - pipe, + cast, ) from eth_typing import ( @@ -22,14 +16,20 @@ BlockNumber, Hash32, ) - from eth_utils import ( + ValidationError, to_dict, to_tuple, - ValidationError, +) +from eth_utils.toolz import ( + curry, + merge, + pipe, ) -from eth import constants +from eth import ( + constants, +) from eth.abc import ( AtomicDatabaseAPI, BlockAPI, @@ -37,47 +37,55 @@ MiningChainAPI, VirtualMachineAPI, ) -from eth.consensus.applier import ConsensusApplier -from eth.consensus.noproof import NoProofConsensus -from eth.db.atomic import AtomicDB +from eth.consensus.applier import ( + ConsensusApplier, +) +from eth.consensus.noproof import ( + NoProofConsensus, +) +from eth.db.atomic import ( + AtomicDB, +) from eth.db.backends.memory import ( MemoryDB, ) from eth.rlp.headers import ( HeaderParams, ) -from eth.tools.mining import POWMiningMixin from eth.tools._utils.mappings import ( deep_merge, ) from eth.tools._utils.normalization import ( normalize_state, ) +from eth.tools.mining import ( + POWMiningMixin, +) from eth.typing import ( AccountState, GeneralState, - VMFork, VMConfiguration, + VMFork, ) from eth.validation import ( validate_vm_configuration, ) from eth.vm.forks import ( - FrontierVM, - HomesteadVM, - TangerineWhistleVM, - SpuriousDragonVM, + ArrowGlacierVM, + BerlinVM, ByzantiumVM, ConstantinopleVM, - PetersburgVM, + FrontierVM, + GrayGlacierVM, + HomesteadVM, IstanbulVM, - MuirGlacierVM, - BerlinVM, LondonVM, - ArrowGlacierVM, - GrayGlacierVM, + MuirGlacierVM, ParisVM, + PetersburgVM, ShanghaiVM, + SpuriousDragonVM, + TangerineWhistleVM, ) diff --git a/eth/tools/db/atomic.py b/eth/tools/db/atomic.py index 7b3a2c5fc9..5ae0775ab3 100644 --- a/eth/tools/db/atomic.py +++ b/eth/tools/db/atomic.py @@ -1,8 +1,12 @@ import pytest -from eth_utils import ValidationError +from eth_utils import ( + ValidationError, +) -from eth.abc import AtomicDatabaseAPI +from eth.abc import ( + AtomicDatabaseAPI, +) class AtomicDatabaseBatchAPITestSuite: diff --git a/eth/tools/db/base.py b/eth/tools/db/base.py index f0d5011196..6cdc46ba64 100644 --- a/eth/tools/db/base.py +++ b/eth/tools/db/base.py @@ -1,6 +1,8 @@ import pytest -from eth.abc import DatabaseAPI +from eth.abc import ( + DatabaseAPI, +) class DatabaseAPITestSuite: diff --git a/eth/tools/factories/keys.py b/eth/tools/factories/keys.py index 4721cdb6ce..2f06975620 100644 --- a/eth/tools/factories/keys.py +++ b/eth/tools/factories/keys.py @@ -1,14 +1,16 @@ import secrets -try: - import factory -except ImportError: - raise ImportError("The p2p.tools.factories module requires the `factory_boy` library.") +from eth_keys import ( + keys, +) from eth_utils import ( int_to_big_endian, ) -from eth_keys import keys +try: + import factory +except ImportError: + raise ImportError("The p2p.tools.factories module requires the `factory_boy` library.") def _mk_private_key_bytes() -> bytes: diff --git a/eth/tools/factories/transaction.py b/eth/tools/factories/transaction.py index 86651f6962..d5bdf0e3d0 100644 --- a/eth/tools/factories/transaction.py +++ b/eth/tools/factories/transaction.py @@ -1,4 +1,6 @@ -from eth_utils.toolz import curry +from eth_utils.toolz import ( + curry, +) from eth.vm.spoof import ( SpoofTransaction, diff --git a/eth/tools/fixtures/_utils.py b/eth/tools/fixtures/_utils.py index fe9e85e107..1410559775 100644 --- a/eth/tools/fixtures/_utils.py +++ b/eth/tools/fixtures/_utils.py @@ -1,14 +1,15 @@ import fnmatch import functools import os - from typing import ( Any, Callable, Iterable, ) -from eth_utils import to_tuple +from eth_utils import ( + to_tuple, +) @to_tuple diff --git a/eth/tools/fixtures/fillers/_utils.py b/eth/tools/fixtures/fillers/_utils.py index 7319c0e08d..1adb7ddbda 100644 --- a/eth/tools/fixtures/fillers/_utils.py +++ b/eth/tools/fixtures/fillers/_utils.py @@ -8,7 +8,9 @@ Type, ) -from eth_keys import keys +from eth_keys import ( + keys, +) from eth_typing import ( Address, ) @@ -22,8 +24,12 @@ from eth._utils.padding import ( pad32, ) -from eth.constants import BLANK_ROOT_HASH -from eth.db.atomic import AtomicDB +from eth.constants import ( + BLANK_ROOT_HASH, +) +from eth.db.atomic import ( + AtomicDB, +) from eth.typing import ( AccountState, TransactionDict, diff --git a/eth/tools/fixtures/fillers/common.py b/eth/tools/fixtures/fillers/common.py index 6581c54873..edd023c91f 100644 --- a/eth/tools/fixtures/fillers/common.py +++ b/eth/tools/fixtures/fillers/common.py @@ -10,35 +10,35 @@ Callable, Dict, ) + +from eth_utils import ( + apply_formatters_to_dict, + decode_hex, + to_canonical_address, +) from eth_utils.toolz import ( assoc, assoc_in, curry, merge, ) -from eth_utils import ( - apply_formatters_to_dict, - decode_hex, - to_canonical_address, -) -from eth.tools.fixtures.helpers import ( - get_test_name, +from eth.tools._utils.mappings import ( + deep_merge, ) from eth.tools._utils.normalization import ( normalize_environment, normalize_execution, + normalize_networks, normalize_state, normalize_transaction, - normalize_networks, -) -from eth.tools._utils.mappings import ( - deep_merge, ) from eth.tools._utils.vyper import ( compile_vyper_lll, ) - +from eth.tools.fixtures.helpers import ( + get_test_name, +) from eth.typing import ( GeneralState, TransactionDict, @@ -49,7 +49,6 @@ wrap_in_list, ) - # # Defaults # diff --git a/eth/tools/fixtures/fillers/formatters.py b/eth/tools/fixtures/fillers/formatters.py index d286496402..85797638f2 100644 --- a/eth/tools/fixtures/fillers/formatters.py +++ b/eth/tools/fixtures/fillers/formatters.py @@ -12,9 +12,9 @@ to_checksum_address, to_hex, ) - -from eth_utils.toolz import curried - +from eth_utils.toolz import ( + curried, +) environment_formatter = apply_formatters_to_dict({ "currentCoinbase": to_checksum_address, diff --git a/eth/tools/fixtures/fillers/main.py b/eth/tools/fixtures/fillers/main.py index 4fa9a3e6cf..0e9cac7ddd 100644 --- a/eth/tools/fixtures/fillers/main.py +++ b/eth/tools/fixtures/fillers/main.py @@ -8,18 +8,23 @@ merge, ) +from eth.tools._utils.git import ( + get_version_from_git, +) from eth.tools.fixtures.helpers import ( get_test_name, ) -from eth.tools._utils.git import get_version_from_git from .formatters import ( filled_state_test_formatter, filled_vm_test_formatter, ) -from .state import fill_state_test -from .vm import fill_vm_test - +from .state import ( + fill_state_test, +) +from .vm import ( + fill_vm_test, +) FILLED_WITH_TEMPLATE = "py-evm-{version}" diff --git a/eth/tools/fixtures/fillers/state.py b/eth/tools/fixtures/fillers/state.py index 36aa71cb54..649ce558fd 100644 --- a/eth/tools/fixtures/fillers/state.py +++ b/eth/tools/fixtures/fillers/state.py @@ -1,14 +1,18 @@ -from collections import defaultdict +from collections import ( + defaultdict, +) from typing import ( Any, Dict, List, ) -from eth_utils import encode_hex +from eth_utils import ( + encode_hex, +) -from eth.tools.fixtures.helpers import ( - get_test_name, +from eth.tools._utils.mappings import ( + deep_merge, ) from eth.tools._utils.normalization import ( normalize_environment, @@ -16,21 +20,38 @@ normalize_state, normalize_transaction_group, ) -from eth.tools._utils.mappings import deep_merge -from eth.vm.forks.byzantium.state import ByzantiumState -from eth.vm.forks.constantinople.state import ConstantinopleState -from eth.vm.forks.frontier.state import FrontierState -from eth.vm.forks.homestead.state import HomesteadState -from eth.vm.forks.istanbul.state import IstanbulState -from eth.vm.forks.petersburg.state import PetersburgState -from eth.vm.forks.spurious_dragon.state import SpuriousDragonState -from eth.vm.forks.tangerine_whistle.state import TangerineWhistleState +from eth.tools.fixtures.helpers import ( + get_test_name, +) +from eth.vm.forks.byzantium.state import ( + ByzantiumState, +) +from eth.vm.forks.constantinople.state import ( + ConstantinopleState, +) +from eth.vm.forks.frontier.state import ( + FrontierState, +) +from eth.vm.forks.homestead.state import ( + HomesteadState, +) +from eth.vm.forks.istanbul.state import ( + IstanbulState, +) +from eth.vm.forks.petersburg.state import ( + PetersburgState, +) +from eth.vm.forks.spurious_dragon.state import ( + SpuriousDragonState, +) +from eth.vm.forks.tangerine_whistle.state import ( + TangerineWhistleState, +) from ._utils import ( calc_state_root, ) - ALL_NETWORKS = [ "Frontier", "Homestead", diff --git a/eth/tools/fixtures/fillers/vm.py b/eth/tools/fixtures/fillers/vm.py index 609d906dc9..b6dec34605 100644 --- a/eth/tools/fixtures/fillers/vm.py +++ b/eth/tools/fixtures/fillers/vm.py @@ -6,8 +6,11 @@ Union, ) -from eth.tools.fixtures.helpers import ( - get_test_name, +from eth.tools._utils.hashing import ( + hash_log_entries, +) +from eth.tools._utils.mappings import ( + deep_merge, ) from eth.tools._utils.normalization import ( normalize_bytes, @@ -18,8 +21,9 @@ normalize_logs, normalize_state, ) -from eth.tools._utils.hashing import hash_log_entries -from eth.tools._utils.mappings import deep_merge +from eth.tools.fixtures.helpers import ( + get_test_name, +) def fill_vm_test( diff --git a/eth/tools/fixtures/generation.py b/eth/tools/fixtures/generation.py index fec792ac0e..5a57180f96 100644 --- a/eth/tools/fixtures/generation.py +++ b/eth/tools/fixtures/generation.py @@ -1,5 +1,4 @@ import hashlib - from typing import ( Any, Callable, diff --git a/eth/tools/fixtures/helpers.py b/eth/tools/fixtures/helpers.py index d12c84283c..5c948d253d 100644 --- a/eth/tools/fixtures/helpers.py +++ b/eth/tools/fixtures/helpers.py @@ -1,60 +1,61 @@ import os - -import rlp - from typing import ( - cast, Any, Dict, Iterable, Tuple, Type, + cast, ) +from eth_utils import ( + to_normalized_address, +) from eth_utils.toolz import ( assoc, first, ) +import rlp -from eth_utils import ( - to_normalized_address, +from eth import ( + MainnetChain, + constants, +) +from eth._utils.state import ( + diff_state, ) - -from eth import MainnetChain from eth.abc import ( BlockAPI, ChainAPI, StateAPI, VirtualMachineAPI, ) -from eth import constants -from eth.db.atomic import AtomicDB from eth.chains.mainnet import ( MainnetDAOValidatorVM, ) +from eth.db.atomic import ( + AtomicDB, +) from eth.tools.builder.chain import ( disable_pow_check, ) from eth.typing import ( AccountState, ) -from eth._utils.state import ( - diff_state, -) from eth.vm.forks import ( - PetersburgVM, - ConstantinopleVM, + BerlinVM, ByzantiumVM, - TangerineWhistleVM, + ConstantinopleVM, FrontierVM, + GrayGlacierVM, HomesteadVM as BaseHomesteadVM, - SpuriousDragonVM, IstanbulVM, - BerlinVM, LondonVM, - GrayGlacierVM, ParisVM, + PetersburgVM, ShanghaiVM, + SpuriousDragonVM, + TangerineWhistleVM, ) diff --git a/eth/tools/fixtures/loading.py b/eth/tools/fixtures/loading.py index 71bf3ac4a6..63b17ddce0 100644 --- a/eth/tools/fixtures/loading.py +++ b/eth/tools/fixtures/loading.py @@ -1,7 +1,6 @@ import functools import json import os - from typing import ( Any, Callable, @@ -10,13 +9,14 @@ Tuple, ) +from eth_utils import ( + to_tuple, +) from eth_utils.toolz import ( curry, identity, ) -from eth_utils import to_tuple - from ._utils import ( recursive_find_files, require_pytest, diff --git a/eth/tools/mining.py b/eth/tools/mining.py index c2aa7105ec..f85c3da0fe 100644 --- a/eth/tools/mining.py +++ b/eth/tools/mining.py @@ -1,6 +1,6 @@ from eth.abc import ( - BlockAPI, BlockAndMetaWitness, + BlockAPI, VirtualMachineAPI, ) from eth.consensus import ( diff --git a/eth/tools/rlp.py b/eth/tools/rlp.py index 5e81ad15da..1ad065cb14 100644 --- a/eth/tools/rlp.py +++ b/eth/tools/rlp.py @@ -1,13 +1,12 @@ from eth_utils import ( - replace_exceptions, ValidationError, + replace_exceptions, ) from eth._utils.rlp import ( validate_rlp_equal, ) - assert_imported_block_unchanged = replace_exceptions({ ValidationError: AssertionError, })(validate_rlp_equal(obj_a_name='provided block', obj_b_name='executed block')) diff --git a/eth/typing.py b/eth/typing.py index 5c575f5902..0a79b39abf 100644 --- a/eth/typing.py +++ b/eth/typing.py @@ -1,17 +1,17 @@ from typing import ( + TYPE_CHECKING, Any, Callable, Dict, Generic, Iterable, List, - Optional, NewType, + Optional, Sequence, Tuple, Type, TypeVar, - TYPE_CHECKING, Union, ) diff --git a/eth/validation.py b/eth/validation.py index f09fd5e8df..877da446fb 100644 --- a/eth/validation.py +++ b/eth/validation.py @@ -1,41 +1,40 @@ import functools - from typing import ( Any, - cast, Dict, Iterable, Sequence, Tuple, Type, Union, + cast, ) from eth_typing import ( Address, Hash32, ) - from eth_utils import ( - is_list_like, ValidationError, + is_list_like, +) +from eth_utils.toolz import ( + dicttoolz, + functoolz, + itertoolz, ) -from eth_utils.toolz import dicttoolz - -from eth_utils.toolz import functoolz - -from eth_utils.toolz import itertoolz from eth._utils.headers import ( compute_gas_limit_bounds, ) -from eth.abc import VirtualMachineAPI +from eth.abc import ( + VirtualMachineAPI, +) from eth.constants import ( SECPK1_N, - UINT_256_MAX, UINT_64_MAX, + UINT_256_MAX, ) - from eth.typing import ( BytesOrView, ) diff --git a/eth/vm/base.py b/eth/vm/base.py index cc7dfc5f1a..1eb62ef4ce 100644 --- a/eth/vm/base.py +++ b/eth/vm/base.py @@ -16,8 +16,12 @@ Union, ) -from cached_property import cached_property -from eth_hash.auto import keccak +from cached_property import ( + cached_property, +) +from eth_hash.auto import ( + keccak, +) from eth_typing import ( Address, Hash32, @@ -28,17 +32,24 @@ ) import rlp +from eth._utils.datatypes import ( + Configurable, +) +from eth._utils.db import ( + get_block_header_by_hash, + get_parent_header, +) from eth.abc import ( AtomicDatabaseAPI, - BlockAPI, BlockAndMetaWitness, + BlockAPI, BlockHeaderAPI, ChainContextAPI, ChainDatabaseAPI, - MessageComputationAPI, ConsensusAPI, ConsensusContextAPI, ExecutionContextAPI, + MessageComputationAPI, ReceiptAPI, ReceiptBuilderAPI, SignedTransactionAPI, @@ -56,7 +67,9 @@ MAX_PREV_HEADER_DEPTH, MAX_UNCLES, ) -from eth.db.trie import make_trie_root_and_nodes +from eth.db.trie import ( + make_trie_root_and_nodes, +) from eth.exceptions import ( HeaderNotFound, ) @@ -66,16 +79,9 @@ from eth.rlp.sedes import ( uint32, ) -from eth._utils.datatypes import ( - Configurable, -) -from eth._utils.db import ( - get_parent_header, - get_block_header_by_hash, -) from eth.validation import ( - validate_length_lte, validate_gas_limit, + validate_length_lte, ) from eth.vm.execution_context import ( ExecutionContext, diff --git a/eth/vm/chain_context.py b/eth/vm/chain_context.py index 2588b53cf2..4601129046 100644 --- a/eth/vm/chain_context.py +++ b/eth/vm/chain_context.py @@ -1,6 +1,10 @@ -from typing import Optional +from typing import ( + Optional, +) -from eth.abc import ChainContextAPI +from eth.abc import ( + ChainContextAPI, +) from eth.validation import ( validate_uint256, ) diff --git a/eth/vm/code_stream.py b/eth/vm/code_stream.py index fc90da43c6..3845a9342f 100644 --- a/eth/vm/code_stream.py +++ b/eth/vm/code_stream.py @@ -2,10 +2,12 @@ import logging from typing import ( Iterator, - Set + Set, ) -from eth.abc import CodeStreamAPI +from eth.abc import ( + CodeStreamAPI, +) from eth.validation import ( validate_is_bytes, ) diff --git a/eth/vm/computation/base_computation.py b/eth/vm/computation/base_computation.py index f7ba78f128..3be3a2058d 100644 --- a/eth/vm/computation/base_computation.py +++ b/eth/vm/computation/base_computation.py @@ -1,4 +1,6 @@ -from types import TracebackType +from types import ( + TracebackType, +) from typing import ( Any, Callable, @@ -12,8 +14,9 @@ Union, ) -from cached_property import cached_property - +from cached_property import ( + cached_property, +) from eth_typing import ( Address, ) @@ -28,13 +31,13 @@ ceil32, ) from eth.abc import ( + CodeStreamAPI, ComputationAPI, - MemoryAPI, - StackAPI, GasMeterAPI, - OpcodeAPI, - CodeStreamAPI, + MemoryAPI, MessageComputationAPI, + OpcodeAPI, + StackAPI, StateAPI, ) from eth.constants import ( diff --git a/eth/vm/computation/message_computation.py b/eth/vm/computation/message_computation.py index 7fdebf33c5..692ef8a81b 100644 --- a/eth/vm/computation/message_computation.py +++ b/eth/vm/computation/message_computation.py @@ -1,5 +1,7 @@ import itertools -from types import TracebackType +from types import ( + TracebackType, +) from typing import ( Any, Dict, @@ -11,10 +13,6 @@ cast, ) -from eth.vm.computation.base_computation import ( - BaseComputation, - NO_RESULT, -) from eth_typing import ( Address, ) @@ -44,6 +42,10 @@ from eth.vm.code_stream import ( CodeStream, ) +from eth.vm.computation.base_computation import ( + NO_RESULT, + BaseComputation, +) from eth.vm.gas_meter import ( GasMeter, ) diff --git a/eth/vm/execution_context.py b/eth/vm/execution_context.py index 85941f11ce..c68a189161 100644 --- a/eth/vm/execution_context.py +++ b/eth/vm/execution_context.py @@ -9,8 +9,12 @@ Hash32, ) -from eth.abc import ExecutionContextAPI -from eth._utils.generator import CachedIterable +from eth._utils.generator import ( + CachedIterable, +) +from eth.abc import ( + ExecutionContextAPI, +) class ExecutionContext(ExecutionContextAPI): diff --git a/eth/vm/forks/arrow_glacier/blocks.py b/eth/vm/forks/arrow_glacier/blocks.py index aaa042c9f0..e2eafe201b 100644 --- a/eth/vm/forks/arrow_glacier/blocks.py +++ b/eth/vm/forks/arrow_glacier/blocks.py @@ -1,18 +1,21 @@ -from abc import ABC -from typing import Type +from abc import ( + ABC, +) +from typing import ( + Type, +) -from eth.abc import TransactionBuilderAPI from eth_utils import ( encode_hex, ) - from rlp.sedes import ( CountableList, ) -from .transactions import ( - ArrowGlacierTransactionBuilder, +from eth.abc import ( + TransactionBuilderAPI, ) + from ..london import ( LondonBlock, ) @@ -21,6 +24,9 @@ LondonBlockHeader, LondonMiningHeader, ) +from .transactions import ( + ArrowGlacierTransactionBuilder, +) class ArrowGlacierMiningHeader(LondonMiningHeader, ABC): diff --git a/eth/vm/forks/arrow_glacier/computation.py b/eth/vm/forks/arrow_glacier/computation.py index b61816c076..8fce10213a 100644 --- a/eth/vm/forks/arrow_glacier/computation.py +++ b/eth/vm/forks/arrow_glacier/computation.py @@ -1,4 +1,6 @@ -from ..london.computation import LondonMessageComputation +from ..london.computation import ( + LondonMessageComputation, +) class ArrowGlacierMessageComputation(LondonMessageComputation): diff --git a/eth/vm/forks/arrow_glacier/headers.py b/eth/vm/forks/arrow_glacier/headers.py index ae99201444..0f5f9de3d8 100644 --- a/eth/vm/forks/arrow_glacier/headers.py +++ b/eth/vm/forks/arrow_glacier/headers.py @@ -1,20 +1,27 @@ -from typing import Any, Callable, Optional - -from toolz import curry +from typing import ( + Any, + Callable, + Optional, +) -from eth.abc import BlockHeaderAPI -from .blocks import ( - ArrowGlacierBlockHeader, +from toolz import ( + curry, ) -from eth.vm.forks.london.headers import ( - create_london_header_from_parent, + +from eth.abc import ( + BlockHeaderAPI, ) from eth.vm.forks.byzantium.headers import ( compute_difficulty, -) -from eth.vm.forks.byzantium.headers import ( configure_header, ) +from eth.vm.forks.london.headers import ( + create_london_header_from_parent, +) + +from .blocks import ( + ArrowGlacierBlockHeader, +) compute_arrow_glacier_difficulty = compute_difficulty(10_700_000) configure_arrow_glacier_header = configure_header(difficulty_fn=compute_arrow_glacier_difficulty) diff --git a/eth/vm/forks/arrow_glacier/state.py b/eth/vm/forks/arrow_glacier/state.py index ccc820a370..f1cfbd2b71 100644 --- a/eth/vm/forks/arrow_glacier/state.py +++ b/eth/vm/forks/arrow_glacier/state.py @@ -1,9 +1,20 @@ -from typing import Type +from typing import ( + Type, +) -from eth.abc import TransactionExecutorAPI -from .computation import ArrowGlacierMessageComputation -from ..london import LondonState -from ..london.state import LondonTransactionExecutor +from eth.abc import ( + TransactionExecutorAPI, +) + +from ..london import ( + LondonState, +) +from ..london.state import ( + LondonTransactionExecutor, +) +from .computation import ( + ArrowGlacierMessageComputation, +) class ArrowGlacierTransactionExecutor(LondonTransactionExecutor): diff --git a/eth/vm/forks/arrow_glacier/transactions.py b/eth/vm/forks/arrow_glacier/transactions.py index b90b66202f..5f44eefe91 100644 --- a/eth/vm/forks/arrow_glacier/transactions.py +++ b/eth/vm/forks/arrow_glacier/transactions.py @@ -1,6 +1,10 @@ -from abc import ABC +from abc import ( + ABC, +) -from eth_keys.datatypes import PrivateKey +from eth_keys.datatypes import ( + PrivateKey, +) from eth._utils.transactions import ( create_transaction_signature, diff --git a/eth/vm/forks/berlin/blocks.py b/eth/vm/forks/berlin/blocks.py index 7e062e7a10..0e31e7b435 100644 --- a/eth/vm/forks/berlin/blocks.py +++ b/eth/vm/forks/berlin/blocks.py @@ -1,4 +1,6 @@ -from typing import Type +from typing import ( + Type, +) from rlp.sedes import ( CountableList, diff --git a/eth/vm/forks/berlin/computation.py b/eth/vm/forks/berlin/computation.py index 6046cf6146..2ceddd1ebb 100644 --- a/eth/vm/forks/berlin/computation.py +++ b/eth/vm/forks/berlin/computation.py @@ -7,10 +7,6 @@ merge, ) -from eth.precompiles.modexp import ( - extract_lengths, - modexp, -) from eth._utils.address import ( force_bytes_to_address, ) @@ -20,17 +16,21 @@ from eth._utils.padding import ( zpad_right, ) - -from eth.vm.forks.berlin import constants - -from eth.vm.forks.muir_glacier.computation import ( - MUIR_GLACIER_PRECOMPILES +from eth.precompiles.modexp import ( + extract_lengths, + modexp, +) +from eth.vm.forks.berlin import ( + constants, ) from eth.vm.forks.muir_glacier.computation import ( + MUIR_GLACIER_PRECOMPILES, MuirGlacierMessageComputation, ) -from .opcodes import BERLIN_OPCODES +from .opcodes import ( + BERLIN_OPCODES, +) def _calculate_multiplication_complexity(base_length: int, modulus_length: int) -> int: diff --git a/eth/vm/forks/berlin/headers.py b/eth/vm/forks/berlin/headers.py index 93262f1a99..8457e9d25c 100644 --- a/eth/vm/forks/berlin/headers.py +++ b/eth/vm/forks/berlin/headers.py @@ -1,10 +1,9 @@ from eth.vm.forks.muir_glacier.headers import ( + compute_muir_glacier_difficulty, configure_header, create_header_from_parent, - compute_muir_glacier_difficulty, ) - compute_berlin_difficulty = compute_muir_glacier_difficulty create_berlin_header_from_parent = create_header_from_parent( diff --git a/eth/vm/forks/berlin/logic.py b/eth/vm/forks/berlin/logic.py index b0bbf30939..f6e3f20509 100644 --- a/eth/vm/forks/berlin/logic.py +++ b/eth/vm/forks/berlin/logic.py @@ -1,16 +1,22 @@ from eth_typing import ( Address, ) -from eth_utils.toolz import curry +from eth_utils.toolz import ( + curry, +) -from eth import constants +from eth import ( + constants, +) from eth._utils.address import ( force_bytes_to_address, ) from eth.abc import ( MessageComputationAPI, ) -from eth.vm import mnemonics +from eth.vm import ( + mnemonics, +) from eth.vm.forks.istanbul.storage import ( GAS_SCHEDULE_EIP2200, sstore_eip2200_generic, @@ -23,8 +29,8 @@ ) from eth.vm.logic.context import ( consume_extcodecopy_word_cost, - push_balance_of_address, extcodecopy_execute, + push_balance_of_address, ) from eth.vm.logic.storage import ( NetSStoreGasSchedule, @@ -36,7 +42,9 @@ selfdestruct_eip161_on_address, ) -from . import constants as berlin_constants +from . import ( + constants as berlin_constants, +) def _mark_address_warm(computation: MessageComputationAPI, address: Address) -> bool: diff --git a/eth/vm/forks/berlin/opcodes.py b/eth/vm/forks/berlin/opcodes.py index bc82b88b52..cea4c051f8 100644 --- a/eth/vm/forks/berlin/opcodes.py +++ b/eth/vm/forks/berlin/opcodes.py @@ -1,30 +1,36 @@ import copy -from typing import Dict +from typing import ( + Dict, +) -from eth_utils.toolz import merge +from eth_utils.toolz import ( + merge, +) +from eth import ( + constants, +) from eth.vm import ( mnemonics, opcode_values, ) -from eth.vm.opcode import ( - Opcode, - as_opcode, -) -from eth import constants - -from eth.vm.forks.tangerine_whistle.constants import ( - GAS_SELFDESTRUCT_EIP150, -) from eth.vm.forks.byzantium.opcodes import ( ensure_no_static, ) from eth.vm.forks.muir_glacier.opcodes import ( MUIR_GLACIER_OPCODES, ) +from eth.vm.forks.tangerine_whistle.constants import ( + GAS_SELFDESTRUCT_EIP150, +) +from eth.vm.opcode import ( + Opcode, + as_opcode, +) -from . import logic - +from . import ( + logic, +) UPDATED_OPCODES: Dict[int, Opcode] = { opcode_values.BALANCE: as_opcode( diff --git a/eth/vm/forks/berlin/receipts.py b/eth/vm/forks/berlin/receipts.py index 6c2b2b54a8..2dbb8c3e50 100644 --- a/eth/vm/forks/berlin/receipts.py +++ b/eth/vm/forks/berlin/receipts.py @@ -4,8 +4,12 @@ Type, ) -from cached_property import cached_property -from eth_bloom import BloomFilter +from cached_property import ( + cached_property, +) +from eth_bloom import ( + BloomFilter, +) from eth_utils import ( ValidationError, to_bytes, @@ -23,15 +27,18 @@ ReceiptBuilderAPI, ReceiptDecoderAPI, ) -from eth.exceptions import UnrecognizedTransactionType -from eth.rlp.receipts import Receipt +from eth.exceptions import ( + UnrecognizedTransactionType, +) +from eth.rlp.receipts import ( + Receipt, +) from .constants import ( ACCESS_LIST_TRANSACTION_TYPE, VALID_TRANSACTION_TYPES, ) - TYPED_RECEIPT_BODY_CODECS = { # Note that the body of a "type 1" receipt uses exactly the same codec as a # legacy receipt, so we can simply reuse all the logic. diff --git a/eth/vm/forks/berlin/state.py b/eth/vm/forks/berlin/state.py index cc66db771b..dbae9ea2ba 100644 --- a/eth/vm/forks/berlin/state.py +++ b/eth/vm/forks/berlin/state.py @@ -1,19 +1,23 @@ -from typing import Type +from typing import ( + Type, +) from eth.abc import ( - MessageComputationAPI, MessageAPI, + MessageComputationAPI, SignedTransactionAPI, TransactionExecutorAPI, ) from eth.vm.forks.muir_glacier.state import ( - MuirGlacierState + MuirGlacierState, ) from eth.vm.forks.spurious_dragon.state import ( SpuriousDragonTransactionExecutor, ) -from .computation import BerlinMessageComputation +from .computation import ( + BerlinMessageComputation, +) class BerlinTransactionExecutor(SpuriousDragonTransactionExecutor): diff --git a/eth/vm/forks/berlin/transactions.py b/eth/vm/forks/berlin/transactions.py index 83cd1e040a..b68c7fe803 100644 --- a/eth/vm/forks/berlin/transactions.py +++ b/eth/vm/forks/berlin/transactions.py @@ -4,13 +4,19 @@ Sequence, Tuple, Type, - cast, Union, + cast, ) -from cached_property import cached_property -from eth_keys.datatypes import PrivateKey -from eth_hash.auto import keccak +from cached_property import ( + cached_property, +) +from eth_hash.auto import ( + keccak, +) +from eth_keys.datatypes import ( + PrivateKey, +) from eth_typing import ( Address, Hash32, @@ -29,6 +35,12 @@ binary, ) +from eth._utils.transactions import ( + calculate_intrinsic_gas, + create_transaction_signature, + extract_transaction_sender, + validate_transaction_signature, +) from eth.abc import ( DecodedZeroOrOneLayerRLP, ReceiptAPI, @@ -37,12 +49,24 @@ TransactionDecoderAPI, UnsignedTransactionAPI, ) -from eth.constants import CREATE_CONTRACT_ADDRESS -from eth.exceptions import UnrecognizedTransactionType -from eth.rlp.logs import Log -from eth.rlp.receipts import Receipt -from eth.rlp.sedes import address -from eth.rlp.transactions import SignedTransactionMethods +from eth.constants import ( + CREATE_CONTRACT_ADDRESS, +) +from eth.exceptions import ( + UnrecognizedTransactionType, +) +from eth.rlp.logs import ( + Log, +) +from eth.rlp.receipts import ( + Receipt, +) +from eth.rlp.sedes import ( + address, +) +from eth.rlp.transactions import ( + SignedTransactionMethods, +) from eth.validation import ( validate_canonical_address, validate_is_bytes, @@ -57,13 +81,6 @@ MuirGlacierUnsignedTransaction, ) -from eth._utils.transactions import ( - calculate_intrinsic_gas, - create_transaction_signature, - extract_transaction_sender, - validate_transaction_signature, -) - from .constants import ( ACCESS_LIST_ADDRESS_COST_EIP_2930, ACCESS_LIST_STORAGE_KEY_COST_EIP_2930, diff --git a/eth/vm/forks/byzantium/blocks.py b/eth/vm/forks/byzantium/blocks.py index 3ce0d707f3..20a523e8a8 100644 --- a/eth/vm/forks/byzantium/blocks.py +++ b/eth/vm/forks/byzantium/blocks.py @@ -1,6 +1,7 @@ from rlp.sedes import ( CountableList, ) + from eth.rlp.headers import ( BlockHeader, ) diff --git a/eth/vm/forks/byzantium/computation.py b/eth/vm/forks/byzantium/computation.py index 30becc1e5d..0522c78b34 100644 --- a/eth/vm/forks/byzantium/computation.py +++ b/eth/vm/forks/byzantium/computation.py @@ -2,14 +2,22 @@ merge, ) -from eth import precompiles +from eth import ( + precompiles, +) from eth._utils.address import ( force_bytes_to_address, ) -from eth.vm.forks.frontier.computation import FRONTIER_PRECOMPILES -from eth.vm.forks.spurious_dragon.computation import SpuriousDragonMessageComputation +from eth.vm.forks.frontier.computation import ( + FRONTIER_PRECOMPILES, +) +from eth.vm.forks.spurious_dragon.computation import ( + SpuriousDragonMessageComputation, +) -from .opcodes import BYZANTIUM_OPCODES +from .opcodes import ( + BYZANTIUM_OPCODES, +) BYZANTIUM_PRECOMPILES = merge( FRONTIER_PRECOMPILES, diff --git a/eth/vm/forks/byzantium/constants.py b/eth/vm/forks/byzantium/constants.py index 9c4d445d18..9bea1d0549 100644 --- a/eth/vm/forks/byzantium/constants.py +++ b/eth/vm/forks/byzantium/constants.py @@ -1,4 +1,6 @@ -from eth_utils import denoms +from eth_utils import ( + denoms, +) # # Difficulty diff --git a/eth/vm/forks/byzantium/headers.py b/eth/vm/forks/byzantium/headers.py index 6cacd0e440..a6be477229 100644 --- a/eth/vm/forks/byzantium/headers.py +++ b/eth/vm/forks/byzantium/headers.py @@ -2,26 +2,27 @@ Any, Callable, ) + from eth_utils.toolz import ( curry, ) +from eth._utils.db import ( + get_parent_header, +) +from eth._utils.headers import ( + new_timestamp_from_parent, +) from eth.abc import ( BlockHeaderAPI, VirtualMachineAPI, ) from eth.constants import ( - EMPTY_UNCLE_HASH, + BOMB_EXPONENTIAL_FREE_PERIODS, + BOMB_EXPONENTIAL_PERIOD, DIFFICULTY_ADJUSTMENT_DENOMINATOR, DIFFICULTY_MINIMUM, - BOMB_EXPONENTIAL_PERIOD, - BOMB_EXPONENTIAL_FREE_PERIODS, -) -from eth._utils.db import ( - get_parent_header, -) -from eth._utils.headers import ( - new_timestamp_from_parent, + EMPTY_UNCLE_HASH, ) from eth.validation import ( validate_gt, @@ -32,7 +33,7 @@ ) from .constants import ( - BYZANTIUM_DIFFICULTY_ADJUSTMENT_CUTOFF + BYZANTIUM_DIFFICULTY_ADJUSTMENT_CUTOFF, ) diff --git a/eth/vm/forks/byzantium/opcodes.py b/eth/vm/forks/byzantium/opcodes.py index 3e614f195f..807e7cf519 100644 --- a/eth/vm/forks/byzantium/opcodes.py +++ b/eth/vm/forks/byzantium/opcodes.py @@ -1,26 +1,37 @@ import copy import functools -from typing import Dict - -from eth_utils.toolz import merge - from typing import ( Any, Callable, + Dict, ) -from eth import constants +from eth_utils.toolz import ( + merge, +) -from eth.abc import OpcodeAPI +from eth import ( + constants, +) +from eth.abc import ( + OpcodeAPI, +) from eth.exceptions import ( WriteProtection, ) -from eth.vm import mnemonics -from eth.vm import opcode_values -from eth.vm.computation import MessageComputation +from eth.vm import ( + mnemonics, + opcode_values, +) +from eth.vm.computation import ( + MessageComputation, +) +from eth.vm.forks.spurious_dragon.opcodes import ( + SPURIOUS_DRAGON_OPCODES, +) from eth.vm.forks.tangerine_whistle.constants import ( GAS_CALL_EIP150, - GAS_SELFDESTRUCT_EIP150 + GAS_SELFDESTRUCT_EIP150, ) from eth.vm.logic import ( call, @@ -29,9 +40,9 @@ storage, system, ) -from eth.vm.opcode import as_opcode - -from eth.vm.forks.spurious_dragon.opcodes import SPURIOUS_DRAGON_OPCODES +from eth.vm.opcode import ( + as_opcode, +) def ensure_no_static(opcode_fn: Callable[..., Any]) -> Callable[..., Any]: diff --git a/eth/vm/forks/byzantium/state.py b/eth/vm/forks/byzantium/state.py index 0ff9c3164f..14d6b71027 100644 --- a/eth/vm/forks/byzantium/state.py +++ b/eth/vm/forks/byzantium/state.py @@ -1,6 +1,10 @@ -from eth.vm.forks.spurious_dragon.state import SpuriousDragonState +from eth.vm.forks.spurious_dragon.state import ( + SpuriousDragonState, +) -from .computation import ByzantiumMessageComputation +from .computation import ( + ByzantiumMessageComputation, +) class ByzantiumState(SpuriousDragonState): diff --git a/eth/vm/forks/byzantium/transactions.py b/eth/vm/forks/byzantium/transactions.py index 4f40e07ee4..91d51de838 100644 --- a/eth/vm/forks/byzantium/transactions.py +++ b/eth/vm/forks/byzantium/transactions.py @@ -1,10 +1,13 @@ -from eth_keys.datatypes import PrivateKey -from eth_typing import Address +from eth_keys.datatypes import ( + PrivateKey, +) +from eth_typing import ( + Address, +) from eth._utils.transactions import ( create_transaction_signature, ) - from eth.vm.forks.spurious_dragon.transactions import ( SpuriousDragonTransaction, SpuriousDragonUnsignedTransaction, diff --git a/eth/vm/forks/constantinople/blocks.py b/eth/vm/forks/constantinople/blocks.py index 8bd7480596..f8021ee767 100644 --- a/eth/vm/forks/constantinople/blocks.py +++ b/eth/vm/forks/constantinople/blocks.py @@ -1,6 +1,7 @@ from rlp.sedes import ( CountableList, ) + from eth.rlp.headers import ( BlockHeader, ) diff --git a/eth/vm/forks/constantinople/computation.py b/eth/vm/forks/constantinople/computation.py index 2fbf5dd107..b6f3df2087 100644 --- a/eth/vm/forks/constantinople/computation.py +++ b/eth/vm/forks/constantinople/computation.py @@ -1,15 +1,15 @@ from eth.vm.forks.byzantium.computation import ( - BYZANTIUM_PRECOMPILES -) -from eth.vm.forks.byzantium.computation import ( - ByzantiumMessageComputation + BYZANTIUM_PRECOMPILES, + ByzantiumMessageComputation, ) from eth.vm.gas_meter import ( - allow_negative_refund_strategy, GasMeter, + allow_negative_refund_strategy, ) -from .opcodes import CONSTANTINOPLE_OPCODES +from .opcodes import ( + CONSTANTINOPLE_OPCODES, +) CONSTANTINOPLE_PRECOMPILES = BYZANTIUM_PRECOMPILES diff --git a/eth/vm/forks/constantinople/constants.py b/eth/vm/forks/constantinople/constants.py index 3c9424f8bb..b85c0bb931 100644 --- a/eth/vm/forks/constantinople/constants.py +++ b/eth/vm/forks/constantinople/constants.py @@ -1,5 +1,6 @@ -from eth_utils import denoms - +from eth_utils import ( + denoms, +) GAS_EXTCODEHASH_EIP1052 = 400 GAS_SSTORE_EIP1283_NOOP = 200 diff --git a/eth/vm/forks/constantinople/headers.py b/eth/vm/forks/constantinople/headers.py index 4a75b016bc..d477659dce 100644 --- a/eth/vm/forks/constantinople/headers.py +++ b/eth/vm/forks/constantinople/headers.py @@ -1,10 +1,9 @@ from eth.vm.forks.byzantium.headers import ( + compute_difficulty, configure_header, create_header_from_parent, - compute_difficulty, ) - compute_constantinople_difficulty = compute_difficulty(5000000) create_constantinople_header_from_parent = create_header_from_parent( diff --git a/eth/vm/forks/constantinople/opcodes.py b/eth/vm/forks/constantinople/opcodes.py index 658b5ca4c4..9655a80e03 100644 --- a/eth/vm/forks/constantinople/opcodes.py +++ b/eth/vm/forks/constantinople/opcodes.py @@ -1,10 +1,11 @@ import copy + from eth_utils.toolz import ( - merge + merge, ) from eth import ( - constants + constants, ) from eth.vm import ( mnemonics, @@ -12,10 +13,10 @@ ) from eth.vm.forks.byzantium.opcodes import ( BYZANTIUM_OPCODES, - ensure_no_static + ensure_no_static, ) from eth.vm.forks.constantinople.constants import ( - GAS_EXTCODEHASH_EIP1052 + GAS_EXTCODEHASH_EIP1052, ) from eth.vm.forks.constantinople.storage import ( sstore_eip1283, @@ -26,10 +27,9 @@ system, ) from eth.vm.opcode import ( - as_opcode + as_opcode, ) - UPDATED_OPCODES = { opcode_values.SHL: as_opcode( logic_fn=arithmetic.shl, diff --git a/eth/vm/forks/constantinople/state.py b/eth/vm/forks/constantinople/state.py index ca41f928d5..2a4d658cd7 100644 --- a/eth/vm/forks/constantinople/state.py +++ b/eth/vm/forks/constantinople/state.py @@ -1,8 +1,10 @@ from eth.vm.forks.byzantium.state import ( - ByzantiumState + ByzantiumState, ) -from .computation import ConstantinopleMessageComputation +from .computation import ( + ConstantinopleMessageComputation, +) class ConstantinopleState(ByzantiumState): diff --git a/eth/vm/forks/constantinople/storage.py b/eth/vm/forks/constantinople/storage.py index 829444940e..ecc7ae47e7 100644 --- a/eth/vm/forks/constantinople/storage.py +++ b/eth/vm/forks/constantinople/storage.py @@ -1,8 +1,10 @@ -from functools import partial +from functools import ( + partial, +) from eth.vm.logic.storage import ( - net_sstore, NetSStoreGasSchedule, + net_sstore, ) GAS_SCHEDULE_EIP1283 = NetSStoreGasSchedule( diff --git a/eth/vm/forks/constantinople/transactions.py b/eth/vm/forks/constantinople/transactions.py index daed44e4b0..093b357b7b 100644 --- a/eth/vm/forks/constantinople/transactions.py +++ b/eth/vm/forks/constantinople/transactions.py @@ -1,14 +1,17 @@ -from eth_keys.datatypes import PrivateKey -from eth_typing import Address - -from eth.vm.forks.byzantium.transactions import ( - ByzantiumTransaction, - ByzantiumUnsignedTransaction, +from eth_keys.datatypes import ( + PrivateKey, +) +from eth_typing import ( + Address, ) from eth._utils.transactions import ( create_transaction_signature, ) +from eth.vm.forks.byzantium.transactions import ( + ByzantiumTransaction, + ByzantiumUnsignedTransaction, +) class ConstantinopleTransaction(ByzantiumTransaction): diff --git a/eth/vm/forks/frontier/blocks.py b/eth/vm/forks/frontier/blocks.py index 75ce44bc40..7145771f03 100644 --- a/eth/vm/forks/frontier/blocks.py +++ b/eth/vm/forks/frontier/blocks.py @@ -4,19 +4,16 @@ Type, ) -from rlp.sedes import ( - CountableList, -) - from eth_bloom import ( BloomFilter, ) - from eth_typing import ( BlockNumber, Hash32, ) - +from rlp.sedes import ( + CountableList, +) from trie.exceptions import ( MissingTrieNode, ) diff --git a/eth/vm/forks/frontier/computation.py b/eth/vm/forks/frontier/computation.py index 693ece056e..f662334add 100644 --- a/eth/vm/forks/frontier/computation.py +++ b/eth/vm/forks/frontier/computation.py @@ -1,35 +1,38 @@ -from eth import precompiles - -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_utils import ( encode_hex, ) -from eth.constants import ( - GAS_CODEDEPOSIT, - STACK_DEPTH_LIMIT, +from eth import ( + precompiles, ) - from eth._utils.address import ( force_bytes_to_address, ) from eth.abc import ( - MessageComputationAPI, MessageAPI, + MessageComputationAPI, StateAPI, TransactionContextAPI, ) +from eth.constants import ( + GAS_CODEDEPOSIT, + STACK_DEPTH_LIMIT, +) from eth.exceptions import ( - OutOfGas, InsufficientFunds, + OutOfGas, StackDepthLimit, ) from eth.vm.computation import ( MessageComputation, ) -from .opcodes import FRONTIER_OPCODES - +from .opcodes import ( + FRONTIER_OPCODES, +) FRONTIER_PRECOMPILES = { force_bytes_to_address(b'\x01'): precompiles.ecrecover, diff --git a/eth/vm/forks/frontier/headers.py b/eth/vm/forks/frontier/headers.py index f7fce87301..d71bd60d87 100644 --- a/eth/vm/forks/frontier/headers.py +++ b/eth/vm/forks/frontier/headers.py @@ -1,21 +1,8 @@ from typing import ( - Any, TYPE_CHECKING, + Any, ) -from eth.abc import BlockHeaderAPI -from eth.validation import ( - validate_gt, - validate_header_params_for_configuration, -) - -from eth.constants import ( - GENESIS_GAS_LIMIT, - DIFFICULTY_ADJUSTMENT_DENOMINATOR, - DIFFICULTY_MINIMUM, - BOMB_EXPONENTIAL_PERIOD, - BOMB_EXPONENTIAL_FREE_PERIODS, -) from eth._utils.db import ( get_parent_header, ) @@ -24,14 +11,30 @@ fill_header_params_from_parent, new_timestamp_from_parent, ) -from eth.rlp.headers import BlockHeader +from eth.abc import ( + BlockHeaderAPI, +) +from eth.constants import ( + BOMB_EXPONENTIAL_FREE_PERIODS, + BOMB_EXPONENTIAL_PERIOD, + DIFFICULTY_ADJUSTMENT_DENOMINATOR, + DIFFICULTY_MINIMUM, + GENESIS_GAS_LIMIT, +) +from eth.rlp.headers import ( + BlockHeader, +) +from eth.validation import ( + validate_gt, + validate_header_params_for_configuration, +) from .constants import ( - FRONTIER_DIFFICULTY_ADJUSTMENT_CUTOFF + FRONTIER_DIFFICULTY_ADJUSTMENT_CUTOFF, ) if TYPE_CHECKING: - from eth.vm.forks.frontier import FrontierVM # noqa: F401 + from eth.vm.forks.frontier import FrontierVM # noqa: F401 def compute_frontier_difficulty(parent_header: BlockHeaderAPI, timestamp: int) -> int: diff --git a/eth/vm/forks/frontier/opcodes.py b/eth/vm/forks/frontier/opcodes.py index c265338250..1b5f2158d9 100644 --- a/eth/vm/forks/frontier/opcodes.py +++ b/eth/vm/forks/frontier/opcodes.py @@ -1,10 +1,17 @@ -from typing import Dict - -from eth import constants +from typing import ( + Dict, +) -from eth.abc import OpcodeAPI -from eth.vm import mnemonics -from eth.vm import opcode_values +from eth import ( + constants, +) +from eth.abc import ( + OpcodeAPI, +) +from eth.vm import ( + mnemonics, + opcode_values, +) from eth.vm.logic import ( arithmetic, block, @@ -25,7 +32,6 @@ as_opcode, ) - FRONTIER_OPCODES: Dict[int, OpcodeAPI] = { # # Arithmetic diff --git a/eth/vm/forks/frontier/state.py b/eth/vm/forks/frontier/state.py index ee8da8b623..111cdd2b3e 100644 --- a/eth/vm/forks/frontier/state.py +++ b/eth/vm/forks/frontier/state.py @@ -1,30 +1,34 @@ -from typing import Type +from typing import ( + Type, +) -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_utils import ( encode_hex, ) +from eth._utils.address import ( + generate_contract_address, +) from eth.abc import ( AccountDatabaseAPI, + MessageAPI, MessageComputationAPI, SignedTransactionAPI, - MessageAPI, TransactionContextAPI, TransactionExecutorAPI, ) -from eth.constants import CREATE_CONTRACT_ADDRESS +from eth.constants import ( + CREATE_CONTRACT_ADDRESS, +) from eth.db.account import ( AccountDB, ) from eth.exceptions import ( ContractCreationCollision, ) - -from eth._utils.address import ( - generate_contract_address, -) - from eth.vm.message import ( Message, ) @@ -33,16 +37,19 @@ BaseTransactionExecutor, ) - -from .computation import FrontierMessageComputation +from .computation import ( + FrontierMessageComputation, +) from .constants import ( - REFUND_SELFDESTRUCT, MAX_REFUND_QUOTIENT, + REFUND_SELFDESTRUCT, ) from .transaction_context import ( - FrontierTransactionContext + FrontierTransactionContext, +) +from .validation import ( + validate_frontier_transaction, ) -from .validation import validate_frontier_transaction class FrontierTransactionExecutor(BaseTransactionExecutor): diff --git a/eth/vm/forks/frontier/transaction_context.py b/eth/vm/forks/frontier/transaction_context.py index 4f63c6fc9a..fc5520a59d 100644 --- a/eth/vm/forks/frontier/transaction_context.py +++ b/eth/vm/forks/frontier/transaction_context.py @@ -1,4 +1,6 @@ -from eth.vm.transaction_context import BaseTransactionContext +from eth.vm.transaction_context import ( + BaseTransactionContext, +) class FrontierTransactionContext(BaseTransactionContext): diff --git a/eth/vm/forks/frontier/transactions.py b/eth/vm/forks/frontier/transactions.py index d6e0d4bf34..49557aeb3a 100644 --- a/eth/vm/forks/frontier/transactions.py +++ b/eth/vm/forks/frontier/transactions.py @@ -1,14 +1,26 @@ -from functools import partial +from functools import ( + partial, +) from typing import ( Tuple, ) -from eth_keys.datatypes import PrivateKey +from eth_keys.datatypes import ( + PrivateKey, +) from eth_typing import ( Address, ) import rlp +from eth._utils.transactions import ( + V_OFFSET, + IntrinsicGasSchedule, + calculate_intrinsic_gas, + create_transaction_signature, + extract_transaction_sender, + validate_transaction_signature, +) from eth.abc import ( ReceiptAPI, SignedTransactionAPI, @@ -16,36 +28,29 @@ from eth.constants import ( CREATE_CONTRACT_ADDRESS, GAS_TX, - GAS_TXDATAZERO, GAS_TXDATANONZERO, + GAS_TXDATAZERO, ) -from eth.validation import ( - validate_uint256, - validate_is_integer, - validate_is_bytes, - validate_lt_secpk1n, - validate_lte, - validate_gte, - validate_canonical_address, +from eth.rlp.logs import ( + Log, +) +from eth.rlp.receipts import ( + Receipt, ) - -from eth.rlp.logs import Log -from eth.rlp.receipts import Receipt from eth.rlp.transactions import ( BaseTransaction, BaseUnsignedTransaction, ) - -from eth._utils.transactions import ( - V_OFFSET, - create_transaction_signature, - extract_transaction_sender, - validate_transaction_signature, - IntrinsicGasSchedule, - calculate_intrinsic_gas, +from eth.validation import ( + validate_canonical_address, + validate_gte, + validate_is_bytes, + validate_is_integer, + validate_lt_secpk1n, + validate_lte, + validate_uint256, ) - FRONTIER_TX_GAS_SCHEDULE = IntrinsicGasSchedule( gas_tx=GAS_TX, gas_txcreate=0, diff --git a/eth/vm/forks/gray_glacier/blocks.py b/eth/vm/forks/gray_glacier/blocks.py index 58f0a43273..be1609648d 100644 --- a/eth/vm/forks/gray_glacier/blocks.py +++ b/eth/vm/forks/gray_glacier/blocks.py @@ -1,18 +1,21 @@ -from abc import ABC -from typing import Type +from abc import ( + ABC, +) +from typing import ( + Type, +) -from eth.abc import TransactionBuilderAPI from eth_utils import ( encode_hex, ) - from rlp.sedes import ( CountableList, ) -from .transactions import ( - GrayGlacierTransactionBuilder, +from eth.abc import ( + TransactionBuilderAPI, ) + from ..arrow_glacier import ( ArrowGlacierBlock, ) @@ -20,7 +23,12 @@ ArrowGlacierBlockHeader, ArrowGlacierMiningHeader, ) -from ..london.blocks import LondonBackwardsHeader +from ..london.blocks import ( + LondonBackwardsHeader, +) +from .transactions import ( + GrayGlacierTransactionBuilder, +) class GrayGlacierMiningHeader(ArrowGlacierMiningHeader, ABC): diff --git a/eth/vm/forks/gray_glacier/computation.py b/eth/vm/forks/gray_glacier/computation.py index 378434304d..76e6ac68d5 100644 --- a/eth/vm/forks/gray_glacier/computation.py +++ b/eth/vm/forks/gray_glacier/computation.py @@ -1,4 +1,6 @@ -from ..arrow_glacier.computation import ArrowGlacierMessageComputation +from ..arrow_glacier.computation import ( + ArrowGlacierMessageComputation, +) class GrayGlacierMessageComputation(ArrowGlacierMessageComputation): diff --git a/eth/vm/forks/gray_glacier/headers.py b/eth/vm/forks/gray_glacier/headers.py index 2896f0c75e..b24fa412eb 100644 --- a/eth/vm/forks/gray_glacier/headers.py +++ b/eth/vm/forks/gray_glacier/headers.py @@ -1,10 +1,13 @@ -from typing import Any, Callable, Optional - -from toolz import curry +from typing import ( + Any, + Callable, + Optional, +) -from .blocks import ( - GrayGlacierBlockHeader, +from toolz import ( + curry, ) + from eth.abc import ( BlockHeaderAPI, ) @@ -13,11 +16,13 @@ ) from eth.vm.forks.byzantium.headers import ( compute_difficulty, -) -from eth.vm.forks.byzantium.headers import ( configure_header, ) +from .blocks import ( + GrayGlacierBlockHeader, +) + compute_gray_glacier_difficulty = compute_difficulty(11_400_000) configure_gray_glacier_header = configure_header(difficulty_fn=compute_gray_glacier_difficulty) diff --git a/eth/vm/forks/gray_glacier/state.py b/eth/vm/forks/gray_glacier/state.py index 629ccd65e4..3ed94db872 100644 --- a/eth/vm/forks/gray_glacier/state.py +++ b/eth/vm/forks/gray_glacier/state.py @@ -1,9 +1,20 @@ -from typing import Type +from typing import ( + Type, +) -from eth.abc import TransactionExecutorAPI -from .computation import GrayGlacierMessageComputation -from ..arrow_glacier import ArrowGlacierState -from ..arrow_glacier.state import ArrowGlacierTransactionExecutor +from eth.abc import ( + TransactionExecutorAPI, +) + +from ..arrow_glacier import ( + ArrowGlacierState, +) +from ..arrow_glacier.state import ( + ArrowGlacierTransactionExecutor, +) +from .computation import ( + GrayGlacierMessageComputation, +) class GrayGlacierTransactionExecutor(ArrowGlacierTransactionExecutor): diff --git a/eth/vm/forks/gray_glacier/transactions.py b/eth/vm/forks/gray_glacier/transactions.py index 008be551f6..ab4d758695 100644 --- a/eth/vm/forks/gray_glacier/transactions.py +++ b/eth/vm/forks/gray_glacier/transactions.py @@ -1,6 +1,10 @@ -from abc import ABC +from abc import ( + ABC, +) -from eth_keys.datatypes import PrivateKey +from eth_keys.datatypes import ( + PrivateKey, +) from eth._utils.transactions import ( create_transaction_signature, diff --git a/eth/vm/forks/homestead/blocks.py b/eth/vm/forks/homestead/blocks.py index 5555f26e3f..53aa27b706 100644 --- a/eth/vm/forks/homestead/blocks.py +++ b/eth/vm/forks/homestead/blocks.py @@ -1,12 +1,14 @@ from rlp.sedes import ( CountableList, ) + from eth.rlp.headers import ( BlockHeader, ) from eth.vm.forks.frontier.blocks import ( FrontierBlock, ) + from .transactions import ( HomesteadTransaction, ) diff --git a/eth/vm/forks/homestead/computation.py b/eth/vm/forks/homestead/computation.py index e2926cecb4..9a07fdf85f 100644 --- a/eth/vm/forks/homestead/computation.py +++ b/eth/vm/forks/homestead/computation.py @@ -1,24 +1,29 @@ -from eth_hash.auto import keccak - -from eth import constants -from eth.exceptions import ( - OutOfGas, +from eth_hash.auto import ( + keccak, ) from eth_utils import ( encode_hex, ) +from eth import ( + constants, +) from eth.abc import ( - MessageComputationAPI, MessageAPI, + MessageComputationAPI, StateAPI, TransactionContextAPI, ) +from eth.exceptions import ( + OutOfGas, +) from eth.vm.forks.frontier.computation import ( FrontierMessageComputation, ) -from .opcodes import HOMESTEAD_OPCODES +from .opcodes import ( + HOMESTEAD_OPCODES, +) class HomesteadMessageComputation(FrontierMessageComputation): diff --git a/eth/vm/forks/homestead/headers.py b/eth/vm/forks/homestead/headers.py index 2008b68d2d..9868e41217 100644 --- a/eth/vm/forks/homestead/headers.py +++ b/eth/vm/forks/homestead/headers.py @@ -1,6 +1,6 @@ from typing import ( - Any, TYPE_CHECKING, + Any, ) from eth_typing import ( @@ -10,16 +10,20 @@ decode_hex, ) -from eth.abc import BlockHeaderAPI +from eth._utils.db import ( + get_parent_header, +) +from eth.abc import ( + BlockHeaderAPI, +) from eth.constants import ( + BOMB_EXPONENTIAL_FREE_PERIODS, + BOMB_EXPONENTIAL_PERIOD, DIFFICULTY_ADJUSTMENT_DENOMINATOR, DIFFICULTY_MINIMUM, - BOMB_EXPONENTIAL_PERIOD, - BOMB_EXPONENTIAL_FREE_PERIODS, ) -from eth.rlp.headers import BlockHeader -from eth._utils.db import ( - get_parent_header, +from eth.rlp.headers import ( + BlockHeader, ) from eth.validation import ( validate_gt, @@ -30,11 +34,11 @@ ) from .constants import ( - HOMESTEAD_DIFFICULTY_ADJUSTMENT_CUTOFF + HOMESTEAD_DIFFICULTY_ADJUSTMENT_CUTOFF, ) if TYPE_CHECKING: - from eth.vm.forks.homestead import HomesteadVM # noqa: F401 + from eth.vm.forks.homestead import HomesteadVM # noqa: F401 def compute_homestead_difficulty(parent_header: BlockHeaderAPI, timestamp: int) -> int: diff --git a/eth/vm/forks/homestead/opcodes.py b/eth/vm/forks/homestead/opcodes.py index a3104dcf25..9e3a58ad81 100644 --- a/eth/vm/forks/homestead/opcodes.py +++ b/eth/vm/forks/homestead/opcodes.py @@ -1,19 +1,29 @@ import copy -from typing import Dict +from typing import ( + Dict, +) -from eth_utils.toolz import merge +from eth_utils.toolz import ( + merge, +) -from eth import constants -from eth.abc import OpcodeAPI -from eth.vm import mnemonics -from eth.vm import opcode_values +from eth import ( + constants, +) +from eth.abc import ( + OpcodeAPI, +) +from eth.vm import ( + mnemonics, + opcode_values, +) +from eth.vm.forks.frontier.opcodes import ( + FRONTIER_OPCODES, +) from eth.vm.logic import ( call, ) -from eth.vm.forks.frontier.opcodes import FRONTIER_OPCODES - - NEW_OPCODES = { opcode_values.DELEGATECALL: call.DelegateCall.configure( __name__='opcode:DELEGATECALL', diff --git a/eth/vm/forks/homestead/state.py b/eth/vm/forks/homestead/state.py index c994ee74c3..47a47881b5 100644 --- a/eth/vm/forks/homestead/state.py +++ b/eth/vm/forks/homestead/state.py @@ -1,4 +1,6 @@ -from typing import Type +from typing import ( + Type, +) from eth.abc import ( MessageComputationAPI, @@ -9,8 +11,12 @@ FrontierTransactionExecutor, ) -from .computation import HomesteadMessageComputation -from .validation import validate_homestead_transaction +from .computation import ( + HomesteadMessageComputation, +) +from .validation import ( + validate_homestead_transaction, +) class HomesteadState(FrontierState): diff --git a/eth/vm/forks/homestead/transactions.py b/eth/vm/forks/homestead/transactions.py index f9ba670d17..0cdc3eb6be 100644 --- a/eth/vm/forks/homestead/transactions.py +++ b/eth/vm/forks/homestead/transactions.py @@ -1,26 +1,29 @@ -from functools import partial +from functools import ( + partial, +) +from eth_keys.datatypes import ( + PrivateKey, +) +from eth_typing import ( + Address, +) import rlp -from eth_keys.datatypes import PrivateKey - -from eth_typing import Address - -from eth.constants import GAS_TXCREATE - +from eth._utils.transactions import ( + calculate_intrinsic_gas, + create_transaction_signature, +) +from eth.constants import ( + GAS_TXCREATE, +) from eth.validation import ( validate_lt_secpk1n2, ) - from eth.vm.forks.frontier.transactions import ( + FRONTIER_TX_GAS_SCHEDULE, FrontierTransaction, FrontierUnsignedTransaction, - FRONTIER_TX_GAS_SCHEDULE, -) - -from eth._utils.transactions import ( - create_transaction_signature, - calculate_intrinsic_gas, ) HOMESTEAD_TX_GAS_SCHEDULE = FRONTIER_TX_GAS_SCHEDULE._replace( diff --git a/eth/vm/forks/homestead/validation.py b/eth/vm/forks/homestead/validation.py index b02ecf5031..dca1158893 100644 --- a/eth/vm/forks/homestead/validation.py +++ b/eth/vm/forks/homestead/validation.py @@ -2,14 +2,13 @@ ValidationError, ) -from eth.constants import ( - SECPK1_N, -) - from eth.abc import ( SignedTransactionAPI, StateAPI, ) +from eth.constants import ( + SECPK1_N, +) from eth.vm.forks.frontier.validation import ( validate_frontier_transaction, ) diff --git a/eth/vm/forks/istanbul/blocks.py b/eth/vm/forks/istanbul/blocks.py index 414ee1ac1d..9a6e89b64a 100644 --- a/eth/vm/forks/istanbul/blocks.py +++ b/eth/vm/forks/istanbul/blocks.py @@ -1,6 +1,7 @@ from rlp.sedes import ( CountableList, ) + from eth.rlp.headers import ( BlockHeader, ) diff --git a/eth/vm/forks/istanbul/computation.py b/eth/vm/forks/istanbul/computation.py index d548a113d8..85c45012a9 100644 --- a/eth/vm/forks/istanbul/computation.py +++ b/eth/vm/forks/istanbul/computation.py @@ -2,19 +2,19 @@ merge, ) -from eth import precompiles +from eth import ( + precompiles, +) from eth._utils.address import ( force_bytes_to_address, ) from eth.vm.forks.petersburg.computation import ( - PETERSBURG_PRECOMPILES -) -from eth.vm.forks.petersburg.computation import ( + PETERSBURG_PRECOMPILES, PetersburgMessageComputation, ) from eth.vm.gas_meter import ( - allow_negative_refund_strategy, GasMeter, + allow_negative_refund_strategy, ) from .constants import ( @@ -23,7 +23,9 @@ GAS_ECPAIRING_BASE, GAS_ECPAIRING_PER_POINT, ) -from .opcodes import ISTANBUL_OPCODES +from .opcodes import ( + ISTANBUL_OPCODES, +) ISTANBUL_PRECOMPILES = merge( PETERSBURG_PRECOMPILES, diff --git a/eth/vm/forks/istanbul/headers.py b/eth/vm/forks/istanbul/headers.py index 78d206ad8d..ba3066a583 100644 --- a/eth/vm/forks/istanbul/headers.py +++ b/eth/vm/forks/istanbul/headers.py @@ -1,10 +1,9 @@ from eth.vm.forks.petersburg.headers import ( + compute_petersburg_difficulty, configure_header, create_header_from_parent, - compute_petersburg_difficulty, ) - compute_istanbul_difficulty = compute_petersburg_difficulty create_istanbul_header_from_parent = create_header_from_parent( diff --git a/eth/vm/forks/istanbul/opcodes.py b/eth/vm/forks/istanbul/opcodes.py index b0f7e9d754..2a0a11eb6b 100644 --- a/eth/vm/forks/istanbul/opcodes.py +++ b/eth/vm/forks/istanbul/opcodes.py @@ -1,33 +1,39 @@ import copy -from eth_utils.toolz import merge +from eth_utils.toolz import ( + merge, +) -from eth import constants +from eth import ( + constants, +) from eth.vm import ( mnemonics, opcode_values, ) from eth.vm.forks.byzantium.opcodes import ( - ensure_no_static -) -from eth.vm.forks.petersburg.opcodes import ( - PETERSBURG_OPCODES, + ensure_no_static, ) from eth.vm.forks.istanbul.constants import ( GAS_BALANCE_EIP1884, - GAS_SLOAD_EIP1884, GAS_EXTCODEHASH_EIP1884, + GAS_SLOAD_EIP1884, +) +from eth.vm.forks.petersburg.opcodes import ( + PETERSBURG_OPCODES, ) from eth.vm.logic import ( context, storage, ) -from eth.vm.opcode import as_opcode +from eth.vm.opcode import ( + as_opcode, +) + from .storage import ( sstore_eip2200, ) - UPDATED_OPCODES = { # New opcodes opcode_values.CHAINID: as_opcode( diff --git a/eth/vm/forks/istanbul/state.py b/eth/vm/forks/istanbul/state.py index 92969a76ae..d3e6d6d001 100644 --- a/eth/vm/forks/istanbul/state.py +++ b/eth/vm/forks/istanbul/state.py @@ -1,8 +1,10 @@ from eth.vm.forks.petersburg.state import ( - PetersburgState + PetersburgState, ) -from .computation import IstanbulMessageComputation +from .computation import ( + IstanbulMessageComputation, +) class IstanbulState(PetersburgState): diff --git a/eth/vm/forks/istanbul/storage.py b/eth/vm/forks/istanbul/storage.py index 773ba9da77..b98d378add 100644 --- a/eth/vm/forks/istanbul/storage.py +++ b/eth/vm/forks/istanbul/storage.py @@ -1,12 +1,18 @@ -from eth_utils.toolz import curry +from eth_utils.toolz import ( + curry, +) -from eth.exceptions import OutOfGas -from eth.vm.computation import MessageComputation +from eth.exceptions import ( + OutOfGas, +) +from eth.vm.computation import ( + MessageComputation, +) from eth.vm.forks.constantinople.storage import ( GAS_SCHEDULE_EIP1283, ) from eth.vm.forks.istanbul import ( - constants + constants, ) from eth.vm.logic.storage import ( NetSStoreGasSchedule, diff --git a/eth/vm/forks/istanbul/transactions.py b/eth/vm/forks/istanbul/transactions.py index 2e0e6b7041..76da9a04b1 100644 --- a/eth/vm/forks/istanbul/transactions.py +++ b/eth/vm/forks/istanbul/transactions.py @@ -1,20 +1,25 @@ -from functools import partial - -from eth_keys.datatypes import PrivateKey -from eth_typing import Address +from functools import ( + partial, +) -from eth.vm.forks.petersburg.transactions import ( - PetersburgTransaction, - PetersburgUnsignedTransaction, +from eth_keys.datatypes import ( + PrivateKey, +) +from eth_typing import ( + Address, ) from eth._utils.transactions import ( - create_transaction_signature, calculate_intrinsic_gas, + create_transaction_signature, ) from eth.vm.forks.homestead.transactions import ( HOMESTEAD_TX_GAS_SCHEDULE, ) +from eth.vm.forks.petersburg.transactions import ( + PetersburgTransaction, + PetersburgUnsignedTransaction, +) from .constants import ( GAS_TXDATANONZERO_EIP2028, diff --git a/eth/vm/forks/london/blocks.py b/eth/vm/forks/london/blocks.py index 9526887fd0..a4926df6c4 100644 --- a/eth/vm/forks/london/blocks.py +++ b/eth/vm/forks/london/blocks.py @@ -5,13 +5,15 @@ cast, ) -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_typing import ( BlockNumber, ) from eth_typing.evm import ( Address, - Hash32 + Hash32, ) from eth_utils import ( encode_hex, @@ -21,7 +23,7 @@ Binary, CountableList, big_endian_int, - binary + binary, ) from eth._utils.headers import ( @@ -35,12 +37,12 @@ TransactionBuilderAPI, ) from eth.constants import ( - ZERO_ADDRESS, - ZERO_HASH32, + BLANK_ROOT_HASH, EMPTY_UNCLE_HASH, GENESIS_NONCE, GENESIS_PARENT_HASH, - BLANK_ROOT_HASH, + ZERO_ADDRESS, + ZERO_HASH32, ) from eth.rlp.headers import ( BlockHeader, diff --git a/eth/vm/forks/london/computation.py b/eth/vm/forks/london/computation.py index 7e56152073..60c94040d3 100644 --- a/eth/vm/forks/london/computation.py +++ b/eth/vm/forks/london/computation.py @@ -1,10 +1,16 @@ -from eth.exceptions import ReservedBytesInCode +from eth.exceptions import ( + ReservedBytesInCode, +) from eth.vm.forks.berlin.computation import ( BerlinMessageComputation, ) -from .opcodes import LONDON_OPCODES -from ..london.constants import EIP3541_RESERVED_STARTING_BYTE +from ..london.constants import ( + EIP3541_RESERVED_STARTING_BYTE, +) +from .opcodes import ( + LONDON_OPCODES, +) class LondonMessageComputation(BerlinMessageComputation): diff --git a/eth/vm/forks/london/headers.py b/eth/vm/forks/london/headers.py index 06c5352868..afe2eb683c 100644 --- a/eth/vm/forks/london/headers.py +++ b/eth/vm/forks/london/headers.py @@ -8,7 +8,9 @@ from eth_utils import ( ValidationError, ) -from toolz.functoolz import curry +from toolz.functoolz import ( + curry, +) from eth._utils.headers import ( compute_gas_limit, @@ -19,8 +21,12 @@ BlockHeaderAPI, BlockHeaderSedesAPI, ) -from eth.constants import GENESIS_GAS_LIMIT -from eth.rlp.headers import BlockHeader +from eth.constants import ( + GENESIS_GAS_LIMIT, +) +from eth.rlp.headers import ( + BlockHeader, +) from eth.vm.forks.berlin.headers import ( configure_header, ) @@ -28,8 +34,9 @@ compute_difficulty, ) - -from .blocks import LondonBlockHeader +from .blocks import ( + LondonBlockHeader, +) from .constants import ( BASE_FEE_MAX_CHANGE_DENOMINATOR, ELASTICITY_MULTIPLIER, diff --git a/eth/vm/forks/london/opcodes.py b/eth/vm/forks/london/opcodes.py index 2b1d738044..a3b25f2952 100644 --- a/eth/vm/forks/london/opcodes.py +++ b/eth/vm/forks/london/opcodes.py @@ -1,29 +1,36 @@ import copy -from typing import Dict +from typing import ( + Dict, +) -from eth_utils.toolz import merge +from eth_utils.toolz import ( + merge, +) -from eth.vm.logic import ( - block, +from eth import ( + constants, ) from eth.vm import ( mnemonics, opcode_values, ) -from eth.vm.opcode import ( - Opcode, - as_opcode, -) -from eth import constants - from eth.vm.forks.berlin.opcodes import ( BERLIN_OPCODES, ) from eth.vm.forks.byzantium.opcodes import ( ensure_no_static, ) +from eth.vm.logic import ( + block, +) +from eth.vm.opcode import ( + Opcode, + as_opcode, +) -from . import storage +from . import ( + storage, +) UPDATED_OPCODES: Dict[int, Opcode] = { opcode_values.BASEFEE: as_opcode( diff --git a/eth/vm/forks/london/receipts.py b/eth/vm/forks/london/receipts.py index 105ec9489a..2a7d8ab7b1 100644 --- a/eth/vm/forks/london/receipts.py +++ b/eth/vm/forks/london/receipts.py @@ -6,15 +6,17 @@ from eth.rlp.receipts import ( Receipt, ) +from eth.vm.forks.berlin.constants import ( + ACCESS_LIST_TRANSACTION_TYPE, +) from eth.vm.forks.berlin.receipts import ( BerlinReceiptBuilder, TypedReceipt as BerlinTypedReceipt, ) -from eth.vm.forks.berlin.constants import ( - ACCESS_LIST_TRANSACTION_TYPE, -) -from .constants import DYNAMIC_FEE_TRANSACTION_TYPE +from .constants import ( + DYNAMIC_FEE_TRANSACTION_TYPE, +) class LondonTypedReceipt(BerlinTypedReceipt): diff --git a/eth/vm/forks/london/state.py b/eth/vm/forks/london/state.py index 39ea04d7a0..4ae8ab2665 100644 --- a/eth/vm/forks/london/state.py +++ b/eth/vm/forks/london/state.py @@ -1,13 +1,20 @@ -from typing import Type +from typing import ( + Type, +) -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_utils import ( encode_hex, ) +from eth._utils.address import ( + generate_contract_address, +) from eth.abc import ( - MessageComputationAPI, MessageAPI, + MessageComputationAPI, SignedTransactionAPI, StateAPI, TransactionContextAPI, @@ -16,20 +23,23 @@ from eth.constants import ( CREATE_CONTRACT_ADDRESS, ) -from eth.vm.message import ( - Message, -) from eth.vm.forks.berlin.state import ( BerlinState, BerlinTransactionExecutor, ) -from eth._utils.address import ( - generate_contract_address, +from eth.vm.message import ( + Message, ) -from .computation import LondonMessageComputation -from .validation import validate_london_normalized_transaction -from .constants import EIP3529_MAX_REFUND_QUOTIENT +from .computation import ( + LondonMessageComputation, +) +from .constants import ( + EIP3529_MAX_REFUND_QUOTIENT, +) +from .validation import ( + validate_london_normalized_transaction, +) class LondonTransactionExecutor(BerlinTransactionExecutor): diff --git a/eth/vm/forks/london/storage.py b/eth/vm/forks/london/storage.py index a72f663a0c..96e84732b1 100644 --- a/eth/vm/forks/london/storage.py +++ b/eth/vm/forks/london/storage.py @@ -1,12 +1,15 @@ -from eth_utils.toolz import partial +from eth_utils.toolz import ( + partial, +) -from eth.vm.forks.berlin import constants as berlin_constants +from eth.vm.forks.berlin import ( + constants as berlin_constants, +) from eth.vm.forks.berlin.logic import ( GAS_SCHEDULE_EIP2929, sstore_eip2929_generic, ) - SSTORE_CLEARS_SCHEDULE_EIP_3529 = ( GAS_SCHEDULE_EIP2929.sstore_reset_gas + berlin_constants.ACCESS_LIST_STORAGE_KEY_COST_EIP_2930 diff --git a/eth/vm/forks/london/transactions.py b/eth/vm/forks/london/transactions.py index 74cf58d50b..8550748623 100644 --- a/eth/vm/forks/london/transactions.py +++ b/eth/vm/forks/london/transactions.py @@ -1,4 +1,3 @@ -from cached_property import cached_property from typing import ( Dict, Sequence, @@ -7,7 +6,12 @@ Union, ) -from eth_keys.datatypes import PrivateKey +from cached_property import ( + cached_property, +) +from eth_keys.datatypes import ( + PrivateKey, +) from eth_typing import ( Address, Hash32, @@ -33,11 +37,21 @@ SignedTransactionAPI, TransactionDecoderAPI, ) -from eth.constants import CREATE_CONTRACT_ADDRESS -from eth.rlp.logs import Log -from eth.rlp.receipts import Receipt -from eth.rlp.transactions import SignedTransactionMethods -from eth.rlp.sedes import address +from eth.constants import ( + CREATE_CONTRACT_ADDRESS, +) +from eth.rlp.logs import ( + Log, +) +from eth.rlp.receipts import ( + Receipt, +) +from eth.rlp.sedes import ( + address, +) +from eth.rlp.transactions import ( + SignedTransactionMethods, +) from eth.validation import ( validate_canonical_address, validate_is_bytes, @@ -61,8 +75,12 @@ ISTANBUL_TX_GAS_SCHEDULE, ) -from .constants import DYNAMIC_FEE_TRANSACTION_TYPE -from .receipts import LondonReceiptBuilder +from .constants import ( + DYNAMIC_FEE_TRANSACTION_TYPE, +) +from .receipts import ( + LondonReceiptBuilder, +) class LondonLegacyTransaction(BerlinLegacyTransaction): diff --git a/eth/vm/forks/london/validation.py b/eth/vm/forks/london/validation.py index 4b4c0e09d2..c41c45159d 100644 --- a/eth/vm/forks/london/validation.py +++ b/eth/vm/forks/london/validation.py @@ -1,8 +1,10 @@ -from eth_utils.exceptions import ValidationError +from eth_utils.exceptions import ( + ValidationError, +) from eth.abc import ( SignedTransactionAPI, - StateAPI + StateAPI, ) from eth.vm.forks.homestead.validation import ( validate_homestead_transaction, diff --git a/eth/vm/forks/muir_glacier/blocks.py b/eth/vm/forks/muir_glacier/blocks.py index c53915065a..4591c444c9 100644 --- a/eth/vm/forks/muir_glacier/blocks.py +++ b/eth/vm/forks/muir_glacier/blocks.py @@ -1,6 +1,7 @@ from rlp.sedes import ( CountableList, ) + from eth.rlp.headers import ( BlockHeader, ) diff --git a/eth/vm/forks/muir_glacier/computation.py b/eth/vm/forks/muir_glacier/computation.py index 50d0a863af..f474b847fa 100644 --- a/eth/vm/forks/muir_glacier/computation.py +++ b/eth/vm/forks/muir_glacier/computation.py @@ -1,11 +1,11 @@ from eth.vm.forks.istanbul.computation import ( - ISTANBUL_PRECOMPILES -) -from eth.vm.forks.istanbul.computation import ( + ISTANBUL_PRECOMPILES, IstanbulMessageComputation, ) -from .opcodes import MUIR_GLACIER_OPCODES +from .opcodes import ( + MUIR_GLACIER_OPCODES, +) MUIR_GLACIER_PRECOMPILES = ISTANBUL_PRECOMPILES diff --git a/eth/vm/forks/muir_glacier/headers.py b/eth/vm/forks/muir_glacier/headers.py index 906342ea41..9eaf43a4df 100644 --- a/eth/vm/forks/muir_glacier/headers.py +++ b/eth/vm/forks/muir_glacier/headers.py @@ -1,11 +1,10 @@ -from eth.vm.forks.petersburg.headers import ( - compute_difficulty, -) from eth.vm.forks.istanbul.headers import ( configure_header, create_header_from_parent, ) - +from eth.vm.forks.petersburg.headers import ( + compute_difficulty, +) compute_muir_glacier_difficulty = compute_difficulty(9000000) diff --git a/eth/vm/forks/muir_glacier/opcodes.py b/eth/vm/forks/muir_glacier/opcodes.py index b0c1df773b..e1bcbec419 100644 --- a/eth/vm/forks/muir_glacier/opcodes.py +++ b/eth/vm/forks/muir_glacier/opcodes.py @@ -1,7 +1,7 @@ import copy + from eth.vm.forks.istanbul.opcodes import ( ISTANBUL_OPCODES, ) - MUIR_GLACIER_OPCODES = copy.deepcopy(ISTANBUL_OPCODES) diff --git a/eth/vm/forks/muir_glacier/state.py b/eth/vm/forks/muir_glacier/state.py index de97ee944a..bfc4b32870 100644 --- a/eth/vm/forks/muir_glacier/state.py +++ b/eth/vm/forks/muir_glacier/state.py @@ -1,8 +1,10 @@ from eth.vm.forks.istanbul.state import ( - IstanbulState + IstanbulState, ) -from .computation import MuirGlacierMessageComputation +from .computation import ( + MuirGlacierMessageComputation, +) class MuirGlacierState(IstanbulState): diff --git a/eth/vm/forks/muir_glacier/transactions.py b/eth/vm/forks/muir_glacier/transactions.py index ad3ed40c36..309f8e5a24 100644 --- a/eth/vm/forks/muir_glacier/transactions.py +++ b/eth/vm/forks/muir_glacier/transactions.py @@ -1,14 +1,17 @@ -from eth_keys.datatypes import PrivateKey -from eth_typing import Address - -from eth.vm.forks.istanbul.transactions import ( - IstanbulTransaction, - IstanbulUnsignedTransaction, +from eth_keys.datatypes import ( + PrivateKey, +) +from eth_typing import ( + Address, ) from eth._utils.transactions import ( create_transaction_signature, ) +from eth.vm.forks.istanbul.transactions import ( + IstanbulTransaction, + IstanbulUnsignedTransaction, +) class MuirGlacierTransaction(IstanbulTransaction): diff --git a/eth/vm/forks/paris/blocks.py b/eth/vm/forks/paris/blocks.py index 023ba5025b..f8ed63830c 100644 --- a/eth/vm/forks/paris/blocks.py +++ b/eth/vm/forks/paris/blocks.py @@ -1,27 +1,32 @@ -from abc import ABC -from typing import Type - -from eth.abc import TransactionBuilderAPI +from abc import ( + ABC, +) +from typing import ( + Type, +) from eth_utils import ( encode_hex, ) - from rlp.sedes import ( CountableList, ) -from .transactions import ( - ParisTransactionBuilder, +from eth.abc import ( + TransactionBuilderAPI, ) from eth.vm.forks.gray_glacier.blocks import ( GrayGlacierBlock, GrayGlacierBlockHeader, GrayGlacierMiningHeader, ) + from ..london.blocks import ( LondonBackwardsHeader, ) +from .transactions import ( + ParisTransactionBuilder, +) class ParisMiningHeader(GrayGlacierMiningHeader, ABC): diff --git a/eth/vm/forks/paris/computation.py b/eth/vm/forks/paris/computation.py index e308f5416c..3f46b8cf54 100644 --- a/eth/vm/forks/paris/computation.py +++ b/eth/vm/forks/paris/computation.py @@ -1,5 +1,10 @@ -from .opcodes import PARIS_OPCODES -from eth.vm.forks.gray_glacier.computation import GrayGlacierMessageComputation +from eth.vm.forks.gray_glacier.computation import ( + GrayGlacierMessageComputation, +) + +from .opcodes import ( + PARIS_OPCODES, +) class ParisMessageComputation(GrayGlacierMessageComputation): diff --git a/eth/vm/forks/paris/headers.py b/eth/vm/forks/paris/headers.py index c9c8054f5c..b2cf7f4782 100644 --- a/eth/vm/forks/paris/headers.py +++ b/eth/vm/forks/paris/headers.py @@ -1,22 +1,34 @@ -from typing import Any, Optional +from typing import ( + Any, + Optional, +) -from toolz import curry +from eth_utils import ( + ValidationError, +) +from toolz import ( + curry, +) -from eth.abc import BlockHeaderAPI +from eth.abc import ( + BlockHeaderAPI, +) from eth.constants import ( POST_MERGE_DIFFICULTY, POST_MERGE_MIX_HASH, POST_MERGE_NONCE, ) +from eth.vm.forks.byzantium.headers import ( + configure_header, +) from eth.vm.forks.gray_glacier.headers import ( compute_gray_glacier_difficulty, create_gray_glacier_header_from_parent, ) -from eth.vm.forks.byzantium.headers import ( - configure_header, + +from .blocks import ( + ParisBlockHeader, ) -from eth_utils import ValidationError -from .blocks import ParisBlockHeader def _validate_and_return_paris_header_param( diff --git a/eth/vm/forks/paris/opcodes.py b/eth/vm/forks/paris/opcodes.py index a382909544..9a7595f008 100644 --- a/eth/vm/forks/paris/opcodes.py +++ b/eth/vm/forks/paris/opcodes.py @@ -1,19 +1,31 @@ import copy -from typing import Dict +from typing import ( + Dict, +) -from eth.vm.opcode import as_opcode -from eth_utils.toolz import merge +from eth_utils.toolz import ( + merge, +) -from eth import constants -from eth.abc import OpcodeAPI -from eth.vm import mnemonics -from eth.vm import opcode_values +from eth import ( + constants, +) +from eth.abc import ( + OpcodeAPI, +) +from eth.vm import ( + mnemonics, + opcode_values, +) +from eth.vm.forks.london.opcodes import ( + LONDON_OPCODES, +) from eth.vm.logic import ( block, ) - -from eth.vm.forks.london.opcodes import LONDON_OPCODES - +from eth.vm.opcode import ( + as_opcode, +) NEW_OPCODES = { # EIP-4399: supplant DIFFICULTY with PREVRANDAO diff --git a/eth/vm/forks/paris/state.py b/eth/vm/forks/paris/state.py index 321480ce26..5bf9eab290 100644 --- a/eth/vm/forks/paris/state.py +++ b/eth/vm/forks/paris/state.py @@ -1,13 +1,25 @@ -from typing import Type +from typing import ( + Type, +) + +from eth_typing import ( + Hash32, +) from eth.abc import ( StateAPI, TransactionExecutorAPI, ) -from eth_typing import Hash32 -from .computation import ParisMessageComputation -from ..gray_glacier import GrayGlacierState -from ..gray_glacier.state import GrayGlacierTransactionExecutor + +from ..gray_glacier import ( + GrayGlacierState, +) +from ..gray_glacier.state import ( + GrayGlacierTransactionExecutor, +) +from .computation import ( + ParisMessageComputation, +) class ParisTransactionExecutor(GrayGlacierTransactionExecutor): diff --git a/eth/vm/forks/paris/transactions.py b/eth/vm/forks/paris/transactions.py index ace279910a..1f44b00ab5 100644 --- a/eth/vm/forks/paris/transactions.py +++ b/eth/vm/forks/paris/transactions.py @@ -1,6 +1,10 @@ -from abc import ABC +from abc import ( + ABC, +) -from eth_keys.datatypes import PrivateKey +from eth_keys.datatypes import ( + PrivateKey, +) from eth._utils.transactions import ( create_transaction_signature, diff --git a/eth/vm/forks/petersburg/blocks.py b/eth/vm/forks/petersburg/blocks.py index 4c244af159..da27af7bd6 100644 --- a/eth/vm/forks/petersburg/blocks.py +++ b/eth/vm/forks/petersburg/blocks.py @@ -1,6 +1,7 @@ from rlp.sedes import ( CountableList, ) + from eth.rlp.headers import ( BlockHeader, ) diff --git a/eth/vm/forks/petersburg/computation.py b/eth/vm/forks/petersburg/computation.py index 6d08ce25c4..aead218be6 100644 --- a/eth/vm/forks/petersburg/computation.py +++ b/eth/vm/forks/petersburg/computation.py @@ -1,11 +1,11 @@ from eth.vm.forks.byzantium.computation import ( - BYZANTIUM_PRECOMPILES -) -from eth.vm.forks.byzantium.computation import ( - ByzantiumMessageComputation + BYZANTIUM_PRECOMPILES, + ByzantiumMessageComputation, ) -from .opcodes import PETERSBURG_OPCODES +from .opcodes import ( + PETERSBURG_OPCODES, +) PETERSBURG_PRECOMPILES = BYZANTIUM_PRECOMPILES diff --git a/eth/vm/forks/petersburg/constants.py b/eth/vm/forks/petersburg/constants.py index 0ba9138d13..bdfe5e9a19 100644 --- a/eth/vm/forks/petersburg/constants.py +++ b/eth/vm/forks/petersburg/constants.py @@ -1,5 +1,6 @@ -from eth_utils import denoms - +from eth_utils import ( + denoms, +) GAS_EXTCODEHASH_EIP1052 = 400 diff --git a/eth/vm/forks/petersburg/headers.py b/eth/vm/forks/petersburg/headers.py index d641b2bd0f..93df416568 100644 --- a/eth/vm/forks/petersburg/headers.py +++ b/eth/vm/forks/petersburg/headers.py @@ -1,10 +1,9 @@ from eth.vm.forks.byzantium.headers import ( + compute_difficulty, configure_header, create_header_from_parent, - compute_difficulty, ) - compute_petersburg_difficulty = compute_difficulty(5000000) create_petersburg_header_from_parent = create_header_from_parent( diff --git a/eth/vm/forks/petersburg/opcodes.py b/eth/vm/forks/petersburg/opcodes.py index dc26b9a62a..a5281ad0d4 100644 --- a/eth/vm/forks/petersburg/opcodes.py +++ b/eth/vm/forks/petersburg/opcodes.py @@ -1,14 +1,18 @@ import copy -from typing import Dict +from typing import ( + Dict, +) from eth_utils.toolz import ( - merge + merge, ) from eth import ( - constants + constants, +) +from eth.abc import ( + OpcodeAPI, ) -from eth.abc import OpcodeAPI from eth.vm import ( mnemonics, opcode_values, @@ -17,7 +21,7 @@ BYZANTIUM_OPCODES, ) from eth.vm.forks.petersburg.constants import ( - GAS_EXTCODEHASH_EIP1052 + GAS_EXTCODEHASH_EIP1052, ) from eth.vm.logic import ( arithmetic, @@ -25,10 +29,9 @@ system, ) from eth.vm.opcode import ( - as_opcode + as_opcode, ) - UPDATED_OPCODES = { opcode_values.SHL: as_opcode( logic_fn=arithmetic.shl, diff --git a/eth/vm/forks/petersburg/state.py b/eth/vm/forks/petersburg/state.py index 60b23d12fb..5e41696b45 100644 --- a/eth/vm/forks/petersburg/state.py +++ b/eth/vm/forks/petersburg/state.py @@ -1,8 +1,10 @@ from eth.vm.forks.byzantium.state import ( - ByzantiumState + ByzantiumState, ) -from .computation import PetersburgMessageComputation +from .computation import ( + PetersburgMessageComputation, +) class PetersburgState(ByzantiumState): diff --git a/eth/vm/forks/petersburg/transactions.py b/eth/vm/forks/petersburg/transactions.py index ba299bb764..bf723d6f1f 100644 --- a/eth/vm/forks/petersburg/transactions.py +++ b/eth/vm/forks/petersburg/transactions.py @@ -1,14 +1,17 @@ -from eth_keys.datatypes import PrivateKey -from eth_typing import Address - -from eth.vm.forks.byzantium.transactions import ( - ByzantiumTransaction, - ByzantiumUnsignedTransaction, +from eth_keys.datatypes import ( + PrivateKey, +) +from eth_typing import ( + Address, ) from eth._utils.transactions import ( create_transaction_signature, ) +from eth.vm.forks.byzantium.transactions import ( + ByzantiumTransaction, + ByzantiumUnsignedTransaction, +) class PetersburgTransaction(ByzantiumTransaction): diff --git a/eth/vm/forks/shanghai/blocks.py b/eth/vm/forks/shanghai/blocks.py index 30df5e4ebe..7b369a76e9 100644 --- a/eth/vm/forks/shanghai/blocks.py +++ b/eth/vm/forks/shanghai/blocks.py @@ -1,47 +1,86 @@ -from abc import ABC -from typing import List, Sequence, Tuple, Type, cast +from abc import ( + ABC, +) +from typing import ( + List, + Sequence, + Tuple, + Type, + cast, +) +from eth_bloom import ( + BloomFilter, +) +from eth_typing import ( + Address, + BlockNumber, + Hash32, +) +from eth_utils import ( + encode_hex, + keccak, +) import rlp -from eth.exceptions import BlockNotFound, HeaderNotFound -from eth.rlp.blocks import BaseBlock -from eth.rlp.headers import BlockHeader -from eth.rlp.sedes import address, hash32, trie_root, uint256 -from eth_bloom import BloomFilter -from eth_typing import Address, BlockNumber, Hash32 - -from eth._utils.headers import new_timestamp_from_parent +from rlp.sedes import ( + Binary, + CountableList, + big_endian_int, + binary, +) +from trie.exceptions import ( + MissingTrieNode, +) + +from eth._utils.headers import ( + new_timestamp_from_parent, +) from eth.abc import ( - BlockHeaderAPI, BlockHeaderSedesAPI, ChainDatabaseAPI, MiningHeaderAPI, - ReceiptAPI, ReceiptBuilderAPI, SignedTransactionAPI, TransactionBuilderAPI, + BlockHeaderAPI, + BlockHeaderSedesAPI, + ChainDatabaseAPI, + MiningHeaderAPI, + ReceiptAPI, + ReceiptBuilderAPI, + SignedTransactionAPI, + TransactionBuilderAPI, WithdrawalAPI, ) from eth.constants import ( - ZERO_ADDRESS, - ZERO_HASH32, + BLANK_ROOT_HASH, EMPTY_UNCLE_HASH, GENESIS_NONCE, GENESIS_PARENT_HASH, - BLANK_ROOT_HASH, + ZERO_ADDRESS, + ZERO_HASH32, ) - -from eth_utils import ( - encode_hex, keccak, +from eth.exceptions import ( + BlockNotFound, + HeaderNotFound, ) - -from rlp.sedes import ( - Binary, CountableList, big_endian_int, binary, +from eth.rlp.blocks import ( + BaseBlock, +) +from eth.rlp.headers import ( + BlockHeader, +) +from eth.rlp.sedes import ( + address, + hash32, + trie_root, + uint256, ) -from trie.exceptions import MissingTrieNode +from ..london.blocks import ( + LondonBlockHeader, +) from .transactions import ( ShanghaiTransactionBuilder, ) -from .withdrawals import Withdrawal -from ..london.blocks import ( - LondonBlockHeader, +from .withdrawals import ( + Withdrawal, ) - UNMINED_SHANGHAI_HEADER_FIELDS = [ ('parent_hash', hash32), ('uncles_hash', hash32), diff --git a/eth/vm/forks/shanghai/computation.py b/eth/vm/forks/shanghai/computation.py index afd00e9183..c31f29a2db 100644 --- a/eth/vm/forks/shanghai/computation.py +++ b/eth/vm/forks/shanghai/computation.py @@ -1,19 +1,26 @@ -from eth._utils.numeric import ceil32 +from eth._utils.numeric import ( + ceil32, +) from eth.abc import ( - MessageComputationAPI, MessageAPI, + MessageComputationAPI, StateAPI, TransactionContextAPI, ) +from eth.exceptions import ( + OutOfGas, +) +from eth.vm.forks.paris.computation import ( + ParisMessageComputation, +) + from .constants import ( INITCODE_WORD_COST, MAX_INITCODE_SIZE, ) -from .opcodes import SHANGHAI_OPCODES -from eth.exceptions import ( - OutOfGas, +from .opcodes import ( + SHANGHAI_OPCODES, ) -from eth.vm.forks.paris.computation import ParisMessageComputation class ShanghaiMessageComputation(ParisMessageComputation): diff --git a/eth/vm/forks/shanghai/constants.py b/eth/vm/forks/shanghai/constants.py index 41bb499491..916f807540 100644 --- a/eth/vm/forks/shanghai/constants.py +++ b/eth/vm/forks/shanghai/constants.py @@ -1,4 +1,6 @@ -from eth.vm.forks.spurious_dragon.constants import EIP170_CODE_SIZE_LIMIT +from eth.vm.forks.spurious_dragon.constants import ( + EIP170_CODE_SIZE_LIMIT, +) # https://eips.ethereum.org/EIPS/eip-3860 INITCODE_WORD_COST = 2 diff --git a/eth/vm/forks/shanghai/headers.py b/eth/vm/forks/shanghai/headers.py index d4234143c4..6c03fc76d1 100644 --- a/eth/vm/forks/shanghai/headers.py +++ b/eth/vm/forks/shanghai/headers.py @@ -1,15 +1,25 @@ -from typing import Any, Optional +from typing import ( + Any, + Optional, +) -from toolz import curry +from toolz import ( + curry, +) -from eth.abc import BlockHeaderAPI -from eth.vm.forks.paris.headers import ( - create_paris_header_from_parent, +from eth.abc import ( + BlockHeaderAPI, ) from eth.vm.forks.byzantium.headers import ( configure_header, ) -from .blocks import ShanghaiBlockHeader +from eth.vm.forks.paris.headers import ( + create_paris_header_from_parent, +) + +from .blocks import ( + ShanghaiBlockHeader, +) @curry diff --git a/eth/vm/forks/shanghai/logic.py b/eth/vm/forks/shanghai/logic.py index 8dcab5edea..a627baa637 100644 --- a/eth/vm/forks/shanghai/logic.py +++ b/eth/vm/forks/shanghai/logic.py @@ -1,17 +1,18 @@ -from .constants import ( - INITCODE_WORD_COST, -) from eth._utils.numeric import ( ceil32, ) from eth.vm.forks.berlin.logic import ( - CreateEIP2929, Create2EIP2929, + CreateEIP2929, ) from eth.vm.logic.system import ( CreateOpcodeStackData, ) +from .constants import ( + INITCODE_WORD_COST, +) + class CreateEIP3860(CreateEIP2929): def get_gas_cost(self, data: CreateOpcodeStackData) -> int: diff --git a/eth/vm/forks/shanghai/opcodes.py b/eth/vm/forks/shanghai/opcodes.py index e6209c0912..bc757f7abf 100644 --- a/eth/vm/forks/shanghai/opcodes.py +++ b/eth/vm/forks/shanghai/opcodes.py @@ -1,24 +1,39 @@ import copy -from typing import Dict +from typing import ( + Dict, +) -from .logic import ( - CreateEIP3860, - Create2EIP3860, +from eth_utils.toolz import ( + merge, ) -from eth.tools._utils.deprecation import deprecate_method -from eth.vm.opcode import as_opcode -from eth_utils.toolz import merge -from eth import constants -from eth.abc import OpcodeAPI -from eth.vm import mnemonics -from eth.vm import opcode_values +from eth import ( + constants, +) +from eth.abc import ( + OpcodeAPI, +) +from eth.tools._utils.deprecation import ( + deprecate_method, +) +from eth.vm import ( + mnemonics, + opcode_values, +) +from eth.vm.forks.paris.opcodes import ( + PARIS_OPCODES, +) from eth.vm.logic import ( stack, ) +from eth.vm.opcode import ( + as_opcode, +) -from eth.vm.forks.paris.opcodes import PARIS_OPCODES - +from .logic import ( + Create2EIP3860, + CreateEIP3860, +) UPDATED_OPCODES: Dict[int, OpcodeAPI] = { opcode_values.CREATE: CreateEIP3860.configure( diff --git a/eth/vm/forks/shanghai/state.py b/eth/vm/forks/shanghai/state.py index 5dbd97eda2..6d6b58e1a7 100644 --- a/eth/vm/forks/shanghai/state.py +++ b/eth/vm/forks/shanghai/state.py @@ -1,12 +1,21 @@ -from typing import Type +from typing import ( + Type, +) from eth.abc import ( TransactionExecutorAPI, WithdrawalAPI, ) -from .computation import ShanghaiMessageComputation -from ..paris import ParisState -from ..paris.state import ParisTransactionExecutor + +from ..paris import ( + ParisState, +) +from ..paris.state import ( + ParisTransactionExecutor, +) +from .computation import ( + ShanghaiMessageComputation, +) class ShanghaiTransactionExecutor(ParisTransactionExecutor): diff --git a/eth/vm/forks/shanghai/transactions.py b/eth/vm/forks/shanghai/transactions.py index 79e48ff9b3..bc320aeae7 100644 --- a/eth/vm/forks/shanghai/transactions.py +++ b/eth/vm/forks/shanghai/transactions.py @@ -1,6 +1,10 @@ -from abc import ABC +from abc import ( + ABC, +) -from eth_keys.datatypes import PrivateKey +from eth_keys.datatypes import ( + PrivateKey, +) from eth._utils.transactions import ( create_transaction_signature, diff --git a/eth/vm/forks/shanghai/withdrawals.py b/eth/vm/forks/shanghai/withdrawals.py index 4161af8b8b..b0dedac734 100644 --- a/eth/vm/forks/shanghai/withdrawals.py +++ b/eth/vm/forks/shanghai/withdrawals.py @@ -1,20 +1,32 @@ -from cached_property import cached_property -from typing import cast +from typing import ( + cast, +) -from eth.abc import WithdrawalAPI -from eth.validation import ( - validate_canonical_address, - validate_uint64, +from cached_property import ( + cached_property, ) from eth_typing import ( Address, Hash32, ) - +from eth_utils import ( + keccak, +) import rlp -from eth.rlp.sedes import address -from eth_utils import keccak -from rlp.sedes import big_endian_int +from rlp.sedes import ( + big_endian_int, +) + +from eth.abc import ( + WithdrawalAPI, +) +from eth.rlp.sedes import ( + address, +) +from eth.validation import ( + validate_canonical_address, + validate_uint64, +) class Withdrawal(rlp.Serializable): diff --git a/eth/vm/forks/spurious_dragon/_utils.py b/eth/vm/forks/spurious_dragon/_utils.py index a55bce7f66..31de432518 100644 --- a/eth/vm/forks/spurious_dragon/_utils.py +++ b/eth/vm/forks/spurious_dragon/_utils.py @@ -1,17 +1,23 @@ -from typing import Iterable - -from eth_typing import Address - -from eth_utils import to_set +from typing import ( + Iterable, +) -from eth import constants +from eth_typing import ( + Address, +) +from eth_utils import ( + to_set, +) +from eth import ( + constants, +) from eth._utils.address import ( force_bytes_to_address, ) - -from eth.vm.computation import MessageComputation - +from eth.vm.computation import ( + MessageComputation, +) THREE = force_bytes_to_address(b'\x03') diff --git a/eth/vm/forks/spurious_dragon/blocks.py b/eth/vm/forks/spurious_dragon/blocks.py index fe9371d1e5..d11d95bc94 100644 --- a/eth/vm/forks/spurious_dragon/blocks.py +++ b/eth/vm/forks/spurious_dragon/blocks.py @@ -1,12 +1,14 @@ from rlp.sedes import ( CountableList, ) + from eth.rlp.headers import ( BlockHeader, ) from eth.vm.forks.homestead.blocks import ( HomesteadBlock, ) + from .transactions import ( SpuriousDragonTransaction, ) diff --git a/eth/vm/forks/spurious_dragon/computation.py b/eth/vm/forks/spurious_dragon/computation.py index a9848a611a..7b7721d1d3 100644 --- a/eth/vm/forks/spurious_dragon/computation.py +++ b/eth/vm/forks/spurious_dragon/computation.py @@ -1,13 +1,16 @@ -from eth_hash.auto import keccak - +from eth_hash.auto import ( + keccak, +) from eth_utils import ( encode_hex, ) -from eth import constants +from eth import ( + constants, +) from eth.abc import ( - MessageComputationAPI, MessageAPI, + MessageComputationAPI, StateAPI, TransactionContextAPI, ) @@ -19,8 +22,12 @@ HomesteadMessageComputation, ) -from ..spurious_dragon.constants import EIP170_CODE_SIZE_LIMIT -from .opcodes import SPURIOUS_DRAGON_OPCODES +from ..spurious_dragon.constants import ( + EIP170_CODE_SIZE_LIMIT, +) +from .opcodes import ( + SPURIOUS_DRAGON_OPCODES, +) class SpuriousDragonMessageComputation(HomesteadMessageComputation): diff --git a/eth/vm/forks/spurious_dragon/opcodes.py b/eth/vm/forks/spurious_dragon/opcodes.py index eed5820eda..0ce713a539 100644 --- a/eth/vm/forks/spurious_dragon/opcodes.py +++ b/eth/vm/forks/spurious_dragon/opcodes.py @@ -1,29 +1,40 @@ import copy -from typing import Dict +from typing import ( + Dict, +) -from eth_utils.toolz import merge +from eth_utils.toolz import ( + merge, +) -from eth.abc import OpcodeAPI +from eth.abc import ( + OpcodeAPI, +) +from eth.vm import ( + mnemonics, + opcode_values, +) from eth.vm.forks.tangerine_whistle.constants import ( + GAS_CALL_EIP150, GAS_SELFDESTRUCT_EIP150, - GAS_CALL_EIP150 ) -from eth.vm import mnemonics -from eth.vm import opcode_values -from eth.vm.forks.tangerine_whistle.opcodes import TANGERINE_WHISTLE_OPCODES +from eth.vm.forks.tangerine_whistle.opcodes import ( + TANGERINE_WHISTLE_OPCODES, +) from eth.vm.logic import ( arithmetic, - system, call, + system, +) +from eth.vm.opcode import ( + as_opcode, ) -from eth.vm.opcode import as_opcode from .constants import ( GAS_EXP_EIP160, - GAS_EXPBYTE_EIP160 + GAS_EXPBYTE_EIP160, ) - UPDATED_OPCODES = { opcode_values.EXP: as_opcode( logic_fn=arithmetic.exp(gas_per_byte=GAS_EXPBYTE_EIP160), diff --git a/eth/vm/forks/spurious_dragon/state.py b/eth/vm/forks/spurious_dragon/state.py index 67e0e98096..74ab627140 100644 --- a/eth/vm/forks/spurious_dragon/state.py +++ b/eth/vm/forks/spurious_dragon/state.py @@ -1,4 +1,6 @@ -from typing import Type +from typing import ( + Type, +) from eth_utils import ( encode_hex, @@ -14,8 +16,12 @@ HomesteadTransactionExecutor, ) -from .computation import SpuriousDragonMessageComputation -from ._utils import collect_touched_accounts +from ._utils import ( + collect_touched_accounts, +) +from .computation import ( + SpuriousDragonMessageComputation, +) class SpuriousDragonTransactionExecutor(HomesteadTransactionExecutor): diff --git a/eth/vm/forks/spurious_dragon/transactions.py b/eth/vm/forks/spurious_dragon/transactions.py index 394bcdf916..55761e6b70 100644 --- a/eth/vm/forks/spurious_dragon/transactions.py +++ b/eth/vm/forks/spurious_dragon/transactions.py @@ -1,28 +1,30 @@ -from typing import Optional - -from eth_keys.datatypes import PrivateKey +from typing import ( + Optional, +) +from eth_keys.datatypes import ( + PrivateKey, +) from eth_typing import ( Address, ) - from eth_utils import ( int_to_big_endian, ) - import rlp -from eth.vm.forks.homestead.transactions import ( - HomesteadTransaction, - HomesteadUnsignedTransaction, +from eth._utils.numeric import ( + is_even, ) - -from eth._utils.numeric import is_even from eth._utils.transactions import ( create_transaction_signature, extract_chain_id, is_eip_155_signed_transaction, ) +from eth.vm.forks.homestead.transactions import ( + HomesteadTransaction, + HomesteadUnsignedTransaction, +) class SpuriousDragonTransaction(HomesteadTransaction): diff --git a/eth/vm/forks/tangerine_whistle/computation.py b/eth/vm/forks/tangerine_whistle/computation.py index cec0fd2c42..ac6d26dbec 100644 --- a/eth/vm/forks/tangerine_whistle/computation.py +++ b/eth/vm/forks/tangerine_whistle/computation.py @@ -1,6 +1,9 @@ -from ..homestead.computation import HomesteadMessageComputation - -from .opcodes import TANGERINE_WHISTLE_OPCODES +from ..homestead.computation import ( + HomesteadMessageComputation, +) +from .opcodes import ( + TANGERINE_WHISTLE_OPCODES, +) class TangerineWhistleMessageComputation(HomesteadMessageComputation): diff --git a/eth/vm/forks/tangerine_whistle/opcodes.py b/eth/vm/forks/tangerine_whistle/opcodes.py index c4f158f9ff..64d8da9645 100644 --- a/eth/vm/forks/tangerine_whistle/opcodes.py +++ b/eth/vm/forks/tangerine_whistle/opcodes.py @@ -1,20 +1,31 @@ import copy -from eth_utils.toolz import merge +from eth_utils.toolz import ( + merge, +) -from eth.vm.forks.tangerine_whistle import constants -from eth.constants import GAS_CREATE -from eth.vm import opcode_values -from eth.vm import mnemonics -from eth.vm.forks.homestead.opcodes import HOMESTEAD_OPCODES +from eth.constants import ( + GAS_CREATE, +) +from eth.vm import ( + mnemonics, + opcode_values, +) +from eth.vm.forks.homestead.opcodes import ( + HOMESTEAD_OPCODES, +) +from eth.vm.forks.tangerine_whistle import ( + constants, +) from eth.vm.logic import ( call, context, storage, system, ) -from eth.vm.opcode import as_opcode - +from eth.vm.opcode import ( + as_opcode, +) UPDATED_OPCODES = { opcode_values.EXTCODESIZE: as_opcode( diff --git a/eth/vm/forks/tangerine_whistle/state.py b/eth/vm/forks/tangerine_whistle/state.py index ca61cab5c7..56a52a0766 100644 --- a/eth/vm/forks/tangerine_whistle/state.py +++ b/eth/vm/forks/tangerine_whistle/state.py @@ -1,6 +1,10 @@ -from eth.vm.forks.homestead.state import HomesteadState +from eth.vm.forks.homestead.state import ( + HomesteadState, +) -from .computation import TangerineWhistleMessageComputation +from .computation import ( + TangerineWhistleMessageComputation, +) class TangerineWhistleState(HomesteadState): diff --git a/eth/vm/gas_meter.py b/eth/vm/gas_meter.py index ea9a30f218..0d6e6780e4 100644 --- a/eth/vm/gas_meter.py +++ b/eth/vm/gas_meter.py @@ -1,12 +1,15 @@ from typing import ( Callable, ) + from eth_utils import ( ValidationError, get_extended_debug_logger, ) -from eth.abc import GasMeterAPI +from eth.abc import ( + GasMeterAPI, +) from eth.exceptions import ( OutOfGas, ) diff --git a/eth/vm/header.py b/eth/vm/header.py index 09222db60d..1f0071e1e8 100644 --- a/eth/vm/header.py +++ b/eth/vm/header.py @@ -1,4 +1,6 @@ -from eth.vm.forks.shanghai.blocks import ShanghaiBackwardsHeader +from eth.vm.forks.shanghai.blocks import ( + ShanghaiBackwardsHeader, +) HeaderSedes = ShanghaiBackwardsHeader """ diff --git a/eth/vm/logic/arithmetic.py b/eth/vm/logic/arithmetic.py index 8be2c52380..e817f625e0 100644 --- a/eth/vm/logic/arithmetic.py +++ b/eth/vm/logic/arithmetic.py @@ -2,15 +2,17 @@ curry, ) -from eth import constants - +from eth import ( + constants, +) from eth._utils.numeric import ( - unsigned_to_signed, - signed_to_unsigned, ceil8, + signed_to_unsigned, + unsigned_to_signed, +) +from eth.vm.computation import ( + MessageComputation, ) - -from eth.vm.computation import MessageComputation def add(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/block.py b/eth/vm/logic/block.py index fe75890b12..5b73eeb6f9 100644 --- a/eth/vm/logic/block.py +++ b/eth/vm/logic/block.py @@ -1,4 +1,6 @@ -from eth.vm.computation import MessageComputation +from eth.vm.computation import ( + MessageComputation, +) def blockhash(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/call.py b/eth/vm/logic/call.py index f704ca7e6d..6c5ea6bb04 100644 --- a/eth/vm/logic/call.py +++ b/eth/vm/logic/call.py @@ -1,18 +1,21 @@ from abc import ( ABC, - abstractmethod + abstractmethod, ) - from typing import ( Tuple, ) -from eth import constants - from eth_typing import ( Address, ) +from eth import ( + constants, +) +from eth._utils.address import ( + force_bytes_to_address, +) from eth.abc import ( MessageComputationAPI, ) @@ -24,11 +27,6 @@ Opcode, ) -from eth._utils.address import ( - force_bytes_to_address, -) - - CallParams = Tuple[int, int, Address, Address, Address, int, int, int, int, bool, bool] diff --git a/eth/vm/logic/comparison.py b/eth/vm/logic/comparison.py index 3f89ca2884..d50cad1c71 100644 --- a/eth/vm/logic/comparison.py +++ b/eth/vm/logic/comparison.py @@ -1,11 +1,13 @@ -from eth import constants - +from eth import ( + constants, +) from eth._utils.numeric import ( signed_to_unsigned, unsigned_to_signed, ) - -from eth.vm.computation import MessageComputation +from eth.vm.computation import ( + MessageComputation, +) def lt(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/context.py b/eth/vm/logic/context.py index 74a89b16a9..c4137da4d0 100644 --- a/eth/vm/logic/context.py +++ b/eth/vm/logic/context.py @@ -1,26 +1,29 @@ -from typing import Tuple +from typing import ( + Tuple, +) from eth_typing import ( Address, ) -from eth import constants - -from eth.abc import ( - MessageComputationAPI, +from eth import ( + constants, ) -from eth.exceptions import ( - OutOfBoundsRead, -) - from eth._utils.address import ( force_bytes_to_address, ) from eth._utils.numeric import ( ceil32, ) - -from eth.vm.computation import MessageComputation +from eth.abc import ( + MessageComputationAPI, +) +from eth.exceptions import ( + OutOfBoundsRead, +) +from eth.vm.computation import ( + MessageComputation, +) def balance(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/duplication.py b/eth/vm/logic/duplication.py index a2e89904be..ffa3b73f0e 100644 --- a/eth/vm/logic/duplication.py +++ b/eth/vm/logic/duplication.py @@ -1,6 +1,8 @@ import functools -from eth.vm.computation import MessageComputation +from eth.vm.computation import ( + MessageComputation, +) def dup_XX(computation: MessageComputation, position: int) -> None: diff --git a/eth/vm/logic/flow.py b/eth/vm/logic/flow.py index b8533f454a..5a23ca6cdd 100644 --- a/eth/vm/logic/flow.py +++ b/eth/vm/logic/flow.py @@ -1,10 +1,11 @@ from eth.exceptions import ( - InvalidJumpDestination, - InvalidInstruction, Halt, + InvalidInstruction, + InvalidJumpDestination, +) +from eth.vm.computation import ( + MessageComputation, ) - -from eth.vm.computation import MessageComputation from eth.vm.opcode_values import ( JUMPDEST, ) diff --git a/eth/vm/logic/invalid.py b/eth/vm/logic/invalid.py index 4566f22b2d..9337c18417 100644 --- a/eth/vm/logic/invalid.py +++ b/eth/vm/logic/invalid.py @@ -1,6 +1,12 @@ -from eth.abc import MessageComputationAPI -from eth.exceptions import InvalidInstruction -from eth.vm.opcode import Opcode +from eth.abc import ( + MessageComputationAPI, +) +from eth.exceptions import ( + InvalidInstruction, +) +from eth.vm.opcode import ( + Opcode, +) class InvalidOpcode(Opcode): diff --git a/eth/vm/logic/logging.py b/eth/vm/logic/logging.py index 8be33e94a8..6e812898fa 100644 --- a/eth/vm/logic/logging.py +++ b/eth/vm/logic/logging.py @@ -1,8 +1,14 @@ import functools -from typing import Tuple -from eth import constants - -from eth.vm.computation import MessageComputation +from typing import ( + Tuple, +) + +from eth import ( + constants, +) +from eth.vm.computation import ( + MessageComputation, +) def log_XX(computation: MessageComputation, topic_count: int) -> None: diff --git a/eth/vm/logic/memory.py b/eth/vm/logic/memory.py index 55790f3a70..1cc313b8cb 100644 --- a/eth/vm/logic/memory.py +++ b/eth/vm/logic/memory.py @@ -1,4 +1,6 @@ -from eth.vm.computation import MessageComputation +from eth.vm.computation import ( + MessageComputation, +) def mstore(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/sha3.py b/eth/vm/logic/sha3.py index dbf488fd99..17f5ec2343 100644 --- a/eth/vm/logic/sha3.py +++ b/eth/vm/logic/sha3.py @@ -1,10 +1,16 @@ -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) -from eth import constants +from eth import ( + constants, +) from eth._utils.numeric import ( ceil32, ) -from eth.vm.computation import MessageComputation +from eth.vm.computation import ( + MessageComputation, +) def sha3(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/stack.py b/eth/vm/logic/stack.py index 35bd1b7def..cf47b6fecb 100644 --- a/eth/vm/logic/stack.py +++ b/eth/vm/logic/stack.py @@ -1,6 +1,8 @@ import functools -from eth.vm.computation import MessageComputation +from eth.vm.computation import ( + MessageComputation, +) def pop(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/storage.py b/eth/vm/logic/storage.py index b13dde35ab..d462aaf031 100644 --- a/eth/vm/logic/storage.py +++ b/eth/vm/logic/storage.py @@ -1,11 +1,17 @@ -from typing import NamedTuple +from typing import ( + NamedTuple, +) from eth_utils import ( encode_hex, ) -from eth import constants -from eth.vm.computation import MessageComputation +from eth import ( + constants, +) +from eth.vm.computation import ( + MessageComputation, +) def sstore(computation: MessageComputation) -> None: diff --git a/eth/vm/logic/swap.py b/eth/vm/logic/swap.py index c2709a82a6..0e7eed5b1f 100644 --- a/eth/vm/logic/swap.py +++ b/eth/vm/logic/swap.py @@ -1,6 +1,8 @@ import functools -from eth.vm.computation import MessageComputation +from eth.vm.computation import ( + MessageComputation, +) def swap_XX(computation: MessageComputation, position: int) -> None: diff --git a/eth/vm/logic/system.py b/eth/vm/logic/system.py index 5f57aa6f11..5c21b74ba1 100644 --- a/eth/vm/logic/system.py +++ b/eth/vm/logic/system.py @@ -4,13 +4,10 @@ from eth_utils import ( encode_hex, ) -from eth import constants -from eth.exceptions import ( - Halt, - Revert, - WriteProtection, -) +from eth import ( + constants, +) from eth._utils.address import ( force_bytes_to_address, generate_contract_address, @@ -20,13 +17,24 @@ ceil32, ) from eth.abc import ( - MessageComputationAPI, MessageAPI, + MessageComputationAPI, +) +from eth.exceptions import ( + Halt, + Revert, + WriteProtection, +) +from eth.vm import ( + mnemonics, +) +from eth.vm.opcode import ( + Opcode, ) -from eth.vm import mnemonics -from eth.vm.opcode import Opcode -from .call import max_child_gas_eip150 +from .call import ( + max_child_gas_eip150, +) def return_op(computation: MessageComputationAPI) -> None: diff --git a/eth/vm/memory.py b/eth/vm/memory.py index cff7f2836e..074817eadf 100644 --- a/eth/vm/memory.py +++ b/eth/vm/memory.py @@ -1,6 +1,12 @@ import itertools import logging +from eth._utils.numeric import ( + ceil32, +) +from eth.abc import ( + MemoryAPI, +) from eth.validation import ( validate_is_bytes, validate_length, @@ -8,11 +14,6 @@ validate_uint256, ) -from eth._utils.numeric import ( - ceil32, -) -from eth.abc import MemoryAPI - class Memory(MemoryAPI): __slots__ = ['_bytes'] diff --git a/eth/vm/message.py b/eth/vm/message.py index f746566e66..ee2f0bc435 100644 --- a/eth/vm/message.py +++ b/eth/vm/message.py @@ -1,8 +1,12 @@ import logging -from eth_typing import Address +from eth_typing import ( + Address, +) -from eth.abc import MessageAPI +from eth.abc import ( + MessageAPI, +) from eth.constants import ( CREATE_CONTRACT_ADDRESS, ) @@ -11,12 +15,12 @@ ) from eth.validation import ( validate_canonical_address, + validate_gte, + validate_is_boolean, validate_is_bytes, validate_is_bytes_or_view, validate_is_integer, - validate_gte, validate_uint256, - validate_is_boolean, ) diff --git a/eth/vm/opcode.py b/eth/vm/opcode.py index 3da0487410..594aa4e8e2 100644 --- a/eth/vm/opcode.py +++ b/eth/vm/opcode.py @@ -1,5 +1,4 @@ import functools - from typing import ( Any, Callable, @@ -12,13 +11,14 @@ get_extended_debug_logger, ) -from eth._utils.datatypes import Configurable +from eth._utils.datatypes import ( + Configurable, +) from eth.abc import ( MessageComputationAPI, OpcodeAPI, ) - T = TypeVar('T') diff --git a/eth/vm/spoof.py b/eth/vm/spoof.py index 1c81eec130..40d27cc0ff 100644 --- a/eth/vm/spoof.py +++ b/eth/vm/spoof.py @@ -1,7 +1,15 @@ -from typing import Any, Union +from typing import ( + Any, + Union, +) -from eth.abc import SignedTransactionAPI, UnsignedTransactionAPI -from eth._utils.spoof import SpoofAttributes +from eth._utils.spoof import ( + SpoofAttributes, +) +from eth.abc import ( + SignedTransactionAPI, + UnsignedTransactionAPI, +) class SpoofTransaction(SpoofAttributes): diff --git a/eth/vm/stack.py b/eth/vm/stack.py index d9be86ce27..74f21ceaa7 100644 --- a/eth/vm/stack.py +++ b/eth/vm/stack.py @@ -3,7 +3,7 @@ Iterable, List, Tuple, - Union + Union, ) from eth_utils import ( @@ -11,17 +11,19 @@ big_endian_to_int, int_to_big_endian, ) + +from eth.abc import ( + StackAPI, +) from eth.exceptions import ( - InsufficientStack, FullStack, + InsufficientStack, ) from eth.validation import ( validate_stack_bytes, validate_stack_int, ) -from eth.abc import StackAPI - def _busted_type(item_type: type, value: Union[int, bytes]) -> ValidationError: return ValidationError( diff --git a/eth/vm/state.py b/eth/vm/state.py index 311fd75d2e..f4db6db9c4 100644 --- a/eth/vm/state.py +++ b/eth/vm/state.py @@ -15,27 +15,31 @@ ExtendedDebugLogger, get_extended_debug_logger, ) -from eth_utils.toolz import nth +from eth_utils.toolz import ( + nth, +) +from eth._utils.datatypes import ( + Configurable, +) from eth.abc import ( AccountDatabaseAPI, AtomicDatabaseAPI, - MessageComputationAPI, ExecutionContextAPI, MessageAPI, + MessageComputationAPI, + MetaWitnessAPI, SignedTransactionAPI, StateAPI, TransactionContextAPI, TransactionExecutorAPI, - MetaWitnessAPI, WithdrawalAPI, ) from eth.constants import ( MAX_PREV_HEADER_DEPTH, ) -from eth.typing import JournalDBCheckpoint -from eth._utils.datatypes import ( - Configurable, +from eth.typing import ( + JournalDBCheckpoint, ) diff --git a/eth/vm/transaction_context.py b/eth/vm/transaction_context.py index c4a12fa9dc..c73e0bd9c6 100644 --- a/eth/vm/transaction_context.py +++ b/eth/vm/transaction_context.py @@ -1,8 +1,12 @@ import itertools -from eth_typing import Address +from eth_typing import ( + Address, +) -from eth.abc import TransactionContextAPI +from eth.abc import ( + TransactionContextAPI, +) from eth.validation import ( validate_canonical_address, validate_uint256, diff --git a/tests/conftest.py b/tests/conftest.py index dc0e29f028..64d2b0a774 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,40 +1,52 @@ -from pathlib import Path - +from pathlib import ( + Path, +) import pytest +from eth_keys import ( + keys, +) from eth_utils import ( decode_hex, + setup_DEBUG2_logging, to_tuple, to_wei, - setup_DEBUG2_logging, ) - -from eth_keys import keys import rlp -from eth import constants +from eth import ( + constants, +) from eth.chains.base import ( Chain, MiningChain, ) -from eth.consensus import PowConsensus -from eth.consensus.noproof import NoProofConsensus -from eth.db.atomic import AtomicDB -from eth.rlp.headers import BlockHeader +from eth.consensus import ( + PowConsensus, +) +from eth.consensus.noproof import ( + NoProofConsensus, +) +from eth.db.atomic import ( + AtomicDB, +) +from eth.rlp.headers import ( + BlockHeader, +) from eth.vm.forks import ( - FrontierVM, - HomesteadVM, - TangerineWhistleVM, - SpuriousDragonVM, + ArrowGlacierVM, + BerlinVM, ByzantiumVM, ConstantinopleVM, - PetersburgVM, + FrontierVM, + GrayGlacierVM, + HomesteadVM, IstanbulVM, - MuirGlacierVM, - BerlinVM, LondonVM, - ArrowGlacierVM, - GrayGlacierVM, + MuirGlacierVM, + PetersburgVM, + SpuriousDragonVM, + TangerineWhistleVM, ) # diff --git a/tests/core/address-utils/test_address_generation.py b/tests/core/address-utils/test_address_generation.py index f9df68aece..abe9742b89 100644 --- a/tests/core/address-utils/test_address_generation.py +++ b/tests/core/address-utils/test_address_generation.py @@ -1,10 +1,11 @@ import pytest from eth_utils import ( - decode_hex, big_endian_to_int, + decode_hex, is_same_address, ) + 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 59d9e924c6..21eb6b6e2a 100644 --- a/tests/core/builder-tools/test_chain_builder.py +++ b/tests/core/builder-tools/test_chain_builder.py @@ -1,12 +1,17 @@ import pytest -from eth_utils import ValidationError, to_wei +from eth_utils import ( + ValidationError, + to_wei, +) from eth.chains.base import ( Chain, MiningChain, ) -from eth.constants import ZERO_ADDRESS +from eth.constants import ( + ZERO_ADDRESS, +) from eth.tools.builder.chain import ( at_block_number, build, @@ -20,7 +25,9 @@ mine_block, mine_blocks, ) -from eth.tools.factories.transaction import new_transaction +from eth.tools.factories.transaction import ( + new_transaction, +) @pytest.fixture diff --git a/tests/core/builder-tools/test_chain_construction.py b/tests/core/builder-tools/test_chain_construction.py index 4b96baaa7f..c1b0278767 100644 --- a/tests/core/builder-tools/test_chain_construction.py +++ b/tests/core/builder-tools/test_chain_construction.py @@ -1,9 +1,15 @@ import pytest -from eth_utils import ValidationError +from eth_utils import ( + ValidationError, +) -from eth.chains.base import MiningChain -from eth.consensus.pow import check_pow +from eth.chains.base import ( + MiningChain, +) +from eth.consensus.pow import ( + check_pow, +) from eth.tools.builder.chain import ( arrow_glacier_at, berlin_at, @@ -30,21 +36,21 @@ tangerine_whistle_at, ) from eth.vm.forks import ( - FrontierVM, - HomesteadVM, - TangerineWhistleVM, - SpuriousDragonVM, + ArrowGlacierVM, + BerlinVM, ByzantiumVM, ConstantinopleVM, - PetersburgVM, + FrontierVM, + GrayGlacierVM, + HomesteadVM, IstanbulVM, - MuirGlacierVM, - BerlinVM, LondonVM, - ArrowGlacierVM, - GrayGlacierVM, + MuirGlacierVM, ParisVM, + PetersburgVM, ShanghaiVM, + SpuriousDragonVM, + TangerineWhistleVM, ) diff --git a/tests/core/builder-tools/test_chain_initializer.py b/tests/core/builder-tools/test_chain_initializer.py index 9cb653703a..42961dbc55 100644 --- a/tests/core/builder-tools/test_chain_initializer.py +++ b/tests/core/builder-tools/test_chain_initializer.py @@ -1,11 +1,16 @@ -import time - import pytest +import time -from eth_utils.toolz import pipe +from eth_utils.toolz import ( + pipe, +) -from eth import constants -from eth.chains.base import Chain +from eth import ( + constants, +) +from eth.chains.base import ( + Chain, +) from eth.tools.builder.chain import ( frontier_at, genesis, diff --git a/tests/core/chain-object/test_build_block_incrementally.py b/tests/core/chain-object/test_build_block_incrementally.py index d1a96d086a..b4a1a4e671 100644 --- a/tests/core/chain-object/test_build_block_incrementally.py +++ b/tests/core/chain-object/test_build_block_incrementally.py @@ -1,11 +1,14 @@ import pytest -from eth.chains.base import MiningChain +from eth._utils.address import ( + force_bytes_to_address, +) +from eth.chains.base import ( + MiningChain, +) from eth.tools.factories.transaction import ( - new_transaction + new_transaction, ) -from eth._utils.address import force_bytes_to_address - ADDRESS_1010 = force_bytes_to_address(b'\x10\x10') diff --git a/tests/core/chain-object/test_chain.py b/tests/core/chain-object/test_chain.py index c58897a17f..5fce0ad8dc 100644 --- a/tests/core/chain-object/test_chain.py +++ b/tests/core/chain-object/test_chain.py @@ -1,26 +1,41 @@ import pytest -import rlp -from eth_utils import decode_hex -from eth_utils.toolz import sliding_window +from eth_utils import ( + decode_hex, +) +from eth_utils.toolz import ( + sliding_window, +) +import rlp -from eth import constants -from eth.abc import MiningChainAPI -from eth.chains.base import MiningChain +from eth import ( + constants, +) +from eth.abc import ( + MiningChainAPI, +) +from eth.chains.base import ( + MiningChain, +) from eth.chains.mainnet import ( MAINNET_GENESIS_HEADER, MINING_MAINNET_VMS, ) -from eth.chains.ropsten import ROPSTEN_GENESIS_HEADER -from eth.consensus.noproof import NoProofConsensus +from eth.chains.ropsten import ( + ROPSTEN_GENESIS_HEADER, +) +from eth.consensus.noproof import ( + NoProofConsensus, +) from eth.exceptions import ( TransactionNotFound, ) from eth.tools.factories.transaction import ( - new_transaction + new_transaction, +) +from eth.vm.forks.frontier.blocks import ( + FrontierBlock, ) -from eth.vm.forks.frontier.blocks import FrontierBlock - from tests.core.fixtures import ( valid_block_rlp, ) diff --git a/tests/core/chain-object/test_chain_get_ancestors.py b/tests/core/chain-object/test_chain_get_ancestors.py index 491b5123a5..16efdb1b23 100644 --- a/tests/core/chain-object/test_chain_get_ancestors.py +++ b/tests/core/chain-object/test_chain_get_ancestors.py @@ -1,8 +1,14 @@ import pytest -from eth.chains.base import MiningChain -from eth.db.backends.memory import MemoryDB -from eth.db.atomic import AtomicDB +from eth.chains.base import ( + MiningChain, +) +from eth.db.atomic import ( + AtomicDB, +) +from eth.db.backends.memory import ( + MemoryDB, +) @pytest.fixture diff --git a/tests/core/chain-object/test_chain_reorganization.py b/tests/core/chain-object/test_chain_reorganization.py index f3ace49e26..35ea3ab13f 100644 --- a/tests/core/chain-object/test_chain_reorganization.py +++ b/tests/core/chain-object/test_chain_reorganization.py @@ -1,8 +1,11 @@ import pytest -from eth.chains.base import MiningChain - -from eth.tools.builder.chain import api +from eth.chains.base import ( + MiningChain, +) +from eth.tools.builder.chain import ( + api, +) @pytest.fixture(params=api.mining_mainnet_fork_at_fns) diff --git a/tests/core/chain-object/test_chain_retrieval_of_vm_class.py b/tests/core/chain-object/test_chain_retrieval_of_vm_class.py index 3f52baa011..1c6e9f906a 100644 --- a/tests/core/chain-object/test_chain_retrieval_of_vm_class.py +++ b/tests/core/chain-object/test_chain_retrieval_of_vm_class.py @@ -1,6 +1,5 @@ import pytest - from eth.chains.base import ( Chain, MiningChain, @@ -10,14 +9,18 @@ GENESIS_DIFFICULTY, GENESIS_GAS_LIMIT, ) -from eth.db.chain import ChainDB +from eth.db.chain import ( + ChainDB, +) from eth.exceptions import ( VMNotFound, ) from eth.rlp.headers import ( BlockHeader, ) -from eth.vm.base import VM +from eth.vm.base import ( + VM, +) @pytest.fixture diff --git a/tests/core/chain-object/test_contract_call.py b/tests/core/chain-object/test_contract_call.py index 5a8b6160df..3ae3708b34 100644 --- a/tests/core/chain-object/test_contract_call.py +++ b/tests/core/chain-object/test_contract_call.py @@ -1,14 +1,13 @@ -from eth_utils.toolz import ( - assoc, -) - +import pytest from eth_utils import ( decode_hex, function_signature_to_4byte_selector, to_bytes, ) -import pytest +from eth_utils.toolz import ( + assoc, +) from eth.exceptions import ( InvalidInstruction, @@ -16,22 +15,22 @@ Revert, ) from eth.tools.factories.transaction import ( - new_transaction + new_transaction, ) from eth.vm.forks import ( - FrontierVM, - HomesteadVM, - TangerineWhistleVM, - SpuriousDragonVM, + ArrowGlacierVM, + BerlinVM, ByzantiumVM, ConstantinopleVM, - PetersburgVM, + FrontierVM, + GrayGlacierVM, + HomesteadVM, IstanbulVM, - MuirGlacierVM, - BerlinVM, LondonVM, - ArrowGlacierVM, - GrayGlacierVM, + MuirGlacierVM, + PetersburgVM, + SpuriousDragonVM, + TangerineWhistleVM, ) diff --git a/tests/core/chain-object/test_create_transaction.py b/tests/core/chain-object/test_create_transaction.py index 80d8630253..e569da3caa 100644 --- a/tests/core/chain-object/test_create_transaction.py +++ b/tests/core/chain-object/test_create_transaction.py @@ -1,10 +1,18 @@ import pytest -from eth_keys import keys +from eth_keys import ( + keys, +) -from eth.chains.base import MiningChain -from eth.chains.mainnet import MINING_MAINNET_VMS -from eth.tools.builder.chain import api +from eth.chains.base import ( + MiningChain, +) +from eth.chains.mainnet import ( + MINING_MAINNET_VMS, +) +from eth.tools.builder.chain import ( + api, +) @pytest.fixture(params=MINING_MAINNET_VMS) diff --git a/tests/core/chain-object/test_gas_estimation.py b/tests/core/chain-object/test_gas_estimation.py index 5f7a758bf1..32042347e2 100644 --- a/tests/core/chain-object/test_gas_estimation.py +++ b/tests/core/chain-object/test_gas_estimation.py @@ -1,30 +1,32 @@ import pytest -from eth.estimators.gas import binary_gas_search_1000_tolerance +from eth._utils.address import ( + force_bytes_to_address, +) +from eth.estimators.gas import ( + binary_gas_search_1000_tolerance, +) from eth.tools.factories.transaction import ( - new_transaction + new_transaction, ) from eth.vm.forks import ( - FrontierVM, - HomesteadVM, - TangerineWhistleVM, - SpuriousDragonVM, + ArrowGlacierVM, + BerlinVM, ByzantiumVM, ConstantinopleVM, - PetersburgVM, + FrontierVM, + HomesteadVM, IstanbulVM, - MuirGlacierVM, - BerlinVM, LondonVM, - ArrowGlacierVM, + MuirGlacierVM, + PetersburgVM, + SpuriousDragonVM, + TangerineWhistleVM, ) -from eth._utils.address import force_bytes_to_address - from tests.core.helpers import ( fill_block, ) - ADDRESS_2 = b'\0' * 19 + b'\x02' ADDR_1010 = force_bytes_to_address(b'\x10\x10') diff --git a/tests/core/code-stream/test_code_stream.py b/tests/core/code-stream/test_code_stream.py index 6199ca207f..ef3e3c3bea 100644 --- a/tests/core/code-stream/test_code_stream.py +++ b/tests/core/code-stream/test_code_stream.py @@ -1,20 +1,27 @@ import itertools -import sys - import pytest +import sys +from eth_utils import ( + ValidationError, +) +from eth_utils.toolz import ( + drop, +) from hypothesis import ( given, strategies as st, ) -from eth_utils import ValidationError - -from eth_utils.toolz import drop - -from eth.vm import opcode_values -from eth.vm.code_stream import CodeStream -from eth.tools._utils.slow_code_stream import SlowCodeStream +from eth.tools._utils.slow_code_stream import ( + SlowCodeStream, +) +from eth.vm import ( + opcode_values, +) +from eth.vm.code_stream import ( + CodeStream, +) def test_code_stream_accepts_bytes(): diff --git a/tests/core/consensus/test_clique_consensus.py b/tests/core/consensus/test_clique_consensus.py index e3f75105b6..5a80a5bfff 100644 --- a/tests/core/consensus/test_clique_consensus.py +++ b/tests/core/consensus/test_clique_consensus.py @@ -1,43 +1,54 @@ import pytest +from eth_keys import ( + keys, +) from eth_utils import ( + ValidationError, decode_hex, to_tuple, ) -from eth_keys import keys - -from eth_utils import ValidationError - -from eth.chains.base import MiningChain +from eth.chains.base import ( + MiningChain, +) from eth.chains.goerli import ( GOERLI_GENESIS_HEADER, ) from eth.consensus.clique import ( + NONCE_AUTH, + NONCE_DROP, CliqueApplier, CliqueConsensus, CliqueConsensusContext, - NONCE_AUTH, - NONCE_DROP, VoteAction, ) -from eth.consensus.clique.constants import ( - VANITY_LENGTH, - SIGNATURE_LENGTH, -) from eth.consensus.clique._utils import ( get_block_signer, sign_block_header, ) +from eth.consensus.clique.constants import ( + SIGNATURE_LENGTH, + VANITY_LENGTH, +) from eth.constants import ( - ZERO_ADDRESS + ZERO_ADDRESS, +) +from eth.rlp.headers import ( + BlockHeader, +) +from eth.tools.factories.keys import ( + PublicKeyFactory, +) +from eth.tools.factories.transaction import ( + new_transaction, +) +from eth.vm.forks.istanbul import ( + IstanbulVM, +) +from eth.vm.forks.petersburg import ( + PetersburgVM, ) -from eth.rlp.headers import BlockHeader -from eth.tools.factories.keys import PublicKeyFactory -from eth.tools.factories.transaction import new_transaction -from eth.vm.forks.istanbul import IstanbulVM -from eth.vm.forks.petersburg import PetersburgVM - ALICE_PK = keys.PrivateKey( decode_hex('0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8') diff --git a/tests/core/consensus/test_clique_encoding.py b/tests/core/consensus/test_clique_encoding.py index dbcf2b91d2..0d8823c817 100644 --- a/tests/core/consensus/test_clique_encoding.py +++ b/tests/core/consensus/test_clique_encoding.py @@ -1,27 +1,25 @@ import pytest -from eth.constants import ( - GENESIS_PARENT_HASH, - ZERO_ADDRESS, -) from eth.consensus.clique.datatypes import ( Snapshot, Tally, Vote, - VoteAction + VoteAction, ) from eth.consensus.clique.encoding import ( decode_address_tally_pair, - encode_address_tally_pair, - decode_snapshot, decode_tally, decode_vote, + encode_address_tally_pair, encode_snapshot, encode_tally, encode_vote, ) - +from eth.constants import ( + GENESIS_PARENT_HASH, + ZERO_ADDRESS, +) SOME_ADDRESS = b'\x85\x82\xa2\x89V\xb9%\x93M\x03\xdd\xb4Xu\xe1\x8e\x85\x93\x12\xc1' diff --git a/tests/core/consensus/test_clique_utils.py b/tests/core/consensus/test_clique_utils.py index 4077e8967e..af08a25501 100644 --- a/tests/core/consensus/test_clique_utils.py +++ b/tests/core/consensus/test_clique_utils.py @@ -1,26 +1,30 @@ import pytest +from eth_keys import ( + keys, +) +from eth_typing import ( + Address, +) from eth_utils import ( decode_hex, ) -from eth_keys import keys - -from eth_typing import Address - from eth.chains.goerli import ( GOERLI_GENESIS_HEADER, ) -from eth.consensus.clique.constants import ( - VANITY_LENGTH, - SIGNATURE_LENGTH, -) from eth.consensus.clique._utils import ( get_block_signer, get_signers_at_checkpoint, sign_block_header, ) -from eth.rlp.headers import BlockHeader +from eth.consensus.clique.constants import ( + SIGNATURE_LENGTH, + VANITY_LENGTH, +) +from eth.rlp.headers import ( + BlockHeader, +) ALICE_PK = keys.PrivateKey( decode_hex('0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8') diff --git a/tests/core/consensus/test_consensus_engine.py b/tests/core/consensus/test_consensus_engine.py index 8980066079..64f2c6a1cc 100644 --- a/tests/core/consensus/test_consensus_engine.py +++ b/tests/core/consensus/test_consensus_engine.py @@ -1,23 +1,25 @@ import pytest +from eth_utils import ( + ValidationError, +) + from eth.abc import ( ConsensusAPI, ) +from eth.chains.base import ( + MiningChain, +) from eth.consensus import ( ConsensusContext, ) - -from eth.chains.base import MiningChain from eth.tools.builder.chain import ( genesis, ) -from eth.vm.forks.istanbul import IstanbulVM - -from eth_utils import ( - ValidationError, +from eth.vm.forks.istanbul import ( + IstanbulVM, ) - CONSENSUS_DATA_LENGH = 9 WHITELISTED_ROOT = b"root" diff --git a/tests/core/consensus/test_pow_mining.py b/tests/core/consensus/test_pow_mining.py index b19ab7214f..e86f9a5851 100644 --- a/tests/core/consensus/test_pow_mining.py +++ b/tests/core/consensus/test_pow_mining.py @@ -3,18 +3,24 @@ import threading import time -from eth.chains.base import MiningChain -from eth.chains.mainnet import MINING_MAINNET_VMS +from eth.chains.base import ( + MiningChain, +) +from eth.chains.mainnet import ( + MINING_MAINNET_VMS, +) from eth.consensus.pow import ( CACHE_MAX_ITEMS, EPOCH_LENGTH, check_pow, get_cache, ) -from eth.tools.mining import POWMiningMixin from eth.tools.builder.chain import ( genesis, ) +from eth.tools.mining import ( + POWMiningMixin, +) def _concurrently_run_to_completion(target, concurrency): diff --git a/tests/core/fixture-tools/test_normalize_state.py b/tests/core/fixture-tools/test_normalize_state.py index 4e8c144117..3775eb39b1 100644 --- a/tests/core/fixture-tools/test_normalize_state.py +++ b/tests/core/fixture-tools/test_normalize_state.py @@ -1,12 +1,13 @@ import pytest from eth_utils import ( - big_endian_to_int, ValidationError, + big_endian_to_int, ) -from eth.tools._utils.normalization import normalize_state - +from eth.tools._utils.normalization import ( + normalize_state, +) ADDRESS_A = b'a' + b'\0' * 19 ADDRESS_B = b'b' + b'\0' * 19 diff --git a/tests/core/fixtures.py b/tests/core/fixtures.py index 9362fed4e6..767ca160d2 100644 --- a/tests/core/fixtures.py +++ b/tests/core/fixtures.py @@ -2,7 +2,6 @@ decode_hex, ) - # This block is a child of the genesis defined in the chain fixture above and contains a single tx # that transfers 10 wei from 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b to # 0x095e7baea6a6c7c4c2dfeb977efac326af552d87. diff --git a/tests/core/gas_meter/test_gas_meter.py b/tests/core/gas_meter/test_gas_meter.py index 54f22f3848..738aedf0fe 100644 --- a/tests/core/gas_meter/test_gas_meter.py +++ b/tests/core/gas_meter/test_gas_meter.py @@ -1,13 +1,15 @@ import pytest + from eth_utils import ( ValidationError, ) -from eth.vm.gas_meter import ( - GasMeter, -) + from eth.exceptions import ( OutOfGas, ) +from eth.vm.gas_meter import ( + GasMeter, +) @pytest.fixture(params=[10, 100, 999]) diff --git a/tests/core/generator-utils/test_cached_iterable.py b/tests/core/generator-utils/test_cached_iterable.py index 433b6bf505..5eeaa864f7 100644 --- a/tests/core/generator-utils/test_cached_iterable.py +++ b/tests/core/generator-utils/test_cached_iterable.py @@ -1,10 +1,13 @@ -from eth._utils.generator import CachedIterable +import itertools from eth_utils.toolz import ( first, nth, ) -import itertools + +from eth._utils.generator import ( + CachedIterable, +) def test_cached_generator(): diff --git a/tests/core/helpers.py b/tests/core/helpers.py index f592a042f3..c59cedc4da 100644 --- a/tests/core/helpers.py +++ b/tests/core/helpers.py @@ -1,12 +1,16 @@ import pytest from eth_utils import ( - decode_hex, ValidationError, + decode_hex, ) -from eth.chains.base import MiningChain -from eth.tools.factories.transaction import new_transaction +from eth.chains.base import ( + MiningChain, +) +from eth.tools.factories.transaction import ( + new_transaction, +) def fill_block(chain, from_, key, gas, data): diff --git a/tests/core/hexadecimal-utils/test_encode_and_decode.py b/tests/core/hexadecimal-utils/test_encode_and_decode.py index 327d5fe4b6..3dbd490eeb 100644 --- a/tests/core/hexadecimal-utils/test_encode_and_decode.py +++ b/tests/core/hexadecimal-utils/test_encode_and_decode.py @@ -1,10 +1,9 @@ import pytest from eth_utils import ( - encode_hex, decode_hex, + encode_hex, ) - from hypothesis import ( given, strategies as st, diff --git a/tests/core/message-object/test_message_object.py b/tests/core/message-object/test_message_object.py index 1fb5ed5c5f..1789fbe830 100644 --- a/tests/core/message-object/test_message_object.py +++ b/tests/core/message-object/test_message_object.py @@ -1,17 +1,16 @@ import pytest from eth_utils import ( - to_normalized_address, ValidationError, + to_normalized_address, ) -from eth.vm.message import ( - Message, -) from eth.constants import ( CREATE_CONTRACT_ADDRESS, ) - +from eth.vm.message import ( + Message, +) ADDRESS_A = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0" ADDRESS_B = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1" diff --git a/tests/core/numeric-utils/test_int_to_bytes32.py b/tests/core/numeric-utils/test_int_to_bytes32.py index a8ef32c951..d71f5b1570 100644 --- a/tests/core/numeric-utils/test_int_to_bytes32.py +++ b/tests/core/numeric-utils/test_int_to_bytes32.py @@ -1,14 +1,13 @@ import pytest +from eth._utils.numeric import ( + int_to_bytes32, +) from eth.constants import ( NULL_BYTE, UINT_256_MAX, ) -from eth._utils.numeric import ( - int_to_bytes32, -) - @pytest.mark.parametrize( 'value, expected', diff --git a/tests/core/numeric-utils/test_integer_squareroot.py b/tests/core/numeric-utils/test_integer_squareroot.py index 2b3c511fb5..75d783591c 100644 --- a/tests/core/numeric-utils/test_integer_squareroot.py +++ b/tests/core/numeric-utils/test_integer_squareroot.py @@ -1,4 +1,5 @@ import pytest + from hypothesis import ( given, strategies as st, diff --git a/tests/core/opcodes/test_opcodes.py b/tests/core/opcodes/test_opcodes.py index 6b7941ecdf..78ca4a853e 100644 --- a/tests/core/opcodes/test_opcodes.py +++ b/tests/core/opcodes/test_opcodes.py @@ -1,66 +1,71 @@ -import warnings - import pytest +import warnings -from eth.chains.mainnet import ( - MAINNET_VMS, - POS_MAINNET_VMS, -) -from eth.vm.forks.shanghai.computation import ( - ShanghaiMessageComputation, -) from eth_utils import ( + ValidationError, decode_hex, encode_hex, hexstr_if_str, int_to_big_endian, to_bytes, to_canonical_address, - ValidationError, ) + from eth import ( - constants + constants, ) from eth._utils.address import ( force_bytes_to_address, ) -from eth.consensus import ConsensusContext +from eth._utils.padding import ( + pad32, +) +from eth.chains.mainnet import ( + MAINNET_VMS, + POS_MAINNET_VMS, +) +from eth.consensus import ( + ConsensusContext, +) from eth.db.atomic import ( - AtomicDB + AtomicDB, ) from eth.db.chain import ( - ChainDB + ChainDB, ) from eth.exceptions import ( InvalidInstruction, VMError, ) -from eth._utils.padding import ( - pad32 -) from eth.vm import ( - opcode_values + opcode_values, +) +from eth.vm.chain_context import ( + ChainContext, ) -from eth.vm.chain_context import ChainContext from eth.vm.forks import ( - FrontierVM, - HomesteadVM, - TangerineWhistleVM, - SpuriousDragonVM, + BerlinVM, ByzantiumVM, ConstantinopleVM, - PetersburgVM, + FrontierVM, + HomesteadVM, IstanbulVM, - MuirGlacierVM, - BerlinVM, LondonVM, + MuirGlacierVM, + PetersburgVM, ShanghaiVM, + SpuriousDragonVM, + TangerineWhistleVM, +) +from eth.vm.forks.shanghai.computation import ( + ShanghaiMessageComputation, ) from eth.vm.message import ( Message, ) -from eth.vm.spoof import SpoofTransaction - +from eth.vm.spoof import ( + SpoofTransaction, +) NORMALIZED_ADDRESS_A = "0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" NORMALIZED_ADDRESS_B = "0xcd1722f3947def4cf144679da39c4c32bdc35681" diff --git a/tests/core/padding-utils/test_padding.py b/tests/core/padding-utils/test_padding.py index e9ed90abcd..631af7e161 100644 --- a/tests/core/padding-utils/test_padding.py +++ b/tests/core/padding-utils/test_padding.py @@ -2,7 +2,7 @@ from eth._utils.padding import ( pad32, - pad32r + pad32r, ) padding_byte = b"\x00" diff --git a/tests/core/precompiles/test_blake2.py b/tests/core/precompiles/test_blake2.py index 243dabca91..fb52b4c7aa 100644 --- a/tests/core/precompiles/test_blake2.py +++ b/tests/core/precompiles/test_blake2.py @@ -1,12 +1,16 @@ import pytest from eth_utils import ( - to_bytes, ValidationError, + to_bytes, ) -from eth._utils.blake2.coders import extract_blake2b_parameters -from eth._utils.blake2.compression import blake2b_compress +from eth._utils.blake2.coders import ( + extract_blake2b_parameters, +) +from eth._utils.blake2.compression import ( + blake2b_compress, +) @pytest.mark.parametrize( diff --git a/tests/core/stack/test_stack.py b/tests/core/stack/test_stack.py index 4b0c897d18..3f327eeb4c 100644 --- a/tests/core/stack/test_stack.py +++ b/tests/core/stack/test_stack.py @@ -4,13 +4,13 @@ ValidationError, ) -from eth.vm.stack import ( - Stack, -) from eth.exceptions import ( FullStack, InsufficientStack, ) +from eth.vm.stack import ( + Stack, +) @pytest.fixture diff --git a/tests/core/tester/test_generate_vm_configuration.py b/tests/core/tester/test_generate_vm_configuration.py index 440bc29dab..2a3db198be 100644 --- a/tests/core/tester/test_generate_vm_configuration.py +++ b/tests/core/tester/test_generate_vm_configuration.py @@ -1,11 +1,12 @@ -import pytest - import enum +import pytest -from eth.vm.forks.frontier import FrontierVM from eth.chains.tester import ( _generate_vm_configuration, ) +from eth.vm.forks.frontier import ( + FrontierVM, +) class Forks(enum.Enum): diff --git a/tests/core/transaction-utils/conftest.py b/tests/core/transaction-utils/conftest.py index f19df4e11a..c2e22dd074 100644 --- a/tests/core/transaction-utils/conftest.py +++ b/tests/core/transaction-utils/conftest.py @@ -1,6 +1,5 @@ import pytest - # from https://github.com/ethereum/tests/blob/c951a3c105d600ccd8f1c3fc87856b2bcca3df0a/BasicTests/txtest.json # noqa: E501 TRANSACTION_FIXTURES = [ { diff --git a/tests/core/transaction-utils/test_receipt_encoding.py b/tests/core/transaction-utils/test_receipt_encoding.py index 545dbdfcbd..5bafdcdd1a 100644 --- a/tests/core/transaction-utils/test_receipt_encoding.py +++ b/tests/core/transaction-utils/test_receipt_encoding.py @@ -1,13 +1,18 @@ +import pytest + from eth_utils import ( ValidationError, decode_hex, to_bytes, ) -import pytest import rlp -from eth.exceptions import UnrecognizedTransactionType -from eth.rlp.receipts import Receipt +from eth.exceptions import ( + UnrecognizedTransactionType, +) +from eth.rlp.receipts import ( + Receipt, +) from eth.vm.forks import ( BerlinVM, LondonVM, diff --git a/tests/core/transaction-utils/test_transaction_encoding.py b/tests/core/transaction-utils/test_transaction_encoding.py index df1e8d0b4e..db09afb603 100644 --- a/tests/core/transaction-utils/test_transaction_encoding.py +++ b/tests/core/transaction-utils/test_transaction_encoding.py @@ -1,13 +1,16 @@ +import pytest + from eth_utils import ( ValidationError, decode_hex, to_bytes, to_int, ) -import pytest import rlp -from eth.exceptions import UnrecognizedTransactionType +from eth.exceptions import ( + UnrecognizedTransactionType, +) from eth.vm.forks import ( BerlinVM, LondonVM, diff --git a/tests/core/transaction-utils/test_transaction_signature_validation.py b/tests/core/transaction-utils/test_transaction_signature_validation.py index 855d37d91f..8c8f41b1b3 100644 --- a/tests/core/transaction-utils/test_transaction_signature_validation.py +++ b/tests/core/transaction-utils/test_transaction_signature_validation.py @@ -1,15 +1,22 @@ import pytest -import rlp - +from eth_keys import ( + keys, +) from eth_utils import ( decode_hex, is_same_address, to_canonical_address, ) +import rlp -from eth_keys import keys - +from eth._utils.transactions import ( + extract_transaction_sender, + validate_transaction_signature, +) +from eth.vm.forks.berlin.transactions import ( + BerlinTransactionBuilder, +) from eth.vm.forks.frontier.transactions import ( FrontierTransaction, ) @@ -19,14 +26,6 @@ from eth.vm.forks.spurious_dragon.transactions import ( SpuriousDragonTransaction, ) -from eth.vm.forks.berlin.transactions import ( - BerlinTransactionBuilder, -) - -from eth._utils.transactions import ( - extract_transaction_sender, - validate_transaction_signature, -) @pytest.fixture(params=[ diff --git a/tests/core/validation/test_eth1_validation.py b/tests/core/validation/test_eth1_validation.py index fa86d1ecdb..4a448774c0 100644 --- a/tests/core/validation/test_eth1_validation.py +++ b/tests/core/validation/test_eth1_validation.py @@ -3,6 +3,7 @@ from eth_utils import ( ValidationError, ) + from eth.constants import ( SECPK1_N, ) @@ -19,9 +20,9 @@ validate_length, validate_length_lte, validate_lt, - validate_lte, validate_lt_secpk1n, validate_lt_secpk1n2, + validate_lte, validate_multiple_of, validate_stack_bytes, validate_stack_int, @@ -32,7 +33,6 @@ validate_word, ) - byte = b"\x00" diff --git a/tests/core/validation/test_transaction_validation.py b/tests/core/validation/test_transaction_validation.py index 3a14903ea7..d0c5bfe4ac 100644 --- a/tests/core/validation/test_transaction_validation.py +++ b/tests/core/validation/test_transaction_validation.py @@ -1,9 +1,15 @@ import pytest -from eth.vm.forks.london.transactions import UnsignedDynamicFeeTransaction -from eth.vm.forks.berlin.transactions import UnsignedAccessListTransaction +from eth_utils import ( + ValidationError, +) -from eth_utils import ValidationError +from eth.vm.forks.berlin.transactions import ( + UnsignedAccessListTransaction, +) +from eth.vm.forks.london.transactions import ( + UnsignedDynamicFeeTransaction, +) @pytest.mark.parametrize( diff --git a/tests/core/validation/test_withdrawal_validation.py b/tests/core/validation/test_withdrawal_validation.py index 210f2f41a6..6e0b279682 100644 --- a/tests/core/validation/test_withdrawal_validation.py +++ b/tests/core/validation/test_withdrawal_validation.py @@ -1,13 +1,20 @@ import pytest -from eth_typing import Address -from eth.vm.forks.shanghai.withdrawals import Withdrawal -from eth.validation import UINT_64_MAX +from eth_typing import ( + Address, +) from eth_utils import ( ValidationError, to_hex, ) +from eth.validation import ( + UINT_64_MAX, +) +from eth.vm.forks.shanghai.withdrawals import ( + Withdrawal, +) + @pytest.mark.parametrize( "withdrawal", diff --git a/tests/core/vm/conftest.py b/tests/core/vm/conftest.py index 338be378bf..bf77fc3044 100644 --- a/tests/core/vm/conftest.py +++ b/tests/core/vm/conftest.py @@ -1,7 +1,12 @@ import pytest -from eth_utils import to_canonical_address -from eth.vm.transaction_context import BaseTransactionContext +from eth_utils import ( + to_canonical_address, +) + +from eth.vm.transaction_context import ( + BaseTransactionContext, +) @pytest.fixture diff --git a/tests/core/vm/test_base_computation.py b/tests/core/vm/test_base_computation.py index e60f4aeaa0..9667212a1d 100644 --- a/tests/core/vm/test_base_computation.py +++ b/tests/core/vm/test_base_computation.py @@ -5,15 +5,15 @@ ) from eth.exceptions import ( - VMError, Revert, -) -from eth.vm.message import ( - Message, + VMError, ) from eth.vm.computation import ( MessageComputation, ) +from eth.vm.message import ( + Message, +) from eth.vm.transaction_context import ( BaseTransactionContext, ) diff --git a/tests/core/vm/test_clique_validation.py b/tests/core/vm/test_clique_validation.py index e989e8da89..3d03607897 100644 --- a/tests/core/vm/test_clique_validation.py +++ b/tests/core/vm/test_clique_validation.py @@ -1,11 +1,13 @@ import pytest from eth_utils import ( - decode_hex, ValidationError, + decode_hex, ) -from eth.chains.base import MiningChain +from eth.chains.base import ( + MiningChain, +) from eth.chains.goerli import ( GOERLI_GENESIS_HEADER, ) @@ -13,14 +15,13 @@ CliqueApplier, CliqueConsensusContext, ) - -from eth.rlp.headers import BlockHeader - +from eth.rlp.headers import ( + BlockHeader, +) from eth.vm.forks.petersburg import ( PetersburgVM, ) - GOERLI_HEADER_ONE = BlockHeader( difficulty=2, block_number=1, diff --git a/tests/core/vm/test_computation.py b/tests/core/vm/test_computation.py index b11cee7ad3..35ddacd6ba 100644 --- a/tests/core/vm/test_computation.py +++ b/tests/core/vm/test_computation.py @@ -1,14 +1,25 @@ # test computation class behavior across VMs import pytest -from eth_typing import Address -from eth_utils import decode_hex - -from eth.chains.base import MiningChain -from eth.chains.mainnet import MINING_MAINNET_VMS +from eth_typing import ( + Address, +) +from eth_utils import ( + decode_hex, +) -from eth import constants -from eth.consensus import NoProofConsensus +from eth import ( + constants, +) +from eth.chains.base import ( + MiningChain, +) +from eth.chains.mainnet import ( + MINING_MAINNET_VMS, +) +from eth.consensus import ( + NoProofConsensus, +) from eth.exceptions import ( InvalidInstruction, ) diff --git a/tests/core/vm/test_frontier_computation.py b/tests/core/vm/test_frontier_computation.py index af890472ba..ea5ec2b5a1 100644 --- a/tests/core/vm/test_frontier_computation.py +++ b/tests/core/vm/test_frontier_computation.py @@ -1,11 +1,11 @@ import pytest -from eth.vm.message import ( - Message, -) from eth.vm.forks.frontier.computation import ( FrontierMessageComputation, ) +from eth.vm.message import ( + Message, +) @pytest.fixture diff --git a/tests/core/vm/test_interrupt.py b/tests/core/vm/test_interrupt.py index 4a777b994a..1e7290472c 100644 --- a/tests/core/vm/test_interrupt.py +++ b/tests/core/vm/test_interrupt.py @@ -1,6 +1,8 @@ import pytest -from eth_hash.auto import keccak +from eth_hash.auto import ( + keccak, +) from eth_utils import ( int_to_big_endian, ) diff --git a/tests/core/vm/test_london.py b/tests/core/vm/test_london.py index 4cfeaa19a2..66caab0ee6 100644 --- a/tests/core/vm/test_london.py +++ b/tests/core/vm/test_london.py @@ -1,18 +1,33 @@ import pytest -from eth_typing import Address -from eth_utils import decode_hex +from eth_typing import ( + Address, +) +from eth_utils import ( + decode_hex, +) -from eth import constants -from eth.consensus.noproof import NoProofConsensus -from eth.chains.base import MiningChain +from eth import ( + constants, +) +from eth.chains.base import ( + MiningChain, +) from eth.chains.mainnet import ( MINING_MAINNET_VMS, ) -from eth.exceptions import InvalidInstruction -from eth.vm.forks import BerlinVM +from eth.consensus.noproof import ( + NoProofConsensus, +) +from eth.exceptions import ( + InvalidInstruction, +) from eth.tools.factories.transaction import ( - new_dynamic_fee_transaction, new_transaction, + new_dynamic_fee_transaction, + new_transaction, +) +from eth.vm.forks import ( + BerlinVM, ) FOUR_TXN_GAS_LIMIT = 21000 * 4 diff --git a/tests/core/vm/test_mainnet_dao_fork.py b/tests/core/vm/test_mainnet_dao_fork.py index a6c7b9553b..8d2026df79 100644 --- a/tests/core/vm/test_mainnet_dao_fork.py +++ b/tests/core/vm/test_mainnet_dao_fork.py @@ -1,16 +1,19 @@ import pytest from eth_utils import ( - to_tuple, ValidationError, + to_tuple, +) +from eth_utils.toolz import ( + sliding_window, ) - -from eth_utils.toolz import sliding_window from eth.chains.mainnet import ( MainnetHomesteadVM, ) -from eth.rlp.headers import BlockHeader +from eth.rlp.headers import ( + BlockHeader, +) class ETC_VM(MainnetHomesteadVM): diff --git a/tests/core/vm/test_modexp_precompile.py b/tests/core/vm/test_modexp_precompile.py index 6e01175b2d..ca58b72f18 100644 --- a/tests/core/vm/test_modexp_precompile.py +++ b/tests/core/vm/test_modexp_precompile.py @@ -7,8 +7,8 @@ ) from eth.precompiles.modexp import ( - _modexp, _compute_modexp_gas_fee_eip_198, + _modexp, ) from eth.vm.forks.berlin.computation import ( _compute_modexp_gas_fee_eip_2565, diff --git a/tests/core/vm/test_rewards.py b/tests/core/vm/test_rewards.py index 45128b56b9..e63bd6a8ef 100644 --- a/tests/core/vm/test_rewards.py +++ b/tests/core/vm/test_rewards.py @@ -1,31 +1,33 @@ import pytest from eth_utils import ( - to_wei, ValidationError, + to_wei, ) from eth.chains.base import ( - MiningChain + MiningChain, ) from eth.tools.builder.chain import ( at_block_number, + berlin_at, build, - disable_pow_check, - mine_block, - mine_blocks, byzantium_at, + constantinople_at, + disable_pow_check, frontier_at, + genesis, homestead_at, + london_at, + mine_block, + mine_blocks, + petersburg_at, spurious_dragon_at, tangerine_whistle_at, - constantinople_at, - petersburg_at, - berlin_at, - london_at, - genesis, ) -from eth.tools.factories.transaction import new_dynamic_fee_transaction +from eth.tools.factories.transaction import ( + new_dynamic_fee_transaction, +) @pytest.mark.parametrize( diff --git a/tests/core/vm/test_shanghai.py b/tests/core/vm/test_shanghai.py index 547762f44e..bf3feb74bb 100644 --- a/tests/core/vm/test_shanghai.py +++ b/tests/core/vm/test_shanghai.py @@ -1,9 +1,17 @@ import pytest -from eth.chains.base import MiningChain -from eth.consensus import NoProofConsensus -from eth.vm.forks import ShanghaiVM -from eth.vm.forks.shanghai.withdrawals import Withdrawal +from eth.chains.base import ( + MiningChain, +) +from eth.consensus import ( + NoProofConsensus, +) +from eth.vm.forks import ( + ShanghaiVM, +) +from eth.vm.forks.shanghai.withdrawals import ( + Withdrawal, +) @pytest.fixture diff --git a/tests/core/vm/test_validate_transaction.py b/tests/core/vm/test_validate_transaction.py index 2571127bc9..370f873156 100644 --- a/tests/core/vm/test_validate_transaction.py +++ b/tests/core/vm/test_validate_transaction.py @@ -1,11 +1,24 @@ -from eth_utils import ValidationError import pytest -from eth._utils.address import force_bytes_to_address -from eth.chains.base import MiningChain -from eth.constants import GAS_TX -from eth.tools.factories.transaction import new_dynamic_fee_transaction -from eth.vm.forks import LondonVM +from eth_utils import ( + ValidationError, +) + +from eth._utils.address import ( + force_bytes_to_address, +) +from eth.chains.base import ( + MiningChain, +) +from eth.constants import ( + GAS_TX, +) +from eth.tools.factories.transaction import ( + new_dynamic_fee_transaction, +) +from eth.vm.forks import ( + LondonVM, +) @pytest.fixture diff --git a/tests/core/vm/test_vm.py b/tests/core/vm/test_vm.py index 6c3a65d4e8..af5dfd998f 100644 --- a/tests/core/vm/test_vm.py +++ b/tests/core/vm/test_vm.py @@ -1,12 +1,14 @@ import pytest -import rlp from eth_utils import ( - decode_hex, ValidationError, + decode_hex, ) +import rlp -from eth import constants +from eth import ( + constants, +) from eth.chains.base import ( MiningChain, ) @@ -14,9 +16,11 @@ MAINNET_VMS, MINING_MAINNET_VMS, ) -from eth.tools.builder.chain import api +from eth.tools.builder.chain import ( + api, +) from eth.tools.factories.transaction import ( - new_transaction + new_transaction, ) diff --git a/tests/core/vm/test_vm_state.py b/tests/core/vm/test_vm_state.py index 5004070f14..9ff5965368 100644 --- a/tests/core/vm/test_vm_state.py +++ b/tests/core/vm/test_vm_state.py @@ -1,12 +1,15 @@ import pytest -from eth_utils import ValidationError +from eth_utils import ( + ValidationError, +) from eth.tools.factories.transaction import ( - new_transaction + new_transaction, +) +from eth.vm.interrupt import ( + MissingAccountTrieNode, ) -from eth.vm.interrupt import MissingAccountTrieNode - ADDRESS = b'\xaa' * 20 OTHER_ADDRESS = b'\xbb' * 20 diff --git a/tests/database/test_accesslog.py b/tests/database/test_accesslog.py index cf7ccb5689..c4174fb254 100644 --- a/tests/database/test_accesslog.py +++ b/tests/database/test_accesslog.py @@ -1,14 +1,17 @@ +import pytest + from hypothesis import ( given, strategies as st, ) -import pytest from eth.db.accesslog import ( - KeyAccessLoggerDB, KeyAccessLoggerAtomicDB, + KeyAccessLoggerDB, +) +from eth.db.backends.memory import ( + MemoryDB, ) -from eth.db.backends.memory import MemoryDB @given(st.lists(st.binary())) diff --git a/tests/database/test_account_db.py b/tests/database/test_account_db.py index 1981bc711b..9c9e0cebce 100644 --- a/tests/database/test_account_db.py +++ b/tests/database/test_account_db.py @@ -1,21 +1,24 @@ import pytest -from eth_hash.auto import keccak - +from eth_hash.auto import ( + keccak, +) from eth_utils import ( ValidationError, ) -from eth.db.atomic import AtomicDB -from eth.db.backends.memory import MemoryDB +from eth.constants import ( + EMPTY_SHA3, +) from eth.db.account import ( AccountDB, ) - -from eth.constants import ( - EMPTY_SHA3, +from eth.db.atomic import ( + AtomicDB, +) +from eth.db.backends.memory import ( + MemoryDB, ) - ADDRESS = b'\xaa' * 20 OTHER_ADDRESS = b'\xbb' * 20 diff --git a/tests/database/test_atomic_database_api.py b/tests/database/test_atomic_database_api.py index 02a1591190..8d76cc86ee 100644 --- a/tests/database/test_atomic_database_api.py +++ b/tests/database/test_atomic_database_api.py @@ -1,10 +1,17 @@ import pytest -from eth.db.atomic import AtomicDB -from eth.db.backends.level import LevelDB - -from eth.tools.db.base import DatabaseAPITestSuite -from eth.tools.db.atomic import AtomicDatabaseBatchAPITestSuite +from eth.db.atomic import ( + AtomicDB, +) +from eth.db.backends.level import ( + LevelDB, +) +from eth.tools.db.atomic import ( + AtomicDatabaseBatchAPITestSuite, +) +from eth.tools.db.base import ( + DatabaseAPITestSuite, +) @pytest.fixture(params=['atomic', 'level']) diff --git a/tests/database/test_batch_db.py b/tests/database/test_batch_db.py index 0dfd742e23..c2ecabee89 100644 --- a/tests/database/test_batch_db.py +++ b/tests/database/test_batch_db.py @@ -1,10 +1,15 @@ import pytest + from eth_utils import ( ValidationError, ) -from eth.db.backends.memory import MemoryDB -from eth.db.batch import BatchDB +from eth.db.backends.memory import ( + MemoryDB, +) +from eth.db.batch import ( + BatchDB, +) @pytest.fixture diff --git a/tests/database/test_database_api.py b/tests/database/test_database_api.py index 7c822d8902..e297a5ad37 100644 --- a/tests/database/test_database_api.py +++ b/tests/database/test_database_api.py @@ -1,15 +1,27 @@ import pytest + from eth.db.accesslog import ( KeyAccessLoggerAtomicDB, KeyAccessLoggerDB, ) -from eth.db.backends.memory import MemoryDB -from eth.db.journal import JournalDB -from eth.db.batch import BatchDB -from eth.db.atomic import AtomicDB -from eth.db.cache import CacheDB - -from eth.tools.db.base import DatabaseAPITestSuite +from eth.db.atomic import ( + AtomicDB, +) +from eth.db.backends.memory import ( + MemoryDB, +) +from eth.db.batch import ( + BatchDB, +) +from eth.db.cache import ( + CacheDB, +) +from eth.db.journal import ( + JournalDB, +) +from eth.tools.db.base import ( + DatabaseAPITestSuite, +) @pytest.fixture(params=[ diff --git a/tests/database/test_eth1_chaindb.py b/tests/database/test_eth1_chaindb.py index 641f7405d1..c9da822a11 100644 --- a/tests/database/test_eth1_chaindb.py +++ b/tests/database/test_eth1_chaindb.py @@ -1,44 +1,56 @@ import pytest +from eth_hash.auto import ( + keccak, +) from hypothesis import ( given, strategies as st, ) - import rlp -from eth_hash.auto import keccak - +from eth._utils.address import ( + force_bytes_to_address, +) +from eth.chains.base import ( + MiningChain, +) from eth.constants import ( BLANK_ROOT_HASH, ZERO_ADDRESS, ) -from eth.chains.base import ( - MiningChain, +from eth.db.atomic import ( + AtomicDB, ) -from eth.db.atomic import AtomicDB from eth.db.chain import ( ChainDB, ) -from eth.db.chain_gaps import GENESIS_CHAIN_GAPS -from eth.db.schema import SchemaV1 +from eth.db.chain_gaps import ( + GENESIS_CHAIN_GAPS, +) +from eth.db.schema import ( + SchemaV1, +) from eth.exceptions import ( BlockNotFound, + CheckpointsMustBeCanonical, HeaderNotFound, ParentNotFound, ReceiptNotFound, - CheckpointsMustBeCanonical, ) from eth.rlp.headers import ( BlockHeader, ) -from eth.tools.builder.chain import api +from eth.tools.builder.chain import ( + api, +) +from eth.tools.factories.transaction import ( + new_access_list_transaction, + new_transaction, +) from eth.tools.rlp import ( assert_headers_eq, ) -from eth._utils.address import ( - force_bytes_to_address, -) from eth.vm.forks import ( BerlinVM, LondonVM, @@ -49,11 +61,6 @@ from eth.vm.forks.homestead.blocks import ( HomesteadBlock, ) -from eth.tools.factories.transaction import ( - new_access_list_transaction, - new_transaction, -) - A_ADDRESS = b"\xaa" * 20 B_ADDRESS = b"\xbb" * 20 diff --git a/tests/database/test_hash_trie.py b/tests/database/test_hash_trie.py index 2d83f28625..0fbb1429ad 100644 --- a/tests/database/test_hash_trie.py +++ b/tests/database/test_hash_trie.py @@ -1,10 +1,13 @@ +from eth_hash.auto import ( + keccak, +) from hypothesis import ( given, strategies as st, ) - -from eth_hash.auto import keccak -from trie import HexaryTrie +from trie import ( + HexaryTrie, +) from eth.db.hash_trie import ( HashTrie, diff --git a/tests/database/test_header_db.py b/tests/database/test_header_db.py index aacaadaae2..692407e2ae 100644 --- a/tests/database/test_header_db.py +++ b/tests/database/test_header_db.py @@ -1,27 +1,27 @@ import enum -from functools import partial +from functools import ( + partial, +) import operator +import pytest import random -from hypothesis import ( - example, - given, - settings, - strategies as st, +from eth_utils import ( + ValidationError, + keccak, + to_set, + to_tuple, ) -import pytest - from eth_utils.toolz import ( accumulate, compose, sliding_window, ) - -from eth_utils import ( - to_set, - to_tuple, - keccak, - ValidationError, +from hypothesis import ( + example, + given, + settings, + strategies as st, ) from eth.constants import ( @@ -29,13 +29,18 @@ GENESIS_DIFFICULTY, GENESIS_GAS_LIMIT, ) -from eth.db.atomic import AtomicDB +from eth.db.atomic import ( + AtomicDB, +) from eth.db.chain_gaps import ( - GapChange, GENESIS_CHAIN_GAPS, + GapChange, fill_gap, - reopen_gap, is_block_number_in_gap, + reopen_gap, +) +from eth.db.header import ( + HeaderDB, ) from eth.exceptions import ( CanonicalHeadNotFound, @@ -44,16 +49,15 @@ HeaderNotFound, ParentNotFound, ) -from eth.db.header import HeaderDB +from eth.tools.rlp import ( + assert_headers_eq, +) from eth.vm.forks.gray_glacier import ( GrayGlacierVM, ) from eth.vm.forks.gray_glacier.blocks import ( GrayGlacierBlockHeader as BlockHeader, ) -from eth.tools.rlp import ( - assert_headers_eq, -) @pytest.fixture diff --git a/tests/database/test_journal_db.py b/tests/database/test_journal_db.py index f55df0b2b5..2dbcbd7a25 100644 --- a/tests/database/test_journal_db.py +++ b/tests/database/test_journal_db.py @@ -1,16 +1,31 @@ -from eth_utils import ValidationError +import pytest + +from eth_utils import ( + ValidationError, +) from hypothesis import ( given, settings, strategies as st, ) -from hypothesis.stateful import Bundle, RuleBasedStateMachine, rule -import pytest +from hypothesis.stateful import ( + Bundle, + RuleBasedStateMachine, + rule, +) -from eth.db.backends.memory import MemoryDB -from eth.db.journal import JournalDB -from eth.db.slow_journal import JournalDB as SlowJournalDB -from eth.vm.interrupt import EVMMissingData +from eth.db.backends.memory import ( + MemoryDB, +) +from eth.db.journal import ( + JournalDB, +) +from eth.db.slow_journal import ( + JournalDB as SlowJournalDB, +) +from eth.vm.interrupt import ( + EVMMissingData, +) @pytest.fixture diff --git a/tests/database/test_leveldb_db_backend.py b/tests/database/test_leveldb_db_backend.py index e32b188a5e..88dc4c9b77 100644 --- a/tests/database/test_leveldb_db_backend.py +++ b/tests/database/test_leveldb_db_backend.py @@ -1,11 +1,14 @@ import pytest -from eth.db.backends.memory import MemoryDB -from eth.db.atomic import AtomicDB from eth.db import ( get_db_backend, ) - +from eth.db.atomic import ( + AtomicDB, +) +from eth.db.backends.memory import ( + MemoryDB, +) pytest.importorskip('leveldb') diff --git a/tests/fillers/build_json.py b/tests/fillers/build_json.py index 9576d24dcd..465b9c1217 100644 --- a/tests/fillers/build_json.py +++ b/tests/fillers/build_json.py @@ -1,21 +1,22 @@ -import os import json +import os -from eth_hash.auto import keccak - +from eth_hash.auto import ( + keccak, +) from eth_utils import ( encode_hex, ) -from eth.tools.fixtures.helpers import ( - get_test_name, -) + from eth.tools.fixtures.fillers import ( fill_test, ) from eth.tools.fixtures.fillers.formatters import ( filler_formatter, ) - +from eth.tools.fixtures.helpers import ( + get_test_name, +) PARENT_DIR = os.path.dirname(os.path.abspath(__file__)) OUTPUT_DIR = os.path.join(PARENT_DIR, "json") diff --git a/tests/json-fixtures/blockchain/test_blockchain.py b/tests/json-fixtures/blockchain/test_blockchain.py index 7e2d67227a..f42d7b6a92 100644 --- a/tests/json-fixtures/blockchain/test_blockchain.py +++ b/tests/json-fixtures/blockchain/test_blockchain.py @@ -1,17 +1,15 @@ import os -from pathlib import Path +from pathlib import ( + Path, +) import pytest -import rlp from eth_utils import ( - to_tuple, ValidationError, + to_tuple, ) +import rlp -from eth.tools.rlp import ( - assert_imported_block_unchanged, - assert_headers_eq, -) from eth.tools._utils.normalization import ( normalize_blockchain_fixtures, ) @@ -25,8 +23,13 @@ should_run_slow_tests, verify_state, ) -from eth.vm.header import HeaderSedes - +from eth.tools.rlp import ( + assert_headers_eq, + assert_imported_block_unchanged, +) +from eth.vm.header import ( + HeaderSedes, +) ROOT_PROJECT_DIR = Path(__file__).parents[3] diff --git a/tests/json-fixtures/test_difficulty.py b/tests/json-fixtures/test_difficulty.py index 0c59ee2769..2d4366192c 100644 --- a/tests/json-fixtures/test_difficulty.py +++ b/tests/json-fixtures/test_difficulty.py @@ -1,26 +1,33 @@ import os - import pytest -from eth_utils import to_int -from eth.constants import EMPTY_UNCLE_HASH -from eth.rlp.headers import BlockHeader +from eth_typing.enums import ( + ForkName, +) +from eth_utils import ( + to_int, +) + +from eth.constants import ( + EMPTY_UNCLE_HASH, +) +from eth.rlp.headers import ( + BlockHeader, +) from eth.tools.fixtures import ( filter_fixtures, generate_fixture_tests, load_fixture, ) from eth.vm.forks import ( - FrontierVM, - HomesteadVM, + ArrowGlacierVM, + BerlinVM, ByzantiumVM, ConstantinopleVM, - BerlinVM, - ArrowGlacierVM, + FrontierVM, GrayGlacierVM, + HomesteadVM, ) -from eth_typing.enums import ForkName - ROOT_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) diff --git a/tests/json-fixtures/test_transactions.py b/tests/json-fixtures/test_transactions.py index df00aaec7c..10640eeb48 100644 --- a/tests/json-fixtures/test_transactions.py +++ b/tests/json-fixtures/test_transactions.py @@ -1,61 +1,62 @@ import os - import pytest -import rlp - -from eth.exceptions import UnrecognizedTransactionType -from eth.vm.forks.shanghai.transactions import ShanghaiTransactionBuilder +from eth_typing.enums import ( + ForkName, +) from eth_utils import ( + ValidationError, is_same_address, to_tuple, - ValidationError, ) -from eth.tools.fixtures import ( - generate_fixture_tests, - load_fixture, +import rlp + +from eth.exceptions import ( + UnrecognizedTransactionType, ) from eth.tools._utils.normalization import ( normalize_transactiontest_fixture, ) -from eth.vm.forks.frontier.transactions import ( - FrontierTransaction +from eth.tools.fixtures import ( + generate_fixture_tests, + load_fixture, ) -from eth.vm.forks.homestead.transactions import ( - HomesteadTransaction +from eth.vm.forks.berlin.constants import ( + VALID_TRANSACTION_TYPES, ) -from eth.vm.forks.spurious_dragon.transactions import ( - SpuriousDragonTransaction +from eth.vm.forks.berlin.transactions import ( + BerlinTransactionBuilder, ) from eth.vm.forks.byzantium.transactions import ( - ByzantiumTransaction + ByzantiumTransaction, ) from eth.vm.forks.constantinople.transactions import ( - ConstantinopleTransaction + ConstantinopleTransaction, ) -from eth.vm.forks.petersburg.transactions import ( - PetersburgTransaction -) -from eth.vm.forks.istanbul.transactions import ( - IstanbulTransaction +from eth.vm.forks.frontier.transactions import ( + FrontierTransaction, ) -from eth.vm.forks.berlin.constants import ( - VALID_TRANSACTION_TYPES, +from eth.vm.forks.homestead.transactions import ( + HomesteadTransaction, ) -from eth.vm.forks.berlin.transactions import ( - BerlinTransactionBuilder +from eth.vm.forks.istanbul.transactions import ( + IstanbulTransaction, ) from eth.vm.forks.london.transactions import ( - LondonTransactionBuilder + LondonTransactionBuilder, ) from eth.vm.forks.paris.transactions import ( - ParisTransactionBuilder + ParisTransactionBuilder, ) - -from eth_typing.enums import ( - ForkName +from eth.vm.forks.petersburg.transactions import ( + PetersburgTransaction, +) +from eth.vm.forks.shanghai.transactions import ( + ShanghaiTransactionBuilder, +) +from eth.vm.forks.spurious_dragon.transactions import ( + SpuriousDragonTransaction, ) - ROOT_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) diff --git a/tests/json-fixtures/test_virtual_machine.py b/tests/json-fixtures/test_virtual_machine.py index 8ea42a1caa..319c1fb851 100644 --- a/tests/json-fixtures/test_virtual_machine.py +++ b/tests/json-fixtures/test_virtual_machine.py @@ -1,25 +1,34 @@ import os - import pytest +from eth_hash.auto import ( + keccak, +) from eth_utils import ( to_bytes, ) -from eth.consensus import ConsensusContext +from eth.consensus import ( + ConsensusContext, +) from eth.db import ( get_db_backend, ) -from eth.db.chain import ChainDB - -from eth_hash.auto import keccak - +from eth.db.chain import ( + ChainDB, +) from eth.exceptions import ( VMError, ) from eth.rlp.headers import ( BlockHeader, ) +from eth.tools._utils.hashing import ( + hash_log_entries, +) +from eth.tools._utils.normalization import ( + normalize_vmtest_fixture, +) from eth.tools.fixtures import ( filter_fixtures, generate_fixture_tests, @@ -27,20 +36,18 @@ setup_state, verify_state, ) -from eth.tools._utils.normalization import ( - normalize_vmtest_fixture, +from eth.vm.chain_context import ( + ChainContext, ) -from eth.tools._utils.hashing import ( - hash_log_entries, -) -from eth.vm.chain_context import ChainContext from eth.vm.forks import ( HomesteadVM, ) from eth.vm.forks.homestead.computation import ( HomesteadMessageComputation, ) -from eth.vm.forks.homestead.state import HomesteadState +from eth.vm.forks.homestead.state import ( + HomesteadState, +) from eth.vm.message import ( Message, )