diff --git a/.integration/Cargo.toml b/.integration/Cargo.toml index 8cb3dd6cd1..7f55636505 100644 --- a/.integration/Cargo.toml +++ b/.integration/Cargo.toml @@ -27,7 +27,6 @@ path = "../node/ledger" [dev-dependencies.snarkvm] workspace = true -default-features = false features = ["synthesizer"] [dev-dependencies.tokio] diff --git a/Cargo.lock b/Cargo.lock index 37069a0468..dec7e13a74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,6 +43,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.3" @@ -117,7 +128,7 @@ checksum = "6118baab6285accf088b31d5ea5029c37bbf9d98e62b4d8720a0a5a66bc2e427" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -155,9 +166,9 @@ checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -167,34 +178,35 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-stream" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", + "pin-project-lite", ] [[package]] name = "async-stream-impl" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] name = "async-trait" -version = "0.1.66" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] @@ -257,9 +269,9 @@ dependencies = [ [[package]] name = "bincode" -version = "2.0.0-rc.2" +version = "2.0.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb50c5a2ef4b9b1e7ae73e3a73b52ea24b20312d629f9c4df28260b7ad2c3c4" +checksum = "f11ea1a0346b94ef188834a65c068a03aec181c94896d481d7a0a40d85b0ce95" dependencies = [ "bincode_derive", "serde", @@ -267,9 +279,9 @@ dependencies = [ [[package]] name = "bincode_derive" -version = "2.0.0-rc.2" +version = "2.0.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a45a23389446d2dd25dc8e73a7a3b3c43522b630cac068927f0649d43d719d2" +checksum = "7e30759b3b99a1b802a7a3aa21c85c3ded5c28e1c83170d82d70f08bbf7f3e4c" dependencies = [ "virtue", ] @@ -291,7 +303,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -322,9 +334,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -335,16 +347,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" -[[package]] -name = "buf_redux" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" -dependencies = [ - "memchr", - "safemem", -] - [[package]] name = "bumpalo" version = "3.12.0" @@ -434,9 +436,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "num-integer", @@ -464,9 +466,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.4.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -500,7 +502,7 @@ dependencies = [ "proc-macro-error", "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -548,9 +550,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" [[package]] name = "core-foundation" @@ -564,15 +566,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" dependencies = [ "libc", ] @@ -588,9 +590,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -598,9 +600,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -609,22 +611,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.13" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", ] @@ -706,9 +708,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.59+curl-7.86.0" +version = "0.4.61+curl-8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cfce34829f448b08f55b7db6d0009e23e2e86a34e8c2b366269bf5799b4a407" +checksum = "14d05c10f541ae6f3bc5b3d923c20001f47db7d5f0b2bc6ad16490133842db79" dependencies = [ "cc", "libc", @@ -735,9 +737,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -747,9 +749,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting", @@ -757,24 +759,24 @@ dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", "scratch", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] name = "cxxbridge-flags" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] @@ -807,7 +809,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -890,13 +892,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -920,9 +922,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.17" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a214f5bb88731d436478f3ae1f8a277b62124089ba9fb67f4f93fb100ef73c90" +checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" [[package]] name = "flate2" @@ -972,9 +974,9 @@ checksum = "c1fd087255f739f4f1aeea69f11b72f8080e9c2e7645cd06955dad4a178a49e3" [[package]] name = "futures" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -987,9 +989,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -997,15 +999,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -1015,38 +1017,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -1071,9 +1073,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1090,13 +1092,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -1117,9 +1119,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" dependencies = [ "bytes", "fnv", @@ -1139,6 +1141,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.6", +] [[package]] name = "hashbrown" @@ -1146,7 +1151,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash", + "ahash 0.8.3", ] [[package]] @@ -1198,6 +1203,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -1240,9 +1251,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.24" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -1277,16 +1288,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] @@ -1344,19 +1355,20 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.5" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "ipnet" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "itertools" @@ -1369,15 +1381,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] @@ -1393,11 +1405,11 @@ dependencies = [ [[package]] name = "jsonwebtoken" -version = "8.2.0" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f4f04699947111ec1733e71778d763555737579e44b85844cae8e1940a1828" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "pem", "ring", "serde", @@ -1412,7 +1424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b367a58a53900cadde9087e3290dbf00dc5e85f94904bd017c43d6c7bb5782" dependencies = [ "async-trait", - "bincode 2.0.0-rc.2", + "bincode 2.0.0-rc.3", "bytes", "parking_lot", "rand", @@ -1435,9 +1447,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" [[package]] name = "libloading" @@ -1457,9 +1469,9 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "librocksdb-sys" -version = "0.8.3+7.4.4" +version = "0.10.0+7.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "557b255ff04123fcc176162f56ed0c9cd42d8f357cf55b3fabeb60f7413741b3" +checksum = "0fe4d5874f5ff2bc616e55e8c6086d478fcda13faf9495768a4aa1c22042d30b" dependencies = [ "bindgen", "bzip2-sys", @@ -1467,6 +1479,7 @@ dependencies = [ "glob", "libc", "libz-sys", + "lz4-sys", ] [[package]] @@ -1498,9 +1511,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" [[package]] name = "lock_api" @@ -1521,6 +1534,25 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lz4-sys" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "matchers" version = "0.0.1" @@ -1554,11 +1586,78 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "metrics" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b9b8653cec6897f73b519a43fba5ee3d50f62fe9af80b428accdcc093b4a849" +dependencies = [ + "ahash 0.7.6", + "metrics-macros", + "portable-atomic", +] + +[[package]] +name = "metrics-exporter-prometheus" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8603921e1f54ef386189335f288441af761e0fc61bcb552168d9cedfe63ebc70" +dependencies = [ + "hyper", + "indexmap", + "ipnet", + "metrics", + "metrics-util", + "parking_lot", + "portable-atomic", + "quanta", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "metrics-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "731f8ecebd9f3a4aa847dfe75455e4757a45da40a7793d2f0b1f9b6ed18b23f3" +dependencies = [ + "proc-macro2 1.0.56", + "quote 1.0.26", + "syn 1.0.109", +] + +[[package]] +name = "metrics-util" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d24dc2dbae22bff6f1f9326ffce828c9f07ef9cc1e8002e5279f845432a30a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", + "hashbrown 0.12.3", + "metrics", + "num_cpus", + "parking_lot", + "portable-atomic", + "quanta", + "sketches-ddsketch", +] + [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" @@ -1593,26 +1692,22 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.45.0", ] [[package]] -name = "multipart" -version = "0.18.0" +name = "multiparty" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00dec633863867f29cb39df64a397cdf4a6354708ddd7759f70c7fb51c5f9182" +checksum = "ed1ec6589a6d4a1e0b33b4c0a3f6ee96dfba88ebdb3da51403fd7cf0a24a4b04" dependencies = [ - "buf_redux", + "bytes", + "futures-core", "httparse", - "log", - "mime", - "mime_guess", - "quick-error", - "rand", - "safemem", - "tempfile", - "twoway", + "memchr", + "pin-project-lite", + "try-lock", ] [[package]] @@ -1648,7 +1743,7 @@ dependencies = [ "bitflags", "cfg-if", "libc", - "memoffset", + "memoffset 0.7.1", "pin-utils", "static_assertions", ] @@ -1692,7 +1787,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1757,9 +1852,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.45" +version = "0.10.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +checksum = "7e30d8bc91859781f0a943411186324d580f2bbeb71b452fe91ae344806af3f1" dependencies = [ "bitflags", "cfg-if", @@ -1772,13 +1867,13 @@ dependencies = [ [[package]] name = "openssl-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] @@ -1789,11 +1884,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.80" +version = "0.9.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", @@ -1802,9 +1896,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" [[package]] name = "overload" @@ -1840,7 +1934,7 @@ checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "windows-sys 0.45.0", ] @@ -1911,7 +2005,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1982,7 +2076,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", "version_check", ] @@ -2016,18 +2110,19 @@ dependencies = [ ] [[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-xml" -version = "0.22.0" +name = "quanta" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" +checksum = "b7e31331286705f455e56cca62e0e717158474ff02b7936c1fa596d983f4ae27" dependencies = [ - "memchr", + "crossbeam-utils", + "libc", + "mach", + "once_cell", + "raw-cpuid", + "wasi 0.10.2+wasi-snapshot-preview1", + "web-sys", + "winapi", ] [[package]] @@ -2102,6 +2197,15 @@ dependencies = [ "rand_core", ] +[[package]] +name = "raw-cpuid" +version = "10.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +dependencies = [ + "bitflags", +] + [[package]] name = "rayon" version = "1.7.0" @@ -2133,6 +2237,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -2140,15 +2253,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "regex" -version = "1.7.1" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" dependencies = [ "aho-corasick", "memchr", @@ -2166,15 +2279,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "reqwest" -version = "0.11.14" +version = "0.11.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" dependencies = [ "base64 0.21.0", "bytes", @@ -2224,9 +2337,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9562ea1d70c0cc63a34a22d977753b50cca91cc6b6527750463bd5dd8697bc" +checksum = "015439787fce1e75d55f279078d33ff14b4af5d93d995e8838ee4631301c8a99" dependencies = [ "libc", "librocksdb-sys", @@ -2249,16 +2362,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.8" +version = "0.37.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2275,11 +2388,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "0.2.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", ] [[package]] @@ -2296,15 +2409,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" - -[[package]] -name = "safemem" -version = "0.3.3" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -2338,9 +2445,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -2377,14 +2484,14 @@ dependencies = [ [[package]] name = "self_update" -version = "0.34.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b28d58e73c427061f46c801176f54349be3c1a2818cf549e1d9bcac37eef7bca" +checksum = "2e18819cd93c4799f93cd4cf0ac069ed0e615fea3af28ec78df71e0ea890628a" dependencies = [ "hyper", "indicatif", "log", - "quick-xml 0.22.0", + "quick-xml", "regex", "reqwest", "semver", @@ -2401,7 +2508,7 @@ dependencies = [ "hyper", "indicatif", "log", - "quick-xml 0.23.1", + "quick-xml", "regex", "reqwest", "semver", @@ -2412,9 +2519,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" @@ -2438,9 +2545,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "indexmap", "itoa", @@ -2482,18 +2589,7 @@ checksum = "079a83df15f85d89a68d64ae1238f142f172b1fa915d0d76b26a7cba1b659a69" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", -] - -[[package]] -name = "sha-1" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", + "syn 1.0.109", ] [[package]] @@ -2575,11 +2671,17 @@ dependencies = [ "time", ] +[[package]] +name = "sketches-ddsketch" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a406c1882ed7f29cd5e248c9848a80e7cb6ae0fea82346d2746f2f941c07e1" + [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -2609,6 +2711,7 @@ dependencies = [ "snarkos-node-router", "snarkos-node-store", "snarkos-node-tcp", + "tikv-jemallocator", "walkdir", ] @@ -2638,7 +2741,7 @@ dependencies = [ "rand", "rand_chacha", "rayon", - "self_update 0.34.0", + "self_update 0.35.0", "serde", "serde_json", "snarkos-account", @@ -2780,6 +2883,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "snarkos-node-metrics" +version = "2.0.2" +dependencies = [ + "metrics", + "metrics-exporter-prometheus", + "tokio", +] + [[package]] name = "snarkos-node-rest" version = "0.9.0" @@ -2789,6 +2901,7 @@ dependencies = [ "indexmap", "jsonwebtoken", "once_cell", + "parking_lot", "rand", "rayon", "serde", @@ -2829,7 +2942,7 @@ dependencies = [ "snarkos-node-router", "snarkos-node-tcp", "snarkvm", - "snarkvm-utilities 0.9.13", + "snarkvm-utilities 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)", "time", "tokio", "tokio-stream", @@ -2891,7 +3004,7 @@ dependencies = [ "snarkvm-console", "snarkvm-parameters", "snarkvm-synthesizer", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "thiserror", "ureq", "walkdir", @@ -2919,7 +3032,7 @@ dependencies = [ "snarkvm-fields", "snarkvm-parameters", "snarkvm-r1cs", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "thiserror", ] @@ -2983,7 +3096,7 @@ dependencies = [ "snarkvm-curves", "snarkvm-fields", "snarkvm-r1cs", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", ] [[package]] @@ -3012,7 +3125,7 @@ dependencies = [ "snarkvm-circuit-network", "snarkvm-circuit-types", "snarkvm-console-program", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", ] [[package]] @@ -3140,7 +3253,7 @@ dependencies = [ "smallvec", "snarkvm-console-types", "snarkvm-fields", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", ] [[package]] @@ -3174,7 +3287,7 @@ dependencies = [ "snarkvm-curves", "snarkvm-fields", "snarkvm-parameters", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", ] [[package]] @@ -3191,7 +3304,7 @@ dependencies = [ "serde", "snarkvm-curves", "snarkvm-fields", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", ] [[package]] @@ -3210,7 +3323,7 @@ dependencies = [ "snarkvm-console-collections", "snarkvm-console-network", "snarkvm-console-types", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", ] [[package]] @@ -3308,7 +3421,7 @@ dependencies = [ "rustc_version", "serde", "snarkvm-fields", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "thiserror", ] @@ -3325,7 +3438,7 @@ dependencies = [ "rand", "rayon", "serde", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "thiserror", ] @@ -3350,7 +3463,7 @@ dependencies = [ "serde_json", "sha2", "snarkvm-curves", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "thiserror", ] @@ -3366,7 +3479,7 @@ dependencies = [ "itertools", "snarkvm-curves", "snarkvm-fields", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "thiserror", ] @@ -3393,25 +3506,28 @@ dependencies = [ "snarkvm-console", "snarkvm-curves", "snarkvm-fields", - "snarkvm-utilities 0.9.16", + "snarkvm-utilities 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "tracing", "ureq", ] [[package]] name = "snarkvm-utilities" -version = "0.9.13" +version = "0.9.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34724eac8768fbc1c39b09f925b1fca52c264280c28b40137a91c09a3148b4de" +checksum = "e34038d6351815ade16f1d7fe6d34fc723b990a9e200ee7dda5c8e3785f914f8" dependencies = [ + "aleo-std", "anyhow", "bincode 1.3.3", "num-bigint", + "num_cpus", "rand", "rand_xorshift", + "rayon", "serde", "serde_json", - "snarkvm-utilities-derives 0.9.13", + "snarkvm-utilities-derives 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", ] @@ -3430,19 +3546,19 @@ dependencies = [ "rayon", "serde", "serde_json", - "snarkvm-utilities-derives 0.9.16", + "snarkvm-utilities-derives 0.9.16 (git+https://github.com/AleoHQ/snarkVM.git?rev=a42905e)", "thiserror", ] [[package]] name = "snarkvm-utilities-derives" -version = "0.9.13" +version = "0.9.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a06c52a5ceba9b9159f1b8cc3ca29bd5da16f339e4eb077cfc9024c813f2b86" +checksum = "541b2488455c3194799b66349714f7891c47d7a7d16413c3b46c0ab280102d4f" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] @@ -3473,9 +3589,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -3529,9 +3645,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", @@ -3560,15 +3676,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -3588,22 +3704,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] @@ -3616,6 +3732,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.3+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.20" @@ -3660,14 +3796,13 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.26.0" +version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "num_cpus", "parking_lot", @@ -3680,13 +3815,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.8.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 2.0.15", ] [[package]] @@ -3701,9 +3836,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite", @@ -3725,9 +3860,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" +checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" dependencies = [ "futures-util", "log", @@ -3785,7 +3920,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -3891,7 +4026,7 @@ checksum = "c49adbab879d2e0dd7f75edace5f0ac2156939ecb7e6a1e8fa14e53728328c48" dependencies = [ "lazy_static", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -3902,7 +4037,7 @@ checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" dependencies = [ "lazy_static", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -3926,9 +4061,9 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" dependencies = [ "base64 0.13.1", "byteorder", @@ -3937,21 +4072,12 @@ dependencies = [ "httparse", "log", "rand", - "sha-1", + "sha1", "thiserror", "url", "utf-8", ] -[[package]] -name = "twoway" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1" -dependencies = [ - "memchr", -] - [[package]] name = "typenum" version = "1.16.0" @@ -3969,15 +4095,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -4089,18 +4215,17 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "virtue" -version = "0.0.8" +version = "0.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b60dcd6a64dd45abf9bd426970c9843726da7fc08f44cd6fcebf68c21220a63" +checksum = "9dcc60c0624df774c82a0ef104151231d37da4962957d691c011c852b2473314" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -4116,9 +4241,9 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed7b8be92646fc3d18b06147664ebc5f48d222686cb11a8755e561a735aacc6d" +checksum = "27e1a710288f0f91a98dd8a74f05b76a10768db245ce183edf64dc1afdc3016c" dependencies = [ "bytes", "futures-channel", @@ -4129,7 +4254,7 @@ dependencies = [ "log", "mime", "mime_guess", - "multipart", + "multiparty", "percent-encoding", "pin-project", "rustls-pemfile", @@ -4145,6 +4270,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -4172,7 +4303,7 @@ dependencies = [ "once_cell", "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -4206,7 +4337,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", - "syn 1.0.107", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4277,19 +4408,28 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -4298,65 +4438,131 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winreg" @@ -4369,6 +4575,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/Cargo.toml b/Cargo.toml index f034b89b5f..b7c0198ff0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ members = [ "node/consensus", "node/ledger", "node/messages", + "node/metrics", "node/rest", "node/router", "node/store", @@ -41,7 +42,7 @@ path = "snarkos/main.rs" #path = "../snarkVM" git = "https://github.com/AleoHQ/snarkVM.git" rev = "a42905e" -#version = "0.9.13" +#version = "0.9.16" features = ["circuit", "console"] [dependencies.anyhow] @@ -87,6 +88,9 @@ path = "./node/store" [dependencies.snarkos-node-tcp] path = "./node/tcp" +[dependencies.tikv-jemallocator] +version = "0.5" + [dev-dependencies.rusty-hook] version = "0.11.2" diff --git a/account/Cargo.toml b/account/Cargo.toml index 5229e0d4ef..1d394e44fd 100644 --- a/account/Cargo.toml +++ b/account/Cargo.toml @@ -28,5 +28,4 @@ default-features = false [dependencies.snarkvm] workspace = true -default-features = false features = [ "console" ] diff --git a/account/src/lib.rs b/account/src/lib.rs index 2d4a25df80..6e4919a5a0 100644 --- a/account/src/lib.rs +++ b/account/src/lib.rs @@ -16,7 +16,10 @@ #![forbid(unsafe_code)] -use snarkvm::{console::types::Field, prelude::*}; +use snarkvm::{ + console::{network::prelude::*, types::Field}, + prelude::*, +}; use anyhow::Error; use colored::*; diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 3d2687e267..28a53f46d6 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -54,7 +54,7 @@ default-features = false version = "1" [dependencies.self_update] -version = "0.34" +version = "0.35" [dependencies.serde] version = "1" diff --git a/node/cdn/Cargo.toml b/node/cdn/Cargo.toml index 8cf6801a3c..111d860e97 100644 --- a/node/cdn/Cargo.toml +++ b/node/cdn/Cargo.toml @@ -17,7 +17,8 @@ license = "GPL-3.0" edition = "2021" [features] -default = [ ] +default = [ "parallel" ] +parallel = [ "rayon" ] [dependencies.anyhow] version = "1.0.70" @@ -40,6 +41,7 @@ version = "0.12" [dependencies.rayon] version = "1" +optional = true [dependencies.reqwest] version = "0.11" @@ -49,7 +51,6 @@ path = "../ledger" [dependencies.snarkvm] workspace = true -default-features = false features = ["synthesizer"] [dependencies.tokio] diff --git a/node/messages/src/challenge_request.rs b/node/messages/src/challenge_request.rs index c9e3ac7a9d..ca7d156058 100644 --- a/node/messages/src/challenge_request.rs +++ b/node/messages/src/challenge_request.rs @@ -48,3 +48,9 @@ impl MessageTrait for ChallengeRequest { Ok(Self { version, listener_port, node_type, address, nonce }) } } + +impl ChallengeRequest { + pub fn new(listener_port: u16, node_type: NodeType, address: Address, nonce: u64) -> Self { + Self { version: Message::::VERSION, listener_port, node_type, address, nonce } + } +} diff --git a/node/messages/src/helpers/codec.rs b/node/messages/src/helpers/codec.rs index dc1f5cfe2b..aca6e4edfc 100644 --- a/node/messages/src/helpers/codec.rs +++ b/node/messages/src/helpers/codec.rs @@ -21,6 +21,9 @@ use ::bytes::{BufMut, BytesMut}; use core::marker::PhantomData; use tokio_util::codec::{Decoder, Encoder, LengthDelimitedCodec}; +/// The maximum size of a message that can be transmitted during the handshake. +const MAXIMUM_HANDSHAKE_MESSAGE_SIZE: usize = 1024 * 1024; // 1 MiB + /// The maximum size of a message that can be transmitted in the network. const MAXIMUM_MESSAGE_SIZE: usize = 128 * 1024 * 1024; // 128 MiB @@ -30,10 +33,20 @@ pub struct MessageCodec { _phantom: PhantomData, } +impl MessageCodec { + /// Increases the maximum permitted message size post-handshake. + pub fn update_max_message_len(&mut self) { + self.codec = LengthDelimitedCodec::builder().max_frame_length(MAXIMUM_MESSAGE_SIZE).little_endian().new_codec(); + } +} + impl Default for MessageCodec { fn default() -> Self { Self { - codec: LengthDelimitedCodec::builder().max_frame_length(MAXIMUM_MESSAGE_SIZE).little_endian().new_codec(), + codec: LengthDelimitedCodec::builder() + .max_frame_length(MAXIMUM_HANDSHAKE_MESSAGE_SIZE) + .little_endian() + .new_codec(), _phantom: Default::default(), } } diff --git a/node/messages/src/helpers/noise_codec.rs b/node/messages/src/helpers/noise_codec.rs index 0daa2c5169..c416db0b7b 100644 --- a/node/messages/src/helpers/noise_codec.rs +++ b/node/messages/src/helpers/noise_codec.rs @@ -386,11 +386,8 @@ mod tests { #[test] fn ping_roundtrip() { - let ping = MessageOrBytes::Message(Box::new(Message::Ping(Ping:: { - version: 0, - node_type: NodeType::Client, - block_locators: None, - }))); + let ping = + MessageOrBytes::Message(Box::new(Message::Ping(Ping::::new(NodeType::Client, None)))); assert_roundtrip(ping) } diff --git a/node/messages/src/ping.rs b/node/messages/src/ping.rs index 1dfccf5bfd..e7e4917e93 100644 --- a/node/messages/src/ping.rs +++ b/node/messages/src/ping.rs @@ -44,3 +44,9 @@ impl MessageTrait for Ping { Ok(Self { version, node_type, block_locators }) } } + +impl Ping { + pub fn new(node_type: NodeType, block_locators: Option>) -> Self { + Self { version: >::VERSION, node_type, block_locators } + } +} diff --git a/node/metrics/Cargo.toml b/node/metrics/Cargo.toml new file mode 100644 index 0000000000..257f838148 --- /dev/null +++ b/node/metrics/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "snarkos-node-metrics" +version = "2.0.2" +authors = [ "The Aleo Team " ] +description = "A node for a decentralized operating system" +homepage = "https://aleo.org" +repository = "https://github.com/AleoHQ/snarkOS" +keywords = [ + "aleo", + "cryptography", + "blockchain", + "decentralized", + "zero-knowledge" +] +categories = [ "cryptography", "operating-systems" ] +license = "GPL-3.0" +edition = "2021" + +[dependencies.metrics] +version = "0.20" + +[dependencies.metrics-exporter-prometheus] +version = "0.11" + +[dependencies.tokio] +version = "1.23" +features = ["rt"] diff --git a/node/metrics/src/lib.rs b/node/metrics/src/lib.rs new file mode 100644 index 0000000000..a7f67963ba --- /dev/null +++ b/node/metrics/src/lib.rs @@ -0,0 +1,48 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// The snarkOS library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The snarkOS library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the snarkOS library. If not, see . + +mod names; + +// Re-export the metrics macros. +pub use metrics::*; +// Expose the names at the crate level for easy access. +pub use names::*; + +/// Initialises the metrics and returns a handle to the task running the metrics exporter. +pub fn initialize() -> tokio::task::JoinHandle<()> { + use metrics_exporter_prometheus::PrometheusBuilder; + + // Build the recorder and set as global. + let (recorder, exporter) = PrometheusBuilder::new().build().expect("can't build the prometheus exporter"); + metrics::set_boxed_recorder(Box::new(recorder)).expect("can't set the prometheus exporter"); + + // Spawn a dedicated task for the exporter on the runtime. + let metrics_exporter_task = tokio::task::spawn(async move { + exporter.await.expect("can't await the prometheus exporter"); + }); + + // Register the metrics so they exist on init. + register_metrics(); + + // Return the exporter's task handle to be tracked by the node's task handling. + metrics_exporter_task +} + +fn register_metrics() { + for name in GAUGE_NAMES { + register_gauge!(name); + } +} diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs new file mode 100644 index 0000000000..d8c6d85fd8 --- /dev/null +++ b/node/metrics/src/names.rs @@ -0,0 +1,27 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// The snarkOS library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The snarkOS library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the snarkOS library. If not, see . + +pub const GAUGE_NAMES: [&str; 4] = [blocks::HEIGHT, peers::CONNECTED, peers::CANDIDATE, peers::RESTRICTED]; + +pub mod blocks { + pub const HEIGHT: &str = "snarkos_blocks_height_total"; +} + +pub mod peers { + pub const CONNECTED: &str = "snarkos_peers_connected_total"; + pub const CANDIDATE: &str = "snarkos_peers_candidate_total"; + pub const RESTRICTED: &str = "snarkos_peers_restricted_total"; +} diff --git a/node/rest/Cargo.toml b/node/rest/Cargo.toml index 4814c1cab2..967e983bbf 100644 --- a/node/rest/Cargo.toml +++ b/node/rest/Cargo.toml @@ -35,6 +35,9 @@ version = "8.2" [dependencies.once_cell] version = "1.13" +[dependencies.parking_lot] +version = "0.12" + [dependencies.serde] version = "1" default-features = false diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 8b8e24cb6c..eb8d566262 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -37,14 +37,12 @@ use snarkvm::{ use anyhow::Result; use http::header::HeaderName; +use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::{net::SocketAddr, str::FromStr, sync::Arc}; use tokio::task::JoinHandle; use warp::{reject, reply, Filter, Rejection, Reply}; -#[cfg(feature = "parallel")] -use rayon::prelude::*; - /// A REST API server for the ledger. #[derive(Clone)] pub struct Rest, R: Routing> { @@ -55,7 +53,7 @@ pub struct Rest, R: Routing> { /// The node (routing). routing: Arc, /// The server handles. - handles: Vec>>, + handles: Arc>>>, } impl, R: Routing> Rest { @@ -67,7 +65,7 @@ impl, R: Routing> Rest routing: Arc, ) -> Result { // Initialize the server. - let mut server = Self { consensus, ledger, routing, handles: vec![] }; + let mut server = Self { consensus, ledger, routing, handles: Default::default() }; // Spawn the server. server.spawn_server(rest_ip); // Return the server. @@ -82,7 +80,7 @@ impl, R: Routing> Rest { } /// Returns the handles. - pub const fn handles(&self) -> &Vec>> { + pub const fn handles(&self) -> &Arc>>> { &self.handles } } @@ -105,9 +103,9 @@ impl, R: Routing> Rest }); // Spawn the server. - self.handles.push(Arc::new(tokio::spawn(async move { + self.handles.lock().push(tokio::spawn(async move { // Start the server. warp::serve(routes.with(cors).with(custom_log)).run(rest_ip).await - }))) + })) } } diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 0fb5d97008..bd0a42b194 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -16,6 +16,8 @@ use super::*; +use rayon::iter::{IntoParallelIterator, ParallelIterator}; + /// The `get_blocks` query object. #[derive(Deserialize, Serialize)] struct BlockRange { @@ -381,7 +383,7 @@ impl, R: Routing> Rest { }); // Broadcast the transaction. - routing.propagate(message, vec![]); + routing.propagate(message, &[]); Ok(transaction_id.to_string()) } diff --git a/node/router/Cargo.toml b/node/router/Cargo.toml index 3f3a06ff7d..fca2723ce8 100644 --- a/node/router/Cargo.toml +++ b/node/router/Cargo.toml @@ -119,7 +119,7 @@ path = "." features = [ "test" ] [dev-dependencies.snarkvm-utilities] -version = "0.9" +version = "0.9.16" [dev-dependencies.tracing-subscriber] version = "0.3" diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index a2e417898e..8aee4a4cdb 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -43,8 +43,51 @@ impl P2P for Router { } } +/// A macro unwrapping the expected handshake message or returning an error for unexpected messages. +#[macro_export] +macro_rules! expect_message { + ($msg_ty:path, $framed:expr, $peer_addr:expr) => { + match $framed.try_next().await? { + // Received the expected message, proceed. + Some($msg_ty(data)) => { + trace!("Received '{}' from '{}'", data.name(), $peer_addr); + data + } + // Received a disconnect message, abort. + Some(Message::Disconnect(reason)) => { + return Err(error(format!("'{}' disconnected: {reason:?}", $peer_addr))) + } + // Received an unexpected message, abort. + Some(ty) => { + return Err(error(format!( + "'{}' did not follow the handshake protocol: received {:?} instead of {}", + $peer_addr, + ty.name(), + stringify!($msg_ty), + ))) + } + // Received nothing. + None => { + return Err(error(format!("'{}' disconnected before sending {:?}", $peer_addr, stringify!($msg_ty),))) + } + } + }; +} + +/// A macro for cutting a handshake short if message verification fails. +#[macro_export] +macro_rules! handle_verification { + ($result:expr, $framed:expr, $peer_addr:expr) => { + if let Some(reason) = $result { + trace!("Sending 'Disconnect' to '{}'", $peer_addr); + $framed.send(Message::Disconnect(Disconnect { reason: reason.clone() })).await?; + return Err(error(format!("Dropped '{}' for reason: {reason:?}", $peer_addr))); + } + }; +} + impl Router { - /// Performs the handshake protocol. + /// Executes the handshake protocol. pub async fn handshake<'a>( &'a self, peer_addr: SocketAddr, @@ -58,133 +101,162 @@ impl Router { debug!("Received a connection request from '{peer_addr}'"); None } else { + debug!("Connecting to {peer_addr}..."); Some(peer_addr) }; // Perform the handshake; we pass on a mutable reference to peer_ip in case the process is broken at any point in time. - let handshake_result = self.handshake_inner(peer_addr, &mut peer_ip, stream, peer_side, genesis_header).await; + let mut handshake_result = if peer_side == ConnectionSide::Responder { + self.handshake_inner_initiator(peer_addr, &mut peer_ip, stream, genesis_header).await + } else { + self.handshake_inner_responder(peer_addr, &mut peer_ip, stream, genesis_header).await + }; // Remove the address from the collection of connecting peers (if the handshake got to the point where it's known). if let Some(ip) = peer_ip { self.connecting_peers.lock().remove(&ip); } + // If the handshake succeeded, announce it and increase the message size limit. + if let Ok((ref peer_ip, ref mut framed)) = handshake_result { + info!("Connected to '{peer_ip}'"); + framed.codec_mut().update_max_message_len(); + } + handshake_result } - /// A helper that facilitates some extra error handling in `Router::handshake`. - async fn handshake_inner<'a>( + /// The connection initiator side of the handshake. + async fn handshake_inner_initiator<'a>( &'a self, peer_addr: SocketAddr, peer_ip: &mut Option, stream: &'a mut TcpStream, - peer_side: ConnectionSide, genesis_header: Header, ) -> io::Result<(SocketAddr, Framed<&mut TcpStream, MessageCodec>)> { // Construct the stream. let mut framed = Framed::new(stream, MessageCodec::::default()); + // This value is immediately guaranteed to be present, so it can be unwrapped. + let peer_ip = peer_ip.unwrap(); + /* Step 1: Send the challenge request. */ // Initialize an RNG. let rng = &mut OsRng; // Sample a random nonce. - let nonce_a = rng.gen(); + let our_nonce = rng.gen(); // Send a challenge request to the peer. - let message_a = Message::::ChallengeRequest(ChallengeRequest { - version: Message::::VERSION, - listener_port: self.local_ip().port(), - node_type: self.node_type, - address: self.address(), - nonce: nonce_a, - }); - trace!("Sending '{}-A' to '{peer_addr}'", message_a.name()); - framed.send(message_a).await?; - - /* Step 2: Receive the challenge request. */ + let our_request = ChallengeRequest::new(self.local_ip().port(), self.node_type, self.address(), our_nonce); + trace!("Sending '{}' to '{peer_addr}'", our_request.name()); + framed.send(Message::ChallengeRequest(our_request)).await?; + + /* Step 2: Receive the peer's challenge response followed by the challenge request. */ + + // Listen for the challenge response message. + let peer_response = expect_message!(Message::ChallengeResponse, framed, peer_addr); // Listen for the challenge request message. - let request_b = match framed.try_next().await? { - // Received the challenge request message, proceed. - Some(Message::ChallengeRequest(data)) => data, - // Received a disconnect message, abort. - Some(Message::Disconnect(reason)) => return Err(error(format!("'{peer_addr}' disconnected: {reason:?}"))), - // Received an unexpected message, abort. - _ => return Err(error(format!("'{peer_addr}' did not send a challenge request"))), - }; - trace!("Received '{}-B' from '{peer_addr}'", request_b.name()); + let peer_request = expect_message!(Message::ChallengeRequest, framed, peer_addr); - // Obtain the peer's listening address if it's an inbound connection. - if peer_ip.is_none() { - *peer_ip = Some(SocketAddr::new(peer_addr.ip(), request_b.listener_port)); - } + // Verify the challenge response. If a disconnect reason was returned, send the disconnect message and abort. + handle_verification!( + self.verify_challenge_response(peer_addr, peer_request.address, peer_response, genesis_header, our_nonce) + .await, + framed, + peer_addr + ); + + // Verify the challenge request. If a disconnect reason was returned, send the disconnect message and abort. + handle_verification!(self.verify_challenge_request(peer_addr, &peer_request), framed, peer_addr); + + /* Step 3: Send the challenge response. */ + + // Sign the counterparty nonce. + let our_signature = self + .account + .sign_bytes(&peer_request.nonce.to_le_bytes(), rng) + .map_err(|_| error(format!("Failed to sign the challenge request nonce from '{peer_addr}'")))?; - // This value is now guaranteed to be present, so it can be unwrapped. + // Send the challenge response. + let our_response = ChallengeResponse { genesis_header, signature: Data::Object(our_signature) }; + trace!("Sending '{}' to '{peer_addr}'", our_response.name()); + framed.send(Message::ChallengeResponse(our_response)).await?; + + // Add the peer to the router. + self.insert_connected_peer(Peer::new(peer_ip, &peer_request), peer_addr); + + Ok((peer_ip, framed)) + } + + /// The connection responder side of the handshake. + async fn handshake_inner_responder<'a>( + &'a self, + peer_addr: SocketAddr, + peer_ip: &mut Option, + stream: &'a mut TcpStream, + genesis_header: Header, + ) -> io::Result<(SocketAddr, Framed<&mut TcpStream, MessageCodec>)> { + // Construct the stream. + let mut framed = Framed::new(stream, MessageCodec::::default()); + + /* Step 1: Receive the challenge request. */ + + // Listen for the challenge request message. + let peer_request = expect_message!(Message::ChallengeRequest, framed, peer_addr); + + // Obtain the peer's listening address. + *peer_ip = Some(SocketAddr::new(peer_addr.ip(), peer_request.listener_port)); let peer_ip = peer_ip.unwrap(); // Knowing the peer's listening address, ensure it is allowed to connect. - if peer_side == ConnectionSide::Initiator { - if let Err(forbidden_message) = self.ensure_peer_is_allowed(peer_ip) { - return Err(error(format!("{forbidden_message}"))); - } + if let Err(forbidden_message) = self.ensure_peer_is_allowed(peer_ip) { + return Err(error(format!("{forbidden_message}"))); } // Verify the challenge request. If a disconnect reason was returned, send the disconnect message and abort. - if let Some(reason) = self.verify_challenge_request(peer_addr, &request_b) { - trace!("Sending 'Disconnect' to '{peer_addr}'"); - framed.send(Message::Disconnect(Disconnect { reason: reason.clone() })).await?; - return Err(error(format!("Dropped '{peer_addr}' for reason: {reason:?}"))); - } + handle_verification!(self.verify_challenge_request(peer_addr, &peer_request), framed, peer_addr); - /* Step 3: Send the challenge response. */ + /* Step 2: Send the challenge response followed by own challenge request. */ + + // Initialize an RNG. + let rng = &mut OsRng; // Sign the counterparty nonce. - let signature_b = self + let our_signature = self .account - .sign_bytes(&request_b.nonce.to_le_bytes(), rng) + .sign_bytes(&peer_request.nonce.to_le_bytes(), rng) .map_err(|_| error(format!("Failed to sign the challenge request nonce from '{peer_addr}'")))?; + // Sample a random nonce. + let our_nonce = rng.gen(); + // Send the challenge response. - let message_b = - Message::ChallengeResponse(ChallengeResponse { genesis_header, signature: Data::Object(signature_b) }); - trace!("Sending '{}-B' to '{peer_addr}'", message_b.name()); - framed.send(message_b).await?; + let our_response = ChallengeResponse { genesis_header, signature: Data::Object(our_signature) }; + trace!("Sending '{}' to '{peer_addr}'", our_response.name()); + framed.send(Message::ChallengeResponse(our_response)).await?; + + // Send the challenge request. + let our_request = ChallengeRequest::new(self.local_ip().port(), self.node_type, self.address(), our_nonce); + trace!("Sending '{}' to '{peer_addr}'", our_request.name()); + framed.send(Message::ChallengeRequest(our_request)).await?; - /* Step 4: Receive the challenge response. */ + /* Step 3: Receive the challenge response. */ // Listen for the challenge response message. - let response_a = match framed.try_next().await? { - // Received the challenge response message, proceed. - Some(Message::ChallengeResponse(data)) => data, - // Received a disconnect message, abort. - Some(Message::Disconnect(reason)) => return Err(error(format!("'{peer_addr}' disconnected: {reason:?}"))), - // Received an unexpected message, abort. - _ => return Err(error(format!("'{peer_addr}' did not send a challenge response"))), - }; - trace!("Received '{}-A' from '{peer_addr}'", response_a.name()); + let peer_response = expect_message!(Message::ChallengeResponse, framed, peer_addr); // Verify the challenge response. If a disconnect reason was returned, send the disconnect message and abort. - if let Some(reason) = - self.verify_challenge_response(peer_addr, request_b.address, response_a, genesis_header, nonce_a).await - { - trace!("Sending 'Disconnect' to '{peer_addr}'"); - framed.send(Message::Disconnect(Disconnect { reason: reason.clone() })).await?; - return Err(error(format!("Dropped '{peer_addr}' for reason: {reason:?}"))); - } - - /* Step 5: Add the peer to the router. */ - - // Prepare the peer. - let peer_address = request_b.address; - let peer_type = request_b.node_type; - let peer_version = request_b.version; - - // Construct the peer. - let peer = Peer::new(peer_ip, peer_address, peer_type, peer_version); - // Insert the connected peer in the router. - self.insert_connected_peer(peer, peer_addr); - info!("Connected to '{peer_ip}'"); + handle_verification!( + self.verify_challenge_response(peer_addr, peer_request.address, peer_response, genesis_header, our_nonce) + .await, + framed, + peer_addr + ); + + // Add the peer to the router. + self.insert_connected_peer(Peer::new(peer_ip, &peer_request), peer_addr); Ok((peer_ip, framed)) } diff --git a/node/router/src/helpers/cache.rs b/node/router/src/helpers/cache.rs index bd8494bd82..1f9334464e 100644 --- a/node/router/src/helpers/cache.rs +++ b/node/router/src/helpers/cache.rs @@ -24,7 +24,6 @@ use parking_lot::RwLock; use std::{ collections::VecDeque, net::{IpAddr, SocketAddr}, - sync::atomic::{AtomicU16, Ordering::SeqCst}, }; use time::{Duration, OffsetDateTime}; @@ -51,7 +50,7 @@ pub struct Cache { /// The map of peer IPs to their block requests. seen_outbound_block_requests: RwLock>>, /// The map of peer IPs to the number of puzzle requests. - seen_outbound_puzzle_requests: RwLock>, + seen_outbound_puzzle_requests: RwLock>, /// The map of solution commitments to their last seen timestamp. seen_outbound_solutions: RwLock, OffsetDateTime>>, /// The map of transaction IDs to their last seen timestamp. @@ -131,12 +130,10 @@ impl Cache { requests.len() } - /// Removes the block request for the given peer IP, returning the number of remaining requests. - pub fn remove_outbound_block_request(&self, peer_ip: SocketAddr, request: &BlockRequest) -> usize { + /// Removes the block request for the given peer IP, returning `true` if the request was present. + pub fn remove_outbound_block_request(&self, peer_ip: SocketAddr, request: &BlockRequest) -> bool { let mut map_write = self.seen_outbound_block_requests.write(); - let requests = map_write.entry(peer_ip).or_default(); - requests.remove(request); - requests.len() + if let Some(requests) = map_write.get_mut(&peer_ip) { requests.remove(request) } else { false } } /// Returns `true` if the cache contains a puzzle request from the given peer. @@ -180,15 +177,16 @@ impl Cache { key: K, interval_in_secs: i64, ) -> usize { + // Fetch the current timestamp. + let now = OffsetDateTime::now_utc(); + let mut map_write = map.write(); // Load the entry for the key. let timestamps = map_write.entry(key).or_default(); - // Fetch the current timestamp. - let now = OffsetDateTime::now_utc(); // Insert the new timestamp. timestamps.push_back(now); // Retain only the timestamps that are within the recent interval. - while timestamps.iter().next().map_or(false, |t| now - *t > Duration::seconds(interval_in_secs)) { + while timestamps.front().map_or(false, |t| now - *t > Duration::seconds(interval_in_secs)) { timestamps.pop_front(); } // Return the frequency of recent requests. @@ -196,23 +194,23 @@ impl Cache { } /// Increments the key's counter in the map, returning the updated counter. - fn increment_counter(map: &RwLock>, key: K) -> u16 { + fn increment_counter(map: &RwLock>, key: K) -> u16 { + let mut map_write = map.write(); // Load the entry for the key, and increment the counter. - let previous_entry = map.write().entry(key).or_default().fetch_add(1, SeqCst); + let entry = map_write.entry(key).or_default(); + *entry = entry.saturating_add(1); // Return the updated counter. - previous_entry.saturating_add(1) + *entry } /// Decrements the key's counter in the map, returning the updated counter. - fn decrement_counter(map: &RwLock>, key: K) -> u16 { + fn decrement_counter(map: &RwLock>, key: K) -> u16 { let mut map_write = map.write(); - // Load the entry for the key. + // Load the entry for the key, and decrement the counter. let entry = map_write.entry(key).or_default(); - // Conditionally decrement the counter. - match entry.load(SeqCst) > 0 { - true => entry.fetch_sub(1, SeqCst).saturating_sub(1), - false => 0, - } + *entry = entry.saturating_sub(1); + // Return the updated counter. + *entry } /// Updates the map by enforcing the maximum cache size. diff --git a/node/router/src/helpers/peer.rs b/node/router/src/helpers/peer.rs index d51807ffdd..9b2c8549bb 100644 --- a/node/router/src/helpers/peer.rs +++ b/node/router/src/helpers/peer.rs @@ -14,11 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the snarkOS library. If not, see . -use snarkos_node_messages::NodeType; +use snarkos_node_messages::{ChallengeRequest, NodeType}; use snarkvm::prelude::{Address, Network}; -use parking_lot::RwLock; -use std::{net::SocketAddr, sync::Arc, time::Instant}; +use std::{net::SocketAddr, time::Instant}; /// The state for each connected peer. #[derive(Clone, Debug)] @@ -34,19 +33,19 @@ pub struct Peer { /// The timestamp of the first message received from the peer. first_seen: Instant, /// The timestamp of the last message received from this peer. - last_seen: Arc>, + last_seen: Instant, } impl Peer { /// Initializes a new instance of `Peer`. - pub fn new(listening_ip: SocketAddr, address: Address, node_type: NodeType, version: u32) -> Self { + pub fn new(listening_ip: SocketAddr, challenge_request: &ChallengeRequest) -> Self { Self { peer_ip: listening_ip, - address, - node_type, - version, + address: challenge_request.address, + node_type: challenge_request.node_type, + version: challenge_request.version, first_seen: Instant::now(), - last_seen: Arc::new(RwLock::new(Instant::now())), + last_seen: Instant::now(), } } @@ -97,7 +96,7 @@ impl Peer { /// Returns the last seen timestamp of the peer. pub fn last_seen(&self) -> Instant { - *self.last_seen.read() + self.last_seen } } @@ -113,7 +112,7 @@ impl Peer { } /// Updates the last seen timestamp of the peer. - pub fn set_last_seen(&self, last_seen: Instant) { - *self.last_seen.write() = last_seen; + pub fn set_last_seen(&mut self, last_seen: Instant) { + self.last_seen = last_seen; } } diff --git a/node/router/src/helpers/sync.rs b/node/router/src/helpers/sync.rs index cff1d82a73..17d2edc0ec 100644 --- a/node/router/src/helpers/sync.rs +++ b/node/router/src/helpers/sync.rs @@ -145,7 +145,7 @@ impl Sync { self.locators.read().iter().map(|(peer_ip, locators)| (locators.latest_locator_height(), *peer_ip)).fold( Default::default(), |mut map, (height, peer_ip)| { - map.entry(height).or_insert_with(Vec::new).push(peer_ip); + map.entry(height).or_default().push(peer_ip); map }, ) diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index bc6b0eab38..451ef66a81 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -23,12 +23,11 @@ use snarkos_node_messages::{ PeerResponse, Ping, Pong, - PuzzleResponse, UnconfirmedSolution, UnconfirmedTransaction, }; use snarkos_node_tcp::protocols::Reading; -use snarkvm::prelude::{Block, Header, Network, ProverSolution, Transaction}; +use snarkvm::prelude::{Block, EpochChallenge, Header, Network, ProverSolution, Transaction}; use anyhow::{bail, ensure, Result}; use std::{net::SocketAddr, time::Instant}; @@ -126,12 +125,10 @@ pub trait Inbound: Reading + Outbound { Message::BlockResponse(message) => { let request = message.request; - // Check that this node previously sent a block request to this peer. - if !self.router().cache.contains_outbound_block_request(&peer_ip, &request) { + // Remove the block request, checking if this node previously sent a block request to this peer. + if !self.router().cache.remove_outbound_block_request(peer_ip, &request) { bail!("Peer '{peer_ip}' is not following the protocol (unexpected block response)") } - // Remove the block request. - self.router().cache.remove_outbound_block_request(peer_ip, &request); // Perform the deferred non-blocking deserialization of the blocks. let blocks = match message.blocks.deserialize().await { @@ -204,15 +201,13 @@ pub trait Inbound: Reading + Outbound { // Decrement the number of puzzle requests. self.router().cache.decrement_outbound_puzzle_requests(peer_ip); - // Clone the serialized message. - let serialized = message.clone(); // Perform the deferred non-blocking deserialization of the block header. let header = match message.block_header.deserialize().await { Ok(header) => header, Err(error) => bail!("[PuzzleResponse] {error}"), }; // Process the puzzle response. - match self.puzzle_response(peer_ip, serialized, header) { + match self.puzzle_response(peer_ip, message.epoch_challenge, header) { true => Ok(()), false => bail!("Peer '{peer_ip}' sent an invalid puzzle response"), } @@ -385,7 +380,7 @@ pub trait Inbound: Reading + Outbound { fn puzzle_request(&self, peer_ip: SocketAddr) -> bool; /// Handles a `PuzzleResponse` message. - fn puzzle_response(&self, peer_ip: SocketAddr, _serialized: PuzzleResponse, _header: Header) -> bool; + fn puzzle_response(&self, peer_ip: SocketAddr, _challenge: EpochChallenge, _header: Header) -> bool; /// Handles an `UnconfirmedSolution` message. async fn unconfirmed_solution( diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 7cc6bb4c7b..42974006a7 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -89,7 +89,7 @@ pub struct InnerRouter { /// The set of restricted peer IPs. restricted_peers: RwLock>, /// The spawned handles. - handles: RwLock>>, + handles: Mutex>>, /// The boolean flag for the development mode. is_dev: bool, } @@ -145,7 +145,6 @@ impl Router { let router = self.clone(); tokio::spawn(async move { // Attempt to connect to the candidate peer. - debug!("Connecting to {peer_ip}..."); match router.tcp.connect(peer_ip).await { // Remove the peer from the candidate peers. Ok(()) => router.remove_candidate_peer(peer_ip), @@ -407,14 +406,15 @@ impl Router { /// Inserts the given peer into the connected peers. pub fn insert_connected_peer(&self, peer: Peer, peer_addr: SocketAddr) { + let peer_ip = peer.ip(); // Adds a bidirectional map between the listener address and (ambiguous) peer address. - self.resolver.insert_peer(peer.ip(), peer_addr); + self.resolver.insert_peer(peer_ip, peer_addr); // Add an entry for this `Peer` in the connected peers. - self.connected_peers.write().insert(peer.ip(), peer.clone()); + self.connected_peers.write().insert(peer_ip, peer); // Remove this peer from the candidate peers, if it exists. - self.candidate_peers.write().remove(&peer.ip()); + self.candidate_peers.write().remove(&peer_ip); // Remove this peer from the restricted peers, if it exists. - self.restricted_peers.write().remove(&peer.ip()); + self.restricted_peers.write().remove(&peer_ip); } /// Inserts the given peer IPs to the set of candidate peers. @@ -489,14 +489,14 @@ impl Router { /// Spawns a task with the given future; it should only be used for long-running tasks. pub fn spawn + Send + 'static>(&self, future: T) { - self.handles.write().push(tokio::spawn(future)); + self.handles.lock().push(tokio::spawn(future)); } /// Shuts down the router. pub async fn shut_down(&self) { trace!("Shutting down the router..."); // Abort the tasks. - self.handles.read().iter().for_each(|handle| handle.abort()); + self.handles.lock().iter().for_each(|handle| handle.abort()); // Close the listener. self.tcp.shut_down().await; } diff --git a/node/router/src/outbound.rs b/node/router/src/outbound.rs index 770b5073b5..f3057993da 100644 --- a/node/router/src/outbound.rs +++ b/node/router/src/outbound.rs @@ -29,14 +29,7 @@ pub trait Outbound: Writing> { /// Sends a "Ping" message to the given peer. fn send_ping(&self, peer_ip: SocketAddr, block_locators: Option>) { - self.send( - peer_ip, - Message::Ping(Ping:: { - version: Message::::VERSION, - node_type: self.router().node_type(), - block_locators, - }), - ); + self.send(peer_ip, Message::Ping(Ping::new(self.router().node_type(), block_locators))); } /// Sends the given message to specified peer. @@ -80,7 +73,7 @@ pub trait Outbound: Writing> { } /// Sends the given message to every connected peer, excluding the sender and any specified peer IPs. - fn propagate(&self, message: Message, excluded_peers: Vec) { + fn propagate(&self, message: Message, excluded_peers: &[SocketAddr]) { // TODO (howardwu): Serialize large messages once only. // // Perform ahead-of-time, non-blocking serialization just once for applicable objects. // if let Message::BeaconPropose(ref mut message) = message { @@ -104,22 +97,17 @@ pub trait Outbound: Writing> { // } // Prepare the peers to send to. - let peers = self - .router() - .connected_peers() - .iter() - .filter(|peer_ip| !self.router().is_local_ip(peer_ip) && !excluded_peers.contains(peer_ip)) - .copied() - .collect::>(); + let connected_peers = self.router().connected_peers(); + let peers = connected_peers.iter().filter(|peer_ip| !excluded_peers.contains(peer_ip)); // Iterate through all peers that are not the sender and excluded peers. for peer_ip in peers { - self.send(peer_ip, message.clone()); + self.send(*peer_ip, message.clone()); } } /// Sends the given message to every connected beacon, excluding the sender and any specified IPs. - fn propagate_to_beacons(&self, message: Message, excluded_peers: Vec) { + fn propagate_to_beacons(&self, message: Message, excluded_peers: &[SocketAddr]) { // TODO (howardwu): Serialize large messages once only. // // Perform ahead-of-time, non-blocking serialization just once for applicable objects. // if let Message::BeaconPropose(ref mut message) = message { @@ -143,22 +131,17 @@ pub trait Outbound: Writing> { // } // Prepare the peers to send to. - let peers = self - .router() - .connected_beacons() - .iter() - .filter(|peer_ip| !self.router().is_local_ip(peer_ip) && !excluded_peers.contains(peer_ip)) - .copied() - .collect::>(); + let connected_beacons = self.router().connected_beacons(); + let peers = connected_beacons.iter().filter(|peer_ip| !excluded_peers.contains(peer_ip)); // Iterate through all beacons that are not the sender and excluded beacons. for peer_ip in peers { - self.send(peer_ip, message.clone()); + self.send(*peer_ip, message.clone()); } } /// Sends the given message to every connected validator, excluding the sender and any specified IPs. - fn propagate_to_validators(&self, message: Message, excluded_peers: Vec) { + fn propagate_to_validators(&self, message: Message, excluded_peers: &[SocketAddr]) { // TODO (howardwu): Serialize large messages once only. // // Perform ahead-of-time, non-blocking serialization just once for applicable objects. // if let Message::BeaconPropose(ref mut message) = message { @@ -182,17 +165,12 @@ pub trait Outbound: Writing> { // } // Prepare the peers to send to. - let peers = self - .router() - .connected_validators() - .iter() - .filter(|peer_ip| !self.router().is_local_ip(peer_ip) && !excluded_peers.contains(peer_ip)) - .copied() - .collect::>(); + let connected_validators = self.router().connected_validators(); + let peers = connected_validators.iter().filter(|peer_ip| !excluded_peers.contains(peer_ip)); // Iterate through all beacons that are not the sender and excluded beacons. for peer_ip in peers { - self.send(peer_ip, message.clone()); + self.send(*peer_ip, message.clone()); } } diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 4cf3dfa087..2f35e2a308 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -22,7 +22,6 @@ use snarkos_node_messages::{ MessageCodec, Ping, Pong, - PuzzleResponse, UnconfirmedSolution, UnconfirmedTransaction, }; @@ -34,7 +33,7 @@ use snarkos_node_tcp::{ Tcp, P2P, }; -use snarkvm::prelude::{Block, Header, Network, ProverSolution, Transaction}; +use snarkvm::prelude::{Block, EpochChallenge, Header, Network, ProverSolution, Transaction}; use async_trait::async_trait; use futures_util::sink::SinkExt; @@ -77,11 +76,7 @@ impl Handshake for TestRouter { let (peer_ip, mut framed) = self.router().handshake(peer_addr, stream, conn_side, genesis_header).await?; // Send the first `Ping` message to the peer. - let message = Message::Ping(Ping:: { - version: Message::::VERSION, - node_type: self.node_type(), - block_locators: None, - }); + let message = Message::Ping(Ping::new(self.node_type(), None)); trace!("Sending '{}' to '{peer_ip}'", message.name()); framed.send(message).await?; @@ -170,7 +165,7 @@ impl Inbound for TestRouter { } /// Handles an `PuzzleResponse` message. - fn puzzle_response(&self, _peer_ip: SocketAddr, _serialized: PuzzleResponse, _header: Header) -> bool { + fn puzzle_response(&self, _peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { true } diff --git a/node/router/tests/connect.rs b/node/router/tests/connect.rs index e30af6e301..e511283e4c 100644 --- a/node/router/tests/connect.rs +++ b/node/router/tests/connect.rs @@ -23,8 +23,6 @@ use core::time::Duration; #[tokio::test] async fn test_connect_without_handshake() { - initialize_logger(3); - // Create 2 routers. let node0 = validator(0, 2).await; let node1 = client(0, 2).await; @@ -81,8 +79,6 @@ async fn test_connect_without_handshake() { #[tokio::test] async fn test_connect_with_handshake() { - initialize_logger(3); - // Create 2 routers. let node0 = validator(0, 2).await; let node1 = client(0, 2).await; @@ -159,8 +155,6 @@ async fn test_connect_with_handshake() { #[ignore] #[tokio::test] async fn test_connect_simultaneously_with_handshake() { - initialize_logger(3); - // Create 2 routers. let node0 = validator(0, 2).await; let node1 = client(0, 2).await; diff --git a/node/router/tests/disconnect.rs b/node/router/tests/disconnect.rs index bf30a335b5..3fd5aefa89 100644 --- a/node/router/tests/disconnect.rs +++ b/node/router/tests/disconnect.rs @@ -23,8 +23,6 @@ use core::time::Duration; #[tokio::test] async fn test_disconnect_without_handshake() { - initialize_logger(3); - // Create 2 routers. let node0 = validator(0, 1).await; let node1 = client(0, 1).await; @@ -67,8 +65,6 @@ async fn test_disconnect_without_handshake() { #[tokio::test] async fn test_disconnect_with_handshake() { - initialize_logger(3); - // Create 2 routers. let node0 = validator(0, 1).await; let node1 = client(0, 1).await; diff --git a/node/src/beacon/mod.rs b/node/src/beacon/mod.rs index d417f1763d..5402993bd5 100644 --- a/node/src/beacon/mod.rs +++ b/node/src/beacon/mod.rs @@ -54,7 +54,7 @@ use ::time::OffsetDateTime; use aleo_std::prelude::{finish, lap, timer}; use anyhow::{bail, Result}; use core::{str::FromStr, time::Duration}; -use parking_lot::RwLock; +use parking_lot::{Mutex, RwLock}; use std::{ net::SocketAddr, sync::{ @@ -76,13 +76,13 @@ pub struct Beacon> { /// The router of the node. router: Router, /// The REST server of the node. - rest: Option>>, + rest: Option>, /// The time it to generate a block. block_generation_time: Arc, /// The unspent records. unspent_records: Arc>>, /// The spawned handles. - handles: Arc>>>, + handles: Arc>>>, /// The shutdown signal. shutdown: Arc, } @@ -151,7 +151,7 @@ impl> Beacon { // Initialize the REST server. if let Some(rest_ip) = rest_ip { - node.rest = Some(Arc::new(Rest::start(rest_ip, Some(consensus), ledger, Arc::new(node.clone()))?)); + node.rest = Some(Rest::start(rest_ip, Some(consensus), ledger, Arc::new(node.clone()))?); lap!(timer, "Initialize REST server"); } // Initialize the routing. @@ -173,7 +173,7 @@ impl> Beacon { } /// Returns the REST server. - pub fn rest(&self) -> &Option>> { + pub fn rest(&self) -> &Option> { &self.rest } } @@ -186,11 +186,11 @@ impl> NodeInterface for Beacon { // Shut down block production. trace!("Shutting down block production..."); - self.shutdown.store(true, Ordering::SeqCst); + self.shutdown.store(true, Ordering::Relaxed); // Abort the tasks. trace!("Shutting down the beacon..."); - self.handles.read().iter().for_each(|handle| handle.abort()); + self.handles.lock().iter().for_each(|handle| handle.abort()); // Shut down the router. self.router.shut_down().await; @@ -221,7 +221,7 @@ impl> Beacon { /// Initialize a new instance of block production. async fn initialize_block_production(&self) { let beacon = self.clone(); - self.handles.write().push(tokio::spawn(async move { + self.handles.lock().push(tokio::spawn(async move { // Expected time per block. const ROUND_TIME: u64 = 15; // 15 seconds per block @@ -234,7 +234,7 @@ impl> Beacon { // Do not produce a block if the elapsed time has not exceeded `ROUND_TIME - block_generation_time`. // This will ensure a block is produced at intervals of approximately `ROUND_TIME`. - let time_to_wait = ROUND_TIME.saturating_sub(beacon.block_generation_time.load(Ordering::SeqCst)); + let time_to_wait = ROUND_TIME.saturating_sub(beacon.block_generation_time.load(Ordering::Acquire)); trace!("Waiting for {time_to_wait} seconds before producing a block..."); if elapsed_time < time_to_wait { if let Err(error) = timeout( @@ -252,7 +252,7 @@ impl> Beacon { // Produce the next block and propagate it to all peers. match beacon.produce_next_block().await { // Update the block generation time. - Ok(()) => beacon.block_generation_time.store(timer.elapsed().as_secs(), Ordering::SeqCst), + Ok(()) => beacon.block_generation_time.store(timer.elapsed().as_secs(), Ordering::Release), Err(error) => error!("{error}"), } @@ -467,7 +467,7 @@ impl> Beacon { )); // Propagate the block to all beacons. - self.propagate_to_beacons(message, vec![]); + self.propagate_to_beacons(message, &[]); Ok(()) } diff --git a/node/src/beacon/router.rs b/node/src/beacon/router.rs index 345308dd67..b3c358edbd 100644 --- a/node/src/beacon/router.rs +++ b/node/src/beacon/router.rs @@ -28,7 +28,7 @@ use snarkos_node_messages::{ }; use snarkos_node_router::Routing; use snarkos_node_tcp::{Connection, ConnectionSide, Tcp}; -use snarkvm::prelude::{error, Header}; +use snarkvm::prelude::{error, EpochChallenge, Header}; use futures_util::sink::SinkExt; use std::{io, net::SocketAddr}; @@ -61,8 +61,7 @@ impl> Handshake for Beacon { }; // Send the first `Ping` message to the peer. - let message = - Message::Ping(Ping:: { version: Message::::VERSION, node_type: self.node_type(), block_locators }); + let message = Message::Ping(Ping::new(self.node_type(), block_locators)); trace!("Sending '{}' to '{peer_ip}'", message.name()); framed.send(message).await?; @@ -222,7 +221,7 @@ impl> Inbound for Beacon { } /// Disconnects on receipt of a `PuzzleResponse` message. - fn puzzle_response(&self, peer_ip: SocketAddr, _serialized: PuzzleResponse, _header: Header) -> bool { + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { debug!("Disconnecting '{peer_ip}' for the following reason - {:?}", DisconnectReason::ProtocolViolation); false } @@ -241,7 +240,7 @@ impl> Inbound for Beacon { } let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution" to the connected beacons. - self.propagate_to_beacons(message, vec![peer_ip]); + self.propagate_to_beacons(message, &[peer_ip]); true } @@ -259,7 +258,7 @@ impl> Inbound for Beacon { } let message = Message::UnconfirmedTransaction(serialized); // Propagate the "UnconfirmedTransaction" to the connected beacons. - self.propagate_to_beacons(message, vec![peer_ip]); + self.propagate_to_beacons(message, &[peer_ip]); true } } diff --git a/node/src/client/mod.rs b/node/src/client/mod.rs index 14899a470c..cec86f4011 100644 --- a/node/src/client/mod.rs +++ b/node/src/client/mod.rs @@ -18,7 +18,7 @@ mod router; use crate::traits::NodeInterface; use snarkos_account::Account; -use snarkos_node_messages::{Message, NodeType, PuzzleResponse, UnconfirmedSolution}; +use snarkos_node_messages::{Message, NodeType, UnconfirmedSolution}; use snarkos_node_router::{Heartbeat, Inbound, Outbound, Router, Routing}; use snarkos_node_tcp::{ protocols::{Disconnect, Handshake, Reading, Writing}, diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 235e3dd53e..35140e321a 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -43,11 +43,7 @@ impl> Handshake for Client { let (peer_ip, mut framed) = self.router.handshake(peer_addr, stream, conn_side, genesis_header).await?; // Send the first `Ping` message to the peer. - let message = Message::Ping(Ping:: { - version: Message::::VERSION, - node_type: self.node_type(), - block_locators: None, - }); + let message = Message::Ping(Ping::new(self.node_type(), None)); trace!("Sending '{}' to '{peer_ip}'", message.name()); framed.send(message).await?; @@ -152,9 +148,9 @@ impl> Inbound for Client { } /// Saves the latest epoch challenge and latest block header in the node. - fn puzzle_response(&self, peer_ip: SocketAddr, serialized: PuzzleResponse, header: Header) -> bool { + fn puzzle_response(&self, peer_ip: SocketAddr, epoch_challenge: EpochChallenge, header: Header) -> bool { // Retrieve the epoch number. - let epoch_number = serialized.epoch_challenge.epoch_number(); + let epoch_number = epoch_challenge.epoch_number(); // Retrieve the block height. let block_height = header.height(); @@ -165,7 +161,7 @@ impl> Inbound for Client { ); // Save the latest epoch challenge in the node. - self.latest_epoch_challenge.write().replace(serialized.epoch_challenge); + self.latest_epoch_challenge.write().replace(epoch_challenge); // Save the latest block header in the node. self.latest_block_header.write().replace(header); @@ -198,7 +194,7 @@ impl> Inbound for Client { Ok(Ok(true)) => { let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution" to the connected validators. - self.propagate_to_validators(message, vec![peer_ip]); + self.propagate_to_validators(message, &[peer_ip]); } Ok(Ok(false)) | Ok(Err(_)) => { trace!("Invalid prover solution '{}' for the proof target.", solution.commitment()) @@ -217,7 +213,7 @@ impl> Inbound for Client { _transaction: Transaction, ) -> bool { // Propagate the `UnconfirmedTransaction`. - self.propagate(Message::UnconfirmedTransaction(serialized), vec![peer_ip]); + self.propagate(Message::UnconfirmedTransaction(serialized), &[peer_ip]); true } } diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index a0fe95ca53..1c2bc6f121 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -18,7 +18,7 @@ mod router; use crate::traits::NodeInterface; use snarkos_account::Account; -use snarkos_node_messages::{Data, Message, NodeType, PuzzleResponse, UnconfirmedSolution}; +use snarkos_node_messages::{Data, Message, NodeType, UnconfirmedSolution}; use snarkos_node_router::{Heartbeat, Inbound, Outbound, Router, Routing}; use snarkos_node_tcp::{ protocols::{Disconnect, Handshake, Reading, Writing}, @@ -29,7 +29,7 @@ use snarkvm::prelude::{Block, CoinbasePuzzle, ConsensusStorage, EpochChallenge, use anyhow::Result; use colored::Colorize; use core::{marker::PhantomData, time::Duration}; -use parking_lot::RwLock; +use parking_lot::{Mutex, RwLock}; use rand::{rngs::OsRng, CryptoRng, Rng}; use std::{ net::SocketAddr, @@ -50,7 +50,7 @@ pub struct Prover> { /// The coinbase puzzle. coinbase_puzzle: CoinbasePuzzle, /// The latest epoch challenge. - latest_epoch_challenge: Arc>>>, + latest_epoch_challenge: Arc>>>>, /// The latest block header. latest_block_header: Arc>>>, /// The number of puzzle instances. @@ -58,7 +58,7 @@ pub struct Prover> { /// The maximum number of puzzle instances. max_puzzle_instances: u8, /// The spawned handles. - handles: Arc>>>, + handles: Arc>>>, /// The shutdown signal. shutdown: Arc, /// PhantomData. @@ -120,11 +120,11 @@ impl> NodeInterface for Prover { // Shut down the coinbase puzzle. trace!("Shutting down the coinbase puzzle..."); - self.shutdown.store(true, Ordering::SeqCst); + self.shutdown.store(true, Ordering::Relaxed); // Abort the tasks. trace!("Shutting down the prover..."); - self.handles.read().iter().for_each(|handle| handle.abort()); + self.handles.lock().iter().for_each(|handle| handle.abort()); // Shut down the router. self.router.shut_down().await; @@ -138,7 +138,7 @@ impl> Prover { async fn initialize_coinbase_puzzle(&self) { for _ in 0..self.max_puzzle_instances { let prover = self.clone(); - self.handles.write().push(tokio::spawn(async move { + self.handles.lock().push(tokio::spawn(async move { prover.coinbase_puzzle_loop().await; })); } @@ -175,7 +175,7 @@ impl> Prover { // Execute the coinbase puzzle. let prover = self.clone(); let result = tokio::task::spawn_blocking(move || { - prover.coinbase_puzzle_iteration(challenge, coinbase_target, proof_target, &mut OsRng) + prover.coinbase_puzzle_iteration(&challenge, coinbase_target, proof_target, &mut OsRng) }) .await; @@ -201,7 +201,7 @@ impl> Prover { /// Performs one iteration of the coinbase puzzle. fn coinbase_puzzle_iteration( &self, - epoch_challenge: EpochChallenge, + epoch_challenge: &EpochChallenge, coinbase_target: u64, proof_target: u64, rng: &mut R, @@ -221,7 +221,7 @@ impl> Prover { // Compute the prover solution. let result = self .coinbase_puzzle - .prove(&epoch_challenge, self.address(), rng.gen(), Some(proof_target)) + .prove(epoch_challenge, self.address(), rng.gen(), Some(proof_target)) .ok() .and_then(|solution| solution.to_target().ok().map(|solution_target| (solution_target, solution))); @@ -239,24 +239,24 @@ impl> Prover { solution: Data::Object(prover_solution), }); // Propagate the "UnconfirmedSolution" to the connected validators. - self.propagate_to_validators(message, vec![]); + self.propagate_to_validators(message, &[]); } /// Returns the current number of puzzle instances. fn num_puzzle_instances(&self) -> u8 { - self.puzzle_instances.load(Ordering::SeqCst) + self.puzzle_instances.load(Ordering::Relaxed) } /// Increments the number of puzzle instances. fn increment_puzzle_instances(&self) { - self.puzzle_instances.fetch_add(1, Ordering::SeqCst); + self.puzzle_instances.fetch_add(1, Ordering::Relaxed); #[cfg(debug_assertions)] trace!("Number of Instances - {}", self.num_puzzle_instances()); } /// Decrements the number of puzzle instances. fn decrement_puzzle_instances(&self) { - self.puzzle_instances.fetch_sub(1, Ordering::SeqCst); + self.puzzle_instances.fetch_sub(1, Ordering::Relaxed); #[cfg(debug_assertions)] trace!("Number of Instances - {}", self.num_puzzle_instances()); } diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index b17c20953b..1bd1bae0db 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -50,11 +50,7 @@ impl> Handshake for Prover { let (peer_ip, mut framed) = self.router.handshake(peer_addr, stream, conn_side, genesis_header).await?; // Send the first `Ping` message to the peer. - let message = Message::Ping(Ping:: { - version: Message::::VERSION, - node_type: self.node_type(), - block_locators: None, - }); + let message = Message::Ping(Ping::new(self.node_type(), None)); trace!("Sending '{}' to '{peer_ip}'", message.name()); framed.send(message).await?; @@ -159,9 +155,9 @@ impl> Inbound for Prover { } /// Saves the latest epoch challenge and latest block header in the node. - fn puzzle_response(&self, peer_ip: SocketAddr, serialized: PuzzleResponse, header: Header) -> bool { + fn puzzle_response(&self, peer_ip: SocketAddr, epoch_challenge: EpochChallenge, header: Header) -> bool { // Retrieve the epoch number. - let epoch_number = serialized.epoch_challenge.epoch_number(); + let epoch_number = epoch_challenge.epoch_number(); // Retrieve the block height. let block_height = header.height(); @@ -172,7 +168,7 @@ impl> Inbound for Prover { ); // Save the latest epoch challenge in the node. - self.latest_epoch_challenge.write().replace(serialized.epoch_challenge); + self.latest_epoch_challenge.write().replace(Arc::new(epoch_challenge)); // Save the latest block header in the node. self.latest_block_header.write().replace(header); @@ -205,7 +201,7 @@ impl> Inbound for Prover { Ok(Ok(true)) => { let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution" to the connected validators. - self.propagate_to_validators(message, vec![peer_ip]); + self.propagate_to_validators(message, &[peer_ip]); } Ok(Ok(false)) | Ok(Err(_)) => { trace!("Invalid prover solution '{}' for the proof target.", solution.commitment()) diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index f36e6743ab..3bb50b2bdc 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -30,7 +30,7 @@ use snarkos_node_tcp::{ use snarkvm::prelude::{Block, ConsensusStorage, Header, Network, ProverSolution}; use anyhow::Result; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::{ net::SocketAddr, sync::{ @@ -51,9 +51,9 @@ pub struct Validator> { /// The router of the node. router: Router, /// The REST server of the node. - rest: Option>>, + rest: Option>, /// The spawned handles. - handles: Arc>>>, + handles: Arc>>>, /// The shutdown signal. shutdown: Arc, } @@ -105,7 +105,7 @@ impl> Validator { // Initialize the REST server. if let Some(rest_ip) = rest_ip { - node.rest = Some(Arc::new(Rest::start(rest_ip, Some(consensus), ledger, Arc::new(node.clone()))?)); + node.rest = Some(Rest::start(rest_ip, Some(consensus), ledger, Arc::new(node.clone()))?); } // Initialize the sync pool. node.initialize_sync()?; @@ -123,7 +123,7 @@ impl> Validator { } /// Returns the REST server. - pub fn rest(&self) -> &Option>> { + pub fn rest(&self) -> &Option> { &self.rest } } @@ -136,11 +136,11 @@ impl> NodeInterface for Validator { // Shut down the sync pool. trace!("Shutting down the sync pool..."); - self.shutdown.store(true, Ordering::SeqCst); + self.shutdown.store(true, Ordering::Relaxed); // Abort the tasks. trace!("Shutting down the validator..."); - self.handles.read().iter().for_each(|handle| handle.abort()); + self.handles.lock().iter().for_each(|handle| handle.abort()); // Shut down the router. self.router.shut_down().await; @@ -163,7 +163,7 @@ impl> Validator { // Start the sync loop. let validator = self.clone(); - self.handles.write().push(tokio::spawn(async move { + self.handles.lock().push(tokio::spawn(async move { loop { // If the Ctrl-C handler registered the signal, stop the node. if validator.shutdown.load(Ordering::Relaxed) { diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index 619aea6f52..26bf69698c 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -29,7 +29,7 @@ use snarkos_node_messages::{ UnconfirmedTransaction, }; use snarkos_node_tcp::{Connection, ConnectionSide, Tcp}; -use snarkvm::prelude::{error, Network, Transaction}; +use snarkvm::prelude::{error, EpochChallenge, Network, Transaction}; use futures_util::sink::SinkExt; use std::{io, net::SocketAddr, time::Duration}; @@ -62,8 +62,7 @@ impl> Handshake for Validator { }; // Send the first `Ping` message to the peer. - let message = - Message::Ping(Ping:: { version: Message::::VERSION, node_type: self.node_type(), block_locators }); + let message = Message::Ping(Ping::new(self.node_type(), block_locators)); trace!("Sending '{}' to '{peer_ip}'", message.name()); framed.send(message).await?; @@ -206,7 +205,7 @@ impl> Inbound for Validator { } /// Disconnects on receipt of a `PuzzleResponse` message. - fn puzzle_response(&self, peer_ip: SocketAddr, _serialized: PuzzleResponse, _header: Header) -> bool { + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { debug!("Disconnecting '{peer_ip}' for the following reason - {:?}", DisconnectReason::ProtocolViolation); false } @@ -225,9 +224,9 @@ impl> Inbound for Validator { } let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution" to the connected beacons. - self.propagate_to_beacons(message.clone(), vec![peer_ip]); + self.propagate_to_beacons(message.clone(), &[peer_ip]); // Propagate the "UnconfirmedSolution" to the connected validators. - self.propagate_to_validators(message, vec![peer_ip]); + self.propagate_to_validators(message, &[peer_ip]); true } @@ -240,9 +239,9 @@ impl> Inbound for Validator { ) -> bool { let message = Message::UnconfirmedTransaction(serialized); // Propagate the "UnconfirmedTransaction" to the connected beacons. - self.propagate_to_beacons(message.clone(), vec![peer_ip]); + self.propagate_to_beacons(message.clone(), &[peer_ip]); // Propagate the "UnconfirmedTransaction" to the connected validators. - self.propagate_to_validators(message, vec![peer_ip]); + self.propagate_to_validators(message, &[peer_ip]); true } } diff --git a/node/store/Cargo.toml b/node/store/Cargo.toml index fbc230b079..63677d61d4 100644 --- a/node/store/Cargo.toml +++ b/node/store/Cargo.toml @@ -35,7 +35,7 @@ version = "1.15" version = "0.12" [dependencies.rocksdb] -version = "0.19" +version = "0.20" default-features = false features = [ "lz4" ] diff --git a/node/store/src/rocksdb/map.rs b/node/store/src/rocksdb/map.rs index c723b4af56..2295410747 100644 --- a/node/store/src/rocksdb/map.rs +++ b/node/store/src/rocksdb/map.rs @@ -44,7 +44,7 @@ impl< /// fn insert(&self, key: K, value: V) -> Result<()> { // Determine if an atomic batch is in progress. - let is_batch = self.batch_in_progress.load(Ordering::SeqCst); + let is_batch = self.batch_in_progress.load(Ordering::Acquire); match is_batch { // If a batch is in progress, add the key-value pair to the batch. @@ -68,7 +68,7 @@ impl< /// fn remove(&self, key: &K) -> Result<()> { // Determine if an atomic batch is in progress. - let is_batch = self.batch_in_progress.load(Ordering::SeqCst); + let is_batch = self.batch_in_progress.load(Ordering::Acquire); match is_batch { // If a batch is in progress, add the key to the batch. @@ -92,7 +92,7 @@ impl< /// fn start_atomic(&self) { // Set the atomic batch flag to `true`. - self.batch_in_progress.store(true, Ordering::SeqCst); + self.batch_in_progress.store(true, Ordering::Relaxed); // Ensure that the atomic batch is empty. assert!(self.atomic_batch.lock().is_empty()); } @@ -103,7 +103,7 @@ impl< /// if they are already part of a larger one. /// fn is_atomic_in_progress(&self) -> bool { - self.batch_in_progress.load(Ordering::SeqCst) + self.batch_in_progress.load(Ordering::Acquire) } /// @@ -113,7 +113,7 @@ impl< // Clear the atomic batch. *self.atomic_batch.lock() = Default::default(); // Set the atomic batch flag to `false`. - self.batch_in_progress.store(false, Ordering::SeqCst); + self.batch_in_progress.store(false, Ordering::Release); } /// @@ -146,7 +146,7 @@ impl< } // Set the atomic batch flag to `false`. - self.batch_in_progress.store(false, Ordering::SeqCst); + self.batch_in_progress.store(false, Ordering::Release); Ok(()) } @@ -201,7 +201,7 @@ impl< K: Borrow, Q: PartialEq + Eq + Hash + Serialize + ?Sized, { - if self.batch_in_progress.load(Ordering::SeqCst) { self.atomic_batch.lock().get(key).cloned() } else { None } + if self.batch_in_progress.load(Ordering::Acquire) { self.atomic_batch.lock().get(key).cloned() } else { None } } /// diff --git a/node/tcp/src/tcp.rs b/node/tcp/src/tcp.rs index 4348a0ef50..ac84a676ea 100644 --- a/node/tcp/src/tcp.rs +++ b/node/tcp/src/tcp.rs @@ -86,7 +86,7 @@ impl Tcp { pub fn new(mut config: Config) -> Self { // If there is no pre-configured name, assign a sequential numeric identifier. if config.name.is_none() { - config.name = Some(SEQUENTIAL_NODE_ID.fetch_add(1, SeqCst).to_string()); + config.name = Some(SEQUENTIAL_NODE_ID.fetch_add(1, Relaxed).to_string()); } // Create a tracing span containing the node's name. diff --git a/node/tests/common/test_peer.rs b/node/tests/common/test_peer.rs index f85a23bc26..58105c720a 100644 --- a/node/tests/common/test_peer.rs +++ b/node/tests/common/test_peer.rs @@ -15,7 +15,8 @@ // along with the snarkOS library. If not, see . use snarkos_account::Account; -use snarkos_node_messages::{ChallengeRequest, ChallengeResponse, Data, Message, MessageCodec, NodeType}; +use snarkos_node_messages::{ChallengeRequest, ChallengeResponse, Data, Message, MessageCodec, MessageTrait, NodeType}; +use snarkos_node_router::expect_message; use snarkvm::prelude::{error, Address, Block, FromBytes, Network, TestRng, Testnet3 as CurrentNetwork}; use std::{ @@ -35,6 +36,7 @@ use pea2pea::{ Pea2Pea, }; use tokio_util::codec::Framed; +use tracing::*; const ALEO_MAXIMUM_FORK_DEPTH: u32 = 4096; @@ -119,47 +121,49 @@ impl Handshake for TestPeer { let local_ip = self.node().listening_addr().expect("listening address should be present"); + let peer_addr = conn.addr(); + let node_side = !conn.side(); let stream = self.borrow_stream(&mut conn); let mut framed = Framed::new(stream, MessageCodec::::default()); - // Send a challenge request to the peer. - let message = Message::::ChallengeRequest(ChallengeRequest { - version: Message::::VERSION, - listener_port: local_ip.port(), - node_type: self.node_type(), - address: self.address(), - nonce: rng.gen(), - }); - framed.send(message).await?; - - // Listen for the challenge request. - let request_b = match framed.try_next().await? { - // Received the challenge request message, proceed. - Some(Message::ChallengeRequest(data)) => data, - // Received a disconnect message, abort. - Some(Message::Disconnect(reason)) => return Err(error(format!("disconnected: {reason:?}"))), - // Received an unexpected message, abort. - _ => return Err(error("didn't send a challenge request")), - }; - - // TODO(nkls): add assertions on the contents. - - // Sign the nonce. - let signature = self.account().sign_bytes(&request_b.nonce.to_le_bytes(), rng).unwrap(); - // Retrieve the genesis block header. let genesis_header = *sample_genesis_block().header(); - // Send the challenge response. - let message = - Message::ChallengeResponse(ChallengeResponse { genesis_header, signature: Data::Object(signature) }); - framed.send(message).await?; - - // Receive the challenge response. - let Message::ChallengeResponse(challenge_response) = framed.try_next().await.unwrap().unwrap() else { - panic!("didn't get challenge response") - }; - assert_eq!(challenge_response.genesis_header, genesis_header); + // TODO(nkls): add assertions on the contents of messages. + match node_side { + ConnectionSide::Initiator => { + // Send a challenge request to the peer. + let our_request = ChallengeRequest::new(local_ip.port(), self.node_type(), self.address(), rng.gen()); + framed.send(Message::ChallengeRequest(our_request)).await?; + + // Receive the peer's challenge bundle. + let _peer_response = expect_message!(Message::ChallengeResponse, framed, peer_addr); + let peer_request = expect_message!(Message::ChallengeRequest, framed, peer_addr); + + // Sign the nonce. + let signature = self.account().sign_bytes(&peer_request.nonce.to_le_bytes(), rng).unwrap(); + + // Send the challenge response. + let our_response = ChallengeResponse { genesis_header, signature: Data::Object(signature) }; + framed.send(Message::ChallengeResponse(our_response)).await?; + } + ConnectionSide::Responder => { + // Listen for the challenge request. + let peer_request = expect_message!(Message::ChallengeRequest, framed, peer_addr); + + // Sign the nonce. + let signature = self.account().sign_bytes(&peer_request.nonce.to_le_bytes(), rng).unwrap(); + + // Send our challenge bundle. + let our_response = ChallengeResponse { genesis_header, signature: Data::Object(signature) }; + framed.send(Message::ChallengeResponse(our_response)).await?; + let our_request = ChallengeRequest::new(local_ip.port(), self.node_type(), self.address(), rng.gen()); + framed.send(Message::ChallengeRequest(our_request)).await?; + + // Listen for the challenge response. + let _peer_response = expect_message!(Message::ChallengeResponse, framed, peer_addr); + } + } Ok(conn) } diff --git a/snarkos/main.rs b/snarkos/main.rs index c5fe33b077..df6922d0f1 100644 --- a/snarkos/main.rs +++ b/snarkos/main.rs @@ -17,6 +17,10 @@ use snarkos_cli::{commands::CLI, helpers::Updater}; use clap::Parser; +use tikv_jemallocator::Jemalloc; + +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; fn main() -> anyhow::Result<()> { // Parse the given arguments.