Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Patch pedersen hash with cpp native implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
THenry14 committed May 27, 2022
1 parent b4aa5bb commit 500427e
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
56 changes: 55 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cairo-lang = "0.8.2.1"
dill = "~0.3.4"
meinheld = "~1.0.2"
Werkzeug = "~2.0.3"
crypto-cpp-py = "^1.0.3"

[tool.poetry.dev-dependencies]
pylint = "~2.12.2"
Expand Down
18 changes: 18 additions & 0 deletions starknet_devnet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
"""
Contains the server implementation and its utility classes and functions.
"""
import sys
from starkware.crypto.signature.fast_pedersen_hash import pedersen_hash
from crypto_cpp_py.cpp_bindings import cpp_hash


__version__ = "0.2.2"


def patched_pedersen_hash(x: int, y: int) -> int:
return cpp_hash(x, y)


# This is a monkey-patch to improve the performance of the devnet
# We are using c++ code for calculating the pedersen hashes
# instead of python implementation from cairo-lang package
setattr(
sys.modules["starkware.crypto.signature.fast_pedersen_hash"],
"pedersen_hash",
patched_pedersen_hash,
)
2 changes: 1 addition & 1 deletion starknet_devnet/blueprints/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from starknet_devnet.state import state
from .shared import validate_transaction

gateway = Blueprint("gateay", __name__, url_prefix="/gateway")
gateway = Blueprint("gateway", __name__, url_prefix="/gateway")

@gateway.route("/is_alive", methods=["GET"])
def is_alive():
Expand Down

0 comments on commit 500427e

Please sign in to comment.