diff --git a/Makefile b/Makefile index d309d0aa8..f8981d25b 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,11 @@ endif .PHONY: build test coverage clean -# 154615699 corresponds to release v0.1.7 of Kakarot SSJ. -KKRT_SSJ_RELEASE_ID = 154615699 +# 173874367 corresponds to release v0.1.12 of Kakarot SSJ. +KKRT_SSJ_RELEASE_ID = 173874367 # Kakarot SSJ artifacts for precompiles. KKRT_SSJ_BUILD_ARTIFACT_URL = $(shell curl -L https://api.github.com/repos/kkrt-labs/kakarot-ssj/releases/${KKRT_SSJ_RELEASE_ID} | jq -r '.assets[0].browser_download_url') -KATANA_VERSION = v1.0.0-alpha.11 +KATANA_VERSION = v1.0.0-alpha.12 ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) BUILD_DIR = build diff --git a/kakarot_scripts/utils/starknet.py b/kakarot_scripts/utils/starknet.py index fb326eed6..95cf7d864 100644 --- a/kakarot_scripts/utils/starknet.py +++ b/kakarot_scripts/utils/starknet.py @@ -32,7 +32,7 @@ from starknet_py.net.client_models import Call, DeclareTransactionResponse from starknet_py.net.full_node_client import _create_broadcasted_txn from starknet_py.net.models.transaction import DeclareV1 -from starknet_py.net.schemas.rpc import DeclareTransactionResponseSchema +from starknet_py.net.schemas.rpc.transactions import DeclareTransactionResponseSchema from starknet_py.net.signer.stark_curve_signer import KeyPair from starkware.starknet.public.abi import get_selector_from_name @@ -243,6 +243,12 @@ def get_deployments(): @cache def get_artifact(contract_name): + # Cairo 0 artifacts + artifacts = list(BUILD_DIR.glob(f"*{contract_name}*.json")) + if artifacts: + return Artifact(sierra=None, casm=artifacts[0]) + + # Cairo 1 artifacts artifacts = list(CAIRO_DIR.glob(f"**/*{contract_name}.*.json")) or list( BUILD_DIR_SSJ.glob(f"**/*{contract_name}.*.json") ) @@ -255,10 +261,7 @@ def get_artifact(contract_name): ) return Artifact(sierra=sierra, casm=casm) - artifacts = list(BUILD_DIR.glob(f"**/*{contract_name}*.json")) - if not artifacts: - raise FileNotFoundError(f"No artifact found for {contract_name}") - return Artifact(sierra=None, casm=artifacts[0]) + raise FileNotFoundError(f"No artifact found for {contract_name}") @cache diff --git a/lib/forge-std b/lib/forge-std new file mode 160000 index 000000000..066ff16c5 --- /dev/null +++ b/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 066ff16c5c03e6f931cd041fd366bc4be1fae82a diff --git a/poetry.lock b/poetry.lock index 60116a536..f686b83dd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2847,77 +2847,77 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "poseidon-py" -version = "0.1.4" +version = "0.1.5" description = "Python implementation of Poseidon hash" optional = false python-versions = ">=3.8" files = [ - {file = "poseidon_py-0.1.4-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:8c2c81636b8389168181425f214da0e75f0b58df89241719373fcbba45c7b061"}, - {file = "poseidon_py-0.1.4-cp310-cp310-macosx_13_0_universal2.whl", hash = "sha256:6103971eb4c4e6f6a8b8d6d83a1e722771dbc04b29e94da7c202bc904efd1aed"}, - {file = "poseidon_py-0.1.4-cp310-cp310-macosx_14_0_universal2.whl", hash = "sha256:f1d269ef1dfaec4fe41226158cd914e8f74b75e937428d2c3de6c7c0cad8ab74"}, - {file = "poseidon_py-0.1.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:195a3b8acb9a3cb27c8a822619663f25f075057471f392ea18098ed83e920e10"}, - {file = "poseidon_py-0.1.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ee3f2995b0023dec31dee06cc5d9c12f5aa1d0e8d7cca7fba7b005145c04afcc"}, - {file = "poseidon_py-0.1.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a08ce457a4a01a3f0c83a5556c21e2e95f86fd7ec594f73f72704c239a489b23"}, - {file = "poseidon_py-0.1.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:71423bc1a8e422a1c82a5a786a0c01b8a024a00fc7cba883e01e85410d5bf275"}, - {file = "poseidon_py-0.1.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:3c8c4e54a616451c3420cdce1a8e52b5ffcdc604f431a9c6a0f3cd50ef2e1292"}, - {file = "poseidon_py-0.1.4-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:1ab0d2d10cdb23be125a918e553bcc7cdd27c48c30339d8d8822757e918706b5"}, - {file = "poseidon_py-0.1.4-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:e57cbdf75398a4faf7b71b2c2b7462975e81047c3a592a2654e0d020aab184e4"}, - {file = "poseidon_py-0.1.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:64bff7984b02a79d4f6864a2d9276ad52d96a933483293bdf5eb2e1558e0994d"}, - {file = "poseidon_py-0.1.4-cp310-cp310-win32.whl", hash = "sha256:0b5fe9eb6e21a8478ea739d3316b28bf2e8de49dc2d2305768b2f14be04bc143"}, - {file = "poseidon_py-0.1.4-cp310-cp310-win_amd64.whl", hash = "sha256:fdabee5ffceb74836979a4497402dd0dd351ec387d3ecad5c627df8da8cf0f04"}, - {file = "poseidon_py-0.1.4-cp311-cp311-macosx_12_0_universal2.whl", hash = "sha256:c1b8778a8b51d980b6780daf3fb11357942d941465f55ebf9eb0702638396b61"}, - {file = "poseidon_py-0.1.4-cp311-cp311-macosx_13_0_universal2.whl", hash = "sha256:89694d6ebaee6086f1d3e6223707acaeb4e9b32c61faf20c6c2685baaeba6326"}, - {file = "poseidon_py-0.1.4-cp311-cp311-macosx_14_0_universal2.whl", hash = "sha256:7cc93c044a03d7067d37c79a697a81562ae5899bd0150bf496520d418a4a774e"}, - {file = "poseidon_py-0.1.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f36dc34704540f2a2bbe18e2f195bcd0fa504b93962bd72f535e37578f264385"}, - {file = "poseidon_py-0.1.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:24a3b643f7e071883686bcb8422558fc1cf485b61a26a028554d60713cdd9aea"}, - {file = "poseidon_py-0.1.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:12237601c95127c0cb8875e81c04f26720069aed544dfff499a473e86a63f14f"}, - {file = "poseidon_py-0.1.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b421fa3e01e0a072622dcc770635dd1aeb2d8a77d334d5af40ae54033587a1df"}, - {file = "poseidon_py-0.1.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:947164c40ef49b47e366b3b838edab9efb42e598a7f95483880e1b3b84536131"}, - {file = "poseidon_py-0.1.4-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:95724cc0f6708a097521f7193af20e62ee63b2927b9775bcbf42ed1ada0653ae"}, - {file = "poseidon_py-0.1.4-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:790a44a2858dc8bab9d80d9527a67232823c3fda2216cc4fb8e37775904b103b"}, - {file = "poseidon_py-0.1.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f658750b779ebd09b30c047d671e4e18e90cbc4ab7bb006dfb5c4468fd5b9f61"}, - {file = "poseidon_py-0.1.4-cp311-cp311-win32.whl", hash = "sha256:48e689782cefd5237fac1001df34c2750e707721d309d9811e0095d3139a47d2"}, - {file = "poseidon_py-0.1.4-cp311-cp311-win_amd64.whl", hash = "sha256:5ecc75a778740fff3d4a3bc374fa9fe6868c08091ac199c43ef7f1d9e40c737c"}, - {file = "poseidon_py-0.1.4-cp312-cp312-macosx_12_0_universal2.whl", hash = "sha256:0eef537ac31cbf195a170e696c9f5b6d2d13ce3a0da98f37cf03f0d855ae2be1"}, - {file = "poseidon_py-0.1.4-cp312-cp312-macosx_13_0_universal2.whl", hash = "sha256:446048c88e8ee97c569032171c7cb057b9c739d2985109c55eb234ce66cd2d16"}, - {file = "poseidon_py-0.1.4-cp312-cp312-macosx_14_0_universal2.whl", hash = "sha256:91c259f85cd1b3a5f2d450a481d90bdd4b911d05bd6bcc51fd290d2fd7d66613"}, - {file = "poseidon_py-0.1.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b53d6eaecac2c7a37a66f7a55a451fe5abed0e317ebb26022e9937b43a54f8c9"}, - {file = "poseidon_py-0.1.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8ac18854c6305d80f0ccb270b261eb278bbc21f055b43737a8b55726d4caee3a"}, - {file = "poseidon_py-0.1.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:53edc8142cca4fe56eb2e2451eb77165925e2d7df25186fd5ab5b7d813555381"}, - {file = "poseidon_py-0.1.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6880dc2461a2c7336abb7f4774971a053bc04169dbfce5e08feecefad4fd49c2"}, - {file = "poseidon_py-0.1.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:514bc3df634a4ca5621bc0ea60e253257f8cc7773e1d3701e5e8f36a35f4d0f3"}, - {file = "poseidon_py-0.1.4-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:76d7cdb3c4a744573627f8170f659236737218245d04a7ead00e74bfb48ab28a"}, - {file = "poseidon_py-0.1.4-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:8fa27f2797abdec641a26abb05fee82194ebb40fd4ded3fa385b8b143bef4d7f"}, - {file = "poseidon_py-0.1.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:53a78d0fcd1a7742f1d72ce9a2871790c0ae862dec62b18f58982c0ca07a3e79"}, - {file = "poseidon_py-0.1.4-cp312-cp312-win32.whl", hash = "sha256:1176e308c18ff878cc8763cb0dc03541d56775a75b8128f5da6d55ad041a6bd8"}, - {file = "poseidon_py-0.1.4-cp312-cp312-win_amd64.whl", hash = "sha256:9efac87f378ceb64c2b2bad5a2bf8678459ce7ae7947c12326effc4a700fe9e5"}, - {file = "poseidon_py-0.1.4-cp38-cp38-macosx_12_0_universal2.whl", hash = "sha256:d38726b1e330000a91fd01cce53c5ed6aaec030fa91f8c23d8a598eb630f6227"}, - {file = "poseidon_py-0.1.4-cp38-cp38-macosx_13_0_universal2.whl", hash = "sha256:026fd9b53c21e1ee9ca15c956e3650e15842f4e0f517580f7a645ac3c71b4b46"}, - {file = "poseidon_py-0.1.4-cp38-cp38-macosx_14_0_universal2.whl", hash = "sha256:f1940fae0aeb2aaa04abb71924c09b54cad845d273ec5a306c1ee27563efd3d3"}, - {file = "poseidon_py-0.1.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3021938f639c55d45584f8cb66d1d5a2bf50d98f2f536fa8ec9da63ff840631a"}, - {file = "poseidon_py-0.1.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fcb8f9060de484c44c015c667527183cdf96f1f8e70df3e0c3e10a60900f81a0"}, - {file = "poseidon_py-0.1.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:06fc95034cd5a2843a06f0bcc9772ed8785c0092fccdc0516fb8c260bb77bf49"}, - {file = "poseidon_py-0.1.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7064ea9b2e4f15761ffdd477cc034cef715c4e0c69724f448d525bd5fceefdc"}, - {file = "poseidon_py-0.1.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ec15d4fdbdefc976340a18d3fe7525f8957ecd7552fd011dbda890b037aef28d"}, - {file = "poseidon_py-0.1.4-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:be89d40c36d815e7668321e2faea01ec2db434ab266685d67e8872c781ad6013"}, - {file = "poseidon_py-0.1.4-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:cfcca7b463d247f423f420dff6b151cc6bf23771d86b637c5da3b14f08b5268b"}, - {file = "poseidon_py-0.1.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e7eae5e8036bbc4ea01a056aa2eb687fb5ca7d91adfc242fdc672391886063a9"}, - {file = "poseidon_py-0.1.4-cp38-cp38-win32.whl", hash = "sha256:96dbe49c2af157982f090dde7c66bc4490bfd16ec3d0ad709add40ba23c3dd71"}, - {file = "poseidon_py-0.1.4-cp38-cp38-win_amd64.whl", hash = "sha256:baa43eed066e6985da5045dc1f0a432f60838582bfbfefe630ce2e506ac18acc"}, - {file = "poseidon_py-0.1.4-cp39-cp39-macosx_12_0_universal2.whl", hash = "sha256:a3aaadec7f16739f7ec9084c19b344bc4d937689c00a22e371e7f02993ac9199"}, - {file = "poseidon_py-0.1.4-cp39-cp39-macosx_13_0_universal2.whl", hash = "sha256:dc812bd192be78b28a06124e847122969ecd7fe217c957a2f177f11225cb09e3"}, - {file = "poseidon_py-0.1.4-cp39-cp39-macosx_14_0_universal2.whl", hash = "sha256:3753cd12acde11192eb9e61e7308cc254e6323d24d6d9e55177d5b295cc3d2e6"}, - {file = "poseidon_py-0.1.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:08deb5310f5f7d1aeff3b1ac3ed01cfae95be64adf9b4e6e7ef990d50f7348f6"}, - {file = "poseidon_py-0.1.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2cf8582f721410764b2da734b79be93123a32fc6b2710e78b36685514a8c6713"}, - {file = "poseidon_py-0.1.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:abdc9f2580144887e3d10a63a00dcde7c9180ac7683fddf314581a32ecc70cba"}, - {file = "poseidon_py-0.1.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8b39d3faae6164157a1b2ef0c6e5ef5658a7f48df18c6c090998c566b8447603"}, - {file = "poseidon_py-0.1.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:841ddcc7d7be6fde7b8927bb6cd47fedd8e8f83b761c95ee7a686f1d794df6b8"}, - {file = "poseidon_py-0.1.4-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:f06638fe92366bc99a2badf0ec052b02e3b89d79cc2ef400864707701c3919a6"}, - {file = "poseidon_py-0.1.4-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:9c586a42871ddc1c9af22e15825f250152b961cf3a7f1144faed10589d1aa505"}, - {file = "poseidon_py-0.1.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4a0caf2fa878cc2b7f4781e7f2574c65231b422257addca64d146b34bc15a7ad"}, - {file = "poseidon_py-0.1.4-cp39-cp39-win32.whl", hash = "sha256:d14aa6c9d76279e46eb6fde66e3e2629e3e461069dd76644b65c5ebed69114c8"}, - {file = "poseidon_py-0.1.4-cp39-cp39-win_amd64.whl", hash = "sha256:e246d46d81bcd465b399c5d7663ef59b31fe0acd3966253cbb53e12508b41d80"}, - {file = "poseidon_py-0.1.4.tar.gz", hash = "sha256:416139d80931c85fd117cbc5b47d2eb1daf25e52acd77b6dd889c4820592a479"}, + {file = "poseidon_py-0.1.5-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:3a8b4cc09d28439764956c47a00e49aa36c23421f724b0ffbd2c62550325240e"}, + {file = "poseidon_py-0.1.5-cp310-cp310-macosx_13_0_universal2.whl", hash = "sha256:a7e611fe04d200eb782a0e7b6f8ee8e34da531a527f96685ff5f12117014fca8"}, + {file = "poseidon_py-0.1.5-cp310-cp310-macosx_14_0_universal2.whl", hash = "sha256:5070cb74a20c433c2a20e91e14f4a92a2f66b8001adaf15ed5febc941d5ea00f"}, + {file = "poseidon_py-0.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:15a6c334161ee8444fb908c0c2f9f2a4d14c6a6ace3397bd3b1ed7673244870b"}, + {file = "poseidon_py-0.1.5-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9a8899e5ea0ba5d1bd41cc54b337780030d9f68859e94bb124d76a751b124a63"}, + {file = "poseidon_py-0.1.5-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:02c1206449d327ffd8eadca80d7c122d8adfaa529639cf5e5a186fa81cd19977"}, + {file = "poseidon_py-0.1.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:755ea18163c156702160c5ede046903c7c2350de806ed92da80e7bae16f61e23"}, + {file = "poseidon_py-0.1.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:ec16f0c8f74d9de6b2083006e4f408ea77c1b68375a2670a43c04754fff92f05"}, + {file = "poseidon_py-0.1.5-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:67d31aebd0e00b1f27e27642e086b04951fa2696417a2ef8b5e11f1d86d097f2"}, + {file = "poseidon_py-0.1.5-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:c47f68fbe13b9e68a0f0af005b329639f75edcb7c44def9030c0fdf37602ca3e"}, + {file = "poseidon_py-0.1.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:14ea566f3e79e59c5d30dfca1f8130953f95cc65aa259424a9c2d37906c63fa5"}, + {file = "poseidon_py-0.1.5-cp310-cp310-win32.whl", hash = "sha256:618c6af537bf0a2efdaacd5a9d511615d50ee21c31f098b1247f24a5b3542893"}, + {file = "poseidon_py-0.1.5-cp310-cp310-win_amd64.whl", hash = "sha256:c6778847c2f6a6a22c8898425adc960ef284d18925780ccd56f53821a66acf4b"}, + {file = "poseidon_py-0.1.5-cp311-cp311-macosx_12_0_universal2.whl", hash = "sha256:af55e19a30e4c75a63c353e1f616d04e188bf901ddce1df3e8bc4aadaf6769e8"}, + {file = "poseidon_py-0.1.5-cp311-cp311-macosx_13_0_universal2.whl", hash = "sha256:c1c68d5db997356941433f95808885395f6c2f4132c8a80d6e189881a553d7df"}, + {file = "poseidon_py-0.1.5-cp311-cp311-macosx_14_0_universal2.whl", hash = "sha256:eead4b7b489e66747e6ff8bb73ef0ace3ae8a15e0622ff0b9415e0cf9d2e6c1c"}, + {file = "poseidon_py-0.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2efb15008ed0dad41777ffe427432107140313c77c764965612d4e4a6a426925"}, + {file = "poseidon_py-0.1.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b218cd61003175791cd1d168559b4aa12cbe9fba2b630e34431d653227c6da05"}, + {file = "poseidon_py-0.1.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:57e67d2dfabab2085e8f30353c4c19eb53b02cd858ca138cb3aa32a03c34e673"}, + {file = "poseidon_py-0.1.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fcde98980879d4d145f25c51c06284564a255cbbd6726a1874712474a8b04137"}, + {file = "poseidon_py-0.1.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:aaa220a9a28246f3b76353697322b6588052d38e7ecaf18337eecaa6cfa7e6d2"}, + {file = "poseidon_py-0.1.5-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:b1750a301b426e3f6ca805672752860e81cf4f6cc2b3e6cd6816d4da78f2dd46"}, + {file = "poseidon_py-0.1.5-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:1ffe57ffacab103c37606b70eda7dd97c857b3d462a7926038123b05be5ba457"}, + {file = "poseidon_py-0.1.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4faeb29252770e10a08c4d6aa2a095c171668640f21d5721441f5015ab1dbc4c"}, + {file = "poseidon_py-0.1.5-cp311-cp311-win32.whl", hash = "sha256:df84226f66078d1aca460db3590b65400fcc1aa593c205baba96c0d25b80b39d"}, + {file = "poseidon_py-0.1.5-cp311-cp311-win_amd64.whl", hash = "sha256:b520591c30af7f0be29ea88404b931eecee8babe0d734e7446aed3e164f8ef83"}, + {file = "poseidon_py-0.1.5-cp312-cp312-macosx_12_0_universal2.whl", hash = "sha256:4f2d28448e5b0bea2622ca23667de8a27b1a6056068181c5a41e78be65f0d980"}, + {file = "poseidon_py-0.1.5-cp312-cp312-macosx_13_0_universal2.whl", hash = "sha256:311291b8caa39f7ebeb3c837f239a46e8214d30722f9e01ded62d79c0b061b8a"}, + {file = "poseidon_py-0.1.5-cp312-cp312-macosx_14_0_universal2.whl", hash = "sha256:06c07b1e2ad273d50b243121b1e94b28bf893bd4942fe1808f98d33cd2de2790"}, + {file = "poseidon_py-0.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:55501c7c881eaf406568db70a16c56c5f92c325eda65f9f741e75ec5cced7ad6"}, + {file = "poseidon_py-0.1.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cbd1ed7d8567e057cc181542aff18dc0b11cf2c67593243830cc2fedb73b112f"}, + {file = "poseidon_py-0.1.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19ae4ddd2b1d05d1ed2e3b38e58c3ac5940a46001b080d5112ce346be4d09681"}, + {file = "poseidon_py-0.1.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1ba4956c6b886457d43e43a4465aed18f9bd1f23e7bd2c5388c9a74ae8f0842"}, + {file = "poseidon_py-0.1.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3e4e76745181fb50c77813b1c7c845f92f2d3b4620bf784f43e01be5713e1c14"}, + {file = "poseidon_py-0.1.5-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:28c0f134533b827eb0bc883347ec38dca2a5559fb277aeeb4ac9cce7f6d30a16"}, + {file = "poseidon_py-0.1.5-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:7bc3995f771b7d98f05b200c2c19c1ae6238bb9f625733042a6df9633219e762"}, + {file = "poseidon_py-0.1.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:f09faa440ff5f10099a3e667bb5f8781d27a7bc719f45119d08d12574a4d9281"}, + {file = "poseidon_py-0.1.5-cp312-cp312-win32.whl", hash = "sha256:4a7fad5110fc64125ef8fbbdc1d49798159b568e239dbef18ada8fd87eed1fc9"}, + {file = "poseidon_py-0.1.5-cp312-cp312-win_amd64.whl", hash = "sha256:0261221c68c36fd11cfcb91e5074953bfbe7a33031d806d3ab2dc5c7c1e70a2b"}, + {file = "poseidon_py-0.1.5-cp38-cp38-macosx_12_0_universal2.whl", hash = "sha256:ed73929274da455b214bc32e548888094ab42a02af683ccdad006a204299cd06"}, + {file = "poseidon_py-0.1.5-cp38-cp38-macosx_13_0_universal2.whl", hash = "sha256:5037c878654a5546e154f28a3f7a85fbfae3e6aaac6d02552fa233e382aa0b73"}, + {file = "poseidon_py-0.1.5-cp38-cp38-macosx_14_0_universal2.whl", hash = "sha256:38ede222b125a2d09e8f76c59289b1cd0d06c135428ca81f567fc5ae17216e03"}, + {file = "poseidon_py-0.1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:68ea474600e445946f96bebadab480c12b11828d9942dbcc534707e0fceb0e6b"}, + {file = "poseidon_py-0.1.5-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e7c8d4a37474d2481c6e5f7016102cd7a3dc85f6c3a7b687ad1982e307a1f812"}, + {file = "poseidon_py-0.1.5-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:76d2a99a976126dc5632905a4e971b1f4477366f88757228b04de10b624b307e"}, + {file = "poseidon_py-0.1.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b504ee79a14e7456e5a7462792afe32d696fdb33819cdf447f9d2d3faa410690"}, + {file = "poseidon_py-0.1.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:13529af9d43bb3a200819b053a4f8b283b60b9f60dbdcc15343d3a41e0db4256"}, + {file = "poseidon_py-0.1.5-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:29ed2a89d0f5417d27130503f6c36e4df4649fdc947ff0b813368e914d562f83"}, + {file = "poseidon_py-0.1.5-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:6cad01961590f198939e46554e50c506f908f7fd680407792501cc337a33cf05"}, + {file = "poseidon_py-0.1.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:c7d3ae493cb4b325dd4d394159f7b76a316f5da74682772060498985d2f838ad"}, + {file = "poseidon_py-0.1.5-cp38-cp38-win32.whl", hash = "sha256:95cbb69541bc1fba2497cb8709f4ab96fec847b2c261129bd9b3bec1ce832bf2"}, + {file = "poseidon_py-0.1.5-cp38-cp38-win_amd64.whl", hash = "sha256:4727b0d32fc80db43a2b6cc3a14a2250ae8c6cb8e30d342f84e68c72ae053032"}, + {file = "poseidon_py-0.1.5-cp39-cp39-macosx_12_0_universal2.whl", hash = "sha256:41bb6269dcb1ac1b57bbaf5d90167ef745541ce4199b0b94ee5a05c0f5c8b189"}, + {file = "poseidon_py-0.1.5-cp39-cp39-macosx_13_0_universal2.whl", hash = "sha256:8c98c7a810adc88695e83dbab94075deec8f2503fe29fc838f680b9eab57e837"}, + {file = "poseidon_py-0.1.5-cp39-cp39-macosx_14_0_universal2.whl", hash = "sha256:b296fc5f2e9fedf03ed8d112b5bc517654ed4d265e60e9029607b6221233d466"}, + {file = "poseidon_py-0.1.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cfc14ee08cd547e8d118a9d8e23455ae114df329a6f7822b2d32e2c8238a04a9"}, + {file = "poseidon_py-0.1.5-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6cc58d3a0f361739259f2140bbe2f85b6fcb9373664d5b3a504af79a687d9d45"}, + {file = "poseidon_py-0.1.5-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b878efb1e76c0287f0ca8f583dca74b8c3cc124dab972832af4bef6e017740a2"}, + {file = "poseidon_py-0.1.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d28bb34be71a105c89d7e4c2071afc568ed5851390fd70b009b50fe5e466ddd1"}, + {file = "poseidon_py-0.1.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:f7342a365ab53ad9524b2e1c6192dfbee6cd10505af4ed5381fe0c0397ccb62a"}, + {file = "poseidon_py-0.1.5-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:3b5d9876c7f3cdbbac1a6ab00e0b84c675a67ae23ccc6fd7d47922660797d1e0"}, + {file = "poseidon_py-0.1.5-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:8582bd1bba9b6b16266dd50eea3ecb4ade6fac48f71d91bf11fc86697f80466b"}, + {file = "poseidon_py-0.1.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:70fb652a80fad42278b6a8d847938785fba773ccbb3ba5be012c66e68b3195af"}, + {file = "poseidon_py-0.1.5-cp39-cp39-win32.whl", hash = "sha256:ed7acb78ef78ab18f0df3bdf5fa75c27dfe8cc66c3892d9a8363bc2ede911f79"}, + {file = "poseidon_py-0.1.5-cp39-cp39-win_amd64.whl", hash = "sha256:c1daece917148c841dcdbade3dea7fdabb6ca45d2453d7f36984bb20e17ed18c"}, + {file = "poseidon_py-0.1.5.tar.gz", hash = "sha256:acfa0f79176505226dc79c27e1a6a55e1184753920463826101a2f1c2dd2fbf6"}, ] [[package]] @@ -4227,30 +4227,35 @@ tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"] [[package]] name = "starknet-py" -version = "0.23.0" +version = "0.24.1" description = "A python SDK for Starknet" optional = false -python-versions = "<3.13,>=3.8" -files = [ - {file = "starknet_py-0.23.0.tar.gz", hash = "sha256:3dbab1a608e4bc67e646f3d096bcf346383da26472cfdb60409b5478c3432e39"}, -] +python-versions = ">=3.8, <3.13" +files = [] +develop = false [package.dependencies] -aiohttp = ">=3.8.4,<4.0.0" -asgiref = ">=3.4.1,<4.0.0" +aiohttp = "^3.8.4" +asgiref = "^3.4.1" crypto-cpp-py = "1.4.4" -eth-keyfile = ">=0.8.1,<0.9.0" -lark = ">=1.1.5,<2.0.0" -marshmallow = ">=3.15.0,<4.0.0" +eth-keyfile = "^0.8.1" +lark = "^1.1.5" +marshmallow = "^3.15.0" marshmallow-dataclass = "<8.8.0" marshmallow-oneofschema = "3.1.1" -poseidon-py = "0.1.4" -pycryptodome = ">=3.17,<4.0" -typing-extensions = ">=4.3.0,<5.0.0" +poseidon-py = "0.1.5" +pycryptodome = "^3.17" +typing-extensions = "^4.3.0" [package.extras] docs = ["enum-tools[sphinx] (==0.12.0)", "furo (>=2024.5.6,<2025.0.0)", "sphinx (>=4.3.1,<8.0.0)"] +[package.source] +type = "git" +url = "https://github.com/kkrt-labs/starknet.py" +reference = "cc272228b66c84079b01034f0d205aae8e7bc113" +resolved_reference = "cc272228b66c84079b01034f0d205aae8e7bc113" + [[package]] name = "sympy" version = "1.11.1" diff --git a/solidity_contracts/src/EvmPrecompiles/EvmPrecompiles.sol b/solidity_contracts/src/EvmPrecompiles/EvmPrecompiles.sol new file mode 100644 index 000000000..e17f457a4 --- /dev/null +++ b/solidity_contracts/src/EvmPrecompiles/EvmPrecompiles.sol @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: AGPL-3.0-only +pragma solidity >=0.8.0; + +/// @title EVM Precompiles Integration +/// @notice Contract for integration testing of EVM precompiles. +/// @dev Implements functions for ECADD and ECMUL precompiles. +contract EvmPrecompiles { + /// @dev Address of the ECADD precompile + address private constant ECADD_PRECOMPILE = address(0x06); + /// @dev Address of the ECMUL precompile + address private constant ECMUL_PRECOMPILE = address(0x07); + + /// @dev Gas cost for ECADD operation + uint256 private constant ECADD_GAS = 150; + /// @dev Gas cost for ECMUL operation + uint256 private constant ECMUL_GAS = 6000; + + /*////////////////////////////////////////////////////////////// + CONSTRUCTOR + //////////////////////////////////////////////////////////////*/ + constructor() {} + + /*////////////////////////////////////////////////////////////// + FUNCTIONS FOR PRECOMPILES + //////////////////////////////////////////////////////////////*/ + /// @notice Performs elliptic curve addition + /// @param x1 X coordinate of the first point + /// @param y1 Y coordinate of the first point + /// @param x2 X coordinate of the second point + /// @param y2 Y coordinate of the second point + /// @return x X coordinate of the result point + /// @return y Y coordinate of the result point + function ecAdd(uint256 x1, uint256 y1, uint256 x2, uint256 y2) public view returns (uint256 x, uint256 y) { + bytes memory input = abi.encodePacked(x1, y1, x2, y2); + (bool success, bytes memory result) = ECADD_PRECOMPILE.staticcall{gas: ECADD_GAS}(input); + require(success, "ECADD precompile call failed"); + return abi.decode(result, (uint256, uint256)); + } + + /// @notice Performs elliptic curve scalar multiplication + /// @param x1 X coordinate of the point + /// @param y1 Y coordinate of the point + /// @param s Scalar for multiplication + /// @return x X coordinate of the result point + /// @return y Y coordinate of the result point + function ecMul(uint256 x1, uint256 y1, uint256 s) public view returns (uint256 x, uint256 y) { + bytes memory input = abi.encodePacked(x1, y1, s); + (bool success, bytes memory result) = ECMUL_PRECOMPILE.staticcall{gas: ECMUL_GAS}(input); + require(success, "ECMUL precompile call failed"); + return abi.decode(result, (uint256, uint256)); + } +} diff --git a/src/kakarot/precompiles/precompiles.cairo b/src/kakarot/precompiles/precompiles.cairo index 42c7191ec..d72fc1a81 100644 --- a/src/kakarot/precompiles/precompiles.cairo +++ b/src/kakarot/precompiles/precompiles.cairo @@ -116,9 +116,9 @@ namespace Precompiles { ret; call external_precompile; // 0x5 ret; - call not_implemented_precompile; // 0x6 + call external_precompile; // 0x6 ret; - call not_implemented_precompile; // 0x7 + call external_precompile; // 0x7 ret; call not_implemented_precompile; // 0x8 ret; diff --git a/tests/end_to_end/EvmPrecompiles/test_evm_precompiles.py b/tests/end_to_end/EvmPrecompiles/test_evm_precompiles.py new file mode 100644 index 000000000..76945dd23 --- /dev/null +++ b/tests/end_to_end/EvmPrecompiles/test_evm_precompiles.py @@ -0,0 +1,95 @@ +import pytest +import pytest_asyncio +from ethereum.base_types import U256, Uint +from ethereum.crypto.alt_bn128 import ALT_BN128_PRIME, BNF, BNP +from ethereum.exceptions import OutOfGasError + +from kakarot_scripts.utils.kakarot import deploy + + +@pytest_asyncio.fixture(scope="package") +async def evm_precompiles(owner): + return await deploy( + "EvmPrecompiles", + "EvmPrecompiles", + caller_eoa=owner.starknet_contract, + ) + + +def ref_alt_bn128_add(x0, y0, x1, y1): + x0_value = U256.from_signed(x0) + y0_value = U256.from_signed(y0) + x1_value = U256.from_signed(x1) + y1_value = U256.from_signed(y1) + + for i in (x0_value, y0_value, x1_value, y1_value): + if i >= ALT_BN128_PRIME: + raise OutOfGasError + + try: + p0 = BNP(BNF(x0_value), BNF(y0_value)) + p1 = BNP(BNF(x1_value), BNF(y1_value)) + except ValueError: + raise OutOfGasError from None + + p = p0 + p1 + + x_bytes = p.x.to_be_bytes32() + y_bytes = p.y.to_be_bytes32() + + x = Uint(x_bytes) + y = Uint(y_bytes) + + return x, y + + +def ref_alt_bn128_mul(x0, y0, s): + x0_value = U256.from_signed(x0) + y0_value = U256.from_signed(y0) + U256.from_signed(s) + + for i in (x0_value, y0_value): + if i >= ALT_BN128_PRIME: + raise OutOfGasError + + try: + p0 = BNP(BNF(x0_value), BNF(y0_value)) + except ValueError: + raise OutOfGasError from None + + p = p0.mul_by(s) + + x_bytes = p.x.to_be_bytes32() + y_bytes = p.y.to_be_bytes32() + + x = Uint(x_bytes) + y = Uint(y_bytes) + + return x, y + + +@pytest.mark.asyncio(scope="package") +@pytest.mark.EvmPrecompiles +@pytest.mark.xfail(reason="Katana doesn't support new builtins") +class TestEvmPrecompiles: + class TestEcAdd: + async def test_should_return_ec_add_point_at_infinity(self, evm_precompiles): + result = await evm_precompiles.ecAdd(0, 0, 0, 0) + expected = ref_alt_bn128_add(0, 0, 0, 0) + assert result == expected + + async def test_should_return_ec_add_with_coordinates(self, evm_precompiles): + result = await evm_precompiles.ecAdd(1, 2, 1, 2) + expected = ref_alt_bn128_add(1, 2, 1, 2) + assert result == expected + + class TestEcMul: + async def test_should_return_ec_mul_with_coordinates(self, evm_precompiles): + result = await evm_precompiles.ecMul(1, 2, 2) + expected = ref_alt_bn128_mul(1, 2, 2) + assert result == expected + + async def test_should_return_ec_mul_point_at_infinity(self, evm_precompiles): + result = await evm_precompiles.ecMul(0, 0, 0) + expected = ref_alt_bn128_mul(0, 0, 0) + assert result == expected diff --git a/tests/src/kakarot/precompiles/test_ec_add.cairo b/tests/src/kakarot/precompiles/test_ec_add.cairo deleted file mode 100644 index 8d756ec82..000000000 --- a/tests/src/kakarot/precompiles/test_ec_add.cairo +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-License-Identifier: MIT - -%lang starknet - -// Starkware dependencies -from starkware.cairo.common.cairo_builtins import HashBuiltin, BitwiseBuiltin -from starkware.cairo.common.cairo_secp.bigint import BigInt3, bigint_to_uint256, uint256_to_bigint -from starkware.cairo.common.uint256 import Uint256, assert_uint256_eq -from starkware.cairo.common.math import split_felt -from starkware.cairo.common.memcpy import memcpy -from starkware.cairo.common.alloc import alloc - -// Local dependencies -from utils.utils import Helpers -from utils.alt_bn128.alt_bn128_g1 import ALT_BN128, G1Point -from kakarot.precompiles.ecadd import PrecompileEcAdd -from kakarot.model import model -from kakarot.memory import Memory -from kakarot.constants import Constants -from kakarot.stack import Stack -from kakarot.evm import EVM -from kakarot.instructions.memory_operations import MemoryOperations -from kakarot.instructions.system_operations import SystemOperations, CallHelper, CreateHelper -from tests.utils.helpers import TestHelpers - -const G1POINT_BYTES_LEN = 32; - -func test__ecadd_impl{ - syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr, bitwise_ptr: BitwiseBuiltin* -}() { - // Given - alloc_locals; - local calldata_len: felt; - let (calldata: felt*) = alloc(); - %{ - ids.calldata_len = len(program_input["calldata"]); - segments.write_arg(ids.calldata, program_input["calldata"]); - %} - - let x0: BigInt3 = Helpers.bytes32_to_bigint(calldata); - let y0: BigInt3 = Helpers.bytes32_to_bigint(calldata + G1POINT_BYTES_LEN); - let x1: BigInt3 = Helpers.bytes32_to_bigint(calldata + G1POINT_BYTES_LEN * 2); - let y1: BigInt3 = Helpers.bytes32_to_bigint(calldata + G1POINT_BYTES_LEN * 3); - - // When - let point0: G1Point = G1Point(x0, y0); - let point1: G1Point = G1Point(x1, y1); - let (expected_point: G1Point) = ALT_BN128.ec_add(point0, point1); - let (bytes_expected_x_len, bytes_expected_result: felt*) = Helpers.bigint_to_bytes_array( - expected_point.x - ); - let (bytes_expected_y_len, bytes_expected_y: felt*) = Helpers.bigint_to_bytes_array( - expected_point.y - ); - memcpy(bytes_expected_result + bytes_expected_x_len, bytes_expected_y, bytes_expected_y_len); - let (output_len, output: felt*, gas_used, reverted) = PrecompileEcAdd.run( - PrecompileEcAdd.PRECOMPILE_ADDRESS, calldata_len, calldata - ); - - // Then - TestHelpers.assert_array_equal( - array_0_len=bytes_expected_x_len + bytes_expected_y_len, - array_0=bytes_expected_result, - array_1_len=output_len, - array_1=output, - ); - - return (); -} diff --git a/tests/src/kakarot/precompiles/test_ec_add.py b/tests/src/kakarot/precompiles/test_ec_add.py deleted file mode 100644 index 9c1437925..000000000 --- a/tests/src/kakarot/precompiles/test_ec_add.py +++ /dev/null @@ -1,11 +0,0 @@ -import hypothesis.strategies as st -import pytest -from hypothesis import given, settings - - -@pytest.mark.EC_ADD -class TestEcAdd: - @given(calldata=st.binary(min_size=128, max_size=128)) - @settings(max_examples=5) - def test_ecadd(self, cairo_run, calldata): - cairo_run("test__ecadd_impl", calldata=list(calldata)) diff --git a/tests/src/kakarot/precompiles/test_ec_mul.py b/tests/src/kakarot/precompiles/test_ec_mul.py deleted file mode 100644 index b9db12788..000000000 --- a/tests/src/kakarot/precompiles/test_ec_mul.py +++ /dev/null @@ -1,8 +0,0 @@ -import pytest - - -@pytest.mark.EC_MUL -class TestEcMul: - @pytest.mark.slow - def test_ec_mul(self, cairo_run): - cairo_run("test__ecmul_impl") diff --git a/tests/src/kakarot/precompiles/test_ec_recover.cairo b/tests/src/kakarot/precompiles/test_ec_recover.cairo deleted file mode 100644 index 8790ddb01..000000000 --- a/tests/src/kakarot/precompiles/test_ec_recover.cairo +++ /dev/null @@ -1,26 +0,0 @@ -%lang starknet - -from starkware.cairo.common.alloc import alloc -from starkware.cairo.common.cairo_builtins import HashBuiltin, BitwiseBuiltin -from starkware.cairo.common.math import unsigned_div_rem, assert_not_zero -from starkware.cairo.common.memset import memset -from starkware.cairo.common.memcpy import memcpy - -from kakarot.precompiles.ec_recover import PrecompileEcRecover -from utils.utils import Helpers - -func test__ec_recover{ - syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr, bitwise_ptr: BitwiseBuiltin* -}() -> (output: felt*) { - alloc_locals; - let (local input) = alloc(); - tempvar input_len: felt; - %{ - ids.input_len = len(program_input["input"]); - segments.write_arg(ids.input, program_input["input"]) - %} - let (output_len: felt, output: felt*, gas_used: felt, reverted: felt) = PrecompileEcRecover.run( - PrecompileEcRecover.PRECOMPILE_ADDRESS, input_len, input - ); - return (output=output); -}