Skip to content

fix: make blake2b optional #2012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions eth/precompiles/blake2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import blake2b
from eth_utils import (
ValidationError,
)
Expand All @@ -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


Expand All @@ -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
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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'",
Expand Down Expand Up @@ -77,7 +77,6 @@
deps['dev'] = (
deps['dev'] +
deps['eth'] +
deps['eth-extra'] +
deps['test'] +
deps['doc'] +
deps['lint']
Expand Down