From 2d15ce49dab0a6d10a67bd94be45d9aaf3051785 Mon Sep 17 00:00:00 2001 From: dcbuilder Date: Fri, 27 Oct 2023 19:31:25 +0100 Subject: [PATCH 01/10] add docs --- Cargo.lock | 482 ++++++++---------- bin/tree_availability_service.rs | 1 + crates/state_bridge/src/bridge.rs | 20 + crates/state_bridge/src/lib.rs | 25 +- crates/tree_availability/src/error.rs | 1 + crates/tree_availability/src/lib.rs | 155 ++++++ .../src/world_tree/block_scanner.rs | 8 + .../tree_availability/src/world_tree/mod.rs | 3 + .../src/world_tree/tree_data.rs | 23 + .../src/world_tree/tree_updater.rs | 20 +- x.toml | 14 + 11 files changed, 494 insertions(+), 258 deletions(-) create mode 100644 x.toml diff --git a/Cargo.lock b/Cargo.lock index 7d9a07fc..f73a2e95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom", "once_cell", @@ -63,9 +63,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -413,13 +413,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -540,9 +540,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -588,9 +588,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bitvec" @@ -670,9 +670,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.5.0" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" @@ -715,9 +715,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" +checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" dependencies = [ "serde", ] @@ -730,7 +730,7 @@ checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" dependencies = [ "camino", "cargo-platform", - "semver 1.0.20", + "semver 1.0.19", "serde", "serde_json", "thiserror", @@ -790,9 +790,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.7" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", "clap_derive", @@ -800,9 +800,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", @@ -812,21 +812,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "coins-bip32" @@ -866,7 +866,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.5", + "base64 0.21.4", "bech32", "bs58", "digest 0.10.7", @@ -962,9 +962,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.9.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37be52ef5e3b394db27a2341010685ad5103c72ac15ce2e9420a7e8f93f342c" +checksum = "aa72a10d0e914cad6bcad4e7409e68d230c1c2db67896e19a37f758b1fcbdab5" dependencies = [ "cfg-if", "cpufeatures", @@ -1015,9 +1015,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -1199,9 +1199,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "626ae34994d3d8d668f4269922248239db4ae42d538b14c398b74a52208e8086" dependencies = [ "csv-core", "itoa", @@ -1211,9 +1211,9 @@ dependencies = [ [[package]] name = "csv-core" -version = "0.1.11" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" dependencies = [ "memchr", ] @@ -1247,7 +1247,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -1258,7 +1258,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -1279,12 +1279,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" -dependencies = [ - "powerfmt", -] +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" [[package]] name = "derivative" @@ -1405,9 +1402,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ "base16ct", "crypto-bigint", @@ -1446,7 +1443,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" dependencies = [ - "base64 0.21.5", + "base64 0.21.4", "bytes", "hex", "k256", @@ -1492,9 +1489,9 @@ dependencies = [ [[package]] name = "enumset" -version = "1.1.3" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" +checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" dependencies = [ "enumset_derive", ] @@ -1508,7 +1505,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -1519,14 +1516,25 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" dependencies = [ + "errno-dragonfly", "libc", "windows-sys 0.48.0", ] +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "eth-keystore" version = "0.5.0" @@ -1663,7 +1671,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.38", + "syn 2.0.37", "toml 0.7.8", "walkdir", ] @@ -1681,7 +1689,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -1707,7 +1715,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.38", + "syn 2.0.37", "tempfile", "thiserror", "tiny-keccak", @@ -1717,7 +1725,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#17c008e915f22686bfdc769e7140e8c50e6b8a61" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "arrayvec", "bytes", @@ -1748,7 +1756,7 @@ checksum = "0e53451ea4a8128fbce33966da71132cf9e1040dcfd2a2084fd7733ada7b2045" dependencies = [ "ethers-core 2.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest", - "semver 1.0.20", + "semver 1.0.19", "serde", "serde_json", "thiserror", @@ -1790,7 +1798,7 @@ checksum = "6838fa110e57d572336178b7c79e94ff88ef976306852d8cb87d9e5b1fc7c0b5" dependencies = [ "async-trait", "auto_impl", - "base64 0.21.5", + "base64 0.21.4", "bytes", "const-hex", "enr", @@ -1859,7 +1867,7 @@ dependencies = [ "path-slash", "rayon", "regex", - "semver 1.0.20", + "semver 1.0.19", "serde", "serde_json", "solang-parser", @@ -1935,9 +1943,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "miniz_oxide", @@ -1991,9 +1999,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -2006,9 +2014,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -2016,15 +2024,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -2033,9 +2041,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-locks" @@ -2049,26 +2057,26 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-timer" @@ -2082,9 +2090,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -2206,7 +2214,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.6", ] [[package]] @@ -2215,14 +2223,14 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.6", ] [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "hashers" @@ -2335,7 +2343,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -2344,9 +2352,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ "futures-util", "http", @@ -2379,7 +2387,7 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" name = "identity-sequencer" version = "0.1.0" dependencies = [ - "clap 4.4.7", + "clap 4.4.6", "ethers", "eyre", "futures", @@ -2388,7 +2396,7 @@ dependencies = [ "serde", "state_bridge", "tokio", - "toml 0.8.5", + "toml 0.8.6", "tracing", "tree_availability", ] @@ -2465,7 +2473,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.1", ] [[package]] @@ -2488,9 +2496,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" @@ -2529,9 +2537,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] @@ -2551,9 +2559,9 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.5", + "base64 0.21.4", "pem", - "ring 0.16.20", + "ring", "serde", "serde_json", "simple_asn1", @@ -2597,7 +2605,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.7.5", + "regex-syntax", "string_cache", "term", "tiny-keccak", @@ -2624,9 +2632,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libloading" @@ -2640,21 +2648,21 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -2782,7 +2790,7 @@ checksum = "ddece26afd34c31585c74a4db0630c376df271c285d682d1e55012197830b6df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -2802,9 +2810,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi", @@ -2941,9 +2949,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", "libm", @@ -2977,7 +2985,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -3050,7 +3058,7 @@ version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.0", "cfg-if", "foreign-types", "libc", @@ -3067,7 +3075,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -3144,13 +3152,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall 0.3.5", "smallvec", "windows-targets 0.48.5", ] @@ -3217,9 +3225,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.5" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" dependencies = [ "memchr", "thiserror", @@ -3276,7 +3284,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -3314,7 +3322,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -3379,12 +3387,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023" -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -3404,14 +3406,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] name = "primitive-types" -version = "0.12.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", "impl-codec", @@ -3457,9 +3459,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -3470,13 +3472,13 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.0", "lazy_static", "num-traits", "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.7.5", + "regex-syntax", "unarray", ] @@ -3585,9 +3587,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags 1.3.2", ] @@ -3616,25 +3618,25 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.8.2", + "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax", ] [[package]] @@ -3643,12 +3645,6 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "region" version = "3.0.0" @@ -3676,7 +3672,7 @@ version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.5", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -3732,26 +3728,12 @@ dependencies = [ "cc", "libc", "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", + "spin", + "untrusted", "web-sys", "winapi", ] -[[package]] -name = "ring" -version = "0.17.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" -dependencies = [ - "cc", - "getrandom", - "libc", - "spin 0.9.8", - "untrusted 0.9.0", - "windows-sys 0.48.0", -] - [[package]] name = "ripemd" version = "0.1.3" @@ -3775,7 +3757,7 @@ dependencies = [ "rkyv_derive", "seahash", "tinyvec", - "uuid 1.5.0", + "uuid 1.4.1", ] [[package]] @@ -3873,16 +3855,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.20", + "semver 1.0.19", ] [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.0", "errno", "libc", "linux-raw-sys", @@ -3891,12 +3873,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.8" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", - "ring 0.17.5", + "ring", "rustls-webpki", "sct", ] @@ -3907,17 +3889,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.5", + "base64 0.21.4", ] [[package]] name = "rustls-webpki" -version = "0.101.7" +version = "0.101.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -3952,9 +3934,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.10.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" dependencies = [ "cfg-if", "derive_more", @@ -3964,9 +3946,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.10.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -4003,12 +3985,12 @@ dependencies = [ [[package]] name = "sct" -version = "0.7.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -4057,7 +4039,7 @@ dependencies = [ [[package]] name = "semaphore" version = "0.1.0" -source = "git+https://github.com/worldcoin/semaphore-rs?branch=main#62a3b3b47217fcf6edf38e6a0ddc6d161366fd6f" +source = "git+https://github.com/worldcoin/semaphore-rs?branch=main#404c2a59b41e60b83a83e7546bd9b3cda7e9a2a7" dependencies = [ "ark-bn254", "ark-circom", @@ -4092,18 +4074,18 @@ dependencies = [ [[package]] name = "semaphore-depth-config" version = "0.1.0" -source = "git+https://github.com/worldcoin/semaphore-rs?branch=main#62a3b3b47217fcf6edf38e6a0ddc6d161366fd6f" +source = "git+https://github.com/worldcoin/semaphore-rs?branch=main#404c2a59b41e60b83a83e7546bd9b3cda7e9a2a7" [[package]] name = "semaphore-depth-macros" version = "0.1.0" -source = "git+https://github.com/worldcoin/semaphore-rs?branch=main#62a3b3b47217fcf6edf38e6a0ddc6d161366fd6f" +source = "git+https://github.com/worldcoin/semaphore-rs?branch=main#404c2a59b41e60b83a83e7546bd9b3cda7e9a2a7" dependencies = [ "itertools 0.10.5", "proc-macro2", "quote", "semaphore-depth-config", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -4117,9 +4099,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" dependencies = [ "serde", ] @@ -4151,9 +4133,9 @@ version = "0.1.0" [[package]] name = "serde" -version = "1.0.190" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] @@ -4179,13 +4161,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -4264,9 +4246,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b" dependencies = [ "lazy_static", ] @@ -4340,9 +4322,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.10" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -4350,9 +4332,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -4378,12 +4360,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "spki" version = "0.7.2" @@ -4455,15 +4431,15 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.25.3" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -4483,7 +4459,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver 1.0.20", + "semver 1.0.19", "serde", "serde_json", "sha2", @@ -4505,9 +4481,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -4569,19 +4545,19 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.12" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "tempfile" -version = "3.8.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", + "redox_syscall 0.3.5", "rustix", "windows-sys 0.48.0", ] @@ -4608,22 +4584,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -4638,13 +4614,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" dependencies = [ "deranged", "itoa", - "powerfmt", "serde", "time-core", "time-macros", @@ -4713,7 +4688,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2 0.5.4", "tokio-macros", "windows-sys 0.48.0", ] @@ -4726,7 +4701,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -4768,9 +4743,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" dependencies = [ "bytes", "futures-core", @@ -4794,14 +4769,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3efaf127c78d5339cc547cce4e4d973bd5e4f56e949a06d091c082ebeef2f800" +checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.5", + "toml_edit 0.20.7", ] [[package]] @@ -4828,9 +4803,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.5" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782bf6c2ddf761c1e7855405e8975472acf76f7f36d0d4328bd3b7a2fae12a85" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ "indexmap 2.0.2", "serde", @@ -4887,7 +4862,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -5069,12 +5044,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - [[package]] name = "url" version = "2.4.1" @@ -5110,9 +5079,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.5.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" [[package]] name = "valuable" @@ -5178,7 +5147,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", "wasm-bindgen-shared", ] @@ -5212,7 +5181,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5225,9 +5194,9 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-encoder" -version = "0.35.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca90ba1b5b0a70d3d49473c5579951f3bddc78d47b59256d2f9d4922b150aca" +checksum = "34180c89672b3e4825c3a8db4b61a674f1447afd5fe2445b2d22c3d8b6ea086c" dependencies = [ "leb128", ] @@ -5471,9 +5440,9 @@ checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "wast" -version = "66.0.2" +version = "65.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93cb43b0ac6dd156f2c375735ccfd72b012a7c0a6e6d09503499b8d3cb6e6072" +checksum = "a55a88724cf8c2c0ebbf32c8e8f4ac0d6aa7ba6d73a1cfd94b254aa8f894317e" dependencies = [ "leb128", "memchr", @@ -5483,9 +5452,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.77" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e367582095d2903caeeea9acbb140e1db9c7677001efa4347c3687fd34fe7072" +checksum = "d83e1a8d86d008adc7bafa5cf4332d448699a08fcf2a715a71fbb75e2c5ca188" dependencies = [ "wast", ] @@ -5732,9 +5701,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] @@ -5800,7 +5769,7 @@ checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -5820,7 +5789,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.37", ] [[package]] @@ -5864,10 +5833,11 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.9+zstd.1.5.5" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", + "libc", "pkg-config", ] diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index c1ab4316..e3bae608 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -7,6 +7,7 @@ use futures::stream::FuturesUnordered; use futures::StreamExt; use tree_availability::TreeAvailabilityService; +/// CLI interface for the Tree Availability Service #[derive(Parser, Debug)] #[clap(name = "Tree Availability Service", about = "")] struct Opts { diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index 9e63fcf6..0fcbf2d8 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -29,14 +29,25 @@ abigen!( event_derives(serde::Deserialize, serde::Serialize) ); +/// The `StateBridge` takes care of listening to roots propagated from the `WorldRoot` and +/// propagates them periodically every time `relaying_period` elapses and the root was updated. pub struct StateBridge { + /// Interface for the `StateBridge` contract pub state_bridge: IStateBridge, + /// Interface for the `BridgedWorldID` contract pub bridged_world_id: IBridgedWorldID, + /// Time in between `propagateRoot()` calls pub relaying_period: Duration, + /// The number of blocks before a `propagateRoot()` call is considered finalized pub block_confirmations: usize, } impl StateBridge { + /// Constructor + /// `state_bridge`: `StateBridge` contract interface + /// `bridged_world_id`: `BridgedWorldID` contract interface + /// `relaying_period`: Time in between `propagateRoot()` calls + /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized pub fn new( state_bridge: IStateBridge, bridged_world_id: IBridgedWorldID, @@ -51,6 +62,13 @@ impl StateBridge { }) } + /// Constructor with address and middleware + /// `bridge_address`: `StateBridge` contract address + /// `canonical_middleware`: middleware for the chain where the `StateBridge` is deployed + /// `bridged_world_id_address`: `BridgedWorldID` contract address + /// `derived_middleware`: middleware for the chain where the `BridgedWorldID` is deployed + /// `relaying_period`: Time in between `propagateRoot()` calls + /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized pub fn new_from_parts( bridge_address: H160, canonical_middleware: Arc, @@ -75,6 +93,8 @@ impl StateBridge { }) } + /// Spawns the `StateBridge` which listens to the `WorldRoot` `TreeChanged` events for new roots to propagate + /// `root_rx`: The root receiver that listens to the `WorldRoot` root sender pub async fn spawn( &self, mut root_rx: tokio::sync::broadcast::Receiver, diff --git a/crates/state_bridge/src/lib.rs b/crates/state_bridge/src/lib.rs index c4ba4d50..c712e4f4 100644 --- a/crates/state_bridge/src/lib.rs +++ b/crates/state_bridge/src/lib.rs @@ -8,7 +8,30 @@ //! //! #### CLI //! -//! TODO: specify how to run the state bridge service as a command-line utility +//! Create a state_bridge_service.toml file which will hold the configuration parameters for the state bridge +//! service. You can use the example in the test as a template: +//! +//! ```toml +//! rpc_url = "127.0.0.1:8545" +//! private_key = "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318" +//! world_id_address = "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9" +//! bridge_configs = [ +//! [ +//! "Optimism", +//! # StateBridge Address +//! "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9", +//! # BridgedWorldID Address +//! "0x4f0BF744bb79A0b919f7DED73724ec20c43572B9", +//! "127.0.0.1:8545", +//! ] +//! ] +//! relaying_period_seconds = 5 +//! ``` +//! +//! ```bash +//! cargo build --bin state-bridge-service --release +//! ./target/release/state-bridge-service --config +//! ``` //! //! #### Library //! In order to launch a `StateBridgeService` as a library you can use the following example from the [`bridge_service.rs`](https://github.com/worldcoin/identity-sequencer/blob/359f0fe3ec62b18d6f569d8ad31967c048401fa1/crates/state_bridge/tests/bridge_service.rs#L37) test file as a guide. diff --git a/crates/tree_availability/src/error.rs b/crates/tree_availability/src/error.rs index 4a653f7b..8f38917d 100644 --- a/crates/tree_availability/src/error.rs +++ b/crates/tree_availability/src/error.rs @@ -4,6 +4,7 @@ use ethers::types::Log; use thiserror::Error; use tokio::sync::mpsc::error::SendError; +/// Wraps dependency errors and converts them to `TreeAvailabilityError`s #[derive(Error, Debug)] pub enum TreeAvailabilityError where diff --git a/crates/tree_availability/src/lib.rs b/crates/tree_availability/src/lib.rs index 7bcc49d6..3713ecda 100644 --- a/crates/tree_availability/src/lib.rs +++ b/crates/tree_availability/src/lib.rs @@ -1,3 +1,147 @@ +//! # Tree Availability Service +//! +//! The tree availability service is able to create an in-memory representation of the World ID +//! merkle tree by syncing the state of the World ID contract `registerIdentities` and `deleteIdentities` +//! function calldata and `TreeChanged` events. Once it syncs the latest state of the state of the tree, it +//! is able to serve inclusion proofs on the `/inclusionProof` endpoint. It also keeps a historical roots list +//! of `tree_history_size` size in order to serve proofs against older tree roots (including the roots of +//! World IDs bridged to other networks). +//! +//! ### Usage +//! +//! #### CLI +//! +//! In order to run the tree availability service you can run the following commands +//! +//! ```bash +//! # Build the binary +//! cargo build --bin tree-availability-service --release +//! # Run the command +//! ./target/release/tree-availability-service \ +//! --tree-depth \ +//! --tree-history-size \ +//! --dense-prefix-depth \ +//! --address
\ +//! --creation-block \ +//! --rpc-endpoint \ +//! ``` +//! +//! #### Library +//! +//! A good example of how to use the `StateBridgeService` struct in a library is demonstrated in the [`inclusion_proof.rs`](https://github.com/worldcoin/identity-sequencer/blob/main/crates/tree_availability/tests/inclusion_proof.rs) test file. +//! +//! ``` +//! use std::str::FromStr; +//! +//! use common::test_utilities::chain_mock::{spawn_mock_chain, MockChain}; +//! use ethers::providers::Middleware; +//! use ethers::types::U256; +//! use futures::stream::FuturesUnordered; +//! use futures::StreamExt; +//! use hyper::StatusCode; +//! use tree_availability::error::TreeAvailabilityError; +//! use tree_availability::server::{InclusionProof, InclusionProofRequest}; +//! use tree_availability::world_tree::tree_updater::pack_indices; +//! use tree_availability::world_tree::Hash; +//! use tree_availability::TreeAvailabilityService; +//! #[tokio::test] +//! async fn test_inclusion_proof() -> eyre::Result<()> { +//! // Initialize a new mock tree +//! let MockChain { +//! anvil: _anvil, +//! middleware, +//! mock_world_id, +//! .. +//! } = spawn_mock_chain().await?; +//! +//! // Register identities +//! let identity_commitments = +//! vec![U256::from(1), U256::from(2), U256::from(3)]; +//! +//! let world_tree_creation_block = +//! middleware.get_block_number().await?.as_u64() - 1; +//! +//! mock_world_id +//! .register_identities( +//! [U256::zero(); 8], +//! U256::zero(), +//! 0, +//! identity_commitments, +//! U256::zero(), +//! ) +//! .send() +//! .await? +//! .await?; +//! +//! // Delete an identity +//! mock_world_id +//! .delete_identities( +//! [U256::zero(); 8], +//! pack_indices(&[1]).into(), +//! U256::zero(), +//! U256::zero(), +//! ) +//! .send() +//! .await? +//! .await?; +//! +//! // Initialize the tree availability service +//! let world_tree_address = mock_world_id.address(); +//! let tree_availability_service = TreeAvailabilityService::new( +//! 3, +//! 1, +//! 5, +//! world_tree_address, +//! world_tree_creation_block, +//! middleware, +//! ); +//! +//! let world_tree = tree_availability_service.world_tree.clone(); +//! +//! // Spawn the service in a separate task +//! let server_handle = tokio::spawn(async move { +//! let handles = tree_availability_service.serve(8080).await; +//! +//! let mut handles = handles.into_iter().collect::>(); +//! while let Some(result) = handles.next().await { +//! result.expect("TODO: propagate this error")?; +//! } +//! +//! Ok::<(), TreeAvailabilityError<_>>(()) +//! }); +//! +//! // Wait for the tree to be synced +//! loop { +//! if world_tree +//! .tree_updater +//! .synced +//! .load(std::sync::atomic::Ordering::Relaxed) +//! { +//! break; +//! } +//! +//! tokio::time::sleep(std::time::Duration::from_secs(1)).await; +//! } +//! +//! // Send a request to get an inclusion proof +//! let client = reqwest::Client::new(); +//! let response = client +//! .post("http://127.0.0.1:8080/inclusionProof") +//! .json(&InclusionProofRequest { +//! identity_commitment: Hash::from(0x01), +//! root: None, +//! }) +//! .send() +//! .await?; +//! +//! assert_eq!(response.status(), StatusCode::OK); +//! +//! // Return an inclusion proof +//! let proof: Option = response.json().await?; +//! assert!(proof.is_some()); +//! } +//! ``` + pub mod error; pub mod server; pub mod world_tree; @@ -14,11 +158,20 @@ use world_tree::{Hash, PoseidonTree, WorldTree}; use crate::server::{inclusion_proof, synced}; +/// The tree availability service data structure pub struct TreeAvailabilityService { + /// The World ID merkle tree synced from the `WorldIDIdentityManager` contract pub world_tree: Arc>, } impl TreeAvailabilityService { + /// Constructor + /// `tree_depth`: the depth of the World ID contract (currently 30 in production - Nov 2023) + /// `dense_prefix_depth`: what is the depth of the tree that is densely populated (currently depth 10) + /// `tree_history_size`: how many historical roots and derived trees to hold in memory to serve proofs for + /// `world_tree_address`: `WorldIDIdentityManager` contract address + /// `world_tree_creation_block`: block at which `WorldIDIdentityManager` contract was deployed + /// `middleware`: Ethereum provider pub fn new( tree_depth: usize, dense_prefix_depth: usize, @@ -44,6 +197,8 @@ impl TreeAvailabilityService { Self { world_tree } } + /// Spins up the /inclusionProof endpoint to serve proofs of inclusion for the World ID tree + /// `port`: which port on the machine will serve HTTP requests pub async fn serve( self, port: u16, diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index 47ba2172..bd28287f 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -5,9 +5,13 @@ use ethers::types::{ Address, BlockNumber, Filter, FilterBlockOption, Log, Topic, ValueOrArray, }; +/// The `BlockScanner` utility tool enables allows parsing arbitrary onchain events pub struct BlockScanner { + /// The onchain data provider middleware: M, + /// The block from which to start parsing a given event current_block: AtomicU64, + /// TODO: doc window_size: u64, } @@ -15,6 +19,7 @@ impl BlockScanner where M: Middleware, { + /// Constructor pub const fn new( middleware: M, window_size: u64, @@ -27,6 +32,9 @@ where } } + /// Returns a list of specified events that were emitted by a given smart contract address + /// `address`: Address of the contract that we want to listen to events in + /// `topics`: The topics of the events the `BlockScanner` will listen to and parse pub async fn next( &self, address: Option>, diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index ead736f3..7ff23dd0 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -26,11 +26,14 @@ pub type Hash = ::Hash; /// In our data model the `tree` is the oldest available tree. /// The entires in `tree_history` represent new additions to the tree. pub struct WorldTree { + /// All the leaves of the tree and their corresponding root hash pub tree_data: Arc, + /// The object in charge of syncing the tree from calldata pub tree_updater: Arc>, } impl WorldTree { + /// Constructor pub fn new( tree: PoseidonTree, tree_history_size: usize, diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index f4542510..664f1faa 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -7,17 +7,28 @@ use tokio::sync::RwLock; use super::{Hash, PoseidonTree}; use crate::server::InclusionProof; +/// The `TreeData` structure represents the in-memory representation of the tree as well as its historic +/// versions up to `tree_history_size` pub struct TreeData { + /// Tree holding all leaves pub tree: RwLock>, + /// Number of most recent historical roots `WorldTree` keeps to be able to serve proofs for pub tree_history_size: usize, + /// Array of derived trees for each historical root pub tree_history: RwLock>>, //TODO: make a note that the latest is at the front } +/// Defines how the tree changed pub struct TreeUpdate { + /// TODO: docs pub index: usize, + /// New hash of the tree pub value: Hash, } impl TreeData { + /// Constructor + /// `tree`: Canonical in-memory tree + /// `tree_history_size`: Number of most recent historical roots that the `WorldTree` can serve proofs for pub fn new( tree: PoseidonTree, tree_history_size: usize, @@ -29,6 +40,9 @@ impl TreeData { } } + /// Inserts identities at a given starting index + /// `start_index`: Index at which to start inserting identity commitments + /// `identities`: Identity commitments pub async fn insert_many_at( &self, start_index: usize, @@ -42,6 +56,8 @@ impl TreeData { } } + /// Deletes identity commitments in the `WorldTree` at the specified indices + /// `delete_indices`: positions of the identity commitments in the tree to be deleted pub async fn delete_many(&self, delete_indices: &[usize]) { self.cache_tree_history().await; @@ -52,6 +68,8 @@ impl TreeData { } } + /// Caches the historical tree representations in memory in order for the `WorldTree` to be able to serve + /// proofs against their roots pub async fn cache_tree_history(&self) { if self.tree_history_size != 0 { let mut tree_history = self.tree_history.write().await; @@ -66,6 +84,8 @@ impl TreeData { /// Fetches the inclusion proof of the provided identity at the given root hash /// + /// `identity`: Identity commitment to fetch the inclusion proof for + /// `root`: The root against which the `WorldTree` will serve the inclusion proof against /// Returns None if the provided root hash is not in the latest one or is not present in tree history /// or if the identity is not present in the tree pub async fn get_inclusion_proof( @@ -110,6 +130,9 @@ impl TreeData { } } + /// Returns an inclusion proof for a given identity commitment in the specified tree + /// `tree`: The `WorldTree` (canonical or derived) to fetch the inclusion proof against + /// `identity`: Identity commitment to create the inclusion proof for fn proof( tree: &PoseidonTree, identity: Hash, diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index 3b3cfdad..6a7d99cf 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -19,15 +19,25 @@ use crate::world_tree::Hash; // TODO: Change to a configurable parameter const SCANNING_WINDOW_SIZE: u64 = 100; +/// The `TreeUpdater` holds the necessary data to be able to sync the World ID tree +/// from Ethereum calldata and events emitted by the `WorldIDIdentityManager` contracts pub struct TreeUpdater { + /// `address`: `WorldIDIdentityManager` contract address pub address: H160, pub latest_synced_block: AtomicU64, + /// `synced`: has the updater finished syncing up to the latest canonical onchain tree pub synced: AtomicBool, + /// `block_scanner`: utility tool to parse calldata and events block_scanner: BlockScanner>, + /// `middleware`: provider pub middleware: Arc, } impl TreeUpdater { + /// Constructor + /// `address`: `WorldIDIdentityManager` contract address + /// `creation_block`: The block height of the `WorldIDIdentityManager` contract deployment + /// `middleware`: provider pub fn new(address: H160, creation_block: u64, middleware: Arc) -> Self { Self { address, @@ -42,7 +52,8 @@ impl TreeUpdater { } } - // Sync the state of the tree to to the chain head + /// Sync the state of the tree to to the chain head + /// `tree_data`: Data structure holding the tree's currently synced state pub async fn sync_to_head( &self, tree_data: &TreeData, @@ -92,6 +103,9 @@ impl TreeUpdater { Ok(()) } + /// Syncs the tree data from a provided onchain transaction + /// `tree_data`: Data structure holding the tree's currently synced state + /// `transaction`: onchain transaction object pub async fn sync_from_transaction( &self, tree_data: &TreeData, @@ -135,6 +149,8 @@ impl TreeUpdater { } } +/// Converts an array of indices into a tightly packed vector of bytes +/// `indices`: array of 32 bit integers that represent the position of identity commitments in the `WorldTree` pub fn pack_indices(indices: &[u32]) -> Vec { let mut packed = Vec::with_capacity(indices.len() * 4); @@ -145,6 +161,8 @@ pub fn pack_indices(indices: &[u32]) -> Vec { packed } +/// Converts a packed array of bytes into a vector of 32 bit integers +/// `packed`: packed indices holding the positions of identity commitments in the `WorldTree` pub fn unpack_indices(packed: &[u8]) -> Vec { let mut indices = Vec::with_capacity(packed.len() / 4); diff --git a/x.toml b/x.toml new file mode 100644 index 00000000..f17e7281 --- /dev/null +++ b/x.toml @@ -0,0 +1,14 @@ +rpc_url = "127.0.0.1:8545" +private_key = "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318" +world_id_address = "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9" +bridge_configs = [ + [ + "Optimism", + # StaeBridge Address + "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9", + # BridgedWorldID Address + "0x4f0BF744bb79A0b919f7DED73724ec20c43572B9", + "127.0.0.1:8545", + ] +] +relaying_period_seconds = 5 From 63d1121ed7c3f3d77f382521f59189165daa05a1 Mon Sep 17 00:00:00 2001 From: dcbuilder Date: Fri, 27 Oct 2023 19:42:55 +0100 Subject: [PATCH 02/10] fix doc formatting --- bin/state_bridge_service.rs | 16 ++++---- crates/state_bridge/src/bridge.rs | 24 +++++------ crates/state_bridge/src/lib.rs | 40 +++++-------------- crates/state_bridge/src/root.rs | 20 +++------- .../src/world_tree/block_scanner.rs | 6 +-- .../tree_availability/src/world_tree/mod.rs | 2 +- .../src/world_tree/tree_data.rs | 27 +++++++------ 7 files changed, 54 insertions(+), 81 deletions(-) diff --git a/bin/state_bridge_service.rs b/bin/state_bridge_service.rs index bce6e690..e537fed5 100644 --- a/bin/state_bridge_service.rs +++ b/bin/state_bridge_service.rs @@ -19,7 +19,7 @@ use tracing::info; /// The state bridge service propagates roots according to the specified relaying_period by /// calling the propagateRoot() method on each specified World ID StateBridge. The state bridge /// service will also make sure that it doesn't propagate roots that have already been propagated -/// and have finalized on the BridgedWorldID side +/// and have finalized on the BridgedWorldID side. #[derive(Parser, Debug)] #[clap( name = "State Bridge Service", @@ -60,13 +60,13 @@ struct BridgeConfig { bridged_rpc_url: String, } -/// The config TOML file defines all the necessary parameters to spawn a state bridge service. -/// rpc_url - HTTP rpc url for an Ethereum node (string) -/// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string) -/// world_id_address - WorldIDIdentityManager contract address (string) -/// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings) -/// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings) -/// relaying_period: propagateRoot() call period time in seconds (u64) +/// The config TOML file defines all the necessary parameters to spawn a state bridge service. \ +/// rpc_url - HTTP rpc url for an Ethereum node (string) \ +/// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string) \ +/// world_id_address - WorldIDIdentityManager contract address (string) \ +/// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings) \ +/// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings) \ +/// relaying_period: propagateRoot() call period time in seconds (u64) \ /// block_confirmations - Number of block confirmations required for the propagateRoot call on the StateBridge contract (optional number) #[derive(Deserialize, Serialize, Debug, Clone)] struct Config { diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index 0fcbf2d8..902348ea 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -43,10 +43,10 @@ pub struct StateBridge { } impl StateBridge { - /// Constructor - /// `state_bridge`: `StateBridge` contract interface - /// `bridged_world_id`: `BridgedWorldID` contract interface - /// `relaying_period`: Time in between `propagateRoot()` calls + /// Constructor \ + /// `state_bridge`: `StateBridge` contract interface \ + /// `bridged_world_id`: `BridgedWorldID` contract interface \ + /// `relaying_period`: Time in between `propagateRoot()` calls \ /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized pub fn new( state_bridge: IStateBridge, @@ -62,13 +62,13 @@ impl StateBridge { }) } - /// Constructor with address and middleware - /// `bridge_address`: `StateBridge` contract address - /// `canonical_middleware`: middleware for the chain where the `StateBridge` is deployed - /// `bridged_world_id_address`: `BridgedWorldID` contract address - /// `derived_middleware`: middleware for the chain where the `BridgedWorldID` is deployed - /// `relaying_period`: Time in between `propagateRoot()` calls - /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized + /// Constructor with address and middleware \ + /// `bridge_address`: `StateBridge` contract address \ + /// `canonical_middleware`: middleware for the chain where the `StateBridge` is deployed \ + /// `bridged_world_id_address`: `BridgedWorldID` contract address \ + /// `derived_middleware`: middleware for the chain where the `BridgedWorldID` is deployed \ + /// `relaying_period`: Time in between `propagateRoot()` calls \ + /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized \ pub fn new_from_parts( bridge_address: H160, canonical_middleware: Arc, @@ -93,7 +93,7 @@ impl StateBridge { }) } - /// Spawns the `StateBridge` which listens to the `WorldRoot` `TreeChanged` events for new roots to propagate + /// Spawns the `StateBridge` which listens to the `WorldRoot` `TreeChanged` events for new roots to propagate. \ /// `root_rx`: The root receiver that listens to the `WorldRoot` root sender pub async fn spawn( &self, diff --git a/crates/state_bridge/src/lib.rs b/crates/state_bridge/src/lib.rs index c712e4f4..a03c973b 100644 --- a/crates/state_bridge/src/lib.rs +++ b/crates/state_bridge/src/lib.rs @@ -124,15 +124,8 @@ impl StateBridgeService where M: Middleware, { - /// constructor for the `StateBridgeService` - /// - /// ### Arguments - /// - /// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager` - /// - /// ### Output - /// - /// `Result>` + /// ### Constructor for the `StateBridgeService` \ + /// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager` \ pub async fn new( world_tree: IWorldIDIdentityManager, ) -> Result> { @@ -143,16 +136,9 @@ where }) } - /// constructor for the `StateBridgeService` - /// - /// ### Arguments - /// - /// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager` - /// `middleware`:`Arc\` - Middleware provider - /// - /// ### Output - /// - /// `Result>` + /// Constructor for the `StateBridgeService` \ + /// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager` \ + /// `middleware`:`Arc\` - Middleware provider \ pub async fn new_from_parts( world_tree_address: H160, middleware: Arc, @@ -168,30 +154,26 @@ where } /// Adds a state bridge to the list of state bridges the service will use - /// to propagate roots on chain to their destination chains - /// - /// ### Args - /// - /// `state_bridge`: `StateBridge` - state bridge contract interface with provider - /// + /// to propagate roots on chain to their destination chains. \ + /// `state_bridge`: `StateBridge` - state bridge contract interface with provider\ /// ### Notes /// Needs to be called before the spawn function so that the `StateBridgeService` - /// knows where to propagate roots to + /// knows where to propagate roots to. pub fn add_state_bridge(&mut self, state_bridge: StateBridge) { self.state_bridges.push(state_bridge); } - /// Spawns the `StateBridgeService` + /// Spawns the `StateBridgeService`. pub async fn spawn(&mut self) -> Result<(), StateBridgeError> { // if no state bridge initialized then there is no point in spawning - // the state bridge service as there'd be no receivers for new roots + // the state bridge service as there'd be no receivers for new roots. if self.state_bridges.is_empty() { return Err(StateBridgeError::BridgesNotInitialized); } // We first instantiate the receivers on the state bridges // so that the root sender doesn't yield an error when pushing roots - // through the channel + // through the channel. for bridge in self.state_bridges.iter() { self.handles.push( bridge.spawn(self.canonical_root.root_tx.subscribe()).await, diff --git a/crates/state_bridge/src/root.rs b/crates/state_bridge/src/root.rs index cf684e95..02932d11 100644 --- a/crates/state_bridge/src/root.rs +++ b/crates/state_bridge/src/root.rs @@ -37,13 +37,8 @@ impl WorldTreeRoot where M: Middleware, { - /// `WorldTreeRoot` constructor - /// - /// ### Args + /// `WorldTreeRoot` constructor \ /// `world_id_identity_manager`:`IWorldIDIdentityManager\` - `WorldIDIdentityManager` interface - /// - /// ### Output - /// `WorldTreeRoot` Result pub async fn new( world_id_identity_manager: IWorldIDIdentityManager, ) -> Result> { @@ -55,15 +50,10 @@ where }) } - /// `WorldTreeRoot` constructor from address and middleware - /// - /// ### Args - /// `world_id_identity_manager`:`IWorldIDIdentityManager\` - `WorldIDIdentityManager` interface - /// `world_tree_address`: `H160` - `WorldIDIdentityManager` contract address - /// `middleware`: `Arc\` - Middleware provider (ethers) - /// - /// ### Output - /// `WorldTreeRoot` Result + /// `WorldTreeRoot` constructor from address and middleware \ + /// `world_id_identity_manager`:`IWorldIDIdentityManager\` - `WorldIDIdentityManager` interface \ + /// `world_tree_address`: `H160` - `WorldIDIdentityManager` contract address \ + /// `middleware`: `Arc\` - Middleware provider (ethers) \ pub async fn new_from_parts( world_tree_address: H160, middleware: Arc, diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index bd28287f..e0317b72 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -32,9 +32,9 @@ where } } - /// Returns a list of specified events that were emitted by a given smart contract address - /// `address`: Address of the contract that we want to listen to events in - /// `topics`: The topics of the events the `BlockScanner` will listen to and parse + /// Returns a list of specified events that were emitted by a given smart contract address \ + /// `address`: Address of the contract that we want to listen to events in \ + /// `topics`: The topics of the events the `BlockScanner` will listen to and parse \ pub async fn next( &self, address: Option>, diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index 7ff23dd0..e99c47cd 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -23,7 +23,7 @@ pub type Hash = ::Hash; /// An abstraction over a tree with a history of changes /// -/// In our data model the `tree` is the oldest available tree. +/// In our data model the `tree` is the oldest available tree. \ /// The entires in `tree_history` represent new additions to the tree. pub struct WorldTree { /// All the leaves of the tree and their corresponding root hash diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index 664f1faa..79ce661f 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -8,7 +8,7 @@ use super::{Hash, PoseidonTree}; use crate::server::InclusionProof; /// The `TreeData` structure represents the in-memory representation of the tree as well as its historic -/// versions up to `tree_history_size` +/// versions up to `tree_history_size`. pub struct TreeData { /// Tree holding all leaves pub tree: RwLock>, @@ -26,8 +26,8 @@ pub struct TreeUpdate { } impl TreeData { - /// Constructor - /// `tree`: Canonical in-memory tree + /// Constructor \ + /// `tree`: Canonical in-memory tree \ /// `tree_history_size`: Number of most recent historical roots that the `WorldTree` can serve proofs for pub fn new( tree: PoseidonTree, @@ -40,8 +40,8 @@ impl TreeData { } } - /// Inserts identities at a given starting index - /// `start_index`: Index at which to start inserting identity commitments + /// Inserts identities at a given starting index. \ + /// `start_index`: Index at which to start inserting identity commitments \ /// `identities`: Identity commitments pub async fn insert_many_at( &self, @@ -56,7 +56,7 @@ impl TreeData { } } - /// Deletes identity commitments in the `WorldTree` at the specified indices + /// Deletes identity commitments in the `WorldTree` at the specified indices. \ /// `delete_indices`: positions of the identity commitments in the tree to be deleted pub async fn delete_many(&self, delete_indices: &[usize]) { self.cache_tree_history().await; @@ -82,12 +82,13 @@ impl TreeData { } } - /// Fetches the inclusion proof of the provided identity at the given root hash + /// Fetches the inclusion proof of the provided identity at the given root hash \ + /// + /// `identity`: Identity commitment to fetch the inclusion proof for \ + /// `root`: The root against which the `WorldTree` will serve the inclusion proof against \ /// - /// `identity`: Identity commitment to fetch the inclusion proof for - /// `root`: The root against which the `WorldTree` will serve the inclusion proof against /// Returns None if the provided root hash is not in the latest one or is not present in tree history - /// or if the identity is not present in the tree + /// or if the identity is not present in the tree. pub async fn get_inclusion_proof( &self, identity: Hash, @@ -130,9 +131,9 @@ impl TreeData { } } - /// Returns an inclusion proof for a given identity commitment in the specified tree - /// `tree`: The `WorldTree` (canonical or derived) to fetch the inclusion proof against - /// `identity`: Identity commitment to create the inclusion proof for + /// Returns an inclusion proof for a given identity commitment in the specified tree \ + /// `tree`: The `WorldTree` (canonical or derived) to fetch the inclusion proof against \ + /// `identity`: Identity commitment to create the inclusion proof for \ fn proof( tree: &PoseidonTree, identity: Hash, From a349c81b5bd1c589ed623b3a74851764ee61115a Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Sat, 28 Oct 2023 01:44:57 -0400 Subject: [PATCH 03/10] removed \ from doc comments --- bin/state_bridge_service.rs | 14 +++++------ crates/state_bridge/src/bridge.rs | 24 +++++++++---------- crates/state_bridge/src/lib.rs | 14 +++++------ crates/state_bridge/src/root.rs | 12 +++++----- crates/tree_availability/src/lib.rs | 14 +++++------ .../src/world_tree/block_scanner.rs | 6 ++--- .../tree_availability/src/world_tree/mod.rs | 2 +- .../src/world_tree/tree_data.rs | 22 ++++++++--------- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/bin/state_bridge_service.rs b/bin/state_bridge_service.rs index e537fed5..ca6c745e 100644 --- a/bin/state_bridge_service.rs +++ b/bin/state_bridge_service.rs @@ -60,13 +60,13 @@ struct BridgeConfig { bridged_rpc_url: String, } -/// The config TOML file defines all the necessary parameters to spawn a state bridge service. \ -/// rpc_url - HTTP rpc url for an Ethereum node (string) \ -/// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string) \ -/// world_id_address - WorldIDIdentityManager contract address (string) \ -/// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings) \ -/// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings) \ -/// relaying_period: propagateRoot() call period time in seconds (u64) \ +/// The config TOML file defines all the necessary parameters to spawn a state bridge service. +/// rpc_url - HTTP rpc url for an Ethereum node (string) +/// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string) +/// world_id_address - WorldIDIdentityManager contract address (string) +/// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings) +/// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings) +/// relaying_period: propagateRoot() call period time in seconds (u64) /// block_confirmations - Number of block confirmations required for the propagateRoot call on the StateBridge contract (optional number) #[derive(Deserialize, Serialize, Debug, Clone)] struct Config { diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index 902348ea..b4de1026 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -43,10 +43,10 @@ pub struct StateBridge { } impl StateBridge { - /// Constructor \ - /// `state_bridge`: `StateBridge` contract interface \ - /// `bridged_world_id`: `BridgedWorldID` contract interface \ - /// `relaying_period`: Time in between `propagateRoot()` calls \ + /// Constructor + /// `state_bridge`: `StateBridge` contract interface + /// `bridged_world_id`: `BridgedWorldID` contract interface + /// `relaying_period`: Time in between `propagateRoot()` calls /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized pub fn new( state_bridge: IStateBridge, @@ -62,13 +62,13 @@ impl StateBridge { }) } - /// Constructor with address and middleware \ - /// `bridge_address`: `StateBridge` contract address \ - /// `canonical_middleware`: middleware for the chain where the `StateBridge` is deployed \ - /// `bridged_world_id_address`: `BridgedWorldID` contract address \ - /// `derived_middleware`: middleware for the chain where the `BridgedWorldID` is deployed \ - /// `relaying_period`: Time in between `propagateRoot()` calls \ - /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized \ + /// Constructor with address and middleware + /// `bridge_address`: `StateBridge` contract address + /// `canonical_middleware`: middleware for the chain where the `StateBridge` is deployed + /// `bridged_world_id_address`: `BridgedWorldID` contract address + /// `derived_middleware`: middleware for the chain where the `BridgedWorldID` is deployed + /// `relaying_period`: Time in between `propagateRoot()` calls + /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized pub fn new_from_parts( bridge_address: H160, canonical_middleware: Arc, @@ -93,7 +93,7 @@ impl StateBridge { }) } - /// Spawns the `StateBridge` which listens to the `WorldRoot` `TreeChanged` events for new roots to propagate. \ + /// Spawns the `StateBridge` which listens to the `WorldRoot` `TreeChanged` events for new roots to propagate. /// `root_rx`: The root receiver that listens to the `WorldRoot` root sender pub async fn spawn( &self, diff --git a/crates/state_bridge/src/lib.rs b/crates/state_bridge/src/lib.rs index a03c973b..ff9b2ca6 100644 --- a/crates/state_bridge/src/lib.rs +++ b/crates/state_bridge/src/lib.rs @@ -124,8 +124,8 @@ impl StateBridgeService where M: Middleware, { - /// ### Constructor for the `StateBridgeService` \ - /// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager` \ + /// ### Constructor for the `StateBridgeService` + /// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager` pub async fn new( world_tree: IWorldIDIdentityManager, ) -> Result> { @@ -136,9 +136,9 @@ where }) } - /// Constructor for the `StateBridgeService` \ - /// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager` \ - /// `middleware`:`Arc\` - Middleware provider \ + /// Constructor for the `StateBridgeService` + /// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager` + /// `middleware`:`Arc` - Middleware provider pub async fn new_from_parts( world_tree_address: H160, middleware: Arc, @@ -154,8 +154,8 @@ where } /// Adds a state bridge to the list of state bridges the service will use - /// to propagate roots on chain to their destination chains. \ - /// `state_bridge`: `StateBridge` - state bridge contract interface with provider\ + /// to propagate roots on chain to their destination chains. + /// `state_bridge`: `StateBridge` - state bridge contract interface with provider /// ### Notes /// Needs to be called before the spawn function so that the `StateBridgeService` /// knows where to propagate roots to. diff --git a/crates/state_bridge/src/root.rs b/crates/state_bridge/src/root.rs index 02932d11..ffce747a 100644 --- a/crates/state_bridge/src/root.rs +++ b/crates/state_bridge/src/root.rs @@ -37,8 +37,8 @@ impl WorldTreeRoot where M: Middleware, { - /// `WorldTreeRoot` constructor \ - /// `world_id_identity_manager`:`IWorldIDIdentityManager\` - `WorldIDIdentityManager` interface + /// `WorldTreeRoot` constructor + /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface pub async fn new( world_id_identity_manager: IWorldIDIdentityManager, ) -> Result> { @@ -50,10 +50,10 @@ where }) } - /// `WorldTreeRoot` constructor from address and middleware \ - /// `world_id_identity_manager`:`IWorldIDIdentityManager\` - `WorldIDIdentityManager` interface \ - /// `world_tree_address`: `H160` - `WorldIDIdentityManager` contract address \ - /// `middleware`: `Arc\` - Middleware provider (ethers) \ + /// `WorldTreeRoot` constructor from address and middleware + /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface + /// `world_tree_address`: `H160` - `WorldIDIdentityManager` contract address + /// `middleware`: `Arc` - Middleware provider (ethers) pub async fn new_from_parts( world_tree_address: H160, middleware: Arc, diff --git a/crates/tree_availability/src/lib.rs b/crates/tree_availability/src/lib.rs index 3713ecda..d32b5ce4 100644 --- a/crates/tree_availability/src/lib.rs +++ b/crates/tree_availability/src/lib.rs @@ -17,13 +17,13 @@ //! # Build the binary //! cargo build --bin tree-availability-service --release //! # Run the command -//! ./target/release/tree-availability-service \ -//! --tree-depth \ -//! --tree-history-size \ -//! --dense-prefix-depth \ -//! --address
\ -//! --creation-block \ -//! --rpc-endpoint \ +//! ./target/release/tree-availability-service +//! --tree-depth +//! --tree-history-size +//! --dense-prefix-depth +//! --address
+//! --creation-block +//! --rpc-endpoint //! ``` //! //! #### Library diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index e0317b72..bd28287f 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -32,9 +32,9 @@ where } } - /// Returns a list of specified events that were emitted by a given smart contract address \ - /// `address`: Address of the contract that we want to listen to events in \ - /// `topics`: The topics of the events the `BlockScanner` will listen to and parse \ + /// Returns a list of specified events that were emitted by a given smart contract address + /// `address`: Address of the contract that we want to listen to events in + /// `topics`: The topics of the events the `BlockScanner` will listen to and parse pub async fn next( &self, address: Option>, diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index e99c47cd..7ff23dd0 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -23,7 +23,7 @@ pub type Hash = ::Hash; /// An abstraction over a tree with a history of changes /// -/// In our data model the `tree` is the oldest available tree. \ +/// In our data model the `tree` is the oldest available tree. /// The entires in `tree_history` represent new additions to the tree. pub struct WorldTree { /// All the leaves of the tree and their corresponding root hash diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index 79ce661f..1cf7cd9c 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -26,8 +26,8 @@ pub struct TreeUpdate { } impl TreeData { - /// Constructor \ - /// `tree`: Canonical in-memory tree \ + /// Constructor + /// `tree`: Canonical in-memory tree /// `tree_history_size`: Number of most recent historical roots that the `WorldTree` can serve proofs for pub fn new( tree: PoseidonTree, @@ -40,8 +40,8 @@ impl TreeData { } } - /// Inserts identities at a given starting index. \ - /// `start_index`: Index at which to start inserting identity commitments \ + /// Inserts identities at a given starting index. + /// `start_index`: Index at which to start inserting identity commitments /// `identities`: Identity commitments pub async fn insert_many_at( &self, @@ -56,7 +56,7 @@ impl TreeData { } } - /// Deletes identity commitments in the `WorldTree` at the specified indices. \ + /// Deletes identity commitments in the `WorldTree` at the specified indices. /// `delete_indices`: positions of the identity commitments in the tree to be deleted pub async fn delete_many(&self, delete_indices: &[usize]) { self.cache_tree_history().await; @@ -82,10 +82,10 @@ impl TreeData { } } - /// Fetches the inclusion proof of the provided identity at the given root hash \ + /// Fetches the inclusion proof of the provided identity at the given root hash /// - /// `identity`: Identity commitment to fetch the inclusion proof for \ - /// `root`: The root against which the `WorldTree` will serve the inclusion proof against \ + /// `identity`: Identity commitment to fetch the inclusion proof for + /// `root`: The root against which the `WorldTree` will serve the inclusion proof against /// /// Returns None if the provided root hash is not in the latest one or is not present in tree history /// or if the identity is not present in the tree. @@ -131,9 +131,9 @@ impl TreeData { } } - /// Returns an inclusion proof for a given identity commitment in the specified tree \ - /// `tree`: The `WorldTree` (canonical or derived) to fetch the inclusion proof against \ - /// `identity`: Identity commitment to create the inclusion proof for \ + /// Returns an inclusion proof for a given identity commitment in the specified tree + /// `tree`: The `WorldTree` (canonical or derived) to fetch the inclusion proof against + /// `identity`: Identity commitment to create the inclusion proof for fn proof( tree: &PoseidonTree, identity: Hash, From 3062432d01adc739cd0ca8d10f8bf338d65f33a6 Mon Sep 17 00:00:00 2001 From: dcbuilder Date: Sat, 28 Oct 2023 22:15:48 +0100 Subject: [PATCH 04/10] fix spacing --- crates/state_bridge/src/bridge.rs | 11 +++++++++++ crates/state_bridge/src/lib.rs | 6 ++++++ crates/state_bridge/src/root.rs | 4 ++++ .../tree_availability/src/world_tree/block_scanner.rs | 4 +++- crates/tree_availability/src/world_tree/tree_data.rs | 9 ++++++++- .../tree_availability/src/world_tree/tree_updater.rs | 6 ++++++ 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index b4de1026..86a5bc5b 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -44,9 +44,13 @@ pub struct StateBridge { impl StateBridge { /// Constructor + /// /// `state_bridge`: `StateBridge` contract interface + /// /// `bridged_world_id`: `BridgedWorldID` contract interface + /// /// `relaying_period`: Time in between `propagateRoot()` calls + /// /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized pub fn new( state_bridge: IStateBridge, @@ -63,11 +67,17 @@ impl StateBridge { } /// Constructor with address and middleware + /// /// `bridge_address`: `StateBridge` contract address + /// /// `canonical_middleware`: middleware for the chain where the `StateBridge` is deployed + /// /// `bridged_world_id_address`: `BridgedWorldID` contract address + /// /// `derived_middleware`: middleware for the chain where the `BridgedWorldID` is deployed + /// /// `relaying_period`: Time in between `propagateRoot()` calls + /// /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized pub fn new_from_parts( bridge_address: H160, @@ -94,6 +104,7 @@ impl StateBridge { } /// Spawns the `StateBridge` which listens to the `WorldRoot` `TreeChanged` events for new roots to propagate. + /// /// `root_rx`: The root receiver that listens to the `WorldRoot` root sender pub async fn spawn( &self, diff --git a/crates/state_bridge/src/lib.rs b/crates/state_bridge/src/lib.rs index ff9b2ca6..2e97e488 100644 --- a/crates/state_bridge/src/lib.rs +++ b/crates/state_bridge/src/lib.rs @@ -125,6 +125,7 @@ where M: Middleware, { /// ### Constructor for the `StateBridgeService` + /// /// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager` pub async fn new( world_tree: IWorldIDIdentityManager, @@ -137,7 +138,9 @@ where } /// Constructor for the `StateBridgeService` + /// /// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager` + /// /// `middleware`:`Arc` - Middleware provider pub async fn new_from_parts( world_tree_address: H160, @@ -155,8 +158,11 @@ where /// Adds a state bridge to the list of state bridges the service will use /// to propagate roots on chain to their destination chains. + /// /// `state_bridge`: `StateBridge` - state bridge contract interface with provider + /// /// ### Notes + /// /// Needs to be called before the spawn function so that the `StateBridgeService` /// knows where to propagate roots to. pub fn add_state_bridge(&mut self, state_bridge: StateBridge) { diff --git a/crates/state_bridge/src/root.rs b/crates/state_bridge/src/root.rs index ffce747a..82b904c7 100644 --- a/crates/state_bridge/src/root.rs +++ b/crates/state_bridge/src/root.rs @@ -38,6 +38,7 @@ where M: Middleware, { /// `WorldTreeRoot` constructor + /// /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface pub async fn new( world_id_identity_manager: IWorldIDIdentityManager, @@ -51,8 +52,11 @@ where } /// `WorldTreeRoot` constructor from address and middleware + /// /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface + /// /// `world_tree_address`: `H160` - `WorldIDIdentityManager` contract address + /// /// `middleware`: `Arc` - Middleware provider (ethers) pub async fn new_from_parts( world_tree_address: H160, diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index bd28287f..4b001818 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -11,7 +11,7 @@ pub struct BlockScanner { middleware: M, /// The block from which to start parsing a given event current_block: AtomicU64, - /// TODO: doc + /// Event window window_size: u64, } @@ -33,7 +33,9 @@ where } /// Returns a list of specified events that were emitted by a given smart contract address + /// /// `address`: Address of the contract that we want to listen to events in + /// /// `topics`: The topics of the events the `BlockScanner` will listen to and parse pub async fn next( &self, diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index 1cf7cd9c..925aff78 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -19,7 +19,6 @@ pub struct TreeData { } /// Defines how the tree changed pub struct TreeUpdate { - /// TODO: docs pub index: usize, /// New hash of the tree pub value: Hash, @@ -27,7 +26,9 @@ pub struct TreeUpdate { impl TreeData { /// Constructor + /// /// `tree`: Canonical in-memory tree + /// /// `tree_history_size`: Number of most recent historical roots that the `WorldTree` can serve proofs for pub fn new( tree: PoseidonTree, @@ -41,7 +42,9 @@ impl TreeData { } /// Inserts identities at a given starting index. + /// /// `start_index`: Index at which to start inserting identity commitments + /// /// `identities`: Identity commitments pub async fn insert_many_at( &self, @@ -57,6 +60,7 @@ impl TreeData { } /// Deletes identity commitments in the `WorldTree` at the specified indices. + /// /// `delete_indices`: positions of the identity commitments in the tree to be deleted pub async fn delete_many(&self, delete_indices: &[usize]) { self.cache_tree_history().await; @@ -85,6 +89,7 @@ impl TreeData { /// Fetches the inclusion proof of the provided identity at the given root hash /// /// `identity`: Identity commitment to fetch the inclusion proof for + /// /// `root`: The root against which the `WorldTree` will serve the inclusion proof against /// /// Returns None if the provided root hash is not in the latest one or is not present in tree history @@ -132,7 +137,9 @@ impl TreeData { } /// Returns an inclusion proof for a given identity commitment in the specified tree + /// /// `tree`: The `WorldTree` (canonical or derived) to fetch the inclusion proof against + /// /// `identity`: Identity commitment to create the inclusion proof for fn proof( tree: &PoseidonTree, diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index 6a7d99cf..4d17c90d 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -35,8 +35,11 @@ pub struct TreeUpdater { impl TreeUpdater { /// Constructor + /// /// `address`: `WorldIDIdentityManager` contract address + /// /// `creation_block`: The block height of the `WorldIDIdentityManager` contract deployment + /// /// `middleware`: provider pub fn new(address: H160, creation_block: u64, middleware: Arc) -> Self { Self { @@ -53,6 +56,7 @@ impl TreeUpdater { } /// Sync the state of the tree to to the chain head + /// /// `tree_data`: Data structure holding the tree's currently synced state pub async fn sync_to_head( &self, @@ -104,7 +108,9 @@ impl TreeUpdater { } /// Syncs the tree data from a provided onchain transaction + /// /// `tree_data`: Data structure holding the tree's currently synced state + /// /// `transaction`: onchain transaction object pub async fn sync_from_transaction( &self, From d3b5c9fa8e81a4a930f9c74a973f232e7b608bc5 Mon Sep 17 00:00:00 2001 From: "dcbuilder.eth" Date: Mon, 30 Oct 2023 10:37:54 +0000 Subject: [PATCH 05/10] update doc 1 Co-authored-by: 0xKitsune <77890308+0xKitsune@users.noreply.github.com> --- crates/state_bridge/src/bridge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index 86a5bc5b..aeeaa6a0 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -38,7 +38,7 @@ pub struct StateBridge { pub bridged_world_id: IBridgedWorldID, /// Time in between `propagateRoot()` calls pub relaying_period: Duration, - /// The number of blocks before a `propagateRoot()` call is considered finalized + /// The number of block confirmations before a `propagateRoot()` transaction is considered finalized pub block_confirmations: usize, } From 1eed40fd0f15544494645f55ff4e2fe2359e36e3 Mon Sep 17 00:00:00 2001 From: "dcbuilder.eth" Date: Mon, 30 Oct 2023 10:38:18 +0000 Subject: [PATCH 06/10] update doc 2 Co-authored-by: 0xKitsune <77890308+0xKitsune@users.noreply.github.com> --- crates/state_bridge/src/bridge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index aeeaa6a0..b515a0a5 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -36,7 +36,7 @@ pub struct StateBridge { pub state_bridge: IStateBridge, /// Interface for the `BridgedWorldID` contract pub bridged_world_id: IBridgedWorldID, - /// Time in between `propagateRoot()` calls + /// Time delay between `propagateRoot()` transactions pub relaying_period: Duration, /// The number of block confirmations before a `propagateRoot()` transaction is considered finalized pub block_confirmations: usize, From 5ab1e57cd25df715b0d2ef888b96e920d19dab11 Mon Sep 17 00:00:00 2001 From: dcbuilder Date: Mon, 30 Oct 2023 10:48:51 +0000 Subject: [PATCH 07/10] adopt review fixes --- bin/state_bridge_service.rs | 41 +++++++- bin/tree_availability_service.rs | 32 +++++- crates/state_bridge/src/bridge.rs | 2 +- crates/state_bridge/src/error.rs | 1 - crates/state_bridge/src/lib.rs | 91 +---------------- crates/tree_availability/src/error.rs | 1 - crates/tree_availability/src/lib.rs | 137 +------------------------- x.toml | 14 --- 8 files changed, 71 insertions(+), 248 deletions(-) delete mode 100644 x.toml diff --git a/bin/state_bridge_service.rs b/bin/state_bridge_service.rs index ca6c745e..ae9289ac 100644 --- a/bin/state_bridge_service.rs +++ b/bin/state_bridge_service.rs @@ -1,3 +1,38 @@ +//! # State Bridge Service +//! +//! ### Description +//! +//! The state bridge service for the World ID protocol takes care of periodically relaying the latest roots from the World ID Identity Manager onto L2 networks or sidechains that implement native bridge on Ethereum or have an integration with third party messaging protocol. The state bridge service requires a deployment of the [`world-id-state-bridge`](github.com/worldcoin/world-id-state-bridge/) contracts which in turn also have to be connected to a valid [`world-id-contracts`](https://github.com/worldcoin/world-id-contracts/) deployment. +//! +//! ### Usage +//! +//! #### CLI +//! +//! Create a state_bridge_service.toml file which will hold the configuration parameters for the state bridge +//! service. You can use the example in the test as a template: +//! +//! ```toml +//! rpc_url = "127.0.0.1:8545" +//! private_key = "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318" +//! world_id_address = "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9" +//! bridge_configs = [ +//! [ +//! "Optimism", +//! # StateBridge Address +//! "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9", +//! # BridgedWorldID Address +//! "0x4f0BF744bb79A0b919f7DED73724ec20c43572B9", +//! "127.0.0.1:8545", +//! ] +//! ] +//! relaying_period_seconds = 5 +//! ``` +//! +//! ```bash +//! cargo build --bin state-bridge-service --release +//! ./target/release/state-bridge-service --config +//! ``` + use std::fs; use std::path::PathBuf; use std::sync::Arc; @@ -16,10 +51,8 @@ use state_bridge::root::IWorldIDIdentityManager; use state_bridge::StateBridgeService; use tracing::info; -/// The state bridge service propagates roots according to the specified relaying_period by -/// calling the propagateRoot() method on each specified World ID StateBridge. The state bridge -/// service will also make sure that it doesn't propagate roots that have already been propagated -/// and have finalized on the BridgedWorldID side. +/// The state bridge service propagates roots from the world tree. Frequency of root propagation is specified +/// by the relaying_period. This service will not propagate roots that have already been propagated before. #[derive(Parser, Debug)] #[clap( name = "State Bridge Service", diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index e3bae608..919b144c 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -1,3 +1,30 @@ +//! # Tree Availability Service +//! +//! The tree availability service is able to create an in-memory representation of the World ID +//! merkle tree by syncing the state of the World ID contract `registerIdentities` and `deleteIdentities` +//! function calldata and `TreeChanged` events. Once it syncs the latest state of the state of the tree, it +//! is able to serve inclusion proofs on the `/inclusionProof` endpoint. It also keeps a historical roots list +//! of `tree_history_size` size in order to serve proofs against older tree roots (including the roots of +//! World IDs bridged to other networks). +//! +//! ### Usage +//! +//! #### CLI +//! +//! In order to run the tree availability service you can run the following commands +//! +//! ```bash +//! # Build the binary +//! cargo build --bin tree-availability-service --release +//! # Run the command +//! ./target/release/tree-availability-service +//! --tree-depth +//! --tree-history-size +//! --dense-prefix-depth +//! --address
+//! --creation-block +//! --rpc-endpoint + use std::sync::Arc; use clap::Parser; @@ -9,7 +36,10 @@ use tree_availability::TreeAvailabilityService; /// CLI interface for the Tree Availability Service #[derive(Parser, Debug)] -#[clap(name = "Tree Availability Service", about = "")] +#[clap( + name = "Tree Availability Service", + about = "The tree availability service periodically calls propagateRoot() on a World ID StateBridge contract." +)] struct Opts { #[clap(long, help = "Depth of the World Tree")] tree_depth: usize, diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index 86a5bc5b..d70cf43d 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -78,7 +78,7 @@ impl StateBridge { /// /// `relaying_period`: Time in between `propagateRoot()` calls /// - /// `block_confirmations: The number of blocks before a `propagateRoot()` call is considered finalized + /// `block_confirmations: The number of block confirmations before a `propagateRoot()` transaction is considered finalized pub fn new_from_parts( bridge_address: H160, canonical_middleware: Arc, diff --git a/crates/state_bridge/src/error.rs b/crates/state_bridge/src/error.rs index b0575188..cbc65608 100644 --- a/crates/state_bridge/src/error.rs +++ b/crates/state_bridge/src/error.rs @@ -4,7 +4,6 @@ use thiserror::Error; use crate::root::Hash; -/// Wraps dependency errors and converts them to `StateBridgeError` using `thiserror` #[derive(Error, Debug)] pub enum StateBridgeError where diff --git a/crates/state_bridge/src/lib.rs b/crates/state_bridge/src/lib.rs index 2e97e488..01b1df49 100644 --- a/crates/state_bridge/src/lib.rs +++ b/crates/state_bridge/src/lib.rs @@ -3,96 +3,7 @@ //! ### Description //! //! The state bridge service for the World ID protocol takes care of periodically relaying the latest roots from the World ID Identity Manager onto L2 networks or sidechains that implement native bridge on Ethereum or have an integration with third party messaging protocol. The state bridge service requires a deployment of the [`world-id-state-bridge`](github.com/worldcoin/world-id-state-bridge/) contracts which in turn also have to be connected to a valid [`world-id-contracts`](https://github.com/worldcoin/world-id-contracts/) deployment. -//! -//! ### Usage -//! -//! #### CLI -//! -//! Create a state_bridge_service.toml file which will hold the configuration parameters for the state bridge -//! service. You can use the example in the test as a template: -//! -//! ```toml -//! rpc_url = "127.0.0.1:8545" -//! private_key = "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318" -//! world_id_address = "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9" -//! bridge_configs = [ -//! [ -//! "Optimism", -//! # StateBridge Address -//! "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9", -//! # BridgedWorldID Address -//! "0x4f0BF744bb79A0b919f7DED73724ec20c43572B9", -//! "127.0.0.1:8545", -//! ] -//! ] -//! relaying_period_seconds = 5 -//! ``` -//! -//! ```bash -//! cargo build --bin state-bridge-service --release -//! ./target/release/state-bridge-service --config -//! ``` -//! -//! #### Library -//! In order to launch a `StateBridgeService` as a library you can use the following example from the [`bridge_service.rs`](https://github.com/worldcoin/identity-sequencer/blob/359f0fe3ec62b18d6f569d8ad31967c048401fa1/crates/state_bridge/tests/bridge_service.rs#L37) test file as a guide. -//! ``` -//! use state_bridge::bridge::{IBridgedWorldID, IStateBridge, StateBridge}; -//! use state_bridge::root::IWorldIDIdentityManager; -//! use state_bridge::StateBridgeService; -//! use common::test_utilities::chain_mock::{spawn_mock_chain, MockChain}; -//! // If you deploy your own state bridge and run your own Ethereum RPC -//! // (or use a third party service like Alchemy) -//! // you can instantiate your own variables by providing the right addresses -//! // and a middleware (implements ethers::middleware::Middleware). -//! #[tokio::test] -//! async fn doc_example() -> eyre::Result<()> { -//! let MockChain { -//! mock_state_bridge, -//! mock_bridged_world_id, -//! mock_world_id, -//! middleware, -//! anvil, -//! .. -//! } = spawn_mock_chain().await?; -//! -//! let relaying_period = std::time::Duration::from_secs(5); -//! -//! let world_id = IWorldIDIdentityManager::new( -//! mock_world_id.address(), -//! middleware.clone(), -//! ); -//! -//! mock_state_bridge.propagate_root().send().await?.await?; -//! -//! let state_bridge_address = mock_state_bridge.address(); -//! -//! let bridged_world_id_address = mock_bridged_world_id.address(); -//! -//! let block_confirmations = 6; -//! -//! let mut state_bridge_service = StateBridgeService::new(world_id) -//! .await -//! .expect("couldn't create StateBridgeService"); -//! -//! let state_bridge = -//! IStateBridge::new(state_bridge_address, middleware.clone()); -//! -//! let bridged_world_id = -//! IBridgedWorldID::new(bridged_world_id_address, middleware.clone()); -//! -//! let state_bridge = -//! StateBridge::new(state_bridge, bridged_world_id, relaying_period, block_confirmations) -//! .unwrap(); -//! -//! state_bridge_service.add_state_bridge(state_bridge); -//! -//! state_bridge_service -//! .spawn() -//! .await -//! .expect("failed to spawn a state bridge service"); -//! } -//! ``` -//! + pub mod bridge; pub mod error; pub mod root; diff --git a/crates/tree_availability/src/error.rs b/crates/tree_availability/src/error.rs index 8f38917d..4a653f7b 100644 --- a/crates/tree_availability/src/error.rs +++ b/crates/tree_availability/src/error.rs @@ -4,7 +4,6 @@ use ethers::types::Log; use thiserror::Error; use tokio::sync::mpsc::error::SendError; -/// Wraps dependency errors and converts them to `TreeAvailabilityError`s #[derive(Error, Debug)] pub enum TreeAvailabilityError where diff --git a/crates/tree_availability/src/lib.rs b/crates/tree_availability/src/lib.rs index d32b5ce4..d89fa61b 100644 --- a/crates/tree_availability/src/lib.rs +++ b/crates/tree_availability/src/lib.rs @@ -6,141 +6,6 @@ //! is able to serve inclusion proofs on the `/inclusionProof` endpoint. It also keeps a historical roots list //! of `tree_history_size` size in order to serve proofs against older tree roots (including the roots of //! World IDs bridged to other networks). -//! -//! ### Usage -//! -//! #### CLI -//! -//! In order to run the tree availability service you can run the following commands -//! -//! ```bash -//! # Build the binary -//! cargo build --bin tree-availability-service --release -//! # Run the command -//! ./target/release/tree-availability-service -//! --tree-depth -//! --tree-history-size -//! --dense-prefix-depth -//! --address
-//! --creation-block -//! --rpc-endpoint -//! ``` -//! -//! #### Library -//! -//! A good example of how to use the `StateBridgeService` struct in a library is demonstrated in the [`inclusion_proof.rs`](https://github.com/worldcoin/identity-sequencer/blob/main/crates/tree_availability/tests/inclusion_proof.rs) test file. -//! -//! ``` -//! use std::str::FromStr; -//! -//! use common::test_utilities::chain_mock::{spawn_mock_chain, MockChain}; -//! use ethers::providers::Middleware; -//! use ethers::types::U256; -//! use futures::stream::FuturesUnordered; -//! use futures::StreamExt; -//! use hyper::StatusCode; -//! use tree_availability::error::TreeAvailabilityError; -//! use tree_availability::server::{InclusionProof, InclusionProofRequest}; -//! use tree_availability::world_tree::tree_updater::pack_indices; -//! use tree_availability::world_tree::Hash; -//! use tree_availability::TreeAvailabilityService; -//! #[tokio::test] -//! async fn test_inclusion_proof() -> eyre::Result<()> { -//! // Initialize a new mock tree -//! let MockChain { -//! anvil: _anvil, -//! middleware, -//! mock_world_id, -//! .. -//! } = spawn_mock_chain().await?; -//! -//! // Register identities -//! let identity_commitments = -//! vec![U256::from(1), U256::from(2), U256::from(3)]; -//! -//! let world_tree_creation_block = -//! middleware.get_block_number().await?.as_u64() - 1; -//! -//! mock_world_id -//! .register_identities( -//! [U256::zero(); 8], -//! U256::zero(), -//! 0, -//! identity_commitments, -//! U256::zero(), -//! ) -//! .send() -//! .await? -//! .await?; -//! -//! // Delete an identity -//! mock_world_id -//! .delete_identities( -//! [U256::zero(); 8], -//! pack_indices(&[1]).into(), -//! U256::zero(), -//! U256::zero(), -//! ) -//! .send() -//! .await? -//! .await?; -//! -//! // Initialize the tree availability service -//! let world_tree_address = mock_world_id.address(); -//! let tree_availability_service = TreeAvailabilityService::new( -//! 3, -//! 1, -//! 5, -//! world_tree_address, -//! world_tree_creation_block, -//! middleware, -//! ); -//! -//! let world_tree = tree_availability_service.world_tree.clone(); -//! -//! // Spawn the service in a separate task -//! let server_handle = tokio::spawn(async move { -//! let handles = tree_availability_service.serve(8080).await; -//! -//! let mut handles = handles.into_iter().collect::>(); -//! while let Some(result) = handles.next().await { -//! result.expect("TODO: propagate this error")?; -//! } -//! -//! Ok::<(), TreeAvailabilityError<_>>(()) -//! }); -//! -//! // Wait for the tree to be synced -//! loop { -//! if world_tree -//! .tree_updater -//! .synced -//! .load(std::sync::atomic::Ordering::Relaxed) -//! { -//! break; -//! } -//! -//! tokio::time::sleep(std::time::Duration::from_secs(1)).await; -//! } -//! -//! // Send a request to get an inclusion proof -//! let client = reqwest::Client::new(); -//! let response = client -//! .post("http://127.0.0.1:8080/inclusionProof") -//! .json(&InclusionProofRequest { -//! identity_commitment: Hash::from(0x01), -//! root: None, -//! }) -//! .send() -//! .await?; -//! -//! assert_eq!(response.status(), StatusCode::OK); -//! -//! // Return an inclusion proof -//! let proof: Option = response.json().await?; -//! assert!(proof.is_some()); -//! } -//! ``` pub mod error; pub mod server; @@ -165,7 +30,7 @@ pub struct TreeAvailabilityService { } impl TreeAvailabilityService { - /// Constructor + /// Initializes new instance of TreeAvailabilityService /// `tree_depth`: the depth of the World ID contract (currently 30 in production - Nov 2023) /// `dense_prefix_depth`: what is the depth of the tree that is densely populated (currently depth 10) /// `tree_history_size`: how many historical roots and derived trees to hold in memory to serve proofs for diff --git a/x.toml b/x.toml deleted file mode 100644 index f17e7281..00000000 --- a/x.toml +++ /dev/null @@ -1,14 +0,0 @@ -rpc_url = "127.0.0.1:8545" -private_key = "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318" -world_id_address = "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9" -bridge_configs = [ - [ - "Optimism", - # StaeBridge Address - "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9", - # BridgedWorldID Address - "0x4f0BF744bb79A0b919f7DED73724ec20c43572B9", - "127.0.0.1:8545", - ] -] -relaying_period_seconds = 5 From a2305e4e92f7972ee2a7c5d66275081e92c66d98 Mon Sep 17 00:00:00 2001 From: dcbuilder Date: Mon, 30 Oct 2023 15:03:02 +0000 Subject: [PATCH 08/10] remove docstring on binaries, rename new --- bin/state_bridge_service.rs | 71 +++++-------------- bin/tree_availability_service.rs | 29 +------- crates/state_bridge/src/bridge.rs | 4 +- crates/state_bridge/src/lib.rs | 4 +- crates/state_bridge/src/root.rs | 4 +- .../src/world_tree/block_scanner.rs | 2 +- .../tree_availability/src/world_tree/mod.rs | 2 +- .../src/world_tree/tree_data.rs | 2 +- .../src/world_tree/tree_updater.rs | 2 +- 9 files changed, 29 insertions(+), 91 deletions(-) diff --git a/bin/state_bridge_service.rs b/bin/state_bridge_service.rs index ae9289ac..60b108cc 100644 --- a/bin/state_bridge_service.rs +++ b/bin/state_bridge_service.rs @@ -1,38 +1,3 @@ -//! # State Bridge Service -//! -//! ### Description -//! -//! The state bridge service for the World ID protocol takes care of periodically relaying the latest roots from the World ID Identity Manager onto L2 networks or sidechains that implement native bridge on Ethereum or have an integration with third party messaging protocol. The state bridge service requires a deployment of the [`world-id-state-bridge`](github.com/worldcoin/world-id-state-bridge/) contracts which in turn also have to be connected to a valid [`world-id-contracts`](https://github.com/worldcoin/world-id-contracts/) deployment. -//! -//! ### Usage -//! -//! #### CLI -//! -//! Create a state_bridge_service.toml file which will hold the configuration parameters for the state bridge -//! service. You can use the example in the test as a template: -//! -//! ```toml -//! rpc_url = "127.0.0.1:8545" -//! private_key = "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318" -//! world_id_address = "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9" -//! bridge_configs = [ -//! [ -//! "Optimism", -//! # StateBridge Address -//! "0x3f0BF744bb79A0b919f7DED73724ec20c43572B9", -//! # BridgedWorldID Address -//! "0x4f0BF744bb79A0b919f7DED73724ec20c43572B9", -//! "127.0.0.1:8545", -//! ] -//! ] -//! relaying_period_seconds = 5 -//! ``` -//! -//! ```bash -//! cargo build --bin state-bridge-service --release -//! ./target/release/state-bridge-service --config -//! ``` - use std::fs; use std::path::PathBuf; use std::sync::Arc; @@ -51,8 +16,8 @@ use state_bridge::root::IWorldIDIdentityManager; use state_bridge::StateBridgeService; use tracing::info; -/// The state bridge service propagates roots from the world tree. Frequency of root propagation is specified -/// by the relaying_period. This service will not propagate roots that have already been propagated before. +// The state bridge service propagates roots from the world tree. Frequency of root propagation is specified +// by the relaying_period. This service will not propagate roots that have already been propagated before. #[derive(Parser, Debug)] #[clap( name = "State Bridge Service", @@ -63,7 +28,7 @@ struct Options { config: PathBuf, } -/// Converts a u64 into a Duration using Duration::from_secs +// Converts a u64 into a Duration using Duration::from_secs mod duration_seconds { use std::time::Duration; @@ -93,29 +58,29 @@ struct BridgeConfig { bridged_rpc_url: String, } -/// The config TOML file defines all the necessary parameters to spawn a state bridge service. -/// rpc_url - HTTP rpc url for an Ethereum node (string) -/// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string) -/// world_id_address - WorldIDIdentityManager contract address (string) -/// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings) -/// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings) -/// relaying_period: propagateRoot() call period time in seconds (u64) -/// block_confirmations - Number of block confirmations required for the propagateRoot call on the StateBridge contract (optional number) +// The config TOML file defines all the necessary parameters to spawn a state bridge service. +// rpc_url - HTTP rpc url for an Ethereum node (string) +// private_key - pk to an address that will call the propagateRoot() method on the StateBridge contract (string) +// world_id_address - WorldIDIdentityManager contract address (string) +// bridge_pair_addresses - List of StateBridge and BridgedWorldID contract address pairs (strings) +// bridged_world_id_addresses - List of BridgedWorldID contract addresses (strings) +// relaying_period: propagateRoot() call period time in seconds (u64) +// block_confirmations - Number of block confirmations required for the propagateRoot call on the StateBridge contract (optional number) #[derive(Deserialize, Serialize, Debug, Clone)] struct Config { - /// RPC URL for the HTTP provider (World ID IdentityManager) + // RPC URL for the HTTP provider (World ID IdentityManager) rpc_url: String, - /// Private key to use for the middleware signer + // Private key to use for the middleware signer private_key: String, - /// `WorldIDIdentityManager` contract address + // `WorldIDIdentityManager` contract address world_id_address: H160, - /// List of `StateBridge` and `BridgedWorldID` pair addresses + // List of `StateBridge` and `BridgedWorldID` pair addresses bridge_configs: Vec, - /// `propagateRoot()` call period time in seconds + // `propagateRoot()` call period time in seconds #[serde(with = "duration_seconds")] relaying_period_seconds: Duration, - /// Number of block confirmations required for the `propagateRoot` call on the `StateBridge` - /// contract + // Number of block confirmations required for the `propagateRoot` call on the `StateBridge` + // contract #[serde(default = "default_block_confirmations")] block_confirmations: usize, } diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index 919b144c..4c1657e4 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -1,30 +1,3 @@ -//! # Tree Availability Service -//! -//! The tree availability service is able to create an in-memory representation of the World ID -//! merkle tree by syncing the state of the World ID contract `registerIdentities` and `deleteIdentities` -//! function calldata and `TreeChanged` events. Once it syncs the latest state of the state of the tree, it -//! is able to serve inclusion proofs on the `/inclusionProof` endpoint. It also keeps a historical roots list -//! of `tree_history_size` size in order to serve proofs against older tree roots (including the roots of -//! World IDs bridged to other networks). -//! -//! ### Usage -//! -//! #### CLI -//! -//! In order to run the tree availability service you can run the following commands -//! -//! ```bash -//! # Build the binary -//! cargo build --bin tree-availability-service --release -//! # Run the command -//! ./target/release/tree-availability-service -//! --tree-depth -//! --tree-history-size -//! --dense-prefix-depth -//! --address
-//! --creation-block -//! --rpc-endpoint - use std::sync::Arc; use clap::Parser; @@ -34,7 +7,7 @@ use futures::stream::FuturesUnordered; use futures::StreamExt; use tree_availability::TreeAvailabilityService; -/// CLI interface for the Tree Availability Service +// CLI interface for the Tree Availability Service #[derive(Parser, Debug)] #[clap( name = "Tree Availability Service", diff --git a/crates/state_bridge/src/bridge.rs b/crates/state_bridge/src/bridge.rs index 929482f4..91432ca3 100644 --- a/crates/state_bridge/src/bridge.rs +++ b/crates/state_bridge/src/bridge.rs @@ -43,7 +43,7 @@ pub struct StateBridge { } impl StateBridge { - /// Constructor + /// Initializes a StateBridge /// /// `state_bridge`: `StateBridge` contract interface /// @@ -66,7 +66,7 @@ impl StateBridge { }) } - /// Constructor with address and middleware + /// Initializes a StateBridge with address and middleware /// /// `bridge_address`: `StateBridge` contract address /// diff --git a/crates/state_bridge/src/lib.rs b/crates/state_bridge/src/lib.rs index 01b1df49..a724d937 100644 --- a/crates/state_bridge/src/lib.rs +++ b/crates/state_bridge/src/lib.rs @@ -35,7 +35,7 @@ impl StateBridgeService where M: Middleware, { - /// ### Constructor for the `StateBridgeService` + /// Initializes the `StateBridgeService` /// /// `world_tree`:`IWorldID ` - interface to the `WorldIDIdentityManager` pub async fn new( @@ -48,7 +48,7 @@ where }) } - /// Constructor for the `StateBridgeService` + /// Initializes the `StateBridgeService` /// /// `world_tree_address`:`H160` - interface to the `WorldIDIdentityManager` /// diff --git a/crates/state_bridge/src/root.rs b/crates/state_bridge/src/root.rs index 82b904c7..5c16e8d2 100644 --- a/crates/state_bridge/src/root.rs +++ b/crates/state_bridge/src/root.rs @@ -37,7 +37,7 @@ impl WorldTreeRoot where M: Middleware, { - /// `WorldTreeRoot` constructor + /// Initializes `WorldTreeRoot` /// /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface pub async fn new( @@ -51,7 +51,7 @@ where }) } - /// `WorldTreeRoot` constructor from address and middleware + /// Initializes `WorldTreeRoot` from address and middleware /// /// `world_id_identity_manager`:`IWorldIDIdentityManager` - `WorldIDIdentityManager` interface /// diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index 4b001818..4181e55e 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -19,7 +19,7 @@ impl BlockScanner where M: Middleware, { - /// Constructor + /// Initializes a BlockScanner pub const fn new( middleware: M, window_size: u64, diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index 7ff23dd0..7a2e9c5d 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -33,7 +33,7 @@ pub struct WorldTree { } impl WorldTree { - /// Constructor + /// Initializes WorldTree pub fn new( tree: PoseidonTree, tree_history_size: usize, diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index 925aff78..f939f88c 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -25,7 +25,7 @@ pub struct TreeUpdate { } impl TreeData { - /// Constructor + /// Initializes TreeData /// /// `tree`: Canonical in-memory tree /// diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index 4d17c90d..5a3e9f1e 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -34,7 +34,7 @@ pub struct TreeUpdater { } impl TreeUpdater { - /// Constructor + /// Initializes TreeUpdater /// /// `address`: `WorldIDIdentityManager` contract address /// From 3f2be7fd65ebb8fabab72b6dbea3c3db11834283 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 14:46:06 -0400 Subject: [PATCH 09/10] updating docs --- crates/tree_availability/src/lib.rs | 36 +++++++---- crates/tree_availability/src/server.rs | 6 +- .../src/world_tree/block_scanner.rs | 11 ++-- .../tree_availability/src/world_tree/mod.rs | 19 +++++- .../src/world_tree/tree_data.rs | 59 +++++++++---------- 5 files changed, 81 insertions(+), 50 deletions(-) diff --git a/crates/tree_availability/src/lib.rs b/crates/tree_availability/src/lib.rs index d89fa61b..0a7282e9 100644 --- a/crates/tree_availability/src/lib.rs +++ b/crates/tree_availability/src/lib.rs @@ -23,20 +23,27 @@ use world_tree::{Hash, PoseidonTree, WorldTree}; use crate::server::{inclusion_proof, synced}; -/// The tree availability service data structure +/// Service that keeps the World Tree synced with `WorldIDIdentityManager` and exposes an API endpoint to serve inclusion proofs for a given World ID. pub struct TreeAvailabilityService { - /// The World ID merkle tree synced from the `WorldIDIdentityManager` contract + /// In-memory representation of the merkle tree containing all verified World IDs. pub world_tree: Arc>, } impl TreeAvailabilityService { - /// Initializes new instance of TreeAvailabilityService - /// `tree_depth`: the depth of the World ID contract (currently 30 in production - Nov 2023) - /// `dense_prefix_depth`: what is the depth of the tree that is densely populated (currently depth 10) - /// `tree_history_size`: how many historical roots and derived trees to hold in memory to serve proofs for - /// `world_tree_address`: `WorldIDIdentityManager` contract address - /// `world_tree_creation_block`: block at which `WorldIDIdentityManager` contract was deployed - /// `middleware`: Ethereum provider + /// Initializes new instance of `TreeAvailabilityService`, + /// + /// # Arguments + /// + /// * `tree_depth` - Depth of the merkle tree + /// * `dense_prefix_depth`: Depth of the tree that is densely populated. Nodes beyond the `dense_prefix_depth` will be stored through pointer based structures. + /// * `tree_history_size`: Number of historical roots to store in memory. This is used to serve proofs against historical roots. + /// * `world_tree_address`: Address of the `WorldIDIdentityManager` contract onchain + /// * `world_tree_creation_block`: Block number where `WorldIDIdentityManager` was deployed + /// * `middleware`: Provider to interact with Ethereum + /// + /// # Returns + /// + /// New instance of `TreeAvailabilityService`. pub fn new( tree_depth: usize, dense_prefix_depth: usize, @@ -62,8 +69,15 @@ impl TreeAvailabilityService { Self { world_tree } } - /// Spins up the /inclusionProof endpoint to serve proofs of inclusion for the World ID tree - /// `port`: which port on the machine will serve HTTP requests + /// Spawns an axum server and exposes an API endpoint to serve inclusion proofs for a given World ID. This function also spawns a new task to keep the world tree synced to the chain head. + /// + /// # Arguments + /// + /// * `port` - Port to bind the server to. + /// + /// # Returns + /// + /// Vector of `JoinHandle`s for the spawned tasks. pub async fn serve( self, port: u16, diff --git a/crates/tree_availability/src/server.rs b/crates/tree_availability/src/server.rs index 4a48a6a3..33239b11 100644 --- a/crates/tree_availability/src/server.rs +++ b/crates/tree_availability/src/server.rs @@ -130,10 +130,12 @@ pub async fn synced( impl TreeError { fn to_status_code(&self) -> StatusCode { - //TODO: update this - StatusCode::BAD_REQUEST + match self { + TreeError::TreeNotSynced => StatusCode::SERVICE_UNAVAILABLE, + } } } + impl IntoResponse for TreeError { fn into_response(self) -> axum::response::Response { let status_code = self.to_status_code(); diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index 4181e55e..48a6b388 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -11,7 +11,7 @@ pub struct BlockScanner { middleware: M, /// The block from which to start parsing a given event current_block: AtomicU64, - /// Event window + /// The maximum block range to parse window_size: u64, } @@ -19,7 +19,7 @@ impl BlockScanner where M: Middleware, { - /// Initializes a BlockScanner + /// Initializes a new `BlockScanner` pub const fn new( middleware: M, window_size: u64, @@ -32,11 +32,12 @@ where } } - /// Returns a list of specified events that were emitted by a given smart contract address + /// Retrieves events matching the specified address and topics from the last synced block to the latest block. /// - /// `address`: Address of the contract that we want to listen to events in + /// # Arguments /// - /// `topics`: The topics of the events the `BlockScanner` will listen to and parse + /// * `address` - Optional address to target when fetching logs. + /// * `topics` - Optional topics to target when fetching logs, enabling granular filtering when looking for specific event signatures or topic values. pub async fn next( &self, address: Option>, diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index 7a2e9c5d..cf72cd87 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -33,7 +33,19 @@ pub struct WorldTree { } impl WorldTree { - /// Initializes WorldTree + /// Initializes a new instance of `WorldTree`. + /// + /// # Arguments + /// + /// * `tree` - The PoseidonTree used for the merkle tree representation. + /// * `tree_history_size` - The number of historical tree roots to keep in memory. + /// * `address` - The smart contract address of the `WorldIDIdentityManager`. + /// * `creation_block` - The block number at which the contract was deployed. + /// * `middleware` - Provider to interact with Ethereum. + /// + /// # Returns + /// + /// New instance of `WorldTree`. pub fn new( tree: PoseidonTree, tree_history_size: usize, @@ -51,6 +63,11 @@ impl WorldTree { } } + /// Spawns a task that continually syncs the `TreeData` to the state at the chain head. + /// + /// # Returns + /// + /// A `JoinHandle` that resolves to a `Result<(), TreeAvailabilityError>` when the spawned task completes. pub async fn spawn( &self, ) -> JoinHandle>> { diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index f939f88c..1e28987c 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -7,29 +7,25 @@ use tokio::sync::RwLock; use super::{Hash, PoseidonTree}; use crate::server::InclusionProof; -/// The `TreeData` structure represents the in-memory representation of the tree as well as its historic -/// versions up to `tree_history_size`. +/// Represents the in-memory state of the World Tree, caching historical roots up to `tree_history_size`. pub struct TreeData { - /// Tree holding all leaves + /// A canonical in-memory representation of the World Tree. pub tree: RwLock>, - /// Number of most recent historical roots `WorldTree` keeps to be able to serve proofs for + /// The number of historical tree roots to cache for serving older proofs. pub tree_history_size: usize, - /// Array of derived trees for each historical root - pub tree_history: RwLock>>, //TODO: make a note that the latest is at the front -} -/// Defines how the tree changed -pub struct TreeUpdate { - pub index: usize, - /// New hash of the tree - pub value: Hash, + /// Cache of historical tree state, used to serve proofs against older roots. If the cache becomes larger than `tree_history_size`, the oldest roots are removed on a FIFO basis. + pub tree_history: RwLock>>, } impl TreeData { - /// Initializes TreeData + /// Initializes a new instance of `TreeData`. + /// + /// * `tree` - PoseidonTree representing the World Tree onchain, which will be used to generate inclusion proofs. + /// * `tree_history_size` - Number of previous tree states to retain for serving proofs with historical roots. /// - /// `tree`: Canonical in-memory tree + /// # Returns /// - /// `tree_history_size`: Number of most recent historical roots that the `WorldTree` can serve proofs for + /// A new `TreeData` instance. pub fn new( tree: PoseidonTree, tree_history_size: usize, @@ -41,11 +37,12 @@ impl TreeData { } } - /// Inserts identities at a given starting index. + /// Inserts multiple identity commitments starting from a specified index. The tree state before the insert operation is cached to tree history. /// - /// `start_index`: Index at which to start inserting identity commitments + /// # Arguments /// - /// `identities`: Identity commitments + /// * `start_index` - The leaf index in the tree to begin inserting identity commitments. + /// * `identities` - The array of identity commitments to insert. pub async fn insert_many_at( &self, start_index: usize, @@ -59,9 +56,11 @@ impl TreeData { } } - /// Deletes identity commitments in the `WorldTree` at the specified indices. + /// Deletes multiple identity commitments at specified indices. The tree state before the delete operation is cached to tree history. /// - /// `delete_indices`: positions of the identity commitments in the tree to be deleted + /// # Arguments + /// + /// * `delete_indices` - The indices of the leaves in the tree to delete. pub async fn delete_many(&self, delete_indices: &[usize]) { self.cache_tree_history().await; @@ -72,8 +71,7 @@ impl TreeData { } } - /// Caches the historical tree representations in memory in order for the `WorldTree` to be able to serve - /// proofs against their roots + /// Caches the current tree state to `tree_history` if `tree_history_size` is greater than 0. pub async fn cache_tree_history(&self) { if self.tree_history_size != 0 { let mut tree_history = self.tree_history.write().await; @@ -86,14 +84,12 @@ impl TreeData { } } - /// Fetches the inclusion proof of the provided identity at the given root hash - /// - /// `identity`: Identity commitment to fetch the inclusion proof for + /// Fetches the inclusion proof for a given identity against a specified root. If no root is specified, the latest root is used. Returns `None` if root or identity is not found. /// - /// `root`: The root against which the `WorldTree` will serve the inclusion proof against + /// # Arguments /// - /// Returns None if the provided root hash is not in the latest one or is not present in tree history - /// or if the identity is not present in the tree. + /// * `identity` - The identity commitment for which to fetch the inclusion proof. + /// * `root` - Optional root hash to serve the inclusion proof against. If `None`, uses the latest root. pub async fn get_inclusion_proof( &self, identity: Hash, @@ -136,11 +132,12 @@ impl TreeData { } } - /// Returns an inclusion proof for a given identity commitment in the specified tree + /// Generates an inclusion proof for a specific identity commitment from a given `PoseidonTree`. /// - /// `tree`: The `WorldTree` (canonical or derived) to fetch the inclusion proof against + /// # Arguments /// - /// `identity`: Identity commitment to create the inclusion proof for + /// * `tree` - The Poseidon tree to fetch the inclusion proof against. + /// * `identity` - The identity commitment to generate the inclusion proof for. fn proof( tree: &PoseidonTree, identity: Hash, From efc0efefb63e6652484dcf6d24b19b66eed7a2cf Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 15:07:07 -0400 Subject: [PATCH 10/10] updating docs --- bin/tree_availability_service.rs | 1 - crates/tree_availability/src/server.rs | 4 +- .../tree_availability/src/world_tree/mod.rs | 9 ++++- .../src/world_tree/tree_updater.rs | 40 +++++++++++-------- .../tests/inclusion_proof.rs | 6 +-- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index 4c1657e4..7b89a83d 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -7,7 +7,6 @@ use futures::stream::FuturesUnordered; use futures::StreamExt; use tree_availability::TreeAvailabilityService; -// CLI interface for the Tree Availability Service #[derive(Parser, Debug)] #[clap( name = "Tree Availability Service", diff --git a/crates/tree_availability/src/server.rs b/crates/tree_availability/src/server.rs index 33239b11..aca2ddc2 100644 --- a/crates/tree_availability/src/server.rs +++ b/crates/tree_availability/src/server.rs @@ -81,7 +81,7 @@ pub async fn inclusion_proof( State(world_tree): State>>, Json(req): Json, ) -> Result<(StatusCode, Json>), TreeError> { - if world_tree.tree_updater.synced.load(Ordering::Relaxed) { + if world_tree.synced.load(Ordering::Relaxed) { let inclusion_proof = world_tree .tree_data .get_inclusion_proof(req.identity_commitment, req.root) @@ -112,7 +112,7 @@ impl SyncResponse { pub async fn synced( State(world_tree): State>>, ) -> (StatusCode, Json) { - if world_tree.tree_updater.synced.load(Ordering::Relaxed) { + if world_tree.synced.load(Ordering::Relaxed) { (StatusCode::OK, SyncResponse::new(true, None).into()) } else { let latest_synced_block = Some( diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index cf72cd87..1d3d9ef6 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -3,7 +3,7 @@ pub mod block_scanner; pub mod tree_data; pub mod tree_updater; -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; @@ -30,6 +30,8 @@ pub struct WorldTree { pub tree_data: Arc, /// The object in charge of syncing the tree from calldata pub tree_updater: Arc>, + /// Boolean to indicate when the tree state is synced wth the chain head upon spawning the `WorldTree`. + pub synced: Arc, } impl WorldTree { @@ -60,6 +62,7 @@ impl WorldTree { creation_block, middleware, )), + synced: Arc::new(AtomicBool::new(false)), } } @@ -73,9 +76,11 @@ impl WorldTree { ) -> JoinHandle>> { let tree_data = self.tree_data.clone(); let tree_updater = self.tree_updater.clone(); + let synced = self.synced.clone(); + tokio::spawn(async move { tree_updater.sync_to_head(&tree_data).await?; - tree_updater.synced.store(true, Ordering::Relaxed); + synced.store(true, Ordering::Relaxed); loop { tree_updater.sync_to_head(&tree_data).await?; diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index 5a3e9f1e..b7d9d984 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -19,17 +19,15 @@ use crate::world_tree::Hash; // TODO: Change to a configurable parameter const SCANNING_WINDOW_SIZE: u64 = 100; -/// The `TreeUpdater` holds the necessary data to be able to sync the World ID tree -/// from Ethereum calldata and events emitted by the `WorldIDIdentityManager` contracts +/// Manages the synchronization of the World Tree with it's onchain representation. pub struct TreeUpdater { - /// `address`: `WorldIDIdentityManager` contract address + /// Contract address of the `WorldIDIdentityManager`. pub address: H160, + /// Latest block that has been synced. pub latest_synced_block: AtomicU64, - /// `synced`: has the updater finished syncing up to the latest canonical onchain tree - pub synced: AtomicBool, - /// `block_scanner`: utility tool to parse calldata and events + /// Scanner responsible for fetching logs and parsing calldata to decode tree updates. block_scanner: BlockScanner>, - /// `middleware`: provider + /// Provider to interact with Ethereum. pub middleware: Arc, } @@ -45,7 +43,6 @@ impl TreeUpdater { Self { address, latest_synced_block: AtomicU64::new(creation_block), - synced: AtomicBool::new(false), block_scanner: BlockScanner::new( middleware.clone(), SCANNING_WINDOW_SIZE, @@ -55,9 +52,11 @@ impl TreeUpdater { } } - /// Sync the state of the tree to to the chain head + /// Updates the in-memory tree to reflect the latest state of the onchain tree. + /// + /// # Arguments /// - /// `tree_data`: Data structure holding the tree's currently synced state + /// * `tree_data` - Instance of `TreeData` maintaining the current state of the tree and tree history. pub async fn sync_to_head( &self, tree_data: &TreeData, @@ -107,11 +106,12 @@ impl TreeUpdater { Ok(()) } - /// Syncs the tree data from a provided onchain transaction + /// Updates the in-memory tree based transaction calldata. /// - /// `tree_data`: Data structure holding the tree's currently synced state + /// # Arguments /// - /// `transaction`: onchain transaction object + /// * `tree_data` - Instance of `TreeData` maintaining the current state of the tree and tree history. + /// * `transaction` - Transaction containing the calldata necessary to update the local tree. pub async fn sync_from_transaction( &self, tree_data: &TreeData, @@ -155,8 +155,11 @@ impl TreeUpdater { } } -/// Converts an array of indices into a tightly packed vector of bytes -/// `indices`: array of 32 bit integers that represent the position of identity commitments in the `WorldTree` +/// Packs an array of 32-bit indices into a contiguous byte vector. +/// +/// # Arguments +/// +/// * `indices` - The array of indices representing positions of identity commitments in the `WorldTree`. pub fn pack_indices(indices: &[u32]) -> Vec { let mut packed = Vec::with_capacity(indices.len() * 4); @@ -167,8 +170,11 @@ pub fn pack_indices(indices: &[u32]) -> Vec { packed } -/// Converts a packed array of bytes into a vector of 32 bit integers -/// `packed`: packed indices holding the positions of identity commitments in the `WorldTree` +/// Unpacks a contiguous byte array into a vector of 32-bit indices. +/// +/// # Arguments +/// +/// * `packed` - The packed byte array containing positions of identity commitments in the `WorldTree`. pub fn unpack_indices(packed: &[u8]) -> Vec { let mut indices = Vec::with_capacity(packed.len() / 4); diff --git a/crates/tree_availability/tests/inclusion_proof.rs b/crates/tree_availability/tests/inclusion_proof.rs index 50b57f34..4b67a7b9 100644 --- a/crates/tree_availability/tests/inclusion_proof.rs +++ b/crates/tree_availability/tests/inclusion_proof.rs @@ -79,11 +79,7 @@ async fn test_inclusion_proof() -> eyre::Result<()> { // Wait for the tree to be synced loop { - if world_tree - .tree_updater - .synced - .load(std::sync::atomic::Ordering::Relaxed) - { + if world_tree.synced.load(std::sync::atomic::Ordering::Relaxed) { break; }