Skip to content

Commit 8e70cea

Browse files
committed
fix: use native blake2b compression function IFF blake2b-py not install
1 parent f7f6295 commit 8e70cea

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

eth/precompiles/blake2.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import blake2b
21
from eth_utils import (
32
ValidationError,
43
)
@@ -11,6 +10,11 @@
1110
BaseComputation,
1211
)
1312

13+
try:
14+
from blake2b import compress as blake2b_compress
15+
except ModuleNotFoundError:
16+
from eth._utils.blake2.compression import blake2b_compress
17+
1418
GAS_COST_PER_ROUND = 1
1519

1620

@@ -25,5 +29,5 @@ def blake2b_fcompress(computation: BaseComputation) -> BaseComputation:
2529

2630
computation.consume_gas(gas_cost, reason=f"Blake2b Compress Precompile w/ {num_rounds} rounds")
2731

28-
computation.output = blake2b.compress(*parameters)
32+
computation.output = blake2b_compress(*parameters)
2933
return computation

0 commit comments

Comments
 (0)