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

Commit

Permalink
Add monkey patching of ContractClass.__deepcopy__ with simpler_copy (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Solpatium authored Oct 5, 2022
1 parent cf4d7d7 commit 38c3529
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ poetry run pytest test/<TEST_FILE> # for a single file
poetry run pytest test/<TEST_FILE>::<TEST_CASE> # for a single test case
```

In case of problems with `test_postman` test on Mac please see https://stackoverflow.com/a/52230415.

### Development - Check versioning consistency

```
Expand Down
14 changes: 14 additions & 0 deletions starknet_devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
Contains the server implementation and its utility classes and functions.
"""
import sys
from copy import copy
from starkware.crypto.signature.fast_pedersen_hash import pedersen_hash
from starkware.starknet.services.api.contract_class import ContractClass
from crypto_cpp_py.cpp_bindings import cpp_hash


__version__ = "0.3.2"



def patched_pedersen_hash(left: int, right: int) -> int:
"""
Pedersen hash function written in c++
Expand All @@ -24,3 +27,14 @@ def patched_pedersen_hash(left: int, right: int) -> int:
"pedersen_hash",
patched_pedersen_hash,
)


# Deep copy of a ContractClass takes a lot of time, but it should never be mutated.
def simpler_copy(self, memo): # pylint: disable=unused-argument
"""
A dummy implementation of ContractClass.__deepcopy__
"""
return copy(self)


setattr(ContractClass, "__deepcopy__", simpler_copy)

0 comments on commit 38c3529

Please sign in to comment.