From fc3207cfcdcf2637b9c0bfb423753046f7b05133 Mon Sep 17 00:00:00 2001 From: Just some guy <3859395+fubuloubu@users.noreply.github.com> Date: Wed, 21 Jul 2021 13:17:09 -0400 Subject: [PATCH 1/4] deps: remove `eth-extra` from dev depenednecies (must install separate) --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 14dcc2dc6e..fab997581d 100644 --- a/setup.py +++ b/setup.py @@ -77,7 +77,6 @@ deps['dev'] = ( deps['dev'] + deps['eth'] + - deps['eth-extra'] + deps['test'] + deps['doc'] + deps['lint'] From 7f716df9d6a23a06960cdf52ca6e710ab1690bb6 Mon Sep 17 00:00:00 2001 From: Just some guy <3859395+fubuloubu@users.noreply.github.com> Date: Wed, 21 Jul 2021 13:17:36 -0400 Subject: [PATCH 2/4] refactor: move `blake2b-py` to optional deps for performance --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fab997581d..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'", From d124966914cfdeb04a453db78d220e141ba8ea22 Mon Sep 17 00:00:00 2001 From: Just some guy <3859395+fubuloubu@users.noreply.github.com> Date: Wed, 21 Jul 2021 13:28:54 -0400 Subject: [PATCH 3/4] fix: use native blake2b compression function IFF blake2b-py not install --- eth/precompiles/blake2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eth/precompiles/blake2.py b/eth/precompiles/blake2.py index cea66d1e83..133dcc3298 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 ModuleNotFoundError: + 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 From 1d8d79ed07e0e08c1c5727418ac054601357c08f Mon Sep 17 00:00:00 2001 From: Just some guy <3859395+fubuloubu@users.noreply.github.com> Date: Thu, 29 Jul 2021 23:58:24 -0400 Subject: [PATCH 4/4] refactor: use ImportError instead of ModuleNotFoundError --- eth/precompiles/blake2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/precompiles/blake2.py b/eth/precompiles/blake2.py index 133dcc3298..22c9a9accd 100644 --- a/eth/precompiles/blake2.py +++ b/eth/precompiles/blake2.py @@ -12,7 +12,7 @@ try: from blake2b import compress as blake2b_compress -except ModuleNotFoundError: +except ImportError: from eth._utils.blake2.compression import blake2b_compress GAS_COST_PER_ROUND = 1