diff --git a/Cargo.lock b/Cargo.lock index 197cada5..52a7d87b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,12 +30,13 @@ dependencies = [ [[package]] name = "aggregator" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "ark-std 0.3.0", "bitstream-io", - "c-kzg 1.0.2", + "c-kzg", + "cfg-if 1.0.0", "ctor", "encoder", "env_logger", @@ -51,12 +52,12 @@ dependencies = [ "num-bigint", "once_cell", "rand", - "revm-precompile 7.0.0", - "revm-primitives 4.0.0", + "revm-precompile 9.2.0", + "revm-primitives 7.1.0", "serde", "serde_json", - "snark-verifier 0.1.0 (git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg)", - "snark-verifier-sdk 0.0.1 (git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg)", + "snark-verifier", + "snark-verifier-sdk", "strum 0.25.0", "strum_macros 0.25.3", "zkevm-circuits", @@ -89,42 +90,91 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy-eip2930" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" +dependencies = [ + "alloy-primitives 0.8.10", + "alloy-rlp", + "serde", +] + +[[package]] +name = "alloy-eip7702" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ffc577390ce50234e02d841214b3dc0bea6aaaae8e04bbf3cb82e9a45da9eb" +dependencies = [ + "alloy-primitives 0.8.10", + "alloy-rlp", + "derive_more 1.0.0", + "k256", + "serde", +] + +[[package]] +name = "alloy-eips" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9431c99a3b3fe606ede4b3d4043bdfbcb780c45b8d8d226c3804e2b75cfbe68" +dependencies = [ + "alloy-primitives 0.7.7", + "alloy-rlp", + "c-kzg", + "k256", + "once_cell", + "serde", +] + [[package]] name = "alloy-primitives" -version = "0.4.2" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0628ec0ba5b98b3370bb6be17b12f23bfce8ee4ad83823325a20546d9b03b78" +checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" dependencies = [ "alloy-rlp", "bytes", "cfg-if 1.0.0", "const-hex", - "derive_more", + "derive_more 0.99.17", "hex-literal", "itoa", + "k256", + "keccak-asm", + "proptest", + "rand", "ruint", + "serde", "tiny-keccak", ] [[package]] name = "alloy-primitives" -version = "0.7.7" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" +checksum = "8edae627382349b56cd6a7a2106f4fd69b243a9233e560c55c2e03cabb7e1d3c" dependencies = [ "alloy-rlp", "bytes", "cfg-if 1.0.0", "const-hex", - "derive_more", + "derive_more 1.0.0", + "foldhash", + "hashbrown 0.15.0", "hex-literal", + "indexmap 2.6.0", "itoa", "k256", "keccak-asm", + "paste", "proptest", "rand", "ruint", + "rustc-hash 2.0.0", "serde", + "sha3 0.10.8", "tiny-keccak", ] @@ -408,9 +458,9 @@ checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "base64ct" -version = "1.0.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bech32" @@ -420,7 +470,7 @@ checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" [[package]] name = "bin" -version = "0.13.0" +version = "0.14.0" dependencies = [ "anyhow", "clap", @@ -448,29 +498,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.66.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" -dependencies = [ - "bitflags 2.6.0", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.66", - "which", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -604,8 +631,8 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "bus-mapping" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "eth-types", "ethers-core", @@ -620,7 +647,7 @@ dependencies = [ "mpt-zktrie", "num", "poseidon-circuit", - "revm-precompile 7.0.0", + "revm-precompile 9.2.0", "serde", "serde_json", "strum 0.25.0", @@ -650,30 +677,16 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac926d808fb72fe09ebf471a091d6d72918876ccf0b4989766093d2d0d24a0ef" -dependencies = [ - "bindgen", - "blst", - "cc", - "glob", - "hex", - "libc", - "serde", -] - -[[package]] -name = "c-kzg" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf100c4cea8f207e883ff91ca886d621d8a166cb04971dfaa9bb8fd99ed95df" +checksum = "f0307f72feab3300336fb803a57134159f6e20139af1357f36c54cb90d8e8928" dependencies = [ "blst", "cc", "glob", "hex", "libc", + "once_cell", "serde", ] @@ -687,15 +700,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "0.1.10" @@ -733,17 +737,6 @@ dependencies = [ "inout", ] -[[package]] -name = "clang-sys" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "3.2.23" @@ -754,7 +747,7 @@ dependencies = [ "bitflags 1.3.2", "clap_derive", "clap_lex", - "indexmap", + "indexmap 1.9.3", "once_cell", "strsim", "termcolor", @@ -841,7 +834,7 @@ dependencies = [ "serde", "serde_derive", "sha2", - "sha3 0.10.6", + "sha3 0.10.8", "thiserror", ] @@ -1097,6 +1090,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -1124,6 +1118,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "unicode-xid", +] + [[package]] name = "digest" version = "0.9.0" @@ -1189,6 +1204,7 @@ dependencies = [ "ff", "generic-array", "group", + "pem-rfc7468", "pkcs8", "rand_core", "sec1", @@ -1199,7 +1215,7 @@ dependencies = [ [[package]] name = "encoder" version = "0.1.0" -source = "git+https://github.com/scroll-tech/da-codec.git?tag=v0.1.0#5a28b752d4504bf0966734fe4a6a5433981c74c2" +source = "git+https://github.com/scroll-tech/da-codec.git?tag=v0.1.2#8c5d2f0cd707153151a5154fef702204f6ca40b3" dependencies = [ "zstd", ] @@ -1227,7 +1243,7 @@ dependencies = [ "rand", "rlp", "serde", - "sha3 0.10.6", + "sha3 0.10.8", "zeroize", ] @@ -1255,6 +1271,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.3" @@ -1293,15 +1315,15 @@ dependencies = [ "serde", "serde_json", "sha2", - "sha3 0.10.6", + "sha3 0.10.8", "thiserror", "uuid", ] [[package]] name = "eth-types" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "base64 0.13.1", "ethers-core", @@ -1314,12 +1336,12 @@ dependencies = [ "num-bigint", "poseidon-base", "regex", - "revm-precompile 7.0.0", - "revm-primitives 4.0.0", + "revm-precompile 9.2.0", + "revm-primitives 7.1.0", "serde", "serde_json", "serde_with", - "sha3 0.10.6", + "sha3 0.10.8", "strum 0.25.0", "strum_macros 0.25.3", "subtle", @@ -1338,7 +1360,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha3 0.10.6", + "sha3 0.10.8", "thiserror", "uint", ] @@ -1456,8 +1478,8 @@ dependencies = [ [[package]] name = "external-tracer" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "eth-types", "geth-utils", @@ -1513,6 +1535,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1638,13 +1666,13 @@ dependencies = [ [[package]] name = "gadgets" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "eth-types", "halo2_proofs", "poseidon-base", - "sha3 0.10.6", + "sha3 0.10.8", "strum 0.25.0", ] @@ -1661,8 +1689,8 @@ dependencies = [ [[package]] name = "geth-utils" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "env_logger", "gobuild", @@ -1757,7 +1785,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -1767,7 +1795,7 @@ dependencies = [ [[package]] name = "halo2-base" version = "0.2.2" -source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#5e3a1c94d069c168febc4586fe6734e6b31b21bb" +source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#b236b88f2baa0f359cd30ffe1354644e7022c272" dependencies = [ "ff", "halo2_proofs", @@ -1776,13 +1804,13 @@ dependencies = [ "num-integer", "num-traits", "rand_chacha", - "rustc-hash", + "rustc-hash 1.1.0", ] [[package]] name = "halo2-ecc" version = "0.2.2" -source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#5e3a1c94d069c168febc4586fe6734e6b31b21bb" +source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#b236b88f2baa0f359cd30ffe1354644e7022c272" dependencies = [ "ff", "group", @@ -1927,6 +1955,15 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "foldhash", +] + [[package]] name = "hashers" version = "1.0.1" @@ -1987,15 +2024,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "0.2.9" @@ -2162,6 +2190,16 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.0", +] + [[package]] name = "inout" version = "0.1.3" @@ -2182,7 +2220,7 @@ dependencies = [ [[package]] name = "integration" -version = "0.13.0" +version = "0.14.0" dependencies = [ "anyhow", "ethers-providers", @@ -2193,12 +2231,11 @@ dependencies = [ "log4rs", "prover", "rand", - "revm 3.5.0", "serde", "serde_derive", "serde_json", - "snark-verifier 0.1.0 (git+https://github.com/scroll-tech/snark-verifier?branch=v0.1)", - "snark-verifier-sdk 0.0.1 (git+https://github.com/scroll-tech/snark-verifier?branch=v0.1)", + "snark-verifier", + "snark-verifier-sdk", "tokio", ] @@ -2298,9 +2335,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] @@ -2324,28 +2361,12 @@ dependencies = [ "spin", ] -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" -[[package]] -name = "libloading" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" -dependencies = [ - "cfg-if 1.0.0", - "windows-targets 0.52.5", -] - [[package]] name = "libm" version = "0.2.8" @@ -2449,12 +2470,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -2494,8 +2509,8 @@ dependencies = [ [[package]] name = "mock" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "eth-types", "ethers-core", @@ -2509,8 +2524,8 @@ dependencies = [ [[package]] name = "mpt-zktrie" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "eth-types", "halo2curves", @@ -2521,16 +2536,6 @@ dependencies = [ "zktrie", ] -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "num" version = "0.4.0" @@ -2724,6 +2729,18 @@ version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + [[package]] name = "pairing" version = "0.23.0" @@ -2823,10 +2840,13 @@ dependencies = [ ] [[package]] -name = "peeking_take_while" -version = "0.1.2" +name = "pem-rfc7468" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] [[package]] name = "percent-encoding" @@ -2915,7 +2935,7 @@ dependencies = [ [[package]] name = "poseidon-base" version = "0.1.0" -source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#7b96835c6201afdbfaf3d13d641efbaaf5db2d20" +source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#b978cee00aae1e0a1e79e0d74c4683b137f5ea2d" dependencies = [ "bitvec", "halo2curves", @@ -2925,7 +2945,7 @@ dependencies = [ [[package]] name = "poseidon-circuit" version = "0.1.0" -source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#7b96835c6201afdbfaf3d13d641efbaaf5db2d20" +source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#b978cee00aae1e0a1e79e0d74c4683b137f5ea2d" dependencies = [ "ff", "halo2_proofs", @@ -2943,13 +2963,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] -name = "prettyplease" -version = "0.2.20" +name = "primeorder" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" dependencies = [ - "proc-macro2", - "syn 2.0.66", + "elliptic-curve", ] [[package]] @@ -3037,8 +3056,8 @@ dependencies = [ [[package]] name = "prover" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "aggregator", "anyhow", @@ -3059,14 +3078,15 @@ dependencies = [ "num-bigint", "rand", "rand_xorshift", - "revm 3.5.0", + "revm 17.1.0", "serde", "serde_derive", "serde_json", "serde_stacker", "sha2", - "snark-verifier 0.1.0 (git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg)", - "snark-verifier-sdk 0.0.1 (git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg)", + "snark-verifier", + "snark-verifier-sdk", + "thiserror", "zkevm-circuits", ] @@ -3255,56 +3275,63 @@ dependencies = [ "primitive-types", "revm_precompiles", "rlp", - "sha3 0.10.6", + "sha3 0.10.8", ] [[package]] name = "revm" -version = "3.5.0" +version = "17.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f4ca8ae0345104523b4af1a8a7ea97cfa1865cdb7a7c25d23c1a18d9b48598" +checksum = "055bee6a81aaeee8c2389ae31f0d4de87f44df24f4444a1116f9755fd87a76ad" dependencies = [ "auto_impl", + "cfg-if 1.0.0", + "dyn-clone", "revm-interpreter", - "revm-precompile 2.2.0", + "revm-precompile 14.0.0", + "serde", + "serde_json", ] [[package]] name = "revm-interpreter" -version = "1.3.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f959cafdf64a7f89b014fa73dc2325001cf654b3d9400260b212d19a2ebe3da0" +checksum = "fac2034454f8bc69dc7d3c94cdb1b57559e27f5ef0518771f1787de543d7d6a1" dependencies = [ - "revm-primitives 1.3.0", + "revm-primitives 13.0.0", + "serde", ] [[package]] name = "revm-precompile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d360a88223d85709d2e95d4609eb1e19c649c47e28954bfabae5e92bb37e83e" +version = "9.2.0" +source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v40#5e215742c4d9d771f73d74fcba39628b1a2e3452" dependencies = [ - "c-kzg 0.1.1", + "aurora-engine-modexp", + "c-kzg", + "cfg-if 1.0.0", "k256", - "num", "once_cell", - "revm-primitives 1.3.0", + "revm-primitives 7.1.0", "ripemd", - "secp256k1 0.27.0", + "secp256k1 0.29.0", "sha2", "substrate-bn", ] [[package]] name = "revm-precompile" -version = "7.0.0" -source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#36c304d9e9ba4e4b2d5468d91a6bd27210133b6a" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a88c8c7c5f9b988a9e65fc0990c6ce859cdb74114db705bd118a96d22d08027" dependencies = [ "aurora-engine-modexp", - "c-kzg 1.0.2", + "c-kzg", + "cfg-if 1.0.0", "k256", "once_cell", - "revm-primitives 4.0.0", + "revm-primitives 13.0.0", "ripemd", "secp256k1 0.29.0", "sha2", @@ -3313,39 +3340,41 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51187b852d9e458816a2e19c81f1dd6c924077e1a8fccd16e4f044f865f299d7" +version = "7.1.0" +source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v40#5e215742c4d9d771f73d74fcba39628b1a2e3452" dependencies = [ - "alloy-primitives 0.4.2", - "alloy-rlp", + "alloy-eips", + "alloy-primitives 0.7.7", "auto_impl", "bitflags 2.6.0", "bitvec", + "c-kzg", + "cfg-if 1.0.0", + "derive_more 0.99.17", + "dyn-clone", "enumn", "hashbrown 0.14.3", "hex", + "once_cell", + "serde", ] [[package]] name = "revm-primitives" -version = "4.0.0" -source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#36c304d9e9ba4e4b2d5468d91a6bd27210133b6a" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d11fa1e195b0bebaf3fb18596f314a13ba3a4cb1fdd16d3465934d812fd921e" dependencies = [ - "alloy-primitives 0.7.7", + "alloy-eip2930", + "alloy-eip7702", + "alloy-primitives 0.8.10", "auto_impl", "bitflags 2.6.0", "bitvec", - "c-kzg 1.0.2", "cfg-if 1.0.0", - "derive_more", "dyn-clone", "enumn", - "halo2curves", - "hashbrown 0.14.3", "hex", - "once_cell", - "poseidon-base", "serde", ] @@ -3363,7 +3392,7 @@ dependencies = [ "ripemd", "secp256k1 0.24.3", "sha2", - "sha3 0.10.6", + "sha3 0.10.8", "substrate-bn", ] @@ -3465,6 +3494,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -3597,7 +3632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cfdffd972d76b22f3d7f81c8be34b2296afd3a25e0a547bd9abe340a4dbbe97" dependencies = [ "cfg-if 1.0.0", - "derive_more", + "derive_more 0.99.17", "parity-scale-codec", "scale-info-derive", ] @@ -3671,15 +3706,6 @@ dependencies = [ "secp256k1-sys 0.6.1", ] -[[package]] -name = "secp256k1" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" -dependencies = [ - "secp256k1-sys 0.8.1", -] - [[package]] name = "secp256k1" version = "0.29.0" @@ -3699,15 +3725,6 @@ dependencies = [ "cc", ] -[[package]] -name = "secp256k1-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" -dependencies = [ - "cc", -] - [[package]] name = "secp256k1-sys" version = "0.10.0" @@ -3755,9 +3772,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.159" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -3773,9 +3790,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.159" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -3788,6 +3805,7 @@ version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" dependencies = [ + "indexmap 1.9.3", "itoa", "ryu", "serde", @@ -3873,9 +3891,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ "digest 0.10.7", "keccak", @@ -3891,12 +3909,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3934,30 +3946,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "snark-verifier" version = "0.1.0" -source = "git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg#0d7c3ae2ea12b864fe8e361c1a2662039ac6c626" -dependencies = [ - "bytes", - "ethereum-types", - "halo2-base", - "halo2-ecc", - "hex", - "itertools 0.12.1", - "num-bigint", - "num-integer", - "num-traits", - "poseidon", - "rand", - "revm 2.3.1", - "rlp", - "rustc-hash", - "serde", - "sha3 0.10.6", -] - -[[package]] -name = "snark-verifier" -version = "0.1.0" -source = "git+https://github.com/scroll-tech/snark-verifier?branch=v0.1#58c46b74c73156b9e09dc27617369d2acfb4461b" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#948671cac73f11e66187a15483e38ab3626dc2a3" dependencies = [ "bytes", "ethereum-types", @@ -3972,42 +3961,21 @@ dependencies = [ "rand", "revm 2.3.1", "rlp", - "rustc-hash", - "serde", - "sha3 0.10.6", -] - -[[package]] -name = "snark-verifier-sdk" -version = "0.0.1" -source = "git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg#0d7c3ae2ea12b864fe8e361c1a2662039ac6c626" -dependencies = [ - "bincode", - "ethereum-types", - "ff", - "halo2-base", - "hex", - "itertools 0.12.1", - "log", - "num-bigint", - "num-integer", - "num-traits", - "rand", - "rand_chacha", + "rustc-hash 1.1.0", "serde", - "serde_json", - "snark-verifier 0.1.0 (git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg)", + "sha3 0.10.8", ] [[package]] name = "snark-verifier-sdk" version = "0.0.1" -source = "git+https://github.com/scroll-tech/snark-verifier?branch=v0.1#58c46b74c73156b9e09dc27617369d2acfb4461b" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#948671cac73f11e66187a15483e38ab3626dc2a3" dependencies = [ "bincode", "ethereum-types", "ff", "halo2-base", + "halo2_proofs", "hex", "itertools 0.12.1", "log", @@ -4018,7 +3986,7 @@ dependencies = [ "rand_chacha", "serde", "serde_json", - "snark-verifier 0.1.0 (git+https://github.com/scroll-tech/snark-verifier?branch=v0.1)", + "snark-verifier", ] [[package]] @@ -4354,7 +4322,7 @@ version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ - "indexmap", + "indexmap 1.9.3", "toml_datetime", "winnow", ] @@ -4675,18 +4643,6 @@ version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix 0.38.13", -] - [[package]] name = "winapi" version = "0.3.9" @@ -4745,15 +4701,6 @@ dependencies = [ "windows-targets 0.48.0", ] -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.5", -] - [[package]] name = "windows-targets" version = "0.42.2" @@ -4784,22 +4731,6 @@ dependencies = [ "windows_x86_64_msvc 0.48.0", ] -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -4812,12 +4743,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -4830,12 +4755,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -4848,18 +4767,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -4872,12 +4779,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -4890,12 +4791,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -4908,12 +4803,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -4926,12 +4815,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" - [[package]] name = "winnow" version = "0.4.1" @@ -5021,8 +4904,8 @@ dependencies = [ [[package]] name = "zkevm-circuits" -version = "0.13.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/hybrid-snark-agg#b621bce33e8dde421e79ab269c2b4e8aec362829" +version = "0.14.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#7fd6b6d7397a91daac347523748d58209becb140" dependencies = [ "array-init", "bus-mapping", @@ -5046,6 +4929,7 @@ dependencies = [ "mpt-zktrie", "num", "num-bigint", + "p256", "poseidon-circuit", "rand", "rand_chacha", @@ -5053,9 +4937,9 @@ dependencies = [ "rayon", "serde", "serde_json", - "sha3 0.10.6", - "snark-verifier 0.1.0 (git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg)", - "snark-verifier-sdk 0.0.1 (git+https://github.com/scroll-tech/snark-verifier?branch=feat/hybrid-snark-agg)", + "sha3 0.10.8", + "snark-verifier", + "snark-verifier-sdk", "strum 0.25.0", "strum_macros 0.25.3", "subtle", diff --git a/Cargo.toml b/Cargo.toml index 7cb5396f..8d1c7793 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ ] [workspace.package] -version = "0.13.0" +version = "0.14.0" edition = "2021" license = "MIT OR Apache-2.0" @@ -27,7 +27,7 @@ serde_json = "1.0" tokio = { version = "1.32", features = ["full"] } halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } -prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "feat/hybrid-snark-agg", default-features = false, features = ["parallel_syn", "scroll"] } +prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "develop", default-features = false, features = ["parallel_syn", "scroll"] } integration = { path = "integration" } [patch.crates-io] diff --git a/bin/src/chain_prover.rs b/bin/src/chain_prover.rs index dd5a4069..5f8a41c7 100644 --- a/bin/src/chain_prover.rs +++ b/bin/src/chain_prover.rs @@ -10,10 +10,8 @@ use integration::{ l2geth, }; use prover::{ - aggregator, - utils::init_env_and_log, - zkevm::{circuit::block_traces_to_witness_block, CircuitCapacityChecker, RowUsage}, - BatchData, BlockTrace, ChunkInfo, ChunkProof, MAX_AGG_SNARKS, + eth_types::l2_types::BlockTrace, init_env_and_log, BatchData, ChunkInfo, ChunkProofV2, + CircuitCapacityChecker, RowUsage, MAX_AGG_SNARKS, }; use std::env; @@ -81,7 +79,7 @@ impl BatchBuilder { } let batch_bytes = self.batch_data.get_batch_data_bytes(); - let blob_bytes = aggregator::eip4844::get_blob_bytes(&batch_bytes); + let blob_bytes = prover::get_blob_bytes(&batch_bytes); let compressed_da_size = blob_bytes.len(); let uncompressed_da_size = self .batch_data @@ -141,7 +139,6 @@ impl ChunkBuilder { // Condition2: ccc let ccc_result = { let mut checker = CircuitCapacityChecker::new(); - checker.set_light_mode(false); checker.estimate_circuit_capacity(trace.clone()).unwrap() }; self.acc_row_usage_normalized.add(&ccc_result); @@ -195,7 +192,7 @@ async fn prove_by_block(l2geth: &l2geth::Client, begin_block: i64, end_block: i6 unimplemented!("uncomment below"); //ChunkInfo::from_block_traces(&chunk) } else { - let witness_block = block_traces_to_witness_block(chunk).unwrap(); + let witness_block = prover::chunk_trace_to_witness_block(chunk).unwrap(); ChunkInfo::from_witness_block(&witness_block, false) }; if let Some(batch) = batch_builder.add(chunk_info) { @@ -203,7 +200,7 @@ async fn prove_by_block(l2geth: &l2geth::Client, begin_block: i64, end_block: i6 padding_chunk(&mut padded_batch); let batch_data = BatchData::<{ MAX_AGG_SNARKS }>::new(batch.len(), &padded_batch); let compressed_da_size = - aggregator::eip4844::get_blob_bytes(&batch_data.get_batch_data_bytes()).len(); + prover::get_blob_bytes(&batch_data.get_batch_data_bytes()).len(); log::info!( "batch built: blob usage {:.3}, chunk num {}, block num {}, block range {} to {}", compressed_da_size as f32 / constants::N_BLOB_BYTES as f32, @@ -235,7 +232,11 @@ fn padding_chunk(chunks: &mut Vec) { } } -fn prove_chunk(batch_id: u64, chunk_id: u64, block_traces: Vec) -> Option { +fn prove_chunk( + batch_id: u64, + chunk_id: u64, + block_traces: Vec, +) -> Option { let total_gas: u64 = block_traces .iter() .map(|b| b.header.gas_used.as_u64()) @@ -320,8 +321,6 @@ async fn prove_by_batch( } } -// Make sure tx-by-tx light_mode=false row usage >= real row usage - async fn txtx_ccc(l2geth: &l2geth::Client, begin_block: i64, end_block: i64) { let (begin_block, end_block) = if begin_block == 0 && end_block == 0 { // Blocks within last 24 hours @@ -354,7 +353,6 @@ async fn txtx_ccc(l2geth: &l2geth::Client, begin_block: i64, end_block: i64) { // part2: tx by tx row usage let tx_num = tx_traces.len(); let mut checker = CircuitCapacityChecker::new(); - checker.light_mode = false; let start_time = std::time::Instant::now(); for tx in tx_traces { checker.estimate_circuit_capacity(tx).unwrap(); diff --git a/bin/src/prove_utils.rs b/bin/src/prove_utils.rs index b1f93fa9..1f50ad6a 100644 --- a/bin/src/prove_utils.rs +++ b/bin/src/prove_utils.rs @@ -1,4 +1,4 @@ -use prover::{BlockTrace, ChunkProof}; +use prover::{eth_types::l2_types::BlockTrace, ChunkProofV2}; use std::panic::{catch_unwind, AssertUnwindSafe}; #[cfg(feature = "batch-prove")] @@ -7,7 +7,7 @@ use prover::{BatchHeader, MAX_AGG_SNARKS}; #[cfg(feature = "batch-prove")] pub fn prove_batch( id: &str, - chunk_proofs: Vec, + chunk_proofs: Vec, batch_header: BatchHeader, ) { use integration::prove::get_blob_from_chunks; @@ -16,7 +16,7 @@ pub fn prove_batch( let chunk_infos = chunk_proofs .iter() - .map(|p| p.chunk_info.clone()) + .map(|p| p.inner.chunk_info().clone()) .collect_vec(); let blob_bytes = get_blob_from_chunks(&chunk_infos); let batch = BatchProvingTask { @@ -24,7 +24,7 @@ pub fn prove_batch( batch_header, blob_bytes, }; - let result = catch_unwind(AssertUnwindSafe(|| prover::test::batch_prove(id, batch))); + let result = catch_unwind(AssertUnwindSafe(|| prover::batch_prove(id, batch))); match result { Ok(_) => log::info!("{id}: succeeded to prove batch"), @@ -41,21 +41,15 @@ pub fn prove_batch( } } -pub fn prove_chunk(id: &str, traces: Vec) -> Option { +pub fn prove_chunk(id: &str, traces: Vec) -> Option { let result = catch_unwind(AssertUnwindSafe(|| { #[cfg(not(feature = "chunk-prove"))] - let proof = None::; + let proof = None::; - #[cfg(feature = "inner-prove")] - { - let witness_block = - prover::zkevm::circuit::block_traces_to_witness_block(traces.clone()).unwrap(); - prover::test::inner_prove(id, &witness_block); - } #[cfg(feature = "chunk-prove")] - let proof = Some(prover::test::chunk_prove( + let proof = Some(prover::chunk_prove( id, - prover::ChunkProvingTask::new(traces, prover::ChunkKind::Halo2), + prover::ChunkProvingTask::new(traces), )); #[cfg(not(any(feature = "inner-prove", feature = "chunk-prove")))] mock_prove(id, traces); @@ -84,12 +78,10 @@ pub fn prove_chunk(id: &str, traces: Vec) -> Option { } #[cfg(not(any(feature = "inner-prove", feature = "chunk-prove")))] -fn mock_prove(id: &str, traces: Vec) { - use prover::{inner::Prover, zkevm::circuit::SuperCircuit}; - +fn mock_prove(id: &str, traces: Vec) { log::info!("{id}: mock-prove BEGIN"); - Prover::::mock_prove_target_circuit_chunk(traces) + integration::mock::mock_prove_target_circuit_chunk(traces) .unwrap_or_else(|err| panic!("{id}: failed to mock-prove: {err}")); log::info!("{id}: mock-prove END"); diff --git a/bin/src/trace_prover.rs b/bin/src/trace_prover.rs index 1554ea0c..5fa76ca3 100644 --- a/bin/src/trace_prover.rs +++ b/bin/src/trace_prover.rs @@ -1,6 +1,6 @@ use clap::Parser; use integration::{prove::prove_and_verify_chunk, test_util::load_chunk}; -use prover::{utils::init_env_and_log, zkevm::Prover, ChunkProvingTask}; +use prover::{init_env_and_log, ChunkProver, ChunkProvingTask}; use std::env; #[derive(Parser, Debug)] @@ -31,16 +31,10 @@ fn main() { let traces = load_chunk(&args.trace_path).1; prover::eth_types::constants::set_scroll_block_constants_with_trace(&traces[0]); - let chunk = ChunkProvingTask::new(traces, prover::ChunkKind::Halo2); - let params_map = prover::common::Prover::load_params_map( - &args.params_path, - &[ - *prover::config::INNER_DEGREE, - *prover::config::LAYER1_DEGREE, - *prover::config::LAYER2_DEGREE, - ], - ); - let mut prover = Prover::from_params_and_assets(¶ms_map, &args.assets_path); + let chunk = ChunkProvingTask::new(traces); + let params_map = + prover::Prover::load_params_map(&args.params_path, &prover::CHUNK_PROVER_DEGREES); + let mut prover = ChunkProverProver::from_params_and_assets(¶ms_map, &args.assets_path); log::info!("Constructed chunk prover"); prove_and_verify_chunk( ¶ms_map, diff --git a/integration/Cargo.toml b/integration/Cargo.toml index d4b6cc72..58be85f0 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -17,9 +17,8 @@ serde_json.workspace = true serde_derive.workspace = true tokio.workspace = true -revm = { version = "3.5.0", default-features = false, features = ["std"] } -snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "v0.1" } -snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "v0.1", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } +snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop" } +snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } halo2_proofs.workspace = true prover.workspace = true @@ -27,3 +26,4 @@ prover.workspace = true [features] default = ["prove_verify"] prove_verify = [] +fix_later = [] # commented codes diff --git a/integration/configs/layer3.config b/integration/configs/layer3.config index be4fea74..6b6b86a7 100644 --- a/integration/configs/layer3.config +++ b/integration/configs/layer3.config @@ -2,7 +2,7 @@ "strategy": "Simple", "degree": 21, "num_advice": [ - 63 + 85 ], "num_lookup_advice": [ 8 diff --git a/integration/src/capacity_checker.rs b/integration/src/capacity_checker.rs index c2f9e56e..fdcc937a 100644 --- a/integration/src/capacity_checker.rs +++ b/integration/src/capacity_checker.rs @@ -1,11 +1,8 @@ use itertools::Itertools; use prover::{ - zkevm::{ - circuit::{block_traces_to_witness_block, calculate_row_usage_of_witness_block}, - CircuitCapacityChecker, RowUsage, SubCircuitRowUsage, - }, - zkevm_circuits::evm_circuit::ExecutionState, - BlockTrace, + calculate_row_usage_of_witness_block, chunk_trace_to_witness_block, + eth_types::l2_types::BlockTrace, zkevm_circuits::evm_circuit::ExecutionState, + CircuitCapacityChecker, RowUsage, SubCircuitRowUsage, }; use std::time::Duration; @@ -13,7 +10,6 @@ use std::time::Duration; pub enum CCCMode { Optimal, Siger, - FollowerLight, FollowerFull, } @@ -39,7 +35,6 @@ pub fn run_circuit_capacity_checker( match mode { CCCMode::Optimal => ccc_by_chunk(batch_id, chunk_id, block_traces), CCCMode::Siger => ccc_as_signer(chunk_id, block_traces), - CCCMode::FollowerLight => ccc_as_follower_light(chunk_id, block_traces), CCCMode::FollowerFull => ccc_as_follower_full(chunk_id, block_traces), }, ) @@ -155,7 +150,6 @@ fn get_ccc_result_of_chunk( blocks: &[BlockTrace], by_block: bool, // by block instead of by tx norm: bool, - light_mode: bool, tag: &str, ) -> (RowUsage, Duration) { log::info!( @@ -167,11 +161,6 @@ fn get_ccc_result_of_chunk( ); let mut checker = CircuitCapacityChecker::new(); - checker.light_mode = light_mode; - - if !checker.light_mode && !by_block { - unimplemented!("!checker.light_mode && !by_block") - } let start_time = std::time::Instant::now(); @@ -221,29 +210,14 @@ fn get_ccc_result_of_chunk( } #[allow(dead_code)] -fn get_ccc_result_by_whole_block( - chunk_id: u64, - light_mode: bool, - blocks: &[BlockTrace], -) -> RowUsage { - log::info!("estimating circuit rows whole block, light_mode {light_mode}"); +fn get_ccc_result_by_whole_block(chunk_id: u64, blocks: &[BlockTrace]) -> RowUsage { let mut checker = CircuitCapacityChecker::new(); - checker.light_mode = light_mode; for block in blocks { checker.estimate_circuit_capacity(block.clone()).unwrap(); } let ccc_result = checker.get_acc_row_usage(false); - pretty_print_row_usage( - &ccc_result, - blocks, - chunk_id, - if light_mode { - "block-light" - } else { - "block-full" - }, - ); + pretty_print_row_usage(&ccc_result, blocks, chunk_id, "block-full"); ccc_result } @@ -285,7 +259,7 @@ pub fn ccc_by_chunk( log::info!("ccc_by_chunk: run ccc for batch-{batch_id} chunk-{chunk_id}"); let start_time = std::time::Instant::now(); - let witness_block = block_traces_to_witness_block(Vec::from(block_traces)).unwrap(); + let witness_block = chunk_trace_to_witness_block(Vec::from(block_traces)).unwrap(); let rows = calculate_row_usage_of_witness_block(&witness_block).unwrap(); let row_usage = RowUsage::from_row_usage_details(rows); pretty_print_row_usage(&row_usage, block_traces, chunk_id, "chunk-opt"); @@ -298,14 +272,9 @@ pub fn ccc_by_chunk( } pub fn ccc_as_signer(chunk_id: u64, blocks: &[BlockTrace]) -> (RowUsage, Duration) { - get_ccc_result_of_chunk(chunk_id, blocks, false, false, true, "chunk-signer") -} - -/// current stats inside db -pub fn ccc_as_follower_light(chunk_id: u64, blocks: &[BlockTrace]) -> (RowUsage, Duration) { - get_ccc_result_of_chunk(chunk_id, blocks, true, false, true, "chunk-f-l") + get_ccc_result_of_chunk(chunk_id, blocks, false, false, "chunk-signer") } pub fn ccc_as_follower_full(chunk_id: u64, blocks: &[BlockTrace]) -> (RowUsage, Duration) { - get_ccc_result_of_chunk(chunk_id, blocks, true, false, false, "chunk-f-f") + get_ccc_result_of_chunk(chunk_id, blocks, true, false, "chunk-f-f") } diff --git a/integration/src/evm.rs b/integration/src/evm.rs deleted file mode 100644 index e2c5bb2c..00000000 --- a/integration/src/evm.rs +++ /dev/null @@ -1,59 +0,0 @@ -use revm::{ - primitives::{CreateScheme, ExecutionResult, Output, TransactTo, TxEnv}, - InMemoryDB, EVM, -}; - -/// Deploy contract and then call with calldata. -/// Returns gas_used of call to deployed contract if both transactions are successful. -pub fn deploy_and_call(deployment_code: Vec, calldata: Vec) -> Result { - let mut evm = EVM { - env: Default::default(), - db: Some(InMemoryDB::default()), - }; - - evm.env.tx = TxEnv { - gas_limit: u64::MAX, - transact_to: TransactTo::Create(CreateScheme::Create), - data: deployment_code.into(), - ..Default::default() - }; - - let result = evm.transact_commit().unwrap(); - let contract = match result { - ExecutionResult::Success { - output: Output::Create(_, Some(contract)), - .. - } => contract, - ExecutionResult::Revert { gas_used, output } => { - return Err(format!( - "Contract deployment transaction reverts with gas_used {gas_used} and output {:#x}", - output - )) - } - ExecutionResult::Halt { reason, gas_used } => return Err(format!( - "Contract deployment transaction halts unexpectedly with gas_used {gas_used} and reason {:?}", - reason - )), - _ => unreachable!(), - }; - - evm.env.tx = TxEnv { - gas_limit: u64::MAX, - transact_to: TransactTo::Call(contract), - data: calldata.into(), - ..Default::default() - }; - - let result = evm.transact_commit().unwrap(); - match result { - ExecutionResult::Success { gas_used, .. } => Ok(gas_used), - ExecutionResult::Revert { gas_used, output } => Err(format!( - "Contract call transaction reverts with gas_used {gas_used} and output {:#x}", - output - )), - ExecutionResult::Halt { reason, gas_used } => Err(format!( - "Contract call transaction halts unexpectedly with gas_used {gas_used} and reason {:?}", - reason - )), - } -} diff --git a/integration/src/l2geth.rs b/integration/src/l2geth.rs index d96bd238..52a12f43 100644 --- a/integration/src/l2geth.rs +++ b/integration/src/l2geth.rs @@ -1,6 +1,6 @@ use anyhow::Result; use ethers_providers::{Http, Middleware, Provider}; -use prover::BlockTrace; +use prover::eth_types::l2_types::BlockTrace; use serde::Serialize; pub struct Client { diff --git a/integration/src/lib.rs b/integration/src/lib.rs index 8501cf68..b069aa44 100644 --- a/integration/src/lib.rs +++ b/integration/src/lib.rs @@ -1,6 +1,6 @@ pub mod capacity_checker; -pub mod evm; pub mod l2geth; +pub mod mock; pub mod prove; pub mod test_util; mod verifier; diff --git a/integration/src/mock.rs b/integration/src/mock.rs new file mode 100644 index 00000000..5a82f332 --- /dev/null +++ b/integration/src/mock.rs @@ -0,0 +1,35 @@ +use anyhow::bail; +use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr}; +use prover::{ + eth_types::l2_types::BlockTrace, + zkevm_circuits::{super_circuit::params::ScrollSuperCircuit, util::SubCircuit, witness::Block}, +}; +use snark_verifier_sdk::CircuitExt; + +use prover::{chunk_trace_to_witness_block, metric_of_witness_block, INNER_DEGREE}; + +pub fn mock_prove_target_circuit_chunk(block_traces: Vec) -> anyhow::Result<()> { + let witness_block = chunk_trace_to_witness_block(block_traces)?; + mock_prove_witness_block(&witness_block) +} + +pub fn mock_prove_witness_block(witness_block: &Block) -> anyhow::Result<()> { + log::info!( + "mock proving chunk, chunk metric {:?}", + metric_of_witness_block(witness_block) + ); + let circuit = ScrollSuperCircuit::new_from_block(witness_block); + let prover = MockProver::::run(*INNER_DEGREE, &circuit, circuit.instances())?; + if let Err(errs) = prover.verify_par() { + log::error!("err num: {}", errs.len()); + for err in &errs { + log::error!("{}", err); + } + bail!("{:#?}", errs); + } + log::info!( + "mock prove done. chunk metric: {:?}", + metric_of_witness_block(witness_block), + ); + Ok(()) +} diff --git a/integration/src/prove.rs b/integration/src/prove.rs index a677007b..a237a4da 100644 --- a/integration/src/prove.rs +++ b/integration/src/prove.rs @@ -1,19 +1,19 @@ use halo2_proofs::{halo2curves::bn256::Bn256, poly::kzg::commitment::ParamsKZG}; use prover::{ - aggregator::Prover as BatchProver, zkevm::Prover as ChunkProver, BatchData, BatchProof, - BatchProvingTask, BundleProvingTask, ChunkInfo, ChunkProof, ChunkProvingTask, MAX_AGG_SNARKS, + get_blob_bytes, BatchData, BatchProofV2, BatchProver, BatchProvingTask, BatchVerifier, + BundleProvingTask, ChunkInfo, ChunkProofV2, ChunkProver, ChunkProvingTask, ChunkVerifier, MAX_AGG_SNARKS, }; use std::{collections::BTreeMap, env, time::Instant}; -use crate::verifier::{new_batch_verifier, new_chunk_verifier, EVMVerifier}; +use crate::verifier::EVMVerifier; /// The `output_dir` is assumed to output_dir of chunk proving. pub fn new_batch_prover<'a>( params_map: &'a BTreeMap>, output_dir: &str, ) -> BatchProver<'a> { - env::set_var("HALO2_CHUNK_PROTOCOL", "chunk_chunk_halo2.protocol"); - env::set_var("SP1_CHUNK_PROTOCOL", "chunk_chunk_sp1.protocol"); + env::set_var("HALO2_CHUNK_PROTOCOL", "protocol_chunk_halo2.protocol"); + env::set_var("SP1_CHUNK_PROTOCOL", "protocol_chunk_sp1.protocol"); env::set_var("SCROLL_PROVER_ASSETS_DIR", output_dir); let prover = BatchProver::from_params_and_assets(params_map, output_dir); log::info!("Constructed batch prover"); @@ -132,13 +132,13 @@ pub fn prove_and_verify_chunk( prover: &mut ChunkProver, chunk_identifier: Option<&str>, skip_verify: bool, -) -> ChunkProof { +) -> ChunkProofV2 { let chunk_identifier = chunk_identifier.map_or_else(|| chunk.identifier(), |name| name.to_string()); let now = Instant::now(); let chunk_proof = prover - .gen_chunk_proof(chunk, Some(&chunk_identifier), None, Some(output_dir)) + .gen_halo2_chunk_proof(chunk, Some(&chunk_identifier), None, Some(output_dir)) .expect("cannot generate chunk snark"); log::info!( "finish generating chunk snark, elapsed: {:?}", @@ -157,8 +157,10 @@ pub fn prove_and_verify_chunk( "CHUNK_VK_FILENAME", &format!("vk_chunk_{chunk_identifier}.vkey"), ); - let verifier = new_chunk_verifier(params_map, output_dir); - assert!(verifier.verify_snark(chunk_proof.clone().to_snark())); + let verifier = ChunkVerifier::from_params_and_assets(params_map, output_dir); + verifier + .verify_chunk_proof(&chunk_proof) + .expect("should verify"); log::info!("Verified chunk proof"); chunk_proof @@ -169,10 +171,11 @@ pub fn prove_and_verify_batch( output_dir: &str, batch_prover: &mut BatchProver, batch: BatchProvingTask, -) -> BatchProof { +) -> BatchProofV2 { let chunk_num = batch.chunk_proofs.len(); log::info!("Prove batch BEGIN: chunk_num = {chunk_num}"); + let batch_id = batch.identifier(); let res_batch_proof = batch_prover.gen_batch_proof(batch, None, Some(output_dir)); if let Err(e) = res_batch_proof { log::error!("proving err: {e}"); @@ -180,11 +183,13 @@ pub fn prove_and_verify_batch( } let batch_proof = res_batch_proof.unwrap(); - env::set_var("BATCH_VK_FILENAME", "vk_batch_agg.vkey"); - let verifier = new_batch_verifier(params_map, output_dir); + env::set_var("BATCH_VK_FILENAME", format!("vk_batch_{batch_id}.vkey")); + let verifier = BatchVerifier::from_params_and_assets(params_map, output_dir); log::info!("Constructed aggregator verifier"); - assert!(verifier.verify_snark((&batch_proof).into())); + verifier + .verify_batch_proof(&batch_proof) + .expect("should verify"); log::info!("Verified batch proof"); log::info!("Prove batch END: chunk_num = {chunk_num}"); @@ -228,7 +233,7 @@ pub fn get_blob_from_chunks(chunks: &[ChunkInfo]) -> Vec { .concat(); let batch_data = BatchData::<{ MAX_AGG_SNARKS }>::new(chunks.len(), &chunks_with_padding); let batch_bytes = batch_data.get_batch_data_bytes(); - let blob_bytes = prover::aggregator::eip4844::get_blob_bytes(&batch_bytes); + let blob_bytes = get_blob_bytes(&batch_bytes); log::info!("blob_bytes len {}", blob_bytes.len()); blob_bytes } diff --git a/integration/src/test_util.rs b/integration/src/test_util.rs index b163d395..f5177ff7 100644 --- a/integration/src/test_util.rs +++ b/integration/src/test_util.rs @@ -1,14 +1,24 @@ -use std::path::{Path, PathBuf}; +use std::{ + io::Read, + path::{Path, PathBuf}, +}; use glob::glob; -use prover::{ - utils::{get_block_trace_from_file, read_env_var}, - BlockTrace, -}; +use prover::{eth_types::l2_types::BlockTrace, get_block_trace_from_file, read_env_var}; pub const ASSETS_DIR: &str = "./test_assets"; pub const PARAMS_DIR: &str = "./params"; +pub fn read_all

(filename: P) -> Vec +where + P: AsRef, +{ + let mut buf = vec![]; + let mut fd = std::fs::File::open(filename).unwrap(); + fd.read_to_end(&mut buf).unwrap(); + buf +} + pub fn trace_path_for_test() -> String { // use trace file of post-curie upgrade read_env_var( diff --git a/integration/src/verifier.rs b/integration/src/verifier.rs index a838d0d6..25bf6b8a 100644 --- a/integration/src/verifier.rs +++ b/integration/src/verifier.rs @@ -1,47 +1,6 @@ -use halo2_proofs::{halo2curves::bn256::Bn256, poly::kzg::commitment::ParamsKZG}; -use prover::{common::Verifier, config, consts, io::force_to_read, CompressionCircuit}; -use std::{collections::BTreeMap, env}; +use std::path::PathBuf; -type SnarkVerifier<'a> = Verifier<'a, CompressionCircuit>; - -// FIXME: why we use common::Verifier instead of ChunkVerifier here? -pub fn new_chunk_verifier<'a>( - params_map: &'a BTreeMap>, - assets_dir: &str, -) -> SnarkVerifier<'a> { - let raw_vk = force_to_read(assets_dir, &consts::chunk_vk_filename()); - if raw_vk.is_empty() { - panic!( - "empty vk read from {}/{}", - assets_dir, - &consts::chunk_vk_filename() - ); - } - env::set_var("COMPRESSION_CONFIG", &*config::LAYER2_CONFIG_PATH); - let params = params_map - .get(&config::LAYER2_DEGREE) - .expect("should be loaded"); - SnarkVerifier::from_params(params, &raw_vk) -} - -pub fn new_batch_verifier<'a>( - params_map: &'a BTreeMap>, - assets_dir: &str, -) -> SnarkVerifier<'a> { - let raw_vk = force_to_read(assets_dir, &consts::batch_vk_filename()); - if raw_vk.is_empty() { - panic!( - "empty vk read from {}/{}", - assets_dir, - &consts::batch_vk_filename() - ); - } - env::set_var("COMPRESSION_CONFIG", &*config::LAYER4_CONFIG_PATH); - let params = params_map - .get(&config::LAYER4_DEGREE) - .expect("should be loaded"); - SnarkVerifier::from_params(params, &raw_vk) -} +use prover::{force_read, DEPLOYMENT_CODE_FILENAME}; #[derive(Debug)] pub struct EVMVerifier(Vec); @@ -52,7 +11,8 @@ impl EVMVerifier { } pub fn from_dirs(assets_dir: &str) -> Self { - Self::new(force_to_read(assets_dir, &consts::DEPLOYMENT_CODE_FILENAME)) + let path = PathBuf::from(assets_dir).join(DEPLOYMENT_CODE_FILENAME.clone()); + Self::new(force_read(&path)) } pub fn verify_evm_proof(&self, call_data: Vec) -> bool { diff --git a/integration/tests/batch_tests.rs b/integration/tests/batch_tests.rs index 8e6adb36..ef98ffe6 100644 --- a/integration/tests/batch_tests.rs +++ b/integration/tests/batch_tests.rs @@ -1,5 +1,5 @@ use integration::prove::{new_batch_prover, prove_and_verify_batch}; -use prover::{io::from_json_file, utils::init_env_and_log, BatchProvingTask}; +use prover::{init_env_and_log, read_json_deep, BatchProvingTask}; use std::{fs, path::PathBuf}; #[cfg(feature = "prove_verify")] @@ -7,14 +7,14 @@ use std::{fs, path::PathBuf}; fn test_batch_prove_verify() { use integration::test_util::PARAMS_DIR; use itertools::Itertools; - use prover::config::AGG_DEGREES; + use prover::BATCH_PROVER_DEGREES; let output_dir = init_env_and_log("batch_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let params_map = prover::common::Prover::load_params_map( + let params_map = prover::Prover::load_params_map( PARAMS_DIR, - &AGG_DEGREES.iter().copied().collect_vec(), + &BATCH_PROVER_DEGREES.iter().copied().collect_vec(), ); //let task_path = "tests/test_data/batch-task-with-blob.json"; // zstd @@ -26,7 +26,7 @@ fn test_batch_prove_verify() { .chunk_proofs .clone() .into_iter() - .map(|p| p.chunk_info) + .map(|p| p.inner.chunk_info().clone()) .collect::>(); let corrected_batch_header = prover::BatchHeader::construct_from_chunks( batch.batch_header.version, @@ -50,14 +50,13 @@ fn test_batch_prove_verify() { fn test_batches_with_each_chunk_num_prove_verify() { use integration::test_util::PARAMS_DIR; use itertools::Itertools; - use prover::config::AGG_DEGREES; let output_dir = init_env_and_log("batches_with_each_chunk_num_tests"); log::info!("Initialized ENV and use output-dir {output_dir}"); - let params_map = prover::common::Prover::load_params_map( + let params_map = prover::Prover::load_params_map( PARAMS_DIR, - &AGG_DEGREES.iter().copied().collect_vec(), + &prover::BATCH_PROVER_DEGREES.iter().copied().collect_vec(), ); let batch = load_batch_proving_task("tests/test_data/full_proof_1.json"); @@ -170,11 +169,11 @@ fn test_batch_prove_verify_after_chunk_tests() { } fn load_batch_proving_task(batch_task_file: &str) -> BatchProvingTask { - let batch: BatchProvingTask = from_json_file(batch_task_file).unwrap(); + let batch: BatchProvingTask = read_json_deep(batch_task_file).unwrap(); let tx_bytes_total_len: usize = batch .chunk_proofs .iter() - .map(|c| c.chunk_info.tx_bytes.len()) + .map(|c| c.inner.chunk_info().tx_bytes.len()) .sum(); log::info!("Loaded chunk-hashes and chunk-proofs, batch info: chunk num {}, tx_bytes_total_len {tx_bytes_total_len}", batch.chunk_proofs.len()); batch diff --git a/integration/tests/bundle_tests.rs b/integration/tests/bundle_tests.rs index 502bd531..78207258 100644 --- a/integration/tests/bundle_tests.rs +++ b/integration/tests/bundle_tests.rs @@ -1,5 +1,5 @@ use integration::prove::{new_batch_prover, prove_and_verify_bundle}; -use prover::{io::from_json_file, utils::init_env_and_log, BatchProof, BundleProvingTask}; +use prover::{init_env_and_log, read_json, BatchProofV2, BundleProvingTask}; //use std::{fs, path::PathBuf}; #[cfg(feature = "prove_verify")] @@ -7,14 +7,14 @@ use prover::{io::from_json_file, utils::init_env_and_log, BatchProof, BundleProv fn test_bundle_prove_verify() { use integration::test_util::PARAMS_DIR; use itertools::Itertools; - use prover::config::AGG_DEGREES; + use prover::BATCH_PROVER_DEGREES; let output_dir = init_env_and_log("bundle_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let params_map = prover::common::Prover::load_params_map( + let params_map = prover::Prover::load_params_map( PARAMS_DIR, - &AGG_DEGREES.iter().copied().collect_vec(), + &BATCH_PROVER_DEGREES.iter().copied().collect_vec(), ); let bundle_task = gen_bundle_proving_task(&[ @@ -30,8 +30,11 @@ fn gen_bundle_proving_task(batch_proof_files: &[&str]) -> BundleProvingTask { let mut batch_proofs = Vec::new(); for proof_file in batch_proof_files { - let batch_proof: BatchProof = from_json_file(proof_file).unwrap(); - log::debug!("Loaded batch-proofs, header {:#?}", batch_proof.batch_hash,); + let batch_proof: BatchProofV2 = read_json(proof_file).unwrap(); + log::debug!( + "Loaded batch-proofs, header {:#?}", + batch_proof.inner.batch_hash + ); batch_proofs.push(batch_proof); } diff --git a/integration/tests/chunk_tests.rs b/integration/tests/chunk_tests.rs index cff605c3..60286850 100644 --- a/integration/tests/chunk_tests.rs +++ b/integration/tests/chunk_tests.rs @@ -2,9 +2,7 @@ use integration::{ prove::{prove_and_verify_chunk, prove_and_verify_sp1_chunk, SP1Prover}, test_util::{load_chunk, trace_path_for_test, ASSETS_DIR, PARAMS_DIR}, }; -use prover::{ - config::ZKEVM_DEGREES, utils::init_env_and_log, zkevm::Prover as ChunkProver, ChunkProvingTask, -}; +use prover::{init_env_and_log, ChunkProvingTask, CHUNK_PROVER_DEGREES}; #[cfg(feature = "prove_verify")] #[test] @@ -13,7 +11,7 @@ fn test_chunk_prove_verify() { let output_dir = init_env_and_log("chunk_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let params_map = prover::common::Prover::load_params_map( + let params_map = prover::Prover::load_params_map( PARAMS_DIR, &ZKEVM_DEGREES.iter().copied().collect_vec(), ); @@ -34,9 +32,9 @@ fn test_sp1_chunk_prove_verify() { let output_dir = init_env_and_log("chunk_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let params_map = prover::common::Prover::load_params_map( + let params_map = prover::Prover::load_params_map( PARAMS_DIR, - &ZKEVM_DEGREES.iter().copied().collect_vec(), + &CHUNK_PROVER_DEGREES.iter().copied().collect_vec(), ); let trace_path = trace_path_for_test(); @@ -54,7 +52,7 @@ fn test_sp1_chunk_prove_verify() { }; let traces = load_chunk(&trace_path).1; - let chunk = ChunkProvingTask::new(traces, prover::ChunkKind::Sp1); + let chunk = ChunkProvingTask::new(traces); let mut prover = SP1Prover::from_params_and_assets(¶ms_map, ASSETS_DIR); log::info!("Constructed sp1 chunk prover"); prove_and_verify_sp1_chunk( diff --git a/integration/tests/e2e_tests.rs b/integration/tests/e2e_tests.rs index 3b98128f..93eaada0 100644 --- a/integration/tests/e2e_tests.rs +++ b/integration/tests/e2e_tests.rs @@ -1,46 +1,43 @@ use halo2_proofs::{halo2curves::bn256::Bn256, poly::kzg::commitment::ParamsKZG}; use integration::{ prove::{get_blob_from_chunks, prove_and_verify_chunk, prove_and_verify_sp1_chunk, SP1Prover}, - test_util::{load_batch, load_chunk, load_chunk_for_test, ASSETS_DIR, PARAMS_DIR}, + test_util::{load_batch, load_chunk, ASSETS_DIR, PARAMS_DIR}, }; use prover::{ - eth_types::H256, - proof::dump_as_json, - utils::{chunk_trace_to_witness_block, init_env_and_log, read_env_var}, - zkevm, BatchHash, BatchHeader, BatchProvingTask, ChunkInfo, ChunkKind, ChunkProvingTask, - MAX_AGG_SNARKS, + eth_types::H256, init_env_and_log, read_env_var, BatchHeader, BatchProvingTask, ChunkProver, + ChunkProvingTask, MAX_AGG_SNARKS, }; -use std::{collections::BTreeMap, env}; - -fn load_test_batch() -> anyhow::Result> { - let batch_dir = read_env_var("TRACE_PATH", "./tests/extra_traces/batch_25".to_string()); - load_batch(&batch_dir) -} +use std::collections::BTreeMap; +/* +#[cfg(feature = "fix_later")] #[test] fn test_batch_pi_consistency() { let output_dir = init_env_and_log("batch_pi"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let trace_paths = load_test_batch().unwrap(); + + let batch_dir = prover::read_env_var("TRACE_PATH", "./tests/extra_traces/batch_25".to_string()); + let trace_paths = load_batch(&batch_dir).unwrap(); log_batch_pi(&trace_paths); } +*/ #[cfg(feature = "prove_verify")] #[test] fn test_e2e_prove_verify() { use integration::prove::{new_batch_prover, prove_and_verify_batch, prove_and_verify_bundle}; use itertools::Itertools; - use prover::config::{AGG_DEGREES, ZKEVM_DEGREES}; + use prover::{dump_as_json, BATCH_PROVER_DEGREES, CHUNK_PROVER_DEGREES}; let output_dir = init_env_and_log("e2e_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let params_map = prover::common::Prover::load_params_map( + let params_map = prover::Prover::load_params_map( PARAMS_DIR, - &ZKEVM_DEGREES + &CHUNK_PROVER_DEGREES .iter() .copied() - .chain(AGG_DEGREES.iter().copied()) + .chain(BATCH_PROVER_DEGREES.iter().copied()) .collect_vec(), ); @@ -95,7 +92,7 @@ fn test_e2e_prove_verify() { "batch proof {}, prev hash {:x?}, current {:x?}", i, batch_header.parent_batch_hash, - batch_proof.batch_hash, + batch_proof.inner.batch_hash, ); opt_batch_header.replace(batch_header); batch_proofs.push(batch_proof); @@ -272,19 +269,19 @@ fn test_batch_bundle_verify() -> anyhow::Result<()> { test_util::read_dir, }; use itertools::Itertools; - use prover::{config::AGG_DEGREES, io::from_json_file, BundleProvingTask}; + use prover::{read_json_deep, BundleProvingTask, ProverError, BATCH_PROVER_DEGREES}; let output_dir = init_env_and_log("batch_bundle_tests"); - let params_map = prover::common::Prover::load_params_map( + let params_map = prover::Prover::load_params_map( PARAMS_DIR, - &AGG_DEGREES.iter().copied().collect_vec(), + &BATCH_PROVER_DEGREES.iter().copied().collect_vec(), ); let batch_tasks_paths = read_dir("./tests/test_data/batch_tasks")?; - let batch_tasks = batch_tasks_paths + let batch_tasks: Vec = batch_tasks_paths .iter() - .map(|path| from_json_file::(&path.as_path().to_string_lossy())) - .collect::>>()?; + .map(read_json_deep) + .collect::, ProverError>>()?; log::info!("num batch tasks = {}", batch_tasks.len()); @@ -378,7 +375,7 @@ fn gen_batch_proving_task( }) .collect::>() } else { - let mut zkevm_prover = zkevm::Prover::from_params_and_assets(params_map, ASSETS_DIR); + let mut zkevm_prover = ChunkProver::from_params_and_assets(params_map, ASSETS_DIR); log::info!("Constructed zkevm prover"); chunks .into_iter() @@ -402,10 +399,11 @@ fn gen_batch_proving_task( 0xab, 0xac, 0xad, 0xae, 0xaf, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]); + let chunks = chunk_proofs .clone() .into_iter() - .map(|cp| cp.chunk_info) + .map(|cp| cp.inner.chunk_info().clone()) .collect::>(); let blob_bytes = get_blob_from_chunks(&chunks); @@ -433,6 +431,8 @@ fn gen_batch_proving_task( ) } +/* +#[cfg(feature = "fix_later")] fn log_batch_pi(trace_paths: &[String]) { let max_num_snarks = prover::MAX_AGG_SNARKS; let chunk_traces: Vec<_> = trace_paths @@ -500,6 +500,7 @@ fn log_batch_pi(trace_paths: &[String]) { println!("blob.coeffs[{}]: {elem:x}", i); } } +*/ fn dump_chunk_protocol(batch: &BatchProvingTask, output_dir: &str) { // Dump chunk-procotol to "chunk_chunk_0.protocol" for batch proving. diff --git a/integration/tests/inner_tests.rs b/integration/tests/inner_tests.rs deleted file mode 100644 index 983fe020..00000000 --- a/integration/tests/inner_tests.rs +++ /dev/null @@ -1,32 +0,0 @@ -use integration::test_util::{load_chunk_for_test, PARAMS_DIR}; -use prover::{inner::Verifier, utils::init_env_and_log, zkevm::circuit::SuperCircuit}; - -#[cfg(feature = "prove_verify")] -#[test] -fn test_inner_prove_verify() { - use itertools::Itertools; - use prover::config::ZKEVM_DEGREES; - - let test_name = "inner_tests"; - let output_dir = init_env_and_log(test_name); - log::info!("Initialized ENV and created output-dir {output_dir}"); - - let params_map = prover::common::Prover::load_params_map( - PARAMS_DIR, - &ZKEVM_DEGREES.iter().copied().collect_vec(), - ); - - let chunk_trace = load_chunk_for_test().1; - log::info!("Loaded chunk trace"); - - let inner_prover = prover::common::Prover::from_params_map(¶ms_map); - let mut prover = prover::inner::Prover::::from(inner_prover); - log::info!("Constructed prover"); - - let snark = prover.gen_inner_snark("inner", chunk_trace).unwrap(); - log::info!("Got inner snark"); - - let verifier = Verifier::::from_params_map(¶ms_map, None); - assert!(verifier.verify_inner_snark(snark)); - log::info!("Finish inner snark verification"); -} diff --git a/integration/tests/integration.rs b/integration/tests/integration.rs index d17212e7..be92d2cc 100644 --- a/integration/tests/integration.rs +++ b/integration/tests/integration.rs @@ -1,15 +1,6 @@ -use halo2_proofs::{ - plonk::{keygen_pk2, keygen_vk}, - poly::commitment::Params, -}; -use integration::test_util::{load_chunk_for_test, PARAMS_DIR}; -use prover::{ - config::INNER_DEGREE, - io::serialize_vk, - utils::{init_env_and_log, load_params}, - zkevm::circuit::{block_traces_to_witness_block, SuperCircuit, TargetCircuit}, - zkevm_circuits::util::SubCircuit, -}; +use halo2_proofs::poly::commitment::Params; +use integration::test_util::PARAMS_DIR; +use prover::{init_env_and_log, load_params}; #[ignore] #[test] @@ -30,8 +21,8 @@ fn test_load_params() { assert_eq!(params19.g2(), downsized_params19.g2()); assert_eq!(params19.s_g2(), downsized_params19.s_g2()); } - -#[ignore] +/* +#[cfg(feature = "fix_later")] #[test] fn test_cs_same_for_vk_consistent() { let params = load_params(PARAMS_DIR, *INNER_DEGREE, None).unwrap(); @@ -46,7 +37,7 @@ fn test_cs_same_for_vk_consistent() { ); let block_traces = load_chunk_for_test().1; - let witness_block = block_traces_to_witness_block(block_traces).unwrap(); + let witness_block = chunk_trace_to_witness_block(block_traces).unwrap(); let real_circuit = SuperCircuit::from_witness_block(&witness_block).unwrap(); let pk = keygen_pk2(¶ms, &real_circuit).unwrap(); @@ -57,7 +48,7 @@ fn test_cs_same_for_vk_consistent() { ); } -#[cfg(feature = "prove_verify")] +#[cfg(feature = "fix_later")] #[test] fn test_deterministic() { use halo2_proofs::dev::MockProver; @@ -91,7 +82,7 @@ fn test_deterministic() { log::info!("test_deterministic done"); } -#[cfg(feature = "prove_verify")] +#[cfg(feature = "fix_later")] #[test] fn test_vk_same() { use halo2_proofs::dev::MockProver; @@ -181,3 +172,4 @@ fn test_vk_same() { assert_eq!(vk_empty.transcript_repr(), vk_real.transcript_repr()); } } + */ diff --git a/integration/tests/mock_tests.rs b/integration/tests/mock_tests.rs index d47f902a..c71b358e 100644 --- a/integration/tests/mock_tests.rs +++ b/integration/tests/mock_tests.rs @@ -1,11 +1,12 @@ use integration::test_util::load_chunk_for_test; -use prover::{inner::Prover, utils::init_env_and_log, zkevm::circuit::SuperCircuit}; - #[cfg(feature = "prove_verify")] #[test] fn test_mock_prove() { + use integration::mock::mock_prove_target_circuit_chunk; + use prover::init_env_and_log; + init_env_and_log("mock_tests"); let block_traces = load_chunk_for_test().1; - Prover::::mock_prove_target_circuit_chunk(block_traces).unwrap(); + mock_prove_target_circuit_chunk(block_traces).unwrap(); } diff --git a/integration/tests/unit_tests.rs b/integration/tests/unit_tests.rs index df234683..a7b061a0 100644 --- a/integration/tests/unit_tests.rs +++ b/integration/tests/unit_tests.rs @@ -2,12 +2,11 @@ use integration::{ capacity_checker::{prepare_circuit_capacity_checker, run_circuit_capacity_checker, CCCMode}, - test_util::load_chunk_for_test, + test_util::{load_chunk_for_test, read_all}, }; use prover::{ - io::read_all, - utils::{init_env_and_log, short_git_version}, - zkevm::circuit::{block_traces_to_witness_block, TargetCircuit}, + calculate_row_usage_of_witness_block, chunk_trace_to_witness_block, init_env_and_log, + read_json, short_git_version, }; #[test] @@ -46,7 +45,7 @@ fn test_evm_verifier() { log::info!("svm use {}", version); let bytecode = compile_yul(&String::from_utf8(yul.clone()).unwrap()); log::info!("bytecode len {}", bytecode.len()); - match integration::evm::deploy_and_call(bytecode, proof.clone()) { + match prover::deploy_and_call(bytecode, proof.clone()) { Ok(gas) => log::info!("gas cost {gas}"), Err(e) => { panic!("test failed {e:#?}"); @@ -57,7 +56,7 @@ fn test_evm_verifier() { log::info!("check released bin"); let bytecode = read_all(&format!("../{version}/evm_verifier.bin")); log::info!("bytecode len {}", bytecode.len()); - match integration::evm::deploy_and_call(bytecode, proof.clone()) { + match prover::deploy_and_call(bytecode, proof.clone()) { Ok(gas) => log::info!("gas cost {gas}"), Err(e) => { panic!("test failed {e:#?}"); @@ -65,29 +64,30 @@ fn test_evm_verifier() { } } -// suppose a "proof.json" has been provided under the 'release' -// directory or the test would fail #[ignore] #[test] fn test_evm_verifier_for_dumped_proof() { - use prover::{io::from_json_file, proof::BundleProof}; - init_env_and_log("test_evm_verifer"); log::info!("cwd {:?}", std::env::current_dir()); - let version = "release-v0.12.0-rc.2"; - let proof: BundleProof = from_json_file(&format!("../{version}/proof.json")).unwrap(); + let search_pattern = "outputs/e2e_tests_*/full_proof_bundle_recursion.json"; + + let paths = glob::glob(search_pattern).expect("Failed to read glob pattern"); - let proof_dump = proof.clone().proof_to_verify(); - log::info!("pi dump {:#?}", proof_dump.instances()); + let mut path = paths.last().unwrap().unwrap(); + log::info!("proof path {}", path.display()); + let proof: prover::BundleProof = read_json(&path).unwrap(); let proof = proof.calldata(); log::info!("calldata len {}", proof.len()); log::info!("check released bin"); - let bytecode = read_all(&format!("../{version}/evm_verifier.bin")); + path.pop(); + path.push("evm_verifier.bin"); + let bytecode = read_all(path); log::info!("bytecode len {}", bytecode.len()); - match integration::evm::deploy_and_call(bytecode, proof.clone()) { + + match prover::deploy_and_call(bytecode, proof.clone()) { Ok(gas) => log::info!("gas cost {gas}"), Err(e) => { panic!("test failed {e:#?}"); @@ -119,13 +119,13 @@ fn estimate_circuit_rows() { prepare_circuit_capacity_checker(); let (_, block_trace) = load_chunk_for_test(); - let witness_block = block_traces_to_witness_block(block_trace).unwrap(); + let witness_block = chunk_trace_to_witness_block(block_trace).unwrap(); log::info!("estimating used rows"); - let row_usage = ::Inner::min_num_rows_block_subcircuits(&witness_block); + let row_usage = calculate_row_usage_of_witness_block(&witness_block).unwrap(); let r = row_usage .iter() - .max_by_key(|x| x.row_num_real) + .max_by_key(|x| x.row_number) .unwrap() .clone(); - log::info!("final rows: {} {}", r.row_num_real, r.name); + log::info!("final rows: {} {}", r.row_number, r.name); }