diff --git a/Cargo.lock b/Cargo.lock index 99cebdb..97994a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,9 +128,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.18" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fd095a9d70f4b1c5c102c84a4c782867a5c6416dbf6dcd42a63e7c7a89d3c8" +checksum = "1752d7d62e2665da650a36d84abbf239f812534475d51f072a49a533513b7cdd" dependencies = [ "alloy-rlp", "arbitrary", @@ -236,7 +236,7 @@ checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -293,7 +293,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "syn-solidity", "tiny-keccak", ] @@ -419,7 +419,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -614,7 +614,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -625,7 +625,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -668,7 +668,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -797,7 +797,7 @@ version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cexpr", "clang-sys", "itertools 0.12.1", @@ -808,7 +808,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -840,9 +840,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" dependencies = [ "arbitrary", "serde", @@ -850,9 +850,9 @@ dependencies = [ [[package]] name = "bitm" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b9ea263f0faf826a1c9de0e8bf8f32f5986c05f5e3abcf6bcde74616009586" +checksum = "b06e8e5bec3490b9f6f3adbb78aa4f53e8396fd9994e8a62a346b44ea7c15f35" dependencies = [ "dyn_size_of", ] @@ -915,7 +915,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73498e9b2f0aa7db74977afa4d594657611e90587abf0dd564c0b55b4a130163" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "boa_interner", "boa_macros", "indexmap 2.2.6", @@ -929,7 +929,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16377479d5d6d33896e7acdd1cc698d04a8f72004025bbbddf47558cd29146a6" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "boa_ast", "boa_gc", "boa_icu_provider", @@ -1012,7 +1012,7 @@ checksum = "005fa0c5bd20805466dda55eb34cd709bb31a2592bb26927b47714eeed6914d8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "synstructure", ] @@ -1022,7 +1022,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e09afb035377a9044443b598187a7d34cd13164617182a4d7c348522ee3f052" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "boa_ast", "boa_icu_provider", "boa_interner", @@ -1092,9 +1092,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -1279,7 +1279,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1610,16 +1610,15 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.2" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "platforms", "rustc_version 0.4.0", "subtle", "zeroize", @@ -1633,7 +1632,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1681,7 +1680,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1703,7 +1702,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1774,7 +1773,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1804,15 +1803,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.68", ] [[package]] @@ -1925,13 +1924,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -2077,7 +2076,7 @@ dependencies = [ "tokio-stream", "tonic", "tonic-build", - "uuid 1.8.0", + "uuid 1.9.1", ] [[package]] @@ -2176,7 +2175,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -2189,7 +2188,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -2200,7 +2199,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -2379,7 +2378,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.66", + "syn 2.0.68", "toml", "walkdir", ] @@ -2397,7 +2396,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -2423,7 +2422,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.66", + "syn 2.0.68", "tempfile", "thiserror", "tiny-keccak", @@ -2753,7 +2752,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -3108,9 +3107,9 @@ checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" -version = "1.9.2" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3935c160d00ac752e09787e6e6bfc26494c2183cc922f1bc678a60d4733bc2" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -3435,18 +3434,18 @@ dependencies = [ [[package]] name = "include_dir" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" dependencies = [ "include_dir_macros", ] [[package]] name = "include_dir_macros" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" dependencies = [ "proc-macro2", "quote", @@ -3846,11 +3845,11 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin 0.9.8", ] [[package]] @@ -3886,9 +3885,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", "windows-targets 0.52.5", @@ -3917,7 +3916,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -4036,9 +4035,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -4086,7 +4085,7 @@ checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4147,9 +4146,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -4351,7 +4350,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4363,7 +4362,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4570,7 +4569,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.5", ] @@ -4672,7 +4671,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4749,7 +4748,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4787,7 +4786,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4818,12 +4817,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "platforms" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" - [[package]] name = "pollster" version = "0.3.0" @@ -4904,7 +4897,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4966,9 +4959,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -4979,7 +4972,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "731e0d9356b0c25f16f33b5be79b1c57b562f141ebfcdb0ad8ac2c13a24293b4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "chrono", "flate2", "hex", @@ -4994,20 +4987,20 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3554923a69f4ce04c4a754260c338f505ce22642d3830e049a399fc2059a29" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "chrono", "hex", ] [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand 0.8.5", @@ -5272,11 +5265,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -5515,7 +5508,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -5784,7 +5777,7 @@ name = "reth-libmdbx" version = "0.2.0-beta.1" source = "git+https://github.com/0xEigenLabs/reth?rev=8cffebd72#8cffebd728cb1b5a1070e8fefbc0995e33597a8a" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "byteorder", "dashmap", "derive_more", @@ -5828,7 +5821,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -6446,7 +6439,7 @@ dependencies = [ "alloy-rlp", "aquamarine", "auto_impl", - "bitflags 2.5.0", + "bitflags 2.6.0", "fnv", "futures-util", "itertools 0.12.1", @@ -6556,7 +6549,7 @@ checksum = "2a4d7d3e793e907dc0797a9d3b43abfdf5226d133855214db9bd27d4cee33ebd" dependencies = [ "alloy-primitives", "auto_impl", - "bitflags 2.5.0", + "bitflags 2.6.0", "bitvec", "c-kzg", "cfg-if", @@ -6675,7 +6668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64 0.21.7", - "bitflags 2.5.0", + "bitflags 2.6.0", "serde", "serde_derive", ] @@ -6769,7 +6762,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -6997,7 +6990,7 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -7064,9 +7057,9 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] @@ -7079,14 +7072,14 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" dependencies = [ "indexmap 2.2.6", "itoa", @@ -7142,7 +7135,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -7167,7 +7160,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -7434,9 +7427,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] @@ -7451,7 +7444,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -7469,9 +7462,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sucds" @@ -7516,9 +7509,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -7534,7 +7527,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -7551,7 +7544,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -7636,7 +7629,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -7713,9 +7706,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" dependencies = [ "tinyvec_macros", ] @@ -7763,7 +7756,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -7948,7 +7941,7 @@ checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ "async-compression", "base64 0.21.7", - "bitflags 2.5.0", + "bitflags 2.6.0", "bytes", "futures-core", "futures-util", @@ -7967,7 +7960,7 @@ dependencies = [ "tower-layer", "tower-service", "tracing", - "uuid 1.8.0", + "uuid 1.9.1", ] [[package]] @@ -8014,7 +8007,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -8318,9 +8311,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", @@ -8363,9 +8356,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "getrandom 0.2.15", "rand 0.8.5", @@ -8374,13 +8367,13 @@ dependencies = [ [[package]] name = "uuid-macro-internal" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9881bea7cbe687e36c9ab3b778c36cd0487402e270304e8b1296d5085303c1a2" +checksum = "a3ff64d5cde1e2cb5268bdb497235b6bd255ba8244f910dbc3574e59593de68c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -8470,7 +8463,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "wasm-bindgen-shared", ] @@ -8504,7 +8497,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8865,7 +8858,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "synstructure", ] @@ -8886,7 +8879,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -8906,7 +8899,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "synstructure", ] @@ -8927,14 +8920,14 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] name = "zerovec" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "591691014119b87047ead4dcf3e6adfbf73cb7c38ab6980d4f18a32138f35d46" +checksum = "432bfb1b38809863a16add25daeff2cc63c8e6bbc1cb05b178237e35ab457885" dependencies = [ "serde", "yoke", @@ -8944,13 +8937,13 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4a1638a1934450809c2266a70362bfc96cd90550c073f5b8a55014d1010157" +checksum = "fa94b6a91d81a9d96473412885b87d8fb677accc447cae54571f93313aebf109" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -9012,9 +9005,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +version = "2.0.11+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" dependencies = [ "cc", "pkg-config", diff --git a/proto/prover/v1/prover.proto b/proto/prover/v1/prover.proto index c5ceeed..a6e8cdc 100644 --- a/proto/prover/v1/prover.proto +++ b/proto/prover/v1/prover.proto @@ -39,21 +39,64 @@ message ProverResponse // batch proof message GenBatchProofRequest { + oneof step + { + GenBatchChunks gen_batch_chunks = 1; + GenChunkProof gen_chunk_proof = 2; + } +} + +message GenBatchChunks { string batch_id = 1; Batch batch = 2; uint64 chain_id = 3; string program_name = 4; } +message GenChunkProof { + // batch_id is used for caching and querying pre_state and post_state + string batch_id = 1; + // convert batch number to string, and pad the left side with zeros to reach 10 characters + string task_id = 2; + // the number of chunks generated by the batch + uint64 chunk_count = 3; + uint64 chain_id = 4; + string program_name = 5; + string batch_data = 6; +} + message Batch { repeated uint64 block_number = 1; } message GenBatchProofResponse { + oneof step + { + GenBatchChunksResult gen_batch_chunks = 1; + GenChunkProofResult gen_chunk_proof = 2; + } +} + +message GenBatchChunksResult { string batch_id = 1; - ProofResultCode result_code = 2; - BatchProofResult batch_proof_result = 3; - string error_message = 4; + // convert batch number to string, and pad the left side with zeros to reach 10 characters + string task_id = 2; + ProofResultCode result_code = 3; + uint64 chunk_count = 4; + // L2 batch data, generated by executor + string batch_data = 5; + bytes pre_state_root = 6; + bytes post_state_root = 7; + string error_message = 8; +} + +message GenChunkProofResult { + string batch_id = 1; + // convert batch number to string, and pad the left side with zeros to reach 10 characters + string task_id = 2; + ProofResultCode result_code = 3; + BatchProofResult batch_proof_result = 4; + string error_message = 5; } message BatchProofResult { @@ -102,8 +145,6 @@ message GenFinalProofResponse { message FinalProof { string proof = 1; string public_input = 2; - bytes pre_state_root = 3; - bytes post_state_root = 4; } // proof result diff --git a/src/db/mod.rs b/src/db/mod.rs index d1ad389..9214c83 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -36,6 +36,7 @@ pub(crate) mod keys { pub const KEY_LAST_SUBMITTED_BLOCK_NUMBER: &[u8] = b"LAST_SUBMITTED_BLOCK_NUMBER"; pub const KEY_LAST_PROVEN_BLOCK_NUMBER: &[u8] = b"LAST_PROVEN_BLOCK_NUMBER"; pub const KEY_LAST_VERIFIED_BLOCK_NUMBER: &[u8] = b"LAST_VERIFIED_BLOCK_NUMBER"; + pub const KEY_PROVE_STEP_RECORD: &[u8] = b"PROVE_STEP_RECORD"; } pub(crate) mod prefix { diff --git a/src/operator.rs b/src/operator.rs index af5d61a..9bb76cd 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -29,7 +29,8 @@ impl Operator { ) -> Result<()> { // initialize all components of the eigen-zeth full node // initialize the prover - let prover = ProverChannel::new(prover_addr, aggregator_addr); + let arc_db_for_prover = rollup_db.clone(); + let prover = ProverChannel::new(prover_addr, aggregator_addr, arc_db_for_prover); // initialize the settlement layer let settlement_provider = init_settlement_provider(settlement_spec) diff --git a/src/prover/provider.rs b/src/prover/provider.rs index 27b2862..32af6ad 100644 --- a/src/prover/provider.rs +++ b/src/prover/provider.rs @@ -6,28 +6,35 @@ //! 3) If the task is finished, update the status into proof database, hence the extended RPC module will fetch this and return it to SDK. use crate::config::env::GLOBAL_ENV; -use crate::db::ProofResult; +use crate::db::keys::KEY_PROVE_STEP_RECORD; +use crate::db::{Database, ProofResult}; +use crate::prover::provider::prover_service::gen_batch_proof_response; use crate::prover::provider::prover_service::prover_request::RequestType; use crate::prover::provider::prover_service::prover_response::ResponseType; use crate::prover::provider::prover_service::prover_service_client::ProverServiceClient; +use crate::prover::provider::prover_service::{gen_batch_proof_request, GenChunkProof}; use crate::prover::provider::prover_service::{ - Batch, GenAggregatedProofRequest, GenBatchProofRequest, GenFinalProofRequest, ProofResultCode, - ProverRequest, + Batch, GenAggregatedProofRequest, GenBatchChunks, GenBatchProofRequest, GenFinalProofRequest, + ProofResultCode, ProverRequest, }; use anyhow::{anyhow, bail, Result}; +use serde::{Deserialize, Serialize}; use std::fmt; +use std::sync::Arc; use std::time::Duration; use tokio::sync::mpsc; use tokio::sync::mpsc::{Receiver, Sender}; use tokio::time; use tokio_stream::wrappers::ReceiverStream; +#[allow(unused_imports)] +use tonic::transport::{Channel, Error}; pub mod prover_service { tonic::include_proto!("prover.v1"); // The string specified here must match the proto package name } /// ProverChannel ... -#[derive(Debug)] +// #[derive(Debug)] pub struct ProverChannel { step: ProveStep, /// the current batch to prove @@ -39,7 +46,10 @@ pub struct ProverChannel { request_sender: Sender, /// used to receive response from the endpoint response_receiver: Receiver, + endpoint_restart_signal_receiver: Receiver<()>, + // + // request_sender2: tokio::sync::broadcast::Sender, /// final proof // final_proof_sender: Sender>, @@ -47,50 +57,113 @@ pub struct ProverChannel { stop_endpoint_tx: Sender<()>, /// the address of the aggregator aggregator_addr: String, + // TODO: Record state data in ProveStep to allow zeth to continue the current batch upon restart + #[allow(dead_code)] + db: Arc>, } type BlockNumber = u64; type StartChunk = String; type EndChunk = String; type RecursiveProof = String; +type ChunkCount = u64; +type L2BatchData = String; + +type TaskId = String; type ErrMsg = String; type BatchId = String; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +struct BatchStateRoot { + pre_state_root: [u8; 32], + post_state_root: [u8; 32], +} + +#[derive(Debug, Clone, Serialize, Deserialize)] pub enum ExecuteResult { Success(ProofResult), + // TODO: Fixme + #[allow(dead_code)] Failed(ErrMsg), } +#[derive(Debug, Clone, Serialize, Deserialize)] +struct ProverStepRecord { + // refactor to Batch + block_number: Option, + step: Option, +} + /// ProveStep ... -#[derive(Debug)] +#[derive(Debug, Clone, Serialize, Deserialize)] enum ProveStep { Start, // TODO: refactor to Batch - Batch(BatchId, BlockNumber), - Aggregate(BatchId, StartChunk, EndChunk), - Final(BatchId, RecursiveProof), + Batch(BatchStep), + Aggregate(AggregateStep), + Final(FinalStep), End(ExecuteResult), } +#[derive(Debug, Clone, Serialize, Deserialize)] +enum BatchStep { + // TODO: refactor to Batch + GenChunk(BatchId, BlockNumber), + GenProof(BatchId, TaskId, ChunkCount, L2BatchData, BatchStateRoot), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +enum AggregateStep { + Aggregate(BatchId, StartChunk, EndChunk, BatchStateRoot), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +enum FinalStep { + Final(BatchId, RecursiveProof, BatchStateRoot), +} + impl fmt::Display for ProveStep { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { ProveStep::Start => write!(f, "♥ Start"), - ProveStep::Batch(_batch_id, no) => write!(f, "♦ Batch: {}", no), - ProveStep::Aggregate(_batch_id, s, e) => write!(f, "♠ Agg: {} -> {}", s, e), - ProveStep::Final(_batch_id, r) => write!(f, "♣ Final: {:?}", r), + ProveStep::Batch(b) => match b { + BatchStep::GenChunk(_batch_id, no) => { + write!(f, "♦ Batch: GenChunk({})", no) + } + BatchStep::GenProof( + _batch_id, + task_id, + chunk_count, + l2_batch_data, + batch_state_root, + ) => { + write!( + f, + "♦ Batch: GenChunkProof(task_id: {}, ChunkCount: {}, L2BatchData: {}, BatchStateRoot: {:?})", + task_id, chunk_count, l2_batch_data, batch_state_root + ) + } + }, + ProveStep::Aggregate(a) => match a { + AggregateStep::Aggregate(_batch_id, s, e, _batch_state_root) => { + write!(f, "♠ Agg: {} -> {}", s, e) + } + }, + ProveStep::Final(final_step) => match final_step { + FinalStep::Final(_batch_id, r, _batch_state_root) => write!(f, "♣ Final: {:?}", r), + }, ProveStep::End(result) => write!(f, "🌹 End: {:?}", result), } } } impl ProverChannel { - pub fn new(addr: &str, aggregator_addr: &str) -> Self { + pub fn new(addr: &str, aggregator_addr: &str, db: Arc>) -> Self { let (response_sender, response_receiver) = mpsc::channel(10); let (request_sender, request_receiver) = mpsc::channel(10); + let (endpoint_restart_signal_sender, endpoint_restart_signal_receiver) = mpsc::channel(1); let (stop_tx, stop_rx) = mpsc::channel(1); ProverChannel { step: ProveStep::Start, @@ -101,56 +174,36 @@ impl ProverChannel { response_sender, request_receiver, stop_rx, + endpoint_restart_signal_sender, )), request_sender, response_receiver, stop_endpoint_tx: stop_tx, aggregator_addr: aggregator_addr.to_string(), + endpoint_restart_signal_receiver, + db, } } pub async fn start(&mut self) -> Result<()> { log::info!("Prover Endpoint started"); // start the endpoint - // self.endpoint.launch().await; - // take the endpoint, and spawn a new task // the self.endpoint will be None after this - // TODO: handle the error, and relaunch the endpoint let mut endpoint = self.endpoint.take().unwrap(); - // loop { - // tokio::select! { - // r = endpoint.launch() => { - // match r { - // Ok(_) => { - // // stop with the signal - // return Ok(()) - // } - // Err(e) => { - // // stop with the error - // // TODO: relaunch the endpoint - // log::error!("ProverEndpoint error: {:?}", e); - // } - // } - // } - // } - // } tokio::spawn(async move { loop { match endpoint.launch().await { + // Only returns Ok when a stop signal is received Ok(_) => { // stop with the signal return; } Err(e) => { - // stop with the error - // TODO: relaunch the endpoint - log::error!( - "ProverEndpoint stopped with error, try again later, err: {:?}", - e - ); - time::sleep(Duration::from_secs(10)).await; + // stop with the error, relaunch the endpoint + log::error!("ProverEndpoint stopped with error: {:?}", e); + log::info!("restarting ProverEndpoint"); } } } @@ -177,149 +230,307 @@ impl ProverChannel { self.clean_current_batch()?; result.map_err(|e| anyhow!("execute batch:{} failed: {:?}", batch, e)) } + fn record_prove_step(&mut self, step: ProveStep) -> Result<()> { + self.db.put( + KEY_PROVE_STEP_RECORD.to_vec(), + serde_json::to_vec(&ProverStepRecord { + block_number: self.current_batch, + step: Some(step), + })?, + ); + Ok(()) + } async fn entry_step(&mut self) -> Result { + // load the ProverStepRecord + match self.db.get(KEY_PROVE_STEP_RECORD) { + Some(record) => { + let record: Result = serde_json::from_slice(&record); + match record { + Ok(record) => { + if record.block_number.is_some() && record.step.is_some() { + if record.block_number.unwrap() == self.current_batch.unwrap() { + // execute from the record step + self.step = record.step.unwrap(); + log::info!("execute from the record step: {:?}", self.step); + } else { + log::info!("invalid ProverStepRecord, ignore it, execute from the start step"); + } + } else { + log::info!( + "invalid ProverStepRecord, ignore it, execute from the start step" + ); + } + } + Err(_) => { + log::info!( + "parse ProverStepRecord failed, ignore it, execute from the start step" + ); + } + } + } + None => { + log::info!("ProverStepRecord not found, execute from the start step"); + } + }; + loop { self.step = match &self.step { ProveStep::Start => { let batch = self.current_batch.unwrap(); + // TODO: remove the batch_id let batch_id = uuid::Uuid::new_v4().to_string(); - ProveStep::Batch(batch_id, batch) + + let next_step = ProveStep::Batch(BatchStep::GenChunk(batch_id, batch)); + self.record_prove_step(next_step.clone())?; + + next_step } - ProveStep::Batch(batch_id, batch) => { - let request = ProverRequest { - id: uuid::Uuid::new_v4().to_string(), - request_type: Some(RequestType::GenBatchProof(GenBatchProofRequest { - batch_id: batch_id.clone(), - batch: Some(Batch { - block_number: vec![*batch], - }), - chain_id: GLOBAL_ENV.chain_id, - program_name: GLOBAL_ENV.program_name.clone(), - })), - }; - // send request to the endpoint - self.request_sender.send(request).await?; - - // waiting for the response from the endpoint - if let Some(ResponseType::GenBatchProof(gen_batch_proof_response)) = - self.response_receiver.recv().await - { - if gen_batch_proof_response.result_code - == ProofResultCode::CompletedOk as i32 - { - let chunks = gen_batch_proof_response - .batch_proof_result - .unwrap() - .chunk_proofs; - let start_chunk = chunks.first().unwrap().clone().proof; - let end_chunk = chunks.last().unwrap().clone().proof; - ProveStep::Aggregate(batch_id.clone(), start_chunk, end_chunk) - } else { - ProveStep::End(ExecuteResult::Failed(format!( - "gen batch proof failed, err: {}", - gen_batch_proof_response.error_message - ))) + ProveStep::Batch(batch_step) => { + match batch_step { + BatchStep::GenChunk(batch_id, batch) => { + let request = ProverRequest { + id: uuid::Uuid::new_v4().to_string(), + request_type: Some(RequestType::GenBatchProof( + GenBatchProofRequest { + step: Some(gen_batch_proof_request::Step::GenBatchChunks( + GenBatchChunks { + batch_id: batch_id.clone(), + batch: Some(Batch { + block_number: vec![*batch], + }), + chain_id: GLOBAL_ENV.chain_id, + program_name: GLOBAL_ENV.program_name.clone(), + }, + )), + }, + )), + }; + // send request to the endpoint + self.request_sender.send(request).await?; + + tokio::select! { + resp = self.response_receiver.recv() => { + // waiting for the response from the endpoint + if let Some(ResponseType::GenBatchProof(gen_batch_proof_response)) = resp { + if let Some(gen_batch_proof_response::Step::GenBatchChunks(gen_batch_chunks_result)) = gen_batch_proof_response.step { + if gen_batch_chunks_result.result_code == ProofResultCode::CompletedOk as i32 { + + let task_id = gen_batch_chunks_result.task_id; + let chunk_count = gen_batch_chunks_result.chunk_count; + let l2_batch_data = gen_batch_chunks_result.batch_data; + let batch_state_root = BatchStateRoot { + pre_state_root: <[u8; 32]>::try_from(gen_batch_chunks_result.pre_state_root).map_err(|e| anyhow!("parse the pre_state_root failed, {:?}", e))?, + post_state_root: <[u8; 32]>::try_from(gen_batch_chunks_result.post_state_root).map_err(|e| anyhow!("parse the post_state_root failed, {:?}", e))?, + }; + + + let next_step = ProveStep::Batch(BatchStep::GenProof(batch_id.clone(), task_id, chunk_count, l2_batch_data, batch_state_root)); + self.record_prove_step(next_step.clone())?; + next_step + + } else { + log::error!("gen batch chunk failed, err: {}, try again", gen_batch_chunks_result.error_message); + ProveStep::Batch(batch_step.clone()) + } + } else { + log::info!("gen batch chunk failed, err: invalid response, try again"); + ProveStep::Batch(batch_step.clone()) + } + } else { + log::info!("gen batch chunk failed, err: invalid response, try again"); + ProveStep::Batch(batch_step.clone()) + } + } + _ = self.endpoint_restart_signal_receiver.recv() => { + log::error!("gen batch chunk failed, err: endpoint restart, try again later"); + ProveStep::Batch(batch_step.clone()) + } + } + } + BatchStep::GenProof( + batch_id, + task_id, + chunk_count, + l2_batch_data, + batch_state_root, + ) => { + let request = ProverRequest { + id: uuid::Uuid::new_v4().to_string(), + request_type: Some(RequestType::GenBatchProof( + GenBatchProofRequest { + step: Some(gen_batch_proof_request::Step::GenChunkProof( + GenChunkProof { + batch_id: batch_id.clone(), + task_id: task_id.clone(), + chunk_count: *chunk_count, + chain_id: GLOBAL_ENV.chain_id, + program_name: GLOBAL_ENV.program_name.clone(), + batch_data: l2_batch_data.clone(), + }, + )), + }, + )), + }; + + // send request to the endpoint + self.request_sender.send(request).await?; + + tokio::select! { + resp = self.response_receiver.recv() => { + if let Some(ResponseType::GenBatchProof(gen_batch_proof_response)) = resp { + if let Some(gen_batch_proof_response::Step::GenChunkProof(gen_chunk_proof_result)) = gen_batch_proof_response.step { + if gen_chunk_proof_result.result_code == ProofResultCode::CompletedOk as i32 { + let chunks = gen_chunk_proof_result.batch_proof_result.unwrap().chunk_proofs; + + let start_chunk = chunks.first().unwrap().clone().proof; + let end_chunk = chunks.last().unwrap().clone().proof; + let next_step = ProveStep::Aggregate(AggregateStep::Aggregate(batch_id.clone(), start_chunk, end_chunk, batch_state_root.clone())); + self.record_prove_step(next_step.clone())?; + next_step + + } else { + log::error!("gen chunk proof failed, err: {}, try again", gen_chunk_proof_result.error_message); + ProveStep::Batch(batch_step.clone()) + } + } else { + log::error!("gen chunk proof failed, err: invalid response, try again"); + ProveStep::Batch(batch_step.clone()) + } + } else { + log::error!("gen chunk proof failed, err: invalid response, try again"); + ProveStep::Batch(batch_step.clone()) + } + } + _ = self.endpoint_restart_signal_receiver.recv() => { + log::error!("gen chunk proof failed, err: endpoint restart, try again later"); + ProveStep::Batch(batch_step.clone()) + } + } } - } else { - ProveStep::End(ExecuteResult::Failed( - "gen batch proof failed, err: invalid response".to_string(), - )) } } - ProveStep::Aggregate(batch_id, start_chunk, end_chunk) => { - let request = ProverRequest { - id: uuid::Uuid::new_v4().to_string(), - request_type: Some(RequestType::GenAggregatedProof( - GenAggregatedProofRequest { - batch_id: batch_id.clone(), - recursive_proof_1: start_chunk.clone(), - recursive_proof_2: end_chunk.clone(), - }, - )), - }; - // send request to the endpoint - self.request_sender.send(request).await?; - - // waiting for the response from the endpoint - if let Some(ResponseType::GenAggregatedProof(gen_aggregated_proof_response)) = - self.response_receiver.recv().await - { - if gen_aggregated_proof_response.result_code - == ProofResultCode::CompletedOk as i32 - { - let recursive_proof = gen_aggregated_proof_response.result_string; - ProveStep::Final(batch_id.clone(), recursive_proof) - } else { - ProveStep::End(ExecuteResult::Failed(format!( - "gen aggregated proof failed, err: {}", - gen_aggregated_proof_response.error_message - ))) + ProveStep::Aggregate(agg_step) => { + match agg_step { + AggregateStep::Aggregate( + batch_id, + start_chunk, + end_chunk, + batch_state_root, + ) => { + let request = ProverRequest { + id: uuid::Uuid::new_v4().to_string(), + request_type: Some(RequestType::GenAggregatedProof( + GenAggregatedProofRequest { + batch_id: batch_id.clone(), + recursive_proof_1: start_chunk.clone(), + recursive_proof_2: end_chunk.clone(), + }, + )), + }; + // send request to the endpoint + self.request_sender.send(request).await?; + + // waiting for the response from the endpoint + if let Some(ResponseType::GenAggregatedProof( + gen_aggregated_proof_response, + )) = self.response_receiver.recv().await + { + if gen_aggregated_proof_response.result_code + == ProofResultCode::CompletedOk as i32 + { + let recursive_proof = + gen_aggregated_proof_response.result_string; + let next_step = ProveStep::Final(FinalStep::Final( + batch_id.clone(), + recursive_proof, + batch_state_root.clone(), + )); + self.record_prove_step(next_step.clone())?; + next_step + } else { + log::error!( + "gen aggregated proof failed, err: {}, try again", + gen_aggregated_proof_response.error_message + ); + ProveStep::Aggregate(agg_step.clone()) + } + } else { + log::error!( + "gen aggregated proof failed, err: invalid response, try again" + ); + ProveStep::Aggregate(agg_step.clone()) + } } - } else { - ProveStep::End(ExecuteResult::Failed( - "gen aggregated proof failed, err: invalid response".to_string(), - )) } } - ProveStep::Final(batch_id, recursive_proof) => { - let request = ProverRequest { - id: uuid::Uuid::new_v4().to_string(), - request_type: Some(RequestType::GenFinalProof(GenFinalProofRequest { - batch_id: batch_id.clone(), - recursive_proof: recursive_proof.clone(), - curve_name: GLOBAL_ENV.curve_type.clone(), - aggregator_addr: self.aggregator_addr.clone(), - })), - }; - self.request_sender.send(request).await?; - - // waiting for the response from the endpoint - if let Some(ResponseType::GenFinalProof(gen_final_proof_response)) = - self.response_receiver.recv().await - { - if gen_final_proof_response.result_code - == ProofResultCode::CompletedOk as i32 - { - if let Some(final_proof) = gen_final_proof_response.final_proof { - ProveStep::End(ExecuteResult::Success(ProofResult { - block_number: self.current_batch.unwrap(), - proof: final_proof.proof, - public_input: final_proof.public_input, - pre_state_root: <[u8; 32]>::try_from( - final_proof.pre_state_root, - ) - .map_err(|_| anyhow!(""))?, - post_state_root: <[u8; 32]>::try_from( - final_proof.post_state_root, - ) - .map_err(|_| anyhow!(""))?, - })) + ProveStep::Final(final_step) => { + match final_step { + FinalStep::Final(batch_id, recursive_proof, batch_state_root) => { + let request = ProverRequest { + id: uuid::Uuid::new_v4().to_string(), + request_type: Some(RequestType::GenFinalProof( + GenFinalProofRequest { + batch_id: batch_id.clone(), + recursive_proof: recursive_proof.clone(), + curve_name: GLOBAL_ENV.curve_type.clone(), + aggregator_addr: self.aggregator_addr.clone(), + }, + )), + }; + self.request_sender.send(request).await?; + + // waiting for the response from the endpoint + if let Some(ResponseType::GenFinalProof(gen_final_proof_response)) = + self.response_receiver.recv().await + { + if gen_final_proof_response.result_code + == ProofResultCode::CompletedOk as i32 + { + if let Some(final_proof) = gen_final_proof_response.final_proof + { + let next_step = + ProveStep::End(ExecuteResult::Success(ProofResult { + block_number: self.current_batch.unwrap(), + proof: final_proof.proof, + public_input: final_proof.public_input, + pre_state_root: batch_state_root.pre_state_root, + post_state_root: batch_state_root.post_state_root, + })); + self.record_prove_step(next_step.clone())?; + next_step + } else { + log::error!( + "gen final proof failed, err: {}, try again", + gen_final_proof_response.error_message + ); + ProveStep::Final(final_step.clone()) + } + } else { + log::error!( + "gen final proof failed, err: {}, try again", + gen_final_proof_response.error_message + ); + ProveStep::Final(final_step.clone()) + } } else { - ProveStep::End(ExecuteResult::Failed( - "gen final proof failed, invalid response, proof is None" - .to_string(), - )) + log::error!( + "gen final proof failed, err: invalid response, try again" + ); + ProveStep::Final(final_step.clone()) } - } else { - ProveStep::End(ExecuteResult::Failed(format!( - "gen final proof failed: {}", - gen_final_proof_response.error_message - ))) } - } else { - ProveStep::End(ExecuteResult::Failed( - "gen final proof failed, err: invalid response".to_string(), - )) } } ProveStep::End(execute_result) => { let result = (*execute_result).clone(); // reset smt state + // clear the ProveStepRecord + self.db.del(KEY_PROVE_STEP_RECORD.to_vec()); self.step = ProveStep::Start; return match result { @@ -359,7 +570,8 @@ pub struct ProverEndpoint { /// used to send request to the gRPC client // request_sender: Sender, /// used to receive request, and send to ProverServer - request_receiver: Option>, + // request_receiver: Option>, + request_receiver: Receiver, // /// used to stop the endpoint // stop_endpoint_tx: Sender<()>, /// listen to the stop signal, and stop the endpoint loop @@ -367,6 +579,8 @@ pub struct ProverEndpoint { /// used to send response to the ProverChannel response_sender: Sender, + + endpoint_restart_signal_sender: Sender<()>, } impl ProverEndpoint { @@ -375,24 +589,44 @@ impl ProverEndpoint { response_sender: Sender, request_receiver: Receiver, stop_rx: Receiver<()>, + endpoint_restart_signal_sender: Sender<()>, ) -> Self { ProverEndpoint { addr: addr.to_string(), - request_receiver: Some(request_receiver), + request_receiver, stop_endpoint_rx: stop_rx, response_sender, + endpoint_restart_signal_sender, } } /// launch the endpoint pub async fn launch(&mut self) -> Result<()> { - let mut client = ProverServiceClient::connect(self.addr.clone()).await?; + let mut client; + loop { + match ProverServiceClient::connect(self.addr.clone()).await { + Ok(c) => { + client = c; + log::info!("ProverEndpoint connected to {}", self.addr); + break; + } + Err(e) => { + log::error!( + "ProverEndpoint connect to server: {} failed: {:?}, try again later", + self.addr, + e + ); + time::sleep(Duration::from_secs(5)).await; + } + } + } - log::info!("ProverEndpoint connected to {}", self.addr); + let (tx, rx) = mpsc::channel(10); // take the request receiver, create a stream // self.request_receiver will be None after this - let request = ReceiverStream::new(self.request_receiver.take().unwrap()); + // let request = ReceiverStream::new(self.request_receiver.take().unwrap()); + let request = ReceiverStream::new(rx); // waiting for the first request let response = client.prover_stream(request).await?; @@ -404,6 +638,12 @@ impl ProverEndpoint { log::info!("ProverEndpoint stopped"); return Ok(()); } + // TODO: Optimize this + prover_request = self.request_receiver.recv() => { + if let Some(request) = prover_request { + tx.send(request).await?; + } + } recv_msg_result = resp_stream.message() => { match recv_msg_result { Ok(Some(recv_msg)) => { @@ -428,13 +668,36 @@ impl ProverEndpoint { } } } + Ok(None) => { - log::info!("Stream ended"); - tokio::time::sleep(Duration::from_secs(10)).await; // add delay + loop { + match self.request_receiver.try_recv() { + Ok(req) => { + log::info!("drop request: {:?}", req); + }, + Err(_) => { + log::info!("request channel is cleared"); + break; + } + } + } + self.endpoint_restart_signal_sender.send(()).await?; + bail!("ProverEndpoint stopped, server closed the connection"); } Err(e) => { - log::error!("Error receiving message: {}", e); - tokio::time::sleep(Duration::from_secs(10)).await; // add delay + loop { + match self.request_receiver.try_recv() { + Ok(req) => { + log::info!("drop request: {:?}", req); + }, + Err(_) => { + log::info!("request channel is cleared"); + break; + } + } + } + self.endpoint_restart_signal_sender.send(()).await?; + bail!("ProverEndpoint stopped with error: {:?}", e); } } }