diff --git a/eth/precompiles/blake2.py b/eth/precompiles/blake2.py index cea66d1e83..22c9a9accd 100644 --- a/eth/precompiles/blake2.py +++ b/eth/precompiles/blake2.py @@ -1,4 +1,3 @@ -import blake2b from eth_utils import ( ValidationError, ) @@ -11,6 +10,11 @@ BaseComputation, ) +try: + from blake2b import compress as blake2b_compress +except ImportError: + from eth._utils.blake2.compression import blake2b_compress + GAS_COST_PER_ROUND = 1 @@ -25,5 +29,5 @@ def blake2b_fcompress(computation: BaseComputation) -> BaseComputation: computation.consume_gas(gas_cost, reason=f"Blake2b Compress Precompile w/ {num_rounds} rounds") - computation.output = blake2b.compress(*parameters) + computation.output = blake2b_compress(*parameters) return computation diff --git a/setup.py b/setup.py index 14dcc2dc6e..5a9101ec4e 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ deps = { 'eth': [ - "blake2b-py>=0.1.4,<0.2", "cached-property>=1.5.1,<2", "eth-bloom>=1.0.3,<2.0.0", "eth-keys>=0.2.1,<0.4.0", @@ -23,6 +22,7 @@ # Installing these libraries may make the evm perform better than # using the default fallbacks though. 'eth-extra': [ + "blake2b-py>=0.1.4,<0.2", "coincurve>=13.0.0,<14.0.0", "eth-hash[pysha3];implementation_name=='cpython'", "eth-hash[pycryptodome];implementation_name=='pypy'", @@ -77,7 +77,6 @@ deps['dev'] = ( deps['dev'] + deps['eth'] + - deps['eth-extra'] + deps['test'] + deps['doc'] + deps['lint']