From fd24b813084674947aba5e3bfe0d6a73f4d0ebe6 Mon Sep 17 00:00:00 2001 From: frisitano Date: Wed, 10 Apr 2024 13:52:25 +0100 Subject: [PATCH 01/13] introduce native tracer support --- Cargo.lock | 1273 +++++++++++++++++++++++--- Cargo.toml | 7 +- leader/src/cli.rs | 19 + leader/src/{jerigon.rs => client.rs} | 14 +- leader/src/main.rs | 29 +- rpc/Cargo.toml | 3 + rpc/src/cli.rs | 3 + rpc/src/lib.rs | 2 +- rpc/src/main.rs | 25 +- rpc/src/rpc/.DS_Store | Bin 0 -> 6148 bytes rpc/src/{rpc.rs => rpc/jerigon.rs} | 176 ++-- rpc/src/rpc/mod.rs | 25 + rpc/src/rpc/native/mod.rs | 303 ++++++ rpc/src/rpc/native/trie.rs | 122 +++ 14 files changed, 1780 insertions(+), 221 deletions(-) rename leader/src/{jerigon.rs => client.rs} (81%) create mode 100644 rpc/src/rpc/.DS_Store rename rpc/src/{rpc.rs => rpc/jerigon.rs} (70%) create mode 100644 rpc/src/rpc/mod.rs create mode 100644 rpc/src/rpc/native/mod.rs create mode 100644 rpc/src/rpc/native/trie.rs diff --git a/Cargo.lock b/Cargo.lock index fb85f5d2..6770b655 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.21.0" @@ -17,6 +27,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.8.11" @@ -41,9 +62,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "amq-protocol" @@ -158,9 +179,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" dependencies = [ "backtrace", ] @@ -171,26 +192,34 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + [[package]] name = "async-channel" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", - "event-listener 5.2.0", - "event-listener-strategy 0.5.0", + "event-listener 5.3.0", + "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" -version = "1.8.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" dependencies = [ - "async-lock 3.3.0", "async-task", "concurrent-queue", "fastrand 2.0.2", @@ -346,7 +375,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.1", "hyper-util", "itoa", "matchit", @@ -417,12 +446,51 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -481,11 +549,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "sha2", + "tinyvec", +] + [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byte-slice-cast" @@ -508,6 +586,59 @@ dependencies = [ "serde", ] +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cbc" version = "0.1.2" @@ -519,7 +650,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" @@ -531,15 +662,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -598,7 +729,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] @@ -625,6 +756,58 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +[[package]] +name = "coins-bip32" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" +dependencies = [ + "bs58", + "coins-core", + "digest", + "hmac", + "k256", + "serde", + "sha2", + "thiserror", +] + +[[package]] +name = "coins-bip39" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" +dependencies = [ + "bitvec", + "coins-bip32", + "hmac", + "once_cell", + "pbkdf2 0.12.2", + "rand", + "sha2", + "thiserror", +] + +[[package]] +name = "coins-core" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" +dependencies = [ + "base64 0.21.7", + "bech32", + "bs58", + "digest", + "generic-array", + "hex", + "ripemd", + "serde", + "serde_derive", + "sha2", + "sha3", + "thiserror", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -655,6 +838,25 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-hex" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" +dependencies = [ + "cfg-if", + "cpufeatures", + "hex", + "proptest", + "serde", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const-random" version = "0.1.18" @@ -675,6 +877,12 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "cookie-factory" version = "0.3.3" @@ -709,6 +917,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + [[package]] name = "critical-section" version = "1.1.2" @@ -787,6 +1004,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -797,6 +1026,15 @@ dependencies = [ "typenum", ] +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + [[package]] name = "darling" version = "0.20.8" @@ -845,6 +1083,22 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -855,6 +1109,17 @@ dependencies = [ "serde", ] +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "des" version = "0.8.1" @@ -871,10 +1136,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -887,9 +1195,29 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" @@ -899,15 +1227,42 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" +[[package]] +name = "ena" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +dependencies = [ + "log", +] + [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] +[[package]] +name = "enr" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" +dependencies = [ + "base64 0.21.7", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] + [[package]] name = "enum-as-inner" version = "0.6.0" @@ -960,6 +1315,45 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "eth-keystore" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" +dependencies = [ + "aes", + "ctr", + "digest", + "hex", + "hmac", + "pbkdf2 0.11.0", + "rand", + "scrypt", + "serde", + "serde_json", + "sha2", + "sha3", + "thiserror", + "uuid 0.8.2", +] + +[[package]] +name = "ethabi" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" +dependencies = [ + "ethereum-types", + "hex", + "once_cell", + "regex", + "serde", + "serde_json", + "sha3", + "thiserror", + "uint", +] + [[package]] name = "ethbloom" version = "0.13.0" @@ -968,8 +1362,10 @@ checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", "fixed-hash 0.8.0", + "impl-codec", "impl-rlp", "impl-serde", + "scale-info", "tiny-keccak", ] @@ -981,9 +1377,11 @@ checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", "fixed-hash 0.8.0", + "impl-codec", "impl-rlp", "impl-serde", "primitive-types 0.12.2", + "scale-info", "uint", ] @@ -1006,9 +1404,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" dependencies = [ "concurrent-queue", "parking", @@ -1027,17 +1425,18 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ - "event-listener 5.2.0", + "event-listener 5.3.0", "pin-project-lite", ] [[package]] name = "evm_arithmetization" version = "0.1.3" +version = "0.1.3" source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" dependencies = [ "anyhow", @@ -1079,6 +1478,16 @@ dependencies = [ "async-trait", ] +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -1094,6 +1503,16 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + [[package]] name = "fixed-hash" version = "0.7.0" @@ -1115,6 +1534,22 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "flume" version = "0.10.14" @@ -1124,7 +1559,7 @@ dependencies = [ "futures-core", "futures-sink", "pin-project", - "spin", + "spin 0.9.8", ] [[package]] @@ -1133,7 +1568,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ - "spin", + "spin 0.9.8", ] [[package]] @@ -1151,6 +1586,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "funty" version = "2.0.0" @@ -1233,6 +1678,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "futures-locks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" +dependencies = [ + "futures-channel", + "futures-task", +] + [[package]] name = "futures-macro" version = "0.3.30" @@ -1256,6 +1711,16 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" +dependencies = [ + "gloo-timers", + "send_wrapper 0.4.0", +] + [[package]] name = "futures-util" version = "0.3.30" @@ -1274,6 +1739,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1282,13 +1756,14 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -1309,8 +1784,7 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ - "bytes", - "fnv", + "futures-channel", "futures-core", "futures-sink", "futures-util", @@ -1324,9 +1798,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -1359,6 +1833,15 @@ dependencies = [ "serde", ] +[[package]] +name = "hashers" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" +dependencies = [ + "fxhash", +] + [[package]] name = "heapless" version = "0.7.17" @@ -1369,7 +1852,7 @@ dependencies = [ "hash32", "rustc_version", "serde", - "spin", + "spin 0.9.8", "stable_deref_trait", ] @@ -1412,6 +1895,15 @@ dependencies = [ "digest", ] +[[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.12" @@ -1512,9 +2004,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" dependencies = [ "bytes", "futures-channel", @@ -1553,7 +2045,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.2.0", + "hyper 1.3.1", "pin-project-lite", "socket2 0.5.6", "tokio", @@ -1647,6 +2139,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "indexmap" version = "1.9.3" @@ -1769,6 +2267,43 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.7", + "pem", + "ring 0.16.20", + "serde", + "serde_json", + "simple_asn1", +] + +[[package]] +name = "k256" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2", + "signature", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + [[package]] name = "keccak-hash" version = "0.8.0" @@ -1846,6 +2381,22 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] + [[package]] name = "linkme" version = "0.3.25" @@ -1910,11 +2461,21 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mime" @@ -1951,6 +2512,7 @@ dependencies = [ [[package]] name = "mpt_trie" version = "0.2.1" +version = "0.2.1" source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" dependencies = [ "bytes", @@ -1972,6 +2534,12 @@ dependencies = [ "uint", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + [[package]] name = "nom" version = "7.1.3" @@ -1994,9 +2562,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" dependencies = [ "num-bigint", "num-complex", @@ -2073,6 +2641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -2100,6 +2669,31 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "open-fastrlp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", + "ethereum-types", + "open-fastrlp-derive", +] + +[[package]] +name = "open-fastrlp-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" +dependencies = [ + "bytes", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "openssl-probe" version = "0.1.5" @@ -2175,7 +2769,7 @@ dependencies = [ "tokio-util", "tracing", "tracing-subscriber", - "uuid", + "uuid 1.8.0", ] [[package]] @@ -2243,12 +2837,60 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "path-slash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest", + "hmac", + "password-hash", + "sha2", +] + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2257,9 +2899,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" dependencies = [ "memchr", "thiserror", @@ -2268,9 +2910,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" dependencies = [ "pest", "pest_generator", @@ -2278,9 +2920,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" dependencies = [ "pest", "pest_meta", @@ -2291,9 +2933,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" dependencies = [ "once_cell", "pest", @@ -2322,9 +2964,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -2355,6 +2997,22 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "plonky2" version = "0.2.2" @@ -2437,7 +3095,7 @@ dependencies = [ "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix 0.38.32", + "rustix 0.38.33", "tracing", "windows-sys 0.52.0", ] @@ -2486,6 +3144,7 @@ dependencies = [ "impl-codec", "impl-rlp", "impl-serde", + "scale-info", "uint", ] @@ -2500,9 +3159,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -2510,6 +3169,7 @@ dependencies = [ [[package]] name = "proof_gen" version = "0.1.3" +version = "0.1.3" source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" dependencies = [ "ethereum-types", @@ -2537,9 +3197,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2580,6 +3240,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + [[package]] name = "rayon" version = "1.10.0" @@ -2621,12 +3290,23 @@ dependencies = [ ] [[package]] -name = "redox_syscall" -version = "0.4.1" +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "bitflags 1.3.2", + "getrandom", + "libredox", + "thiserror", ] [[package]] @@ -2679,7 +3359,7 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -2714,6 +3394,31 @@ dependencies = [ "winreg", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted 0.7.1", + "web-sys", + "winapi", +] + [[package]] name = "ring" version = "0.17.8" @@ -2724,11 +3429,20 @@ dependencies = [ "cfg-if", "getrandom", "libc", - "spin", - "untrusted", + "spin 0.9.8", + "untrusted 0.9.0", "windows-sys 0.52.0", ] +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest", +] + [[package]] name = "rlp" version = "0.5.2" @@ -2736,6 +3450,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", + "rlp-derive", "rustc-hex", ] @@ -2755,13 +3470,16 @@ name = "rpc" version = "0.1.0" dependencies = [ "anyhow", + "async-trait", "clap", "common", "ethereum-types", + "ethers", "evm_arithmetization", "futures", "hex", "hex-literal", + "mpt_trie", "prover", "reqwest", "serde", @@ -2811,9 +3529,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" dependencies = [ "bitflags 2.5.0", "errno", @@ -2824,12 +3542,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", - "ring", + "ring 0.17.8", "rustls-webpki", "sct", ] @@ -2864,7 +3582,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64", + "base64 0.21.7", ] [[package]] @@ -2873,15 +3591,15 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring", - "untrusted", + "ring 0.17.8", + "untrusted 0.9.0", ] [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -2904,6 +3622,18 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scrypt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" +dependencies = [ + "hmac", + "pbkdf2 0.11.0", + "salsa20", + "sha2", +] + [[package]] name = "sct" version = "0.7.1" @@ -2922,9 +3652,9 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -2935,9 +3665,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -2948,21 +3678,36 @@ name = "semver" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +dependencies = [ + "serde", +] + +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", @@ -2990,6 +3735,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3008,7 +3762,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" dependencies = [ - "base64", + "base64 0.21.7", "chrono", "hex", "indexmap 1.9.3", @@ -3054,6 +3808,16 @@ dependencies = [ "digest", ] +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -3065,13 +3829,41 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -3107,6 +3899,26 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "solang-parser" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" +dependencies = [ + "itertools", + "lalrpop", + "lalrpop-util", + "phf", + "thiserror", + "unicode-xid", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spin" version = "0.9.8" @@ -3116,6 +3928,16 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3145,6 +3967,19 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared 0.10.0", + "precomputed-hash", +] + [[package]] name = "strsim" version = "0.10.0" @@ -3153,7 +3988,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" @@ -3163,6 +3998,26 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "svm-rs" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" +dependencies = [ + "dirs", + "fs2", + "hex", + "once_cell", + "reqwest", + "semver", + "serde", + "serde_json", + "sha2", + "thiserror", + "url", + "zip", +] + [[package]] name = "syn" version = "1.0.109" @@ -3247,18 +4102,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", @@ -3277,9 +4132,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -3298,9 +4153,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -3332,9 +4187,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -3406,6 +4261,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +dependencies = [ + "futures-util", + "log", + "rustls", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki-roots", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -3428,13 +4298,48 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap 2.2.6", + "serde", + "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.6", ] [[package]] @@ -3468,6 +4373,7 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "trace_decoder" version = "0.3.0" +version = "0.3.0" source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" dependencies = [ "bytes", @@ -3522,6 +4428,16 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tracing-log" version = "0.2.0" @@ -3557,6 +4473,26 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 0.2.12", + "httparse", + "log", + "rand", + "rustls", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.17.0" @@ -3581,6 +4517,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -3602,6 +4544,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "unroll" version = "0.1.5" @@ -3612,6 +4560,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "untrusted" version = "0.9.0" @@ -3629,12 +4583,28 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "uuid" version = "1.8.0" @@ -3680,6 +4650,16 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" +[[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" @@ -3824,7 +4804,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -3842,7 +4822,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -3862,17 +4842,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "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]] @@ -3883,9 +4864,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -3895,9 +4876,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -3907,9 +4888,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +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" @@ -3919,9 +4906,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -3931,9 +4918,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -3943,9 +4930,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -3955,9 +4942,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" @@ -3968,6 +4955,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -3993,6 +4989,25 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version", + "send_wrapper 0.6.0", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wyz" version = "0.5.1" @@ -4002,6 +5017,12 @@ dependencies = [ "tap", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "yasna" version = "0.5.2" diff --git a/Cargo.toml b/Cargo.toml index 4e8f5b57..46a3511b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,10 @@ keccak-hash = "0.10.0" # zk-evm dependencies plonky2 = "0.2.2" -evm_arithmetization = { git = "https://github.com/0xPolygonZero/zk_evm.git", branch = "develop" } -trace_decoder = { git = "https://github.com/0xPolygonZero/zk_evm.git", branch = "develop" } -proof_gen = { git = "https://github.com/0xPolygonZero/zk_evm.git", branch = "develop" } +evm_arithmetization = { path = "../zk_evm/evm_arithmetization" } +mpt_trie = { path = "../zk_evm/mpt_trie" } +trace_decoder = { path = "../zk_evm/trace_decoder" } +proof_gen = { path = "../zk_evm/proof_gen" } [workspace.package] edition = "2021" diff --git a/leader/src/cli.rs b/leader/src/cli.rs index 6ab9d8fb..d5087bbf 100644 --- a/leader/src/cli.rs +++ b/leader/src/cli.rs @@ -45,6 +45,25 @@ pub(crate) enum Command { #[arg(long, short = 'o', value_hint = ValueHint::FilePath)] proof_output_path: Option, }, + /// Reads input from a native node and writes output to stdout. + Native { + // The native RPC URL. + #[arg(long, short = 'u', value_hint = ValueHint::Url)] + rpc_url: String, + /// The block number for which to generate a proof. + #[arg(short, long)] + block_number: u64, + /// The checkpoint block number. + #[arg(short, long, default_value_t = 0)] + checkpoint_block_number: u64, + /// The previous proof output. + #[arg(long, short = 'f', value_hint = ValueHint::FilePath)] + previous_proof: Option, + /// If provided, write the generated proof to this file instead of + /// stdout. + #[arg(long, short = 'o', value_hint = ValueHint::FilePath)] + proof_output_path: Option, + }, /// Reads input from HTTP and writes output to a directory. Http { /// The port on which to listen. diff --git a/leader/src/jerigon.rs b/leader/src/client.rs similarity index 81% rename from leader/src/jerigon.rs rename to leader/src/client.rs index 899ea20e..55e3761a 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/client.rs @@ -7,22 +7,20 @@ use std::{ use anyhow::Result; use paladin::runtime::Runtime; use proof_gen::types::PlonkyProofIntern; +use rpc::RpcClient; /// The main function for the jerigon mode. -pub(crate) async fn jerigon_main( +pub(crate) async fn rpc_main( + client: T, runtime: Runtime, - rpc_url: &str, block_number: u64, checkpoint_block_number: u64, previous: Option, proof_output_path_opt: Option, ) -> Result<()> { - let prover_input = rpc::fetch_prover_input(rpc::FetchProverInputRequest { - rpc_url, - block_number, - checkpoint_block_number, - }) - .await?; + let prover_input = client + .fetch_prover_input(block_number, checkpoint_block_number) + .await?; let proof = prover_input.prove(&runtime, previous).await; runtime.close().await?; diff --git a/leader/src/main.rs b/leader/src/main.rs index 36d2f1e3..986c2d84 100644 --- a/leader/src/main.rs +++ b/leader/src/main.rs @@ -8,11 +8,12 @@ use dotenvy::dotenv; use ops::register; use paladin::runtime::Runtime; use proof_gen::types::PlonkyProofIntern; +use rpc::{JerigonRpcClient, NativeRpcClient}; mod cli; +mod client; mod http; mod init; -mod jerigon; mod stdio; fn get_previous_proof(path: Option) -> Result> { @@ -71,10 +72,32 @@ async fn main() -> Result<()> { proof_output_path, } => { let previous_proof = get_previous_proof(previous_proof)?; + let client = JerigonRpcClient::new(rpc_url); - jerigon::jerigon_main( + client::rpc_main( + client, + runtime, + block_number, + checkpoint_block_number, + previous_proof, + proof_output_path, + ) + .await?; + } + Command::Native { + rpc_url, + block_number, + checkpoint_block_number, + previous_proof, + proof_output_path, + } => { + let previous_proof = get_previous_proof(previous_proof)?; + let client = + NativeRpcClient::new(rpc_url).expect("should be able to create native rpc client"); + + client::rpc_main( + client, runtime, - &rpc_url, block_number, checkpoint_block_number, previous_proof, diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 999169f6..2943e8ec 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -9,6 +9,7 @@ keywords.workspace = true categories.workspace = true [dependencies] +async-trait = { version = "0.1" } tokio = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } @@ -20,6 +21,8 @@ serde_path_to_error = { workspace = true } clap = { workspace = true } ethereum-types = { workspace = true } evm_arithmetization = { workspace = true } +mpt_trie = { workspace = true } +ethers = "2.0.7" thiserror = { workspace = true } futures = { workspace = true } diff --git a/rpc/src/cli.rs b/rpc/src/cli.rs index 5afe67c7..3422a03c 100644 --- a/rpc/src/cli.rs +++ b/rpc/src/cli.rs @@ -13,6 +13,9 @@ pub(crate) enum Commands { /// The RPC URL #[arg(short = 'u', long, value_hint = ValueHint::Url)] rpc_url: String, + /// The RPC Tracer Type + #[arg(short = 't', long, default_value = "jerigon")] + rpc_type: String, /// The block number #[arg(short, long)] block_number: u64, diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 4e74ff49..073e2ecf 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -1,2 +1,2 @@ mod rpc; -pub use rpc::{fetch_prover_input, FetchProverInputRequest}; +pub use rpc::{JerigonRpcClient, NativeRpcClient, RpcClient}; diff --git a/rpc/src/main.rs b/rpc/src/main.rs index 00bfc4c4..b41c099e 100644 --- a/rpc/src/main.rs +++ b/rpc/src/main.rs @@ -3,7 +3,7 @@ use std::io::Write; use anyhow::Result; use clap::Parser; use cli::Commands; -use rpc::{fetch_prover_input, FetchProverInputRequest}; +use rpc::{JerigonRpcClient, NativeRpcClient, RpcClient}; mod cli; mod init; @@ -17,15 +17,26 @@ async fn main() -> Result<()> { match args.command { Commands::Fetch { rpc_url, + rpc_type, block_number, checkpoint_block_number, } => { - let prover_input = fetch_prover_input(FetchProverInputRequest { - rpc_url: &rpc_url, - block_number, - checkpoint_block_number, - }) - .await?; + let prover_input = match rpc_type.as_str() { + "jerigon" => { + let client = JerigonRpcClient::new(rpc_url); + client + .fetch_prover_input(block_number, checkpoint_block_number) + .await? + } + "native" => { + let client = NativeRpcClient::new(rpc_url) + .expect("should be able to create native rpc client"); + client + .fetch_prover_input(block_number, checkpoint_block_number) + .await? + } + _ => panic!("Invalid RPC type"), + }; std::io::stdout().write_all(&serde_json::to_vec(&prover_input)?)?; } } diff --git a/rpc/src/rpc/.DS_Store b/rpc/src/rpc/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8de44222493aebfc5b742bb442256fad2f447b12 GIT binary patch literal 6148 zcmeHKOKQU~5S>X)F?8c)mbyZ3AWV9KTp)pl5-1LYCTp*9t{$y#J{#BVF4>qjFnZEx zo`l}Q;}H?L%G>7H`_O#*(xIngyW2>9Io5*@Oc_OX4!uSjQcEu?Bz?2 zzxcLCqXJZb3Qz$mKn3orK-Smx<-W)AG%7#^7NCHA9}3*CCXRvr>A>JE0I)&W4Rh}$ zfW-p9nm7g`0@I)ZgR0qLXwVTanO76Xz@Up}^PzdOW{0AFJI*hjE?NUQQUNM3Rp2R> zoz?$0_&@#sl*APkpaP3hK%32W)8k25TW626T3g^dxaEAq%`kTg1~11zFUMF|IbM5G bPDkA7K>iGvE;K6eXa#-%iLVu@ literal 0 HcmV?d00001 diff --git a/rpc/src/rpc.rs b/rpc/src/rpc/jerigon.rs similarity index 70% rename from rpc/src/rpc.rs rename to rpc/src/rpc/jerigon.rs index 2abc255e..d89b10c9 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc/jerigon.rs @@ -1,8 +1,9 @@ use anyhow::{Context, Result}; +use async_trait::async_trait; use ethereum_types::{Address, Bloom, H256, U256}; use evm_arithmetization::proof::{BlockHashes, BlockMetadata}; use futures::{stream::FuturesOrdered, TryStreamExt}; -use prover::ProverInput; +use reqwest::Client; use reqwest::IntoUrl; use serde::Deserialize; use thiserror::Error; @@ -13,22 +14,66 @@ use trace_decoder::{ }; use tracing::{debug, info}; +use super::{ProverInput, RpcClient}; + +pub struct JerigonRpcClient { + client: Client, + rpc_url: String, +} + +impl JerigonRpcClient { + pub fn new(rpc_url: String) -> Self { + Self { + client: Client::new(), + rpc_url, + } + } +} + +#[async_trait] +impl RpcClient for JerigonRpcClient { + async fn fetch_prover_input( + &self, + block_number: u64, + checkpoint_block_number: u64, + ) -> Result { + let (trace_result, rpc_block_metadata) = try_join!( + JerigonTraceResponse::fetch(&self.client, &self.rpc_url, block_number), + RpcBlockMetadata::fetch( + &self.client, + &self.rpc_url, + block_number, + checkpoint_block_number + ), + )?; + + debug!("Got block result: {:?}", rpc_block_metadata.block_by_number); + debug!("Got trace result: {:?}", trace_result); + debug!("Got chain_id: {:?}", rpc_block_metadata.chain_id); + + Ok(ProverInput { + block_trace: trace_result.try_into()?, + other_data: rpc_block_metadata.into(), + }) + } +} + #[derive(Deserialize, Debug)] #[serde(rename_all = "snake_case")] #[allow(clippy::large_enum_variant)] -enum JerigonResultItem { +pub(crate) enum JerigonResultItem { Result(TxnInfo), BlockWitness(BlockTraceTriePreImages), } /// The response from the `debug_traceBlockByNumber` RPC method. #[derive(Deserialize, Debug)] -struct JerigonTraceResponse { - result: Vec, +pub(crate) struct JerigonTraceResponse { + pub(crate) result: Vec, } #[derive(Error, Debug)] -enum JerigonTraceError { +pub(crate) enum JerigonTraceError { #[error("expected BlockTraceTriePreImages in block_witness key")] BlockTraceTriePreImagesNotFound, } @@ -63,8 +108,11 @@ impl TryFrom for BlockTrace { impl JerigonTraceResponse { /// Fetches the block trace for the given block number. - async fn fetch(rpc_url: U, block_number: u64) -> Result { - let client = reqwest::Client::new(); + pub(crate) async fn fetch( + client: &reqwest::Client, + rpc_url: U, + block_number: u64, + ) -> Result { let block_number_hex = format!("0x{:x}", block_number); info!("Fetching block trace for block {}", block_number_hex); @@ -91,27 +139,27 @@ impl JerigonTraceResponse { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] -struct EthGetBlockByNumberResult { - base_fee_per_gas: U256, - difficulty: U256, - gas_limit: U256, - gas_used: U256, - hash: H256, - logs_bloom: Bloom, - miner: Address, - mix_hash: H256, - number: U256, - parent_hash: H256, - state_root: H256, - timestamp: U256, - withdrawals: Vec, +pub(crate) struct EthGetBlockByNumberResult { + pub(crate) base_fee_per_gas: U256, + pub(crate) difficulty: U256, + pub(crate) gas_limit: U256, + pub(crate) gas_used: U256, + pub(crate) hash: H256, + pub(crate) logs_bloom: Bloom, + pub(crate) miner: Address, + pub(crate) mix_hash: H256, + pub(crate) number: U256, + pub(crate) parent_hash: H256, + pub(crate) state_root: H256, + pub(crate) timestamp: U256, + pub(crate) withdrawals: Vec, } #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] -struct Withdrawal { - address: Address, - amount: U256, +pub(crate) struct Withdrawal { + pub(crate) address: Address, + pub(crate) amount: U256, } impl From for (Address, U256) { @@ -122,14 +170,17 @@ impl From for (Address, U256) { /// The response from the `eth_getBlockByNumber` RPC method. #[derive(Deserialize, Debug)] -struct EthGetBlockByNumberResponse { - result: EthGetBlockByNumberResult, +pub(crate) struct EthGetBlockByNumberResponse { + pub(crate) result: EthGetBlockByNumberResult, } impl EthGetBlockByNumberResponse { /// Fetches the block metadata for the given block number. - async fn fetch(rpc_url: U, block_number: u64) -> Result { - let client = reqwest::Client::new(); + pub(crate) async fn fetch( + client: &Client, + rpc_url: U, + block_number: u64, + ) -> Result { let block_number_hex = format!("0x{:x}", block_number); info!("Fetching block metadata for block {}", block_number_hex); @@ -153,7 +204,8 @@ impl EthGetBlockByNumberResponse { Ok(parsed) } - async fn fetch_previous_block_hashes( + pub(crate) async fn fetch_previous_block_hashes( + client: &Client, rpc_url: U, block_number: u64, ) -> Result> { @@ -176,7 +228,7 @@ impl EthGetBlockByNumberResponse { let start = block_number.saturating_sub(256); let mut futs: FuturesOrdered<_> = (start..=block_number) .step_by(2) - .map(|block_number| Self::fetch(rpc_url, block_number)) + .map(|block_number| Self::fetch(client, rpc_url, block_number)) .collect(); while let Some(response) = futs.try_next().await? { @@ -197,25 +249,25 @@ impl EthGetBlockByNumberResponse { Ok(hashes) } - async fn fetch_checkpoint_state_trie_root( + pub(crate) async fn fetch_checkpoint_state_trie_root( + client: &Client, rpc_url: U, block_number: u64, ) -> Result { - let res = Self::fetch(rpc_url, block_number).await?; + let res = Self::fetch(client, rpc_url, block_number).await?; Ok(res.result.state_root) } } /// The response from the `eth_chainId` RPC method. #[derive(Deserialize, Debug)] -struct EthChainIdResponse { - result: U256, +pub(crate) struct EthChainIdResponse { + pub(crate) result: U256, } impl EthChainIdResponse { /// Fetches the chain id. - async fn fetch(rpc_url: U) -> Result { - let client = reqwest::Client::new(); + pub(crate) async fn fetch(client: &Client, rpc_url: U) -> Result { info!("Fetching chain id"); let response = client @@ -241,20 +293,26 @@ impl EthChainIdResponse { /// Product of the `eth_getBlockByNumber` and `eth_chainId` RPC methods. /// /// Contains the necessary data to construct the `OtherBlockData` struct. -struct RpcBlockMetadata { - block_by_number: EthGetBlockByNumberResponse, - chain_id: EthChainIdResponse, - prev_hashes: Vec, - checkpoint_state_trie_root: H256, +pub(crate) struct RpcBlockMetadata { + pub(crate) block_by_number: EthGetBlockByNumberResponse, + pub(crate) chain_id: EthChainIdResponse, + pub(crate) prev_hashes: Vec, + pub(crate) checkpoint_state_trie_root: H256, } impl RpcBlockMetadata { - async fn fetch(rpc_url: &str, block_number: u64, checkpoint_block_number: u64) -> Result { + pub(crate) async fn fetch( + client: &Client, + rpc_url: &str, + block_number: u64, + checkpoint_block_number: u64, + ) -> Result { let (block_result, chain_id_result, prev_hashes, checkpoint_state_trie_root) = try_join!( - EthGetBlockByNumberResponse::fetch(rpc_url, block_number), - EthChainIdResponse::fetch(rpc_url), - EthGetBlockByNumberResponse::fetch_previous_block_hashes(rpc_url, block_number), + EthGetBlockByNumberResponse::fetch(client, rpc_url, block_number), + EthChainIdResponse::fetch(client, rpc_url), + EthGetBlockByNumberResponse::fetch_previous_block_hashes(client, rpc_url, block_number), EthGetBlockByNumberResponse::fetch_checkpoint_state_trie_root( + client, rpc_url, checkpoint_block_number ) @@ -322,31 +380,3 @@ impl From for OtherBlockData { } } } - -pub struct FetchProverInputRequest<'a> { - pub rpc_url: &'a str, - pub block_number: u64, - pub checkpoint_block_number: u64, -} - -pub async fn fetch_prover_input( - FetchProverInputRequest { - rpc_url, - block_number, - checkpoint_block_number, - }: FetchProverInputRequest<'_>, -) -> Result { - let (trace_result, rpc_block_metadata) = try_join!( - JerigonTraceResponse::fetch(rpc_url, block_number), - RpcBlockMetadata::fetch(rpc_url, block_number, checkpoint_block_number), - )?; - - debug!("Got block result: {:?}", rpc_block_metadata.block_by_number); - debug!("Got trace result: {:?}", trace_result); - debug!("Got chain_id: {:?}", rpc_block_metadata.chain_id); - - Ok(ProverInput { - block_trace: trace_result.try_into()?, - other_data: rpc_block_metadata.into(), - }) -} diff --git a/rpc/src/rpc/mod.rs b/rpc/src/rpc/mod.rs new file mode 100644 index 00000000..05aa751f --- /dev/null +++ b/rpc/src/rpc/mod.rs @@ -0,0 +1,25 @@ +use anyhow::Result; +use async_trait::async_trait; +use prover::ProverInput; + +mod jerigon; +pub use jerigon::JerigonRpcClient; + +mod native; +pub use native::NativeRpcClient; + +/// RPC CLIENT TRAIT +/// =============================================================================================== + +/// The RPC client trait. +/// +/// This trait defines the interface for fetching prover input from the RPC. +#[async_trait] +pub trait RpcClient { + /// Fetches the prover input from the RPC. + async fn fetch_prover_input( + &self, + block_number: u64, + checkpoint_block_number: u64, + ) -> Result; +} diff --git a/rpc/src/rpc/native/mod.rs b/rpc/src/rpc/native/mod.rs new file mode 100644 index 00000000..1e2adbb7 --- /dev/null +++ b/rpc/src/rpc/native/mod.rs @@ -0,0 +1,303 @@ +#![allow(clippy::needless_range_loop)] +use std::collections::{BTreeMap, HashMap}; +use std::str::FromStr; +use std::sync::{Arc, Mutex}; + +use anyhow::{anyhow, Result}; +use ethers::prelude::*; +use ethers::types::{GethDebugTracerType, H256, U256}; +use ethers::utils::keccak256; +use ethers::utils::rlp; +use futures::stream::{self, TryStreamExt}; +use reqwest::Client; +use trace_decoder::trace_protocol::TrieDirect; +use trace_decoder::trace_protocol::{ + BlockTrace, BlockTraceTriePreImages, ContractCodeUsage, SeparateStorageTriesPreImage, + SeparateTriePreImage, SeparateTriePreImages, TxnInfo, TxnMeta, TxnTrace, +}; +use trace_decoder::types::HashedStorageAddr; + +use super::{async_trait, jerigon::RpcBlockMetadata, ProverInput, RpcClient}; + +mod trie; +use trie::HashedPartialTrieBuilder; + +/// The native RPC client. +pub struct NativeRpcClient { + provider: Provider, + rpc_url: String, +} + +impl NativeRpcClient { + /// Creates a new `NativeRpcClient` with the given RPC URL. + pub fn new(rpc_url: String) -> Result { + let provider = Provider::::try_from(rpc_url.clone())?; + Ok(Self { provider, rpc_url }) + } +} + +#[async_trait] +impl RpcClient for NativeRpcClient { + async fn fetch_prover_input( + &self, + block_number: u64, + checkpoint_block_number: u64, + ) -> Result { + let accounts_state = Arc::new(Mutex::new(BTreeMap::::new())); + let block = self + .provider + .get_block(block_number) + .await? + .ok_or_else(|| anyhow!("Block not found. Block number: {}", block_number))?; + + let tx_infos = stream::iter(&block.transactions) + .then(|tx_hash| { + let arc = accounts_state.clone(); + async move { process_transaction(&self.provider, tx_hash, arc).await } + }) + .try_collect::>() + .await?; + + let block_trace = BlockTrace { + txn_info: tx_infos, + trie_pre_images: process_block_trace_witness(&self.provider, block, accounts_state) + .await?, + }; + + let client = Client::new(); + Ok(ProverInput { + block_trace, + other_data: RpcBlockMetadata::fetch( + &client, + &self.rpc_url, + block_number, + checkpoint_block_number, + ) + .await? + .into(), + }) + } +} + +async fn process_block_trace_witness( + provider: &Provider, + block: Block, + accounts_state: Arc>>, +) -> Result { + let accounts_state = Arc::try_unwrap(accounts_state) + .unwrap() + .into_inner() + .unwrap(); + + let block_number = block.number.unwrap(); + let prev_block = provider + .get_block(block_number - 1) + .await? + .ok_or_else(|| anyhow!("Block not found. Block number: {}", block_number - 1))?; + + let mut state = HashedPartialTrieBuilder::new(prev_block.state_root, Default::default()); + let mut storage_proofs = HashMap::::new(); + for (address, account) in accounts_state.iter() { + let proof = provider + .get_proof( + *address, + account + .storage + .as_ref() + .map_or(vec![], |x| x.keys().copied().collect()), + Some((block_number - 1).into()), + ) + .await?; + state.insert_proof(proof.account_proof); + + if account.storage.is_some() { + let mut storage_mpt = + HashedPartialTrieBuilder::new(proof.storage_hash, Default::default()); + for proof in proof.storage_proof { + storage_mpt.insert_proof(proof.proof); + } + + storage_proofs.insert(keccak256(address).into(), storage_mpt); + } + } + + let proof = provider + .get_proof( + block.author.expect("block must have author"), + vec![], + block.number.map(Into::into), + ) + .await?; + state.insert_proof(proof.account_proof); + + if let Some(withdrawals) = block.withdrawals.as_ref() { + for withdrawal in withdrawals { + let proof = provider + .get_proof(withdrawal.address, vec![], Some((block_number - 1).into())) + .await?; + state.insert_proof(proof.account_proof); + } + } + + Ok(BlockTraceTriePreImages::Separate(SeparateTriePreImages { + state: SeparateTriePreImage::Direct(TrieDirect(state.build())), + storage: SeparateStorageTriesPreImage::MultipleTries( + storage_proofs + .into_iter() + .map(|(a, m)| (a, SeparateTriePreImage::Direct(TrieDirect(m.build())))) + .collect(), + ), + })) +} + +async fn process_transaction( + provider: &Provider, + tx_hash: &H256, + accounts_state: Arc>>, +) -> Result { + let tx = provider + .get_transaction(*tx_hash) + .await? + .ok_or_else(|| anyhow!("Transaction not found."))?; + let tx_receipt = provider + .get_transaction_receipt(*tx_hash) + .await? + .ok_or_else(|| anyhow!("Transaction receipt not found."))?; + let pre_trace = provider + .debug_trace_transaction(*tx_hash, tracing_options()) + .await?; + let diff_trace = provider + .debug_trace_transaction(*tx_hash, tracing_options_diff()) + .await?; + let tx_meta = TxnMeta { + byte_code: tx.rlp().to_vec(), + new_txn_trie_node_byte: tx.rlp().to_vec(), + new_receipt_trie_node_byte: compute_receipt_bytes(&tx_receipt), + gas_used: tx.gas.try_into().expect("gas used must be valid u64"), + }; + + let tx_traces = match (pre_trace, diff_trace) { + ( + GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Default(read))), + GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Diff(diff))), + ) => process_tx_traces(accounts_state, read, diff).await?, + _ => unreachable!(), + }; + + Ok(TxnInfo { + meta: tx_meta, + traces: tx_traces, + }) +} + +fn compute_receipt_bytes(tx_receipt: &TransactionReceipt) -> Vec { + let mut bytes = rlp::encode(tx_receipt).to_vec(); + match tx_receipt.transaction_type { + Some(tx_type) if !tx_type.is_zero() => { + bytes.insert(0, tx_type.0[0] as u8); + } + _ => return bytes, + } + + rlp::encode(&bytes).to_vec() +} + +async fn process_tx_traces( + accounts_state: Arc>>, + read_trace: PreStateMode, + diff_trace: DiffMode, +) -> Result> { + let mut accounts_state = accounts_state.lock().unwrap(); + for (address, acct_state) in read_trace.0.iter() { + accounts_state + .entry(*address) + .and_modify(|acct| { + merge_account_storage(&mut acct.storage, acct_state.storage.as_ref()) + }) + .or_insert(acct_state.clone()); + } + + let DiffMode { + pre: pre_trace, + post: post_trace, + } = diff_trace; + + Ok(read_trace + .0 + .into_iter() + .map(|(address, acct_state)| { + ( + address, + TxnTrace { + balance: post_trace.get(&address).and_then(|x| x.balance), + nonce: post_trace.get(&address).and_then(|x| x.nonce), + storage_read: acct_state.storage.map(|x| x.keys().copied().collect()), + //TODO: check if endianess is correct + storage_written: post_trace.get(&address).and_then(|x| { + x.storage.as_ref().map(|s| { + s.into_iter() + .map(|(k, v)| (*k, U256::from_big_endian(v.as_bytes()))) + .collect() + }) + }), + code_usage: post_trace.get(&address).map_or( + acct_state.code.map(|x| { + ContractCodeUsage::Read(H256::from_str(&x).expect("must be valid")) + }), + |x| { + x.code + .as_ref() + .map(|x| ContractCodeUsage::Write(x.as_bytes().to_vec().into())) + }, + ), + self_destructed: if post_trace.get(&address).is_none() + && pre_trace.contains_key(&address) + { + Some(true) + } else { + None + }, + }, + ) + }) + .collect::>()) +} + +fn merge_account_storage( + storage: &mut Option>, + new_storage: Option<&BTreeMap>, +) { + match (storage, new_storage) { + (Some(storage), Some(new_storage)) => storage.extend(new_storage), + (storage, Some(new_storage)) => { + *storage = Some(new_storage.clone()); + } + _ => (), + } +} + +/// Tracing options for the debug_traceTransaction call. +fn tracing_options() -> GethDebugTracingOptions { + GethDebugTracingOptions { + tracer: Some(GethDebugTracerType::BuiltInTracer( + GethDebugBuiltInTracerType::PreStateTracer, + )), + + ..GethDebugTracingOptions::default() + } +} + +fn tracing_options_diff() -> GethDebugTracingOptions { + GethDebugTracingOptions { + tracer: Some(GethDebugTracerType::BuiltInTracer( + GethDebugBuiltInTracerType::PreStateTracer, + )), + + tracer_config: Some(GethDebugTracerConfig::BuiltInTracer( + GethDebugBuiltInTracerConfig::PreStateTracer(PreStateConfig { + diff_mode: Some(true), + }), + )), + ..GethDebugTracingOptions::default() + } +} diff --git a/rpc/src/rpc/native/trie.rs b/rpc/src/rpc/native/trie.rs new file mode 100644 index 00000000..3d5edce9 --- /dev/null +++ b/rpc/src/rpc/native/trie.rs @@ -0,0 +1,122 @@ +use std::collections::HashMap; +use std::sync::Arc; + +use ethereum_types::H256; +use ethers::{ + types::Bytes, + utils::{keccak256, rlp}, +}; +use mpt_trie::{ + nibbles::Nibbles, + partial_trie::{HashedPartialTrie, Node, PartialTrie, WrappedNode}, +}; + +/// A builder for constructing a partial trie from a collection of nodes. +pub struct HashedPartialTrieBuilder { + root: H256, + nodes: HashMap>, +} + +impl HashedPartialTrieBuilder { + /// Creates a new `HashedPartialTrieBuilder` with the given root and nodes. + pub fn new(root: H256, nodes: HashMap>) -> Self { + HashedPartialTrieBuilder { root, nodes } + } + + /// Inserts a proof into the builder. + /// + /// The proof is a collection of nodes that are used to construct the + /// partial trie. + pub fn insert_proof(&mut self, proof: Vec) { + for node in proof { + self.nodes.insert(keccak256(&node).into(), node.to_vec()); + } + } + + /// Builds the partial trie from the nodes and root. + pub fn build(self) -> HashedPartialTrie { + construct_partial_trie(self.root, &self.nodes) + } +} + +/// Constructs a partial trie from a root hash and a collection of nodes. +fn construct_partial_trie(hash: H256, nodes: &HashMap>) -> T { + let bytes = match nodes.get(&hash) { + Some(value) => rlp::decode_list::>(value), + None => return T::new(Node::Hash(hash)), + }; + + let node = match bytes.len() { + 17 => parse_branch_node(bytes, nodes), + 2 if is_extension_node(&bytes) => parse_extension_node(bytes, nodes), + 2 if is_leaf_node(&bytes) => parse_leaf_node(bytes), + _ => unreachable!(), + }; + + T::new(node) +} + +/// Returns true if the node is an extension node. +fn is_extension_node(bytes: &[Vec]) -> bool { + (bytes[0][0] >> 4 == 0) | (bytes[0][0] >> 4 == 1) +} + +/// Returns true if the node is a leaf node. +fn is_leaf_node(bytes: &[Vec]) -> bool { + (bytes[0][0] >> 4 == 2) | (bytes[0][0] >> 4 == 3) +} + +/// Parses a branch node from the given bytes. +fn parse_branch_node( + bytes: Vec>, + nodes: &HashMap>, +) -> Node { + let children = (0..16) + .map(|i| { + let child = match bytes[i].is_empty() { + true => T::default(), + false => construct_partial_trie(H256::from_slice(&bytes[i]), nodes), + }; + Arc::new(Box::new(child)) + }) + .collect::>>(); + + Node::::Branch { + children: children.try_into().unwrap(), + value: bytes[16].clone(), + } +} + +/// Parses an extension node from the given bytes. +fn parse_extension_node( + bytes: Vec>, + nodes: &HashMap>, +) -> Node { + let mut encoded_path = Nibbles::from_bytes_be(&bytes[0][..]).unwrap(); + + if encoded_path.pop_nibbles_front(1).get_nibble(0) == 0 { + encoded_path.pop_nibbles_front(1); + } + + Node::Extension { + nibbles: encoded_path, + child: Arc::new(Box::new(construct_partial_trie( + H256::from_slice(&bytes[1]), + nodes, + ))), + } +} + +/// Parses a leaf node from the given bytes. +fn parse_leaf_node(bytes: Vec>) -> Node { + let mut encoded_path = Nibbles::from_bytes_be(&bytes[0][..]).unwrap(); + + if encoded_path.pop_nibbles_front(1).get_nibble(0) == 2 { + encoded_path.pop_nibbles_front(1); + } + + Node::Leaf { + nibbles: encoded_path, + value: bytes[1].clone(), + } +} From 2d071e40253254f692fe9b2baf68d694cd902c50 Mon Sep 17 00:00:00 2001 From: frisitano Date: Wed, 10 Apr 2024 16:19:20 +0100 Subject: [PATCH 02/13] modularity and hygiene refactor --- rpc/src/rpc/jerigon.rs | 72 ++++++------ rpc/src/rpc/native/mod.rs | 225 +++--------------------------------- rpc/src/rpc/native/state.rs | 125 ++++++++++++++++++++ rpc/src/rpc/native/trie.rs | 17 ++- rpc/src/rpc/native/txn.rs | 184 +++++++++++++++++++++++++++++ 5 files changed, 367 insertions(+), 256 deletions(-) create mode 100644 rpc/src/rpc/native/state.rs create mode 100644 rpc/src/rpc/native/txn.rs diff --git a/rpc/src/rpc/jerigon.rs b/rpc/src/rpc/jerigon.rs index d89b10c9..2c232d12 100644 --- a/rpc/src/rpc/jerigon.rs +++ b/rpc/src/rpc/jerigon.rs @@ -68,12 +68,12 @@ pub(crate) enum JerigonResultItem { /// The response from the `debug_traceBlockByNumber` RPC method. #[derive(Deserialize, Debug)] -pub(crate) struct JerigonTraceResponse { - pub(crate) result: Vec, +struct JerigonTraceResponse { + result: Vec, } #[derive(Error, Debug)] -pub(crate) enum JerigonTraceError { +enum JerigonTraceError { #[error("expected BlockTraceTriePreImages in block_witness key")] BlockTraceTriePreImagesNotFound, } @@ -108,7 +108,7 @@ impl TryFrom for BlockTrace { impl JerigonTraceResponse { /// Fetches the block trace for the given block number. - pub(crate) async fn fetch( + async fn fetch( client: &reqwest::Client, rpc_url: U, block_number: u64, @@ -139,27 +139,27 @@ impl JerigonTraceResponse { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] -pub(crate) struct EthGetBlockByNumberResult { - pub(crate) base_fee_per_gas: U256, - pub(crate) difficulty: U256, - pub(crate) gas_limit: U256, - pub(crate) gas_used: U256, - pub(crate) hash: H256, - pub(crate) logs_bloom: Bloom, - pub(crate) miner: Address, - pub(crate) mix_hash: H256, - pub(crate) number: U256, - pub(crate) parent_hash: H256, - pub(crate) state_root: H256, - pub(crate) timestamp: U256, - pub(crate) withdrawals: Vec, +struct EthGetBlockByNumberResult { + base_fee_per_gas: U256, + difficulty: U256, + gas_limit: U256, + gas_used: U256, + hash: H256, + logs_bloom: Bloom, + miner: Address, + mix_hash: H256, + number: U256, + parent_hash: H256, + state_root: H256, + timestamp: U256, + withdrawals: Vec, } #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] -pub(crate) struct Withdrawal { - pub(crate) address: Address, - pub(crate) amount: U256, +struct Withdrawal { + address: Address, + amount: U256, } impl From for (Address, U256) { @@ -170,17 +170,13 @@ impl From for (Address, U256) { /// The response from the `eth_getBlockByNumber` RPC method. #[derive(Deserialize, Debug)] -pub(crate) struct EthGetBlockByNumberResponse { - pub(crate) result: EthGetBlockByNumberResult, +struct EthGetBlockByNumberResponse { + result: EthGetBlockByNumberResult, } impl EthGetBlockByNumberResponse { /// Fetches the block metadata for the given block number. - pub(crate) async fn fetch( - client: &Client, - rpc_url: U, - block_number: u64, - ) -> Result { + async fn fetch(client: &Client, rpc_url: U, block_number: u64) -> Result { let block_number_hex = format!("0x{:x}", block_number); info!("Fetching block metadata for block {}", block_number_hex); @@ -204,7 +200,7 @@ impl EthGetBlockByNumberResponse { Ok(parsed) } - pub(crate) async fn fetch_previous_block_hashes( + async fn fetch_previous_block_hashes( client: &Client, rpc_url: U, block_number: u64, @@ -249,7 +245,7 @@ impl EthGetBlockByNumberResponse { Ok(hashes) } - pub(crate) async fn fetch_checkpoint_state_trie_root( + async fn fetch_checkpoint_state_trie_root( client: &Client, rpc_url: U, block_number: u64, @@ -261,13 +257,13 @@ impl EthGetBlockByNumberResponse { /// The response from the `eth_chainId` RPC method. #[derive(Deserialize, Debug)] -pub(crate) struct EthChainIdResponse { - pub(crate) result: U256, +struct EthChainIdResponse { + result: U256, } impl EthChainIdResponse { /// Fetches the chain id. - pub(crate) async fn fetch(client: &Client, rpc_url: U) -> Result { + async fn fetch(client: &Client, rpc_url: U) -> Result { info!("Fetching chain id"); let response = client @@ -294,14 +290,14 @@ impl EthChainIdResponse { /// /// Contains the necessary data to construct the `OtherBlockData` struct. pub(crate) struct RpcBlockMetadata { - pub(crate) block_by_number: EthGetBlockByNumberResponse, - pub(crate) chain_id: EthChainIdResponse, - pub(crate) prev_hashes: Vec, - pub(crate) checkpoint_state_trie_root: H256, + block_by_number: EthGetBlockByNumberResponse, + chain_id: EthChainIdResponse, + prev_hashes: Vec, + checkpoint_state_trie_root: H256, } impl RpcBlockMetadata { - pub(crate) async fn fetch( + pub async fn fetch( client: &Client, rpc_url: &str, block_number: u64, diff --git a/rpc/src/rpc/native/mod.rs b/rpc/src/rpc/native/mod.rs index 1e2adbb7..b475322e 100644 --- a/rpc/src/rpc/native/mod.rs +++ b/rpc/src/rpc/native/mod.rs @@ -1,26 +1,22 @@ #![allow(clippy::needless_range_loop)] -use std::collections::{BTreeMap, HashMap}; -use std::str::FromStr; +use std::collections::BTreeMap; use std::sync::{Arc, Mutex}; use anyhow::{anyhow, Result}; use ethers::prelude::*; -use ethers::types::{GethDebugTracerType, H256, U256}; -use ethers::utils::keccak256; -use ethers::utils::rlp; +use ethers::types::GethDebugTracerType; use futures::stream::{self, TryStreamExt}; use reqwest::Client; -use trace_decoder::trace_protocol::TrieDirect; -use trace_decoder::trace_protocol::{ - BlockTrace, BlockTraceTriePreImages, ContractCodeUsage, SeparateStorageTriesPreImage, - SeparateTriePreImage, SeparateTriePreImages, TxnInfo, TxnMeta, TxnTrace, -}; -use trace_decoder::types::HashedStorageAddr; +use trace_decoder::trace_protocol::{BlockTrace, TxnInfo}; use super::{async_trait, jerigon::RpcBlockMetadata, ProverInput, RpcClient}; +mod state; mod trie; -use trie::HashedPartialTrieBuilder; +mod txn; + +/// NATIVE RPC CLIENT +/// =============================================================================================== /// The native RPC client. pub struct NativeRpcClient { @@ -53,22 +49,21 @@ impl RpcClient for NativeRpcClient { let tx_infos = stream::iter(&block.transactions) .then(|tx_hash| { let arc = accounts_state.clone(); - async move { process_transaction(&self.provider, tx_hash, arc).await } + async move { txn::process_transaction(&self.provider, tx_hash, arc).await } }) .try_collect::>() .await?; let block_trace = BlockTrace { txn_info: tx_infos, - trie_pre_images: process_block_trace_witness(&self.provider, block, accounts_state) + trie_pre_images: state::process_state_witness(&self.provider, block, accounts_state) .await?, }; - let client = Client::new(); Ok(ProverInput { block_trace, other_data: RpcBlockMetadata::fetch( - &client, + &Client::new(), &self.rpc_url, block_number, checkpoint_block_number, @@ -79,202 +74,8 @@ impl RpcClient for NativeRpcClient { } } -async fn process_block_trace_witness( - provider: &Provider, - block: Block, - accounts_state: Arc>>, -) -> Result { - let accounts_state = Arc::try_unwrap(accounts_state) - .unwrap() - .into_inner() - .unwrap(); - - let block_number = block.number.unwrap(); - let prev_block = provider - .get_block(block_number - 1) - .await? - .ok_or_else(|| anyhow!("Block not found. Block number: {}", block_number - 1))?; - - let mut state = HashedPartialTrieBuilder::new(prev_block.state_root, Default::default()); - let mut storage_proofs = HashMap::::new(); - for (address, account) in accounts_state.iter() { - let proof = provider - .get_proof( - *address, - account - .storage - .as_ref() - .map_or(vec![], |x| x.keys().copied().collect()), - Some((block_number - 1).into()), - ) - .await?; - state.insert_proof(proof.account_proof); - - if account.storage.is_some() { - let mut storage_mpt = - HashedPartialTrieBuilder::new(proof.storage_hash, Default::default()); - for proof in proof.storage_proof { - storage_mpt.insert_proof(proof.proof); - } - - storage_proofs.insert(keccak256(address).into(), storage_mpt); - } - } - - let proof = provider - .get_proof( - block.author.expect("block must have author"), - vec![], - block.number.map(Into::into), - ) - .await?; - state.insert_proof(proof.account_proof); - - if let Some(withdrawals) = block.withdrawals.as_ref() { - for withdrawal in withdrawals { - let proof = provider - .get_proof(withdrawal.address, vec![], Some((block_number - 1).into())) - .await?; - state.insert_proof(proof.account_proof); - } - } - - Ok(BlockTraceTriePreImages::Separate(SeparateTriePreImages { - state: SeparateTriePreImage::Direct(TrieDirect(state.build())), - storage: SeparateStorageTriesPreImage::MultipleTries( - storage_proofs - .into_iter() - .map(|(a, m)| (a, SeparateTriePreImage::Direct(TrieDirect(m.build())))) - .collect(), - ), - })) -} - -async fn process_transaction( - provider: &Provider, - tx_hash: &H256, - accounts_state: Arc>>, -) -> Result { - let tx = provider - .get_transaction(*tx_hash) - .await? - .ok_or_else(|| anyhow!("Transaction not found."))?; - let tx_receipt = provider - .get_transaction_receipt(*tx_hash) - .await? - .ok_or_else(|| anyhow!("Transaction receipt not found."))?; - let pre_trace = provider - .debug_trace_transaction(*tx_hash, tracing_options()) - .await?; - let diff_trace = provider - .debug_trace_transaction(*tx_hash, tracing_options_diff()) - .await?; - let tx_meta = TxnMeta { - byte_code: tx.rlp().to_vec(), - new_txn_trie_node_byte: tx.rlp().to_vec(), - new_receipt_trie_node_byte: compute_receipt_bytes(&tx_receipt), - gas_used: tx.gas.try_into().expect("gas used must be valid u64"), - }; - - let tx_traces = match (pre_trace, diff_trace) { - ( - GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Default(read))), - GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Diff(diff))), - ) => process_tx_traces(accounts_state, read, diff).await?, - _ => unreachable!(), - }; - - Ok(TxnInfo { - meta: tx_meta, - traces: tx_traces, - }) -} - -fn compute_receipt_bytes(tx_receipt: &TransactionReceipt) -> Vec { - let mut bytes = rlp::encode(tx_receipt).to_vec(); - match tx_receipt.transaction_type { - Some(tx_type) if !tx_type.is_zero() => { - bytes.insert(0, tx_type.0[0] as u8); - } - _ => return bytes, - } - - rlp::encode(&bytes).to_vec() -} - -async fn process_tx_traces( - accounts_state: Arc>>, - read_trace: PreStateMode, - diff_trace: DiffMode, -) -> Result> { - let mut accounts_state = accounts_state.lock().unwrap(); - for (address, acct_state) in read_trace.0.iter() { - accounts_state - .entry(*address) - .and_modify(|acct| { - merge_account_storage(&mut acct.storage, acct_state.storage.as_ref()) - }) - .or_insert(acct_state.clone()); - } - - let DiffMode { - pre: pre_trace, - post: post_trace, - } = diff_trace; - - Ok(read_trace - .0 - .into_iter() - .map(|(address, acct_state)| { - ( - address, - TxnTrace { - balance: post_trace.get(&address).and_then(|x| x.balance), - nonce: post_trace.get(&address).and_then(|x| x.nonce), - storage_read: acct_state.storage.map(|x| x.keys().copied().collect()), - //TODO: check if endianess is correct - storage_written: post_trace.get(&address).and_then(|x| { - x.storage.as_ref().map(|s| { - s.into_iter() - .map(|(k, v)| (*k, U256::from_big_endian(v.as_bytes()))) - .collect() - }) - }), - code_usage: post_trace.get(&address).map_or( - acct_state.code.map(|x| { - ContractCodeUsage::Read(H256::from_str(&x).expect("must be valid")) - }), - |x| { - x.code - .as_ref() - .map(|x| ContractCodeUsage::Write(x.as_bytes().to_vec().into())) - }, - ), - self_destructed: if post_trace.get(&address).is_none() - && pre_trace.contains_key(&address) - { - Some(true) - } else { - None - }, - }, - ) - }) - .collect::>()) -} - -fn merge_account_storage( - storage: &mut Option>, - new_storage: Option<&BTreeMap>, -) { - match (storage, new_storage) { - (Some(storage), Some(new_storage)) => storage.extend(new_storage), - (storage, Some(new_storage)) => { - *storage = Some(new_storage.clone()); - } - _ => (), - } -} +/// TRACING OPTIONS +/// =============================================================================================== /// Tracing options for the debug_traceTransaction call. fn tracing_options() -> GethDebugTracingOptions { diff --git a/rpc/src/rpc/native/state.rs b/rpc/src/rpc/native/state.rs new file mode 100644 index 00000000..d3c263a5 --- /dev/null +++ b/rpc/src/rpc/native/state.rs @@ -0,0 +1,125 @@ +use std::collections::BTreeMap; +use std::collections::HashMap; +use std::sync::Arc; +use std::sync::Mutex; + +use anyhow::{anyhow, Result}; +use ethers::providers::{Http, Middleware, Provider}; +use ethers::types::{AccountState, Block, H160, H256}; +use ethers::utils::keccak256; +use mpt_trie::partial_trie::HashedPartialTrie; +use trace_decoder::trace_protocol::{ + BlockTraceTriePreImages, SeparateStorageTriesPreImage, SeparateTriePreImage, + SeparateTriePreImages, TrieDirect, +}; +use trace_decoder::types::HashedStorageAddr; + +use super::trie::PartialTrieBuilder; + +/// Processes the state witness for the given block. +pub(super) async fn process_state_witness( + provider: &Provider, + block: Block, + accounts_state: Arc>>, +) -> Result { + let accounts_state = Arc::try_unwrap(accounts_state) + .map_err(|e| anyhow!("Failed to unwrap accounts state from arc: {e:?}"))? + .into_inner() + .map_err(|e| anyhow!("Failed to unwrap accounts state from mutex: {e:?}"))?; + + let block_number = block + .number + .ok_or_else(|| anyhow!("Block number not returned with block"))?; + let prev_block = provider.get_block(block_number - 1).await?.ok_or_else(|| { + anyhow!( + "Previous block not found. Block number: {}", + block_number - 1 + ) + })?; + + let (state, storage_proofs) = generate_state_witness( + prev_block.state_root, + accounts_state, + provider, + block_number, + block, + ) + .await?; + + Ok(BlockTraceTriePreImages::Separate(SeparateTriePreImages { + state: SeparateTriePreImage::Direct(TrieDirect(state.build())), + storage: SeparateStorageTriesPreImage::MultipleTries( + storage_proofs + .into_iter() + .map(|(a, m)| (a, SeparateTriePreImage::Direct(TrieDirect(m.build())))) + .collect(), + ), + })) +} + +/// Generates the state witness for the given block. +async fn generate_state_witness( + prev_state_root: H256, + accounts_state: BTreeMap, + provider: &Provider, + block_number: ethereum_types::U64, + block: Block, +) -> Result< + ( + PartialTrieBuilder, + HashMap>, + ), + anyhow::Error, +> { + let mut state = PartialTrieBuilder::new(prev_state_root, Default::default()); + let mut storage_proofs = + HashMap::>::new(); + + // Process transaction state accesses + for (address, account) in accounts_state.iter() { + let proof = provider + .get_proof( + *address, + account + .storage + .as_ref() + .map_or(vec![], |x| x.keys().copied().collect()), + Some((block_number - 1).into()), + ) + .await?; + state.insert_proof(proof.account_proof); + + if account.storage.is_some() { + let mut storage_mpt = PartialTrieBuilder::new(proof.storage_hash, Default::default()); + for proof in proof.storage_proof { + storage_mpt.insert_proof(proof.proof); + } + + storage_proofs.insert(keccak256(address).into(), storage_mpt); + } + } + + // Process author account access + let proof = provider + .get_proof( + block + .author + .ok_or_else(|| anyhow!("Block author not found"))?, + vec![], + block.number.map(Into::into), + ) + .await?; + state.insert_proof(proof.account_proof); + + // Process withdrawals account access + if let Some(withdrawals) = block.withdrawals.as_ref() { + for withdrawal in withdrawals { + let proof = provider + .get_proof(withdrawal.address, vec![], Some((block_number - 1).into())) + .await?; + state.insert_proof(proof.account_proof); + } + } + + Ok((state, storage_proofs)) +} diff --git a/rpc/src/rpc/native/trie.rs b/rpc/src/rpc/native/trie.rs index 3d5edce9..556b0546 100644 --- a/rpc/src/rpc/native/trie.rs +++ b/rpc/src/rpc/native/trie.rs @@ -8,19 +8,24 @@ use ethers::{ }; use mpt_trie::{ nibbles::Nibbles, - partial_trie::{HashedPartialTrie, Node, PartialTrie, WrappedNode}, + partial_trie::{Node, PartialTrie, WrappedNode}, }; /// A builder for constructing a partial trie from a collection of nodes. -pub struct HashedPartialTrieBuilder { +pub struct PartialTrieBuilder { root: H256, nodes: HashMap>, + _marker: std::marker::PhantomData, } -impl HashedPartialTrieBuilder { - /// Creates a new `HashedPartialTrieBuilder` with the given root and nodes. +impl PartialTrieBuilder { + /// Creates a new `PartialTrieBuilder` with the given root and nodes. pub fn new(root: H256, nodes: HashMap>) -> Self { - HashedPartialTrieBuilder { root, nodes } + PartialTrieBuilder { + root, + nodes, + _marker: std::marker::PhantomData, + } } /// Inserts a proof into the builder. @@ -34,7 +39,7 @@ impl HashedPartialTrieBuilder { } /// Builds the partial trie from the nodes and root. - pub fn build(self) -> HashedPartialTrie { + pub fn build(self) -> T { construct_partial_trie(self.root, &self.nodes) } } diff --git a/rpc/src/rpc/native/txn.rs b/rpc/src/rpc/native/txn.rs new file mode 100644 index 00000000..133c25b3 --- /dev/null +++ b/rpc/src/rpc/native/txn.rs @@ -0,0 +1,184 @@ +use std::collections::BTreeMap; +use std::collections::HashMap; +use std::str::FromStr; +use std::sync::Arc; +use std::sync::Mutex; + +use anyhow::{anyhow, Result}; +use ethers::providers::Middleware; +use ethers::providers::{Http, Provider}; +use ethers::types::U256; +use ethers::types::{ + AccountState, Address, DiffMode, GethTrace, GethTraceFrame, PreStateFrame, PreStateMode, + TransactionReceipt, H160, H256, +}; +use ethers::utils::rlp; +use trace_decoder::trace_protocol::ContractCodeUsage; +use trace_decoder::trace_protocol::TxnTrace; +use trace_decoder::trace_protocol::{TxnInfo, TxnMeta}; + +use super::tracing_options; +use super::tracing_options_diff; + +/// Processes the transaction with the given transaction hash and updates the +/// accounts state. +pub(super) async fn process_transaction( + provider: &Provider, + tx_hash: &H256, + accounts_state: Arc>>, +) -> Result { + let (tx, tx_receipt, pre_trace, diff_trace) = fetch_tx_data(provider, tx_hash).await?; + let tx_meta = TxnMeta { + byte_code: tx.rlp().to_vec(), + new_txn_trie_node_byte: tx.rlp().to_vec(), + new_receipt_trie_node_byte: compute_receipt_bytes(&tx_receipt), + gas_used: tx + .gas + .try_into() + .map_err(|_| anyhow!("gas used must be valid u64"))?, + }; + + let tx_traces = match (pre_trace, diff_trace) { + ( + GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Default(read))), + GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Diff(diff))), + ) => process_tx_traces(accounts_state, read, diff).await?, + _ => unreachable!(), + }; + + Ok(TxnInfo { + meta: tx_meta, + traces: tx_traces, + }) +} + +/// Fetches the transaction data for the given transaction hash. +async fn fetch_tx_data( + provider: &Provider, + tx_hash: &H256, +) -> Result< + ( + ethers::types::Transaction, + TransactionReceipt, + GethTrace, + GethTrace, + ), + anyhow::Error, +> { + let tx_fut = provider.get_transaction(*tx_hash); + let tx_receipt_fut = provider.get_transaction_receipt(*tx_hash); + let pre_trace_fut = provider.debug_trace_transaction(*tx_hash, tracing_options()); + let diff_trace_fut = provider.debug_trace_transaction(*tx_hash, tracing_options_diff()); + + let (tx, tx_receipt, pre_trace, diff_trace) = + futures::try_join!(tx_fut, tx_receipt_fut, pre_trace_fut, diff_trace_fut,)?; + + Ok(( + tx.ok_or_else(|| anyhow!("Transaction not found."))?, + tx_receipt.ok_or_else(|| anyhow!("Transaction receipt not found."))?, + pre_trace, + diff_trace, + )) +} + +// TODO: upstream this to ethers +/// Computes the receipt bytes for the given transaction receipt. +/// +/// NOTE: The ethers-rs library does not encode the transaction type in the +/// transaction receipt hence we do it manually here. +fn compute_receipt_bytes(tx_receipt: &TransactionReceipt) -> Vec { + let mut bytes = rlp::encode(tx_receipt).to_vec(); + + match tx_receipt.transaction_type { + Some(tx_type) if !tx_type.is_zero() => { + bytes.insert(0, tx_type.0[0] as u8); + } + _ => return bytes, + } + + rlp::encode(&bytes).to_vec() +} + +/// Processes the transaction traces and updates the accounts state. +async fn process_tx_traces( + accounts_state: Arc>>, + read_trace: PreStateMode, + diff_trace: DiffMode, +) -> Result> { + let mut accounts_state = accounts_state.lock().unwrap(); + for (address, acct_state) in read_trace.0.iter() { + accounts_state + .entry(*address) + .and_modify(|acct| { + merge_account_storage(&mut acct.storage, acct_state.storage.as_ref()) + }) + .or_insert(acct_state.clone()); + } + + let DiffMode { + pre: pre_trace, + post: post_trace, + } = diff_trace; + + Ok(read_trace + .0 + .into_iter() + .map(|(address, acct_state)| { + let balance = post_trace.get(&address).and_then(|x| x.balance); + let nonce = post_trace.get(&address).and_then(|x| x.nonce); + let storage_read = acct_state.storage.map(|x| x.keys().copied().collect()); + + let storage_written = post_trace.get(&address).and_then(|x| { + x.storage.as_ref().map(|s| { + s.iter() + //TODO: check if endianess is correct + .map(|(k, v)| (*k, U256::from_big_endian(v.as_bytes()))) + .collect() + }) + }); + + let code_usage = post_trace.get(&address).map_or( + acct_state + .code + .map(|x| ContractCodeUsage::Read(H256::from_str(&x).expect("must be valid"))), + |x| { + x.code + .as_ref() + .map(|x| ContractCodeUsage::Write(x.as_bytes().to_vec().into())) + }, + ); + + let self_destructed = + if post_trace.get(&address).is_none() && pre_trace.contains_key(&address) { + Some(true) + } else { + None + }; + ( + address, + TxnTrace { + balance, + nonce, + storage_read, + storage_written, + code_usage, + self_destructed, + }, + ) + }) + .collect::>()) +} + +/// Merges the account storage. +fn merge_account_storage( + storage: &mut Option>, + new_storage: Option<&BTreeMap>, +) { + match (storage, new_storage) { + (Some(storage), Some(new_storage)) => storage.extend(new_storage), + (storage, Some(new_storage)) => { + *storage = Some(new_storage.clone()); + } + _ => (), + } +} From 815f189d45ed7124a7ffd06c1fd32076ff8859dd Mon Sep 17 00:00:00 2001 From: frisitano Date: Wed, 10 Apr 2024 16:29:52 +0100 Subject: [PATCH 03/13] cleanup .DS_Store and add to gitignore --- .gitignore | 3 +++ rpc/src/rpc/.DS_Store | Bin 6148 -> 0 bytes 2 files changed, 3 insertions(+) delete mode 100644 rpc/src/rpc/.DS_Store diff --git a/.gitignore b/.gitignore index 42acc248..907e7480 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ proofs/ # Serialized generated prover & verifier state used by plonky2 prover_state_* verifier_state_* + +# System files +.DS_Store \ No newline at end of file diff --git a/rpc/src/rpc/.DS_Store b/rpc/src/rpc/.DS_Store deleted file mode 100644 index 8de44222493aebfc5b742bb442256fad2f447b12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOKQU~5S>X)F?8c)mbyZ3AWV9KTp)pl5-1LYCTp*9t{$y#J{#BVF4>qjFnZEx zo`l}Q;}H?L%G>7H`_O#*(xIngyW2>9Io5*@Oc_OX4!uSjQcEu?Bz?2 zzxcLCqXJZb3Qz$mKn3orK-Smx<-W)AG%7#^7NCHA9}3*CCXRvr>A>JE0I)&W4Rh}$ zfW-p9nm7g`0@I)ZgR0qLXwVTanO76Xz@Up}^PzdOW{0AFJI*hjE?NUQQUNM3Rp2R> zoz?$0_&@#sl*APkpaP3hK%32W)8k25TW626T3g^dxaEAq%`kTg1~11zFUMF|IbM5G bPDkA7K>iGvE;K6eXa#-%iLVu@ From 1d4851e2b001e80f42850f0996a5b0212eb682fa Mon Sep 17 00:00:00 2001 From: frisitano Date: Tue, 16 Apr 2024 15:58:56 +0100 Subject: [PATCH 04/13] update state processing logic --- rpc/src/rpc/jerigon.rs | 31 ++++++---- rpc/src/rpc/native/mod.rs | 49 ++++++++++------ rpc/src/rpc/native/state.rs | 28 ++++----- rpc/src/rpc/native/txn.rs | 110 +++++++++++++++++++----------------- 4 files changed, 119 insertions(+), 99 deletions(-) diff --git a/rpc/src/rpc/jerigon.rs b/rpc/src/rpc/jerigon.rs index 2c232d12..8fc88227 100644 --- a/rpc/src/rpc/jerigon.rs +++ b/rpc/src/rpc/jerigon.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use anyhow::{Context, Result}; use async_trait::async_trait; use ethereum_types::{Address, Bloom, H256, U256}; @@ -17,14 +19,14 @@ use tracing::{debug, info}; use super::{ProverInput, RpcClient}; pub struct JerigonRpcClient { - client: Client, + client: Arc, rpc_url: String, } impl JerigonRpcClient { pub fn new(rpc_url: String) -> Self { Self { - client: Client::new(), + client: Arc::new(Client::new()), rpc_url, } } @@ -40,7 +42,7 @@ impl RpcClient for JerigonRpcClient { let (trace_result, rpc_block_metadata) = try_join!( JerigonTraceResponse::fetch(&self.client, &self.rpc_url, block_number), RpcBlockMetadata::fetch( - &self.client, + self.client.clone(), &self.rpc_url, block_number, checkpoint_block_number @@ -101,6 +103,7 @@ impl TryFrom for BlockTrace { Ok(Self { txn_info, + code_db: None, trie_pre_images, }) } @@ -176,7 +179,7 @@ struct EthGetBlockByNumberResponse { impl EthGetBlockByNumberResponse { /// Fetches the block metadata for the given block number. - async fn fetch(client: &Client, rpc_url: U, block_number: u64) -> Result { + async fn fetch(client: Arc, rpc_url: U, block_number: u64) -> Result { let block_number_hex = format!("0x{:x}", block_number); info!("Fetching block metadata for block {}", block_number_hex); @@ -201,7 +204,7 @@ impl EthGetBlockByNumberResponse { } async fn fetch_previous_block_hashes( - client: &Client, + client: Arc, rpc_url: U, block_number: u64, ) -> Result> { @@ -224,7 +227,7 @@ impl EthGetBlockByNumberResponse { let start = block_number.saturating_sub(256); let mut futs: FuturesOrdered<_> = (start..=block_number) .step_by(2) - .map(|block_number| Self::fetch(client, rpc_url, block_number)) + .map(|block_number| Self::fetch(client.clone(), rpc_url, block_number)) .collect(); while let Some(response) = futs.try_next().await? { @@ -246,7 +249,7 @@ impl EthGetBlockByNumberResponse { } async fn fetch_checkpoint_state_trie_root( - client: &Client, + client: Arc, rpc_url: U, block_number: u64, ) -> Result { @@ -263,7 +266,7 @@ struct EthChainIdResponse { impl EthChainIdResponse { /// Fetches the chain id. - async fn fetch(client: &Client, rpc_url: U) -> Result { + async fn fetch(client: Arc, rpc_url: U) -> Result { info!("Fetching chain id"); let response = client @@ -298,15 +301,19 @@ pub(crate) struct RpcBlockMetadata { impl RpcBlockMetadata { pub async fn fetch( - client: &Client, + client: Arc, rpc_url: &str, block_number: u64, checkpoint_block_number: u64, ) -> Result { let (block_result, chain_id_result, prev_hashes, checkpoint_state_trie_root) = try_join!( - EthGetBlockByNumberResponse::fetch(client, rpc_url, block_number), - EthChainIdResponse::fetch(client, rpc_url), - EthGetBlockByNumberResponse::fetch_previous_block_hashes(client, rpc_url, block_number), + EthGetBlockByNumberResponse::fetch(client.clone(), rpc_url, block_number), + EthChainIdResponse::fetch(client.clone(), rpc_url), + EthGetBlockByNumberResponse::fetch_previous_block_hashes( + client.clone(), + rpc_url, + block_number + ), EthGetBlockByNumberResponse::fetch_checkpoint_state_trie_root( client, rpc_url, diff --git a/rpc/src/rpc/native/mod.rs b/rpc/src/rpc/native/mod.rs index b475322e..118f1282 100644 --- a/rpc/src/rpc/native/mod.rs +++ b/rpc/src/rpc/native/mod.rs @@ -1,12 +1,12 @@ -#![allow(clippy::needless_range_loop)] -use std::collections::BTreeMap; -use std::sync::{Arc, Mutex}; +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; use anyhow::{anyhow, Result}; use ethers::prelude::*; -use ethers::types::GethDebugTracerType; +use ethers::types::{GethDebugTracerType, H160, H256}; use futures::stream::{self, TryStreamExt}; -use reqwest::Client; +use reqwest::ClientBuilder; +use tokio::sync::Mutex; use trace_decoder::trace_protocol::{BlockTrace, TxnInfo}; use super::{async_trait, jerigon::RpcBlockMetadata, ProverInput, RpcClient}; @@ -20,14 +20,14 @@ mod txn; /// The native RPC client. pub struct NativeRpcClient { - provider: Provider, + provider: Arc>, rpc_url: String, } impl NativeRpcClient { /// Creates a new `NativeRpcClient` with the given RPC URL. pub fn new(rpc_url: String) -> Result { - let provider = Provider::::try_from(rpc_url.clone())?; + let provider = Arc::new(Provider::::try_from(rpc_url.clone())?); Ok(Self { provider, rpc_url }) } } @@ -39,31 +39,44 @@ impl RpcClient for NativeRpcClient { block_number: u64, checkpoint_block_number: u64, ) -> Result { - let accounts_state = Arc::new(Mutex::new(BTreeMap::::new())); let block = self .provider .get_block(block_number) .await? .ok_or_else(|| anyhow!("Block not found. Block number: {}", block_number))?; - let tx_infos = stream::iter(&block.transactions) - .then(|tx_hash| { - let arc = accounts_state.clone(); - async move { txn::process_transaction(&self.provider, tx_hash, arc).await } - }) - .try_collect::>() - .await?; + let accounts_state = Arc::new(Mutex::new(HashMap::>::new())); + let code_db = Arc::new(Mutex::new(HashMap::>::new())); + let tx_infos = + stream::iter(&block.transactions) + .then(|tx_hash| { + let accounts_state = accounts_state.clone(); + let provider = Arc::clone(&self.provider); + let code_db = Arc::clone(&code_db); + async move { + txn::process_transaction(provider, tx_hash, accounts_state, code_db).await + } + }) + .try_collect::>() + .await?; + + let trie_pre_images = + state::process_state_witness(Arc::clone(&self.provider), block, accounts_state).await?; let block_trace = BlockTrace { txn_info: tx_infos, - trie_pre_images: state::process_state_witness(&self.provider, block, accounts_state) - .await?, + code_db: Some( + Arc::try_unwrap(code_db) + .map_err(|_| anyhow!("Lock still has multiple owners"))? + .into_inner(), + ), + trie_pre_images: trie_pre_images, }; Ok(ProverInput { block_trace, other_data: RpcBlockMetadata::fetch( - &Client::new(), + Arc::new(ClientBuilder::new().http1_only().build()?), &self.rpc_url, block_number, checkpoint_block_number, diff --git a/rpc/src/rpc/native/state.rs b/rpc/src/rpc/native/state.rs index d3c263a5..ec0e9fe2 100644 --- a/rpc/src/rpc/native/state.rs +++ b/rpc/src/rpc/native/state.rs @@ -1,13 +1,12 @@ -use std::collections::BTreeMap; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::sync::Arc; -use std::sync::Mutex; use anyhow::{anyhow, Result}; use ethers::providers::{Http, Middleware, Provider}; -use ethers::types::{AccountState, Block, H160, H256}; +use ethers::types::{Block, H160, H256}; use ethers::utils::keccak256; use mpt_trie::partial_trie::HashedPartialTrie; +use tokio::sync::Mutex; use trace_decoder::trace_protocol::{ BlockTraceTriePreImages, SeparateStorageTriesPreImage, SeparateTriePreImage, SeparateTriePreImages, TrieDirect, @@ -18,14 +17,13 @@ use super::trie::PartialTrieBuilder; /// Processes the state witness for the given block. pub(super) async fn process_state_witness( - provider: &Provider, + provider: Arc>, block: Block, - accounts_state: Arc>>, + accounts_state: Arc>>>, ) -> Result { let accounts_state = Arc::try_unwrap(accounts_state) .map_err(|e| anyhow!("Failed to unwrap accounts state from arc: {e:?}"))? - .into_inner() - .map_err(|e| anyhow!("Failed to unwrap accounts state from mutex: {e:?}"))?; + .into_inner(); let block_number = block .number @@ -60,8 +58,8 @@ pub(super) async fn process_state_witness( /// Generates the state witness for the given block. async fn generate_state_witness( prev_state_root: H256, - accounts_state: BTreeMap, - provider: &Provider, + accounts_state: HashMap>, + provider: Arc>, block_number: ethereum_types::U64, block: Block, ) -> Result< @@ -76,20 +74,17 @@ async fn generate_state_witness( HashMap::>::new(); // Process transaction state accesses - for (address, account) in accounts_state.iter() { + for (address, keys) in accounts_state.iter() { let proof = provider .get_proof( *address, - account - .storage - .as_ref() - .map_or(vec![], |x| x.keys().copied().collect()), + keys.iter().copied().collect(), Some((block_number - 1).into()), ) .await?; state.insert_proof(proof.account_proof); - if account.storage.is_some() { + if keys.len() > 0 { let mut storage_mpt = PartialTrieBuilder::new(proof.storage_hash, Default::default()); for proof in proof.storage_proof { storage_mpt.insert_proof(proof.proof); @@ -115,6 +110,7 @@ async fn generate_state_witness( if let Some(withdrawals) = block.withdrawals.as_ref() { for withdrawal in withdrawals { let proof = provider + // TODO: should this be for the next block? .get_proof(withdrawal.address, vec![], Some((block_number - 1).into())) .await?; state.insert_proof(proof.account_proof); diff --git a/rpc/src/rpc/native/txn.rs b/rpc/src/rpc/native/txn.rs index 133c25b3..0c44b19f 100644 --- a/rpc/src/rpc/native/txn.rs +++ b/rpc/src/rpc/native/txn.rs @@ -1,18 +1,16 @@ -use std::collections::BTreeMap; -use std::collections::HashMap; -use std::str::FromStr; +use std::collections::{HashMap, HashSet}; use std::sync::Arc; -use std::sync::Mutex; use anyhow::{anyhow, Result}; use ethers::providers::Middleware; use ethers::providers::{Http, Provider}; -use ethers::types::U256; use ethers::types::{ - AccountState, Address, DiffMode, GethTrace, GethTraceFrame, PreStateFrame, PreStateMode, - TransactionReceipt, H160, H256, + Address, DiffMode, GethTrace, GethTraceFrame, PreStateFrame, PreStateMode, TransactionReceipt, + H160, H256, U256, }; +use ethers::utils::keccak256; use ethers::utils::rlp; +use tokio::sync::Mutex; use trace_decoder::trace_protocol::ContractCodeUsage; use trace_decoder::trace_protocol::TxnTrace; use trace_decoder::trace_protocol::{TxnInfo, TxnMeta}; @@ -23,9 +21,10 @@ use super::tracing_options_diff; /// Processes the transaction with the given transaction hash and updates the /// accounts state. pub(super) async fn process_transaction( - provider: &Provider, + provider: Arc>, tx_hash: &H256, - accounts_state: Arc>>, + accounts_state: Arc>>>, + code_db: Arc>>>, ) -> Result { let (tx, tx_receipt, pre_trace, diff_trace) = fetch_tx_data(provider, tx_hash).await?; let tx_meta = TxnMeta { @@ -38,11 +37,13 @@ pub(super) async fn process_transaction( .map_err(|_| anyhow!("gas used must be valid u64"))?, }; + let mut accounts_state = accounts_state.lock().await; + let mut code_db = code_db.lock().await; let tx_traces = match (pre_trace, diff_trace) { ( GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Default(read))), GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Diff(diff))), - ) => process_tx_traces(accounts_state, read, diff).await?, + ) => process_tx_traces(&mut accounts_state, &mut code_db, read, diff)?, _ => unreachable!(), }; @@ -54,7 +55,7 @@ pub(super) async fn process_transaction( /// Fetches the transaction data for the given transaction hash. async fn fetch_tx_data( - provider: &Provider, + provider: Arc>, tx_hash: &H256, ) -> Result< ( @@ -100,53 +101,70 @@ fn compute_receipt_bytes(tx_receipt: &TransactionReceipt) -> Vec { } /// Processes the transaction traces and updates the accounts state. -async fn process_tx_traces( - accounts_state: Arc>>, +fn process_tx_traces( + accounts_state: &mut HashMap>, + code_db: &mut HashMap>, read_trace: PreStateMode, diff_trace: DiffMode, ) -> Result> { - let mut accounts_state = accounts_state.lock().unwrap(); - for (address, acct_state) in read_trace.0.iter() { - accounts_state - .entry(*address) - .and_modify(|acct| { - merge_account_storage(&mut acct.storage, acct_state.storage.as_ref()) - }) - .or_insert(acct_state.clone()); - } - let DiffMode { pre: pre_trace, post: post_trace, } = diff_trace; - Ok(read_trace - .0 + let mut addresses = HashSet::::new(); + addresses.extend(read_trace.0.keys()); + addresses.extend(post_trace.keys()); + addresses.extend(pre_trace.keys()); + + Ok(addresses .into_iter() - .map(|(address, acct_state)| { + .map(|address| { + let storage_keys = accounts_state.entry(address).or_insert(Default::default()); + + let acct_state = read_trace.0.get(&address); let balance = post_trace.get(&address).and_then(|x| x.balance); let nonce = post_trace.get(&address).and_then(|x| x.nonce); - let storage_read = acct_state.storage.map(|x| x.keys().copied().collect()); + + let storage_read = acct_state.and_then(|acct| { + acct.storage.as_ref().map(|x| { + let read_keys: Vec = x.keys().copied().collect(); + storage_keys.extend(read_keys.iter().copied()); + read_keys + }) + }); let storage_written = post_trace.get(&address).and_then(|x| { x.storage.as_ref().map(|s| { - s.iter() + let write_keys: HashMap = s + .iter() //TODO: check if endianess is correct .map(|(k, v)| (*k, U256::from_big_endian(v.as_bytes()))) - .collect() + .collect(); + storage_keys.extend(write_keys.keys().copied()); + write_keys }) }); - let code_usage = post_trace.get(&address).map_or( - acct_state - .code - .map(|x| ContractCodeUsage::Read(H256::from_str(&x).expect("must be valid"))), - |x| { - x.code - .as_ref() - .map(|x| ContractCodeUsage::Write(x.as_bytes().to_vec().into())) - }, - ); + let code_usage = post_trace + .get(&address) + .and_then(|x| x.code.as_ref()) + .map_or( + acct_state.and_then(|acct| { + acct.code.as_ref().map(|x| { + let code = hex::decode(&x[2..]).expect("must be valid"); + let code_hash = keccak256(&code).into(); + code_db.insert(code_hash, code); + ContractCodeUsage::Read(code_hash) + }) + }), + |x| { + let code = hex::decode(&x[2..]).expect("must be valid"); + let code_hash = keccak256(&code).into(); + code_db.insert(code_hash, code.clone()); + Some(ContractCodeUsage::Write(code.into())) + }, + ); let self_destructed = if post_trace.get(&address).is_none() && pre_trace.contains_key(&address) { @@ -168,17 +186,3 @@ async fn process_tx_traces( }) .collect::>()) } - -/// Merges the account storage. -fn merge_account_storage( - storage: &mut Option>, - new_storage: Option<&BTreeMap>, -) { - match (storage, new_storage) { - (Some(storage), Some(new_storage)) => storage.extend(new_storage), - (storage, Some(new_storage)) => { - *storage = Some(new_storage.clone()); - } - _ => (), - } -} From d68f0b7e296517b635aa2fdf3edafc43ddf38e4a Mon Sep 17 00:00:00 2001 From: frisitano Date: Thu, 18 Apr 2024 15:06:07 +0100 Subject: [PATCH 05/13] fix gas used bug --- rpc/src/rpc/native/state.rs | 2 +- rpc/src/rpc/native/txn.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/rpc/src/rpc/native/state.rs b/rpc/src/rpc/native/state.rs index ec0e9fe2..5271f639 100644 --- a/rpc/src/rpc/native/state.rs +++ b/rpc/src/rpc/native/state.rs @@ -101,7 +101,7 @@ async fn generate_state_witness( .author .ok_or_else(|| anyhow!("Block author not found"))?, vec![], - block.number.map(Into::into), + Some((block_number - 1).into()), ) .await?; state.insert_proof(proof.account_proof); diff --git a/rpc/src/rpc/native/txn.rs b/rpc/src/rpc/native/txn.rs index 0c44b19f..cb5e8523 100644 --- a/rpc/src/rpc/native/txn.rs +++ b/rpc/src/rpc/native/txn.rs @@ -31,10 +31,7 @@ pub(super) async fn process_transaction( byte_code: tx.rlp().to_vec(), new_txn_trie_node_byte: tx.rlp().to_vec(), new_receipt_trie_node_byte: compute_receipt_bytes(&tx_receipt), - gas_used: tx - .gas - .try_into() - .map_err(|_| anyhow!("gas used must be valid u64"))?, + gas_used: tx_receipt.gas_used.unwrap().as_u64(), }; let mut accounts_state = accounts_state.lock().await; @@ -139,7 +136,7 @@ fn process_tx_traces( let write_keys: HashMap = s .iter() //TODO: check if endianess is correct - .map(|(k, v)| (*k, U256::from_big_endian(v.as_bytes()))) + .map(|(k, v)| (*k, U256::from_big_endian(&v.0))) .collect(); storage_keys.extend(write_keys.keys().copied()); write_keys From 3b71b277b38f01553562f45e061e41bb457bef17 Mon Sep 17 00:00:00 2001 From: frisitano Date: Mon, 22 Apr 2024 15:50:04 +0100 Subject: [PATCH 06/13] fix bugs relating to gas and storage slot deletions --- Cargo.lock | 2 +- README.md | 33 ++++++++ rpc/src/rpc/native/block.rs | 47 +++++++++++ rpc/src/rpc/native/mod.rs | 46 ++--------- rpc/src/rpc/native/state.rs | 105 ++++++++++++++++-------- rpc/src/rpc/native/txn.rs | 158 ++++++++++++++++++++++++------------ 6 files changed, 262 insertions(+), 129 deletions(-) create mode 100644 rpc/src/rpc/native/block.rs diff --git a/Cargo.lock b/Cargo.lock index 6770b655..2e260d25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,7 +286,7 @@ dependencies = [ "futures-lite 2.3.0", "parking", "polling 3.6.0", - "rustix 0.38.32", + "rustix 0.38.33", "slab", "tracing", "windows-sys 0.52.0", diff --git a/README.md b/README.md index 6b410242..63b05906 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Usage: leader [OPTIONS] Commands: stdio Reads input from stdin and writes output to stdout jerigon Reads input from a Jerigon node and writes output to stdout + native Reads input from a native node and writes output to stdout http Reads input from HTTP and writes output to a directory help Print this message or the help of the given subcommand(s) @@ -225,6 +226,38 @@ Prove a block. cargo r --release --bin leader -- -r in-memory jerigon -u -b 16 > ./output/proof_16.json ``` +### Native + +The native command reads proof input from a native node and writes output to stdout. + +``` +cargo r --release --bin leader native --help + +Reads input from a native node and writes output to stdout + +Usage: leader native [OPTIONS] --rpc-url --block-number + +Options: + -u, --rpc-url + + -b, --block-number + The block number for which to generate a proof + -c, --checkpoint-block-number + The checkpoint block number [default: 0] + -f, --previous-proof + The previous proof output + -o, --proof-output-path + If provided, write the generated proof to this file instead of stdout + -h, --help + Print help +``` + +Prove a block. + +```bash +cargo r --release --bin leader -- -r in-memory native -u -b 16 > ./output/proof_16.json +``` + ### HTTP The HTTP command reads proof input from HTTP and writes output to a directory. diff --git a/rpc/src/rpc/native/block.rs b/rpc/src/rpc/native/block.rs new file mode 100644 index 00000000..e97fbe64 --- /dev/null +++ b/rpc/src/rpc/native/block.rs @@ -0,0 +1,47 @@ +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; + +use anyhow::{anyhow, Result}; +use ethers::prelude::*; +use ethers::providers::{Http, Provider}; +use ethers::types::{H160, H256}; +use futures::stream::{self, TryStreamExt}; +use tokio::sync::Mutex; +use trace_decoder::trace_protocol::{BlockTrace, TxnInfo}; + +pub async fn process_block_trace( + provider: Arc>, + block_number: u64, +) -> Result { + let block = provider + .get_block(block_number) + .await? + .ok_or_else(|| anyhow!("Block not found. Block number: {}", block_number))?; + + let accounts_state = Arc::new(Mutex::new(HashMap::>::new())); + let code_db = Arc::new(Mutex::new(HashMap::>::new())); + let tx_infos = stream::iter(&block.transactions) + .then(|tx_hash| { + let accounts_state = accounts_state.clone(); + let provider = Arc::clone(&provider); + let code_db = Arc::clone(&code_db); + async move { + super::txn::process_transaction(provider, tx_hash, accounts_state, code_db).await + } + }) + .try_collect::>() + .await?; + + let trie_pre_images = + super::state::process_state_witness(Arc::clone(&provider), block, accounts_state).await?; + + Ok(BlockTrace { + txn_info: tx_infos, + code_db: Some( + Arc::try_unwrap(code_db) + .map_err(|_| anyhow!("Lock still has multiple owners"))? + .into_inner(), + ), + trie_pre_images: trie_pre_images, + }) +} diff --git a/rpc/src/rpc/native/mod.rs b/rpc/src/rpc/native/mod.rs index 118f1282..dab8ca93 100644 --- a/rpc/src/rpc/native/mod.rs +++ b/rpc/src/rpc/native/mod.rs @@ -1,16 +1,13 @@ -use std::collections::{HashMap, HashSet}; use std::sync::Arc; -use anyhow::{anyhow, Result}; +use anyhow::Result; use ethers::prelude::*; -use ethers::types::{GethDebugTracerType, H160, H256}; -use futures::stream::{self, TryStreamExt}; +use ethers::types::GethDebugTracerType; use reqwest::ClientBuilder; -use tokio::sync::Mutex; -use trace_decoder::trace_protocol::{BlockTrace, TxnInfo}; use super::{async_trait, jerigon::RpcBlockMetadata, ProverInput, RpcClient}; +mod block; mod state; mod trie; mod txn; @@ -39,42 +36,9 @@ impl RpcClient for NativeRpcClient { block_number: u64, checkpoint_block_number: u64, ) -> Result { - let block = self - .provider - .get_block(block_number) - .await? - .ok_or_else(|| anyhow!("Block not found. Block number: {}", block_number))?; - - let accounts_state = Arc::new(Mutex::new(HashMap::>::new())); - let code_db = Arc::new(Mutex::new(HashMap::>::new())); - let tx_infos = - stream::iter(&block.transactions) - .then(|tx_hash| { - let accounts_state = accounts_state.clone(); - let provider = Arc::clone(&self.provider); - let code_db = Arc::clone(&code_db); - async move { - txn::process_transaction(provider, tx_hash, accounts_state, code_db).await - } - }) - .try_collect::>() - .await?; - - let trie_pre_images = - state::process_state_witness(Arc::clone(&self.provider), block, accounts_state).await?; - - let block_trace = BlockTrace { - txn_info: tx_infos, - code_db: Some( - Arc::try_unwrap(code_db) - .map_err(|_| anyhow!("Lock still has multiple owners"))? - .into_inner(), - ), - trie_pre_images: trie_pre_images, - }; - Ok(ProverInput { - block_trace, + block_trace: block::process_block_trace(Arc::clone(&self.provider), block_number) + .await?, other_data: RpcBlockMetadata::fetch( Arc::new(ClientBuilder::new().http1_only().build()?), &self.rpc_url, diff --git a/rpc/src/rpc/native/state.rs b/rpc/src/rpc/native/state.rs index 5271f639..7e70c28f 100644 --- a/rpc/src/rpc/native/state.rs +++ b/rpc/src/rpc/native/state.rs @@ -3,8 +3,10 @@ use std::sync::Arc; use anyhow::{anyhow, Result}; use ethers::providers::{Http, Middleware, Provider}; -use ethers::types::{Block, H160, H256}; +use ethers::types::{Block, EIP1186ProofResponse, H160, H256}; use ethers::utils::keccak256; +use futures::stream::{self, StreamExt, TryStreamExt}; +use futures::TryFutureExt; use mpt_trie::partial_trie::HashedPartialTrie; use tokio::sync::Mutex; use trace_decoder::trace_protocol::{ @@ -62,26 +64,19 @@ async fn generate_state_witness( provider: Arc>, block_number: ethereum_types::U64, block: Block, -) -> Result< - ( - PartialTrieBuilder, - HashMap>, - ), - anyhow::Error, -> { +) -> Result<( + PartialTrieBuilder, + HashMap>, +)> { let mut state = PartialTrieBuilder::new(prev_state_root, Default::default()); let mut storage_proofs = HashMap::>::new(); - // Process transaction state accesses - for (address, keys) in accounts_state.iter() { - let proof = provider - .get_proof( - *address, - keys.iter().copied().collect(), - Some((block_number - 1).into()), - ) - .await?; + let (account_proofs, withdrawals_proofs, author_proof) = + fetch_proof_data(accounts_state, provider, block_number, block).await?; + + // Insert account proofs + for (address, keys, proof) in account_proofs.into_iter() { state.insert_proof(proof.account_proof); if keys.len() > 0 { @@ -94,8 +89,60 @@ async fn generate_state_witness( } } - // Process author account access - let proof = provider + // Insert withdrawal proofs + for proof in withdrawals_proofs.into_iter() { + state.insert_proof(proof.account_proof); + } + + // Insert author proof + state.insert_proof(author_proof.account_proof); + + Ok((state, storage_proofs)) +} + +async fn fetch_proof_data( + accounts_state: HashMap>, + provider: Arc>, + block_number: ethereum_types::U64, + block: Block, +) -> Result< + ( + Vec<(H160, HashSet, EIP1186ProofResponse)>, + Vec, + EIP1186ProofResponse, + ), + anyhow::Error, +> { + let account_proofs_fut = stream::iter(accounts_state.into_iter()).then(|(address, keys)| { + let provider = Arc::clone(&provider); + let block_number = block_number; + async move { + let proof = provider + .get_proof( + address, + keys.iter().copied().collect(), + Some((block_number - 1).into()), + ) + .map_err(|e| anyhow!("Failed to get proof for account: {:?}", e)) + .await?; + Ok::<_, anyhow::Error>((address, keys, proof)) + } + }); + + let withdrawals_proofs_fut = + stream::iter(block.withdrawals.unwrap_or_default()).then(|withdrawal| { + let provider = Arc::clone(&provider); + let block_number = block_number; + async move { + let proof = provider + .get_proof(withdrawal.address, vec![], Some((block_number - 1).into())) + .map_err(|e| anyhow!("Failed to get proof for withdrawal: {:?}", e)) + .await?; + Ok::<_, anyhow::Error>(proof) + } + }); + + let author_proof_fut = provider .get_proof( block .author @@ -103,19 +150,11 @@ async fn generate_state_witness( vec![], Some((block_number - 1).into()), ) - .await?; - state.insert_proof(proof.account_proof); - - // Process withdrawals account access - if let Some(withdrawals) = block.withdrawals.as_ref() { - for withdrawal in withdrawals { - let proof = provider - // TODO: should this be for the next block? - .get_proof(withdrawal.address, vec![], Some((block_number - 1).into())) - .await?; - state.insert_proof(proof.account_proof); - } - } + .map_err(|e| anyhow!("Failed to get proof for author: {:?}", e)); - Ok((state, storage_proofs)) + Ok(futures::try_join!( + account_proofs_fut.try_collect::>(), + withdrawals_proofs_fut.try_collect::>(), + author_proof_fut, + )?) } diff --git a/rpc/src/rpc/native/txn.rs b/rpc/src/rpc/native/txn.rs index cb5e8523..fef895bf 100644 --- a/rpc/src/rpc/native/txn.rs +++ b/rpc/src/rpc/native/txn.rs @@ -4,6 +4,7 @@ use std::sync::Arc; use anyhow::{anyhow, Result}; use ethers::providers::Middleware; use ethers::providers::{Http, Provider}; +use ethers::types::AccountState; use ethers::types::{ Address, DiffMode, GethTrace, GethTraceFrame, PreStateFrame, PreStateMode, TransactionReceipt, H160, H256, U256, @@ -109,66 +110,29 @@ fn process_tx_traces( post: post_trace, } = diff_trace; - let mut addresses = HashSet::::new(); - addresses.extend(read_trace.0.keys()); - addresses.extend(post_trace.keys()); - addresses.extend(pre_trace.keys()); + let addresses: HashSet<_> = read_trace + .0 + .keys() + .chain(post_trace.keys()) + .chain(pre_trace.keys()) + .copied() + .collect(); Ok(addresses .into_iter() .map(|address| { let storage_keys = accounts_state.entry(address).or_insert(Default::default()); + let read_state = read_trace.0.get(&address); + let pre_state = pre_trace.get(&address); + let post_state = post_trace.get(&address); + + let balance = post_state.and_then(|x| x.balance); + let nonce = post_state.and_then(|x| x.nonce); + let (storage_read, storage_written) = + process_storage(storage_keys, read_state, post_state, pre_state); + let code_usage = process_code(post_state, read_state, code_db); + let self_destructed = process_self_destruct(post_state, pre_state); - let acct_state = read_trace.0.get(&address); - let balance = post_trace.get(&address).and_then(|x| x.balance); - let nonce = post_trace.get(&address).and_then(|x| x.nonce); - - let storage_read = acct_state.and_then(|acct| { - acct.storage.as_ref().map(|x| { - let read_keys: Vec = x.keys().copied().collect(); - storage_keys.extend(read_keys.iter().copied()); - read_keys - }) - }); - - let storage_written = post_trace.get(&address).and_then(|x| { - x.storage.as_ref().map(|s| { - let write_keys: HashMap = s - .iter() - //TODO: check if endianess is correct - .map(|(k, v)| (*k, U256::from_big_endian(&v.0))) - .collect(); - storage_keys.extend(write_keys.keys().copied()); - write_keys - }) - }); - - let code_usage = post_trace - .get(&address) - .and_then(|x| x.code.as_ref()) - .map_or( - acct_state.and_then(|acct| { - acct.code.as_ref().map(|x| { - let code = hex::decode(&x[2..]).expect("must be valid"); - let code_hash = keccak256(&code).into(); - code_db.insert(code_hash, code); - ContractCodeUsage::Read(code_hash) - }) - }), - |x| { - let code = hex::decode(&x[2..]).expect("must be valid"); - let code_hash = keccak256(&code).into(); - code_db.insert(code_hash, code.clone()); - Some(ContractCodeUsage::Write(code.into())) - }, - ); - - let self_destructed = - if post_trace.get(&address).is_none() && pre_trace.contains_key(&address) { - Some(true) - } else { - None - }; ( address, TxnTrace { @@ -183,3 +147,89 @@ fn process_tx_traces( }) .collect::>()) } + +/// Processes the storage for the given account state. +/// +/// Returns the storage read and written for the given account in the +/// transaction and updates the storage keys. +fn process_storage( + storage_keys: &mut HashSet, + acct_state: Option<&AccountState>, + post_acct: Option<&AccountState>, + pre_acct: Option<&AccountState>, +) -> (Option>, Option>) { + let storage_read = acct_state.and_then(|acct| { + acct.storage.as_ref().map(|x| { + let read_keys: Vec = x.keys().copied().collect(); + storage_keys.extend(read_keys.iter().copied()); + read_keys + }) + }); + + let mut storage_written: HashMap = post_acct + .and_then(|x| { + x.storage.as_ref().map(|s| { + s.iter() + .map(|(k, v)| (*k, U256::from_big_endian(&v.0))) + .collect() + }) + }) + .unwrap_or_default(); + + // Add the deleted keys to the storage written + pre_acct.and_then(|x| { + x.storage.as_ref().map(|s| { + for key in s.keys() { + storage_written.entry(*key).or_insert(U256::zero()); + } + }) + }); + + storage_keys.extend(storage_written.keys().copied()); + + let storage_written = if storage_written.is_empty() { + None + } else { + Some(storage_written) + }; + + (storage_read, storage_written) +} + +/// Processes the code usage for the given account state. +fn process_code( + post_state: Option<&AccountState>, + read_state: Option<&AccountState>, + code_db: &mut HashMap>, +) -> Option { + let code_usage = post_state.and_then(|x| x.code.as_ref()).map_or( + read_state.and_then(|acct| { + acct.code.as_ref().map(|x| { + let code = hex::decode(&x[2..]).expect("must be valid"); + let code_hash = keccak256(&code).into(); + code_db.insert(code_hash, code); + ContractCodeUsage::Read(code_hash) + }) + }), + |x| { + let code = hex::decode(&x[2..]).expect("must be valid"); + let code_hash = keccak256(&code).into(); + code_db.insert(code_hash, code.clone()); + Some(ContractCodeUsage::Write(code.into())) + }, + ); + code_usage +} + +/// Processes the self destruct for the given account state. +fn process_self_destruct( + post_state: Option<&AccountState>, + pre_state: Option<&AccountState>, +) -> Option { + let self_destructed = if post_state.is_none() && pre_state.is_some() { + Some(true) + } else { + None + }; + self_destructed +} From 361edbf788fced449b7ff996dccd71880f1c480e Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 23 Apr 2024 14:22:27 -0600 Subject: [PATCH 07/13] Implement RAII span for transaction timing to avoid cloning input (#67) --- ops/src/lib.rs | 86 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/ops/src/lib.rs b/ops/src/lib.rs index 04faa1c7..1200047c 100644 --- a/ops/src/lib.rs +++ b/ops/src/lib.rs @@ -25,14 +25,10 @@ impl Operation for TxProof { type Output = proof_gen::proof_types::AggregatableProof; fn execute(&self, input: Self::Input) -> Result { - let proof = Self::run_and_wrap_txn_proof_in_elapsed_span( - || { - common::prover_state::p_manager() - .generate_txn_proof(input.clone()) - .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate).into()) - }, - &input, - )?; + let _span = TxProofSpan::new(&input); + let proof = common::prover_state::p_manager() + .generate_txn_proof(input) + .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate))?; Ok(proof.into()) } @@ -44,48 +40,68 @@ impl Operation for TxProof { type Output = (); fn execute(&self, input: Self::Input) -> Result { - Self::run_and_wrap_txn_proof_in_elapsed_span( - || { - evm_arithmetization::prover::testing::simulate_execution::( - input.clone(), - ) - .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate).into()) - }, - &input, - )?; + let _span = TxProofSpan::new(&input); + evm_arithmetization::prover::testing::simulate_execution::(input) + .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate))?; Ok(()) } } -impl TxProof { - fn run_and_wrap_txn_proof_in_elapsed_span(f: F, ir: &GenerationInputs) -> Result - where - F: Fn() -> Result, - { - let id = format!( +/// RAII struct to measure the time taken by a transaction proof. +/// +/// - When created, it starts a span with the transaction proof id. +/// - When dropped, it logs the time taken by the transaction proof. +struct TxProofSpan { + _span: tracing::span::EnteredSpan, + start: Instant, + descriptor: String, +} + +impl TxProofSpan { + /// Get a unique id for the transaction proof. + fn get_id(ir: &GenerationInputs) -> String { + format!( "b{} - {}", ir.block_metadata.block_number, ir.txn_number_before - ); - - let _span = info_span!("p_gen", id).entered(); - let start = Instant::now(); - - let proof = f()?; + ) + } - let txn_hash_str = ir - .signed_txn + /// Get a textual descriptor for the transaction proof. + /// + /// Either the hex-encoded hash of the transaction or "Dummy" if the + /// transaction is not present. + fn get_descriptor(ir: &GenerationInputs) -> String { + ir.signed_txn .as_ref() .map(|txn| format!("{:x}", keccak(txn))) - .unwrap_or_else(|| "Dummy".to_string()); + .unwrap_or_else(|| "Dummy".to_string()) + } + + /// Create a new transaction proof span. + /// + /// When dropped, it logs the time taken by the transaction proof. + fn new(ir: &GenerationInputs) -> Self { + let id = Self::get_id(ir); + let span = info_span!("p_gen", id).entered(); + let start = Instant::now(); + let descriptor = Self::get_descriptor(ir); + Self { + _span: span, + start, + descriptor, + } + } +} +impl Drop for TxProofSpan { + fn drop(&mut self) { event!( Level::INFO, "txn proof ({}) took {:?}", - txn_hash_str, - start.elapsed() + self.descriptor, + self.start.elapsed() ); - Ok(proof) } } From e18dbd5ed702395917d2e83f26221cbdfde34fcb Mon Sep 17 00:00:00 2001 From: Vladimir Trifonov Date: Wed, 24 Apr 2024 20:07:23 +0300 Subject: [PATCH 08/13] feat: provide IR for debugging upon failure (#48) * feat: provide IR for debugging upon failure * fix: fix clippy issues * fix: fix pr comments * fix: make evm_arithmetization non optional for ops * fix: fix pr comments * fix: fix clippy issues * fix: fix clippy issue * fix: fix pr comment * fix: fix clippy issue * fix: fix cargo lock * fix: fix pr comments * fix: fix format issues * fix: fix save input on error for test-only * fix: fix pr comments * fix: fix * fix: fix clippy issue * fix: fmt fix --------- Co-authored-by: Vladimir Trifonov --- Cargo.lock | 2 + README.md | 5 ++ common/Cargo.toml | 2 + common/src/debug_utils.rs | 102 ++++++++++++++++++++++++++++++++++++ common/src/lib.rs | 1 + leader/src/cli.rs | 9 ++++ leader/src/http.rs | 16 ++++-- leader/src/jerigon.rs | 5 +- leader/src/main.rs | 17 ++++-- leader/src/stdio.rs | 3 +- ops/src/lib.rs | 107 +++++++++++++++++++++++++++++++++----- prover/src/lib.rs | 19 +++++-- 12 files changed, 263 insertions(+), 25 deletions(-) create mode 100644 common/src/debug_utils.rs diff --git a/Cargo.lock b/Cargo.lock index d9777c37..ba777c30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,6 +641,8 @@ dependencies = [ "plonky2", "proof_gen", "seahash", + "serde", + "serde_json", "thiserror", "trace_decoder", "tracing", diff --git a/README.md b/README.md index 6b410242..d826ab96 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ A composition of [`paladin`](https://github.com/0xPolygonZero/paladin) and [`plo - [RPC Usage](#rpc-usage) - [Docker](#docker) - [Development Branches](#development-branches) + - [Testing Blocks](#testing-blocks) + - [Proving Blocks](#proving-blocks) + - [Generating Witnesses Only](#generating-witnesses-only) - [License](#license) - [Contribution](#contribution) @@ -217,6 +220,8 @@ Options: If provided, write the generated proof to this file instead of stdout -h, --help Print help + -s, --save-inputs-on-error + If provided, save the public inputs to disk on error ``` Prove a block. diff --git a/common/Cargo.toml b/common/Cargo.toml index 2eab391d..9a08bbd1 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -17,4 +17,6 @@ evm_arithmetization = { workspace = true } clap = { workspace = true } anyhow = { workspace = true } trace_decoder = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } seahash = "4.1.0" diff --git a/common/src/debug_utils.rs b/common/src/debug_utils.rs new file mode 100644 index 00000000..f8cb53dd --- /dev/null +++ b/common/src/debug_utils.rs @@ -0,0 +1,102 @@ +use std::fs::{self, File}; +use std::io::{self, Write}; +use std::path::{Path, PathBuf}; + +use serde::Serialize; +use serde_json::Error as SerdeError; +use thiserror::Error; + +const DEBUG_FOLDER: &str = "./debug"; + +/// Ensures that the specified directory exists on the filesystem. +/// +/// This function checks if the directory at `folder_path` exists. If not, it +/// attempts to create the directory. It returns an error if the path is not a +/// directory or if there are issues accessing or creating the directory. +/// +/// # Parameters +/// * `folder_path` - A reference to a `Path` that specifies the directory to +/// check or create. +/// +/// # Returns +/// * `Ok(())` - The directory exists or was successfully created. +/// * `Err(io::Error)` - The path is not a directory, or there was a problem +/// accessing or creating the directory. +fn ensure_directory_exists(folder_path: &Path) -> io::Result<()> { + match fs::metadata(folder_path) { + Ok(metadata) => { + if metadata.is_dir() { + Ok(()) // The directory already exists + } else { + Err(io::Error::new( + io::ErrorKind::AlreadyExists, + "The path exists but is not a directory", + )) + } + } + Err(e) => { + if e.kind() == io::ErrorKind::NotFound { + // Directory does not exist, try to create it + fs::create_dir(folder_path) + } else { + // Re-throw the error if it's not a 'NotFound' error + Err(e) + } + } + } +} + +/// An error type for save debug input information. +#[derive(Error, Debug)] +pub enum SaveInputError { + #[error("failed to create directory '{0}'")] + CreateDirectoryError(PathBuf, #[source] io::Error), + + #[error("failed to create file '{0}'")] + CreateFileError(PathBuf, #[source] io::Error), + + #[error("failed to serialize inputs")] + SerializationError(#[source] SerdeError), + + #[error("failed to write to file '{0}'")] + WriteToFileError(PathBuf, #[source] io::Error), +} + +/// Serializes a collection of inputs to a pretty-printed JSON format and saves +/// them to a file. +/// +/// # Arguments +/// +/// * `file_name` - The name of the file (including the extension) where the +/// serialized data will be saved. +/// * `inputs` - A collection of items to be serialized. Each item in the +/// collection must implement the `Serialize` trait. +/// +/// # Returns +/// +/// This function returns a `Result<(), std::io::Error>` indicating the +/// operation's success or failure. +pub fn save_inputs_to_disk( + file_name: String, + inputs: T, +) -> Result<(), SaveInputError> { + let debug_folder = Path::new(DEBUG_FOLDER); + let input_file_path = debug_folder.join(file_name); + + // Ensure the DEBUG_FOLDER exists + ensure_directory_exists(debug_folder) + .map_err(|e| SaveInputError::CreateDirectoryError(debug_folder.to_path_buf(), e))?; + + let mut file = File::create(&input_file_path) + .map_err(|e| SaveInputError::CreateFileError(input_file_path.clone(), e))?; + + // Serialize the entire collection to a pretty JSON string + let all_inputs_str = + serde_json::to_string_pretty(&inputs).map_err(SaveInputError::SerializationError)?; + + // Write the serialized data to the file + file.write_all(all_inputs_str.as_bytes()) + .map_err(|e| SaveInputError::WriteToFileError(input_file_path, e))?; + + Ok(()) +} diff --git a/common/src/lib.rs b/common/src/lib.rs index 234099cf..e9e7b504 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,2 +1,3 @@ +pub mod debug_utils; pub mod parsing; pub mod prover_state; diff --git a/leader/src/cli.rs b/leader/src/cli.rs index 6ab9d8fb..10316f6a 100644 --- a/leader/src/cli.rs +++ b/leader/src/cli.rs @@ -25,6 +25,9 @@ pub(crate) enum Command { /// The previous proof output. #[arg(long, short = 'f', value_hint = ValueHint::FilePath)] previous_proof: Option, + /// If true, save the public inputs to disk on error. + #[arg(short, long, default_value_t = false)] + save_inputs_on_error: bool, }, /// Reads input from a Jerigon node and writes output to stdout. Jerigon { @@ -44,6 +47,9 @@ pub(crate) enum Command { /// stdout. #[arg(long, short = 'o', value_hint = ValueHint::FilePath)] proof_output_path: Option, + /// If true, save the public inputs to disk on error. + #[arg(short, long, default_value_t = false)] + save_inputs_on_error: bool, }, /// Reads input from HTTP and writes output to a directory. Http { @@ -53,5 +59,8 @@ pub(crate) enum Command { /// The directory to which output should be written. #[arg(short, long, value_hint = ValueHint::DirPath)] output_dir: PathBuf, + /// If true, save the public inputs to disk on error. + #[arg(short, long, default_value_t = false)] + save_inputs_on_error: bool, }, } diff --git a/leader/src/http.rs b/leader/src/http.rs index 84187794..80111ce4 100644 --- a/leader/src/http.rs +++ b/leader/src/http.rs @@ -11,7 +11,12 @@ use serde_json::to_writer; use tracing::{debug, error, info}; /// The main function for the HTTP mode. -pub(crate) async fn http_main(runtime: Runtime, port: u16, output_dir: PathBuf) -> Result<()> { +pub(crate) async fn http_main( + runtime: Runtime, + port: u16, + output_dir: PathBuf, + save_inputs_on_error: bool, +) -> Result<()> { let addr = SocketAddr::from(([0, 0, 0, 0], port)); debug!("listening on {}", addr); @@ -20,7 +25,7 @@ pub(crate) async fn http_main(runtime: Runtime, port: u16, output_dir: PathBuf) "/prove", post({ let runtime = runtime.clone(); - move |body| prove(body, runtime, output_dir.clone()) + move |body| prove(body, runtime, output_dir.clone(), save_inputs_on_error) }), ); let listener = tokio::net::TcpListener::bind(&addr).await?; @@ -60,12 +65,17 @@ async fn prove( Json(payload): Json, runtime: Arc, output_dir: PathBuf, + save_inputs_on_error: bool, ) -> StatusCode { debug!("Received payload: {:#?}", payload); let block_number = payload.prover_input.get_block_number(); - match payload.prover_input.prove(&runtime, payload.previous).await { + match payload + .prover_input + .prove(&runtime, payload.previous, save_inputs_on_error) + .await + { Ok(b_proof) => match write_to_file(output_dir, block_number, &b_proof) { Ok(file) => { info!("Successfully wrote proof to {}", file.display()); diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index 899ea20e..6719112a 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -16,6 +16,7 @@ pub(crate) async fn jerigon_main( checkpoint_block_number: u64, previous: Option, proof_output_path_opt: Option, + save_inputs_on_error: bool, ) -> Result<()> { let prover_input = rpc::fetch_prover_input(rpc::FetchProverInputRequest { rpc_url, @@ -24,7 +25,9 @@ pub(crate) async fn jerigon_main( }) .await?; - let proof = prover_input.prove(&runtime, previous).await; + let proof = prover_input + .prove(&runtime, previous, save_inputs_on_error) + .await; runtime.close().await?; let proof = serde_json::to_vec(&proof?.intern)?; diff --git a/leader/src/main.rs b/leader/src/main.rs index 36d2f1e3..8c054ea4 100644 --- a/leader/src/main.rs +++ b/leader/src/main.rs @@ -47,11 +47,18 @@ async fn main() -> Result<()> { let runtime = Runtime::from_config(&args.paladin, register()).await?; match args.command { - Command::Stdio { previous_proof } => { + Command::Stdio { + previous_proof, + save_inputs_on_error, + } => { let previous_proof = get_previous_proof(previous_proof)?; - stdio::stdio_main(runtime, previous_proof).await?; + stdio::stdio_main(runtime, previous_proof, save_inputs_on_error).await?; } - Command::Http { port, output_dir } => { + Command::Http { + port, + output_dir, + save_inputs_on_error, + } => { // check if output_dir exists, is a directory, and is writable let output_dir_metadata = std::fs::metadata(&output_dir); if output_dir_metadata.is_err() { @@ -61,7 +68,7 @@ async fn main() -> Result<()> { panic!("output-dir is not a writable directory"); } - http::http_main(runtime, port, output_dir).await?; + http::http_main(runtime, port, output_dir, save_inputs_on_error).await?; } Command::Jerigon { rpc_url, @@ -69,6 +76,7 @@ async fn main() -> Result<()> { checkpoint_block_number, previous_proof, proof_output_path, + save_inputs_on_error, } => { let previous_proof = get_previous_proof(previous_proof)?; @@ -79,6 +87,7 @@ async fn main() -> Result<()> { checkpoint_block_number, previous_proof, proof_output_path, + save_inputs_on_error, ) .await?; } diff --git a/leader/src/stdio.rs b/leader/src/stdio.rs index e3b6ec5a..7f1e6e3f 100644 --- a/leader/src/stdio.rs +++ b/leader/src/stdio.rs @@ -9,13 +9,14 @@ use prover::ProverInput; pub(crate) async fn stdio_main( runtime: Runtime, previous: Option, + save_inputs_on_error: bool, ) -> Result<()> { let mut buffer = String::new(); std::io::stdin().read_to_string(&mut buffer)?; let des = &mut serde_json::Deserializer::from_str(&buffer); let input: ProverInput = serde_path_to_error::deserialize(des)?; - let proof = input.prove(&runtime, previous).await; + let proof = input.prove(&runtime, previous, save_inputs_on_error).await; runtime.close().await?; let proof = proof?; diff --git a/ops/src/lib.rs b/ops/src/lib.rs index 1200047c..5b6caf69 100644 --- a/ops/src/lib.rs +++ b/ops/src/lib.rs @@ -1,7 +1,7 @@ use std::time::Instant; -use common::prover_state::p_state; -use evm_arithmetization::GenerationInputs; +use common::{debug_utils::save_inputs_to_disk, prover_state::p_state}; +use evm_arithmetization::{proof::PublicValues, GenerationInputs}; use keccak_hash::keccak; use paladin::{ operation::{FatalError, FatalStrategy, Monoid, Operation, Result}, @@ -12,12 +12,14 @@ use proof_gen::{ proof_types::{AggregatableProof, GeneratedAggProof, GeneratedBlockProof}, }; use serde::{Deserialize, Serialize}; -use tracing::{event, info_span, Level}; +use tracing::{error, event, info_span, Level}; registry!(); #[derive(Deserialize, Serialize, RemoteExecute)] -pub struct TxProof; +pub struct TxProof { + pub save_inputs_on_error: bool, +} #[cfg(not(feature = "test_only"))] impl Operation for TxProof { @@ -26,9 +28,27 @@ impl Operation for TxProof { fn execute(&self, input: Self::Input) -> Result { let _span = TxProofSpan::new(&input); - let proof = common::prover_state::p_manager() - .generate_txn_proof(input) - .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate))?; + let proof = if self.save_inputs_on_error { + common::prover_state::p_manager() + .generate_txn_proof(input.clone()) + .map_err(|err| { + if let Err(write_err) = save_inputs_to_disk( + format!( + "b{}_txn_{}_input.log", + input.block_metadata.block_number, input.txn_number_before + ), + input, + ) { + error!("Failed to save txn proof input to disk: {:?}", write_err); + } + + FatalError::from_anyhow(err, FatalStrategy::Terminate) + })? + } else { + common::prover_state::p_manager() + .generate_txn_proof(input) + .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate))? + }; Ok(proof.into()) } @@ -41,8 +61,30 @@ impl Operation for TxProof { fn execute(&self, input: Self::Input) -> Result { let _span = TxProofSpan::new(&input); - evm_arithmetization::prover::testing::simulate_execution::(input) + + if self.save_inputs_on_error { + evm_arithmetization::prover::testing::simulate_execution::( + input.clone(), + ) + .map_err(|err| { + if let Err(write_err) = save_inputs_to_disk( + format!( + "b{}_txn_{}_input.log", + input.block_metadata.block_number, input.txn_number_before + ), + input, + ) { + error!("Failed to save txn proof input to disk: {:?}", write_err); + } + + FatalError::from_anyhow(err, FatalStrategy::Terminate) + })?; + } else { + evm_arithmetization::prover::testing::simulate_execution::( + input, + ) .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate))?; + } Ok(()) } @@ -106,13 +148,40 @@ impl Drop for TxProofSpan { } #[derive(Deserialize, Serialize, RemoteExecute)] -pub struct AggProof; +pub struct AggProof { + pub save_inputs_on_error: bool, +} + +fn get_agg_proof_public_values(elem: AggregatableProof) -> PublicValues { + match elem { + AggregatableProof::Txn(info) => info.p_vals, + AggregatableProof::Agg(info) => info.p_vals, + } +} impl Monoid for AggProof { type Elem = AggregatableProof; fn combine(&self, a: Self::Elem, b: Self::Elem) -> Result { - let result = generate_agg_proof(p_state(), &a, &b).map_err(FatalError::from)?; + let result = generate_agg_proof(p_state(), &a, &b).map_err(|e| { + if self.save_inputs_on_error { + let pv = vec![ + get_agg_proof_public_values(a), + get_agg_proof_public_values(b), + ]; + if let Err(write_err) = save_inputs_to_disk( + format!( + "b{}_agg_lhs_rhs_inputs.log", + pv[0].block_metadata.block_number + ), + pv, + ) { + error!("Failed to save agg proof inputs to disk: {:?}", write_err); + } + } + + FatalError::from(e) + })?; Ok(result.into()) } @@ -126,6 +195,7 @@ impl Monoid for AggProof { #[derive(Deserialize, Serialize, RemoteExecute)] pub struct BlockProof { pub prev: Option, + pub save_inputs_on_error: bool, } impl Operation for BlockProof { @@ -134,8 +204,21 @@ impl Operation for BlockProof { fn execute(&self, input: Self::Input) -> Result { Ok( - generate_block_proof(p_state(), self.prev.as_ref(), &input) - .map_err(FatalError::from)?, + generate_block_proof(p_state(), self.prev.as_ref(), &input).map_err(|e| { + if self.save_inputs_on_error { + if let Err(write_err) = save_inputs_to_disk( + format!( + "b{}_block_input.log", + input.p_vals.block_metadata.block_number + ), + input.p_vals, + ) { + error!("Failed to save block proof input to disk: {:?}", write_err); + } + } + + FatalError::from(e) + })?, ) } } diff --git a/prover/src/lib.rs b/prover/src/lib.rs index abf424a9..8cef4303 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -35,6 +35,7 @@ impl ProverInput { self, runtime: &Runtime, previous: Option, + save_inputs_on_error: bool, ) -> Result { let block_number = self.get_block_number(); info!("Proving block {block_number}"); @@ -46,8 +47,12 @@ impl ProverInput { )?; let agg_proof = IndexedStream::from(txs) - .map(&TxProof) - .fold(&ops::AggProof) + .map(&TxProof { + save_inputs_on_error, + }) + .fold(&ops::AggProof { + save_inputs_on_error, + }) .run(runtime) .await?; @@ -58,7 +63,10 @@ impl ProverInput { }); let block_proof = paladin::directive::Literal(proof) - .map(&ops::BlockProof { prev }) + .map(&ops::BlockProof { + prev, + save_inputs_on_error, + }) .run(runtime) .await?; @@ -74,6 +82,7 @@ impl ProverInput { self, runtime: &Runtime, _previous: Option, + save_inputs_on_error: bool, ) -> Result { let block_number = self.get_block_number(); info!("Testing witness generation for block {block_number}."); @@ -85,7 +94,9 @@ impl ProverInput { )?; IndexedStream::from(txs) - .map(&TxProof) + .map(&TxProof { + save_inputs_on_error, + }) .run(runtime) .await? .try_collect::>() From b25c1129611c32458d19c345e743e3393748c058 Mon Sep 17 00:00:00 2001 From: Vladimir Trifonov Date: Wed, 24 Apr 2024 20:41:36 +0300 Subject: [PATCH 09/13] fix: fix circuit version consistency check (#58) * fix: fix circuit version consistency check * fix: fix clippy issues * fix: update deps --------- Co-authored-by: Vladimir Trifonov Co-authored-by: Robin Salen --- Cargo.lock | 51 ++++++++++++++- common/src/prover_state/mod.rs | 28 ++------ common/src/prover_state/persistence.rs | 15 +++-- common/src/prover_state/utils.rs | 90 -------------------------- leader/Cargo.toml | 1 + leader/src/main.rs | 17 +++++ leader/src/utils.rs | 72 +++++++++++++++++++++ 7 files changed, 154 insertions(+), 120 deletions(-) delete mode 100644 common/src/prover_state/utils.rs create mode 100644 leader/src/utils.rs diff --git a/Cargo.lock b/Cargo.lock index ba777c30..d09d1d71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1855,6 +1855,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "tokio", + "toml", "tracing", "tracing-subscriber", ] @@ -2513,7 +2514,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "toml_edit", + "toml_edit 0.20.2", ] [[package]] @@ -3008,6 +3009,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3432,11 +3442,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.9", +] + [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -3446,7 +3471,20 @@ checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap 2.2.5", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +dependencies = [ + "indexmap 2.2.5", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.6", ] [[package]] @@ -3980,6 +4018,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" diff --git a/common/src/prover_state/mod.rs b/common/src/prover_state/mod.rs index b2c18e39..44463b53 100644 --- a/common/src/prover_state/mod.rs +++ b/common/src/prover_state/mod.rs @@ -15,30 +15,24 @@ use std::{fmt::Display, sync::OnceLock}; use clap::ValueEnum; use evm_arithmetization::{ - cpu::kernel::aggregator::KERNEL, proof::AllProof, prover::prove, AllStark, GenerationInputs, - StarkConfig, + proof::AllProof, prover::prove, AllStark, GenerationInputs, StarkConfig, }; use plonky2::{ - field::goldilocks_field::GoldilocksField, - plonk::config::{GenericHashOut, PoseidonGoldilocksConfig}, + field::goldilocks_field::GoldilocksField, plonk::config::PoseidonGoldilocksConfig, util::timing::TimingTree, }; use proof_gen::{proof_types::GeneratedTxnProof, prover_state::ProverState, VerifierState}; use tracing::info; use self::circuit::{CircuitConfig, NUM_TABLES}; -use crate::prover_state::{ - persistence::{ - BaseProverResource, DiskResource, MonolithicProverResource, RecursiveCircuitResource, - VerifierResource, - }, - utils::pkg_consistency_check, +use crate::prover_state::persistence::{ + BaseProverResource, DiskResource, MonolithicProverResource, RecursiveCircuitResource, + VerifierResource, }; pub mod circuit; pub mod cli; pub mod persistence; -mod utils; pub(crate) type Config = PoseidonGoldilocksConfig; pub(crate) type Field = GoldilocksField; @@ -259,18 +253,6 @@ impl ProverStateManager { CircuitPersistence::Disk(strategy) => { info!("attempting to load preprocessed circuits from disk..."); - // Check the package consistency before loading the circuits. - pkg_consistency_check([ - self.circuit_config - .as_all_recursive_circuits() - .block - .circuit - .verifier_only - .circuit_digest - .to_bytes(), - KERNEL.hash().to_fixed_bytes().to_vec(), - ]); - let disk_state = match strategy { TableLoadStrategy::OnDemand => BaseProverResource::get(&self.circuit_config), TableLoadStrategy::Monolithic => { diff --git a/common/src/prover_state/persistence.rs b/common/src/prover_state/persistence.rs index dae26e64..cd33b04e 100644 --- a/common/src/prover_state/persistence.rs +++ b/common/src/prover_state/persistence.rs @@ -1,3 +1,4 @@ +use std::env; use std::{ fmt::{Debug, Display}, fs::{self, OpenOptions}, @@ -16,7 +17,7 @@ use super::{ Config, RecursiveCircuitsForTableSize, SIZE, }; -pub(crate) const CIRCUITS_FOLDER: &str = "./circuits"; +const CIRCUITS_FOLDER: &str = "./circuits"; const PROVER_STATE_FILE_PREFIX: &str = "prover_state"; const VERIFIER_STATE_FILE_PREFIX: &str = "verifier_state"; @@ -102,9 +103,10 @@ impl DiskResource for BaseProverResource { fn path(p: &Self::PathConstrutor) -> impl AsRef { format!( - "{}/{}_base_{}", + "{}/{}_base_{}_{}", CIRCUITS_FOLDER, PROVER_STATE_FILE_PREFIX, + env::var("EVM_ARITHMETIZATION_PKG_VER").unwrap_or("NA".to_string()), p.get_configuration_digest() ) } @@ -137,9 +139,10 @@ impl DiskResource for MonolithicProverResource { fn path(p: &Self::PathConstrutor) -> impl AsRef { format!( - "{}/{}_monolithic_{}", + "{}/{}_monolithic_{}_{}", CIRCUITS_FOLDER, PROVER_STATE_FILE_PREFIX, + env::var("EVM_ARITHMETIZATION_PKG_VER").unwrap_or("NA".to_string()), p.get_configuration_digest() ) } @@ -171,9 +174,10 @@ impl DiskResource for RecursiveCircuitResource { fn path((circuit_type, size): &Self::PathConstrutor) -> impl AsRef { format!( - "{}/{}_{}_{}", + "{}/{}_{}_{}_{}", CIRCUITS_FOLDER, PROVER_STATE_FILE_PREFIX, + env::var("EVM_ARITHMETIZATION_PKG_VER").unwrap_or("NA".to_string()), circuit_type.as_short_str(), size ) @@ -214,9 +218,10 @@ impl DiskResource for VerifierResource { fn path(p: &Self::PathConstrutor) -> impl AsRef { format!( - "{}/{}_{}", + "{}/{}_{}_{}", CIRCUITS_FOLDER, VERIFIER_STATE_FILE_PREFIX, + env::var("EVM_ARITHMETIZATION_PKG_VER").unwrap_or("NA".to_string()), p.get_configuration_digest() ) } diff --git a/common/src/prover_state/utils.rs b/common/src/prover_state/utils.rs deleted file mode 100644 index 21d042aa..00000000 --- a/common/src/prover_state/utils.rs +++ /dev/null @@ -1,90 +0,0 @@ -use std::fs::{self, File}; -use std::hash::Hasher; -use std::io::{Read, Write}; -use std::path::Path; - -use seahash::SeaHasher; -use tracing::{info, warn}; - -use super::persistence::CIRCUITS_FOLDER; - -/// Checks the consistency of circuits code by comparing a computed hash -/// derived from the provided array of circuit code hashes against a reference -/// hash stored in a designated file within the circuits folder. This function -/// performs several actions based on this comparison: -/// -/// - If the computed aggregate hash differs from the stored hash, or if the -/// hash file does not exist, the function will delete the existing circuits -/// folder (if it exists), recreate it, and then write the new computed hash -/// into the hash file. -/// -/// - If the computed hash matches the stored hash, indicating no changes in the -/// circuits code, the function takes no action. -/// -/// This process ensures that the stored hash always reflects the current state -/// of the circuits code, providing a mechanism for detecting changes and -/// maintaining consistency. -/// -/// # Parameters -/// -/// * `circuits_hashes` - A dynamic number of `Vec` arguments representing -/// circuit code hashes. -/// -/// # Side Effects -/// -/// - May delete and recreate the circuits folder. -/// - May modify or create a file within the circuits folder to store the latest -/// hash. -pub(crate) fn pkg_consistency_check(circuits_hashes: I) -where - I: IntoIterator, - T: AsRef<[u8]>, -{ - let mut hasher = SeaHasher::new(); - for hash in circuits_hashes { - hasher.write(hash.as_ref()); - } - let hash = hasher.finish(); - - let hash_file_path = Path::new(CIRCUITS_FOLDER).join("circuits_consistency_hash"); - - // Check if the circuits folder exists - match fs::metadata(CIRCUITS_FOLDER) { - Ok(_) => { - // Circuits folder exists, check the hash file - let mut existing_hash = String::new(); - if let Ok(mut hash_file) = File::open(&hash_file_path) { - // If the hash file exists and can be read, compare the hash - if hash_file.read_to_string(&mut existing_hash).is_ok() - && existing_hash == hash.to_string() - { - // Hashes are the same, do nothing - return; - } - } else { - warn!("Unable to read circuits consistency hash file"); - } - - // Hashes differ or hash file cannot be read, delete the folder - if fs::remove_dir_all(CIRCUITS_FOLDER).is_err() { - panic!("Failed to delete circuits storage folder"); - } - } - Err(_) => { - info!( - "Initializing circuits storage folder with new consistency hash: {}", - hash - ); - } - } - - // Recreate the circuits folder and write the new hash - if fs::create_dir(CIRCUITS_FOLDER).is_ok() { - if let Ok(mut hash_file) = File::create(&hash_file_path) { - // Ignore errors in writing the hash - let _ = hash_file.write_all(hash.to_string().as_bytes()); - } - } else { - panic!("Failed to create circuits storage folder"); - } -} diff --git a/leader/Cargo.toml b/leader/Cargo.toml index 5c7bcc92..de39328a 100644 --- a/leader/Cargo.toml +++ b/leader/Cargo.toml @@ -22,6 +22,7 @@ serde_json = { workspace = true } serde_path_to_error = { workspace = true } ethereum-types = { workspace = true } axum = "0.7.4" +toml = "0.8.12" # Local dependencies ops = { path = "../ops" } diff --git a/leader/src/main.rs b/leader/src/main.rs index 8c054ea4..5fc4d767 100644 --- a/leader/src/main.rs +++ b/leader/src/main.rs @@ -1,3 +1,4 @@ +use std::env; use std::{fs::File, path::PathBuf}; use anyhow::Result; @@ -9,11 +10,14 @@ use ops::register; use paladin::runtime::Runtime; use proof_gen::types::PlonkyProofIntern; +use crate::utils::get_package_version; + mod cli; mod http; mod init; mod jerigon; mod stdio; +mod utils; fn get_previous_proof(path: Option) -> Result> { if path.is_none() { @@ -32,6 +36,19 @@ async fn main() -> Result<()> { dotenv().ok(); init::tracing(); + if env::var("EVM_ARITHMETIZATION_PKG_VER").is_err() { + let pkg_ver = get_package_version("evm_arithmetization")?; + // Extract the major and minor version parts and append 'x' as the patch version + if let Some((major_minor, _)) = pkg_ver.as_ref().and_then(|s| s.rsplit_once('.')) { + let circuits_version = format!("{}.x", major_minor); + // Set the environment variable for the evm_arithmetization package version + env::set_var("EVM_ARITHMETIZATION_PKG_VER", circuits_version); + } else { + // Set to "NA" if version extraction fails + env::set_var("EVM_ARITHMETIZATION_PKG_VER", "NA"); + } + } + let args = cli::Cli::parse(); if let paladin::config::Runtime::InMemory = args.paladin.runtime { // If running in emulation mode, we'll need to initialize the prover diff --git a/leader/src/utils.rs b/leader/src/utils.rs new file mode 100644 index 00000000..e2c7d5f1 --- /dev/null +++ b/leader/src/utils.rs @@ -0,0 +1,72 @@ +use std::fs::File; +use std::io::{BufReader, Read}; +use std::path::Path; + +use anyhow::Result; + +/// Retrieves the version of a specified package from the `Cargo.lock` file. +/// +/// This function attempts to find the version of a package specified by +/// `package_name` by reading and parsing the `Cargo.lock` file. The +/// `Cargo.lock` file is expected to be located one directory level up from the +/// directory specified by the `CARGO_MANIFEST_DIR` environment variable. The +/// path may need adjustment depending on the structure of the project. +/// +/// # Parameters +/// - `package_name`: The name of the package for which the version is being +/// retrieved. +/// +/// # Returns +/// - `Ok(Some(String))`: If the package is found in the `Cargo.lock` file, +/// returns the version of the package. +/// - `Ok(None)`: If the package is not found in the `Cargo.lock` file, or if +/// the `Cargo.lock` file does not exist. +/// - `Err(_)`: If any error occurs during the execution, such as issues with +/// file paths, file access, reading, or parsing the `Cargo.lock` file. +/// +/// # Examples +/// ```no_run +/// let version = get_package_version("my_package"); +/// match version { +/// Ok(Some(ver)) => println!("Found version: {}", ver), +/// Ok(None) => println!("Package not found."), +/// Err(e) => println!("Error occurred: {}", e), +/// } +/// ``` +/// +/// # Errors +/// This function can return an `Err` result if: +/// - There is a problem finding, opening, or reading the `Cargo.lock` file. +/// - There is a failure in parsing the `Cargo.lock` file as TOML. +/// +/// The function uses `?` to propagate errors upwards, so the exact nature of +/// the error will be indicated by the error value returned in the `Err` variant +/// of the `Result`. +pub(crate) fn get_package_version(package_name: &str) -> Result> { + let manifest_dir = env!("CARGO_MANIFEST_DIR"); + let zero_bin_path = Path::new(manifest_dir) + .join("../") // Adjust the path according to your workspace structure + .canonicalize()?; + + let cargo_lock_path = zero_bin_path.join("Cargo.lock"); + let cargo_lock_file = File::open(cargo_lock_path); + if cargo_lock_file.is_err() { + return Ok(None); + } + + let mut cargo_lock_contents = String::new(); + BufReader::new(cargo_lock_file?).read_to_string(&mut cargo_lock_contents)?; + + let lockfile: toml::Value = toml::from_str(&cargo_lock_contents)?; + if let Some(package) = lockfile["package"] + .as_array() + .unwrap() + .iter() + .find(|&p| p["name"].as_str() == Some(package_name)) + { + let version = package["version"].as_str().unwrap(); + return Ok(Some(version.to_string())); + } + + Ok(None) +} From d913fad47631509ab94439eee9398c804835e7ef Mon Sep 17 00:00:00 2001 From: Robin Salen <30937548+Nashtare@users.noreply.github.com> Date: Thu, 25 Apr 2024 03:35:51 +0900 Subject: [PATCH 10/13] Reduce sizes and add distinction with test_only mode (#69) --- tools/simple_test.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tools/simple_test.sh b/tools/simple_test.sh index 89f1900b..f00e34ce 100755 --- a/tools/simple_test.sh +++ b/tools/simple_test.sh @@ -22,14 +22,26 @@ export RUST_BACKTRACE=full export RUST_LOG=info export RUSTFLAGS='-C target-cpu=native' -# This sizes are configured specifically for this witness. Don't use this in other scenarios -export ARITHMETIC_CIRCUIT_SIZE="16..19" -export BYTE_PACKING_CIRCUIT_SIZE="9..19" -export CPU_CIRCUIT_SIZE="12..21" -export KECCAK_CIRCUIT_SIZE="14..18" -export KECCAK_SPONGE_CIRCUIT_SIZE="9..13" -export LOGIC_CIRCUIT_SIZE="12..17" -export MEMORY_CIRCUIT_SIZE="17..23" +if [[ $1 == "test_only" ]]; then + # Circuit sizes don't matter in test_only mode, so we keep them minimal. + export ARITHMETIC_CIRCUIT_SIZE="16..17" + export BYTE_PACKING_CIRCUIT_SIZE="9..10" + export CPU_CIRCUIT_SIZE="12..13" + export KECCAK_CIRCUIT_SIZE="14..15" + export KECCAK_SPONGE_CIRCUIT_SIZE="9..10" + export LOGIC_CIRCUIT_SIZE="12..13" + export MEMORY_CIRCUIT_SIZE="17..18" +else + # These sizes are configured specifically for this witness. Don't use this in other scenarios + export ARITHMETIC_CIRCUIT_SIZE="16..19" + export BYTE_PACKING_CIRCUIT_SIZE="16..19" + export CPU_CIRCUIT_SIZE="18..21" + export KECCAK_CIRCUIT_SIZE="15..18" + export KECCAK_SPONGE_CIRCUIT_SIZE="10..13" + export LOGIC_CIRCUIT_SIZE="13..17" + export MEMORY_CIRCUIT_SIZE="20..23" +fi + # If we run ./simple_test test_only, we'll generate a dummy # proof. This is useful for quickly testing decoding and all of the From 60fa7c69ca0fa53b95af31307411a196b6258159 Mon Sep 17 00:00:00 2001 From: frisitano Date: Thu, 25 Apr 2024 18:13:19 +0100 Subject: [PATCH 11/13] fix bug relating to empty storage trie --- Cargo.lock | 1305 +++++++++++++++++++++++++++++++---- Cargo.toml | 8 +- rpc/src/rpc/native/state.rs | 2 +- rpc/src/rpc/native/trie.rs | 19 +- 4 files changed, 1201 insertions(+), 133 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e260d25..a48a8e75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "amq-protocol" -version = "7.1.2" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d40d8b2465c7959dd40cee32ba6ac334b5de57e9fca0cc756759894a4152a5d" +checksum = "f051d4d77904272e9be7e292607378dc9900d15b8d314bfd3ed4b82fdd84f125" dependencies = [ "amq-protocol-tcp", "amq-protocol-types", @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "amq-protocol-tcp" -version = "7.1.2" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cb2100adae7da61953a2c3a01935d86caae13329fadce3333f524d6d6ce12e2" +checksum = "4e3d51dd36e67d757c9ba80a7b2a2a2a69254c1dbe4d8c631824ec7f5b69f60e" dependencies = [ "amq-protocol-uri", "tcp-stream", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "amq-protocol-types" -version = "7.1.2" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "156ff13c8a3ced600b4e54ed826a2ae6242b6069d00dd98466827cef07d3daff" +checksum = "0acdd47054ced8b9bc89ee0dbb42ccc8028de48d8658b24de4c255a226c9bfec" dependencies = [ "cookie-factory", "nom", @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "amq-protocol-uri" -version = "7.1.2" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "751bbd7d440576066233e740576f1b31fdc6ab86cfabfbd48c548de77eca73e4" +checksum = "f17881b7575dab3e71403f28a3e50b71f0d1bd026829abca3c48664522ce0df0" dependencies = [ "amq-protocol-types", "percent-encoding", @@ -201,6 +201,45 @@ dependencies = [ "term", ] +[[package]] +name = "asn1-rs" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", + "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.60", +] + [[package]] name = "async-channel" version = "2.2.1" @@ -285,8 +324,8 @@ dependencies = [ "futures-io", "futures-lite 2.3.0", "parking", - "polling 3.6.0", - "rustix 0.38.33", + "polling 3.7.0", + "rustix 0.38.34", "slab", "tracing", "windows-sys 0.52.0", @@ -332,13 +371,24 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", +] + +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version", ] [[package]] @@ -356,12 +406,50 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "auto_impl" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "aws-lc-rs" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5509d663b2c00ee421bda8d6a24d6c42e15970957de1701b8df9f6fbe5707df1" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d5d317212c2a78d86ba6622e969413c38847b62f48111f8b763af3dac2f9840" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + [[package]] name = "axum" version = "0.7.5" @@ -388,7 +476,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.0", + "sync_wrapper 1.0.1", "tokio", "tower", "tower-layer", @@ -464,6 +552,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + [[package]] name = "base64ct" version = "1.6.0" @@ -476,6 +570,29 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.60", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -652,7 +769,21 @@ dependencies = [ name = "cc" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] + +[[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" @@ -710,6 +841,17 @@ dependencies = [ "inout", ] +[[package]] +name = "clang-sys" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "4.5.4" @@ -741,7 +883,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -750,6 +892,27 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "cms" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b77c319abfd5219629c45c34c89ba945ed3c5e49fcde9d16b6c3885f118a730" +dependencies = [ + "const-oid", + "der", + "spki", + "x509-cert", +] + [[package]] name = "cobs" version = "0.2.3" @@ -888,9 +1051,6 @@ name = "cookie-factory" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" -dependencies = [ - "futures", -] [[package]] name = "core-foundation" @@ -1056,7 +1216,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -1067,7 +1227,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -1096,9 +1256,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", + "der_derive", + "flagset", + "pem-rfc7468", "zeroize", ] +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "deranged" version = "0.3.11" @@ -1183,6 +1371,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -1219,7 +1418,26 @@ dependencies = [ name = "either" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] [[package]] name = "embedded-io" @@ -1272,7 +1490,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -1283,7 +1501,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -1328,7 +1546,7 @@ dependencies = [ "hmac", "pbkdf2 0.11.0", "rand", - "scrypt", + "scrypt 0.10.0", "serde", "serde_json", "sha2", @@ -1385,6 +1603,254 @@ dependencies = [ "uint", ] +[[package]] +name = "ethers" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816841ea989f0c69e459af1cf23a6b0033b19a55424a1ea3a30099becdb8dec0" +dependencies = [ + "ethers-addressbook", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-middleware", + "ethers-providers", + "ethers-signers", + "ethers-solc", +] + +[[package]] +name = "ethers-addressbook" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5495afd16b4faa556c3bba1f21b98b4983e53c1755022377051a975c3b021759" +dependencies = [ + "ethers-core", + "once_cell", + "serde", + "serde_json", +] + +[[package]] +name = "ethers-contract" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fceafa3578c836eeb874af87abacfb041f92b4da0a78a5edd042564b8ecdaaa" +dependencies = [ + "const-hex", + "ethers-contract-abigen", + "ethers-contract-derive", + "ethers-core", + "ethers-providers", + "futures-util", + "once_cell", + "pin-project", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "ethers-contract-abigen" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" +dependencies = [ + "Inflector", + "const-hex", + "dunce", + "ethers-core", + "ethers-etherscan", + "eyre", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "reqwest", + "serde", + "serde_json", + "syn 2.0.60", + "toml", + "walkdir", +] + +[[package]] +name = "ethers-contract-derive" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87689dcabc0051cde10caaade298f9e9093d65f6125c14575db3fd8c669a168f" +dependencies = [ + "Inflector", + "const-hex", + "ethers-contract-abigen", + "ethers-core", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.60", +] + +[[package]] +name = "ethers-core" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" +dependencies = [ + "arrayvec", + "bytes", + "cargo_metadata", + "chrono", + "const-hex", + "elliptic-curve", + "ethabi", + "generic-array", + "k256", + "num_enum", + "once_cell", + "open-fastrlp", + "rand", + "rlp", + "serde", + "serde_json", + "strum", + "syn 2.0.60", + "tempfile", + "thiserror", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "ethers-etherscan" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" +dependencies = [ + "chrono", + "ethers-core", + "reqwest", + "semver", + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "ethers-middleware" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48f9fdf09aec667c099909d91908d5eaf9be1bd0e2500ba4172c1d28bfaa43de" +dependencies = [ + "async-trait", + "auto_impl", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-providers", + "ethers-signers", + "futures-channel", + "futures-locks", + "futures-util", + "instant", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "url", +] + +[[package]] +name = "ethers-providers" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" +dependencies = [ + "async-trait", + "auto_impl", + "base64 0.21.7", + "bytes", + "const-hex", + "enr", + "ethers-core", + "futures-core", + "futures-timer", + "futures-util", + "hashers", + "http 0.2.12", + "instant", + "jsonwebtoken", + "once_cell", + "pin-project", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-tungstenite", + "tracing", + "tracing-futures", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "ws_stream_wasm", +] + +[[package]] +name = "ethers-signers" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228875491c782ad851773b652dd8ecac62cda8571d3bc32a5853644dd26766c2" +dependencies = [ + "async-trait", + "coins-bip32", + "coins-bip39", + "const-hex", + "elliptic-curve", + "eth-keystore", + "ethers-core", + "rand", + "sha2", + "thiserror", + "tracing", +] + +[[package]] +name = "ethers-solc" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66244a771d9163282646dbeffe0e6eca4dda4146b6498644e678ac6089b11edd" +dependencies = [ + "cfg-if", + "const-hex", + "dirs", + "dunce", + "ethers-core", + "glob", + "home", + "md-5", + "num_cpus", + "once_cell", + "path-slash", + "rayon", + "regex", + "semver", + "serde", + "serde_json", + "solang-parser", + "svm-rs", + "thiserror", + "tiny-keccak", + "tokio", + "tracing", + "walkdir", + "yansi", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -1436,8 +1902,7 @@ dependencies = [ [[package]] name = "evm_arithmetization" version = "0.1.3" -version = "0.1.3" -source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" dependencies = [ "anyhow", "bytes", @@ -1445,7 +1910,7 @@ dependencies = [ "ethereum-types", "hashbrown 0.14.3", "hex-literal", - "itertools", + "itertools 0.11.0", "jemallocator", "keccak-hash 0.10.0", "log", @@ -1540,6 +2005,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flagset" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb3aa5e95cf9aabc17f060cfa0ced7b83f042390760ca53bf09df9968acaa1" + [[package]] name = "flate2" version = "1.0.28" @@ -1550,24 +2021,14 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "flume" -version = "0.10.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" -dependencies = [ - "futures-core", - "futures-sink", - "pin-project", - "spin 0.9.8", -] - [[package]] name = "flume" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ + "futures-core", + "futures-sink", "spin 0.9.8", ] @@ -1596,6 +2057,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "funty" version = "2.0.0" @@ -1696,7 +2163,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -1778,13 +2245,43 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + [[package]] name = "h2" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ - "futures-channel", + "bytes", + "fnv", "futures-core", "futures-sink", "futures-util", @@ -2030,7 +2527,7 @@ dependencies = [ "futures-util", "http 0.2.12", "hyper 0.14.28", - "rustls", + "rustls 0.21.11", "tokio", "tokio-rustls", ] @@ -2232,6 +2729,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -2258,6 +2764,15 @@ dependencies = [ "libc", ] +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -2324,18 +2839,48 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "lalrpop" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cb077ad656299f160924eb2912aa147d7339ea7d69e1b5517326fdcec3c1ca" +dependencies = [ + "ascii-canvas", + "bit-set", + "ena", + "itertools 0.11.0", + "lalrpop-util", + "petgraph", + "regex", + "regex-syntax 0.8.3", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", + "walkdir", +] + +[[package]] +name = "lalrpop-util" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" +dependencies = [ + "regex-automata 0.4.6", +] + [[package]] name = "lapin" -version = "2.3.1" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f3067a1fcfbc3fc46455809c023e69b8f6602463201010f4ae5a3b572adb9dc" +checksum = "be0454336697a39b3eb8d06339aa1b4da3cad94862fca62b0e32fd4b7f71b563" dependencies = [ "amq-protocol", "async-global-executor-trait", "async-reactor-trait", "async-trait", "executor-trait", - "flume 0.10.14", + "flume", "futures-core", "futures-io", "parking_lot", @@ -2352,6 +2897,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "leader" version = "0.1.0" @@ -2381,6 +2932,16 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if", + "windows-targets 0.52.5", +] + [[package]] name = "libm" version = "0.2.8" @@ -2414,7 +2975,7 @@ checksum = "adf157a4dc5a29b7b464aa8fe7edeff30076e07e13646a1c3874f58477dc99f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -2509,11 +3070,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "mpt_trie" version = "0.2.1" -version = "0.2.1" -source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" dependencies = [ "bytes", "enum-as-inner", @@ -2654,6 +3220,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate 3.1.0", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "object" version = "0.32.2" @@ -2663,6 +3250,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "oid-registry" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" +dependencies = [ + "asn1-rs", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -2716,6 +3312,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "overload" version = "0.1.1" @@ -2723,20 +3325,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] -name = "p12" -version = "0.6.3" +name = "p12-keystore" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4873306de53fe82e7e484df31e1e947d61514b6ea2ed6cd7b45d63006fd9224" +checksum = "fbd7792ed56836118732faffa19b8c2bb20d5f3ff8b403002cd817d6c4ffc96c" dependencies = [ "cbc", - "cipher", + "cms", + "der", "des", - "getrandom", + "hex", "hmac", - "lazy_static", + "pkcs12", + "pkcs5", + "rand", "rc2", "sha1", - "yasna", + "sha2", + "thiserror", + "x509-parser", ] [[package]] @@ -2779,7 +3386,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af25dcb10b7c0ce99abee8694e2e79e4787d7f778b9339dc5a50ba6fc45e5cc9" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -2802,7 +3409,7 @@ version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 1.0.109", @@ -2891,6 +3498,15 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2928,7 +3544,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -2942,6 +3558,77 @@ dependencies = [ "sha2", ] +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.2.6", +] + +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.5" @@ -2959,7 +3646,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -2981,7 +3668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6cfae3ead413ca051a681152bd266438d3bfa301c9bdf836939a14c721bb2a21" dependencies = [ "doc-comment", - "flume 0.11.0", + "flume", "parking_lot", "tracing", ] @@ -2997,6 +3684,36 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkcs12" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "695b3df3d3cc1015f12d70235e35b6b79befc5fa7a9b95b951eab1dd07c9efc2" +dependencies = [ + "cms", + "const-oid", + "der", + "digest", + "spki", + "x509-cert", + "zeroize", +] + +[[package]] +name = "pkcs5" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e847e2c91a18bfa887dd028ec33f2fe6f25db77db3619024764914affe8b69a6" +dependencies = [ + "aes", + "cbc", + "der", + "pbkdf2 0.12.2", + "scrypt 0.11.0", + "sha2", + "spki", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -3023,7 +3740,7 @@ dependencies = [ "anyhow", "getrandom", "hashbrown 0.14.3", - "itertools", + "itertools 0.11.0", "keccak-hash 0.8.0", "log", "num", @@ -3045,7 +3762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a1dca60ad900d81b1fe2df3d0b88d43345988e2935e6709176e96573f4bcf5d" dependencies = [ "anyhow", - "itertools", + "itertools 0.11.0", "num", "plonky2_util", "rand", @@ -3087,15 +3804,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" +checksum = "645493cf344456ef24219d02a768cf1fb92ddf8c92161679ae3d91b91a637be3" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix 0.38.33", + "rustix 0.38.34", "tracing", "windows-sys 0.52.0", ] @@ -3124,6 +3841,22 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "prettyplease" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +dependencies = [ + "proc-macro2", + "syn 2.0.60", +] + [[package]] name = "primitive-types" version = "0.10.1" @@ -3148,13 +3881,32 @@ dependencies = [ "uint", ] +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + [[package]] name = "proc-macro-crate" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "toml_edit", + "toml_edit 0.20.7", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", ] [[package]] @@ -3169,8 +3921,7 @@ dependencies = [ [[package]] name = "proof_gen" version = "0.1.3" -version = "0.1.3" -source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" dependencies = [ "ethereum-types", "evm_arithmetization", @@ -3180,6 +3931,22 @@ dependencies = [ "serde", ] +[[package]] +name = "proptest" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +dependencies = [ + "bitflags 2.5.0", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax 0.8.3", + "unarray", +] + [[package]] name = "prover" version = "0.1.0" @@ -3376,8 +4143,8 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", - "rustls-pemfile", + "rustls 0.21.11", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -3498,6 +4265,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -3513,6 +4286,15 @@ dependencies = [ "semver", ] +[[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.37.27" @@ -3529,9 +4311,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.33" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -3548,30 +4330,47 @@ checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", "ring 0.17.8", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.23.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afabcee0551bd1aa3e18e5adbf2c0544722014b899adb31bd186ec638d3da97e" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki 0.102.3", + "subtle", + "zeroize", +] + [[package]] name = "rustls-connector" -version = "0.18.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25da151615461c7347114b1ad1a7458b4cdebc69cb220cd140cd5cb324b1dd37" +checksum = "727a826801254b6cfcd2508a0508c01b7c1bca21d3673e84d86da084781b83d5" dependencies = [ "log", - "rustls", + "rustls 0.23.5", "rustls-native-certs", - "rustls-webpki", + "rustls-pki-types", + "rustls-webpki 0.102.3", ] [[package]] name = "rustls-native-certs" -version = "0.6.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 2.1.2", + "rustls-pki-types", "schannel", "security-framework", ] @@ -3585,6 +4384,22 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.0", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -3595,6 +4410,18 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +dependencies = [ + "aws-lc-rs", + "ring 0.17.8", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.15" @@ -3607,6 +4434,48 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +dependencies = [ + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "schannel" version = "0.1.23" @@ -3634,14 +4503,25 @@ dependencies = [ "sha2", ] +[[package]] +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "pbkdf2 0.12.2", + "salsa20", + "sha2", +] + [[package]] name = "sct" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring", - "untrusted", + "ring 0.17.8", + "untrusted 0.9.0", ] [[package]] @@ -3650,6 +4530,20 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "security-framework" version = "2.10.0" @@ -3711,14 +4605,14 @@ checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -3758,11 +4652,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.7.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" +checksum = "2c85f8e96d1d6857f13768fcbd895fcb06225510022a2774ed8b5150581847b0" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "chrono", "hex", "indexmap 1.9.3", @@ -3776,14 +4670,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.7.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" +checksum = "c8b3a576c4eb2924262d5951a3b737ccaf16c931e39a2810c36f9a7e25575557" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -3827,6 +4721,12 @@ dependencies = [ "lazy_static", ] +[[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.2" @@ -3905,7 +4805,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" dependencies = [ - "itertools", + "itertools 0.11.0", "lalrpop", "lalrpop-util", "phf", @@ -3953,7 +4853,7 @@ dependencies = [ "ahash", "anyhow", "hashbrown 0.14.3", - "itertools", + "itertools 0.11.0", "log", "num-bigint", "plonky2", @@ -3990,7 +4890,29 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.60", +] [[package]] name = "subtle" @@ -4031,9 +4953,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -4048,9 +4970,20 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.0" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + +[[package]] +name = "synstructure" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384595c11a4e2969895cad5a8c4029115f5ab956a9e5ef4de79d11a426e5f20c" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] [[package]] name = "system-configuration" @@ -4081,14 +5014,37 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tcp-stream" -version = "0.26.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4da30af7998f51ee1aa48ab24276fe303a697b004e31ff542b192c088d5630a5" +checksum = "495b0abdce3dc1f8fd27240651c9e68890c14e9d9c61527b1ce44d8a5a7bd3d5" dependencies = [ "cfg-if", - "p12", + "p12-keystore", "rustls-connector", - "rustls-pemfile", + "rustls-pemfile 2.1.2", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand 2.0.2", + "rustix 0.38.34", + "windows-sys 0.52.0", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", ] [[package]] @@ -4117,7 +5073,7 @@ checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -4223,7 +5179,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -4246,7 +5202,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.11", "tokio", ] @@ -4269,7 +5225,7 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls", + "rustls 0.21.11", "tokio", "tokio-rustls", "tungstenite", @@ -4290,11 +5246,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.12", +] + [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -4373,8 +5344,7 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "trace_decoder" version = "0.3.0" -version = "0.3.0" -source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=develop#4a9dfda25906b3cf29d192342ed4322f39514b7f" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" dependencies = [ "bytes", "ciborium", @@ -4415,7 +5385,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", ] [[package]] @@ -4486,7 +5456,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls", + "rustls 0.21.11", "sha1", "thiserror", "url", @@ -4696,7 +5666,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -4730,7 +5700,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4767,6 +5737,18 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[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.34", +] + [[package]] name = "winapi" version = "0.3.9" @@ -4785,11 +5767,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -5018,16 +6000,38 @@ dependencies = [ ] [[package]] -name = "yansi" -version = "0.5.1" +name = "x509-cert" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +checksum = "1301e935010a701ae5f8655edc0ad17c44bad3ac5ce8c39185f75453b720ae94" +dependencies = [ + "const-oid", + "der", + "spki", +] [[package]] -name = "yasna" -version = "0.5.2" +name = "x509-parser" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" +dependencies = [ + "asn1-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" @@ -5046,5 +6050,60 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.60", +] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2 0.11.0", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.10+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +dependencies = [ + "cc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 46a3511b..54e75d32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,10 +21,10 @@ keccak-hash = "0.10.0" # zk-evm dependencies plonky2 = "0.2.2" -evm_arithmetization = { path = "../zk_evm/evm_arithmetization" } -mpt_trie = { path = "../zk_evm/mpt_trie" } -trace_decoder = { path = "../zk_evm/trace_decoder" } -proof_gen = { path = "../zk_evm/proof_gen" } +evm_arithmetization = { git = "https://github.com/fractal-zkp/zk_evm.git", branch = "trace-processing" } +mpt_trie = { git = "https://github.com/fractal-zkp/zk_evm.git", branch = "trace-processing" } +trace_decoder = { git = "https://github.com/fractal-zkp/zk_evm.git", branch = "trace-processing" } +proof_gen = { git = "https://github.com/fractal-zkp/zk_evm.git", branch = "trace-processing" } [workspace.package] edition = "2021" diff --git a/rpc/src/rpc/native/state.rs b/rpc/src/rpc/native/state.rs index 7e70c28f..c52dae8e 100644 --- a/rpc/src/rpc/native/state.rs +++ b/rpc/src/rpc/native/state.rs @@ -79,7 +79,7 @@ async fn generate_state_witness( for (address, keys, proof) in account_proofs.into_iter() { state.insert_proof(proof.account_proof); - if keys.len() > 0 { + if keys.len() > 0 && proof.storage_hash != H256::zero() { let mut storage_mpt = PartialTrieBuilder::new(proof.storage_hash, Default::default()); for proof in proof.storage_proof { storage_mpt.insert_proof(proof.proof); diff --git a/rpc/src/rpc/native/trie.rs b/rpc/src/rpc/native/trie.rs index 556b0546..1739a5a8 100644 --- a/rpc/src/rpc/native/trie.rs +++ b/rpc/src/rpc/native/trie.rs @@ -51,6 +51,10 @@ fn construct_partial_trie(hash: H256, nodes: &HashMap return T::new(Node::Hash(hash)), }; + decode_node(bytes, nodes) +} + +fn decode_node(bytes: Vec>, nodes: &HashMap>) -> T { let node = match bytes.len() { 17 => parse_branch_node(bytes, nodes), 2 if is_extension_node(&bytes) => parse_extension_node(bytes, nodes), @@ -80,7 +84,7 @@ fn parse_branch_node( .map(|i| { let child = match bytes[i].is_empty() { true => T::default(), - false => construct_partial_trie(H256::from_slice(&bytes[i]), nodes), + false => parse_child_node(&bytes[i], nodes), }; Arc::new(Box::new(child)) }) @@ -105,10 +109,7 @@ fn parse_extension_node( Node::Extension { nibbles: encoded_path, - child: Arc::new(Box::new(construct_partial_trie( - H256::from_slice(&bytes[1]), - nodes, - ))), + child: Arc::new(Box::new(parse_child_node(&bytes[1], nodes))), } } @@ -125,3 +126,11 @@ fn parse_leaf_node(bytes: Vec>) -> Node { value: bytes[1].clone(), } } + +/// Parses a child node from the given bytes. +fn parse_child_node(bytes: &[u8], nodes: &HashMap>) -> T { + match bytes.len() { + x if x < 32 => decode_node(rlp::decode_list::>(bytes), nodes), + _ => construct_partial_trie(H256::from_slice(bytes), nodes), + } +} From a46fde2f451db24719752783f70ded33dd83bb13 Mon Sep 17 00:00:00 2001 From: frisitano Date: Fri, 3 May 2024 12:00:49 +0100 Subject: [PATCH 12/13] add access lists, short node varaints and refactor api request pattern --- Cargo.lock | 197 ++++++++++++++++++------------------ rpc/src/rpc/jerigon.rs | 8 +- rpc/src/rpc/native/block.rs | 18 +++- rpc/src/rpc/native/mod.rs | 20 ++-- rpc/src/rpc/native/state.rs | 103 +++++++++---------- rpc/src/rpc/native/trie.rs | 41 +++++++- rpc/src/rpc/native/txn.rs | 70 +++++++++---- 7 files changed, 273 insertions(+), 184 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a48a8e75..6ed841e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -131,47 +131,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -248,7 +249,7 @@ checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", - "event-listener-strategy 0.5.1", + "event-listener-strategy 0.5.2", "futures-core", "pin-project-lite", ] @@ -261,7 +262,7 @@ checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-lite 2.3.0", "slab", ] @@ -365,9 +366,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.7.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" @@ -554,9 +555,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -652,18 +653,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" dependencies = [ "async-channel", "async-lock 3.3.0", "async-task", - "fastrand 2.0.2", "futures-io", "futures-lite 2.3.0", "piper", - "tracing", ] [[package]] @@ -767,9 +766,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" dependencies = [ "jobserver", "libc", @@ -973,9 +972,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "common" @@ -994,9 +993,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -1237,7 +1236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -1245,9 +1244,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "der" @@ -1891,9 +1890,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener 5.3.0", "pin-project-lite", @@ -1902,13 +1901,13 @@ dependencies = [ [[package]] name = "evm_arithmetization" version = "0.1.3" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" dependencies = [ "anyhow", "bytes", "env_logger", "ethereum-types", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex-literal", "itertools 0.11.0", "jemallocator", @@ -1964,9 +1963,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "ff" @@ -2013,9 +2012,9 @@ checksum = "cdeb3aa5e95cf9aabc17f060cfa0ced7b83f042390760ca53bf09df9968acaa1" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -2138,7 +2137,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-core", "futures-io", "parking", @@ -2320,9 +2319,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -2492,7 +2491,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -2527,7 +2526,7 @@ dependencies = [ "futures-util", "http 0.2.12", "hyper 0.14.28", - "rustls 0.21.11", + "rustls 0.21.12", "tokio", "tokio-rustls", ] @@ -2544,7 +2543,7 @@ dependencies = [ "http-body 1.0.0", "hyper 1.3.1", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", ] @@ -2660,7 +2659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] @@ -2720,6 +2719,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.11.0" @@ -2871,9 +2876,9 @@ dependencies = [ [[package]] name = "lapin" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0454336697a39b3eb8d06339aa1b4da3cad94862fca62b0e32fd4b7f71b563" +checksum = "fae02c316a8a5922ce7518afa6b6c00e9a099f8e59587567e3331efdd11b8ceb" dependencies = [ "amq-protocol", "async-global-executor-trait", @@ -2928,9 +2933,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libloading" @@ -2992,9 +2997,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -3079,7 +3084,7 @@ checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" [[package]] name = "mpt_trie" version = "0.2.1" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" dependencies = [ "bytes", "enum-as-inner", @@ -3423,9 +3428,9 @@ checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -3433,15 +3438,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -3515,9 +3520,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -3526,9 +3531,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -3536,9 +3541,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", @@ -3549,9 +3554,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -3680,7 +3685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" dependencies = [ "atomic-waker", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-io", ] @@ -3739,7 +3744,7 @@ dependencies = [ "ahash", "anyhow", "getrandom", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "itertools 0.11.0", "keccak-hash 0.8.0", "log", @@ -3921,7 +3926,7 @@ dependencies = [ [[package]] name = "proof_gen" version = "0.1.3" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" dependencies = [ "ethereum-types", "evm_arithmetization", @@ -4058,11 +4063,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] @@ -4143,7 +4148,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.11", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -4324,9 +4329,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.11" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", @@ -4390,7 +4395,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "rustls-pki-types", ] @@ -4590,18 +4595,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", @@ -4652,11 +4657,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c85f8e96d1d6857f13768fcbd895fcb06225510022a2774ed8b5150581847b0" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", @@ -4670,9 +4675,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8b3a576c4eb2924262d5951a3b737ccaf16c931e39a2810c36f9a7e25575557" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ "darling", "proc-macro2", @@ -4791,9 +4796,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -4852,7 +4857,7 @@ checksum = "8a8480ca5b8eedf83ad070a780783b4e21a56c6ef66b4c0d1b7520b72bdfda1b" dependencies = [ "ahash", "anyhow", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "itertools 0.11.0", "log", "num-bigint", @@ -5031,7 +5036,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.2", + "fastrand 2.1.0", "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -5155,7 +5160,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.48.0", ] @@ -5202,7 +5207,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.11", + "rustls 0.21.12", "tokio", ] @@ -5225,7 +5230,7 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls 0.21.11", + "rustls 0.21.12", "tokio", "tokio-rustls", "tungstenite", @@ -5310,7 +5315,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.6", + "winnow 0.6.7", ] [[package]] @@ -5343,8 +5348,8 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "trace_decoder" -version = "0.3.0" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#b042dff03554a37e3c27342520c8e4bf54348159" +version = "0.3.1" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" dependencies = [ "bytes", "ciborium", @@ -5456,7 +5461,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.21.11", + "rustls 0.21.12", "sha1", "thiserror", "url", @@ -5939,9 +5944,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" dependencies = [ "memchr", ] diff --git a/rpc/src/rpc/jerigon.rs b/rpc/src/rpc/jerigon.rs index 8fc88227..c626a7cb 100644 --- a/rpc/src/rpc/jerigon.rs +++ b/rpc/src/rpc/jerigon.rs @@ -173,7 +173,7 @@ impl From for (Address, U256) { /// The response from the `eth_getBlockByNumber` RPC method. #[derive(Deserialize, Debug)] -struct EthGetBlockByNumberResponse { +pub(crate) struct EthGetBlockByNumberResponse { result: EthGetBlockByNumberResult, } @@ -260,7 +260,7 @@ impl EthGetBlockByNumberResponse { /// The response from the `eth_chainId` RPC method. #[derive(Deserialize, Debug)] -struct EthChainIdResponse { +pub(crate) struct EthChainIdResponse { result: U256, } @@ -293,8 +293,8 @@ impl EthChainIdResponse { /// /// Contains the necessary data to construct the `OtherBlockData` struct. pub(crate) struct RpcBlockMetadata { - block_by_number: EthGetBlockByNumberResponse, - chain_id: EthChainIdResponse, + pub(crate) block_by_number: EthGetBlockByNumberResponse, + pub(crate) chain_id: EthChainIdResponse, prev_hashes: Vec, checkpoint_state_trie_root: H256, } diff --git a/rpc/src/rpc/native/block.rs b/rpc/src/rpc/native/block.rs index e97fbe64..a93b995a 100644 --- a/rpc/src/rpc/native/block.rs +++ b/rpc/src/rpc/native/block.rs @@ -9,6 +9,7 @@ use futures::stream::{self, TryStreamExt}; use tokio::sync::Mutex; use trace_decoder::trace_protocol::{BlockTrace, TxnInfo}; +/// Processes the block with the given block number and returns the block trace. pub async fn process_block_trace( provider: Arc>, block_number: u64, @@ -18,8 +19,23 @@ pub async fn process_block_trace( .await? .ok_or_else(|| anyhow!("Block not found. Block number: {}", block_number))?; - let accounts_state = Arc::new(Mutex::new(HashMap::>::new())); + let mut accounts_state = HashMap::>::new(); + + block.withdrawals.as_ref().map(|w| { + w.iter().for_each(|w| { + accounts_state.insert(w.address, Default::default()); + }) + }); + accounts_state.insert( + block + .author + .ok_or_else(|| anyhow!("Block author not found"))?, + Default::default(), + ); + + let accounts_state = Arc::new(Mutex::new(accounts_state)); let code_db = Arc::new(Mutex::new(HashMap::>::new())); + let tx_infos = stream::iter(&block.transactions) .then(|tx_hash| { let accounts_state = accounts_state.clone(); diff --git a/rpc/src/rpc/native/mod.rs b/rpc/src/rpc/native/mod.rs index dab8ca93..8ca10c41 100644 --- a/rpc/src/rpc/native/mod.rs +++ b/rpc/src/rpc/native/mod.rs @@ -3,7 +3,9 @@ use std::sync::Arc; use anyhow::Result; use ethers::prelude::*; use ethers::types::GethDebugTracerType; +use futures::try_join; use reqwest::ClientBuilder; +use tracing::debug; use super::{async_trait, jerigon::RpcBlockMetadata, ProverInput, RpcClient}; @@ -36,17 +38,23 @@ impl RpcClient for NativeRpcClient { block_number: u64, checkpoint_block_number: u64, ) -> Result { - Ok(ProverInput { - block_trace: block::process_block_trace(Arc::clone(&self.provider), block_number) - .await?, - other_data: RpcBlockMetadata::fetch( + let (block_trace, rpc_block_metadata) = try_join!( + block::process_block_trace(Arc::clone(&self.provider), block_number), + RpcBlockMetadata::fetch( Arc::new(ClientBuilder::new().http1_only().build()?), &self.rpc_url, block_number, checkpoint_block_number, ) - .await? - .into(), + )?; + + debug!("Got block result: {:?}", rpc_block_metadata.block_by_number); + debug!("Got trace result: {:?}", block_trace); + debug!("Got chain_id: {:?}", rpc_block_metadata.chain_id); + + Ok(ProverInput { + block_trace, + other_data: rpc_block_metadata.into(), }) } } diff --git a/rpc/src/rpc/native/state.rs b/rpc/src/rpc/native/state.rs index c52dae8e..8184b028 100644 --- a/rpc/src/rpc/native/state.rs +++ b/rpc/src/rpc/native/state.rs @@ -42,7 +42,6 @@ pub(super) async fn process_state_witness( accounts_state, provider, block_number, - block, ) .await?; @@ -63,7 +62,6 @@ async fn generate_state_witness( accounts_state: HashMap>, provider: Arc>, block_number: ethereum_types::U64, - block: Block, ) -> Result<( PartialTrieBuilder, HashMap>, @@ -72,30 +70,35 @@ async fn generate_state_witness( let mut storage_proofs = HashMap::>::new(); - let (account_proofs, withdrawals_proofs, author_proof) = - fetch_proof_data(accounts_state, provider, block_number, block).await?; + let (account_proofs, next_account_proofs) = + fetch_proof_data(accounts_state, provider, block_number).await?; // Insert account proofs - for (address, keys, proof) in account_proofs.into_iter() { + for (address, _, proof) in account_proofs.into_iter() { state.insert_proof(proof.account_proof); - if keys.len() > 0 && proof.storage_hash != H256::zero() { - let mut storage_mpt = PartialTrieBuilder::new(proof.storage_hash, Default::default()); - for proof in proof.storage_proof { - storage_mpt.insert_proof(proof.proof); - } - - storage_proofs.insert(keccak256(address).into(), storage_mpt); + let storage_mpt = + storage_proofs + .entry(keccak256(address).into()) + .or_insert(PartialTrieBuilder::new( + proof.storage_hash, + Default::default(), + )); + for proof in proof.storage_proof { + storage_mpt.insert_proof(proof.proof); } } - // Insert withdrawal proofs - for proof in withdrawals_proofs.into_iter() { - state.insert_proof(proof.account_proof); - } + // Insert short node variants from next proofs + for (address, _, proof) in next_account_proofs.into_iter() { + state.insert_if_empty_short_node_variants_from_proof(proof.account_proof); - // Insert author proof - state.insert_proof(author_proof.account_proof); + if let Some(storage_mpt) = storage_proofs.get_mut(&keccak256(address).into()) { + for proof in proof.storage_proof { + storage_mpt.insert_if_empty_short_node_variants_from_proof(proof.proof); + } + } + } Ok((state, storage_proofs)) } @@ -104,57 +107,51 @@ async fn fetch_proof_data( accounts_state: HashMap>, provider: Arc>, block_number: ethereum_types::U64, - block: Block, ) -> Result< ( Vec<(H160, HashSet, EIP1186ProofResponse)>, - Vec, - EIP1186ProofResponse, + Vec<(H160, HashSet, EIP1186ProofResponse)>, ), anyhow::Error, > { - let account_proofs_fut = stream::iter(accounts_state.into_iter()).then(|(address, keys)| { - let provider = Arc::clone(&provider); - let block_number = block_number; - async move { - let proof = provider - .get_proof( - address, - keys.iter().copied().collect(), - Some((block_number - 1).into()), - ) - .map_err(|e| anyhow!("Failed to get proof for account: {:?}", e)) - .await?; - Ok::<_, anyhow::Error>((address, keys, proof)) - } - }); + let account_proofs_fut = { + let accounts_state = accounts_state.clone(); + stream::iter(accounts_state.into_iter()).then(|(address, keys)| { + let provider = Arc::clone(&provider); + let block_number = block_number; + async move { + let proof = provider + .get_proof( + address, + keys.iter().copied().collect(), + Some((block_number - 1).into()), + ) + .map_err(|e| anyhow!("Failed to get proof for account: {:?}", e)) + .await?; + Ok::<_, anyhow::Error>((address, keys, proof)) + } + }) + }; - let withdrawals_proofs_fut = - stream::iter(block.withdrawals.unwrap_or_default()).then(|withdrawal| { + let next_account_proofs_fut = + stream::iter(accounts_state.into_iter()).then(|(address, keys)| { let provider = Arc::clone(&provider); let block_number = block_number; async move { let proof = provider - .get_proof(withdrawal.address, vec![], Some((block_number - 1).into())) - .map_err(|e| anyhow!("Failed to get proof for withdrawal: {:?}", e)) + .get_proof( + address, + keys.iter().copied().collect(), + Some((block_number).into()), + ) + .map_err(|e| anyhow!("Failed to get proof for account: {:?}", e)) .await?; - Ok::<_, anyhow::Error>(proof) + Ok::<_, anyhow::Error>((address, keys, proof)) } }); - let author_proof_fut = provider - .get_proof( - block - .author - .ok_or_else(|| anyhow!("Block author not found"))?, - vec![], - Some((block_number - 1).into()), - ) - .map_err(|e| anyhow!("Failed to get proof for author: {:?}", e)); - Ok(futures::try_join!( account_proofs_fut.try_collect::>(), - withdrawals_proofs_fut.try_collect::>(), - author_proof_fut, + next_account_proofs_fut.try_collect::>() )?) } diff --git a/rpc/src/rpc/native/trie.rs b/rpc/src/rpc/native/trie.rs index 1739a5a8..80f68258 100644 --- a/rpc/src/rpc/native/trie.rs +++ b/rpc/src/rpc/native/trie.rs @@ -11,6 +11,12 @@ use mpt_trie::{ partial_trie::{Node, PartialTrie, WrappedNode}, }; +/// The hash of an empty trie. +pub const EMPTY_TRIE_HASH: H256 = H256([ + 0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, + 0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21, +]); + /// A builder for constructing a partial trie from a collection of nodes. pub struct PartialTrieBuilder { root: H256, @@ -38,16 +44,43 @@ impl PartialTrieBuilder { } } + /// Inserts variants of extension and leaf nodes into the builder. + pub fn insert_if_empty_short_node_variants_from_proof(&mut self, proof: Vec) { + for node in proof { + let bytes = rlp::decode_list::>(&node); + match bytes.len() { + 2 => self.insert_short_node_variants(bytes), + _ => continue, + } + } + } + /// Builds the partial trie from the nodes and root. pub fn build(self) -> T { construct_partial_trie(self.root, &self.nodes) } + + fn insert_short_node_variants(&mut self, bytes: Vec>) { + let is_leaf = is_leaf_node(&bytes); + let mut nibbles = Nibbles::from_bytes_be(&bytes[0][..]).unwrap(); + while !nibbles.is_empty() { + nibbles.pop_next_nibble_front(); + let node = rlp::encode_list::, _>(&[ + nibbles.to_hex_prefix_encoding(is_leaf).to_vec(), + bytes[1].clone(), + ]); + self.nodes + .entry(keccak256(&node).into()) + .or_insert(node.to_vec()); + } + } } /// Constructs a partial trie from a root hash and a collection of nodes. fn construct_partial_trie(hash: H256, nodes: &HashMap>) -> T { let bytes = match nodes.get(&hash) { Some(value) => rlp::decode_list::>(value), + None if [H256::zero(), EMPTY_TRIE_HASH].contains(&hash) => return T::default(), None => return T::new(Node::Hash(hash)), }; @@ -103,8 +136,8 @@ fn parse_extension_node( ) -> Node { let mut encoded_path = Nibbles::from_bytes_be(&bytes[0][..]).unwrap(); - if encoded_path.pop_nibbles_front(1).get_nibble(0) == 0 { - encoded_path.pop_nibbles_front(1); + if encoded_path.pop_next_nibble_front() == 0 { + encoded_path.pop_next_nibble_front(); } Node::Extension { @@ -117,8 +150,8 @@ fn parse_extension_node( fn parse_leaf_node(bytes: Vec>) -> Node { let mut encoded_path = Nibbles::from_bytes_be(&bytes[0][..]).unwrap(); - if encoded_path.pop_nibbles_front(1).get_nibble(0) == 2 { - encoded_path.pop_nibbles_front(1); + if encoded_path.pop_next_nibble_front() == 2 { + encoded_path.pop_next_nibble_front(); } Node::Leaf { diff --git a/rpc/src/rpc/native/txn.rs b/rpc/src/rpc/native/txn.rs index fef895bf..19acf489 100644 --- a/rpc/src/rpc/native/txn.rs +++ b/rpc/src/rpc/native/txn.rs @@ -6,8 +6,8 @@ use ethers::providers::Middleware; use ethers::providers::{Http, Provider}; use ethers::types::AccountState; use ethers::types::{ - Address, DiffMode, GethTrace, GethTraceFrame, PreStateFrame, PreStateMode, TransactionReceipt, - H160, H256, U256, + transaction::eip2930::AccessList, Address, DiffMode, GethTrace, GethTraceFrame, PreStateFrame, + PreStateMode, TransactionReceipt, H160, H256, U256, }; use ethers::utils::keccak256; use ethers::utils::rlp; @@ -35,13 +35,14 @@ pub(super) async fn process_transaction( gas_used: tx_receipt.gas_used.unwrap().as_u64(), }; + let access_list = parse_access_list(tx.access_list.unwrap_or_default()); let mut accounts_state = accounts_state.lock().await; let mut code_db = code_db.lock().await; let tx_traces = match (pre_trace, diff_trace) { ( GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Default(read))), GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Diff(diff))), - ) => process_tx_traces(&mut accounts_state, &mut code_db, read, diff)?, + ) => process_tx_traces(&mut accounts_state, &mut code_db, access_list, read, diff)?, _ => unreachable!(), }; @@ -98,10 +99,25 @@ fn compute_receipt_bytes(tx_receipt: &TransactionReceipt) -> Vec { rlp::encode(&bytes).to_vec() } +/// Parse the access list data into a hashmap. +fn parse_access_list(access_list: AccessList) -> HashMap> { + let mut result = HashMap::new(); + + for item in access_list.0.into_iter() { + result + .entry(item.address) + .or_insert_with(HashSet::new) + .extend(item.storage_keys); + } + + result +} + /// Processes the transaction traces and updates the accounts state. fn process_tx_traces( accounts_state: &mut HashMap>, code_db: &mut HashMap>, + mut access_list: HashMap>, read_trace: PreStateMode, diff_trace: DiffMode, ) -> Result> { @@ -115,6 +131,7 @@ fn process_tx_traces( .keys() .chain(post_trace.keys()) .chain(pre_trace.keys()) + .chain(access_list.keys()) .copied() .collect(); @@ -127,10 +144,21 @@ fn process_tx_traces( let post_state = post_trace.get(&address); let balance = post_state.and_then(|x| x.balance); - let nonce = post_state.and_then(|x| x.nonce); - let (storage_read, storage_written) = - process_storage(storage_keys, read_state, post_state, pre_state); + let (storage_read, storage_written) = process_storage( + storage_keys, + access_list.remove(&address).unwrap_or_default(), + read_state, + post_state, + pre_state, + ); let code_usage = process_code(post_state, read_state, code_db); + let nonce = post_state.and_then(|x| x.nonce).or_else(|| { + if let Some(ContractCodeUsage::Write(_)) = code_usage.as_ref() { + Some(U256::from(1)) + } else { + None + } + }); let self_destructed = process_self_destruct(post_state, pre_state); ( @@ -154,17 +182,21 @@ fn process_tx_traces( /// transaction and updates the storage keys. fn process_storage( storage_keys: &mut HashSet, + access_list: HashSet, acct_state: Option<&AccountState>, post_acct: Option<&AccountState>, pre_acct: Option<&AccountState>, ) -> (Option>, Option>) { - let storage_read = acct_state.and_then(|acct| { - acct.storage.as_ref().map(|x| { - let read_keys: Vec = x.keys().copied().collect(); - storage_keys.extend(read_keys.iter().copied()); - read_keys - }) - }); + let mut storage_read = access_list; + storage_read.extend( + acct_state + .and_then(|acct| { + acct.storage + .as_ref() + .map(|x| x.keys().copied().collect::>()) + }) + .unwrap_or_default(), + ); let mut storage_written: HashMap = post_acct .and_then(|x| { @@ -186,14 +218,12 @@ fn process_storage( }); storage_keys.extend(storage_written.keys().copied()); + storage_keys.extend(storage_read.iter().copied()); - let storage_written = if storage_written.is_empty() { - None - } else { - Some(storage_written) - }; - - (storage_read, storage_written) + ( + Option::from(storage_read.into_iter().collect::>()).filter(|v| !v.is_empty()), + Option::from(storage_written).filter(|v| !v.is_empty()), + ) } /// Processes the code usage for the given account state. From c41a3327c218bcba289235e9d89ef4030543db02 Mon Sep 17 00:00:00 2001 From: frisitano Date: Fri, 10 May 2024 14:30:44 +0100 Subject: [PATCH 13/13] add native tracer support --- Cargo.lock | 422 +++++++++++++++++++++--------------- leader/src/cli.rs | 3 + leader/src/main.rs | 2 + prover/src/lib.rs | 6 +- rpc/src/rpc/jerigon.rs | 10 +- rpc/src/rpc/native/block.rs | 6 +- rpc/src/rpc/native/state.rs | 26 ++- 7 files changed, 280 insertions(+), 195 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3762b200..46d11d25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" dependencies = [ "backtrace", ] @@ -226,7 +226,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "synstructure", ] @@ -238,7 +238,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -378,7 +378,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -415,20 +415,20 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-lc-rs" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5509d663b2c00ee421bda8d6a24d6c42e15970957de1701b8df9f6fbe5707df1" +checksum = "8487b59d62764df8231cb371c459314df895b41756df457a1fb1243d65c89195" dependencies = [ "aws-lc-sys", "mirai-annotations", @@ -438,9 +438,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d5d317212c2a78d86ba6622e969413c38847b62f48111f8b763af3dac2f9840" +checksum = "c15eb61145320320eb919d9bab524617a7aa4216c78d342fae3a758bc33073e4" dependencies = [ "bindgen", "cc", @@ -590,7 +590,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.60", + "syn 2.0.61", "which", ] @@ -766,9 +766,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", @@ -882,7 +882,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -982,7 +982,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", - "evm_arithmetization", + "evm_arithmetization 0.1.3 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", "plonky2", "proof_gen", "seahash", @@ -1217,7 +1217,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1228,7 +1228,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1285,7 +1285,7 @@ checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1380,7 +1380,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1448,9 +1448,9 @@ checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" [[package]] name = "ena" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" dependencies = [ "log", ] @@ -1491,7 +1491,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1502,7 +1502,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1526,9 +1526,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -1670,7 +1670,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.60", + "syn 2.0.61", "toml", "walkdir", ] @@ -1688,7 +1688,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1714,7 +1714,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.60", + "syn 2.0.61", "tempfile", "thiserror", "tiny-keccak", @@ -1903,7 +1903,7 @@ dependencies = [ [[package]] name = "evm_arithmetization" version = "0.1.3" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" +source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=feat_type2_hack#b4c5e0948d644e0ebdf82510c9c98aa765868553" dependencies = [ "anyhow", "bytes", @@ -1915,7 +1915,7 @@ dependencies = [ "jemallocator", "keccak-hash 0.10.0", "log", - "mpt_trie", + "mpt_trie 0.2.1 (git+https://github.com/0xPolygonZero/zk_evm.git?branch=feat_type2_hack)", "num", "num-bigint", "once_cell", @@ -1930,7 +1930,43 @@ dependencies = [ "rlp-derive", "serde", "serde_json", - "starky", + "smt_trie", + "starky 0.3.0", + "static_assertions", + "tiny-keccak", +] + +[[package]] +name = "evm_arithmetization" +version = "0.1.3" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#a37e613c79602504993372cb176b6ebb118c33ab" +dependencies = [ + "anyhow", + "bytes", + "env_logger", + "ethereum-types", + "hashbrown 0.14.5", + "hex-literal", + "itertools 0.11.0", + "jemallocator", + "keccak-hash 0.10.0", + "log", + "mpt_trie 0.2.1 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", + "num", + "num-bigint", + "once_cell", + "pest", + "pest_derive", + "plonky2", + "plonky2_maybe_rayon", + "plonky2_util", + "rand", + "rand_chacha", + "rlp", + "rlp-derive", + "serde", + "serde_json", + "starky 0.4.0", "static_assertions", "tiny-keccak", ] @@ -2164,7 +2200,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -2229,9 +2265,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -2493,7 +2529,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -2528,7 +2564,7 @@ dependencies = [ "futures-util", "http 0.2.12", "hyper 0.14.28", - "rustls 0.21.11", + "rustls 0.21.12", "tokio", "tokio-rustls", ] @@ -2968,22 +3004,22 @@ dependencies = [ [[package]] name = "linkme" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2cfee0de9bd869589fb9a015e155946d1be5ff415cb844c2caccc6cc4b5db9" +checksum = "833222afbfe72868ac8f9770c91a33673f0d5fefc37c9dbe94aa3548b571623f" dependencies = [ "linkme-impl", ] [[package]] name = "linkme-impl" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adf157a4dc5a29b7b464aa8fe7edeff30076e07e13646a1c3874f58477dc99f8" +checksum = "39f0dea92dbea3271557cc2e1848723967bba81f722f95026860974ec9283f08" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3087,7 +3123,31 @@ checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" [[package]] name = "mpt_trie" version = "0.2.1" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" +source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=feat_type2_hack#b4c5e0948d644e0ebdf82510c9c98aa765868553" +dependencies = [ + "bytes", + "enum-as-inner", + "ethereum-types", + "hex", + "impl-codec", + "impl-num-traits", + "impl-rlp", + "impl-serde", + "keccak-hash 0.10.0", + "log", + "num", + "num-traits", + "parking_lot", + "rlp", + "serde", + "thiserror", + "uint", +] + +[[package]] +name = "mpt_trie" +version = "0.2.1" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#a37e613c79602504993372cb176b6ebb118c33ab" dependencies = [ "bytes", "enum-as-inner", @@ -3136,9 +3196,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -3150,11 +3210,10 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", "rand", @@ -3162,9 +3221,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", "rand", @@ -3187,9 +3246,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -3198,11 +3257,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -3210,9 +3268,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -3243,10 +3301,10 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3310,7 +3368,7 @@ version = "0.1.0" dependencies = [ "common", "ethereum-types", - "evm_arithmetization", + "evm_arithmetization 0.1.3 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", "keccak-hash 0.10.0", "paladin-core", "proof_gen", @@ -3394,14 +3452,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af25dcb10b7c0ce99abee8694e2e79e4787d7f778b9339dc5a50ba6fc45e5cc9" dependencies = [ "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "bitvec", @@ -3413,11 +3471,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -3465,9 +3523,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "path-slash" @@ -3552,7 +3610,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3568,9 +3626,9 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap 2.2.6", @@ -3616,7 +3674,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3654,7 +3712,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3857,12 +3915,12 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettyplease" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3891,28 +3949,18 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit 0.20.7", + "toml_edit 0.21.1", ] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -3920,10 +3968,10 @@ dependencies = [ [[package]] name = "proof_gen" version = "0.1.3" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#a37e613c79602504993372cb176b6ebb118c33ab" dependencies = [ "ethereum-types", - "evm_arithmetization", + "evm_arithmetization 0.1.3 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", "log", "paste", "plonky2", @@ -4142,7 +4190,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.11", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -4241,11 +4289,11 @@ dependencies = [ "common", "ethereum-types", "ethers", - "evm_arithmetization", + "evm_arithmetization 0.1.3 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", "futures", "hex", "hex-literal", - "mpt_trie", + "mpt_trie 0.2.1 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", "prover", "reqwest", "serde", @@ -4260,9 +4308,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -4323,9 +4371,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.11" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", @@ -4395,9 +4443,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" @@ -4423,15 +4471,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "salsa20" @@ -4453,9 +4501,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", "derive_more", @@ -4465,11 +4513,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -4545,11 +4593,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -4558,9 +4606,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -4568,9 +4616,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -4589,29 +4637,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.200" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.200" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -4676,7 +4724,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4778,6 +4826,28 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smt_trie" +version = "0.1.0" +source = "git+https://github.com/0xPolygonZero/zk_evm.git?branch=feat_type2_hack#b4c5e0948d644e0ebdf82510c9c98aa765868553" +dependencies = [ + "bytes", + "enum-as-inner", + "ethereum-types", + "hex", + "hex-literal", + "keccak-hash 0.10.0", + "log", + "num-traits", + "parking_lot", + "plonky2", + "rand", + "rlp", + "serde", + "thiserror", + "uint", +] + [[package]] name = "socket2" version = "0.4.10" @@ -4843,6 +4913,23 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "starky" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf2fe03f53197fbd5e2f2e5fbb809f8e953881cc729261b55f71134323bbfd6" +dependencies = [ + "ahash", + "anyhow", + "hashbrown 0.14.5", + "itertools 0.11.0", + "log", + "num-bigint", + "plonky2", + "plonky2_maybe_rayon", + "plonky2_util", +] + [[package]] name = "starky" version = "0.4.0" @@ -4910,7 +4997,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4952,9 +5039,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" dependencies = [ "proc-macro2", "quote", @@ -4981,7 +5068,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -5057,22 +5144,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -5178,7 +5265,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -5201,7 +5288,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.11", + "rustls 0.21.12", "tokio", ] @@ -5224,7 +5311,7 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls 0.21.11", + "rustls 0.21.12", "tokio", "tokio-rustls", "tungstenite", @@ -5233,16 +5320,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -5254,7 +5340,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.9", + "toml_edit 0.22.12", ] [[package]] @@ -5268,20 +5354,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.20.7" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.6", "toml_datetime", @@ -5290,15 +5365,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.6", + "winnow 0.6.8", ] [[package]] @@ -5332,7 +5407,7 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "trace_decoder" version = "0.3.1" -source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#3ff7f26ccd5ffaeae717e3385423ea825d29c097" +source = "git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing#a37e613c79602504993372cb176b6ebb118c33ab" dependencies = [ "bytes", "ciborium", @@ -5340,12 +5415,13 @@ dependencies = [ "enum-as-inner", "enumn", "ethereum-types", - "evm_arithmetization", + "evm_arithmetization 0.1.3 (git+https://github.com/0xPolygonZero/zk_evm.git?branch=feat_type2_hack)", + "evm_arithmetization 0.1.3 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", "hex", "hex-literal", "keccak-hash 0.10.0", "log", - "mpt_trie", + "mpt_trie 0.2.1 (git+https://github.com/fractal-zkp/zk_evm.git?branch=trace-processing)", "rlp", "rlp-derive", "serde", @@ -5373,7 +5449,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -5444,7 +5520,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.21.11", + "rustls 0.21.12", "sha1", "thiserror", "url", @@ -5654,7 +5730,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "wasm-bindgen-shared", ] @@ -5688,7 +5764,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5927,9 +6003,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr", ] @@ -6023,22 +6099,22 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] diff --git a/leader/src/cli.rs b/leader/src/cli.rs index dfc9b98b..cab00d4e 100644 --- a/leader/src/cli.rs +++ b/leader/src/cli.rs @@ -69,6 +69,9 @@ pub(crate) enum Command { /// stdout. #[arg(long, short = 'o', value_hint = ValueHint::FilePath)] proof_output_path: Option, + /// If true, save the public inputs to disk on error. + #[arg(short, long, default_value_t = false)] + save_inputs_on_error: bool, }, /// Reads input from HTTP and writes output to a directory. Http { diff --git a/leader/src/main.rs b/leader/src/main.rs index 91f08a9d..793f8b12 100644 --- a/leader/src/main.rs +++ b/leader/src/main.rs @@ -106,6 +106,7 @@ async fn main() -> Result<()> { checkpoint_block_number, previous_proof, proof_output_path, + save_inputs_on_error, ) .await?; } @@ -115,6 +116,7 @@ async fn main() -> Result<()> { checkpoint_block_number, previous_proof, proof_output_path, + save_inputs_on_error, } => { let previous_proof = get_previous_proof(previous_proof)?; let client = diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 8cef4303..258863a1 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -10,7 +10,7 @@ use paladin::{ use proof_gen::{proof_types::GeneratedBlockProof, types::PlonkyProofIntern}; use serde::{Deserialize, Serialize}; use trace_decoder::{ - processed_block_trace::ProcessingMeta, + processed_block_trace_mpt::ProcessingMeta, trace_protocol::BlockTrace, types::{CodeHash, OtherBlockData}, }; @@ -41,7 +41,7 @@ impl ProverInput { info!("Proving block {block_number}"); let other_data = self.other_data; - let txs = self.block_trace.into_txn_proof_gen_ir( + let txs = self.block_trace.into_proof_gen_mpt_ir( &ProcessingMeta::new(resolve_code_hash_fn), other_data.clone(), )?; @@ -88,7 +88,7 @@ impl ProverInput { info!("Testing witness generation for block {block_number}."); let other_data = self.other_data; - let txs = self.block_trace.into_txn_proof_gen_ir( + let txs = self.block_trace.into_proof_gen_mpt_ir( &ProcessingMeta::new(resolve_code_hash_fn), other_data.clone(), )?; diff --git a/rpc/src/rpc/jerigon.rs b/rpc/src/rpc/jerigon.rs index c626a7cb..0349a167 100644 --- a/rpc/src/rpc/jerigon.rs +++ b/rpc/src/rpc/jerigon.rs @@ -11,7 +11,9 @@ use serde::Deserialize; use thiserror::Error; use tokio::try_join; use trace_decoder::{ - trace_protocol::{BlockTrace, BlockTraceTriePreImages, TxnInfo}, + trace_protocol::{ + AtomicUnitInfo, BlockTrace, MptBlockTraceTriePreImages, TriePreImage, TxnInfo, + }, types::{BlockLevelData, OtherBlockData}, }; use tracing::{debug, info}; @@ -65,7 +67,7 @@ impl RpcClient for JerigonRpcClient { #[allow(clippy::large_enum_variant)] pub(crate) enum JerigonResultItem { Result(TxnInfo), - BlockWitness(BlockTraceTriePreImages), + BlockWitness(MptBlockTraceTriePreImages), } /// The response from the `debug_traceBlockByNumber` RPC method. @@ -102,9 +104,9 @@ impl TryFrom for BlockTrace { trie_pre_images.ok_or(JerigonTraceError::BlockTraceTriePreImagesNotFound)?; Ok(Self { - txn_info, + atomic_info: AtomicUnitInfo::Txn(txn_info), code_db: None, - trie_pre_images, + trie_pre_images: TriePreImage::Mpt(trie_pre_images), }) } } diff --git a/rpc/src/rpc/native/block.rs b/rpc/src/rpc/native/block.rs index a93b995a..1826a786 100644 --- a/rpc/src/rpc/native/block.rs +++ b/rpc/src/rpc/native/block.rs @@ -7,7 +7,7 @@ use ethers::providers::{Http, Provider}; use ethers::types::{H160, H256}; use futures::stream::{self, TryStreamExt}; use tokio::sync::Mutex; -use trace_decoder::trace_protocol::{BlockTrace, TxnInfo}; +use trace_decoder::trace_protocol::{AtomicUnitInfo, BlockTrace, TriePreImage, TxnInfo}; /// Processes the block with the given block number and returns the block trace. pub async fn process_block_trace( @@ -52,12 +52,12 @@ pub async fn process_block_trace( super::state::process_state_witness(Arc::clone(&provider), block, accounts_state).await?; Ok(BlockTrace { - txn_info: tx_infos, + atomic_info: AtomicUnitInfo::Txn(tx_infos), code_db: Some( Arc::try_unwrap(code_db) .map_err(|_| anyhow!("Lock still has multiple owners"))? .into_inner(), ), - trie_pre_images: trie_pre_images, + trie_pre_images: TriePreImage::Mpt(trie_pre_images), }) } diff --git a/rpc/src/rpc/native/state.rs b/rpc/src/rpc/native/state.rs index 8184b028..edbadc56 100644 --- a/rpc/src/rpc/native/state.rs +++ b/rpc/src/rpc/native/state.rs @@ -10,8 +10,8 @@ use futures::TryFutureExt; use mpt_trie::partial_trie::HashedPartialTrie; use tokio::sync::Mutex; use trace_decoder::trace_protocol::{ - BlockTraceTriePreImages, SeparateStorageTriesPreImage, SeparateTriePreImage, - SeparateTriePreImages, TrieDirect, + MptBlockTraceTriePreImages, MptSeparateStorageTriesPreImage, MptSeparateTriePreImage, + MptSeparateTriePreImages, MptTrieDirect, }; use trace_decoder::types::HashedStorageAddr; @@ -22,7 +22,7 @@ pub(super) async fn process_state_witness( provider: Arc>, block: Block, accounts_state: Arc>>>, -) -> Result { +) -> Result { let accounts_state = Arc::try_unwrap(accounts_state) .map_err(|e| anyhow!("Failed to unwrap accounts state from arc: {e:?}"))? .into_inner(); @@ -45,15 +45,17 @@ pub(super) async fn process_state_witness( ) .await?; - Ok(BlockTraceTriePreImages::Separate(SeparateTriePreImages { - state: SeparateTriePreImage::Direct(TrieDirect(state.build())), - storage: SeparateStorageTriesPreImage::MultipleTries( - storage_proofs - .into_iter() - .map(|(a, m)| (a, SeparateTriePreImage::Direct(TrieDirect(m.build())))) - .collect(), - ), - })) + Ok(MptBlockTraceTriePreImages::Separate( + MptSeparateTriePreImages { + state: MptSeparateTriePreImage::Direct(MptTrieDirect(state.build())), + storage: MptSeparateStorageTriesPreImage::MultipleTries( + storage_proofs + .into_iter() + .map(|(a, m)| (a, MptSeparateTriePreImage::Direct(MptTrieDirect(m.build())))) + .collect(), + ), + }, + )) } /// Generates the state witness for the given block.