diff --git a/eth/beacon/types/active_states.py b/eth/beacon/types/active_states.py index 7516539422..a899dc6324 100644 --- a/eth/beacon/types/active_states.py +++ b/eth/beacon/types/active_states.py @@ -9,13 +9,13 @@ from eth_typing import ( Hash32, ) +from eth_utils import ( + encode_hex, +) from eth.rlp.sedes import ( hash32 ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.utils.blake import ( blake, ) diff --git a/eth/beacon/types/blocks.py b/eth/beacon/types/blocks.py index 3eaee398a4..f071bc7e5c 100644 --- a/eth/beacon/types/blocks.py +++ b/eth/beacon/types/blocks.py @@ -5,6 +5,9 @@ from eth_typing import ( Hash32, ) +from eth_utils import ( + encode_hex, +) import rlp from rlp.sedes import ( CountableList, @@ -19,9 +22,6 @@ int64, hash32, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from .attestation_records import AttestationRecord diff --git a/eth/beacon/types/crystallized_states.py b/eth/beacon/types/crystallized_states.py index 5abbe6e884..97ac9f944c 100644 --- a/eth/beacon/types/crystallized_states.py +++ b/eth/beacon/types/crystallized_states.py @@ -6,6 +6,9 @@ from eth_typing import ( Hash32, ) +from eth_utils import ( + encode_hex, +) import rlp from rlp.sedes import ( @@ -16,9 +19,6 @@ int64, hash32, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.utils.blake import ( blake, ) diff --git a/eth/chains/base.py b/eth/chains/base.py index 512a6f1113..1fe027bcbb 100644 --- a/eth/chains/base.py +++ b/eth/chains/base.py @@ -28,6 +28,9 @@ BlockNumber, Hash32, ) +from eth_utils import ( + encode_hex, +) from eth.db.backends.base import BaseAtomicDB from eth.db.chain import ( @@ -82,9 +85,6 @@ from eth.utils.headers import ( compute_gas_limit_bounds, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.utils.rlp import ( validate_imported_block_unchanged, ) diff --git a/eth/consensus/pow.py b/eth/consensus/pow.py index 3815f541cb..be8199e53d 100644 --- a/eth/consensus/pow.py +++ b/eth/consensus/pow.py @@ -4,25 +4,25 @@ Tuple ) -from pyethash import ( - EPOCH_LENGTH, - hashimoto_light, - mkcache_bytes, -) - from eth_typing import ( Hash32 ) + from eth_utils import ( big_endian_to_int, ValidationError, + encode_hex, ) from eth_hash.auto import keccak -from eth.utils.hexadecimal import ( - encode_hex, +from pyethash import ( + EPOCH_LENGTH, + hashimoto_light, + mkcache_bytes, ) + + from eth.validation import ( validate_length, validate_lte, diff --git a/eth/db/__init__.py b/eth/db/__init__.py index 9211a0b37f..bb4e7c8e34 100644 --- a/eth/db/__init__.py +++ b/eth/db/__init__.py @@ -1,16 +1,14 @@ import os from typing import ( Any, - cast, - Type + Type, + cast ) -from eth.utils.module_loading import ( - import_string, -) -from eth.db.backends.base import ( - BaseAtomicDB, -) +from eth_utils import import_string + +from eth.db.backends.base import BaseAtomicDB + DEFAULT_DB_BACKEND = 'eth.db.atomic.AtomicDB' diff --git a/eth/db/chain.py b/eth/db/chain.py index a50535c955..dabb7de11a 100644 --- a/eth/db/chain.py +++ b/eth/db/chain.py @@ -17,6 +17,9 @@ BlockNumber, Hash32 ) +from eth_utils import ( + encode_hex, +) from eth_hash.auto import keccak @@ -39,9 +42,6 @@ from eth.rlp.receipts import ( Receipt ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.validation import ( validate_word, ) @@ -59,9 +59,7 @@ if TYPE_CHECKING: from eth.rlp.blocks import ( # noqa: F401 - BaseBlock - ) - from eth.rlp.transactions import ( # noqa: F401 + BaseBlock, BaseTransaction ) diff --git a/eth/estimators/__init__.py b/eth/estimators/__init__.py index 1ce66ac7a0..f879ab0107 100644 --- a/eth/estimators/__init__.py +++ b/eth/estimators/__init__.py @@ -1,18 +1,14 @@ import os from typing import ( Callable, - cast, + cast ) -from eth.rlp.transactions import ( - BaseTransaction, -) -from eth.utils.module_loading import ( - import_string, -) -from eth.vm.state import ( - BaseState, -) + +from eth_utils import import_string + +from eth.rlp.transactions import BaseTransaction +from eth.vm.state import BaseState def get_gas_estimator() -> Callable[[BaseState, BaseTransaction], int]: diff --git a/eth/rlp/headers.py b/eth/rlp/headers.py index a1be902d22..6382582c47 100644 --- a/eth/rlp/headers.py +++ b/eth/rlp/headers.py @@ -20,6 +20,10 @@ from eth_hash.auto import keccak +from eth_utils import ( + encode_hex, +) + from eth.constants import ( ZERO_ADDRESS, ZERO_HASH32, @@ -29,8 +33,8 @@ BLANK_ROOT_HASH, ) -from eth.utils.hexadecimal import ( - encode_hex, +from eth.vm.execution_context import ( + ExecutionContext, ) from .sedes import ( @@ -40,10 +44,6 @@ trie_root, ) -from eth.vm.execution_context import ( - ExecutionContext, -) - class MiningHeader(rlp.Serializable): fields = [ diff --git a/eth/utils/hexadecimal.py b/eth/utils/hexadecimal.py deleted file mode 100644 index 912ae4a67c..0000000000 --- a/eth/utils/hexadecimal.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import unicode_literals - -import codecs - - -def encode_hex(value: bytes) -> str: - return '0x' + codecs.decode(codecs.encode(value, 'hex'), 'utf8') # type: ignore - - -def decode_hex(value: str) -> bytes: - _, _, hex_part = value.rpartition('x') - return codecs.decode(hex_part, 'hex') # type: ignore diff --git a/eth/vm/computation.py b/eth/vm/computation.py index 86bdf912cc..7c9fc756df 100644 --- a/eth/vm/computation.py +++ b/eth/vm/computation.py @@ -9,7 +9,6 @@ Callable, cast, Dict, - Iterator, List, Tuple, Union, @@ -18,6 +17,9 @@ from eth_typing import ( Address, ) +from eth_utils import ( + encode_hex, +) from eth.constants import ( GAS_MEMORY, @@ -33,9 +35,6 @@ from eth.utils.datatypes import ( Configurable, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.utils.numeric import ( ceil32, ) diff --git a/eth/vm/forks/constantinople/storage.py b/eth/vm/forks/constantinople/storage.py index 61e96875e6..4fe55ce915 100644 --- a/eth/vm/forks/constantinople/storage.py +++ b/eth/vm/forks/constantinople/storage.py @@ -1,3 +1,7 @@ +from eth_utils import ( + encode_hex, +) + from eth.constants import ( UINT256 ) @@ -7,10 +11,6 @@ constants ) -from eth.utils.hexadecimal import ( - encode_hex, -) - def sstore_eip1283(computation: BaseComputation) -> None: slot, value = computation.stack_pop(num_items=2, type_hint=UINT256) diff --git a/eth/vm/forks/frontier/computation.py b/eth/vm/forks/frontier/computation.py index 08fdc618a4..bc2fa9014e 100644 --- a/eth/vm/forks/frontier/computation.py +++ b/eth/vm/forks/frontier/computation.py @@ -1,6 +1,9 @@ from eth import precompiles from eth_hash.auto import keccak +from eth_utils import ( + encode_hex, +) from eth.constants import ( GAS_CODEDEPOSIT, @@ -16,9 +19,6 @@ from eth.utils.address import ( force_bytes_to_address, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.vm.computation import ( BaseComputation, diff --git a/eth/vm/forks/frontier/state.py b/eth/vm/forks/frontier/state.py index 19a996df04..be29ceb322 100644 --- a/eth/vm/forks/frontier/state.py +++ b/eth/vm/forks/frontier/state.py @@ -2,6 +2,9 @@ from typing import Type # noqa: F401 from eth_hash.auto import keccak +from eth_utils import ( + encode_hex, +) from eth.constants import CREATE_CONTRACT_ADDRESS from eth.db.account import ( @@ -18,9 +21,6 @@ from eth.utils.address import ( generate_contract_address, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.vm.computation import ( BaseComputation, diff --git a/eth/vm/forks/homestead/computation.py b/eth/vm/forks/homestead/computation.py index ee745a7b9e..97697de9fc 100644 --- a/eth/vm/forks/homestead/computation.py +++ b/eth/vm/forks/homestead/computation.py @@ -4,7 +4,7 @@ from eth.exceptions import ( OutOfGas, ) -from eth.utils.hexadecimal import ( +from eth_utils import ( encode_hex, ) from eth.vm.computation import BaseComputation diff --git a/eth/vm/forks/spurious_dragon/computation.py b/eth/vm/forks/spurious_dragon/computation.py index a053b3bd74..ef189fcb15 100644 --- a/eth/vm/forks/spurious_dragon/computation.py +++ b/eth/vm/forks/spurious_dragon/computation.py @@ -1,12 +1,12 @@ from eth_hash.auto import keccak +from eth_utils import ( + encode_hex, +) from eth import constants from eth.exceptions import ( OutOfGas, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.vm.computation import BaseComputation from eth.vm.forks.homestead.computation import ( HomesteadComputation, diff --git a/eth/vm/forks/spurious_dragon/state.py b/eth/vm/forks/spurious_dragon/state.py index be0019c0b9..8bc01fd903 100644 --- a/eth/vm/forks/spurious_dragon/state.py +++ b/eth/vm/forks/spurious_dragon/state.py @@ -1,6 +1,6 @@ from eth.rlp.transactions import BaseTransaction -from eth.utils.hexadecimal import ( +from eth_utils import ( encode_hex, ) diff --git a/eth/vm/logic/storage.py b/eth/vm/logic/storage.py index 42609092be..899a7a7d9a 100644 --- a/eth/vm/logic/storage.py +++ b/eth/vm/logic/storage.py @@ -1,8 +1,7 @@ -from eth import constants - -from eth.utils.hexadecimal import ( +from eth_utils import ( encode_hex, ) +from eth import constants from eth.vm.computation import BaseComputation diff --git a/eth/vm/logic/system.py b/eth/vm/logic/system.py index 6c2cb7c14b..a6ad3aaad2 100644 --- a/eth/vm/logic/system.py +++ b/eth/vm/logic/system.py @@ -1,7 +1,9 @@ from eth_typing import ( Address, ) - +from eth_utils import ( + encode_hex, +) from eth import constants from eth.exceptions import ( Halt, @@ -14,9 +16,6 @@ generate_contract_address, generate_safe_contract_address, ) -from eth.utils.hexadecimal import ( - encode_hex, -) from eth.utils.numeric import ( ceil32, ) diff --git a/scripts/benchmark/utils/format.py b/scripts/benchmark/utils/format.py index fed23af02e..fd76f4c84d 100644 --- a/scripts/benchmark/utils/format.py +++ b/scripts/benchmark/utils/format.py @@ -1,7 +1,7 @@ -from eth.rlp.blocks import BaseBlock -from eth.utils.hexadecimal import ( +from eth_utils import ( encode_hex, ) +from eth.rlp.blocks import BaseBlock def format_block(block: BaseBlock) -> str: diff --git a/tests/core/hexadecimal-utils/test_encode_and_decode.py b/tests/core/hexadecimal-utils/test_encode_and_decode.py index eef3756f00..f2c42ba35b 100644 --- a/tests/core/hexadecimal-utils/test_encode_and_decode.py +++ b/tests/core/hexadecimal-utils/test_encode_and_decode.py @@ -2,16 +2,16 @@ import pytest +from eth_utils import ( + encode_hex, + decode_hex, +) + from hypothesis import ( given, strategies as st, ) -from eth.utils.hexadecimal import ( - encode_hex, - decode_hex, -) - @pytest.mark.parametrize( 'value,expected', diff --git a/tests/core/vm/test_modexp_precompile.py b/tests/core/vm/test_modexp_precompile.py index 3d8f32af65..387943b9ff 100644 --- a/tests/core/vm/test_modexp_precompile.py +++ b/tests/core/vm/test_modexp_precompile.py @@ -1,12 +1,13 @@ import pytest +from eth_utils import ( + decode_hex, +) + from eth.precompiles.modexp import ( _modexp, _compute_modexp_gas_fee, ) -from eth.utils.hexadecimal import ( - decode_hex, -) EIP198_VECTOR_A = decode_hex( diff --git a/tests/fillers/build_json.py b/tests/fillers/build_json.py index d92e0a08cd..9576d24dcd 100644 --- a/tests/fillers/build_json.py +++ b/tests/fillers/build_json.py @@ -3,6 +3,9 @@ from eth_hash.auto import keccak +from eth_utils import ( + encode_hex, +) from eth.tools.fixtures.helpers import ( get_test_name, ) @@ -13,10 +16,6 @@ filler_formatter, ) -from eth.utils.hexadecimal import ( - encode_hex, -) - PARENT_DIR = os.path.dirname(os.path.abspath(__file__)) OUTPUT_DIR = os.path.join(PARENT_DIR, "json")