diff --git a/.github/workflows/test-zkvm-jolt.yml b/.github/workflows/test-zkvm-jolt.yml index 6b8aa7c5..8a6476bf 100644 --- a/.github/workflows/test-zkvm-jolt.yml +++ b/.github/workflows/test-zkvm-jolt.yml @@ -16,3 +16,4 @@ jobs: uses: ./.github/workflows/test-zkvm.yml with: zkvm: jolt + test_threads: 1 diff --git a/.github/workflows/test-zkvm-zisk.yml b/.github/workflows/test-zkvm-zisk.yml index 0fc551f3..7dea64a3 100644 --- a/.github/workflows/test-zkvm-zisk.yml +++ b/.github/workflows/test-zkvm-zisk.yml @@ -19,4 +19,5 @@ jobs: cuda: true cuda_archs: '120' cluster: true + test_threads: 1 skip_prove_test: true diff --git a/Cargo.lock b/Cargo.lock index e6eed764..0ea49d56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,16 +164,18 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-consensus" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad451f9a70c341d951bca4e811d74dbe1e193897acd17e9dbac1353698cc430b" +checksum = "b0c0dc44157867da82c469c13186015b86abef209bf0e41625e4b68bac61d728" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", "alloy-trie", + "alloy-tx-macros", "auto_impl", + "borsh", "c-kzg", "derive_more 2.0.1", "either", @@ -182,15 +184,16 @@ dependencies = [ "rand 0.8.5", "secp256k1", "serde", + "serde_json", "serde_with", "thiserror 2.0.18", ] [[package]] name = "alloy-consensus-any" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142daffb15d5be1a2b20d2cd540edbcef03037b55d4ff69dc06beb4d06286dba" +checksum = "ba4cdb42df3871cd6b346d6a938ec2ba69a9a0f49d1f82714bc5c48349268434" dependencies = [ "alloy-consensus", "alloy-eips", @@ -215,52 +218,70 @@ dependencies = [ [[package]] name = "alloy-eip2930" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b82752a889170df67bbb36d42ca63c531eb16274f0d7299ae2a680facba17bd" +checksum = "9441120fa82df73e8959ae0e4ab8ade03de2aaae61be313fbf5746277847ce25" dependencies = [ "alloy-primitives", "alloy-rlp", + "borsh", "serde", ] [[package]] name = "alloy-eip7702" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d4769c6ffddca380b0070d71c8b7f30bed375543fe76bb2f74ec0acf4b7cd16" +checksum = "2919c5a56a1007492da313e7a3b6d45ef5edc5d33416fdec63c0d7a2702a0d20" dependencies = [ "alloy-primitives", "alloy-rlp", + "borsh", "serde", "thiserror 2.0.18", ] +[[package]] +name = "alloy-eip7928" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8222b1d88f9a6d03be84b0f5e76bb60cd83991b43ad8ab6477f0e4a7809b98d" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "borsh", + "serde", +] + [[package]] name = "alloy-eips" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3056872f6da48046913e76edb5ddced272861f6032f09461aea1a2497be5ae5d" +checksum = "b9f7ef09f21bd1e9cb8a686f168cb4a206646804567f0889eadb8dcc4c9288c8" dependencies = [ "alloy-eip2124", "alloy-eip2930", "alloy-eip7702", + "alloy-eip7928", "alloy-primitives", "alloy-rlp", "alloy-serde", "auto_impl", + "borsh", "c-kzg", "derive_more 2.0.1", "either", "serde", + "serde_with", "sha2", + "thiserror 2.0.18", ] [[package]] name = "alloy-json-abi" -version = "1.1.0" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0068ae277f5ee3153a95eaea8ff10e188ed8ccde9b7f9926305415a2c0ab2442" +checksum = "e9dbe713da0c737d9e5e387b0ba790eb98b14dd207fe53eef50e19a5a8ec3dac" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -270,12 +291,13 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc08b31ebf9273839bd9a01f9333cbb7a3abb4e820c312ade349dd18bdc79581" +checksum = "ff42cd777eea61f370c0b10f2648a1c81e0b783066cd7269228aa993afd487f7" dependencies = [ "alloy-primitives", "alloy-sol-types", + "http 1.3.1", "serde", "serde_json", "thiserror 2.0.18", @@ -284,9 +306,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed117b08f0cc190312bf0c38c34cf4f0dabfb4ea8f330071c587cd7160a88cb2" +checksum = "8cbca04f9b410fdc51aaaf88433cbac761213905a65fe832058bcf6690585762" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -310,9 +332,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7162ff7be8649c0c391f4e248d1273e85c62076703a1f3ec7daf76b283d886d" +checksum = "42d6d15e069a8b11f56bef2eccbad2a873c6dd4d4c81d04dda29710f5ea52f04" dependencies = [ "alloy-consensus", "alloy-eips", @@ -323,17 +345,17 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "1.1.0" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a12fe11d0b8118e551c29e1a67ccb6d01cc07ef08086df30f07487146de6fa1" +checksum = "de3b431b4e72cd8bd0ec7a50b4be18e73dab74de0dba180eef171055e5d5926e" dependencies = [ "alloy-rlp", "bytes", "cfg-if", "const-hex", "derive_more 2.0.1", - "foldhash 0.1.5", - "hashbrown 0.15.3", + "foldhash 0.2.0", + "hashbrown 0.16.1", "indexmap 2.10.0", "itoa", "k256", @@ -341,11 +363,11 @@ dependencies = [ "paste", "proptest", "rand 0.9.2", + "rapidhash", "ruint", "rustc-hash 2.1.1", "serde", "sha3", - "tiny-keccak", ] [[package]] @@ -372,9 +394,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "1.0.19" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed1e99233cff99aff94fe29cea9e9dd6014c85eeea7890ea4f0e4eada9957ceb" +checksum = "dd720b63f82b457610f2eaaf1f32edf44efffe03ae25d537632e7d23e7929e1a" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -383,9 +405,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf7dff0fdd756a714d58014f4f8354a1706ebf9fa2cf73431e0aeec3c9431e" +checksum = "9b2dc411f13092f237d2bf6918caf80977fc2f51485f9b90cb2a2f956912c8c9" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -395,17 +417,18 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", - "itertools 0.14.0", + "itertools 0.13.0", "serde", "serde_json", + "serde_with", "thiserror 2.0.18", ] [[package]] name = "alloy-serde" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "730e8f2edf2fc224cabd1c25d090e1655fa6137b2e409f92e5eec735903f1507" +checksum = "e2ce1e0dbf7720eee747700e300c99aac01b1a95bb93f493a01e78ee28bb1a37" dependencies = [ "alloy-primitives", "serde", @@ -414,9 +437,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0d2428445ec13edc711909e023d7779618504c4800be055a5b940025dbafe3" +checksum = "2425c6f314522c78e8198979c8cbf6769362be4da381d4152ea8eefce383535d" dependencies = [ "alloy-primitives", "async-trait", @@ -429,15 +452,16 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6be3d371299b62eac5aa459fa58e8d1c761aabdc637573ae258ab744457fcc88" +checksum = "e38b411077d7b17e464de7dfa599f5b94161cdffc25c2f28a90a3a345b6d6490" dependencies = [ "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", "async-trait", + "aws-config", "aws-sdk-kms", "k256", "spki", @@ -447,9 +471,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "1.0.9" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14fe6fedb7fe6e0dfae47fe020684f1d8e063274ef14bca387ddb7a6efa8ec1" +checksum = "c3ecb71ee53d8d9c3fa7bac17542c8116ebc7a9726c91b1bf333ec3d04f5a789" dependencies = [ "alloy-consensus", "alloy-network", @@ -463,9 +487,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "1.3.0" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedac07a10d4c2027817a43cc1f038313fc53c7ac866f7363239971fd01f9f18" +checksum = "ab81bab693da9bb79f7a95b64b394718259fdd7e41dceeced4cad57cb71c4f6a" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -477,9 +501,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "1.3.0" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f9a598f010f048d8b8226492b6401104f5a5c1273c2869b72af29b48bb4ba9" +checksum = "489f1620bb7e2483fb5819ed01ab6edc1d2f93939dce35a5695085a1afd1d699" dependencies = [ "alloy-sol-macro-input", "const-hex", @@ -488,16 +512,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", + "sha3", "syn 2.0.101", "syn-solidity", - "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "1.3.0" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f494adf9d60e49aa6ce26dfd42c7417aa6d4343cf2ae621f20e4d92a5ad07d85" +checksum = "56cef806ad22d4392c5fc83cf8f2089f988eb99c7067b4e0c6f1971fc1cca318" dependencies = [ "const-hex", "dunce", @@ -511,9 +535,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "1.3.1" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe8c27b3cf6b2bb8361904732f955bc7c05e00be5f469cec7e2280b6167f3ff0" +checksum = "a6df77fea9d6a2a75c0ef8d2acbdfd92286cc599983d3175ccdc170d3433d249" dependencies = [ "serde", "winnow 0.7.10", @@ -521,33 +545,44 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "1.1.0" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5460a975434ae594fe2b91586253c1beb404353b78f0a55bf124abcd79557b15" +checksum = "64612d29379782a5dde6f4b6570d9c756d734d760c0c94c254d361e678a6591f" dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-macro", - "const-hex", "serde", ] [[package]] name = "alloy-trie" -version = "0.8.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "983d99aa81f586cef9dae38443245e585840fcf0fc58b09aee0b1f27aed1d500" +checksum = "3f14b5d9b2c2173980202c6ff470d96e7c5e202c65a9f67884ad565226df7fbb" dependencies = [ "alloy-primitives", "alloy-rlp", - "arrayvec", "derive_more 2.0.1", "nybbles", "serde", "smallvec", + "thiserror 2.0.18", "tracing", ] +[[package]] +name = "alloy-tx-macros" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fa0c53e8c1e1ef4d01066b01c737fb62fc9397ab52c6e7bb5669f97d281b9bc" +dependencies = [ + "darling 0.21.3", + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -618,12 +653,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" -dependencies = [ - "backtrace", -] +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "arbitrary" @@ -634,6 +666,18 @@ dependencies = [ "derive_arbitrary", ] +[[package]] +name = "ark-bls12-381" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df4dcc01ff89867cd86b0da835f23c3f02738353aaee7dde7495af71363b8d5" +dependencies = [ + "ark-ec", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", +] + [[package]] name = "ark-bn254" version = "0.5.0" @@ -898,6 +942,17 @@ dependencies = [ "tracing-subscriber 0.2.25", ] +[[package]] +name = "ark-secp256k1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bd211c48debd3037b48873a7aa22c3aba034e83388aa4124795c9f220b88c7" +dependencies = [ + "ark-ec", + "ark-ff 0.5.0", + "ark-std 0.5.0", +] + [[package]] name = "ark-secp256k1" version = "0.5.0" @@ -908,6 +963,17 @@ dependencies = [ "ark-std 0.5.0", ] +[[package]] +name = "ark-secp256r1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cf8be5820de567729bfa73a410ddd07cec8ad102d9a4bf61fd6b2e60db264e8" +dependencies = [ + "ark-ec", + "ark-ff 0.5.0", + "ark-std 0.5.0", +] + [[package]] name = "ark-serialize" version = "0.3.0" @@ -1012,9 +1078,6 @@ name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -dependencies = [ - "serde", -] [[package]] name = "as_derive_utils" @@ -1028,6 +1091,63 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "asm-runner" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "libc", + "mem-common", + "mem-planner-cpp", + "named-sem", + "proofman-common", + "rayon", + "thiserror 2.0.18", + "tracing", + "zisk-common", + "zisk-core", +] + +[[package]] +name = "asn1-rs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56624a96882bb8c26d61312ae18cb45868e5a9992ea73c58e45c3101e56a1e60" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror 2.0.18", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "async-scoped" version = "0.9.0" @@ -1359,7 +1479,7 @@ dependencies = [ "http 1.3.1", "http-body 0.4.6", "hyper 0.14.32", - "hyper 1.6.0", + "hyper 1.8.1", "hyper-rustls 0.24.2", "hyper-rustls 0.27.5", "hyper-util", @@ -1504,7 +1624,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.8.1", "hyper-util", "itoa", "matchit 0.7.3", @@ -1538,7 +1658,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.8.1", "hyper-util", "itoa", "matchit 0.8.4", @@ -1954,7 +2074,7 @@ version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce61d2d3844c6b8d31b2353d9f66cf5e632b3e9549583fe3cac2f4f6136725e" dependencies = [ - "darling", + "darling 0.20.11", "ident_case", "prettyplease", "proc-macro2", @@ -2059,9 +2179,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" dependencies = [ "serde", ] @@ -2099,11 +2219,11 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.9" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -2115,6 +2235,16 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-platform" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0c0e6148f11f01f32650a2ea02d532b2ad4e81d8bd41e6e565b5adc5e6082" +dependencies = [ + "serde", + "serde_core", +] + [[package]] name = "cargo_metadata" version = "0.18.1" @@ -2122,7 +2252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", - "cargo-platform", + "cargo-platform 0.1.9", "semver 1.0.26", "serde", "serde_json", @@ -2136,7 +2266,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" dependencies = [ "camino", - "cargo-platform", + "cargo-platform 0.1.9", + "semver 1.0.26", + "serde", + "serde_json", + "thiserror 2.0.18", +] + +[[package]] +name = "cargo_metadata" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" +dependencies = [ + "camino", + "cargo-platform 0.3.2", "semver 1.0.26", "serde", "serde_json", @@ -2155,6 +2299,12 @@ dependencies = [ "shlex", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cexpr" version = "0.6.0" @@ -2217,6 +2367,11 @@ dependencies = [ "half", ] +[[package]] +name = "circuit" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" + [[package]] name = "circuit_common" version = "0.1.0" @@ -2305,7 +2460,17 @@ version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.48.0", +] + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", ] [[package]] @@ -2691,6 +2856,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ctor" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" +dependencies = [ + "quote", + "syn 2.0.101", +] + [[package]] name = "ctor" version = "0.5.0" @@ -2769,13 +2944,12 @@ dependencies = [ [[package]] name = "curves" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ - "fields", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", "num-bigint 0.4.6", "num-traits", - "rand 0.9.2", ] [[package]] @@ -2790,8 +2964,18 @@ version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.20.11", + "darling_macro 0.20.11", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core 0.21.3", + "darling_macro 0.21.3", ] [[package]] @@ -2808,13 +2992,39 @@ dependencies = [ "syn 2.0.101", ] +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "serde", + "strsim", + "syn 2.0.101", +] + [[package]] name = "darling_macro" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ - "darling_core", + "darling_core 0.20.11", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core 0.21.3", "quote", "syn 2.0.101", ] @@ -2912,6 +3122,30 @@ dependencies = [ "rustversion", ] +[[package]] +name = "data-bus" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "zisk-common", + "zisk-core", +] + +[[package]] +name = "data-encoding" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" + +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "uuid", +] + [[package]] name = "deepsize2" version = "0.1.0" @@ -2945,18 +3179,32 @@ dependencies = [ ] [[package]] -name = "deranged" -version = "0.4.0" +name = "der-parser" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" dependencies = [ - "powerfmt", - "serde", + "asn1-rs", + "displaydoc", + "nom", + "num-bigint 0.4.6", + "num-traits", + "rusticata-macros", ] [[package]] -name = "derivative" -version = "2.2.0" +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", + "serde_core", +] + +[[package]] +name = "derivative" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ @@ -3024,7 +3272,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" dependencies = [ - "darling", + "darling 0.20.11", "proc-macro2", "quote", "syn 2.0.101", @@ -3760,8 +4008,8 @@ dependencies = [ "ere-sp1", "ere-zisk", "ere-zkvm-interface", - "prost 0.13.5", - "prost-build 0.13.5", + "prost 0.14.3", + "prost-build 0.14.3", "serde", "tempfile", "thiserror 2.0.18", @@ -3812,25 +4060,33 @@ name = "ere-zisk" version = "0.3.0" dependencies = [ "anyhow", + "bincode 2.0.1", "blake3", "bytemuck", "ere-build-utils", "ere-compile-utils", "ere-test-utils", "ere-zkvm-interface", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", "futures-util", "http 1.3.1", + "mpi", "parking_lot", + "proofman-common", + "proofman-starks-lib-c", + "proofman-util", "proofman-verifier", + "rom-setup", "serde", - "strum 0.27.2", "tempfile", "thiserror 2.0.18", "tonic 0.14.3", "tracing", "uuid", - "wait-timeout", + "zisk-core", "zisk-distributed-grpc-api", + "zisk-sdk", + "ziskemu", ] [[package]] @@ -3885,6 +4141,49 @@ dependencies = [ "verifier_common", ] +[[package]] +name = "executor" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "asm-runner", + "crossbeam", + "data-bus", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "itertools 0.14.0", + "mem-common", + "mem-planner-cpp", + "named-sem", + "pil-std-lib", + "precomp-arith-eq", + "precomp-arith-eq-384", + "precomp-big-int", + "precomp-blake2", + "precomp-dma", + "precomp-keccakf", + "precomp-poseidon2", + "precomp-sha256f", + "precompiles-common", + "precompiles-hints", + "proofman", + "proofman-common", + "proofman-util", + "rayon", + "sm-arith", + "sm-binary", + "sm-frequent-ops", + "sm-main", + "sm-mem", + "sm-rom", + "tracing", + "witness", + "zisk-common", + "zisk-core", + "zisk-pil", + "ziskemu", +] + [[package]] name = "eyre" version = "0.6.12" @@ -3901,6 +4200,18 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" +[[package]] +name = "fastbloom" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27cea6e7f512d43b098939ff4d5a5d6fe3db07971e1d05176fe26c642d33f5b8" +dependencies = [ + "getrandom 0.3.3", + "rand 0.9.2", + "siphasher", + "wide", +] + [[package]] name = "fastrand" version = "2.3.0" @@ -4000,9 +4311,21 @@ dependencies = [ [[package]] name = "fields" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" +dependencies = [ + "cfg-if", + "num-bigint 0.4.6", + "paste", + "serde", +] + +[[package]] +name = "fields" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=pre-develop-0.16.0#620e7c89f39ee2b608bd0f5d43765dc89728ff67" dependencies = [ + "cfg-if", "num-bigint 0.4.6", "paste", "serde", @@ -4350,6 +4673,19 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "git2" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b" +dependencies = [ + "bitflags 2.9.0", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "glam" version = "0.30.3" @@ -4603,7 +4939,6 @@ dependencies = [ "allocator-api2", "equivalent", "foldhash 0.1.5", - "serde", ] [[package]] @@ -4613,6 +4948,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "foldhash 0.2.0", + "serde", + "serde_core", ] [[package]] @@ -4811,13 +5148,14 @@ dependencies = [ [[package]] name = "hyper" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "h2 0.4.10", "http 1.3.1", "http-body 1.0.1", @@ -4825,6 +5163,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", + "pin-utils", "smallvec", "tokio", "want", @@ -4854,7 +5193,7 @@ checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http 1.3.1", - "hyper 1.6.0", + "hyper 1.8.1", "hyper-util", "rustls 0.23.27", "rustls-native-certs 0.8.1", @@ -4871,7 +5210,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.6.0", + "hyper 1.8.1", "hyper-util", "pin-project-lite", "tokio", @@ -4889,7 +5228,7 @@ dependencies = [ "futures-util", "http 1.3.1", "http-body 1.0.1", - "hyper 1.6.0", + "hyper 1.8.1", "libc", "pin-project-lite", "socket2 0.5.9", @@ -5201,9 +5540,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "jiff" @@ -5229,6 +5568,28 @@ dependencies = [ "syn 2.0.101", ] +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.33" @@ -5299,7 +5660,7 @@ version = "0.1.0" source = "git+https://github.com/a16z/jolt.git?rev=2e05fe88#2e05fe883920054df2ee3a6df8f85c2caba77c99" dependencies = [ "ark-ff 0.5.0", - "ark-secp256k1", + "ark-secp256k1 0.5.0 (git+https://github.com/a16z/arkworks-algebra?branch=dev%2Ftwist-shout)", "ctor 0.6.3", "num-bigint 0.4.6", "num-integer", @@ -5358,7 +5719,7 @@ dependencies = [ "jolt-platform", "jolt-sdk-macros", "postcard", - "riscv 0.16.0", + "riscv 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "zeroos", ] @@ -5424,9 +5785,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" +checksum = "b646a74e746cd25045aa0fd42f4f7f78aa6d119380182c7e63a5593c4ab8df6f" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -5472,8 +5833,13 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lib-c" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.15.0#b3ca745b80423c8123dc24f19039865a5bc8b074" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" + +[[package]] +name = "lib-float" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" [[package]] name = "lib-rv32-asm" @@ -5514,6 +5880,18 @@ dependencies = [ "cc", ] +[[package]] +name = "libgit2-sys" +version = "0.18.3+1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + [[package]] name = "libloading" version = "0.7.4" @@ -5570,6 +5948,18 @@ dependencies = [ "libc", ] +[[package]] +name = "libz-sys" +version = "1.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52f4c29e2a68ac30c9087e1b772dc9f44a2b66ed44edf2266cf2be9b03dafc1" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linked_list_allocator" version = "0.10.5" @@ -5770,6 +6160,39 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "mem-common" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "clap", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "num-bigint 0.4.6", + "num-traits", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "static_assertions", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "mem-planner-cpp" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "mem-common", + "proofman-common", + "proofman-util", + "tracing", + "zisk-common", + "zisk-pil", +] + [[package]] name = "memchr" version = "2.7.4" @@ -5950,6 +6373,16 @@ dependencies = [ "cc", ] +[[package]] +name = "msvc-demangler" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeff6bd154a309b2ada5639b2661ca6ae4599b34e8487dc276d2cd637da2d76" +dependencies = [ + "bitflags 2.9.0", + "itoa", +] + [[package]] name = "mti" version = "1.1.1" @@ -5986,6 +6419,17 @@ dependencies = [ "syn 2.0.101", ] +[[package]] +name = "named-sem" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0875efe1a57a20d0cee7034499aa9d764b3c7525563fa3c3f16a2ccf01ddfa04" +dependencies = [ + "libc", + "thiserror 2.0.18", + "windows 0.61.1", +] + [[package]] name = "ndarray" version = "0.16.1" @@ -6089,11 +6533,10 @@ dependencies = [ [[package]] name = "num-bigint-dig" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" dependencies = [ - "byteorder", "lazy_static", "libm", "num-integer", @@ -6115,9 +6558,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" [[package]] name = "num-derive" @@ -6313,13 +6756,14 @@ dependencies = [ [[package]] name = "nybbles" -version = "0.3.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8983bb634df7248924ee0c4c3a749609b5abcb082c28fffe3254b3eb3602b307" +checksum = "bfa11e84403164a9f12982ab728f3c67c6fd4ab5b5f0254ffc217bdbd3b28ab0" dependencies = [ "alloy-rlp", - "const-hex", + "cfg-if", "proptest", + "ruint", "serde", "smallvec", ] @@ -6399,6 +6843,15 @@ dependencies = [ "ruzstd 0.8.1", ] +[[package]] +name = "oid-registry" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" +dependencies = [ + "asn1-rs", +] + [[package]] name = "once_cell" version = "1.21.3" @@ -8392,15 +8845,6 @@ dependencies = [ "group 0.13.0", ] -[[package]] -name = "papergrid" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608b6444acf7f5ea39e8bd06dd6037e34a4b5ddfb29ae840edad49ea798e9e79" -dependencies = [ - "unicode-width 0.1.14", -] - [[package]] name = "parity-scale-codec" version = "3.7.4" @@ -8490,6 +8934,22 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "path-clean" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64 0.22.1", + "serde_core", +] + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -8670,17 +9130,20 @@ dependencies = [ [[package]] name = "pil-std-lib" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ "colored", - "fields", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", "num-bigint 0.4.6", "num-traits", "proofman-common", "proofman-hints", "proofman-util", "rayon", + "rustc-hash 2.1.1", + "serde", + "serde_json", "tracing", "witness", ] @@ -8808,38 +9271,288 @@ dependencies = [ ] [[package]] -name = "prettyplease" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" +name = "precomp-arith-eq" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" dependencies = [ - "proc-macro2", - "syn 2.0.101", + "ark-bn254", + "ark-ff 0.5.0", + "ark-secp256k1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ark-secp256r1", + "ark-std 0.5.0", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "lazy_static", + "lib-c", + "mem-common", + "num-bigint 0.4.6", + "num-traits", + "path-clean", + "pil-std-lib", + "precompiles-common", + "precompiles-helpers", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "regex", + "rustfmt-wrapper", + "serde", + "serde_json", + "sm-mem", + "tracing", + "typenum", + "witness", + "zisk-common", + "zisk-core", + "zisk-pil", ] [[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +name = "precomp-arith-eq-384" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" dependencies = [ - "elliptic-curve", + "ark-bls12-381", + "ark-bn254", + "ark-ff 0.5.0", + "ark-secp256k1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ark-std 0.5.0", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "lazy_static", + "lib-c", + "mem-common", + "num-bigint 0.4.6", + "num-traits", + "path-clean", + "pil-std-lib", + "precomp-arith-eq", + "precompiles-common", + "precompiles-helpers", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "regex", + "rustfmt-wrapper", + "serde", + "serde_json", + "tracing", + "typenum", + "witness", + "zisk-common", + "zisk-core", + "zisk-pil", ] [[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +name = "precomp-big-int" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" dependencies = [ - "fixed-hash", - "impl-codec", - "uint", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "generic-array 0.14.7", + "lib-c", + "mem-common", + "pil-std-lib", + "precompiles-common", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "sm-mem", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", ] [[package]] -name = "proc-macro-crate" -version = "1.3.1" +name = "precomp-blake2" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "mem-common", + "pil-std-lib", + "precompiles-common", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "sm-mem", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "precomp-dma" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "generic-array 0.14.7", + "lib-c", + "mem-common", + "pil-std-lib", + "precompiles-common", + "precompiles-helpers", + "proofman", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "sm-mem", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "precomp-keccakf" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "circuit", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "path-clean", + "pil-std-lib", + "precompiles-common", + "precompiles-helpers", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "tiny-keccak", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "precomp-poseidon2" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "mem-common", + "pil-std-lib", + "precompiles-common", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "sha2", + "sm-mem", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "precomp-sha256f" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "mem-common", + "pil-std-lib", + "precompiles-common", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "sm-mem", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "precompiles-common" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "mem-common", + "sm-mem", + "zisk-common", + "zisk-core", +] + +[[package]] +name = "precompiles-helpers" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "ark-bls12-381", + "ark-bn254", + "ark-ff 0.5.0", + "ark-secp256k1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ark-secp256r1", + "ark-std 0.5.0", + "cfg-if", + "circuit", + "lib-c", + "num-bigint 0.4.6", + "num-traits", +] + +[[package]] +name = "precompiles-hints" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "borsh", + "lib-c", + "precompiles-helpers", + "rayon", + "rustls 0.23.27", + "tracing", + "zisk-common", + "zisk-distributed-common", + "ziskos-hints", +] + +[[package]] +name = "prettyplease" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" +dependencies = [ + "proc-macro2", + "syn 2.0.101", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ @@ -8889,9 +9602,10 @@ dependencies = [ [[package]] name = "proofman" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ + "bincode 1.3.3", "blake3", "borsh", "bytemuck", @@ -8900,7 +9614,7 @@ dependencies = [ "crossbeam-channel", "csv", "curves", - "fields", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", "libloading 0.8.7", "mpi", "num-bigint 0.4.6", @@ -8912,7 +9626,6 @@ dependencies = [ "proofman-starks-lib-c", "proofman-util", "proofman-verifier", - "rand 0.9.2", "rayon", "serde", "serde_json", @@ -8924,17 +9637,18 @@ dependencies = [ [[package]] name = "proofman-common" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ + "bincode 1.3.3", "borsh", + "bytemuck", "colored", "crossbeam-channel", "crossbeam-queue", "csv", "env", - "fields", - "indexmap 2.10.0", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", "lazy_static", "libloading 0.8.7", "mpi", @@ -8946,7 +9660,6 @@ dependencies = [ "serde", "serde_json", "sysinfo 0.35.2", - "tabled", "thiserror 2.0.18", "tracing", "tracing-subscriber 0.3.20", @@ -8955,10 +9668,11 @@ dependencies = [ [[package]] name = "proofman-hints" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ - "fields", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "itoa", "proofman-common", "proofman-starks-lib-c", "proofman-util", @@ -8967,19 +9681,18 @@ dependencies = [ [[package]] name = "proofman-macros" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ "proc-macro2", "quote", - "rayon", "syn 2.0.101", ] [[package]] name = "proofman-starks-lib-c" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ "crossbeam-channel", "tracing", @@ -8987,22 +9700,24 @@ dependencies = [ [[package]] name = "proofman-util" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ + "bincode 1.3.3", + "bytemuck", "colored", - "fields", + "serde", "sysinfo 0.35.2", - "tracing", ] [[package]] name = "proofman-verifier" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ "bytemuck", - "fields", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "proofman-util", "rayon", "tracing", ] @@ -9053,7 +9768,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" dependencies = [ "heck 0.4.1", - "itertools 0.14.0", + "itertools 0.11.0", "log", "multimap", "once_cell", @@ -9073,7 +9788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" dependencies = [ "heck 0.4.1", - "itertools 0.14.0", + "itertools 0.11.0", "log", "multimap", "petgraph 0.8.3", @@ -9094,7 +9809,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.14.0", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.101", @@ -9107,7 +9822,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" dependencies = [ "anyhow", - "itertools 0.14.0", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.101", @@ -9270,6 +9985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e" dependencies = [ "bytes", + "fastbloom", "getrandom 0.3.3", "lru-slab", "rand 0.9.2", @@ -9277,6 +9993,7 @@ dependencies = [ "rustc-hash 2.1.1", "rustls 0.23.27", "rustls-pki-types", + "rustls-platform-verifier", "slab", "thiserror 2.0.18", "tinyvec", @@ -9430,6 +10147,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "rapidhash" +version = "4.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e48930979c155e2f33aa36ab3119b5ee81332beb6482199a8ecd6029b80b59" +dependencies = [ + "rustversion", +] + [[package]] name = "raw-cpuid" version = "11.5.0" @@ -9474,6 +10200,20 @@ dependencies = [ "rayon", ] +[[package]] +name = "rcgen" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10b99e0098aa4082912d4c649628623db6aba77335e4f4569ff5083a6448b32e" +dependencies = [ + "pem", + "ring", + "rustls-pki-types", + "time", + "x509-parser", + "yasna", +] + [[package]] name = "redox_syscall" version = "0.5.12" @@ -9595,7 +10335,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.8.1", "hyper-rustls 0.27.5", "hyper-util", "ipnet", @@ -10107,6 +10847,11 @@ dependencies = [ "riscv-types", ] +[[package]] +name = "riscv" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" + [[package]] name = "riscv-types" version = "0.1.0" @@ -10170,6 +10915,23 @@ dependencies = [ "svgbobdoc", ] +[[package]] +name = "rom-setup" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "blake3", + "colored", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "proofman-common", + "sm-rom", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + [[package]] name = "rrs-lib" version = "0.1.0" @@ -10298,6 +11060,28 @@ dependencies = [ "semver 1.0.26", ] +[[package]] +name = "rustfmt-wrapper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1adc9dfed5cc999077978cc7163b9282c5751c8d39827c4ea8c8c220ca5a440" +dependencies = [ + "serde", + "tempfile", + "thiserror 1.0.69", + "toml", + "toolchain_find", +] + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + [[package]] name = "rustix" version = "0.38.44" @@ -10404,6 +11188,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19787cda76408ec5404443dc8b31795c87cd8fec49762dc75fa727740d34acc1" +dependencies = [ + "core-foundation 0.10.0", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls 0.23.27", + "rustls-native-certs 0.8.1", + "rustls-platform-verifier-android", + "rustls-webpki 0.103.3", + "security-framework 3.2.0", + "security-framework-sys", + "webpki-root-certs 0.26.11", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -10428,9 +11239,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "rusty-fork" @@ -10507,6 +11318,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scale-info" version = "2.11.6" @@ -10678,9 +11498,9 @@ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" [[package]] name = "serde" -version = "1.0.221" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "341877e04a22458705eb4e131a1508483c877dca2792b3781d4e5d8a6019ec43" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", @@ -10725,18 +11545,18 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.221" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c459bc0a14c840cb403fc14b148620de1e0778c96ecd6e0c8c3cacb6d8d00fe" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.221" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6185cf75117e20e62b1ff867b9518577271e58abe0037c40bb4794969355ab0" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -10811,7 +11631,7 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ - "darling", + "darling 0.20.11", "proc-macro2", "quote", "syn 2.0.101", @@ -10915,9 +11735,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" +checksum = "b31139435f327c93c6038ed350ae4588e2c70a13d50599509fee6349967ba35a" dependencies = [ "cc", "cfg-if", @@ -10975,6 +11795,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "siphasher" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + [[package]] name = "sketches-ddsketch" version = "0.2.2" @@ -11427,23 +12253,139 @@ dependencies = [ ] [[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" -dependencies = [ - "serde", -] - -[[package]] -name = "smartstring" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +name = "sm-arith" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" dependencies = [ - "autocfg", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "num-bigint 0.4.6", + "pil-std-lib", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "sm-binary", + "sm-frequent-ops", "static_assertions", - "version_check", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "sm-binary" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "num-bigint 0.4.6", + "pil-std-lib", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "sm-frequent-ops", + "static_assertions", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "sm-frequent-ops" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "clap", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "num-bigint 0.4.6", + "proofman-common", + "proofman-util", + "rayon", + "static_assertions", + "tracing", + "zisk-core", +] + +[[package]] +name = "sm-main" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "mem-common", + "num-bigint 0.4.6", + "pil-std-lib", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", + "ziskemu", +] + +[[package]] +name = "sm-mem" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "mem-common", + "num-bigint 0.4.6", + "num-traits", + "pil-std-lib", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "tracing", + "witness", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "sm-rom" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "asm-runner", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "itertools 0.14.0", + "proofman-common", + "proofman-macros", + "proofman-util", + "rayon", + "tracing", + "zisk-common", + "zisk-core", + "zisk-pil", +] + +[[package]] +name = "smallvec" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +dependencies = [ + "serde", +] + +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", ] [[package]] @@ -12243,6 +13185,31 @@ dependencies = [ "unicode-width 0.1.14", ] +[[package]] +name = "symbolic-common" +version = "12.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "751a2823d606b5d0a7616499e4130a516ebd01a44f39811be2b9600936509c23" +dependencies = [ + "debugid", + "memmap2", + "stable_deref_trait", + "uuid", +] + +[[package]] +name = "symbolic-demangle" +version = "12.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b237cfbe320601dd24b4ac817a5b68bb28f5508e33f08d42be0682cadc8ac9" +dependencies = [ + "cc", + "cpp_demangle 0.5.1", + "msvc-demangler", + "rustc-demangle", + "symbolic-common", +] + [[package]] name = "syn" version = "1.0.109" @@ -12267,9 +13234,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "1.3.0" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a985ff4ffd7373e10e0fb048110fb11a162e5a4c47f92ddb8787a6f766b769" +checksum = "53f425ae0b12e2f5ae65542e00898d500d4d318b4baf09f40fd0d410454e9947" dependencies = [ "paste", "proc-macro2", @@ -12327,24 +13294,17 @@ dependencies = [ ] [[package]] -name = "tabled" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2407502760ccfd538f2fb1f843dd87b6daf1a17848d57bc5a25617e408ef4c7a" -dependencies = [ - "papergrid", - "tabled_derive", -] - -[[package]] -name = "tabled_derive" -version = "0.3.0" +name = "sysinfo" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278ea3921cee8c5a69e0542998a089f7a14fa43c9c4e4f9951295da89bd0c943" +checksum = "92ab6a2f8bfe508deb3c6406578252e491d299cbbf3bc0529ecc3313aee4a52f" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "libc", + "memchr", + "ntapi", + "objc2-core-foundation", + "objc2-io-kit", + "windows 0.62.0", ] [[package]] @@ -12459,30 +13419,32 @@ dependencies = [ [[package]] name = "time" -version = "0.3.41" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", - "serde", + "serde_core", "time-core", "time-macros", ] [[package]] name = "time-core" -version = "0.1.4" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" -version = "0.2.22" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" dependencies = [ "num-conv", "time-core", @@ -12661,7 +13623,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.8.1", "hyper-timeout", "hyper-util", "percent-encoding", @@ -12693,7 +13655,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.8.1", "hyper-timeout", "hyper-util", "percent-encoding", @@ -12761,6 +13723,19 @@ dependencies = [ "tonic-build 0.14.3", ] +[[package]] +name = "toolchain_find" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc8c9a7f0a2966e1acdaf0461023d0b01471eeead645370cf4c3f5cff153f2a" +dependencies = [ + "home", + "once_cell", + "regex", + "semver 1.0.26", + "walkdir", +] + [[package]] name = "tower" version = "0.4.13" @@ -13038,9 +14013,9 @@ checksum = "e78122066b0cb818b8afd08f7ed22f7fdbc3e90815035726f0840d0d26c0747a" [[package]] name = "twirp" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c52cc4e4423b6b3e2e2659523c8c9e19af514a06422fe77a95d86f6bf3478a" +checksum = "4bfc65c610b3c5395ebb12132f251e1679386e0efef00c55ddee6affc68dd5c6" dependencies = [ "anyhow", "async-trait", @@ -13048,8 +14023,8 @@ dependencies = [ "futures", "http 1.3.1", "http-body-util", - "hyper 1.6.0", - "prost 0.13.5", + "hyper 1.8.1", + "prost 0.14.3", "reqwest", "serde", "serde_json", @@ -13061,13 +14036,13 @@ dependencies = [ [[package]] name = "twirp-build" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "361c9d2474d96655b8a2fbaefba5801d5b1ffe74157b92cc3eae721ebb48d7a9" +checksum = "f108ced0bc35967d210e9e0eab7f79c95ac4a7c4bcf5c40c1e9e53d25885550f" dependencies = [ "prettyplease", "proc-macro2", - "prost-build 0.13.5", + "prost-build 0.14.3", "quote", "syn 2.0.101", ] @@ -13083,7 +14058,7 @@ dependencies = [ "futures", "http 1.3.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.8.1", "prost 0.13.5", "reqwest", "serde", @@ -13314,6 +14289,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vec_map" version = "0.8.2" @@ -13323,6 +14304,45 @@ dependencies = [ "serde", ] +[[package]] +name = "vergen" +version = "9.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b849a1f6d8639e8de261e81ee0fc881e3e3620db1af9f2e0da015d4382ceaf75" +dependencies = [ + "anyhow", + "derive_builder", + "rustversion", + "time", + "vergen-lib", +] + +[[package]] +name = "vergen-git2" +version = "9.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51ab55ddf1188c8d679f349775362b0fa9e90bd7a4ac69838b2a087623f0d57" +dependencies = [ + "anyhow", + "derive_builder", + "git2", + "rustversion", + "time", + "vergen", + "vergen-lib", +] + +[[package]] +name = "vergen-lib" +version = "9.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b34a29ba7e9c59e62f229ae1932fb1b8fb8a6fdcc99215a641913f5f5a59a569" +dependencies = [ + "anyhow", + "derive_builder", + "rustversion", +] + [[package]] name = "verifier_common" version = "0.1.0" @@ -13380,6 +14400,16 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -13508,6 +14538,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-root-certs" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75c7f0ef91146ebfb530314f5f1d24528d7f0767efbfd31dce919275413e393e" +dependencies = [ + "webpki-root-certs 1.0.6", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804f18a4ac2676ffb4e8b5b5fa9ae38af06df08162314f96a68d2a363e21a8ca" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webpki-roots" version = "0.26.11" @@ -13564,6 +14612,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -13586,11 +14643,24 @@ version = "0.61.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5ee8f3d025738cb02bad7868bbb5f8a6327501e870bf51f1b455b0a2454a419" dependencies = [ - "windows-collections", + "windows-collections 0.2.0", "windows-core 0.61.0", - "windows-future", + "windows-future 0.2.0", "windows-link 0.1.3", - "windows-numerics", + "windows-numerics 0.2.0", +] + +[[package]] +name = "windows" +version = "0.62.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9579d0e6970fd5250aa29aba5994052385ff55cf7b28a059e484bb79ea842e42" +dependencies = [ + "windows-collections 0.3.0", + "windows-core 0.62.0", + "windows-future 0.3.0", + "windows-link 0.2.1", + "windows-numerics 0.3.0", ] [[package]] @@ -13602,6 +14672,15 @@ dependencies = [ "windows-core 0.61.0", ] +[[package]] +name = "windows-collections" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a90dd7a7b86859ec4cdf864658b311545ef19dbcf17a672b52ab7cefe80c336f" +dependencies = [ + "windows-core 0.62.0", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -13620,10 +14699,23 @@ dependencies = [ "windows-implement", "windows-interface", "windows-link 0.1.3", - "windows-result", + "windows-result 0.3.2", "windows-strings 0.4.0", ] +[[package]] +name = "windows-core" +version = "0.62.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + [[package]] name = "windows-future" version = "0.2.0" @@ -13634,6 +14726,17 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-future" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2194dee901458cb79e1148a4e9aac2b164cc95fa431891e7b296ff0b2f1d8a6" +dependencies = [ + "windows-core 0.62.0", + "windows-link 0.2.1", + "windows-threading", +] + [[package]] name = "windows-implement" version = "0.60.0" @@ -13678,13 +14781,23 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-numerics" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ce3498fe0aba81e62e477408383196b4b0363db5e0c27646f932676283b43d8" +dependencies = [ + "windows-core 0.62.0", + "windows-link 0.2.1", +] + [[package]] name = "windows-registry" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ - "windows-result", + "windows-result 0.3.2", "windows-strings 0.3.1", "windows-targets 0.53.3", ] @@ -13698,6 +14811,15 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows-strings" version = "0.3.1" @@ -13716,6 +14838,24 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -13752,6 +14892,21 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -13800,6 +14955,21 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -13818,6 +14988,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -13836,6 +15012,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -13866,6 +15048,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -13884,6 +15072,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -13902,6 +15096,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -13920,6 +15120,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -13967,11 +15173,11 @@ dependencies = [ [[package]] name = "witness" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/pil2-proofman?tag=v0.15.0#78497c5a05ea316df2188f98c1df66bffb80192f" +version = "0.16.0" +source = "git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0#d61d40bee66b3c7f02bd4ab8661f9f29ad6730a4" dependencies = [ "colored", - "fields", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", "libloading 0.8.7", "proofman-common", "proofman-util", @@ -14003,6 +15209,24 @@ dependencies = [ "tap", ] +[[package]] +name = "x509-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202" +dependencies = [ + "asn1-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "ring", + "rusticata-macros", + "thiserror 2.0.18", + "time", +] + [[package]] name = "xmlparser" version = "0.13.6" @@ -14026,6 +15250,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +[[package]] +name = "yasna" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time", +] + [[package]] name = "yoke" version = "0.8.0" @@ -14262,16 +15495,80 @@ dependencies = [ "zopfli", ] +[[package]] +name = "zisk-build" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "cargo_metadata 0.23.1", + "clap", + "rom-setup", + "tracing", + "vergen-git2", +] + +[[package]] +name = "zisk-common" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "bincode 1.3.3", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "libc", + "mpi", + "proofman", + "proofman-common", + "proofman-util", + "quinn", + "rcgen", + "rustls 0.23.27", + "serde", + "serde_json", + "thiserror 2.0.18", + "tokio", + "tracing", + "tracing-subscriber 0.3.20", + "zisk-core", +] + +[[package]] +name = "zisk-core" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "elf", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "lib-c", + "lib-float", + "paste", + "precompiles-helpers", + "rayon", + "riscv 0.16.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0)", + "serde", + "sha2", + "tiny-keccak", + "zisk-definitions", + "ziskos-hints", +] + +[[package]] +name = "zisk-definitions" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" + [[package]] name = "zisk-distributed-common" version = "0.1.0" -source = "git+https://github.com/han0110/zisk?branch=patch%2Fv0.15.0-cluster#6ffe5f4123a258765cf814c5ff3d3bb8988fb964" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" dependencies = [ "anyhow", "borsh", "chrono", "proofman", "proofman-common", + "proofman-util", "serde", "serde_json", "thiserror 2.0.18", @@ -14279,12 +15576,13 @@ dependencies = [ "tracing-appender", "tracing-subscriber 0.3.20", "uuid", + "zisk-common", ] [[package]] name = "zisk-distributed-grpc-api" -version = "0.15.0" -source = "git+https://github.com/han0110/zisk?branch=patch%2Fv0.15.0-cluster#6ffe5f4123a258765cf814c5ff3d3bb8988fb964" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" dependencies = [ "anyhow", "chrono", @@ -14300,23 +15598,133 @@ dependencies = [ "zisk-distributed-common", ] +[[package]] +name = "zisk-pil" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "proofman-common", + "proofman-macros", + "rayon", + "serde", + "serde_arrays 0.2.0", +] + +[[package]] +name = "zisk-sdk" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "asm-runner", + "bincode 1.3.3", + "colored", + "executor", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "precompiles-hints", + "proofman", + "proofman-common", + "proofman-util", + "proofman-verifier", + "rom-setup", + "serde", + "sha2", + "tracing", + "zisk-build", + "zisk-common", + "zisk-core", + "zisk-distributed-common", + "ziskemu", +] + +[[package]] +name = "zisk-verifier" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "proofman-verifier", +] + +[[package]] +name = "ziskemu" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "clap", + "data-bus", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "mem-common", + "memmap2", + "num-format", + "object 0.37.3", + "proofman-common", + "rayon", + "regex", + "riscv 0.16.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0)", + "sm-arith", + "sm-binary", + "symbolic-common", + "symbolic-demangle", + "sysinfo 0.38.4", + "vergen-git2", + "zisk-common", + "zisk-core", + "zisk-pil", +] + [[package]] name = "ziskos" -version = "0.15.0" -source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.15.0#b3ca745b80423c8123dc24f19039865a5bc8b074" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" dependencies = [ - "bincode 2.0.1", + "anyhow", + "bincode 1.3.3", + "bytes", "cfg-if", + "ctor 0.2.9", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?branch=pre-develop-0.16.0)", "getrandom 0.2.16", "lazy_static", "lib-c", "num-bigint 0.4.6", "num-integer", "num-traits", + "once_cell", + "paste", + "precompiles-helpers", "rand 0.8.5", "serde", - "static_assertions", + "sha2", + "tiny-keccak", + "tokio", + "zisk-common", + "zisk-definitions", + "zisk-verifier", +] + +[[package]] +name = "ziskos-hints" +version = "0.16.0" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.16.0#61fe43922231290ec0e09f482a88bbf3572a8f1c" +dependencies = [ + "anyhow", + "bincode 1.3.3", + "cfg-if", + "fields 0.16.0 (git+https://github.com/0xPolygonHermez/pil2-proofman.git?tag=v0.16.0)", + "getrandom 0.2.16", + "lazy_static", + "lib-c", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "paste", + "precompiles-helpers", + "rand 0.8.5", + "serde", + "sha2", "tiny-keccak", + "zisk-verifier", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0433bfd0..233e4a70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,24 +43,24 @@ license = "MIT OR Apache-2.0" anyhow = "1.0.98" auto_impl = "1.3.0" bincode = { version = "2.0.1", default-features = false } -blake3 = "1.8.2" +blake3 = "1.8" bytemuck = "1.25.0" cargo_metadata = "0.19.0" ciborium = { version = "0.2.2", default-features = false } ciborium-io = { version = "0.2.2", default-features = false } clap = "4.5.42" -dashmap = "6.1.0" digest = { version = "0.10.7", default-features = false } eyre = "0.6.12" fnv = { version = "1.0.7", default-features = false } futures-util = "0.3" http = "1" indexmap = "2.10.0" +mpi = "0.8.0" parking_lot = "0.12.5" paste = "1.0.15" postcard = { version = "1.0.8", default-features = false } -prost = "0.13" -prost-build = "0.13" +prost = "0.14" +prost-build = "0.14" rand = "0.9.2" rkyv = { version = "0.8.12", default-features = false } serde = { version = "1.0.219", default-features = false } @@ -77,10 +77,9 @@ tonic = "0.14" tower-http = "0.6.6" tracing = "0.1.41" tracing-subscriber = "0.3.19" -twirp = "0.9.1" -twirp-build = "0.9.0" +twirp = "0.10" +twirp-build = "0.10" uuid = "1" -wait-timeout = "0.2.1" # Airbender dependencies airbender_execution_utils = { git = "https://github.com/matter-labs/zksync-airbender", package = "execution_utils", tag = "v0.5.2" } @@ -127,9 +126,17 @@ sp1-zkvm = { version = "6.0.1", default-features = false } # ZisK dependencies -ziskos = { git = "https://github.com/0xPolygonHermez/zisk.git", tag = "v0.15.0" } -zisk-distributed-grpc-api = { git = "https://github.com/han0110/zisk", branch = "patch/v0.15.0-cluster" } -zisk-proofman-verifier = { git = "https://github.com/0xPolygonHermez/pil2-proofman", package = "proofman-verifier", tag = "v0.15.0" } +ziskos = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.0" } +zisk-rom-setup = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.0", package = "rom-setup" } +zisk-sdk = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.0" } +zisk-core = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.0" } +ziskemu = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.0" } +zisk-distributed-grpc-api = { git = "https://github.com/han0110/zisk.git", branch = "patch/v0.16.0" } +proofman-common = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.0" } +proofman-util = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.0" } +proofman-fields = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.0", package = "fields" } +proofman-starks-lib-c = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.0" } +proofman-verifier = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", tag = "v0.16.0" } # Local dependencies ere-zkvm-interface = { path = "crates/zkvm-interface" } diff --git a/README.md b/README.md index bfafb3df..8dde4581 100644 --- a/README.md +++ b/README.md @@ -142,15 +142,15 @@ Public values written in the guest program (via `Platform::write_whole_output()` Different zkVMs handles public values in different approaches: -| zkVM | Size Limit | Note | -| --------- | ------------------------- | ------------------------------- | -| Airbender | 32 bytes | Padded to 32 bytes with zeros | -| Jolt | 4096 bytes (Configurable) | | -| OpenVM | 32 bytes | Padded to 32 bytes with zeros | -| Pico | unlimited | Hashed internally | -| Risc0 | unlimited | Hashed internally | -| SP1 | unlimited | Hashed internally | -| Zisk | 256 bytes | | +| zkVM | Size Limit | Note | +| --------- | ------------------------- | ----------------------------- | +| Airbender | 32 bytes | Padded to 32 bytes with zeros | +| Jolt | 4096 bytes (Configurable) | | +| OpenVM | 32 bytes | Padded to 32 bytes with zeros | +| Pico | unlimited | Hashed internally | +| Risc0 | unlimited | Hashed internally | +| SP1 | unlimited | Hashed internally | +| Zisk | 256 bytes | | For zkVMs with size limits on public values, `OutputHashedPlatform` serves as a wrapper that hashes outputs before calling the inner `P::write_whole_output`. This enables the same guest program to run across all zkVMs regardless of their size constraints: @@ -160,15 +160,15 @@ OutputHashedPlatform::::write_whole_output(&large_output ## Supported zkVMs -| zkVM | Version | GPU | -| --------- | ---------------------------------------------------------------------- | --- | -| Airbender | [`0.5.2`](https://github.com/matter-labs/zksync-airbender/tree/v0.5.2) | Yes | -| Jolt | [`2e05fe88`](https://github.com/a16z/jolt/tree/2e05fe88) | No | -| OpenVM | [`1.4.3`](https://github.com/openvm-org/openvm/tree/v1.4.3) | Yes | -| Pico | [`1.3.0`](https://github.com/brevis-network/pico/tree/v1.3.0) | No | -| Risc0 | [`3.0.4`](https://github.com/risc0/risc0/tree/v3.0.4) | Yes | -| SP1 | [`6.0.1`](https://github.com/succinctlabs/sp1/tree/v6.0.1) | Yes | -| Zisk | [`0.15.0`](https://github.com/0xPolygonHermez/zisk/tree/v0.15.0) | Yes | +| zkVM | Version | ISA | GPU | Multi GPU | Cluster | +| --------- | ---------------------------------------------------------------------- | ---------- | :---: | :-------: | :-----: | +| Airbender | [`0.5.2`](https://github.com/matter-labs/zksync-airbender/tree/v0.5.2) | `RV32IMA` | V | V | | +| Jolt | [`2e05fe88`](https://github.com/a16z/jolt/tree/2e05fe88) | `RV64IMAC` | | | | +| OpenVM | [`1.4.3`](https://github.com/openvm-org/openvm/tree/v1.4.3) | `RV32IMA` | V | | | +| Pico | [`1.3.0`](https://github.com/brevis-network/pico/tree/v1.3.0) | `RV32IMA` | | | | +| Risc0 | [`3.0.4`](https://github.com/risc0/risc0/tree/v3.0.4) | `RV32IMA` | V | V | | +| SP1 | [`6.0.1`](https://github.com/succinctlabs/sp1/tree/v6.0.1) | `RV64IMA` | V | | | +| Zisk | [`0.16.0`](https://github.com/0xPolygonHermez/zisk/tree/v0.16.0) | `RV64IMA` | V | V | V | ## Examples diff --git a/crates/dockerized/common/build.rs b/crates/dockerized/common/build.rs index 35ce4ded..e0d77765 100644 --- a/crates/dockerized/common/build.rs +++ b/crates/dockerized/common/build.rs @@ -43,7 +43,7 @@ fn generate_zkvm_sdk_version_impl() { "pico-vm", "risc0-zkvm", "sp1-sdk", - "ziskos", + "zisk-sdk", ] .map(detect_sdk_version); diff --git a/crates/dockerized/compiler/src/main.rs b/crates/dockerized/compiler/src/main.rs index 093c6e8d..c23533c1 100644 --- a/crates/dockerized/compiler/src/main.rs +++ b/crates/dockerized/compiler/src/main.rs @@ -1,4 +1,4 @@ -use anyhow::{Context, Error, bail}; +use anyhow::{Context, Error}; use clap::Parser; use ere_common::CompilerKind; use ere_zkvm_interface::compiler::Compiler; @@ -103,7 +103,7 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let elf = program.elf().to_vec(); (Some(elf), None, program) } - _ => bail!(unsupported_compiler_kind_err( + _ => anyhow::bail!(unsupported_compiler_kind_err( compiler_kind, [CompilerKind::Rust, CompilerKind::RustCustomized] )), @@ -122,7 +122,7 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let program = RustRv64imacCustomized.compile(&guest_dir)?; (Some(program.elf().to_vec()), None, program) } - _ => bail!(unsupported_compiler_kind_err( + _ => anyhow::bail!(unsupported_compiler_kind_err( compiler_kind, [CompilerKind::Rust, CompilerKind::RustCustomized] )), @@ -141,7 +141,7 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let program = RustRv32imaCustomized.compile(&guest_dir)?; (Some(program.elf().to_vec()), None, program) } - _ => bail!(unsupported_compiler_kind_err( + _ => anyhow::bail!(unsupported_compiler_kind_err( compiler_kind, [CompilerKind::Rust, CompilerKind::RustCustomized] )), @@ -160,7 +160,7 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let program = RustRv32imaCustomized.compile(&guest_dir)?; (Some(program.elf().to_vec()), None, program) } - _ => bail!(unsupported_compiler_kind_err( + _ => anyhow::bail!(unsupported_compiler_kind_err( compiler_kind, [CompilerKind::Rust, CompilerKind::RustCustomized] )), @@ -183,7 +183,7 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let digest = program.image_id().as_bytes().to_vec(); (Some(elf), Some(digest), program) } - _ => bail!(unsupported_compiler_kind_err( + _ => anyhow::bail!(unsupported_compiler_kind_err( compiler_kind, [CompilerKind::Rust, CompilerKind::RustCustomized] )), @@ -202,7 +202,7 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let program = RustRv64imaCustomized.compile(&guest_dir)?; (Some(program.elf().to_vec()), None, program) } - _ => bail!(unsupported_compiler_kind_err( + _ => anyhow::bail!(unsupported_compiler_kind_err( compiler_kind, [CompilerKind::Rust, CompilerKind::RustCustomized] )), @@ -213,6 +213,10 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let result = { use ere_zisk::compiler::*; match compiler_kind { + CompilerKind::Rust => { + let program = RustRv64ima.compile(&guest_dir)?; + (Some(program.elf().to_vec()), None, program) + } CompilerKind::RustCustomized => { let program = RustRv64imaCustomized.compile(&guest_dir)?; (Some(program.elf().to_vec()), None, program) @@ -221,16 +225,13 @@ fn compile(guest_dir: PathBuf, compiler_kind: CompilerKind) -> CompilationResult let program = GoCustomized.compile(&guest_dir)?; (Some(program.elf().to_vec()), None, program) } - _ => bail!(unsupported_compiler_kind_err( - compiler_kind, - [CompilerKind::RustCustomized, CompilerKind::GoCustomized] - )), } }; Ok(result) } +#[allow(dead_code)] fn unsupported_compiler_kind_err( compiler_kind: CompilerKind, supported: impl IntoIterator, diff --git a/crates/dockerized/server/Cargo.toml b/crates/dockerized/server/Cargo.toml index befb8df1..4385955f 100644 --- a/crates/dockerized/server/Cargo.toml +++ b/crates/dockerized/server/Cargo.toml @@ -53,4 +53,4 @@ sp1 = ["dep:ere-sp1", "server"] zisk = ["dep:ere-zisk", "server"] # Cuda -cuda = ["ere-openvm?/cuda"] +cuda = ["ere-openvm?/cuda", "ere-zisk?/cuda"] diff --git a/crates/dockerized/server/src/api.rs b/crates/dockerized/server/src/api.rs index c070e954..68773f94 100644 --- a/crates/dockerized/server/src/api.rs +++ b/crates/dockerized/server/src/api.rs @@ -1,6 +1,6 @@ // This file is @generated by prost-build. #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct ExecuteRequest { #[prost(bytes = "vec", tag = "1")] pub input_stdin: ::prost::alloc::vec::Vec, @@ -8,7 +8,7 @@ pub struct ExecuteRequest { pub input_proofs: ::core::option::Option<::prost::alloc::vec::Vec>, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct ExecuteResponse { #[prost(oneof = "execute_response::Result", tags = "1, 2")] pub result: ::core::option::Option, @@ -16,7 +16,7 @@ pub struct ExecuteResponse { /// Nested message and enum types in `ExecuteResponse`. pub mod execute_response { #[derive(serde::Serialize, serde::Deserialize)] - #[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] pub enum Result { #[prost(message, tag = "1")] Ok(super::ExecuteOk), @@ -25,7 +25,7 @@ pub mod execute_response { } } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct ExecuteOk { #[prost(bytes = "vec", tag = "1")] pub public_values: ::prost::alloc::vec::Vec, @@ -33,7 +33,7 @@ pub struct ExecuteOk { pub report: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct ProveRequest { #[prost(bytes = "vec", tag = "1")] pub input_stdin: ::prost::alloc::vec::Vec, @@ -43,7 +43,7 @@ pub struct ProveRequest { pub proof_kind: i32, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct ProveResponse { #[prost(oneof = "prove_response::Result", tags = "1, 2")] pub result: ::core::option::Option, @@ -51,7 +51,7 @@ pub struct ProveResponse { /// Nested message and enum types in `ProveResponse`. pub mod prove_response { #[derive(serde::Serialize, serde::Deserialize)] - #[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] pub enum Result { #[prost(message, tag = "1")] Ok(super::ProveOk), @@ -60,7 +60,7 @@ pub mod prove_response { } } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct ProveOk { #[prost(bytes = "vec", tag = "1")] pub public_values: ::prost::alloc::vec::Vec, @@ -70,7 +70,7 @@ pub struct ProveOk { pub report: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct VerifyRequest { #[prost(bytes = "vec", tag = "1")] pub proof: ::prost::alloc::vec::Vec, @@ -78,7 +78,7 @@ pub struct VerifyRequest { pub proof_kind: i32, } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct VerifyResponse { #[prost(oneof = "verify_response::Result", tags = "1, 2")] pub result: ::core::option::Option, @@ -86,7 +86,7 @@ pub struct VerifyResponse { /// Nested message and enum types in `VerifyResponse`. pub mod verify_response { #[derive(serde::Serialize, serde::Deserialize)] - #[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] pub enum Result { #[prost(message, tag = "1")] Ok(super::VerifyOk), @@ -95,7 +95,7 @@ pub mod verify_response { } } #[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct VerifyOk { #[prost(bytes = "vec", tag = "1")] pub public_values: ::prost::alloc::vec::Vec, diff --git a/crates/dockerized/src/compiler.rs b/crates/dockerized/src/compiler.rs index 1307f12f..ad8177ff 100644 --- a/crates/dockerized/src/compiler.rs +++ b/crates/dockerized/src/compiler.rs @@ -269,8 +269,10 @@ pub(crate) mod test { mod zisk { test_compile!(Zisk, RustCustomized, "basic_rust"); + test_compile!(Zisk, Rust, "stock_nightly_no_std"); test_compile!(Zisk, GoCustomized, "basic_go"); test_reproducible_elf!(Zisk, RustCustomized, "basic_rust"); + test_reproducible_elf!(Zisk, Rust, "stock_nightly_no_std"); test_reproducible_elf!(Zisk, GoCustomized, "basic_go"); } } diff --git a/crates/dockerized/src/zkvm.rs b/crates/dockerized/src/zkvm.rs index 3b2a0fc1..9bc60bc4 100644 --- a/crates/dockerized/src/zkvm.rs +++ b/crates/dockerized/src/zkvm.rs @@ -212,6 +212,7 @@ impl ServerContainer { let mut cmd = DockerRunCmd::new(server_zkvm_image(zkvm_kind, gpu)) .rm() .inherit_env("RUST_LOG") + .inherit_env("RUST_BACKTRACE") .inherit_env("NO_COLOR") .publish(port.to_string(), port.to_string()) .name(&name); @@ -234,17 +235,13 @@ impl ServerContainer { .option("shm-size", "32G") .option("ulimit", "memlock=-1:-1") .inherit_env("ERE_ZISK_SETUP_ON_INIT") - .inherit_env("ERE_ZISK_PORT") .inherit_env("ERE_ZISK_UNLOCK_MAPPED_MEMORY") .inherit_env("ERE_ZISK_MINIMAL_MEMORY") .inherit_env("ERE_ZISK_PREALLOCATE") .inherit_env("ERE_ZISK_SHARED_TABLES") .inherit_env("ERE_ZISK_MAX_STREAMS") .inherit_env("ERE_ZISK_NUMBER_THREADS_WITNESS") - .inherit_env("ERE_ZISK_MAX_WITNESS_STORED") - .inherit_env("ERE_ZISK_START_SERVER_TIMEOUT_SEC") - .inherit_env("ERE_ZISK_SHUTDOWN_SERVER_TIMEOUT_SEC") - .inherit_env("ERE_ZISK_PROVE_TIMEOUT_SEC"), + .inherit_env("ERE_ZISK_MAX_WITNESS_STORED"), _ => cmd, }; @@ -520,6 +517,11 @@ mod test { "Expect error variant `Error::zkVM`, got {err:?}", ); } + + // Should be able to recover + for test_case in $valid_test_cases { + run_zkvm_prove(&zkvm, &test_case); + } } }; } diff --git a/crates/test-utils/src/host.rs b/crates/test-utils/src/host.rs index 7fdbecc9..18da454c 100644 --- a/crates/test-utils/src/host.rs +++ b/crates/test-utils/src/host.rs @@ -122,6 +122,7 @@ where fn assert_output(&self, public_values: &[u8]) { let output = P::compute(self.test_case.clone()); let digest = D::digest(P::Io::serialize_output(&output).unwrap()); - assert_eq!(&*digest, public_values) + assert_eq!(&*digest, &public_values[..digest.len()]); + assert!(public_values[digest.len()..].iter().all(|byte| *byte == 0)); } } diff --git a/crates/test-utils/src/program/basic.rs b/crates/test-utils/src/program/basic.rs index 12be852f..9c4618e7 100644 --- a/crates/test-utils/src/program/basic.rs +++ b/crates/test-utils/src/program/basic.rs @@ -21,8 +21,8 @@ where BasicProgramOutput { a: input.a.wrapping_add(1), b: input.b.wrapping_add(1), - c: input.c.wrapping_add(1), - d: input.d.wrapping_add(1), + c: input.c.wrapping_mul(input.a as u32).wrapping_add(1), + d: input.d.wrapping_mul(input.b as u64).wrapping_add(1), e: input.e.iter().map(|byte| byte.wrapping_add(1)).collect(), } } diff --git a/crates/zkvm-interface/platform/src/lib.rs b/crates/zkvm-interface/platform/src/lib.rs index 30365ddf..d649e181 100644 --- a/crates/zkvm-interface/platform/src/lib.rs +++ b/crates/zkvm-interface/platform/src/lib.rs @@ -1,8 +1,5 @@ #![no_std] -extern crate alloc; - -use alloc::vec::Vec; use core::{marker::PhantomData, ops::Deref}; pub use digest::Digest; @@ -108,18 +105,18 @@ where /// Stdin with a LE u32 length prefix. /// /// Dereferencing it returns slice to the actual data. -pub struct LengthPrefixedStdin(Vec); +pub struct LengthPrefixedStdin(T); -impl Deref for LengthPrefixedStdin { +impl> Deref for LengthPrefixedStdin { type Target = [u8]; fn deref(&self) -> &Self::Target { - &self.0[4..] + &self.0.deref()[4..] } } -impl LengthPrefixedStdin { - pub fn new(stdin: Vec) -> Self { +impl> LengthPrefixedStdin { + pub fn new(stdin: T) -> Self { assert!( stdin.len() >= 4, "stdin must have a LE u32 length prefix; use Input::with_prefixed_length(stdin) on the host side" diff --git a/crates/zkvm/airbender/Cargo.toml b/crates/zkvm/airbender/Cargo.toml index fe681ee0..354c448e 100644 --- a/crates/zkvm/airbender/Cargo.toml +++ b/crates/zkvm/airbender/Cargo.toml @@ -30,6 +30,7 @@ ere-build-utils.workspace = true default = ["compiler", "zkvm"] compiler = ["dep:ere-compile-utils"] zkvm = ["dep:airbender_execution_utils"] +cuda = [] [lints] workspace = true diff --git a/crates/zkvm/airbender/src/zkvm.rs b/crates/zkvm/airbender/src/zkvm.rs index 34c7ada4..49bcb54d 100644 --- a/crates/zkvm/airbender/src/zkvm.rs +++ b/crates/zkvm/airbender/src/zkvm.rs @@ -188,5 +188,37 @@ mod tests { ] { zkvm.prove(&input, ProofKind::default()).unwrap_err(); } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case().into_output_sha256(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_gpu() { + let program = basic_program(); + let zkvm = EreAirbender::new(program, ProverResource::Gpu).unwrap(); + + let test_case = BasicProgram::::valid_test_case().into_output_sha256(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_invalid_test_case_gpu() { + let program = basic_program(); + let zkvm = EreAirbender::new(program, ProverResource::Gpu).unwrap(); + + for input in [ + Input::new(), + BasicProgram::::invalid_test_case().input(), + ] { + zkvm.prove(&input, ProofKind::default()).unwrap_err(); + } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case().into_output_sha256(); + run_zkvm_prove(&zkvm, &test_case); } } diff --git a/crates/zkvm/jolt/src/zkvm.rs b/crates/zkvm/jolt/src/zkvm.rs index 97744bcd..f7bde2eb 100644 --- a/crates/zkvm/jolt/src/zkvm.rs +++ b/crates/zkvm/jolt/src/zkvm.rs @@ -191,5 +191,9 @@ mod tests { ] { zkvm.prove(&input, ProofKind::default()).unwrap_err(); } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); } } diff --git a/crates/zkvm/openvm/src/zkvm.rs b/crates/zkvm/openvm/src/zkvm.rs index 5977252d..add444c4 100644 --- a/crates/zkvm/openvm/src/zkvm.rs +++ b/crates/zkvm/openvm/src/zkvm.rs @@ -36,11 +36,6 @@ pub struct EreOpenVM { impl EreOpenVM { pub fn new(program: OpenVMProgram, resource: ProverResource) -> Result { - #[cfg(not(feature = "cuda"))] - if resource.is_gpu() { - return Err(Error::CudaFeatureDisabled); - } - if !matches!(resource, ProverResource::Cpu | ProverResource::Gpu) { Err(CommonError::unsupported_prover_resource_kind( resource.kind(), @@ -322,5 +317,37 @@ mod tests { ] { zkvm.prove(&input, ProofKind::default()).unwrap_err(); } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case().into_output_sha256(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_gpu() { + let program = basic_program(); + let zkvm = EreOpenVM::new(program, ProverResource::Gpu).unwrap(); + + let test_case = BasicProgram::::valid_test_case().into_output_sha256(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_invalid_test_case_gpu() { + let program = basic_program(); + let zkvm = EreOpenVM::new(program, ProverResource::Gpu).unwrap(); + + for input in [ + Input::new(), + BasicProgram::::invalid_test_case().input(), + ] { + zkvm.prove(&input, ProofKind::default()).unwrap_err(); + } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case().into_output_sha256(); + run_zkvm_prove(&zkvm, &test_case); } } diff --git a/crates/zkvm/pico/src/zkvm.rs b/crates/zkvm/pico/src/zkvm.rs index d3b68b9b..abd03e02 100644 --- a/crates/zkvm/pico/src/zkvm.rs +++ b/crates/zkvm/pico/src/zkvm.rs @@ -259,5 +259,9 @@ mod tests { ] { zkvm.prove(&input, ProofKind::default()).unwrap_err(); } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); } } diff --git a/crates/zkvm/risc0/Cargo.toml b/crates/zkvm/risc0/Cargo.toml index bb8955e8..4352dd57 100644 --- a/crates/zkvm/risc0/Cargo.toml +++ b/crates/zkvm/risc0/Cargo.toml @@ -34,6 +34,7 @@ default = ["compiler", "zkvm"] compiler = ["dep:ere-compile-utils"] zkvm = ["dep:risc0-zkvm"] metal = ["risc0-zkvm/metal"] +cuda = [] [lints] workspace = true diff --git a/crates/zkvm/risc0/src/zkvm.rs b/crates/zkvm/risc0/src/zkvm.rs index bd4a5f4a..cbdb10b3 100644 --- a/crates/zkvm/risc0/src/zkvm.rs +++ b/crates/zkvm/risc0/src/zkvm.rs @@ -298,6 +298,10 @@ mod tests { ] { zkvm.prove(&input, ProofKind::default()).unwrap_err(); } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); } #[test] @@ -320,4 +324,32 @@ mod tests { } } } + + #[cfg(any(feature = "cuda", feature = "metal"))] + #[test] + fn test_prove_gpu() { + let program = basic_program(); + let zkvm = EreRisc0::new(program, ProverResource::Gpu).unwrap(); + + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(any(feature = "cuda", feature = "metal"))] + #[test] + fn test_prove_invalid_test_case_gpu() { + let program = basic_program(); + let zkvm = EreRisc0::new(program, ProverResource::Gpu).unwrap(); + + for input in [ + Input::new(), + BasicProgram::::invalid_test_case().input(), + ] { + zkvm.prove(&input, ProofKind::default()).unwrap_err(); + } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); + } } diff --git a/crates/zkvm/sp1/Cargo.toml b/crates/zkvm/sp1/Cargo.toml index 1f1fed98..dc061d5e 100644 --- a/crates/zkvm/sp1/Cargo.toml +++ b/crates/zkvm/sp1/Cargo.toml @@ -41,6 +41,7 @@ zkvm = [ "dep:sp1-sdk", "ere-zkvm-interface/tokio", ] +cuda = [] [lints] workspace = true diff --git a/crates/zkvm/sp1/src/zkvm.rs b/crates/zkvm/sp1/src/zkvm.rs index a5180f25..7054765f 100644 --- a/crates/zkvm/sp1/src/zkvm.rs +++ b/crates/zkvm/sp1/src/zkvm.rs @@ -197,6 +197,38 @@ mod tests { ] { zkvm.prove(&input, ProofKind::default()).unwrap_err(); } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_gpu() { + let program = basic_program(); + let zkvm = EreSP1::new(program, ProverResource::Gpu).unwrap(); + + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_invalid_test_case_gpu() { + let program = basic_program(); + let zkvm = EreSP1::new(program, ProverResource::Gpu).unwrap(); + + for input in [ + Input::new(), + BasicProgram::::invalid_test_case().input(), + ] { + zkvm.prove(&input, ProofKind::default()).unwrap_err(); + } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); } #[test] diff --git a/crates/zkvm/zisk/Cargo.toml b/crates/zkvm/zisk/Cargo.toml index 11d437bf..fc9f4f45 100644 --- a/crates/zkvm/zisk/Cargo.toml +++ b/crates/zkvm/zisk/Cargo.toml @@ -7,27 +7,35 @@ license.workspace = true [dependencies] anyhow.workspace = true -blake3.workspace = true -bytemuck = { workspace = true, features = ["extern_crate_alloc"] } +bincode = { workspace = true, features = ["alloc"] } +blake3 = { workspace = true, optional = true } +bytemuck.workspace = true futures-util.workspace = true http.workspace = true +mpi = { workspace = true, optional = true } parking_lot.workspace = true serde.workspace = true -strum = { workspace = true, features = ["derive"] } tempfile.workspace = true thiserror.workspace = true tonic = { workspace = true, optional = true } tracing.workspace = true uuid = { workspace = true, features = ["v4"] } -wait-timeout.workspace = true # Local dependencies ere-compile-utils = { workspace = true, optional = true } ere-zkvm-interface.workspace = true # Zisk dependencies +proofman-common = { workspace = true, optional = true } +proofman-fields = { workspace = true, optional = true } +proofman-starks-lib-c = { workspace = true, optional = true } +proofman-util = { workspace = true, optional = true } +proofman-verifier = { workspace = true, optional = true } +zisk-core = { workspace = true, optional = true } +zisk-rom-setup = { workspace = true, optional = true } +zisk-sdk = { workspace = true, optional = true, features = ["disable_distributed"] } +ziskemu = { workspace = true, optional = true } zisk-distributed-grpc-api = { workspace = true, optional = true } -zisk-proofman-verifier = { workspace = true, optional = true } [dev-dependencies] ere-test-utils = { workspace = true, features = ["host"] } @@ -39,11 +47,22 @@ ere-build-utils.workspace = true default = ["compiler", "zkvm"] compiler = ["dep:ere-compile-utils"] zkvm = [ + "dep:blake3", + "dep:mpi", "dep:tonic", + "dep:proofman-common", + "dep:proofman-fields", + "dep:proofman-starks-lib-c", + "dep:proofman-util", + "dep:proofman-verifier", + "dep:zisk-rom-setup", + "dep:zisk-core", + "dep:zisk-sdk", + "dep:ziskemu", "dep:zisk-distributed-grpc-api", - "dep:zisk-proofman-verifier", "ere-zkvm-interface/tokio", ] +cuda = ["zisk-sdk/gpu"] [lints] workspace = true diff --git a/crates/zkvm/zisk/build.rs b/crates/zkvm/zisk/build.rs index eebd5b32..57672ec4 100644 --- a/crates/zkvm/zisk/build.rs +++ b/crates/zkvm/zisk/build.rs @@ -1,5 +1,5 @@ use ere_build_utils::detect_and_generate_name_and_sdk_version; fn main() { - detect_and_generate_name_and_sdk_version("zisk", "ziskos"); + detect_and_generate_name_and_sdk_version("zisk", "zisk-sdk"); } diff --git a/crates/zkvm/zisk/platform/src/lib.rs b/crates/zkvm/zisk/platform/src/lib.rs index 868a02ba..c3b0476b 100644 --- a/crates/zkvm/zisk/platform/src/lib.rs +++ b/crates/zkvm/zisk/platform/src/lib.rs @@ -2,7 +2,7 @@ extern crate alloc; -use core::{array::from_fn, cell::UnsafeCell, hash::Hasher, ops::Deref}; +use core::{cell::UnsafeCell, hash::Hasher, ops::Deref}; use ere_platform_trait::LengthPrefixedStdin; use fnv::FnvHasher; use ziskos::ziskos_definitions::ziskos_config::UART_ADDR; @@ -55,10 +55,11 @@ impl ScopeRegistry { #[cfg(feature = "check-cycle-scope")] let names = &mut *self.names.get(); - for i in 0..*count as usize { - if entries[i] == name_hash { - return i as u8; - } + if let Some(i) = entries[..*count as usize] + .iter() + .position(|entry| *entry == name_hash) + { + return i as u8; } assert!( @@ -150,7 +151,7 @@ pub struct ZiskPlatform; impl Platform for ZiskPlatform { fn read_whole_input() -> impl Deref { - LengthPrefixedStdin::new(ziskos::read_input()) + LengthPrefixedStdin::new(ziskos::io::read_input_slice()) } fn write_whole_output(output: &[u8]) { @@ -159,10 +160,7 @@ impl Platform for ZiskPlatform { "Maximum output size is 256 bytes, got {}", output.len() ); - output.chunks(4).enumerate().for_each(|(idx, chunk)| { - let value = u32::from_le_bytes(from_fn(|i| chunk.get(i).copied().unwrap_or_default())); - ziskos::set_output(idx, value) - }); + ziskos::io::write(output); } fn print(message: &str) { diff --git a/crates/zkvm/zisk/src/compiler.rs b/crates/zkvm/zisk/src/compiler.rs index dbecedcb..578f7705 100644 --- a/crates/zkvm/zisk/src/compiler.rs +++ b/crates/zkvm/zisk/src/compiler.rs @@ -1,7 +1,9 @@ mod error; mod go_customized; +mod rust_rv64ima; mod rust_rv64ima_customized; pub use error::Error; pub use go_customized::GoCustomized; +pub use rust_rv64ima::RustRv64ima; pub use rust_rv64ima_customized::RustRv64imaCustomized; diff --git a/crates/zkvm/zisk/src/compiler/rust_rv64ima.rs b/crates/zkvm/zisk/src/compiler/rust_rv64ima.rs new file mode 100644 index 00000000..4a7eb85c --- /dev/null +++ b/crates/zkvm/zisk/src/compiler/rust_rv64ima.rs @@ -0,0 +1,85 @@ +use crate::{compiler::Error, program::ZiskProgram}; +use ere_compile_utils::{CargoBuildCmd, RustTarget}; +use ere_zkvm_interface::compiler::Compiler; +use std::{env, path::Path}; + +/// Target spec modified from `riscv64im-unknown-none-elf` with patch `atomic-cas = true`. +/// +/// To reproduce: +/// +/// ```bash +/// rustc +nightly -Z unstable-options --print target-spec-json --target riscv64im-unknown-none-elf \ +/// | jq '.["atomic-cas"] = true' \ +/// > ./crates/zkvm/zisk/src/compiler/rust_rv64ima/riscv64ima-unknown-none-elf.json +/// ``` +const TARGET: RustTarget = RustTarget::SpecJson { + name: "riscv64ima-unknown-none-elf", + json: include_str!("./rust_rv64ima/riscv64ima-unknown-none-elf.json"), +}; + +const RUSTFLAGS: &[&str] = &[ + "-C", + "passes=lower-atomic", + "-C", + "panic=abort", + "--cfg", + "getrandom_backend=\"custom\"", +]; + +const CARGO_BUILD_OPTIONS: &[&str] = &[ + // For bare metal we have to build core and alloc + "-Zbuild-std=core,alloc", + // For using json target spec + "-Zjson-target-spec", +]; + +/// Copied from https://github.com/0xPolygonHermez/rust/blob/c03068e/compiler/rustc_target/src/spec/targets/riscv64ima_zisk_zkvm_elf_linker_script.ld. +const LINKER_SCRIPT: &str = include_str!("rust_rv64ima/link.x"); + +/// Compiler for Rust guest program to RV64IMA architecture, using a stock +/// nightly Rust toolchain with ZisK's target specification. +pub struct RustRv64ima; + +impl Compiler for RustRv64ima { + type Error = Error; + + type Program = ZiskProgram; + + fn compile(&self, guest_directory: &Path) -> Result { + let toolchain = env::var("ERE_RUST_TOOLCHAIN").unwrap_or_else(|_| "nightly".into()); + let elf = CargoBuildCmd::new() + .linker_script(Some(LINKER_SCRIPT)) + .toolchain(toolchain) + .build_options(CARGO_BUILD_OPTIONS) + .rustflags(RUSTFLAGS) + .exec(guest_directory, TARGET)?; + Ok(ZiskProgram { elf }) + } +} + +#[cfg(test)] +mod tests { + use crate::{compiler::RustRv64ima, zkvm::EreZisk}; + use ere_test_utils::host::testing_guest_directory; + use ere_zkvm_interface::{ + Input, + compiler::Compiler, + zkvm::{ProverResource, zkVM}, + }; + + #[test] + fn test_compile() { + let guest_directory = testing_guest_directory("zisk", "stock_nightly_no_std"); + let program = RustRv64ima.compile(&guest_directory).unwrap(); + assert!(!program.elf().is_empty(), "ELF bytes should not be empty."); + } + + #[test] + fn test_execute() { + let guest_directory = testing_guest_directory("zisk", "stock_nightly_no_std"); + let program = RustRv64ima.compile(&guest_directory).unwrap(); + let zkvm = EreZisk::new(program, ProverResource::Cpu).unwrap(); + + zkvm.execute(&Input::new()).unwrap(); + } +} diff --git a/crates/zkvm/zisk/src/compiler/rust_rv64ima/link.x b/crates/zkvm/zisk/src/compiler/rust_rv64ima/link.x new file mode 100644 index 00000000..228facff --- /dev/null +++ b/crates/zkvm/zisk/src/compiler/rust_rv64ima/link.x @@ -0,0 +1,83 @@ +/* Copied from https://github.com/0xPolygonHermez/rust/blob/c03068e/compiler/rustc_target/src/spec/targets/riscv64ima_zisk_zkvm_elf_linker_script.ld */ + +OUTPUT_FORMAT("elf64-littleriscv") +OUTPUT_ARCH("riscv") +ENTRY(_start) + +MEMORY { + rom (xa) : ORIGIN = 0x80000000, LENGTH = 0x10000000 + ram (wxa) : ORIGIN = 0xa0020000, LENGTH = 0x1FFE0000 +} + +PHDRS { + text PT_LOAD FLAGS(5); + rodata PT_LOAD FLAGS(4); + data PT_LOAD FLAGS(6); + bss PT_LOAD FLAGS(6); + output_data PT_LOAD FLAGS(6); +} + +_stack_size = 0x400000; /* 4 MB reserved */ +_output_data_size = 0x10000; /* 64 KB reserved */ +_float_ram_data_size = 0x10000; /* 64 KB reserved */ + +/* + +0xA0000000 ┌────────────────────┐ + │ .general_registers │ 64 KB reserved (NOLOAD) + │ 0x10000 bytes │ _general_registers_start / _end +0xA0010000 ├────────────────────┤ + │ .float_registers │ 64 KB reserved (NOLOAD) + │ 0x10000 bytes │ _float_registers_start / _end +0xA001FFFF └────────────────────┘ ← _kernel_heap_top +0xA0020000 ┌────────────────────┐ + │ .output_data │ 64 KB reserved (NOLOAD) + │ 0x10000 bytes │ _output_data_start / _end +0xA0030000 ├────────────────────┤ + │ .data │ + │ .bss │ + ├────────────────────┤ ← _bss_end + │ stack ↑ 4MB │ + ├────────────────────┤ ← _init_stack_top = _kernel_heap_bottom + │ heap ↓ │ + │ │ +0xBFFEFFFF │ │ +0xBFFF0000 ├────────────────────┤ ← _kernel_heap_top + │ float ram │ +0xC0000000 └────────────────────┘ + +*/ + +SECTIONS +{ + .text : { *(.text.init) *(.text .text.*)} >rom AT>rom :text + + . = ALIGN(8); + PROVIDE(_global_pointer = .); + .rodata : { *(.rodata .rodata.*)} >rom AT>rom :rodata + + /* reserved space for output data */ + + .output_data (NOLOAD) : { + PROVIDE(_output_data_start = .); + . = . + _output_data_size; + PROVIDE(_output_data_end = .); + } >ram AT>ram :output_data + + .data : { *(.data .data.* .sdata .sdata.*) } >ram AT>ram :data + + .bss : { + PROVIDE(_bss_start = .); + *(.bss .bss.*); + PROVIDE(_bss_end = .); # ... and one at the end + } >ram AT>ram :bss + + . = ALIGN(8); + PROVIDE(_init_stack_top = . + _stack_size); # reserve 4M bytes for the initialisation stack + + PROVIDE(_kernel_heap_bottom = _init_stack_top); + PROVIDE(_kernel_heap_top = ORIGIN(ram) + LENGTH(ram) - _float_ram_data_size); + PROVIDE(_kernel_heap_size = _kernel_heap_top - _kernel_heap_bottom); + + _end = .; +} diff --git a/crates/zkvm/zisk/src/compiler/rust_rv64ima/riscv64ima-unknown-none-elf.json b/crates/zkvm/zisk/src/compiler/rust_rv64ima/riscv64ima-unknown-none-elf.json new file mode 100644 index 00000000..9f105d4f --- /dev/null +++ b/crates/zkvm/zisk/src/compiler/rust_rv64ima/riscv64ima-unknown-none-elf.json @@ -0,0 +1,25 @@ +{ + "arch": "riscv64", + "atomic-cas": true, + "code-model": "medium", + "cpu": "generic-rv64", + "crt-objects-fallback": "false", + "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128", + "eh-frame-header": false, + "emit-debug-gdb-scripts": false, + "features": "+m,+forced-atomics", + "linker": "rust-lld", + "linker-flavor": "gnu-lld", + "llvm-abiname": "lp64", + "llvm-target": "riscv64", + "max-atomic-width": 64, + "metadata": { + "description": "Bare RISC-V (RV64IM ISA)", + "host_tools": false, + "std": false, + "tier": 3 + }, + "panic-strategy": "abort", + "relocation-model": "static", + "target-pointer-width": 64 +} diff --git a/crates/zkvm/zisk/src/lib.rs b/crates/zkvm/zisk/src/lib.rs index 2eebb95f..ba233acb 100644 --- a/crates/zkvm/zisk/src/lib.rs +++ b/crates/zkvm/zisk/src/lib.rs @@ -5,8 +5,7 @@ //! To install all requirements, run [`install_zisk_sdk.sh`] from the Ere //! repository at the same git revision as your `ere-zisk` dependency. //! -//! To install `cargo-zisk-cuda` (with GPU proving support), make sure CUDA 12.9 -//! is installed, run [`install_zisk_sdk.sh`] with env `CUDA=1` set. +//! GPU proving requires the `cuda` Cargo feature and CUDA 12.9 installed. //! //! ## `Compiler` requirements //! @@ -16,17 +15,16 @@ //! ## `zkVM` requirements //! //! - Installation via [`ziskup`] -//! - `cargo-zisk-cuda` - Used by `zkVM::prove` if `ProverResource::Gpu` is -//! selected //! //! # `Compiler` implementation //! //! ## Available compilers //! -//! | Compiler | Language | Target | Note | -//! | ----------------------- | :------: | -------------------------- | ------------------ | -//! | `RustRv64imaCustomized` | Rust | `riscv64ima-zisk-zkvm-elf` | With `std` support | -//! | `GoCustomized` | Go | `riscv64` | | +//! | Compiler | Language | Target | Note | +//! | ----------------------- | :------: | ----------------------------- | ------------------ | +//! | `RustRv64imaCustomized` | Rust | `riscv64ima-zisk-zkvm-elf` | With `std` support | +//! | `RustRv64ima` | Rust | `riscv64ima-unknown-none-elf` | | +//! | `GoCustomized` | Go | `riscv64` | | //! //! # `zkVM` implementation //! @@ -43,18 +41,14 @@ //! //! | Variable | Type | Default | Description | //! | -------------------------------------- | ----- | ------- | ---------------------------------------------------------------------- | -//! | `ERE_ZISK_SETUP_ON_INIT` | Flag | | Trigger ROM setup at initialization instead of lazily | -//! | `ERE_ZISK_PORT` | Value | | Pass `--port {port}` to the server | -//! | `ERE_ZISK_UNLOCK_MAPPED_MEMORY` | Flag | | Pass `--unlock-mapped-memory` to the server | -//! | `ERE_ZISK_MINIMAL_MEMORY` | Flag | | Pass `--minimal_memory` to the server | -//! | `ERE_ZISK_PREALLOCATE` | Flag | | Pass `--preallocate` to the server | -//! | `ERE_ZISK_SHARED_TABLES` | Flag | | Pass `--shared-tables` to the server | -//! | `ERE_ZISK_MAX_STREAMS` | Value | | Pass `--max-streams {max_streams}` to the server | -//! | `ERE_ZISK_NUMBER_THREADS_WITNESS` | Value | | Pass `--number-threads-witness {number_threads_witness}` to the server | -//! | `ERE_ZISK_MAX_WITNESS_STORED` | Value | | Pass `--max-witness-stored {max_witness_stored}` to the server | -//! | `ERE_ZISK_START_SERVER_TIMEOUT_SEC` | Value | `120` | Timeout waiting for server to start | -//! | `ERE_ZISK_SHUTDOWN_SERVER_TIMEOUT_SEC` | Value | `30` | Timeout for server shutdown | -//! | `ERE_ZISK_PROVE_TIMEOUT_SEC` | Value | `3600` | Timeout for proof generation | +//! | `ERE_ZISK_SETUP_ON_INIT` | Flag | | Setup local prover on initialization instead of lazily | +//! | `ERE_ZISK_UNLOCK_MAPPED_MEMORY` | Flag | | Configure the prover to unlock mapped memory | +//! | `ERE_ZISK_MINIMAL_MEMORY` | Flag | | Configure the prover to use minimal memory | +//! | `ERE_ZISK_PREALLOCATE` | Flag | | Configure the prover to preallocate memory | +//! | `ERE_ZISK_SHARED_TABLES` | Flag | | Configure the prover to use shared tables | +//! | `ERE_ZISK_MAX_STREAMS` | Value | | Configure the prover max streams | +//! | `ERE_ZISK_NUMBER_THREADS_WITNESS` | Value | | Configure the prover number of witness threads | +//! | `ERE_ZISK_MAX_WITNESS_STORED` | Value | | Configure the prover max witness stored | //! //! [`install_zisk_sdk.sh`]: https://github.com/eth-act/ere/blob/master/scripts/sdk_installers/install_zisk_sdk.sh //! [`install_tamago.sh`]: https://github.com/eth-act/ere/blob/master/scripts/install_tamago.sh diff --git a/crates/zkvm/zisk/src/zkvm.rs b/crates/zkvm/zisk/src/zkvm.rs index 8f97754c..816406c8 100644 --- a/crates/zkvm/zisk/src/zkvm.rs +++ b/crates/zkvm/zisk/src/zkvm.rs @@ -1,18 +1,17 @@ use crate::{ program::ZiskProgram, - zkvm::sdk::{RomDigest, ZiskSdk}, + zkvm::sdk::{ProgramVk, ZiskSdk}, }; use anyhow::bail; use ere_zkvm_interface::zkvm::{ CommonError, Input, ProgramExecutionReport, ProgramProvingReport, Proof, ProofKind, ProverResource, PublicValues, zkVM, zkVMProgramDigest, }; +use mpi as _; // Import symbols referenced by starks_api.cpp use std::time::Instant; -mod cluster_client; mod error; mod sdk; -mod server; pub use error::Error; @@ -98,10 +97,10 @@ impl zkVM for EreZisk { } impl zkVMProgramDigest for EreZisk { - type ProgramDigest = RomDigest; + type ProgramDigest = ProgramVk; fn program_digest(&self) -> anyhow::Result { - Ok(self.sdk.rom_digest()?) + Ok(self.sdk.program_vk()) } } @@ -120,8 +119,6 @@ mod tests { }; use std::sync::{Mutex, OnceLock}; - /// It fails if multiple servers created concurrently using the same port, - /// so we have a lock to avoid that. static PROVE_LOCK: Mutex<()> = Mutex::new(()); fn basic_program() -> ZiskProgram { @@ -157,30 +154,68 @@ mod tests { } } + #[cfg(not(feature = "cuda"))] #[test] fn test_prove() { + let _guard = PROVE_LOCK.lock().unwrap(); + let program = basic_program(); let zkvm = EreZisk::new(program, ProverResource::Cpu).unwrap(); - let _guard = PROVE_LOCK.lock().unwrap(); - let test_case = BasicProgram::::valid_test_case(); run_zkvm_prove(&zkvm, &test_case); } + #[cfg(not(feature = "cuda"))] #[test] fn test_prove_invalid_test_case() { + let _guard = PROVE_LOCK.lock().unwrap(); + let program = basic_program(); let zkvm = EreZisk::new(program, ProverResource::Cpu).unwrap(); + for input in [ + Input::new(), + BasicProgram::::invalid_test_case().input(), + ] { + zkvm.prove(&input, ProofKind::default()).unwrap_err(); + } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_gpu() { + let _guard = PROVE_LOCK.lock().unwrap(); + + let program = basic_program(); + let zkvm = EreZisk::new(program, ProverResource::Gpu).unwrap(); + + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); + } + + #[cfg(feature = "cuda")] + #[test] + fn test_prove_invalid_test_case_gpu() { let _guard = PROVE_LOCK.lock().unwrap(); + let program = basic_program(); + let zkvm = EreZisk::new(program, ProverResource::Gpu).unwrap(); + for input in [ Input::new(), BasicProgram::::invalid_test_case().input(), ] { zkvm.prove(&input, ProofKind::default()).unwrap_err(); } + + // Should be able to recover + let test_case = BasicProgram::::valid_test_case(); + run_zkvm_prove(&zkvm, &test_case); } #[test] diff --git a/crates/zkvm/zisk/src/zkvm/error.rs b/crates/zkvm/zisk/src/zkvm/error.rs index 995f891b..c4464d47 100644 --- a/crates/zkvm/zisk/src/zkvm/error.rs +++ b/crates/zkvm/zisk/src/zkvm/error.rs @@ -1,5 +1,6 @@ -use crate::zkvm::sdk::RomDigest; +use crate::zkvm::sdk::ProgramVk; use ere_zkvm_interface::zkvm::CommonError; +use proofman_common::ProofmanError; use thiserror::Error; #[derive(Debug, Error)] @@ -7,29 +8,53 @@ pub enum Error { #[error(transparent)] CommonError(#[from] CommonError), - // Execution - #[error("Total steps not found in execution report")] - TotalStepsNotFound, + // Common + #[error("Invalid env variable {key}, expected usize, got {value}")] + InvalidEnvVar { key: &'static str, value: String }, - // Rom setup - #[error("Failed to find ROM digest in output")] - RomDigestNotFound, + #[error("Enable `cuda` feature to use `ProverResource::Gpu`")] + CudaFeatureDisabled, - #[error("`cargo-zisk rom-setup` failed in another thread")] - RomSetupFailedBefore, + #[error("Disable `cuda` feature to use `ProverResource::Cpu`")] + CudaFeatureEnabled, - // Prove - #[error("Server crashed")] - ServerCrashed, + // Emulator + #[error("ROM transpilation failed: {0}")] + Riscv2zisk(String), - #[error("Timeout waiting for server proving")] - TimeoutWaitingServerProving, + #[error("Emulation not terminated")] + EmulatorNotTerminated, - #[error("Timeout waiting for server ready")] - TimeoutWaitingServerReady, + #[error("Emulation failure")] + EmulatorError, - #[error("Unknown server status, stdout: {stdout}")] - UnknownServerStatus { stdout: String }, + #[error("Emulator panicked: {0}")] + EmulatorPanic(String), + + // SDK + #[error("Create ProofCtx failed: {0}")] + ProofCtx(#[source] ProofmanError), + + #[error("Generate assembly failed: {0}")] + GenerateAssembly(String), + + #[error("Compute program VK failed: {0}")] + ComputeProgramVk(#[source] anyhow::Error), + + #[error("Invalid program VK length, expected 32, got {0}")] + InvalidProgramVkLength(usize), + + #[error("Initialize prover failed: {0}")] + InitProver(#[source] anyhow::Error), + + #[error("Setup prover failed: {0}")] + SetupProver(#[source] anyhow::Error), + + #[error("Prove failed: {0}")] + Prove(#[source] anyhow::Error), + + #[error("Prove panicked: {0}")] + ProvePanic(String), // Cluster #[error("Invalid cluster endpoint: {0}")] @@ -44,6 +69,9 @@ pub enum Error { #[error("Cluster error: {0}")] ClusterError(String), + #[error("Invalid proof format: {0}")] + InvalidProofFormat(anyhow::Error), + // Verify #[error("Invalid proof")] InvalidProof, @@ -51,15 +79,9 @@ pub enum Error { #[error("Invalid proof size {0}, expected a multiple of 8")] InvalidProofSize(usize), - #[error("Invalid public value format")] - InvalidPublicValue, - - #[error("Public values length {0}, but expected at least 6")] - InvalidPublicValuesLength(usize), - - #[error("Unexpected ROM digest - preprocessed: {preprocessed:?}, proved: {proved:?}")] - UnexpectedRomDigest { - preprocessed: RomDigest, - proved: RomDigest, + #[error("Unexpected program VK - preprocessed: {preprocessed:?}, proved: {proved:?}")] + UnexpectedProgramVk { + preprocessed: ProgramVk, + proved: ProgramVk, }, } diff --git a/crates/zkvm/zisk/src/zkvm/sdk.rs b/crates/zkvm/zisk/src/zkvm/sdk.rs index 9d697a42..952ead30 100644 --- a/crates/zkvm/zisk/src/zkvm/sdk.rs +++ b/crates/zkvm/zisk/src/zkvm/sdk.rs @@ -1,80 +1,75 @@ -use crate::zkvm::Error; -use crate::zkvm::cluster_client::ClusterClient; -use crate::zkvm::server::{ZiskServer, ZiskServerOptions}; +use crate::zkvm::{ + Error, + sdk::{cluster::ClusterClient, local::LocalProver}, +}; +use bytemuck::cast_slice; use ere_zkvm_interface::zkvm::{CommonError, ProverResource, ProverResourceKind, PublicValues}; -use std::borrow::Cow; -use std::path::Path; -use std::process::Command; +use proofman_common::{ + MpiCtx, ParamsGPU, ProofCtx, ProofType, SetupCtx, SetupsVadcop, VerboseMode, +}; +use proofman_fields::Goldilocks; +use proofman_starks_lib_c::free_device_buffers_c; +use proofman_util::VadcopFinalProof; +use proofman_verifier::verify_vadcop_final; use std::{ - env, fs, - io::BufRead, - mem::transmute, + any::Any, + env, + mem::ManuallyDrop, + panic::{self, AssertUnwindSafe}, path::PathBuf, - sync::OnceLock, - time::{Duration, Instant}, + sync::Arc, + time::Duration, }; use tempfile::tempdir; -use tracing::info; +use zisk_core::{Riscv2zisk, ZiskRom}; +use zisk_rom_setup::rom_merkle_setup; +use zisk_sdk::{ElfBinaryFromFile, ZISK_PUBLICS, ZiskProofWithPublicValues}; +use ziskemu::{Emu, EmuOptions}; -/// Verifying key of the aggregation proof. -/// -/// Extracted from `$HOME/.zisk/provingKey/zisk/vadcop_final/vadcop_final.verkey.json`. -pub const VADCOP_FINAL_VK: [u8; 32] = unsafe { - // Use `transmute` to keep the endianness because `zisk_proofman_verifier::verify` will - // use `bytemuck` to cast it to `[u64; 4]`. - transmute([ - 723851053263266420u64, - 2272245643171245153u64, - 9868173762158752255u64, - 6004219199197288727u64, - ]) -}; +mod cluster; +mod local; -/// Merkle root of ROM trace generated by `cargo-zisk rom-setup`. -pub type RomDigest = [u64; 4]; +/// Merkle root of ROM trace. +pub type ProgramVk = [u8; 32]; +/// Verifying key of the aggregation proof. +pub const VADCOP_FINAL_VK: [u64; 4] = [ + 9211010158316595036, + 7055235338110277438, + 2391371252028311145, + 10691781997660262077, +]; + +/// Prover backend - either local or cluster. +#[allow(clippy::large_enum_variant)] pub enum ZiskProver { - Server(ZiskServer), + Local(LocalProver), Cluster(ClusterClient), } pub struct ZiskSdk { - elf_path: PathBuf, resource: ProverResource, - /// ROM digest will be setup when `ZiskSdk::prove` or `ZiskSdk::verify` - /// is called, or if env variable `ERE_ZISK_SETUP_ON_INIT` is set. - /// - /// Use `Option` inside because ROM setup might fail, we can get rid of - /// it if `OnceLock::get_or_try_init` is stabilized. - rom_digest: OnceLock>, - /// Prover instance, either a local server or a cluster client. + rom: ZiskRom, + program_vk: ProgramVk, prover: ZiskProver, } impl ZiskSdk { /// Returns SDK for the ELF. pub fn new(elf: Vec, resource: ProverResource) -> Result { - // Save ELF to `~/.zisk/cache` along with the ROM binaries, to avoid it - // been cleaned up during a long run process. - let cache_dir_path = dot_zisk_dir_path().join("cache"); - fs::create_dir_all(&cache_dir_path) - .map_err(|err| CommonError::create_dir("cache", &cache_dir_path, err))?; - - // Use blake3 hash as the ELF file name, since ROM setup uses blake3 as - // unique identifier as well. - let elf_hash = blake3::hash(&elf); - let elf_path = cache_dir_path.join(format!("{elf_hash}.elf")); + // Convert ELF to ZisK ROM + let rom = Riscv2zisk::new(&elf) + .run() + .map_err(|e| Error::Riscv2zisk(e.to_string()))?; - fs::write(&elf_path, elf).map_err(|err| CommonError::write_file("elf", &elf_path, err))?; + // Compute program VK + let program_vk = compute_program_vk(&elf)?; + // Initialize prover let prover = match &resource { - ProverResource::Cpu | ProverResource::Gpu => ZiskProver::Server(ZiskServer::new( - &elf_path, - resource.is_gpu(), - ZiskServerOptions::from_env(), - )), + ProverResource::Cpu | ProverResource::Gpu => ZiskProver::Local(LocalProver::new(elf)?), ProverResource::Cluster(config) => ZiskProver::Cluster(ClusterClient::new(config)?), - _ => Err(CommonError::unsupported_prover_resource_kind( + ProverResource::Network(_) => Err(CommonError::unsupported_prover_resource_kind( resource.kind(), [ ProverResourceKind::Cpu, @@ -84,137 +79,96 @@ impl ZiskSdk { ))?, }; - let sdk = Self { - elf_path, + Ok(Self { resource, - rom_digest: OnceLock::new(), + rom, + program_vk, prover, - }; + }) + } - if env::var_os("ERE_ZISK_SETUP_ON_INIT").is_some() { - sdk.rom_digest()?; + pub fn program_vk(&self) -> ProgramVk { + self.program_vk + } - if let ZiskProver::Server(server) = &sdk.prover { - server.ensure_ready()?; - } - } + /// Execute the ELF with the given `stdin`. + pub fn execute(&self, stdin: &[u8]) -> Result<(PublicValues, u64), Error> { + let stdin = length_prefixed_and_padded(stdin); + let mut emu = Emu::new(&self.rom); + emu.ctx = emu.create_emu_context(stdin, &EmuOptions::default()); - Ok(sdk) - } + panic::catch_unwind(AssertUnwindSafe(|| emu.run_fast(&EmuOptions::default()))) + .map_err(|err| Error::EmulatorPanic(panic_msg(err)))?; - /// Execute the ELF with the given `input`. - pub fn execute(&self, input: &[u8]) -> Result<(PublicValues, u64), Error> { - let tempdir = tempdir().map_err(CommonError::tempdir)?; - let input_path = tempdir.path().join("input"); - let output_path = tempdir.path().join("output"); - - fs::write(&input_path, input) - .map_err(|err| CommonError::write_file("input", &input_path, err))?; - - let mut cmd = Command::new("ziskemu"); - let output = cmd - .arg("--elf") - .arg(&self.elf_path) - .arg("--inputs") - .arg(input_path) - .arg("--output") - .arg(&output_path) - .arg("--stats") // Enable stats in order to get total steps. - .output() - .map_err(|err| CommonError::command(&cmd, err))?; - - if !output.status.success() { - return Err(CommonError::command_exit_non_zero( - &cmd, - output.status, - Some(&output), - ))?; + if !emu.ctx.inst_ctx.end { + return Err(Error::EmulatorNotTerminated); } - // Extract cycle count from the stdout. - - let total_num_cycles = String::from_utf8_lossy(&output.stdout) - .split_once("STEPS") - .and_then(|(_, stats)| { - stats - .split_whitespace() - .next() - .and_then(|steps| steps.replace(",", "").parse::().ok()) - }) - .ok_or(Error::TotalStepsNotFound)?; + if emu.ctx.inst_ctx.error { + return Err(Error::EmulatorError); + } - let public_values = fs::read(&output_path) - .map_err(|err| CommonError::read_file("output", &output_path, err))?; + let public_values = emu.get_output_8(); + let total_num_cycles = emu.number_of_steps(); Ok((public_values, total_num_cycles)) } - /// Returns the ROM digest of the ELF. - /// - /// If it is not setup yet, it makes sure the global setup is done, then - /// does ROM setup of the ELF and stores the ROM digest for later usage. - pub fn rom_digest(&self) -> Result { - // FIXME: Use `get_or_try_init` when it is stabilized - let mut result = Ok(()); - let rom_digest = *self.rom_digest.get_or_init(|| { - check_setup(self.resource.is_gpu()) - .and_then(|_| rom_setup(&self.elf_path)) - .map_err(|err| result = Err(err)) - .ok() - }); - result?; - rom_digest.ok_or(Error::RomSetupFailedBefore) - } - - /// Prove the ELF with the given input. + /// Prove the ELF with the given stdin. /// /// Returns the public values, proof, and proving time. - pub fn prove(&self, input: &[u8]) -> Result<(PublicValues, Vec, Duration), Error> { - let (proof, proving_time) = match &self.prover { - ZiskProver::Cluster(client) => client.prove(input)?, - ZiskProver::Server(server) => { - self.rom_digest()?; - - let start = Instant::now(); - let proof = server.prove(input)?; - let proving_time = start.elapsed(); + pub fn prove(&self, stdin: &[u8]) -> Result<(PublicValues, Vec, Duration), Error> { + match &self.resource { + ProverResource::Cpu if cfg!(feature = "cuda") => Err(Error::CudaFeatureEnabled)?, + ProverResource::Gpu if cfg!(not(feature = "cuda")) => Err(Error::CudaFeatureDisabled)?, + _ => {} + }; - (proof, proving_time) - } + let stdin = length_prefixed_and_padded(stdin); + let (proof, proving_time) = match &self.prover { + ZiskProver::Local(local) => local.prove(&stdin)?, + ZiskProver::Cluster(client) => client.prove(&stdin)?, }; - // Deserialize public values. - let (proved_rom_digest, public_values) = deserialize_public_values(&proof)?; + // Extract public values and program_vk + let (public_values, proved_program_vk) = extract_public_values_and_program_vk(&proof)?; - // The proved ROM digest should be equal to preprocessed one. - let rom_digest = self.rom_digest()?; - if proved_rom_digest != rom_digest { - return Err(Error::UnexpectedRomDigest { - preprocessed: rom_digest, - proved: proved_rom_digest, + // The proved program VK should match the preprocessed + if proved_program_vk != self.program_vk { + return Err(Error::UnexpectedProgramVk { + preprocessed: self.program_vk, + proved: proved_program_vk, }); } - Ok((public_values, proof, proving_time)) + Ok(( + public_values, + bincode::serde::encode_to_vec(&proof, bincode::config::legacy()) + .map_err(|err| CommonError::serialize("proof", "bincode", err))?, + proving_time, + )) } /// Verify the proof of the ELF, and returns public values. pub fn verify(&self, proof: &[u8]) -> Result { - let proof = align_to_u64(proof)?; - - if !zisk_proofman_verifier::verify(&proof, &VADCOP_FINAL_VK) { - Err(Error::InvalidProof)? + let proof: ZiskProofWithPublicValues = + bincode::serde::decode_from_slice(proof, bincode::config::legacy()) + .map_err(|err| CommonError::deserialize("proof", "bincode", err))? + .0; + + let vadcop_final_proof = vadcop_final_proof_aligned(&proof)?; + if !verify_vadcop_final(&vadcop_final_proof, cast_slice(&VADCOP_FINAL_VK)) { + return Err(Error::InvalidProof); } - // Deserialize public values. - let (proved_rom_digest, public_values) = deserialize_public_values(&proof)?; + // Extract public values and program_vk + let (public_values, proved_program_vk) = extract_public_values_and_program_vk(&proof)?; - // The proved ROM digest should be equal to preprocessed one. - let rom_digest = self.rom_digest()?; - if proved_rom_digest != rom_digest { - return Err(Error::UnexpectedRomDigest { - preprocessed: rom_digest, - proved: proved_rom_digest, + // The proved program VK should match the preprocessed + if proved_program_vk != self.program_vk { + return Err(Error::UnexpectedProgramVk { + preprocessed: self.program_vk, + proved: proved_program_vk, }); } @@ -222,127 +176,113 @@ impl ZiskSdk { } } -/// Does global setup if it is not done yet. -fn check_setup(cuda: bool) -> Result<(), Error> { - info!("Running command `cargo-zisk check-setup --aggregation`..."); - - let cargo_zisk = if cuda { - "cargo-zisk-cuda" - } else { - "cargo-zisk" - }; - - let mut cmd = Command::new(cargo_zisk); - let output = cmd - .args(["check-setup", "--aggregation"]) - .output() - .map_err(|err| CommonError::command(&cmd, err))?; - - if !output.status.success() { - Err(CommonError::command_exit_non_zero( - &cmd, - output.status, - Some(&output), - ))?; - } - - info!("Command `cargo-zisk check-setup --aggregation` succeeded"); +fn compute_program_vk(elf: &[u8]) -> Result { + let mpi_ctx = Arc::new(MpiCtx::new()); + let mut pctx = ProofCtx::create_ctx(proving_key_dir(), false, VerboseMode::Info, mpi_ctx) + .map_err(Error::ProofCtx)?; + let mut params = ParamsGPU::new(false); + params.with_max_number_streams(1); + let sctx = SetupCtx::new(&pctx.global_info, &ProofType::Basic, false, ¶ms, &[]); + let setups_vadcop = SetupsVadcop::new(&pctx.global_info, false, false, ¶ms, &[]); + + let result = (|| { + pctx.set_device_buffers(&sctx, &setups_vadcop, false, ¶ms) + .map_err(Error::ProofCtx)?; + + let elf = ElfBinaryFromFile { + elf: elf.to_vec(), + name: String::new(), + with_hints: false, + path: None, + }; - Ok(()) -} + let tempdir = tempdir().map_err(CommonError::tempdir)?; -/// Does ROM setup of the ELF and returns the ROM digest. -fn rom_setup(elf_path: &Path) -> Result { - info!("Running command `cargo-zisk rom-setup` ..."); - - let mut cmd = Command::new("cargo-zisk"); - let output = cmd - .arg("rom-setup") - .arg("--elf") - .arg(elf_path) - .output() - .map_err(|err| CommonError::command(&cmd, err))?; - - if !output.status.success() { - Err(CommonError::command_exit_non_zero( - &cmd, - output.status, - Some(&output), - ))?; - } + let (_, program_vk) = + rom_merkle_setup::(&pctx, &elf, &Some(tempdir.path().to_path_buf())) + .map_err(Error::ComputeProgramVk)?; - // Parse the ROM digest from the stdout. - let rom_digest = output - .stdout - .lines() - .find_map(|line| { - let line = line.ok()?; - let line = line.split_once("Root hash: [")?.1; - let line = line.strip_suffix("]")?; - line.split(", ") - .filter_map(|word| word.parse::().ok()) - .collect::>() - .try_into() - .ok() - }) - .ok_or(Error::RomDigestNotFound)?; + Ok(program_vk) + })(); - info!("Command `cargo-zisk rom-setup` succeeded"); + free_device_buffers_c(pctx.get_device_buffers_ptr()); - Ok(rom_digest) + result.and_then(|program_vk| program_vk_from_slice(&program_vk)) } -/// Deserialize public values as json string sequence, and parse the `RomDigest` -/// and user set public values as `Vec`. -fn deserialize_public_values(proof: &[u8]) -> Result<(RomDigest, Vec), Error> { - let proof = align_to_u64(proof)?; - let proof = bytemuck::cast_slice::(&proof); +fn extract_public_values_and_program_vk( + proof: &ZiskProofWithPublicValues, +) -> Result<(PublicValues, ProgramVk), Error> { + let program_vk = program_vk_from_slice(&proof.get_program_vk().vk)?; - // The public values contain at least the the total number of public values, - // `RomDigest`, and the number of user set public values. - if proof.len() < 6 { - return Err(Error::InvalidPublicValuesLength(proof.len())); - } + let mut public_values = vec![0; ZISK_PUBLICS * 4]; + proof.get_publics().read_slice(&mut public_values); + proof.get_publics().head(); - // The first element is total number of public values. - - // The next 4 elements of public values should be ROM digest. - let rom_digest = proof[1..5].try_into().unwrap(); - - // The next element should be the number of user set public values. - let num_user_public_values = proof[5] as usize; + Ok((public_values, program_vk)) +} - // The rest elements should be user set public values and should be `u32`. - let public_values = proof[6..] - .iter() - .map(|v| Some(u32::try_from(*v).ok()?.to_le_bytes())) - .take(num_user_public_values) - .collect::>>() - .ok_or(Error::InvalidPublicValue)? - .into_iter() - .flatten() - .collect(); +fn program_vk_from_slice(program_vk: &[u8]) -> Result { + (program_vk.len() == 32) + .then(|| program_vk.try_into().unwrap()) + .ok_or_else(|| Error::InvalidProgramVkLength(program_vk.len())) +} - Ok((rom_digest, public_values)) +fn vadcop_final_proof_aligned( + proof: &ZiskProofWithPublicValues, +) -> Result { + let mut vadcop_final_proof = proof + .get_vadcop_final_proof() + .map_err(Error::InvalidProofFormat)?; + vadcop_final_proof.proof = align_to_u64(vadcop_final_proof.proof)?; + vadcop_final_proof.public_values = align_to_u64(vadcop_final_proof.public_values)?; + Ok(vadcop_final_proof) } /// Returns u64-aligned bytes. /// /// Returns an error if `data.len()` is not a multiple of 8. -fn align_to_u64(data: &[u8]) -> Result, Error> { +fn align_to_u64(data: Vec) -> Result, Error> { if !data.len().is_multiple_of(8) { return Err(Error::InvalidProofSize(data.len())); } Ok(if data.as_ptr().cast::().is_aligned() { - Cow::Borrowed(data) + data } else { - let mut aligned: Vec = vec![0; data.len() / 8]; - bytemuck::cast_slice_mut(&mut aligned).copy_from_slice(data); - Cow::Owned(bytemuck::cast_slice(&aligned).to_vec()) + let mut aligned = ManuallyDrop::new(vec![0u64; data.len() / 8]); + bytemuck::cast_slice_mut(&mut aligned).copy_from_slice(&data); + let ptr = aligned.as_mut_ptr().cast::(); + let len = aligned.len() * size_of::(); + let cap = aligned.capacity() * size_of::(); + // SAFETY: `ptr` came from a `Vec` allocation. + unsafe { Vec::from_raw_parts(ptr, len, cap) } }) } +/// Returns `data` with a LE u64 length prefix and padding to multiple of 8. +/// +/// The length prefix and padding is expected by ZisK emulator/prover runtime. +fn length_prefixed_and_padded(data: &[u8]) -> Vec { + let len = (8 + data.len()).next_multiple_of(8); + let mut buf = Vec::with_capacity(len); + buf.extend_from_slice(&(data.len() as u64).to_le_bytes()); + buf.extend_from_slice(data); + buf.resize(len, 0); + buf +} + +fn panic_msg(err: Box) -> String { + None.or_else(|| err.downcast_ref::().cloned()) + .or_else(|| err.downcast_ref::<&'static str>().map(ToString::to_string)) + .unwrap_or_else(|| "unknown panic msg".to_string()) +} + /// Returns path to `~/.zisk` directory. -pub(crate) fn dot_zisk_dir_path() -> PathBuf { +fn dot_zisk_dir() -> PathBuf { PathBuf::from(env::var("HOME").expect("env `$HOME` should be set")).join(".zisk") } + +/// Returns path to `~/.zisk/provingKey` directory. +fn proving_key_dir() -> PathBuf { + dot_zisk_dir().join("provingKey") +} diff --git a/crates/zkvm/zisk/src/zkvm/cluster_client.rs b/crates/zkvm/zisk/src/zkvm/sdk/cluster.rs similarity index 83% rename from crates/zkvm/zisk/src/zkvm/cluster_client.rs rename to crates/zkvm/zisk/src/zkvm/sdk/cluster.rs index dcc36e7d..7c252d2a 100644 --- a/crates/zkvm/zisk/src/zkvm/cluster_client.rs +++ b/crates/zkvm/zisk/src/zkvm/sdk/cluster.rs @@ -7,10 +7,11 @@ use std::time::Duration; use tonic::transport::Channel; use tracing::debug; use zisk_distributed_grpc_api::{ - ErrorResponse, InputMode, LaunchProofRequest, ProofStatusType, SubscribeToProofRequest, - SystemStatusRequest, launch_proof_response, system_status_response, + ErrorResponse, HintsMode, InputMode, LaunchProofRequest, ProofStatusType, + SubscribeToProofRequest, SystemStatusRequest, launch_proof_response, system_status_response, zisk_distributed_api_client::ZiskDistributedApiClient, }; +use zisk_sdk::ZiskProofWithPublicValues; /// Wrapper for the ZisK cluster client. /// @@ -27,14 +28,17 @@ impl ClusterClient { } /// Sync wrapper for [`Self::prove_async`]. - pub fn prove(&self, input: &[u8]) -> Result<(Vec, Duration), Error> { + pub fn prove(&self, input: &[u8]) -> Result<(ZiskProofWithPublicValues, Duration), Error> { block_on(self.prove_async(input)) } /// Send proof request to cluster and wait for completion. /// - /// Returns the proof and proving time reported by the cluster. - async fn prove_async(&self, input: &[u8]) -> Result<(Vec, Duration), Error> { + /// Returns the proof with public values and proving time reported by the cluster. + async fn prove_async( + &self, + input: &[u8], + ) -> Result<(ZiskProofWithPublicValues, Duration), Error> { let mut client = self.client.clone(); // Check system status to get available compute capacity @@ -80,9 +84,12 @@ impl ClusterClient { let launch_request = LaunchProofRequest { data_id, compute_capacity, - input_mode: InputMode::Data.into(), - input_path: None, + minimal_compute_capacity: compute_capacity, + inputs_mode: InputMode::Data.into(), + inputs_uri: None, input_data: Some(input.to_vec()), + hints_mode: HintsMode::None.into(), + hints_uri: None, simulated_node: None, }; @@ -120,16 +127,19 @@ impl ClusterClient { match ProofStatusType::try_from(update.status) { Ok(ProofStatusType::ProofStatusCompleted) => match update.final_proof { Some(final_proof) => { - let proof = bytemuck::cast_slice(&final_proof.values).to_vec(); + let proof_with_publics = ZiskProofWithPublicValues::new_from_vadcop_proof( + &final_proof.values, + false, + ) + .map_err(Error::InvalidProofFormat)?; let proving_time = Duration::from_millis(update.duration_ms); debug!( - proof_size = proof.len(), proving_time = ?proving_time, "Proof generated successfully" ); - Ok((proof, proving_time)) + Ok((proof_with_publics, proving_time)) } None => Err(cluster_error("Missing final proof")), }, diff --git a/crates/zkvm/zisk/src/zkvm/sdk/local.rs b/crates/zkvm/zisk/src/zkvm/sdk/local.rs new file mode 100644 index 00000000..ee7b9ab5 --- /dev/null +++ b/crates/zkvm/zisk/src/zkvm/sdk/local.rs @@ -0,0 +1,187 @@ +use crate::zkvm::{ + Error, + sdk::{dot_zisk_dir, panic_msg}, +}; +use blake3::Hash; +use ere_zkvm_interface::zkvm::CommonError; +use parking_lot::{Mutex, MutexGuard}; +use proofman_common::ParamsGPU; +use std::{env, panic, path::PathBuf, process::Command, thread::sleep, time::Duration}; +use tempfile::tempdir; +use tracing::info; +use zisk_rom_setup::generate_assembly; +use zisk_sdk::{ + Asm, ElfBinaryFromFile, ProofOpts, ProverClientBuilder, ZiskProgramPK, + ZiskProofWithPublicValues, ZiskProver, ZiskStdin, +}; + +const ELF_NAME: &str = "elf"; + +struct Config { + preallocate: bool, + unlock_mapped_memory: bool, + minimal_memory: bool, + shared_tables: bool, + max_streams: Option, + number_threads_witness: Option, + max_witness_stored: Option, +} + +impl Config { + fn from_env() -> Result { + let parse_usize = |key| { + env::var(key) + .ok() + .map(|value| { + value + .parse() + .map_err(|_| Error::InvalidEnvVar { key, value }) + }) + .transpose() + }; + let preallocate = env::var_os("ERE_ZISK_PREALLOCATE").is_some(); + let unlock_mapped_memory = env::var_os("ERE_ZISK_UNLOCK_MAPPED_MEMORY").is_some(); + let minimal_memory = env::var_os("ERE_ZISK_MINIMAL_MEMORY").is_some(); + let shared_tables = env::var_os("ERE_ZISK_SHARED_TABLES").is_some(); + let max_streams = parse_usize("ERE_ZISK_MAX_STREAMS")?; + let number_threads_witness = parse_usize("ERE_ZISK_NUMBER_THREADS_WITNESS")?; + let max_witness_stored = parse_usize("ERE_ZISK_MAX_WITNESS_STORED")?; + Ok(Self { + preallocate, + unlock_mapped_memory, + minimal_memory, + shared_tables, + max_streams, + number_threads_witness, + max_witness_stored, + }) + } +} + +pub struct LocalProver { + config: Config, + elf: Vec, + elf_hash: Hash, + prover_and_pk: Mutex, ZiskProgramPK)>>, +} + +impl LocalProver { + pub fn new(elf: Vec) -> Result { + let config = Config::from_env()?; + let elf_hash = blake3::hash(&elf); + + let prover_and_pk = env::var_os("ERE_ZISK_SETUP_ON_INIT") + .map(|_| initialize(&config, &elf, elf_hash)) + .transpose()?; + + Ok(Self { + config, + elf, + elf_hash, + prover_and_pk: Mutex::new(prover_and_pk), + }) + } + + pub fn prove(&self, stdin: &[u8]) -> Result<(ZiskProofWithPublicValues, Duration), Error> { + let mut guard = self.prover_and_pk.lock(); + + if guard.is_none() { + *guard = Some(initialize(&self.config, &self.elf, self.elf_hash)?) + } + + let (prover, pk) = guard.as_ref().unwrap(); + + let stdin = ZiskStdin::from_vec(stdin.to_vec()); + let tempdir = tempdir().map_err(CommonError::tempdir)?; + let mut opts = ProofOpts::default().output_dir(tempdir.path().to_path_buf()); + if self.config.minimal_memory { + opts = opts.minimal_memory(); + } + + let result = panic::catch_unwind(|| prover.prove(pk, stdin).with_proof_options(opts).run()); + + match result { + Err(err) => { + uninitialize(guard); + Err(Error::ProvePanic(panic_msg(err))) + } + Ok(Err(err)) => { + uninitialize(guard); + Err(Error::Prove(err)) + } + Ok(Ok(result)) => Ok(( + result.get_proof_with_publics().clone(), + result.get_duration(), + )), + } + } +} + +fn assembly_files_exist(elf_hash: Hash) -> bool { + ["mt", "rh", "mo"].into_iter().all(|suffix| { + let bin = cache_dir().join(format!("{ELF_NAME}-{elf_hash}-{suffix}.bin")); + bin.exists() + }) +} + +fn initialize( + config: &Config, + elf: &[u8], + elf_hash: Hash, +) -> Result<(ZiskProver, ZiskProgramPK), Error> { + info!("Initializing ZisK prover..."); + + if !assembly_files_exist(elf_hash) { + generate_assembly(elf, ELF_NAME, &cache_dir(), false, false) + .map_err(|error| Error::GenerateAssembly(error.to_string()))?; + }; + + let mut params_gpu = ParamsGPU::new(config.preallocate); + if let Some(max_streams) = config.max_streams { + params_gpu.with_max_number_streams(max_streams); + } + if let Some(number_threads_witness) = config.number_threads_witness { + params_gpu.with_number_threads_pools_witness(number_threads_witness); + } + if let Some(max_witness_stored) = config.max_witness_stored { + params_gpu.with_max_witness_stored(max_witness_stored); + } + + let prover = ProverClientBuilder::new() + .asm() + .gpu(Some(params_gpu)) + .unlock_mapped_memory(config.unlock_mapped_memory) + .shared_tables(config.shared_tables) + .build() + .map_err(Error::InitProver)?; + + let elf_binary = ElfBinaryFromFile { + elf: elf.to_vec(), + name: ELF_NAME.to_string(), + with_hints: false, + path: None, + }; + let (pk, _) = prover.setup(&elf_binary).map_err(Error::SetupProver)?; + + info!("ZisK prover initialized"); + + Ok((prover, pk)) +} + +fn uninitialize(mut prover_and_pk: MutexGuard, ZiskProgramPK)>>) { + info!("Uninitializing ZisK prover..."); + + let _ = Command::new("fuser") + .args(["-k", "-9", "23115/tcp", "23116/tcp", "23117/tcp"]) + .output(); + sleep(Duration::from_secs(1)); + + drop(prover_and_pk.take()); + + info!("ZisK prover uninitialized"); +} + +/// Returns path to `~/.zisk/cache` directory. +fn cache_dir() -> PathBuf { + dot_zisk_dir().join("cache") +} diff --git a/crates/zkvm/zisk/src/zkvm/server.rs b/crates/zkvm/zisk/src/zkvm/server.rs deleted file mode 100644 index a212ba7b..00000000 --- a/crates/zkvm/zisk/src/zkvm/server.rs +++ /dev/null @@ -1,461 +0,0 @@ -//! Local ZisK server management via `cargo-zisk` commands. - -use crate::zkvm::{Error, sdk::dot_zisk_dir_path}; -use ere_zkvm_interface::zkvm::CommonError; -use parking_lot::Mutex; -use std::{ - collections::BTreeMap, - env, fs, - io::Write, - iter, - net::{Ipv4Addr, TcpStream}, - path::{Path, PathBuf}, - process::{Child, Command, Stdio}, - thread, - time::{Duration, Instant}, -}; -use strum::{EnumIter, IntoEnumIterator}; -use tempfile::tempdir; -use tracing::{error, info}; -use wait_timeout::ChildExt; - -pub const DEFAULT_START_SERVER_TIMEOUT_SEC: u64 = 120; // 2 mins -pub const DEFAULT_SHUTDOWN_SERVER_TIMEOUT_SEC: u64 = 30; // 30 secs -pub const DEFAULT_PROVE_TIMEOUT_SEC: u64 = 3600; // 1 hour - -/// ZisK server status returned from `cargo-zisk prove-client status`. -#[derive(Debug)] -pub enum ZiskServerStatus { - Idle, - Working, -} - -/// Options of `cargo-zisk` commands. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, EnumIter)] -pub enum ZiskServerOption { - Port, - UnlockMappedMemory, // Should be set if locked memory is not enough - MinimalMemory, - // GPU options - Preallocate, // Should be set only if GPU memory is enough - SharedTables, - MaxStreams, - NumberThreadsWitness, - MaxWitnessStored, -} - -impl ZiskServerOption { - /// The key of the env variable to read from. - fn env_var_key(&self) -> &'static str { - match self { - Self::Port => "ERE_ZISK_PORT", - Self::UnlockMappedMemory => "ERE_ZISK_UNLOCK_MAPPED_MEMORY", - Self::MinimalMemory => "ERE_ZISK_MINIMAL_MEMORY", - Self::Preallocate => "ERE_ZISK_PREALLOCATE", - Self::SharedTables => "ERE_ZISK_SHARED_TABLES", - Self::MaxStreams => "ERE_ZISK_MAX_STREAMS", - Self::NumberThreadsWitness => "ERE_ZISK_NUMBER_THREADS_WITNESS", - Self::MaxWitnessStored => "ERE_ZISK_MAX_WITNESS_STORED", - } - } - - /// Whether the option is a flag (false-by-default boolean option) or not. - /// - /// When we read the option from env variable, if the option is a flag, - /// we only check if the env variable is set or not. - fn is_flag(&self) -> bool { - match self { - Self::UnlockMappedMemory - | Self::MinimalMemory - | Self::Preallocate - | Self::SharedTables => true, - Self::Port | Self::MaxStreams | Self::NumberThreadsWitness | Self::MaxWitnessStored => { - false - } - } - } - - /// The option key to be appended to `cargo-zisk` command arguments. - fn key(&self) -> &'static str { - match self { - Self::Port => "--port", - Self::UnlockMappedMemory => "--unlock-mapped-memory", - // NOTE: Use snake case for `prove-client` command - // Issue for tracking: https://github.com/eth-act/ere/issues/151. - Self::MinimalMemory => "--minimal_memory", - Self::Preallocate => "--preallocate", - Self::SharedTables => "--shared-tables", - Self::MaxStreams => "--max-streams", - Self::NumberThreadsWitness => "--number-threads-witness", - Self::MaxWitnessStored => "--max-witness-stored", - } - } -} - -/// Configurable options for `cargo-zisk server` and `cargo-zisk prove-client` commands. -#[derive(Clone)] -pub struct ZiskServerOptions(BTreeMap); - -impl ZiskServerOptions { - /// Read options from env variables. - pub fn from_env() -> Self { - Self( - ZiskServerOption::iter() - .flat_map(|option| env::var(option.env_var_key()).ok().map(|val| (option, val))) - .collect(), - ) - } - - /// Returns `cargo-zisk` command arguments by given options that have been - /// set. - fn args( - &self, - options: impl IntoIterator, - ) -> impl Iterator { - options - .into_iter() - .filter(|option| self.0.contains_key(option)) - .flat_map(|option| { - iter::once(option.key()) - .chain((!option.is_flag()).then(|| self.0[&option].as_str())) - }) - } - - /// Returns `cargo-zisk server` command arguments. - pub(crate) fn server_args(&self) -> impl Iterator { - self.args([ - ZiskServerOption::Port, - ZiskServerOption::UnlockMappedMemory, - ZiskServerOption::Preallocate, - ZiskServerOption::SharedTables, - ZiskServerOption::MaxStreams, - ZiskServerOption::NumberThreadsWitness, - ZiskServerOption::MaxWitnessStored, - ]) - } - - /// Returns `cargo-zisk prove-client` command arguments. - pub(crate) fn prove_client_args(&self) -> impl Iterator { - self.args([ZiskServerOption::Port]) - } - - /// Returns `cargo-zisk prove-client prove` command arguments. - pub(crate) fn prove_args(&self) -> impl Iterator { - self.prove_client_args() - .chain(self.args([ZiskServerOption::MinimalMemory])) - } -} - -/// Wrapper for ZisK server child process. -pub struct ZiskServer { - options: ZiskServerOptions, - elf_path: PathBuf, - cuda: bool, - child: Mutex>, -} - -impl Drop for ZiskServer { - fn drop(&mut self) { - self.shutdown(); - } -} - -impl ZiskServer { - /// Create a new ZisK server for the given ELF. - /// - /// The server process is lazily started on the first call to [`prove`](ZiskServer::prove). - pub fn new(elf_path: &Path, cuda: bool, options: ZiskServerOptions) -> Self { - Self { - elf_path: elf_path.to_path_buf(), - cuda, - options, - child: Mutex::new(None), - } - } - - /// Send prove request to server and wait for proof to be created. - /// - /// Returns the proof. - pub fn prove(&self, input: &[u8]) -> Result, Error> { - self.ensure_ready()?; - - // Prefix that ZisK server will add to the file name of the proof. - // We use constant because the file will be save to a temporary dir, - // so there will be no conflict. - const PREFIX: &str = "ere"; - - let tempdir = tempdir().map_err(CommonError::tempdir)?; - let input_path = tempdir.path().join("input"); - let output_path = tempdir.path().join("output"); - let proof_path = output_path.join(format!("{PREFIX}-vadcop_final_proof.bin")); - - fs::write(&input_path, input) - .map_err(|err| CommonError::write_file("input", &input_path, err))?; - - // NOTE: Use snake case for `prove-client` command - // Issue for tracking: https://github.com/eth-act/ere/issues/151. - let mut cmd = Command::new("cargo-zisk"); - let output = cmd - .args(["prove-client", "prove"]) - .arg("--input") - .arg(input_path) - .arg("--output_dir") - .arg(&output_path) - .args(["-p", PREFIX]) - .args(["--aggregation", "--verify_proofs"]) - .args(self.options.prove_args()) - .output() - .map_err(|err| CommonError::command(&cmd, err))?; - - if !output.status.success() { - return Err(CommonError::command_exit_non_zero( - &cmd, - output.status, - Some(&output), - ))?; - } - - // ZisK server will finish the `prove` requested above then respond the - // following `status`. So if the following `status` succeeds, the proof - // should also be ready. - self.status(prove_timeout()).map_err(|err| { - if matches!(err, Error::TimeoutWaitingServerReady) { - Error::TimeoutWaitingServerProving - } else if err.to_string().contains("EOF") { - Error::ServerCrashed - } else { - err - } - })?; - - let proof = fs::read(&proof_path) - .map_err(|err| CommonError::read_file("proof", &proof_path, err))?; - - Ok(proof) - } - - /// Ensure the server is running and responsive, restarting it if needed. - pub fn ensure_ready(&self) -> Result<(), Error> { - if self.child.lock().is_some() && self.status(start_server_timeout()).is_ok() { - return Ok(()); - } - - const MAX_RETRY: usize = 3; - let mut attempt = 0; - - loop { - self.shutdown(); - match self.start() { - Ok(()) => return Ok(()), - Err(Error::TimeoutWaitingServerReady) if attempt < MAX_RETRY => { - error!("Timeout waiting server ready, restarting..."); - attempt += 1; - continue; - } - Err(err) => return Err(err), - } - } - } - - /// Spawn the server process and wait until it's ready. - fn start(&self) -> Result<(), Error> { - info!("Starting ZisK server..."); - - let (cargo_zisk, witness_lib_name) = if self.cuda { - ("cargo-zisk-cuda", "libzisk_witness_cuda.so") - } else { - ("cargo-zisk", "libzisk_witness.so") - }; - let witness_lib_path = dot_zisk_dir_path().join("bin").join(witness_lib_name); - - let mut cmd = Command::new(cargo_zisk); - cmd.arg("server") - .args(self.options.server_args()) - .arg("--elf") - .arg(&self.elf_path) - .arg("--witness-lib") - .arg(witness_lib_path) - .arg("--aggregation"); - - let child = cmd.spawn().map_err(|err| CommonError::command(&cmd, err))?; - - { - let mut guard = self.child.lock(); - *guard = Some(child); - } - - self.wait_until_ready()?; - - Ok(()) - } - - /// Wait until the server status to be idle. - pub fn wait_until_ready(&self) -> Result<(), Error> { - const INTERVAL: Duration = Duration::from_secs(1); - - let timeout = start_server_timeout(); - - info!("Waiting until server is ready..."); - - let start = Instant::now(); - while !matches!(self.status(timeout), Ok(ZiskServerStatus::Idle)) { - if start.elapsed() > timeout { - return Err(Error::TimeoutWaitingServerReady); - } - thread::sleep(INTERVAL); - } - - Ok(()) - } - - /// Gracefully shut down the server, falling back to force-kill on failure. - fn shutdown(&self) { - let mut guard = self.child.lock(); - let Some(mut child) = guard.take() else { - return; - }; - - info!("Shutting down ZisK server"); - - let mut cmd = Command::new("cargo-zisk"); - let result = cmd - .args(["prove-client", "shutdown"]) - .args(self.options.prove_client_args()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .and_then( - |mut child| match child.wait_timeout(shutdown_server_timeout())? { - Some(_) => child.wait_with_output(), - None => { - child.kill().ok(); - Err(std::io::Error::other("shutdown command timed out")) - } - }, - ); - - if result.as_ref().is_ok_and(|output| output.status.success()) { - info!("Shutdown ZisK server"); - } else { - error!( - "Failed to shutdown ZisK server: {}", - result - .map(|output| String::from_utf8_lossy(&output.stderr).to_string()) - .unwrap_or_else(|err| err.to_string()) - ); - error!("Shutdown server child process and asm services manually..."); - let _ = child.kill(); - shutdown_asm_service(23115); - shutdown_asm_service(23116); - shutdown_asm_service(23117); - remove_shm_files(); - } - } - - /// Get status of server. - fn status(&self, timeout: Duration) -> Result { - let mut cmd = Command::new("cargo-zisk"); - let mut child = cmd - .args(["prove-client", "status"]) - .args(self.options.prove_client_args()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .map_err(|err| CommonError::command(&cmd, err))?; - - if child - .wait_timeout(timeout) - .map_err(|err| CommonError::command(&cmd, err))? - .is_none() - { - // Timeout reached, kill the process - child.kill().ok(); - return Err(Error::TimeoutWaitingServerReady); - } - - let output = child - .wait_with_output() - .map_err(|err| CommonError::command(&cmd, err))?; - - if !output.status.success() { - return Err(CommonError::command_exit_non_zero( - &cmd, - output.status, - Some(&output), - ))?; - } - - let stdout = String::from_utf8_lossy(&output.stdout); - if stdout.contains("idle") { - Ok(ZiskServerStatus::Idle) - } else if stdout.contains("working") { - Ok(ZiskServerStatus::Working) - } else { - Err(Error::UnknownServerStatus { - stdout: stdout.to_string(), - }) - } - } -} - -/// Send shutdown request to ZisK asm services. -fn shutdown_asm_service(port: u16) { - // According to https://github.com/0xPolygonHermez/zisk/blob/v0.15.0/emulator-asm/asm-runner/src/asm_services/mod.rs#L34. - const CMD_SHUTDOWN_REQUEST_ID: u64 = 1000000; - if let Ok(mut stream) = TcpStream::connect((Ipv4Addr::LOCALHOST, port)) { - let _ = stream.write_all( - &[CMD_SHUTDOWN_REQUEST_ID, 0, 0, 0, 0] - .into_iter() - .flat_map(|word| word.to_le_bytes()) - .collect::>(), - ); - } -} - -/// Remove shared memory created by ZisK. -fn remove_shm_files() { - let Ok(shm_dir) = fs::read_dir(Path::new("/dev/shm")) else { - return; - }; - - for entry in shm_dir.flatten() { - let path = entry.path(); - if path - .file_name() - .and_then(|n| n.to_str()) - .is_some_and(|name| name.starts_with("ZISK") || name.starts_with("sem")) - { - let _ = fs::remove_file(&path); - } - } -} - -/// Returns the server start timeout, configurable via `ERE_ZISK_START_SERVER_TIMEOUT_SEC`. -fn start_server_timeout() -> Duration { - timeout( - "ERE_ZISK_START_SERVER_TIMEOUT_SEC", - DEFAULT_START_SERVER_TIMEOUT_SEC, - ) -} - -/// Returns the server shutdown timeout, configurable via `ERE_ZISK_SHUTDOWN_SERVER_TIMEOUT_SEC`. -fn shutdown_server_timeout() -> Duration { - timeout( - "ERE_ZISK_SHUTDOWN_SERVER_TIMEOUT_SEC", - DEFAULT_SHUTDOWN_SERVER_TIMEOUT_SEC, - ) -} - -/// Returns the prove timeout, configurable via `ERE_ZISK_PROVE_TIMEOUT_SEC`. -fn prove_timeout() -> Duration { - timeout("ERE_ZISK_PROVE_TIMEOUT_SEC", DEFAULT_PROVE_TIMEOUT_SEC) -} - -/// Read a timeout from the given env variable key, falling back to `default`. -fn timeout(key: &str, default: u64) -> Duration { - let sec = env::var(key) - .ok() - .and_then(|timeout| timeout.parse::().ok()) - .unwrap_or(default); - Duration::from_secs(sec) -} diff --git a/docker/zisk/Dockerfile.base b/docker/zisk/Dockerfile.base index 067ade9c..68b9d4a5 100644 --- a/docker/zisk/Dockerfile.base +++ b/docker/zisk/Dockerfile.base @@ -6,9 +6,6 @@ FROM $BASE_IMAGE # ZisK requires Ubuntu 22.04 or higher (ere-base uses 24.04 by default). # We operate as root for SDK and dependency installation. -# Whether to enable CUDA feature or not. -ARG CUDA - # Install ZisK system dependencies (for Ubuntu) # Taken from https://0xpolygonhermez.github.io/zisk/getting_started/installation.html RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -37,8 +34,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-riscv64-unknown-elf \ && apt-get clean && rm -rf /var/lib/apt/lists/* -# Default to build for RTX 50 series -ARG CUDA_ARCH=sm_120 # Copy the ZisK SDK installer script from the workspace context COPY --chmod=755 scripts/sdk_installers/install_zisk_sdk.sh /tmp/install_zisk_sdk.sh diff --git a/docker/zisk/Dockerfile.cluster b/docker/zisk/Dockerfile.cluster index e550808a..6ec262cf 100644 --- a/docker/zisk/Dockerfile.cluster +++ b/docker/zisk/Dockerfile.cluster @@ -49,7 +49,7 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --de # Clone repo WORKDIR /app -RUN git clone https://github.com/han0110/zisk.git --depth 1 --branch patch/v0.15.0-cluster /app +RUN git clone https://github.com/han0110/zisk.git --depth 1 --branch patch/v0.16.0 /app # Whether to enable CUDA feature or not. ARG CUDA @@ -100,7 +100,6 @@ COPY --from=build_stage /app/ziskup/ziskup /app/ziskup/ziskup # Copy binaries (to /usr/local/bin instead of ~/.zisk/bin because we want to mount ~/.zisk later) COPY --from=build_stage /app/target/release/cargo-zisk /usr/local/bin/cargo-zisk -COPY --from=build_stage /app/target/release/libzisk_witness.so /usr/local/bin/libzisk_witness.so COPY --from=build_stage /app/target/release/zisk-coordinator /usr/local/bin/zisk-coordinator COPY --from=build_stage /app/target/release/zisk-worker /usr/local/bin/zisk-worker diff --git a/docker/zisk/Dockerfile.server b/docker/zisk/Dockerfile.server index 9fa9499e..2d69a830 100644 --- a/docker/zisk/Dockerfile.server +++ b/docker/zisk/Dockerfile.server @@ -14,6 +14,9 @@ WORKDIR /ere ARG CUDA ARG RUSTFLAGS +# Default to build for RTX 50 series +ARG CUDA_ARCH=sm_120 + RUN cargo build --release --package ere-server --bin ere-server --features zisk${CUDA:+,cuda} \ && mkdir bin && mv target/release/ere-server bin/ere-server \ && cargo clean && rm -rf $CARGO_HOME/registry/ diff --git a/examples/zisk/docker-compose.cluster.yml b/examples/zisk/docker-compose.cluster.yml index 49e0b113..4395b402 100644 --- a/examples/zisk/docker-compose.cluster.yml +++ b/examples/zisk/docker-compose.cluster.yml @@ -18,7 +18,6 @@ services: rustup self uninstall -y rm -rf /root/.zisk/toolchains rm /root/.zisk/bin/cargo-zisk - rm /root/.zisk/bin/libzisk_witness.so rm /root/.zisk/bin/riscv2zisk rm /root/.zisk/bin/zisk-coordinator rm /root/.zisk/bin/ziskemu @@ -36,7 +35,7 @@ services: echo "Setup complete" volumes: - - zisk_setup:/root/.zisk + - zisk-setup:/root/.zisk - ${ELF_PATH}:/app/elf:ro deploy: resources: @@ -77,11 +76,9 @@ services: - "http://zisk-coordinator:50051" - "--elf" - "/app/elf" - - "--witness-lib" - - "/usr/local/bin/libzisk_witness.so" volumes: # Mount proving key - - zisk_setup:/root/.zisk:ro + - zisk-setup:/root/.zisk:ro # Mount ELF - ${ELF_PATH}:/app/elf:ro # Uncomment to override config @@ -125,7 +122,7 @@ services: # capabilities: [gpu] volumes: - zisk_setup: + zisk-setup: networks: default: diff --git a/scripts/sdk_installers/install_zisk_sdk.sh b/scripts/sdk_installers/install_zisk_sdk.sh index b9059b11..aea29397 100755 --- a/scripts/sdk_installers/install_zisk_sdk.sh +++ b/scripts/sdk_installers/install_zisk_sdk.sh @@ -28,69 +28,16 @@ echo "Installing ZisK Toolchain and SDK using ziskup (prebuilt binaries)..." ensure_tool_installed "curl" "to download the ziskup installer" ensure_tool_installed "bash" "to run the ziskup installer" ensure_tool_installed "rustup" "for managing Rust toolchains (ZisK installs its own)" -ensure_tool_installed "cargo" "as cargo-zisk is a cargo subcommand" +ensure_tool_installed "cargo" "to pre-build lib-c" # Step 1: Download and run the script that installs the ziskup binary itself. -# Export SETUP_KEY=proving-no-consttree to download proving key but avoid doing -# cargo-zisk check-setup. -export ZISK_VERSION="0.15.0" +# Export SETUP_KEY=proving-no-consttree to download proving key without doing setup. +export ZISK_VERSION="0.16.0" export SETUP_KEY=${SETUP_KEY:=proving-no-consttree} curl "https://raw.githubusercontent.com/0xPolygonHermez/zisk/main/ziskup/install.sh" | bash unset SETUP_KEY -# Step 2: Ensure the installed cargo-zisk binary is in PATH for this script session. -export PATH="$PATH:$HOME/.zisk/bin" - -# FIXME: Issue for tracking: https://github.com/eth-act/ere/issues/200. -if true; then - WORKSPACE=$(mktemp -d) - git clone https://github.com/han0110/zisk.git --depth 1 --branch patch/v0.15.0 "$WORKSPACE" - cargo build --manifest-path "$WORKSPACE/Cargo.toml" --release - cp "$WORKSPACE/target/release/cargo-zisk" "$HOME/.zisk/bin/cargo-zisk" - cp "$WORKSPACE/target/release/libzisk_witness.so" "$HOME/.zisk/bin/libzisk_witness.so" - rm -rf "$WORKSPACE" -fi - -# Verify ZisK installation -echo "Verifying ZisK installation..." - -echo "Checking for 'zisk' toolchain..." -if rustup toolchain list | grep -q "^zisk"; then - echo "ZisK Rust toolchain found." -else - echo "Error: ZisK Rust toolchain ('zisk') not found after installation!" >&2 - exit 1 -fi - -echo "Checking for cargo-zisk CLI tool..." -if cargo-zisk --version; then - echo "cargo-zisk CLI tool verified successfully." -else - echo "Error: 'cargo-zisk --version' failed." >&2 - exit 1 -fi - -# Step 3: Build cargo-zisk-cuda from source with `gpu` feature enabled -if [ -n "$CUDA" ]; then - WORKSPACE=$(mktemp -d) - # FIXME: Issue for tracking: https://github.com/eth-act/ere/issues/200. - # git clone https://github.com/0xPolygonHermez/zisk.git --depth 1 --tag "v$ZISK_VERSION" "$WORKSPACE" - git clone https://github.com/han0110/zisk.git --depth 1 --branch patch/v0.15.0 "$WORKSPACE" - cargo build --manifest-path "$WORKSPACE/Cargo.toml" --release --features gpu - cp "$WORKSPACE/target/release/cargo-zisk" "$HOME/.zisk/bin/cargo-zisk-cuda" - cp "$WORKSPACE/target/release/libzisk_witness.so" "$HOME/.zisk/bin/libzisk_witness_cuda.so" - rm -rf "$WORKSPACE" - - echo "Checking for cargo-zisk-cuda CLI tool..." - if cargo-zisk-cuda --version; then - echo "cargo-zisk-cuda CLI tool verified successfully." - else - echo "Error: 'cargo-zisk-cuda --version' failed." >&2 - exit 1 - fi -fi - -# Step 4: Make sure `lib-c`'s build script is ran. +# Step 2: Make sure `lib-c`'s build script is ran. # # `ziskos` provides guest program runtime, and `lib-c` is a dependency of `ziskos`, # when we need to compile guest, the `build.rs` of `lib-c` will need to be ran once, @@ -98,8 +45,8 @@ fi # So here we make sure it's already ran, and the built thing will be stored in # `$CARGO_HOME/git/checkouts/zisk-{hash}/{rev}/lib-c/c/build`, so could be # re-used as long as the `ziskos` has the same version. -WORKSPACE="/tmp/build-lib-c" -cargo new "$WORKSPACE" --name build-lib-c +WORKSPACE=$(mktemp -d) +cargo init "$WORKSPACE" --name build-lib-c cargo add lib-c --git https://github.com/0xPolygonHermez/zisk.git --tag "v$ZISK_VERSION" --manifest-path "$WORKSPACE/Cargo.toml" cargo build --manifest-path "$WORKSPACE/Cargo.toml" rm -rf "$WORKSPACE" diff --git a/tests/zisk/basic_go/go.mod b/tests/zisk/basic_go/go.mod index 5ab7560e..786a3178 100644 --- a/tests/zisk/basic_go/go.mod +++ b/tests/zisk/basic_go/go.mod @@ -11,3 +11,7 @@ require ( github.com/usbarmory/tamago v0.0.0-20250710154000-3dd21eabac74 // indirect github.com/x448/float16 v0.8.4 // indirect ) + +// FIXME: Remove when it is upstreamed + +replace github.com/eth-act/skunkworks-tama => github.com/han0110/skunkworks-tama v0.0.0-20260317122225-91096817c56b diff --git a/tests/zisk/basic_go/go.sum b/tests/zisk/basic_go/go.sum index 276b6d10..1b536b71 100644 --- a/tests/zisk/basic_go/go.sum +++ b/tests/zisk/basic_go/go.sum @@ -1,7 +1,7 @@ -github.com/eth-act/skunkworks-tama v0.0.0-20251105112532-eff8e3af014b h1:Nm1FYhFjCWnKkaRZzSjGmeWdqevsunbpOnYOayWpuoM= -github.com/eth-act/skunkworks-tama v0.0.0-20251105112532-eff8e3af014b/go.mod h1:M9fXNuyicUdFmj5nBlXRTNcUbJIDLMMs4eY1QoZHM3g= github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/han0110/skunkworks-tama v0.0.0-20260317122225-91096817c56b h1:ACOvMjhTOfbtMZJ4mOVQKAm7wTaRNMH+RG6uP8fLZrQ= +github.com/han0110/skunkworks-tama v0.0.0-20260317122225-91096817c56b/go.mod h1:M9fXNuyicUdFmj5nBlXRTNcUbJIDLMMs4eY1QoZHM3g= github.com/usbarmory/tamago v0.0.0-20250710154000-3dd21eabac74 h1:zH22Y68S2cpwW278H+9v4r2SWpdP+JwUk/AwVc9LOlw= github.com/usbarmory/tamago v0.0.0-20250710154000-3dd21eabac74/go.mod h1:0Bc0GnC88LvCAoCRUcd3DBFl7cribfVbCsiMJUbXyAE= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= diff --git a/tests/zisk/basic_go/main.go b/tests/zisk/basic_go/main.go index 81371cb9..1c9a6025 100644 --- a/tests/zisk/basic_go/main.go +++ b/tests/zisk/basic_go/main.go @@ -58,8 +58,8 @@ func compute(input BasicProgramInput) BasicProgramOutput { output := BasicProgramOutput{ A: input.A + 1, B: input.B + 1, - C: input.C + 1, - D: input.D + 1, + C: uint32(input.A)*input.C + 1, + D: uint64(input.B)*input.D + 1, E: make([]byte, len(input.E)), } for i, b := range input.E { diff --git a/tests/zisk/stock_nightly_no_std/Cargo.toml b/tests/zisk/stock_nightly_no_std/Cargo.toml new file mode 100644 index 00000000..c00518f7 --- /dev/null +++ b/tests/zisk/stock_nightly_no_std/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "addition_no_std" +edition = "2021" + +[dependencies] + +[workspace] diff --git a/tests/zisk/stock_nightly_no_std/src/main.rs b/tests/zisk/stock_nightly_no_std/src/main.rs new file mode 100644 index 00000000..0674fff5 --- /dev/null +++ b/tests/zisk/stock_nightly_no_std/src/main.rs @@ -0,0 +1,27 @@ +#![no_std] +#![no_main] + +extern crate alloc; + +use alloc::vec::Vec; +use core::sync::atomic::AtomicU16; +use core::sync::atomic::Ordering; + +mod zisk; + +fn main() { + let a: AtomicU16 = core::hint::black_box(AtomicU16::new(5)); + let b: AtomicU16 = core::hint::black_box(AtomicU16::new(7)); + + if a.load(Ordering::SeqCst) + b.load(Ordering::SeqCst) != 12 { + panic!("Something went wrong!"); + } + + let mut v: Vec = Vec::new(); + v.push(AtomicU16::new(5)); + v.push(AtomicU16::new(7)); + + if v[0].load(Ordering::SeqCst) + v[1].load(Ordering::SeqCst) != 12 { + panic!("Something went wrong!"); + } +} diff --git a/tests/zisk/stock_nightly_no_std/src/memcpy.s b/tests/zisk/stock_nightly_no_std/src/memcpy.s new file mode 100644 index 00000000..fed5c7a6 --- /dev/null +++ b/tests/zisk/stock_nightly_no_std/src/memcpy.s @@ -0,0 +1,16 @@ +# Copied from https://github.com/0xPolygonHermez/zisk/blob/v0.16.0/ziskos/entrypoint/src/dma/memcpy.s + + .section ".note.GNU-stack","",@progbits + .text + .attribute 4, 16 + .attribute 5, "rv64im" + .globl memcpy + .p2align 4 + .type memcpy,@function +memcpy: + csrs 0x813, a2 # Marker: Write count (a2) to CSR 0x813 + add x0,a0,a1 + ret + + .size memcpy, .-memcpy + .section .text.hot,"ax",@progbits \ No newline at end of file diff --git a/tests/zisk/stock_nightly_no_std/src/memmove.s b/tests/zisk/stock_nightly_no_std/src/memmove.s new file mode 100644 index 00000000..1bb34d21 --- /dev/null +++ b/tests/zisk/stock_nightly_no_std/src/memmove.s @@ -0,0 +1,15 @@ +# Copied from https://github.com/0xPolygonHermez/zisk/blob/v0.16.0/ziskos/entrypoint/src/dma/memmove.s + + .section ".note.GNU-stack","",@progbits + .text + .attribute 4, 16 + .attribute 5, "rv64im" + .globl memmove + .p2align 4 + .type memmove,@function +memmove: + csrs 0x813, a2 # Marker: Write count (a2) to CSR 0x813 + add x0,a0,a1 + ret + .size memmove, .-memmove + .section .text.hot,"ax",@progbits \ No newline at end of file diff --git a/tests/zisk/stock_nightly_no_std/src/zisk.rs b/tests/zisk/stock_nightly_no_std/src/zisk.rs new file mode 100644 index 00000000..b5a5fe53 --- /dev/null +++ b/tests/zisk/stock_nightly_no_std/src/zisk.rs @@ -0,0 +1,94 @@ +use core::alloc::{GlobalAlloc, Layout}; + +#[no_mangle] +unsafe extern "C" fn _zisk_main() { + crate::main(); +} + +// According to https://github.com/0xPolygonHermez/zisk/blob/v0.16.0/ziskos/entrypoint/src/lib.rs#L116 +core::arch::global_asm!( + r#" +.section .text.init +.globl _start +_start: + .option push + .option norelax + la gp, _global_pointer + .option pop + + la sp, _init_stack_top + + call _zisk_main + + li a7, 93 + ecall + + j . +"#, +); + +// According to https://github.com/0xPolygonHermez/rust/blob/zisk/library/std/src/sys/pal/zisk/mod.rs#L48 +#[panic_handler] +fn panic_impl(_info: &core::panic::PanicInfo) -> ! { + unsafe { core::arch::asm!("unimp", options(noreturn)) } +} + +struct SimpleAlloc; + +unsafe impl GlobalAlloc for SimpleAlloc { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + sys_alloc_aligned(layout.size(), layout.align()) + } + + unsafe fn dealloc(&self, _: *mut u8, _: Layout) {} +} + +#[global_allocator] +static HEAP: SimpleAlloc = SimpleAlloc; + +// According to https://github.com/0xPolygonHermez/zisk/blob/v0.16.0/ziskos/entrypoint/src/lib.rs#L241 +#[no_mangle] +pub unsafe extern "C" fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8 { + use core::arch::asm; + let heap_bottom: usize; + // UNSAFE: This is fine, just loading some constants. + unsafe { + // using inline assembly is easier to access linker constants + asm!( + "la {heap_bottom}, _kernel_heap_bottom", + heap_bottom = out(reg) heap_bottom, + options(nomem) + ) + }; + + // Pointer to next heap address to use, or 0 if the heap has not yet been + // initialized. + static mut HEAP_POS: usize = 0; + + // SAFETY: Single threaded, so nothing else can touch this while we're working. + let mut heap_pos = unsafe { HEAP_POS }; + + if heap_pos == 0 { + heap_pos = heap_bottom; + } + + let offset = heap_pos & (align - 1); + if offset != 0 { + heap_pos += align - offset; + } + + let ptr = heap_pos as *mut u8; + heap_pos += bytes; + + // Check to make sure heap doesn't collide with SYSTEM memory. + //if SYSTEM_START < heap_pos { + // panic!(); + // } + + unsafe { HEAP_POS = heap_pos }; + + ptr +} + +core::arch::global_asm!(include_str!("memcpy.s")); +core::arch::global_asm!(include_str!("memmove.s"));