From f4708835b440281e5a65ca714ba20c530d6845d5 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Fri, 25 Mar 2022 14:31:39 +0100 Subject: [PATCH 01/14] Use external transport crate #366 --- Cargo.lock | 769 ++++++++++++++++----------- Cargo.toml | 5 +- src/cli/customer.rs | 3 +- src/customer.rs | 4 +- src/database/customer.rs | 3 +- src/merchant.rs | 2 +- src/transport.rs | 89 +++- src/transport/channel.rs | 72 --- src/transport/client.rs | 362 ------------- src/transport/handshake.rs | 107 ---- src/transport/io_stream.rs | 62 --- src/transport/pem.rs | 67 --- src/transport/server.rs | 302 ----------- src/zkchannels/customer.rs | 7 +- src/zkchannels/customer/close.rs | 2 +- src/zkchannels/customer/establish.rs | 2 +- 16 files changed, 558 insertions(+), 1300 deletions(-) delete mode 100644 src/transport/channel.rs delete mode 100644 src/transport/client.rs delete mode 100644 src/transport/handshake.rs delete mode 100644 src/transport/io_stream.rs delete mode 100644 src/transport/pem.rs delete mode 100644 src/transport/server.rs diff --git a/Cargo.lock b/Cargo.lock index a1927177..3e38b263 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.7.6" @@ -13,15 +19,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -33,15 +30,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d9ff5d688f1c13395289f67db01d4826b46dd694e7580accdc3e8430f2d98e" - -[[package]] -name = "arrayvec" -version = "0.5.2" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" [[package]] name = "arrayvec" @@ -51,9 +42,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-trait" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" dependencies = [ "proc-macro2", "quote", @@ -82,9 +73,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base58" @@ -156,9 +147,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "byteorder" @@ -190,9 +181,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -214,11 +205,11 @@ checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term 0.11.0", + "ansi_term", "atty", "bitflags", "strsim 0.8.0", @@ -240,9 +231,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -256,9 +247,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" dependencies = [ "libc", ] @@ -279,20 +270,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" [[package]] -name = "crossbeam-channel" -version = "0.5.1" +name = "crc32fast" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils", ] [[package]] name = "crossbeam-queue" -version = "0.3.2" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9" +checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -300,9 +290,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ "cfg-if 1.0.0", "lazy_static", @@ -317,8 +307,8 @@ dependencies = [ "bitflags", "crossterm_winapi", "libc", - "mio", - "parking_lot", + "mio 0.7.14", + "parking_lot 0.11.2", "signal-hook", "signal-hook-mio", "winapi", @@ -345,9 +335,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" dependencies = [ "darling_core", "darling_macro", @@ -355,9 +345,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" dependencies = [ "fnv", "ident_case", @@ -369,9 +359,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" dependencies = [ "darling_core", "quote", @@ -448,7 +438,7 @@ dependencies = [ "derivative", "dialectic", "humantime-serde", - "rand 0.8.4", + "rand 0.8.5", "serde", "tokio", ] @@ -499,9 +489,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -535,9 +525,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.29" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if 1.0.0", ] @@ -554,6 +544,15 @@ dependencies = [ "ureq", ] +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + [[package]] name = "ff" version = "0.9.0" @@ -565,6 +564,30 @@ dependencies = [ "subtle", ] +[[package]] +name = "flate2" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" +dependencies = [ + "cfg-if 1.0.0", + "crc32fast", + "libc", + "miniz_oxide", +] + +[[package]] +name = "flume" +version = "0.10.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843c03199d0c0ca54bc1ea90ac0d507274c28abcc4f691ae8b4eaa375087c76a" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project", + "spin 0.9.2", +] + [[package]] name = "fnv" version = "1.0.7" @@ -610,9 +633,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", @@ -625,9 +648,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", "futures-sink", @@ -635,15 +658,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-executor" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", @@ -658,23 +681,21 @@ checksum = "62007592ac46aa7c2b6416f7deb9a8a8f63a01e0f1d6e1787d5630170db2b63e" dependencies = [ "futures-core", "lock_api", - "parking_lot", + "parking_lot 0.11.2", ] [[package]] name = "futures-io" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-macro" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ - "autocfg", - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -682,23 +703,22 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ - "autocfg", "futures-channel", "futures-core", "futures-io", @@ -708,8 +728,6 @@ dependencies = [ "memchr", "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] @@ -721,9 +739,9 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ "typenum", "version_check", @@ -731,13 +749,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -754,9 +772,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.7" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" +checksum = "62eeb471aa3e3c9197aa4bfeabfe02982f6dc96f750486c0bb0009ac58b26d2b" dependencies = [ "bytes", "fnv", @@ -815,9 +833,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hidapi" -version = "1.2.7" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f39cbe399e8e9550264e9f26553bf26f5ece2b6cf13abe32d06c857a5166263" +checksum = "c2ec6bf425a5c3af047bb2a029de540a7d74cefa4761f14be67d7884dcd497b0" dependencies = [ "cc", "libc", @@ -826,9 +844,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes", "fnv", @@ -848,9 +866,9 @@ dependencies = [ [[package]] name = "http-serde" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25698ac7002625796d5a7df8f0602400571da944c2edc1d5c268a6947dd4f692" +checksum = "6d98b3d9662de70952b14c4840ee0f37e23973542a363e2275f4b9d024ff6cca" dependencies = [ "http", "serde", @@ -858,9 +876,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" +checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" [[package]] name = "httpdate" @@ -876,9 +894,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "humantime-serde" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac34a56cfd4acddb469cc7fff187ed5ac36f498ba085caf8bbc725e3ff474058" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" dependencies = [ "humantime", "serde", @@ -886,9 +904,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.15" +version = "0.14.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c" +checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" dependencies = [ "bytes", "futures-channel", @@ -940,9 +958,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ "autocfg", "hashbrown", @@ -1004,30 +1022,30 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c" [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.8" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" dependencies = [ "wasm-bindgen", ] @@ -1104,9 +1122,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.107" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" [[package]] name = "libsodium-sys" @@ -1122,9 +1140,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.22.2" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d" +checksum = "d2cafc7c74096c336d9d27145f7ebd4f4b6f95ba16aa5a282387267e6925cb58" dependencies = [ "cc", "pkg-config", @@ -1145,18 +1163,18 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] [[package]] name = "log" -version = "0.4.14" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ "cfg-if 1.0.0", ] @@ -1194,6 +1212,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "mio" version = "0.7.14" @@ -1207,6 +1235,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "mio" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", + "winapi", +] + [[package]] name = "miow" version = "0.3.7" @@ -1249,20 +1291,19 @@ dependencies = [ [[package]] name = "nom" -version = "7.1.0" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" dependencies = [ "memchr", "minimal-lexical", - "version_check", ] [[package]] name = "ntapi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" dependencies = [ "winapi", ] @@ -1345,9 +1386,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", @@ -1366,9 +1407,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] name = "opaque-debug" @@ -1392,15 +1433,15 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.71" +version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df13d165e607909b363a4757a6f133f8a818a74e9d3a98d09c6128e15fa4c73" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ "autocfg", "cc", @@ -1427,7 +1468,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.1", ] [[package]] @@ -1444,6 +1495,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "paste" version = "0.1.18" @@ -1480,6 +1544,15 @@ dependencies = [ "regex", ] +[[package]] +name = "pem" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9a3b09a20e374558580a4914d3b7d89bd61b954a5a5e1dcbea98753addb1947" +dependencies = [ + "base64", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -1488,18 +1561,18 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pin-project" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" dependencies = [ "proc-macro2", "quote", @@ -1508,9 +1581,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] name = "pin-utils" @@ -1520,21 +1593,21 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "ppv-lite86" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro-crate" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ "thiserror", "toml", @@ -1570,41 +1643,35 @@ version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] [[package]] name = "protobuf" -version = "2.25.2" +version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c327e191621a2158159df97cdbc2e7074bb4e940275e35abf38eb3d2595754" +checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96" [[package]] name = "protobuf-codegen" -version = "2.25.2" +version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df8c98c08bd4d6653c2dbae00bd68c1d1d82a360265a5b0bbc73d48c63cb853" +checksum = "aec1632b7c8f2e620343439a7dfd1f3c47b18906c4be58982079911482b5d707" dependencies = [ "protobuf", ] [[package]] name = "protoc" -version = "2.25.2" +version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac70cfc8935f5db2a29c0929db697035d02284011a9b78a5ef5d48092ce9673" +checksum = "c2ef1dc036942fac2470fdb8a911f125404ee9129e9e807f3d12d8589001a38f" dependencies = [ "log", "which", @@ -1612,9 +1679,9 @@ dependencies = [ [[package]] name = "protoc-rust" -version = "2.25.2" +version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bad71c8404e3e09024fccbab55aae36e3662662167dc4530a242c8cc8ef8d20" +checksum = "1a9e315121c8e7e21396e940a3d27f92280a6d28e3931213bf6cbfea76c5cc94" dependencies = [ "protobuf", "protobuf-codegen", @@ -1631,7 +1698,7 @@ dependencies = [ "cfg-if 1.0.0", "indoc", "libc", - "parking_lot", + "parking_lot 0.11.2", "paste 0.1.18", "pyo3-build-config", "pyo3-macros", @@ -1672,9 +1739,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.10" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57" dependencies = [ "proc-macro2", ] @@ -1710,14 +1777,13 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", "rand_core 0.6.3", - "rand_hc", ] [[package]] @@ -1754,15 +1820,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core 0.6.3", -] - [[package]] name = "rdrand" version = "0.4.0" @@ -1780,28 +1837,29 @@ checksum = "8f8258dbe9cd2ac4fc41981ad7b298d9c6dcff8f21ee8a601aa72c425a4b4999" [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55" dependencies = [ "getrandom", "redox_syscall", + "thiserror", ] [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "regex-syntax", ] @@ -1832,15 +1890,16 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.6" +version = "0.11.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280" +checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" dependencies = [ "base64", "bytes", "encoding_rs", "futures-core", "futures-util", + "h2", "http", "http-body", "hyper", @@ -1858,6 +1917,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", + "tokio-util", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -1874,7 +1934,7 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", + "spin 0.5.2", "untrusted", "web-sys", "winapi", @@ -1922,20 +1982,20 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.17.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353775f96a1f400edcca737f843cb201af3645912e741e64456a257c770173e8" +checksum = "d37baa70cf8662d2ba1c1868c5983dda16ef32b105cce41fb5c47e72936a90b3" dependencies = [ - "arrayvec 0.5.2", + "arrayvec", "num-traits", "serde", ] [[package]] name = "rust_decimal_macros" -version = "1.17.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0847e5bbcded958275518f18a567fea27e53b22b52b549cc3557c88d780b22e" +checksum = "184abaf7b434800e1a5a8aad3ebc8cd7498df33af72d65371d797a264713a59b" dependencies = [ "quote", "rust_decimal", @@ -1962,9 +2022,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.1" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac4581f0fc0e0efd529d069e8189ec7b90b8e7680e21beb35141bdc45f36040" +checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" dependencies = [ "log", "ring", @@ -1974,9 +2034,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "rusty-money" @@ -1990,9 +2050,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "same-file" @@ -2041,9 +2101,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.4.2" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" dependencies = [ "bitflags", "core-foundation", @@ -2054,9 +2114,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.4.2" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ "core-foundation-sys", "libc", @@ -2064,9 +2124,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.130" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] @@ -2083,9 +2143,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -2094,11 +2154,10 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.71" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ - "indexmap", "itoa", "ryu", "serde", @@ -2106,9 +2165,9 @@ dependencies = [ [[package]] name = "serde_urlencoded" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", "itoa", @@ -2118,9 +2177,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad6056b4cb69b6e43e3a0f055def223380baecc99da683884f205bf347f7c4b3" +checksum = "ec1e6ec4d8950e5b1e894eac0d360742f3b1407a6078a604a731c4b3f49cefbc" dependencies = [ "rustversion", "serde", @@ -2141,9 +2200,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer", "cfg-if 1.0.0", @@ -2175,9 +2234,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c98891d737e271a2954825ef19e46bd16bdb98e2746f2eec4f7a4ef7946efd1" +checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d" dependencies = [ "libc", "signal-hook-registry", @@ -2190,7 +2249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4" dependencies = [ "libc", - "mio", + "mio 0.7.14", "signal-hook", ] @@ -2221,7 +2280,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa37347a2b4609765d113afe55f16636ccd42dadc1ad0d29030908d1bac4c95b" dependencies = [ - "rand 0.8.4", + "rand 0.8.5", ] [[package]] @@ -2232,15 +2291,15 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -2263,6 +2322,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5" +dependencies = [ + "lock_api", +] + [[package]] name = "sqlformat" version = "0.1.8" @@ -2276,9 +2344,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7911b0031a0247af40095838002999c7a52fba29d9739e93326e71a5a1bc9d43" +checksum = "fc15591eb44ffb5816a4a70a7efd5dd87bfd3aa84c4c200401c4396140525826" dependencies = [ "sqlx-core", "sqlx-macros", @@ -2286,9 +2354,9 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aec89bfaca8f7737439bad16d52b07f1ccd0730520d3bf6ae9d069fe4b641fb1" +checksum = "195183bf6ff8328bb82c0511a83faf60aacf75840103388851db61d7a9854ae3" dependencies = [ "ahash", "atoi", @@ -2296,12 +2364,12 @@ dependencies = [ "byteorder", "bytes", "crc", - "crossbeam-channel", "crossbeam-queue", - "crossbeam-utils", "either", + "flume", "futures-channel", "futures-core", + "futures-executor", "futures-intrusive", "futures-util", "hashlink", @@ -2313,7 +2381,7 @@ dependencies = [ "log", "memchr", "once_cell", - "parking_lot", + "paste 1.0.6", "percent-encoding", "rustls 0.19.1", "serde", @@ -2327,14 +2395,13 @@ dependencies = [ "url", "webpki 0.21.4", "webpki-roots 0.21.1", - "whoami", ] [[package]] name = "sqlx-macros" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "584866c833511b1a152e87a7ee20dee2739746f60c858b3c5209150bc4b466f5" +checksum = "eee35713129561f5e55c554bba1c378e2a7e67f81257b7311183de98c50e6f94" dependencies = [ "dotenv", "either", @@ -2354,13 +2421,13 @@ dependencies = [ [[package]] name = "sqlx-rt" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1bd069de53442e7a320f525a6d4deb8bb0621ac7a55f7eccbc2b58b57f43d0" +checksum = "b555e70fbbf84e269ec3858b7a6515bcfe7a166a7cc9c636dd6efd20431678b6" dependencies = [ "once_cell", "tokio", - "tokio-rustls", + "tokio-rustls 0.22.0", ] [[package]] @@ -2393,9 +2460,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "structopt" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ "clap", "lazy_static", @@ -2441,9 +2508,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.81" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" dependencies = [ "proc-macro2", "quote", @@ -2470,13 +2537,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if 1.0.0", + "fastrand", "libc", - "rand 0.8.4", "redox_syscall", "remove_dir_all", "winapi", @@ -2513,9 +2580,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ "once_cell", ] @@ -2553,29 +2620,29 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.14.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ - "autocfg", "bytes", "libc", "memchr", - "mio", + "mio 0.8.2", "num_cpus", "once_cell", - "parking_lot", + "parking_lot 0.12.0", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", "winapi", ] [[package]] name = "tokio-macros" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -2603,6 +2670,17 @@ dependencies = [ "webpki 0.21.4", ] +[[package]] +name = "tokio-rustls" +version = "0.23.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4151fda0cf2798550ad0b34bcfc9b9dcc2a9d2471c895c68f3a8818e54f2389e" +dependencies = [ + "rustls 0.20.4", + "tokio", + "webpki 0.22.0", +] + [[package]] name = "tokio-stream" version = "0.1.8" @@ -2645,9 +2723,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", @@ -2657,9 +2735,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.18" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" dependencies = [ "proc-macro2", "quote", @@ -2668,11 +2746,12 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c" dependencies = [ "lazy_static", + "valuable", ] [[package]] @@ -2698,11 +2777,11 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d81bfa81424cc98cb034b837c985b7a290f592e5b4322f353f94a0ab0f9f594" +checksum = "9e0ab7bdc962035a87fba73f3acca9b8a8d0034c2e6f60b84aeaaddddc155dce" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "lazy_static", "matchers", "regex", @@ -2714,6 +2793,29 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "transport" +version = "0.1.0" +source = "git+https://github.com/boltlabs-inc/transport.git?branch=main#7cbf46468c4e1b81cbdca343374f294fadeca1d6" +dependencies = [ + "bincode", + "dialectic", + "dialectic-reconnect", + "dialectic-tokio-serde", + "dialectic-tokio-serde-bincode", + "futures", + "pem 1.0.2", + "rustls 0.20.4", + "serde", + "thiserror", + "tokio", + "tokio-rustls 0.23.3", + "tracing", + "uuid", + "webpki 0.22.0", + "webpki-roots 0.22.2", +] + [[package]] name = "trezor_api" version = "0.1.0" @@ -2735,9 +2837,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "types" @@ -2769,9 +2871,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "unicode-width" @@ -2793,9 +2895,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] name = "unindent" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" +checksum = "514672a55d7380da379785a4d70ca8386c8883ff7eaae877be4d2081cebe73d8" [[package]] name = "untrusted" @@ -2805,20 +2907,21 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "ureq" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5c448dcb78ec38c7d59ec61f87f70a98ea19171e06c139357e012ee226fec90" +checksum = "9399fa2f927a3d327187cbd201480cee55bee6ac5d3c77dd27f0c6814cff16d5" dependencies = [ "base64", "chunked_transfer", + "flate2", "log", "once_cell", - "rustls 0.20.1", + "rustls 0.20.4", "serde", "serde_json", "url", "webpki 0.22.0", - "webpki-roots 0.22.1", + "webpki-roots 0.22.2", ] [[package]] @@ -2854,6 +2957,12 @@ dependencies = [ "serde", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -2868,9 +2977,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -2905,11 +3014,17 @@ 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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -2917,9 +3032,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" dependencies = [ "bumpalo", "lazy_static", @@ -2932,9 +3047,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -2944,9 +3059,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2954,9 +3069,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" dependencies = [ "proc-macro2", "quote", @@ -2967,15 +3082,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" dependencies = [ "js-sys", "wasm-bindgen", @@ -3012,34 +3127,24 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c475786c6f47219345717a043a37ec04cb4bc185e28853adcc4fa0a947eba630" +checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" dependencies = [ "webpki 0.22.0", ] [[package]] name = "which" -version = "4.2.2" +version = "4.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" +checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" dependencies = [ "either", "lazy_static", "libc", ] -[[package]] -name = "whoami" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33ac5ee236a4efbf2c98967e12c6cc0c51d93a744159a52957ba206ae6ef5f7" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - [[package]] name = "winapi" version = "0.3.9" @@ -3071,11 +3176,54 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" + +[[package]] +name = "windows_i686_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" + +[[package]] +name = "windows_i686_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" + [[package]] name = "winreg" -version = "0.7.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ "winapi", ] @@ -3114,9 +3262,9 @@ dependencies = [ "lib", "num", "num-traits", - "pem", + "pem 0.8.3", "pyo3", - "rand 0.8.4", + "rand 0.8.5", "read-restrict", "reqwest", "ring", @@ -3134,34 +3282,35 @@ dependencies = [ "strum_macros", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.22.0", "toml", "tracing", "tracing-futures", "tracing-subscriber", + "transport", "typenum", "url", "uuid", - "webpki 0.21.4", - "webpki-roots 0.21.1", + "webpki 0.22.0", + "webpki-roots 0.22.2", "zeroize", "zkabacus-crypto", ] [[package]] name = "zeroize" -version = "1.4.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" +checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.2.2" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65f1a51723ec88c66d5d1fe80c841f17f63587d6691901d66be9bec6c3b51f73" +checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" dependencies = [ "proc-macro2", "quote", @@ -3172,13 +3321,13 @@ dependencies = [ [[package]] name = "zkabacus-crypto" version = "0.1.0" -source = "git+https://github.com/boltlabs-inc/libzkchannels-crypto.git#da9b356a4ec075aeeb5875962f9783a24f6961a8" +source = "git+https://github.com/boltlabs-inc/libzkchannels-crypto.git#647de81ec2af2fe4fb6e0eaf513434a7fff12064" dependencies = [ "base64", "bincode", "bls12_381", "ff", - "rand 0.8.4", + "rand 0.8.5", "rand_core 0.6.3", "serde", "sha3", @@ -3190,15 +3339,15 @@ dependencies = [ [[package]] name = "zkchannels-crypto" version = "0.1.0" -source = "git+https://github.com/boltlabs-inc/libzkchannels-crypto.git#da9b356a4ec075aeeb5875962f9783a24f6961a8" +source = "git+https://github.com/boltlabs-inc/libzkchannels-crypto.git#647de81ec2af2fe4fb6e0eaf513434a7fff12064" dependencies = [ - "arrayvec 0.7.2", + "arrayvec", "bincode", "bls12_381", "ff", "group", "paste 1.0.6", - "rand 0.8.4", + "rand 0.8.5", "rand_core 0.6.3", "rust-crypto", "serde", diff --git a/Cargo.toml b/Cargo.toml index 61bca50f..1b9ca63e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,8 +32,8 @@ zkabacus-crypto = { git = "https://github.com/boltlabs-inc/libzkchannels-crypto. tokio = { version = "1", features = ["full"] } tokio-rustls = "0.22" anyhow = "1" -webpki = "0.21" -webpki-roots = "0.21" +webpki = "0.22" +webpki-roots = "0.22" async-trait = "0.1" sha2 = "0.9" sha3 = "0.9.1" @@ -82,6 +82,7 @@ canonicalize_json_micheline = { path = "src/canonicalize_json_micheline" } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-futures = "0.2" +transport = { git = "https://github.com/boltlabs-inc/transport.git", branch = "main", features = ["allow_explicit_certificate_trust"] } [dev-dependencies] rand = "0.8.3" diff --git a/src/cli/customer.rs b/src/cli/customer.rs index 2691153c..7600ea57 100644 --- a/src/cli/customer.rs +++ b/src/cli/customer.rs @@ -8,7 +8,8 @@ use { structopt::StructOpt, }; -use crate::{amount::Amount, customer::ChannelName, transport::client::ZkChannelAddress}; +use crate::transport::ZkChannelAddress; +use crate::{amount::Amount, customer::ChannelName}; /// The customer zkChannels command-line interface. #[derive(Debug, StructOpt)] diff --git a/src/customer.rs b/src/customer.rs index dd21db29..6fcac3c4 100644 --- a/src/customer.rs +++ b/src/customer.rs @@ -10,9 +10,9 @@ pub use crate::cli::{customer as cli, customer::Cli}; pub use crate::config::{customer as config, customer::Config}; pub use crate::database::customer as database; pub use crate::defaults::customer as defaults; -pub use crate::transport::client::{self as client, Chan, Client}; -pub use crate::transport::server::{self as server, Server}; pub use crate::zkchannels::customer as zkchannels; +pub use transport::client::{self as client, Chan, Client}; +pub use transport::server::{self as server, Server}; #[derive(Debug, Clone, sqlx::Type, Serialize, Deserialize)] #[sqlx(transparent)] diff --git a/src/database/customer.rs b/src/database/customer.rs index aa509345..4ff76dfa 100644 --- a/src/database/customer.rs +++ b/src/database/customer.rs @@ -15,7 +15,7 @@ use zkabacus_crypto::{ use tezedge::crypto::ToBase58Check; use crate::{ - customer::{client::ZkChannelAddress, ChannelName}, + customer::ChannelName, escrow::types::{ContractDetails, ContractId, TezosPublicKey}, }; @@ -23,6 +23,7 @@ mod state; use self::state::zkchannels_state::ZkChannelState; pub use super::connect_sqlite; +use crate::transport::ZkChannelAddress; pub use state::{zkchannels_state, State, StateName, UnexpectedState}; type Result = std::result::Result; diff --git a/src/merchant.rs b/src/merchant.rs index e7ce7128..1abf7405 100644 --- a/src/merchant.rs +++ b/src/merchant.rs @@ -2,5 +2,5 @@ pub use crate::cli::{merchant as cli, merchant::Cli}; pub use crate::config::{merchant as config, merchant::Config}; pub use crate::database::merchant as database; pub use crate::defaults::merchant as defaults; -pub use crate::transport::server::{self as server, Chan, Server}; pub use crate::zkchannels::merchant as zkchannels; +pub use transport::server::{self as server, Chan, Server}; diff --git a/src/transport.rs b/src/transport.rs index f3bc1e1b..9b0a7552 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -1,6 +1,83 @@ -mod channel; -pub mod client; -mod handshake; -pub mod io_stream; -pub mod pem; -pub mod server; +use crate::customer; +use crate::transport::client::Address; +use http::uri::InvalidUri; +use http::Uri; +use std::fmt; +use std::fmt::Display; +use std::str::FromStr; +use thiserror::Error; +use webpki::{DnsName, DnsNameRef, InvalidDnsNameError}; + +use transport::client; + +/// The address of a zkChannels merchant: a URI of the form `zkchannel://some.domain.com:2611` with +/// an optional port number. +#[derive(Debug, Clone, serde_with::SerializeDisplay, serde_with::DeserializeFromStr)] +pub struct ZkChannelAddress { + host: DnsName, + port: Option, +} + +impl Address for ZkChannelAddress { + fn get_host(&self) -> &DnsName { + &self.host + } + + fn get_port(&self) -> u16 { + self.port.unwrap_or_else(customer::defaults::port) + } +} + +zkabacus_crypto::impl_sqlx_for_bincode_ty!(ZkChannelAddress); + +#[derive(Debug, Error)] +#[non_exhaustive] +pub enum InvalidZkChannelAddress { + #[error("Incorrect URI scheme: expecting `zkchannel://`")] + IncorrectScheme, + #[error("Unexpected non-root path in `zkchannel://` address")] + UnsupportedPath, + #[error("Unexpected query string in `zkchannel://` address")] + UnsupportedQuery, + #[error("Missing hostname in `zkchannel://` address")] + MissingHost, + #[error("Invalid DNS hostname in `zkchannel://` address: {0}")] + InvalidDnsName(InvalidDnsNameError), + #[error("Invalid `zkchannel://` address: {0}")] + InvalidUri(InvalidUri), +} + +impl FromStr for ZkChannelAddress { + type Err = InvalidZkChannelAddress; + + fn from_str(s: &str) -> Result { + let uri: Uri = s.parse().map_err(InvalidZkChannelAddress::InvalidUri)?; + if uri.scheme_str() != Some("zkchannel") { + Err(InvalidZkChannelAddress::IncorrectScheme) + } else if uri.path() != "" && uri.path() != "/" { + Err(InvalidZkChannelAddress::UnsupportedPath) + } else if uri.query().is_some() { + Err(InvalidZkChannelAddress::UnsupportedQuery) + } else if let Some(host) = uri.host() { + Ok(ZkChannelAddress { + host: DnsNameRef::try_from_ascii_str(host) + .map_err(InvalidZkChannelAddress::InvalidDnsName)? + .to_owned(), + port: uri.port_u16(), + }) + } else { + Err(InvalidZkChannelAddress::MissingHost) + } + } +} + +impl Display for ZkChannelAddress { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let host: &str = self.host.as_ref().into(); + write!(f, "zkchannel://{}", host)?; + if let Some(port) = self.port { + write!(f, ":{}", port)?; + } + Ok(()) + } +} diff --git a/src/transport/channel.rs b/src/transport/channel.rs deleted file mode 100644 index acfb5200..00000000 --- a/src/transport/channel.rs +++ /dev/null @@ -1,72 +0,0 @@ -use { - dialectic::{Chan, Session}, - dialectic_reconnect::{resume, retry}, - dialectic_tokio_serde::{codec::LengthDelimitedCodec, Receiver, Sender, SymmetricalError}, - dialectic_tokio_serde_bincode::Bincode, - std::io, - tokio::{ - io::{ReadHalf, WriteHalf}, - net::TcpStream, - }, - tokio_rustls::webpki::DNSName, -}; - -use super::handshake::{Handshake, SessionKey}; -use super::io_stream::IoStream; - -/// A *server-side* session-typed channel over TCP using length-delimited bincode encoding for -/// serialization. -/// -/// The session type parameter for this channel is the session from **the client's perspective.** -pub type ServerChan = - ResumeSplitChan<::Dual, SessionKey, Bincode, LengthDelimitedCodec, IoStream>; - -/// A *client-side* session-typed channel over TCP using length-delimited bincode encoding for -/// serialization. -/// -/// The session type parameter for this channel is the session from **the client's perspective.** -pub type ClientChan = RetrySplitChan< - S, - SessionKey, - Handshake, - (DNSName, u16), - io::Error, - SymmetricalError, - Bincode, - LengthDelimitedCodec, - tokio_rustls::client::TlsStream, ->; - -/// An error in the underlying non-resuming transport. -pub type TransportError = SymmetricalError; - -// This tower of type synonyms builds up a: -// -// - retrying/resuming, -// - TLS-secured, -// - TCP-transported, -// - Dialectic channel, -// -// with the session type `S`: - -type ResumeSplitChan = - Chan, ResumeSplitReceiver>; - -type RetrySplitChan = Chan< - S, - RetrySplitSender, - RetrySplitReceiver, ->; - -type ResumeSplitSender = - resume::Sender, SplitReceiver>; -type ResumeSplitReceiver = - resume::Receiver, SplitReceiver>; - -type RetrySplitSender = - retry::Sender, SplitReceiver>; -type RetrySplitReceiver = - retry::Receiver, SplitReceiver>; - -type SplitSender = Sender>; -type SplitReceiver = Receiver>; diff --git a/src/transport/client.rs b/src/transport/client.rs deleted file mode 100644 index a0bed69e..00000000 --- a/src/transport/client.rs +++ /dev/null @@ -1,362 +0,0 @@ -//! The client side of Zeekoe's transport layer. - -use { - dialectic::prelude::*, - dialectic_reconnect::retry, - dialectic_tokio_serde::codec::LengthDelimitedCodec, - dialectic_tokio_serde::{RecvError, SendError}, - dialectic_tokio_serde_bincode::{length_delimited, Bincode}, - http::uri::{InvalidUri, Uri}, - std::{ - fmt::{self, Display}, - io, - marker::PhantomData, - str::FromStr, - sync::Arc, - time::Duration, - }, - thiserror::Error, - tokio::net::TcpStream, - tokio_rustls::{rustls, webpki::DNSName, TlsConnector}, - webpki::{DNSNameRef, InvalidDNSNameError}, -}; - -use super::{channel::TransportError, handshake}; -use crate::customer; - -#[cfg(feature = "allow_explicit_certificate_trust")] -use {super::pem, std::path::Path}; - -pub use super::channel::ClientChan as Chan; -pub use dialectic_reconnect::Backoff; -pub use handshake::SessionKey; - -/// The type of errors returned during sessions on a client-side channel. -pub type Error = retry::RetryError; - -#[cfg(all(not(debug_assertions), feature = "allow_explicit_certificate_trust"))] -compile_error!( - "crate cannot be built for release with the `allow_explicit_certificate_trust` feature enabled" -); - -/// A client for some session-typed `Protocol` which connects over TLS with a parameterizable -/// [`Backoff`] strategy for retrying lost connections. -/// -/// -/// The session type parameter for this type is the session from **the client's perspective.** -/// The session type parameter for this type is the session from **the client's perspective.** -#[derive(Clone)] -pub struct Client { - /// The number of bytes used to represent the length field in the length-delimited encoding. - length_field_bytes: usize, - /// The maximum length, in bytes, of messages to permit in serialization/deserialization. - /// Receiving or sending any larger messages will result in an error. - max_length: usize, - /// The backoff strategy for reconnecting to the server in the event of a connection loss. - backoff: Backoff, - /// The maximum permissible number of pending retries. - max_pending_retries: usize, - /// The timeout after which broken connections will be garbage-collected. - timeout: Option, - /// Client TLS configuration. - tls_config: rustls::ClientConfig, - /// Client session type. - client_session: PhantomData Protocol>, -} - -impl Client -where - Protocol: Session, -{ - /// Create a new [`Client`] with the specified [`Backoff`] strategy. - /// - /// There is no default backoff strategy, because there is no one-size-fits-all reasonable - /// default. - pub fn new(backoff: Backoff) -> Client { - let mut tls_config = rustls::ClientConfig::new(); - tls_config - .root_store - .add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS); - Client { - length_field_bytes: 4, - max_length: usize::MAX, - backoff, - tls_config, - max_pending_retries: usize::MAX, - timeout: None, - client_session: PhantomData, - } - } - /// - /// The session type parameter for this type is the session from **the client's perspective.** - - /// Set the number of bytes used to represent the length field in the length-delimited encoding. - pub fn length_field_bytes(&mut self, length_field_bytes: usize) -> &mut Self { - self.length_field_bytes = length_field_bytes; - self - } - - /// Set the maximum length, in bytes, of messages to permit in serialization/deserialization. - /// Receiving or sending any larger messages will result in an error. - pub fn max_length(&mut self, max_length: usize) -> &mut Self { - self.max_length = max_length; - self - } - - /// Set a maximum number of pending retries for all future [`Chan`]s produced by this - /// [`Client`]: an error will be thrown if a channel auto-retries more than this number of times - /// before the it is able to process the newly reconnected ends. - /// - /// Restricting this limit (the default is `usize::MAX`) prevents a potential unbounded memory - /// leak in the case where one a protocol only ever sends or only ever receives, and encounters - /// an unbounded number of errors. - pub fn max_pending_retries(&mut self, max_pending_retries: usize) -> &mut Self { - self.max_pending_retries = max_pending_retries.saturating_add(1); - self - } - - /// Set a timeout for recovery within all future [`Chan`]s produced by this [`Client`]: an - /// error will be thrown if recovery from an error takes longer than the given timeout, even if - /// the error recovery strategy specifies trying again. - pub fn timeout(&mut self, timeout: Option) -> &mut Self { - self.timeout = timeout; - self - } - - // Only on non-release builds that explicitly request this capability via the - // `allow_explicit_certificate_trust` feature, add the auxiliary trusted certificate to the set - // of trusted certificates. In release builds, it is not possible for the client to trust anyone - // other than the `webpki_roots::TLS_SERVER_ROOTS`. - #[cfg(feature = "allow_explicit_certificate_trust")] - pub fn trust_explicit_certificate( - &mut self, - trust_explicit_certificate: impl AsRef, - ) -> Result<&mut Self, io::Error> { - self.tls_config - .root_store - .add(&pem::read_single_certificate(trust_explicit_certificate)?) - .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Invalid certificate"))?; - Ok(self) - } - - pub async fn connect_zkchannel( - &self, - ZkChannelAddress { host, port }: &ZkChannelAddress, - ) -> Result<(SessionKey, Chan), Error> { - let port = port.unwrap_or_else(customer::defaults::port); - self.connect(host, port).await - } - - /// Connect to the given [`DNSName`] and port, returning either a connected [`Chan`] or an - /// error if connection and all re-connection attempts failed. - pub async fn connect( - &self, - host: &DNSName, - port: u16, - ) -> Result<(SessionKey, Chan), Error> { - // Share the TLS config between all times we connect - let tls_config = Arc::new(self.tls_config.clone()); - - // Address configuration - let length_field_bytes = self.length_field_bytes; - let max_length = self.max_length; - - // A closure that connects to the server we want to connect to - let connect = move |(domain, port): (DNSName, u16)| { - let tls_config = tls_config.clone(); - async move { - // Resolve the domain name we wish to connect to - let address_str: &str = AsRef::as_ref(&domain); - let mut addresses = tokio::net::lookup_host((address_str, port)).await?; - - // Attempt to connect to any of the socket addresses, succeeding on the first - let mut connection_error = None; - let tcp_stream = loop { - if let Some(address) = addresses.next() { - match TcpStream::connect(address).await { - Ok(tcp_stream) => { - // Session typed messages may be small; send them immediately - tcp_stream.set_nodelay(true)?; - break tcp_stream; - } - Err(e) => connection_error = Some(e), - } - } else { - return Err(connection_error.unwrap_or_else(|| { - io::Error::new( - io::ErrorKind::NotFound, - format!("unknown domain: {}", address_str), - ) - })); - } - }; - - // Wrap a TCP stream in a TLS connection, then wrap that in a Dialectic channel - let tls_connector = TlsConnector::from(tls_config); - let tls_stream = tls_connector.connect(domain.as_ref(), tcp_stream).await?; - let (rx, tx) = tokio::io::split(tls_stream); - let (tx, rx) = length_delimited(tx, rx, length_field_bytes, max_length); - Ok((tx, rx)) - } - }; - - retry::Connector::new( - connect, - handshake::client::init::<_, _, TransportError>, - handshake::client::retry::<_, _, TransportError>, - Protocol::default(), - ) - .recover_rx(reconnect_unless(&self.backoff, permanent_rx_error)) - .recover_tx(reconnect_unless(&self.backoff, permanent_tx_error)) - .recover_connect(reconnect_unless(&self.backoff, permanent_connect_error)) - .recover_handshake(reconnect_unless(&self.backoff, permanent_handshake_error)) - .timeout(self.timeout) - .max_pending_retries(self.max_pending_retries) - .connect((host.to_owned(), port)) - .await - .map_err(|e| { - // Convert error into general error type - use retry::RetryError::*; - match e { - OriginalError(e) => match e {}, - ConnectError(e) => ConnectError(e), - ConnectTimeout => ConnectTimeout, - HandshakeError(e) => HandshakeError(e), - HandshakeTimeout => HandshakeTimeout, - HandshakeIncomplete => HandshakeIncomplete, - NoCapacity => NoCapacity, - } - }) - } -} - -/// The address of a zkChannels merchant: a URI of the form `zkchannel://some.domain.com:2611` with -/// an optional port number. -#[derive(Debug, Clone, serde_with::SerializeDisplay, serde_with::DeserializeFromStr)] -pub struct ZkChannelAddress { - host: DNSName, - port: Option, -} - -zkabacus_crypto::impl_sqlx_for_bincode_ty!(ZkChannelAddress); - -#[derive(Debug, Error)] -#[non_exhaustive] -pub enum InvalidZkChannelAddress { - #[error("Incorrect URI scheme: expecting `zkchannel://`")] - IncorrectScheme, - #[error("Unexpected non-root path in `zkchannel://` address")] - UnsupportedPath, - #[error("Unexpected query string in `zkchannel://` address")] - UnsupportedQuery, - #[error("Missing hostname in `zkchannel://` address")] - MissingHost, - #[error("Invalid DNS hostname in `zkchannel://` address: {0}")] - InvalidDnsName(InvalidDNSNameError), - #[error("Invalid `zkchannel://` address: {0}")] - InvalidUri(InvalidUri), -} - -impl FromStr for ZkChannelAddress { - type Err = InvalidZkChannelAddress; - - fn from_str(s: &str) -> Result { - let uri: Uri = s.parse().map_err(InvalidZkChannelAddress::InvalidUri)?; - if uri.scheme_str() != Some("zkchannel") { - Err(InvalidZkChannelAddress::IncorrectScheme) - } else if uri.path() != "" && uri.path() != "/" { - Err(InvalidZkChannelAddress::UnsupportedPath) - } else if uri.query().is_some() { - Err(InvalidZkChannelAddress::UnsupportedQuery) - } else if let Some(host) = uri.host() { - Ok(ZkChannelAddress { - host: DNSNameRef::try_from_ascii_str(host) - .map_err(InvalidZkChannelAddress::InvalidDnsName)? - .to_owned(), - port: uri.port_u16(), - }) - } else { - Err(InvalidZkChannelAddress::MissingHost) - } - } -} - -impl Display for ZkChannelAddress { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let host: &str = self.host.as_ref().into(); - write!(f, "zkchannel://{}", host)?; - if let Some(port) = self.port { - write!(f, ":{}", port)?; - } - Ok(()) - } -} - -/// Given a backoff and a predicate on errors, return a reconnection strategy which uses that -/// backoff unless the predicate returns true. This is marginally more efficient than rebuilding the -/// backoff every time inside a closure. -fn reconnect_unless( - backoff: &Backoff, - unless: impl Fn(&E) -> bool, -) -> impl Fn(usize, &E) -> retry::Recovery { - let backoff = backoff.build(retry::Recovery::ReconnectAfter); - move |retries, error| { - if unless(error) { - retry::Recovery::Fail - } else { - backoff(retries, error) - } - } -} - -/// Determine if a given [`io::ErrorKind`] should be considered a permanent error, or if it should -/// be retried. If this predicate returns `false`, a retry is executed. -fn permanent_error_kind(error_kind: &io::ErrorKind) -> bool { - matches!( - error_kind, - io::ErrorKind::NotFound - | io::ErrorKind::PermissionDenied - | io::ErrorKind::ConnectionRefused - | io::ErrorKind::AddrInUse - | io::ErrorKind::AddrNotAvailable - | io::ErrorKind::InvalidInput - | io::ErrorKind::InvalidData - | io::ErrorKind::Unsupported - ) -} - -/// Determine if a sending error should be considered permanent. -fn permanent_tx_error(error: &SendError) -> bool { - permanent_error_kind(&match error { - SendError::Serialize(err) => match &**err { - bincode::ErrorKind::Io(err) => err.kind(), - _ => return true, - }, - SendError::Encode(err) => err.kind(), - }) -} - -/// Determine if a receiving error should be considered permanent. -fn permanent_rx_error(error: &RecvError) -> bool { - permanent_error_kind(&match error { - RecvError::Deserialize(err) => match &**err { - bincode::ErrorKind::Io(err) => err.kind(), - _ => return true, - }, - RecvError::Decode(err) => err.kind(), - RecvError::Closed => return true, - }) -} - -/// Determine if a connecting error should be considered permanent. -fn permanent_connect_error(error: &io::Error) -> bool { - permanent_error_kind(&error.kind()) -} - -/// Determine if a handshake error should be considered permanent. -fn permanent_handshake_error(error: &TransportError) -> bool { - match error { - dialectic_tokio_serde::Error::Send(err) => permanent_tx_error(err), - dialectic_tokio_serde::Error::Recv(err) => permanent_rx_error(err), - } -} diff --git a/src/transport/handshake.rs b/src/transport/handshake.rs deleted file mode 100644 index e4da8b3b..00000000 --- a/src/transport/handshake.rs +++ /dev/null @@ -1,107 +0,0 @@ -//! The definitions of the handshake protocol used when starting new connections and resuming broken -//! ones, and implementations of both the client and server side handshakes. - -use { - dialectic::prelude::*, - dialectic_reconnect::resume, - serde::{Deserialize, Serialize}, - uuid::Uuid, -}; - -/// A unique identifier for a client-server session, used when resuming lost connections. -#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] -pub struct SessionKey { - client_key: Uuid, - server_key: Uuid, -} - -impl SessionKey { - pub fn to_bytes(&self) -> [u8; 32] { - let mut bytes = [0; 32]; - for (index, byte) in self - .client_key - .as_bytes() - .iter() - .chain(self.server_key.as_bytes().iter()) - .enumerate() - { - bytes[index] = *byte; - } - bytes - } -} - -pub(crate) type Handshake = Session! { - choose { - 0 => { - // Send a freshly generated client session ID - send Uuid; - // Receive a freshly generated server session ID - recv Uuid; - }, - 1 => { - // Send the current pair of client/server session ID - send SessionKey; - } - } -}; - -pub(crate) mod server { - use super::*; - - #[Transmitter(Tx for Uuid)] - #[Receiver(Rx for Uuid, SessionKey)] - pub(crate) async fn handshake( - chan: Chan<::Dual, Tx, Rx>, - ) -> Result<(resume::ResumeKind, SessionKey), E> - where - E: From + From, - { - offer!(in chan { - 0 => { - let (client_key, chan) = chan.recv().await?; - let server_key = Uuid::new_v4(); - chan.send(server_key).await?.close(); - Ok((resume::ResumeKind::New, SessionKey { client_key, server_key })) - }, - 1 => { - let (session_key, chan) = chan.recv().await?; - chan.close(); - Ok((resume::ResumeKind::Existing, session_key)) - } - })? - } -} - -pub(super) mod client { - use super::*; - - #[Transmitter(Tx for Uuid, SessionKey)] - #[Receiver(Rx for Uuid)] - pub(crate) async fn init(chan: Chan) -> Result - where - E: From + From, - { - let client_key = Uuid::new_v4(); - let chan = chan.choose::<0>().await?.send(client_key).await?; - let (server_key, chan) = chan.recv().await?; - chan.close(); - Ok(SessionKey { - client_key, - server_key, - }) - } - - #[Transmitter(Tx for Uuid, SessionKey)] - #[Receiver(Rx for Uuid)] - pub(crate) async fn retry( - key: SessionKey, - chan: Chan, - ) -> Result<(), E> - where - E: From, - { - chan.choose::<1>().await?.send(key).await?.close(); - Ok(()) - } -} diff --git a/src/transport/io_stream.rs b/src/transport/io_stream.rs deleted file mode 100644 index e6867f20..00000000 --- a/src/transport/io_stream.rs +++ /dev/null @@ -1,62 +0,0 @@ -use std::pin::Pin; -use std::task::{Context, Poll}; -use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; -use tokio::net::TcpStream; -use tokio_rustls::server::TlsStream; - -pub enum IoStream { - Tcp(TcpStream), - Tls(Box>), -} - -impl AsyncRead for IoStream { - fn poll_read( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut ReadBuf<'_>, - ) -> Poll> { - match self.get_mut() { - IoStream::Tcp(stream) => Pin::new(stream).poll_read(cx, buf), - IoStream::Tls(stream) => Pin::new(stream).poll_read(cx, buf), - } - } -} - -impl AsyncWrite for IoStream { - fn poll_write( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &[u8], - ) -> Poll> { - match self.get_mut() { - IoStream::Tcp(stream) => Pin::new(stream).poll_write(cx, buf), - IoStream::Tls(stream) => Pin::new(stream).poll_write(cx, buf), - } - } - - fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - match self.get_mut() { - IoStream::Tcp(stream) => Pin::new(stream).poll_flush(cx), - IoStream::Tls(stream) => Pin::new(stream).poll_flush(cx), - } - } - - fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - match self.get_mut() { - IoStream::Tcp(stream) => Pin::new(stream).poll_shutdown(cx), - IoStream::Tls(stream) => Pin::new(stream).poll_shutdown(cx), - } - } -} - -impl From for IoStream { - fn from(stream: TcpStream) -> Self { - IoStream::Tcp(stream) - } -} - -impl From> for IoStream { - fn from(stream: TlsStream) -> Self { - IoStream::Tls(Box::new(stream)) - } -} diff --git a/src/transport/pem.rs b/src/transport/pem.rs deleted file mode 100644 index 28c04acc..00000000 --- a/src/transport/pem.rs +++ /dev/null @@ -1,67 +0,0 @@ -//! Utilities for reading PEM files as [`Certificate`]s and [`PrivateKey`]s, as necessary to -//! initialize TLS. - -use std::{fs::File, io, io::Read, path::Path}; -use tokio_rustls::rustls::{Certificate, PrivateKey}; - -/// Read the file at `path` into memory as a vector of PEM-encoded `CERTIFICATE`s, silently skipping -/// any entries in the file which are not labeled `CERTIFICATE`. -pub fn read_certificates(path: impl AsRef) -> Result, io::Error> { - let mut file = File::open(&path)?; - let mut contents = Vec::new(); - file.read_to_end(&mut contents)?; - - let mut certificates = Vec::new(); - for pem::Pem { contents, .. } in pem::parse_many(contents) - .into_iter() - .filter(|p| p.tag == "CERTIFICATE") - { - certificates.push(Certificate(contents)); - } - Ok(certificates) -} - -/// Read the file at `path` as a single PEM-encoded `CERTIFICATE`. -#[cfg(feature = "allow_explicit_certificate_trust")] -pub fn read_single_certificate(path: impl AsRef) -> Result { - let mut file = File::open(&path)?; - let mut contents = Vec::new(); - file.read_to_end(&mut contents)?; - - let pem = pem::parse(contents).map_err(|e| { - io::Error::new( - io::ErrorKind::InvalidData, - format!("invalid PEM encoding in certificate: {}", e), - ) - })?; - if pem.tag == "CERTIFICATE" { - Ok(Certificate(pem.contents)) - } else { - Err(io::Error::new( - io::ErrorKind::InvalidData, - format!("not labeled as a certificate: '{}'", pem.tag), - )) - } -} - -/// Read the file at `path` as a single PEM-encoded `PRIVATE KEY`. -pub fn read_private_key(path: impl AsRef) -> Result { - let mut file = File::open(&path)?; - let mut contents = Vec::new(); - file.read_to_end(&mut contents)?; - - let pem = pem::parse(contents).map_err(|e| { - io::Error::new( - io::ErrorKind::InvalidData, - format!("invalid PEM encoding in private key: {}", e), - ) - })?; - if pem.tag == "PRIVATE KEY" { - Ok(PrivateKey(pem.contents)) - } else { - Err(io::Error::new( - io::ErrorKind::InvalidData, - format!("not labeled as a private key: '{}'", pem.tag), - )) - } -} diff --git a/src/transport/server.rs b/src/transport/server.rs deleted file mode 100644 index 5cb9cf0c..00000000 --- a/src/transport/server.rs +++ /dev/null @@ -1,302 +0,0 @@ -//! The server side of Zeekoe's transport layer. - -use { - crate::TestLogs, - dialectic::prelude::*, - dialectic_reconnect::resume, - dialectic_tokio_serde::codec::LengthDelimitedCodec, - dialectic_tokio_serde_bincode::{length_delimited, Bincode}, - futures::{stream::FuturesUnordered, Future, StreamExt}, - std::{ - fmt::Debug, io, marker::PhantomData, net::SocketAddr, path::Path, sync::Arc, time::Duration, - }, - thiserror::Error, - tokio::{net::TcpListener, select, sync::mpsc}, - tokio_rustls::{rustls, TlsAcceptor}, - tracing::{error, info}, -}; - -use super::{channel::TransportError, handshake, io_stream::IoStream, pem}; - -pub use super::channel::ServerChan as Chan; -pub use handshake::SessionKey; - -/// A server for some `Protocol` which accepts resumable connections over TLS. -/// -/// The session type parameter for this type is the session from **the client's perspective.** -#[derive(Debug, Clone)] -pub struct Server { - /// The maximum length, in bytes, of messages to permit in serialization/deserialization. - /// Receiving or sending any larger messages will result in an error. - max_length: usize, - /// The number of bytes used to represent the length in length-delimited encoding. - length_field_bytes: usize, - /// The maximum permissible number of pending retries. - max_pending_retries: Option, - /// The timeout after which broken connections will be garbage-collected. - timeout: Option, - /// The session, from the *client's* perspective. - client_session: PhantomData Protocol>, -} - -type AcceptError = dialectic_reconnect::resume::AcceptError< - SessionKey, - dialectic_tokio_serde::Error, ->; - -#[derive(Debug, Error)] -pub enum ServerError { - #[error(transparent)] - Tcp(#[from] io::Error), - #[error("{0:?}")] - Task(TaskError), - #[error(transparent)] - Join(#[from] tokio::task::JoinError), - #[error("{0:?}")] - Accept(AcceptError), -} - -impl Default for Server -where - Protocol: Session, - ::Dual: Session, -{ - fn default() -> Self { - Self { - max_length: usize::MAX, - length_field_bytes: 4, - max_pending_retries: None, - timeout: None, - client_session: PhantomData, - } - } -} - -impl Server -where - Protocol: Session, - ::Dual: Session, -{ - /// Create a new server using the given certificate chain and private key. - pub fn new() -> Self { - Self::default() - } - - /// Set the number of bytes used to represent the length field in the length-delimited encoding. - pub fn length_field_bytes(&mut self, length_field_bytes: usize) -> &mut Self { - self.length_field_bytes = length_field_bytes; - self - } - - /// Set the maximum length, in bytes, of messages to permit in serialization/deserialization. - /// Receiving or sending any larger messages will result in an error. - pub fn max_length(&mut self, max_length: usize) -> &mut Self { - self.max_length = max_length; - self - } - - /// Set a timeout for recovery within all future [`Chan`]s handled by this [`Server`]. - /// - /// When there is a timeout, an error will be thrown if recovery from a previous error takes - /// longer than the given timeout, even if the error recovery strategy specifies trying again. - pub fn timeout(&mut self, timeout: Option) -> &mut Self { - self.timeout = timeout; - self - } - - /// Set the maximum number of pending retries for all future [`Chan`]s handled by this - /// [`Server`]. - /// - /// Restricting this limit (the default is `None`) prevents a potential unbounded memory leak in - /// the case where a mis-behaving client attempts to reconnect many times before either end of a - /// channel encounters an error and attempts to reconnect. - pub fn max_pending_retries(&mut self, max_pending_retries: Option) -> &mut Self { - self.max_pending_retries = max_pending_retries; - self - } - - /// Accept connections on `address` in a loop, running the `initialize` function when accepting. - /// If `initialize` returns `None`, stop; otherwise, concurrently serve each connection with - /// `interact`. - /// - /// Note that `initialize` runs sequentially: it can pause the server if desired by - /// `.await`-ing. - pub async fn serve_while< - Input, - Error, - Init, - InitFut, - Interaction, - InteractionFut, - TerminateFut, - >( - &self, - address: impl Into, - tls_config: Option<(&Path, &Path)>, - mut initialize: Init, - interact: Interaction, - terminate: TerminateFut, - ) -> Result<(), io::Error> - where - Input: Send + 'static, - Error: Send + Debug + 'static, - Init: FnMut() -> InitFut, - InitFut: Future>, - Interaction: - Fn(SessionKey, Input, Chan) -> InteractionFut + Send + Sync + 'static, - InteractionFut: Future> + Send + 'static, - TerminateFut: Future + Send + 'static, - { - let mut server_config = rustls::ServerConfig::new(rustls::NoClientAuth::new()); - - // Optionally configure server-side TLS - let tls_acceptor = match tls_config { - None => None, - Some((certificate_chain_path, private_key_path)) => { - let certificate_chain = pem::read_certificates(certificate_chain_path)?; - let private_key = pem::read_private_key(private_key_path)?; - - server_config - .set_single_cert(certificate_chain, private_key) - .map_err(|_error| { - io::Error::new( - io::ErrorKind::InvalidData, - "invalid server certificate chain or private key", - ) - })?; - Some(TlsAcceptor::from(Arc::new(server_config))) - } - }; - - // Resume-handling acceptor to be shared between all connections - let mut acceptor = resume::Acceptor::new( - handshake::server::handshake::<_, _, TransportError>, - <::Dual>::default(), - ); - acceptor - .timeout(self.timeout) - .max_pending_retries(self.max_pending_retries); - let acceptor = Arc::new(acceptor); - - // Error handling task awaits the result of each spawned server task and logs any errors - // that occur, as they occur - let (result_tx, result_rx) = mpsc::unbounded_channel(); - let error_join_handle = tokio::spawn(error_handler(result_rx)); - - // Listen for the termination event and forward it to stop the server - let (stop_server, mut recv_stop_server) = mpsc::channel(1); - tokio::spawn(async move { - terminate.await; - stop_server.send(()).await.unwrap_or(()); - }); - - // Wrap the server function in an `Arc` to share it between threads - let interact = Arc::new(interact); - - // Bind to the address and serve - let address = address.into(); - info!("{}", TestLogs::MerchantServerSpawned(address.to_string())); - let listener = TcpListener::bind(address).await?; - - // Loop over incoming TCP connections until `initialize` returns `None` - while let Some(input) = initialize().await { - // If the termination future returns before a new connection, stop - let accept_result = tokio::select! { - result = listener.accept() => result, - () = async { recv_stop_server.recv().await.unwrap_or(()) } => break, - }; - - match accept_result { - Err(err) => result_tx.send(Err(err.into())).unwrap_or(()), - Ok((tcp_stream, addr)) => { - tcp_stream.set_nodelay(true)?; - - let io_stream = match tls_acceptor { - None => IoStream::from(tcp_stream), - Some(ref acceptor) => match acceptor.accept(tcp_stream).await { - Ok(tls_stream) => IoStream::from(tls_stream), - Err(e) => { - error!("Server TLS initialization error [{}]: {}", addr, e); - continue; - } - }, - }; - - // Layer a length-delimmited bincode `Chan` over the TLS stream - let (rx, tx) = tokio::io::split(io_stream); - let (tx, rx) = - length_delimited(tx, rx, self.length_field_bytes, self.max_length); - - let acceptor = acceptor.clone(); - let interact = interact.clone(); - - // Run the interaction concurrently, or resume it if it's resuming an - // existing one - let join_handle = tokio::spawn(async move { - let result = acceptor.accept(tx, rx).await; - run_interaction::(result, input, interact).await - }); - - // Keep track of pending server task - result_tx.send(Ok(join_handle)).unwrap_or(()); - } - } - } - - error_join_handle.await?; - Ok(()) - } -} - -type JoinHandle = tokio::task::JoinHandle>>; - -/// Run the interaction on a single connection. -async fn run_interaction( - result: Result<(SessionKey, Option>), AcceptError>, - input: Input, - interact: Arc, -) -> Result<(), ServerError> -where - Protocol: Session, - ::Dual: Session, - InteractionFut: Future> + Send + 'static, - Interaction: Fn(SessionKey, Input, Chan) -> InteractionFut + Send + Sync + 'static, - Error: Debug + 'static, -{ - match result.map_err(ServerError::Accept)? { - (session_key, Some(chan)) => interact(session_key, input, chan) - .await - .map_err(ServerError::Task)?, - (_session_key, None) => { - // reconnected existing channel, nothing more to do - } - } - Ok::<_, ServerError>(()) -} - -/// Handle errors on the provided `Receiver`. -async fn error_handler( - mut result_rx: mpsc::UnboundedReceiver, ServerError>>, -) { - let mut results = FuturesUnordered::new(); - loop { - select! { - Some(incoming) = result_rx.recv() => { - match incoming { - Ok(join_handle) => results.push(async move { - let join_handle: JoinHandle = join_handle; - join_handle.await.map_err(ServerError::Join).and_then(|r| r) - }), - Err(err) => error!("{}", err), - } - }, - Some(result) = results.next() => { - match result { - Ok(()) => {}, - Err(err) => error!("{}", err), - } - }, - else => break, - } - } -} diff --git a/src/zkchannels/customer.rs b/src/zkchannels/customer.rs index 9e5de4d8..610442bd 100644 --- a/src/zkchannels/customer.rs +++ b/src/zkchannels/customer.rs @@ -2,6 +2,7 @@ #[cfg(not(feature = "allow_explicit_certificate_trust"))] use tracing::warn; +use webpki::DnsNameRef; use { anyhow::Context, @@ -10,12 +11,11 @@ use { sqlx::SqlitePool, std::{sync::Arc, time::Duration}, thiserror::Error, - webpki::DNSNameRef, }; use crate::{ customer::{ - client::{Backoff, SessionKey, ZkChannelAddress}, + client::{Backoff, SessionKey}, config::DatabaseLocation, database::{self, connect_sqlite, QueryCustomer}, defaults, Chan, ChannelName, Client, Config, @@ -30,6 +30,7 @@ mod manage; mod pay; mod watch; +use crate::transport::ZkChannelAddress; pub use manage::PublicChannelDetails; /// A single customer-side command, parameterized by the currently loaded configuration. @@ -93,7 +94,7 @@ pub async fn connect_daemon( let mut backoff = Backoff::with_delay(Duration::ZERO); backoff.max_retries(0); - let address = DNSNameRef::try_from_ascii_str("localhost").unwrap(); + let address = DnsNameRef::try_from_ascii_str("localhost").unwrap(); let client: Client = Client::new(backoff); Ok(client.connect(&address.into(), config.daemon_port).await?) } diff --git a/src/zkchannels/customer/close.rs b/src/zkchannels/customer/close.rs index ed16ca2c..0f965dd0 100644 --- a/src/zkchannels/customer/close.rs +++ b/src/zkchannels/customer/close.rs @@ -16,13 +16,13 @@ use crate::{ abort, customer::{ cli::Close, - client::ZkChannelAddress, database::{zkchannels_state, QueryCustomer, QueryCustomerExt, State}, Chan, ChannelName, Config, }, offer_abort, proceed, protocol::{close, Party::Customer}, timeout::WithTimeout, + transport::ZkChannelAddress, }; use zkabacus_crypto::{ customer::ClosingMessage, ChannelId, CloseState, CloseStateSignature, CustomerBalance, diff --git a/src/zkchannels/customer/establish.rs b/src/zkchannels/customer/establish.rs index 7ef2f31d..173b95d5 100644 --- a/src/zkchannels/customer/establish.rs +++ b/src/zkchannels/customer/establish.rs @@ -18,7 +18,6 @@ use crate::{ abort, customer::{ cli::Establish, - client::ZkChannelAddress, database::{zkchannels_state, QueryCustomer, QueryCustomerExt, State}, Chan, ChannelName, Config, }, @@ -29,6 +28,7 @@ use crate::{ offer_abort, proceed, protocol::{establish, Party::Customer}, timeout::WithTimeout, + transport::ZkChannelAddress, }; use tezedge::crypto::Prefix; From ed501a1333d6a907c60be50bfb23f9fccecea5d9 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Fri, 25 Mar 2022 14:45:11 +0100 Subject: [PATCH 02/14] Add CI on PR #366 --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cb405cf1..cdad9c83 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,6 +3,8 @@ name: Rust on: push: branches: [ main ] + pull_request: + branches: [ main ] jobs: build: From 45251ead12d528fb577f72af78014af50fe20504 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Fri, 25 Mar 2022 15:00:30 +0100 Subject: [PATCH 03/14] Make transport public for docs #366 --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4afec61d..d02964b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ mod cli; mod config; mod database; mod defaults; -mod transport; +pub mod transport; mod zkchannels; use std::fmt; From 9324928e1951da2f9665a9f664378e7d5fe543ee Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Fri, 25 Mar 2022 15:31:42 +0100 Subject: [PATCH 04/14] Reintroduce logging that is tracked by the tests #366 --- src/zkchannels/merchant.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/zkchannels/merchant.rs b/src/zkchannels/merchant.rs index eb9c1c49..28db9f67 100644 --- a/src/zkchannels/merchant.rs +++ b/src/zkchannels/merchant.rs @@ -7,7 +7,7 @@ use { futures::stream::{FuturesUnordered, StreamExt}, rand::{rngs::StdRng, SeedableRng}, sqlx::SqlitePool, - std::{sync::Arc, time::Duration}, + std::{net::SocketAddr, sync::Arc, time::Duration}, tokio::signal, tokio::sync::broadcast, tracing::{error, info}, @@ -25,6 +25,7 @@ use crate::{ Chan, Config, Server, }, protocol::{ChannelStatus, ZkChannels}, + TestLogs, }; mod approve; @@ -165,6 +166,8 @@ impl Command for Run { wait_terminate, ) .await?; + let address: SocketAddr = address.into(); + info!("{}", TestLogs::MerchantServerSpawned(address.to_string())); Ok::<_, anyhow::Error>(()) } }) @@ -298,10 +301,10 @@ async fn dispatch_channel( database, &channel.channel_id, ) - .await - .context( - "Failed to finalize mutual close - perhaps the contract was closed by a different flow", - )?; + .await + .context( + "Failed to finalize mutual close - perhaps the contract was closed by a different flow", + )?; } Ok(()) @@ -323,7 +326,7 @@ pub async fn database(config: &Config) -> Result, anyhow: DatabaseLocation::Postgres(_) => { return Err(anyhow::anyhow!( "Postgres database support is not yet implemented" - )) + )); } }; Ok(database) From 2d7f071be6c46a93c4cc75c64b0930564a282f39 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Fri, 25 Mar 2022 15:56:14 +0100 Subject: [PATCH 05/14] Move logging back to transport #366 --- src/zkchannels/merchant.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/zkchannels/merchant.rs b/src/zkchannels/merchant.rs index 28db9f67..bac8e469 100644 --- a/src/zkchannels/merchant.rs +++ b/src/zkchannels/merchant.rs @@ -166,8 +166,6 @@ impl Command for Run { wait_terminate, ) .await?; - let address: SocketAddr = address.into(); - info!("{}", TestLogs::MerchantServerSpawned(address.to_string())); Ok::<_, anyhow::Error>(()) } }) From 2762e292ef25c1807159be5e89f2519ba1d207f0 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Thu, 31 Mar 2022 12:24:31 +0200 Subject: [PATCH 06/14] Use FnOnce when server is up and running #366 --- Cargo.lock | 98 +++++++++++++++++++------------------- Cargo.toml | 2 +- src/customer.rs | 4 +- src/lib.rs | 2 +- src/zkchannels/merchant.rs | 3 +- 5 files changed, 55 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e38b263..ba27a19f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,9 +42,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-trait" -version = "0.1.52" +version = "0.1.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" +checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600" dependencies = [ "proc-macro2", "quote", @@ -749,9 +749,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if 1.0.0", "libc", @@ -958,9 +958,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" dependencies = [ "autocfg", "hashbrown", @@ -1163,10 +1163,11 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ + "autocfg", "scopeguard", ] @@ -1260,9 +1261,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" dependencies = [ "lazy_static", "libc", @@ -1478,7 +1479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ "lock_api", - "parking_lot_core 0.9.1", + "parking_lot_core 0.9.2", ] [[package]] @@ -1497,9 +1498,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" dependencies = [ "cfg-if 1.0.0", "libc", @@ -1520,9 +1521,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" [[package]] name = "paste-impl" @@ -1593,9 +1594,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "ppv-lite86" @@ -1739,9 +1740,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57" +checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" dependencies = [ "proc-macro2", ] @@ -1837,18 +1838,18 @@ checksum = "8f8258dbe9cd2ac4fc41981ad7b298d9c6dcff8f21ee8a601aa72c425a4b4999" [[package]] name = "redox_syscall" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", @@ -1982,9 +1983,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.22.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37baa70cf8662d2ba1c1868c5983dda16ef32b105cce41fb5c47e72936a90b3" +checksum = "22dc69eadbf0ee2110b8d20418c0c6edbaefec2811c4963dc17b6344e11fe0f8" dependencies = [ "arrayvec", "num-traits", @@ -1993,9 +1994,9 @@ dependencies = [ [[package]] name = "rust_decimal_macros" -version = "1.22.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "184abaf7b434800e1a5a8aad3ebc8cd7498df33af72d65371d797a264713a59b" +checksum = "a4c70be9367d4bc095d10b48d41b819d09ed4dafc528765a144d32ed1d530654" dependencies = [ "quote", "rust_decimal", @@ -2133,12 +2134,11 @@ dependencies = [ [[package]] name = "serde-big-array" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18b20e7752957bbe9661cff4e0bb04d183d0948cdab2ea58cdb9df36a61dfe62" +checksum = "cd31f59f6fe2b0c055371bb2f16d7f0aa7d8881676c04a55b1596d1a17cd10a4" dependencies = [ "serde", - "serde_derive", ] [[package]] @@ -2244,9 +2244,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", "mio 0.7.14", @@ -2381,7 +2381,7 @@ dependencies = [ "log", "memchr", "once_cell", - "paste 1.0.6", + "paste 1.0.7", "percent-encoding", "rustls 0.19.1", "serde", @@ -2508,9 +2508,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" +checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f" dependencies = [ "proc-macro2", "quote", @@ -2796,7 +2796,7 @@ dependencies = [ [[package]] name = "transport" version = "0.1.0" -source = "git+https://github.com/boltlabs-inc/transport.git?branch=main#7cbf46468c4e1b81cbdca343374f294fadeca1d6" +source = "git+https://github.com/boltlabs-inc/transport.git?branch=fix-integration-test#2e2c15adc65dad89a34a428178a93c58ee50adbf" dependencies = [ "bincode", "dialectic", @@ -3178,9 +3178,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.32.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825" dependencies = [ "windows_aarch64_msvc", "windows_i686_gnu", @@ -3191,33 +3191,33 @@ dependencies = [ [[package]] name = "windows_aarch64_msvc" -version = "0.32.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" +checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" [[package]] name = "windows_i686_gnu" -version = "0.32.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" +checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" [[package]] name = "windows_i686_msvc" -version = "0.32.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" +checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" [[package]] name = "windows_x86_64_gnu" -version = "0.32.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" +checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" [[package]] name = "windows_x86_64_msvc" -version = "0.32.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" +checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" [[package]] name = "winreg" @@ -3346,7 +3346,7 @@ dependencies = [ "bls12_381", "ff", "group", - "paste 1.0.6", + "paste 1.0.7", "rand 0.8.5", "rand_core 0.6.3", "rust-crypto", diff --git a/Cargo.toml b/Cargo.toml index 1b9ca63e..82266f7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,7 +82,7 @@ canonicalize_json_micheline = { path = "src/canonicalize_json_micheline" } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-futures = "0.2" -transport = { git = "https://github.com/boltlabs-inc/transport.git", branch = "main", features = ["allow_explicit_certificate_trust"] } +transport = { git = "https://github.com/boltlabs-inc/transport.git", branch = "fix-integration-test", features = ["allow_explicit_certificate_trust"] } [dev-dependencies] rand = "0.8.3" diff --git a/src/customer.rs b/src/customer.rs index 6fcac3c4..58be9e13 100644 --- a/src/customer.rs +++ b/src/customer.rs @@ -11,8 +11,8 @@ pub use crate::config::{customer as config, customer::Config}; pub use crate::database::customer as database; pub use crate::defaults::customer as defaults; pub use crate::zkchannels::customer as zkchannels; -pub use transport::client::{self as client, Chan, Client}; -pub use transport::server::{self as server, Server}; +pub use transport::client::{self, Chan, Client}; +pub use transport::server::{self, Server}; #[derive(Debug, Clone, sqlx::Type, Serialize, Deserialize)] #[sqlx(transparent)] diff --git a/src/lib.rs b/src/lib.rs index d02964b2..4afec61d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ mod cli; mod config; mod database; mod defaults; -pub mod transport; +mod transport; mod zkchannels; use std::fmt; diff --git a/src/zkchannels/merchant.rs b/src/zkchannels/merchant.rs index bac8e469..46ca2b42 100644 --- a/src/zkchannels/merchant.rs +++ b/src/zkchannels/merchant.rs @@ -7,7 +7,7 @@ use { futures::stream::{FuturesUnordered, StreamExt}, rand::{rngs::StdRng, SeedableRng}, sqlx::SqlitePool, - std::{net::SocketAddr, sync::Arc, time::Duration}, + std::{sync::Arc, time::Duration}, tokio::signal, tokio::sync::broadcast, tracing::{error, info}, @@ -164,6 +164,7 @@ impl Command for Run { initialize, interact, wait_terminate, + |address| info!("{}", TestLogs::MerchantServerSpawned(address)), ) .await?; Ok::<_, anyhow::Error>(()) From 7dcd1e0b66356a4b23ee7bc09a290b0c8cac806b Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Thu, 31 Mar 2022 12:57:58 +0200 Subject: [PATCH 07/14] Make transport public again #366 --- Cargo.toml | 1 + src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 82266f7d..c0fd50bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,6 +82,7 @@ canonicalize_json_micheline = { path = "src/canonicalize_json_micheline" } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-futures = "0.2" +#TODO: change transport to main branch transport = { git = "https://github.com/boltlabs-inc/transport.git", branch = "fix-integration-test", features = ["allow_explicit_certificate_trust"] } [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 4afec61d..1ac2bda9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,12 +5,12 @@ pub mod escrow; pub mod merchant; pub mod protocol; pub mod timeout; +pub mod transport; mod cli; mod config; mod database; mod defaults; -mod transport; mod zkchannels; use std::fmt; From 081f64fbdc883540d8a47c0258ca7e33a3ff3dc9 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Fri, 8 Apr 2022 09:49:37 +0200 Subject: [PATCH 08/14] Add import_granularity=Crate --- Cargo.lock | 120 +++++++++++++++------------ integration_tests/common.rs | 18 ++-- integration_tests/main.rs | 22 +++-- rustfmt.toml | 1 + src/amount.rs | 18 ++-- src/bin/customer.rs | 12 ++- src/bin/merchant.rs | 5 +- src/cli/customer.rs | 17 ++-- src/cli/merchant.rs | 3 +- src/config.rs | 8 +- src/config/customer.rs | 12 ++- src/config/merchant.rs | 12 +-- src/customer.rs | 28 ++++--- src/database.rs | 3 +- src/database/customer.rs | 20 ++--- src/database/customer/state.rs | 8 +- src/database/merchant.rs | 20 +++-- src/defaults.rs | 14 ++-- src/escrow/mod.rs | 16 ++-- src/escrow/notify.rs | 24 +++--- src/escrow/tezos.rs | 32 ++++--- src/merchant.rs | 12 +-- src/protocol.rs | 16 ++-- src/timeout.rs | 5 +- src/transport.rs | 10 +-- src/zkchannels/customer.rs | 14 ++-- src/zkchannels/customer/close.rs | 10 +-- src/zkchannels/customer/establish.rs | 12 ++- src/zkchannels/customer/manage.rs | 16 ++-- src/zkchannels/customer/pay.rs | 10 +-- src/zkchannels/customer/watch.rs | 14 ++-- src/zkchannels/merchant.rs | 21 ++--- src/zkchannels/merchant/approve.rs | 3 +- src/zkchannels/merchant/close.rs | 3 +- src/zkchannels/merchant/establish.rs | 3 +- src/zkchannels/merchant/manage.rs | 14 ++-- src/zkchannels/merchant/pay.rs | 3 +- 37 files changed, 284 insertions(+), 295 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba27a19f..85cc371f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -335,9 +335,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" dependencies = [ "darling_core", "darling_macro", @@ -345,9 +345,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" dependencies = [ "fnv", "ident_case", @@ -359,9 +359,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core", "quote", @@ -453,7 +453,7 @@ dependencies = [ "serde", "thiserror", "tokio", - "tokio-util", + "tokio-util 0.6.9", ] [[package]] @@ -466,7 +466,7 @@ dependencies = [ "dialectic-tokio-serde", "serde", "tokio", - "tokio-util", + "tokio-util 0.6.9", ] [[package]] @@ -525,9 +525,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.30" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ "cfg-if 1.0.0", ] @@ -772,9 +772,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62eeb471aa3e3c9197aa4bfeabfe02982f6dc96f750486c0bb0009ac58b26d2b" +checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" dependencies = [ "bytes", "fnv", @@ -785,7 +785,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util", + "tokio-util 0.7.1", "tracing", ] @@ -833,9 +833,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hidapi" -version = "1.3.4" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ec6bf425a5c3af047bb2a029de540a7d74cefa4761f14be67d7884dcd497b0" +checksum = "253bfb01a7a31d71212dc3e920540546fa4a4fe08e2d87fc3299c42bae7ee2f9" dependencies = [ "cc", "libc", @@ -1043,9 +1043,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "js-sys" -version = "0.3.56" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" +checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" dependencies = [ "wasm-bindgen", ] @@ -1122,9 +1122,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.121" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" +checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259" [[package]] name = "libsodium-sys" @@ -1646,9 +1646,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" dependencies = [ "unicode-xid", ] @@ -1918,7 +1918,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-util", + "tokio-util 0.6.9", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -2177,9 +2177,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec1e6ec4d8950e5b1e894eac0d360742f3b1407a6078a604a731c4b3f49cefbc" +checksum = "946fa04a8ac43ff78a1f4b811990afb9ddbdf5890b46d6dda0ba1998230138b7" dependencies = [ "rustversion", "serde", @@ -2188,9 +2188,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" dependencies = [ "darling", "proc-macro2", @@ -2285,9 +2285,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" [[package]] name = "smallvec" @@ -2508,9 +2508,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f" +checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" dependencies = [ "proc-macro2", "quote", @@ -2706,6 +2706,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-util" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0edfdeb067411dba2044da6d1cb2df793dd35add7888d73c16e3381ded401764" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.8" @@ -2746,9 +2760,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c" +checksum = "90442985ee2f57c9e1b548ee72ae842f4a9a20e3f417cc38dbc5dc684d9bb4ee" dependencies = [ "lazy_static", "valuable", @@ -2777,9 +2791,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e0ab7bdc962035a87fba73f3acca9b8a8d0034c2e6f60b84aeaaddddc155dce" +checksum = "b9df98b037d039d03400d9dd06b0f8ce05486b5f25e9a2d7d36196e142ebbc52" dependencies = [ "ansi_term", "lazy_static", @@ -2813,7 +2827,7 @@ dependencies = [ "tracing", "uuid", "webpki 0.22.0", - "webpki-roots 0.22.2", + "webpki-roots 0.22.3", ] [[package]] @@ -2921,7 +2935,7 @@ dependencies = [ "serde_json", "url", "webpki 0.22.0", - "webpki-roots 0.22.2", + "webpki-roots 0.22.3", ] [[package]] @@ -3022,9 +3036,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" +checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -3032,9 +3046,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" +checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" dependencies = [ "bumpalo", "lazy_static", @@ -3047,9 +3061,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" +checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3059,9 +3073,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" +checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3069,9 +3083,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" +checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" dependencies = [ "proc-macro2", "quote", @@ -3082,15 +3096,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" +checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" [[package]] name = "web-sys" -version = "0.3.56" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" +checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" dependencies = [ "js-sys", "wasm-bindgen", @@ -3127,9 +3141,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" +checksum = "44d8de8415c823c8abd270ad483c6feeac771fad964890779f9a8cb24fbbc1bf" dependencies = [ "webpki 0.22.0", ] @@ -3292,7 +3306,7 @@ dependencies = [ "url", "uuid", "webpki 0.22.0", - "webpki-roots 0.22.2", + "webpki-roots 0.22.3", "zeroize", "zkabacus-crypto", ] diff --git a/integration_tests/common.rs b/integration_tests/common.rs index f780a06d..59f1d93f 100644 --- a/integration_tests/common.rs +++ b/integration_tests/common.rs @@ -7,16 +7,14 @@ use std::{ sync::Mutex, }; -use { - futures::future::{self, Join}, - rand::prelude::StdRng, - structopt::StructOpt, - strum::IntoEnumIterator, - strum_macros::EnumIter, - tokio::{task::JoinHandle, time::Duration}, - tracing::info_span, - tracing_futures::Instrument, -}; +use futures::future::{self, Join}; +use rand::prelude::StdRng; +use structopt::StructOpt; +use strum::IntoEnumIterator; +use strum_macros::EnumIter; +use tokio::{task::JoinHandle, time::Duration}; +use tracing::info_span; +use tracing_futures::Instrument; use crate::{await_log, TestLogs}; diff --git a/integration_tests/main.rs b/integration_tests/main.rs index b93d4ba2..da96ebdc 100644 --- a/integration_tests/main.rs +++ b/integration_tests/main.rs @@ -8,19 +8,17 @@ use zeekoe::{ TestLogs, }; -use { - anyhow::Context, - common::{customer_cli, merchant_cli, Party}, - rand::prelude::StdRng, - std::{ - fs::{File, OpenOptions}, - io::Read, - panic, - time::Duration, - }, - structopt::StructOpt, - thiserror::Error, +use anyhow::Context; +use common::{customer_cli, merchant_cli, Party}; +use rand::prelude::StdRng; +use std::{ + fs::{File, OpenOptions}, + io::Read, + panic, + time::Duration, }; +use structopt::StructOpt; +use thiserror::Error; #[tokio::main] pub async fn main() { diff --git a/rustfmt.toml b/rustfmt.toml index c7b58051..0bbfe24f 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,3 @@ edition = "2018" unstable_features = true +imports_granularity = "Crate" \ No newline at end of file diff --git a/src/amount.rs b/src/amount.rs index d33da51d..1be0bfab 100644 --- a/src/amount.rs +++ b/src/amount.rs @@ -1,14 +1,12 @@ -use { - rust_decimal::Decimal, - rusty_money::{define_currency_set, FormattableCurrency, Money, MoneyError}, - std::{ - convert::TryInto, - fmt::{self, Display}, - num::TryFromIntError, - str::FromStr, - }, - thiserror::Error, +use rust_decimal::Decimal; +use rusty_money::{define_currency_set, FormattableCurrency, Money, MoneyError}; +use std::{ + convert::TryInto, + fmt::{self, Display}, + num::TryFromIntError, + str::FromStr, }; +use thiserror::Error; pub use supported::*; use zkabacus_crypto::{ diff --git a/src/bin/customer.rs b/src/bin/customer.rs index d2773474..f0450b2d 100644 --- a/src/bin/customer.rs +++ b/src/bin/customer.rs @@ -1,10 +1,8 @@ -use { - anyhow::Context, - futures::FutureExt, - rand::{rngs::StdRng, SeedableRng}, - std::convert::identity, - structopt::StructOpt, -}; +use anyhow::Context; +use futures::FutureExt; +use rand::{rngs::StdRng, SeedableRng}; +use std::convert::identity; +use structopt::StructOpt; use zeekoe::customer::{ cli::{self, Customer::*}, diff --git a/src/bin/merchant.rs b/src/bin/merchant.rs index ec6c7241..725be447 100644 --- a/src/bin/merchant.rs +++ b/src/bin/merchant.rs @@ -1,4 +1,7 @@ -use {anyhow::Context, futures::FutureExt, std::convert::identity, structopt::StructOpt}; +use anyhow::Context; +use futures::FutureExt; +use std::convert::identity; +use structopt::StructOpt; use zeekoe::merchant::{cli, defaults::config_path, zkchannels::Command, Cli, Config}; diff --git a/src/cli/customer.rs b/src/cli/customer.rs index 7600ea57..2f1f75e8 100644 --- a/src/cli/customer.rs +++ b/src/cli/customer.rs @@ -1,15 +1,12 @@ -use { - read_restrict::ReadExt, - std::{ - io::{self, Read}, - path::PathBuf, - str::FromStr, - }, - structopt::StructOpt, +use read_restrict::ReadExt; +use std::{ + io::{self, Read}, + path::PathBuf, + str::FromStr, }; +use structopt::StructOpt; -use crate::transport::ZkChannelAddress; -use crate::{amount::Amount, customer::ChannelName}; +use crate::{amount::Amount, customer::ChannelName, transport::ZkChannelAddress}; /// The customer zkChannels command-line interface. #[derive(Debug, StructOpt)] diff --git a/src/cli/merchant.rs b/src/cli/merchant.rs index ee03455e..b83fa182 100644 --- a/src/cli/merchant.rs +++ b/src/cli/merchant.rs @@ -1,4 +1,5 @@ -use {std::path::PathBuf, structopt::StructOpt}; +use std::path::PathBuf; +use structopt::StructOpt; use zkabacus_crypto::ChannelId; diff --git a/src/config.rs b/src/config.rs index 3d69058a..03bd030f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,8 +1,6 @@ -use { - http::Uri, - serde::{de, Deserialize, Deserializer, Serialize}, - std::path::{Path, PathBuf}, -}; +use http::Uri; +use serde::{de, Deserialize, Deserializer, Serialize}; +use std::path::{Path, PathBuf}; pub mod customer; pub mod merchant; diff --git a/src/config/customer.rs b/src/config/customer.rs index 68c719d4..ec8aa45b 100644 --- a/src/config/customer.rs +++ b/src/config/customer.rs @@ -1,10 +1,8 @@ -use { - dialectic_reconnect::Backoff, - serde::{Deserialize, Serialize}, - std::{ - path::{Path, PathBuf}, - time::Duration, - }, +use dialectic_reconnect::Backoff; +use serde::{Deserialize, Serialize}; +use std::{ + path::{Path, PathBuf}, + time::Duration, }; use http::Uri; diff --git a/src/config/merchant.rs b/src/config/merchant.rs index 64c7b098..c7388046 100644 --- a/src/config/merchant.rs +++ b/src/config/merchant.rs @@ -1,9 +1,11 @@ -use { - http::Uri, - serde::{Deserialize, Serialize}, - std::{net::IpAddr, path::Path, path::PathBuf, time::Duration}, - url::Url, +use http::Uri; +use serde::{Deserialize, Serialize}; +use std::{ + net::IpAddr, + path::{Path, PathBuf}, + time::Duration, }; +use url::Url; pub use super::{deserialize_confirmation_depth, deserialize_self_delay, DatabaseLocation}; diff --git a/src/customer.rs b/src/customer.rs index 58be9e13..cb8d7b31 100644 --- a/src/customer.rs +++ b/src/customer.rs @@ -1,18 +1,20 @@ -use { - serde::{Deserialize, Serialize}, - std::{ - fmt::{Display, Formatter}, - str::FromStr, - }, +use serde::{Deserialize, Serialize}; +use std::{ + fmt::{Display, Formatter}, + str::FromStr, }; -pub use crate::cli::{customer as cli, customer::Cli}; -pub use crate::config::{customer as config, customer::Config}; -pub use crate::database::customer as database; -pub use crate::defaults::customer as defaults; -pub use crate::zkchannels::customer as zkchannels; -pub use transport::client::{self, Chan, Client}; -pub use transport::server::{self, Server}; +pub use crate::{ + cli::{customer as cli, customer::Cli}, + config::{customer as config, customer::Config}, + database::customer as database, + defaults::customer as defaults, + zkchannels::customer as zkchannels, +}; +pub use transport::{ + client::{self, Chan, Client}, + server::{self, Server}, +}; #[derive(Debug, Clone, sqlx::Type, Serialize, Deserialize)] #[sqlx(transparent)] diff --git a/src/database.rs b/src/database.rs index bf8ba7d1..bbf780dd 100644 --- a/src/database.rs +++ b/src/database.rs @@ -2,7 +2,8 @@ pub mod customer; pub mod merchant; pub use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqlitePoolOptions, SqliteRow}; -use {anyhow::Context, std::path::Path, std::sync::Arc}; +use anyhow::Context; +use std::{path::Path, sync::Arc}; pub async fn connect_sqlite>(path: T) -> Result, anyhow::Error> { let options = SqliteConnectOptions::new() diff --git a/src/database/customer.rs b/src/database/customer.rs index 4ff76dfa..7cfbdb86 100644 --- a/src/database/customer.rs +++ b/src/database/customer.rs @@ -1,11 +1,9 @@ -use { - async_trait::async_trait, - futures::stream::StreamExt, - serde::{Deserialize, Serialize}, - sqlx::SqlitePool, - std::any::Any, - thiserror::Error, -}; +use async_trait::async_trait; +use futures::stream::StreamExt; +use serde::{Deserialize, Serialize}; +use sqlx::SqlitePool; +use std::any::Any; +use thiserror::Error; use zkabacus_crypto::{ customer::{ClosingMessage, Inactive}, @@ -838,10 +836,8 @@ impl QueryCustomerExt for Q { mod tests { use super::*; use crate::database::SqlitePoolOptions; - use { - rand::{rngs::StdRng, SeedableRng}, - std::str::FromStr, - }; + use rand::{rngs::StdRng, SeedableRng}; + use std::str::FromStr; use tezedge::OriginatedAddress; use zkabacus_crypto::{customer::*, merchant, *}; diff --git a/src/database/customer/state.rs b/src/database/customer/state.rs index 2cf0404b..0cc22cb3 100644 --- a/src/database/customer/state.rs +++ b/src/database/customer/state.rs @@ -1,8 +1,6 @@ -use { - serde::{Deserialize, Serialize}, - std::fmt::{Display, Formatter}, - thiserror::Error, -}; +use serde::{Deserialize, Serialize}; +use std::fmt::{Display, Formatter}; +use thiserror::Error; use zkabacus_crypto::{ customer as zkabacus, impl_sqlx_for_bincode_ty, ChannelId, CustomerBalance, MerchantBalance, diff --git a/src/database/merchant.rs b/src/database/merchant.rs index f9b80088..97d5e64b 100644 --- a/src/database/merchant.rs +++ b/src/database/merchant.rs @@ -1,8 +1,10 @@ -use {async_trait::async_trait, futures::StreamExt, rand::rngs::StdRng, thiserror::Error}; +use async_trait::async_trait; +use futures::StreamExt; +use rand::rngs::StdRng; +use thiserror::Error; pub use super::connect_sqlite; -use crate::database::SqlitePool; -use crate::{escrow::types::ContractId, protocol::ChannelStatus}; +use crate::{database::SqlitePool, escrow::types::ContractId, protocol::ChannelStatus}; use serde::{Deserialize, Serialize}; use zkabacus_crypto::{ revlock::{RevocationLock, RevocationPair, RevocationSecret}, @@ -820,10 +822,14 @@ impl QueryMerchantExt for Q { mod tests { use super::*; use crate::database::SqlitePoolOptions; - use {rand::SeedableRng, strum::IntoEnumIterator, tezedge::OriginatedAddress}; - - use zkabacus_crypto::internal::{test_new_nonce, test_new_revocation_pair}; - use zkabacus_crypto::{CustomerRandomness, MerchantRandomness}; + use rand::SeedableRng; + use strum::IntoEnumIterator; + use tezedge::OriginatedAddress; + + use zkabacus_crypto::{ + internal::{test_new_nonce, test_new_revocation_pair}, + CustomerRandomness, MerchantRandomness, + }; // The default dummy originated contract address, per https://tezos.stackexchange.com/a/2270 const DEFAULT_ADDR: &str = "KT1Mjjcb6tmSsLm7Cb3DSQszePjfchPM4Uxm"; diff --git a/src/defaults.rs b/src/defaults.rs index d444e1e7..abf74090 100644 --- a/src/defaults.rs +++ b/src/defaults.rs @@ -1,11 +1,9 @@ -use { - dialectic_reconnect::Backoff, - directories::ProjectDirs, - std::{ - net::{IpAddr, Ipv4Addr}, - path::PathBuf, - time::Duration, - }, +use dialectic_reconnect::Backoff; +use directories::ProjectDirs; +use std::{ + net::{IpAddr, Ipv4Addr}, + path::PathBuf, + time::Duration, }; fn project_dirs() -> Result { diff --git a/src/escrow/mod.rs b/src/escrow/mod.rs index 7f03a272..7892f302 100644 --- a/src/escrow/mod.rs +++ b/src/escrow/mod.rs @@ -5,19 +5,17 @@ pub mod types { use std::{borrow::Cow, convert::TryFrom, path::PathBuf}; + use serde::{Deserialize, Serialize}; + use sha3::{Digest, Sha3_256}; + use std::{ + fmt::{self, Display, Formatter}, + path::Path, + }; use tezedge::{ crypto::base58check::ToBase58Check, OriginatedAddress, PrivateKey as TezosPrivateKey, }; + use thiserror::Error; use zkabacus_crypto::PublicKey as ZkAbacusPublicKey; - use { - serde::{Deserialize, Serialize}, - sha3::{Digest, Sha3_256}, - std::{ - fmt::{self, Display, Formatter}, - path::Path, - }, - thiserror::Error, - }; /// ID for a zkChannels contract originated on Tezos. /// Equivalent to the Tezos OriginatedAddress type. diff --git a/src/escrow/notify.rs b/src/escrow/notify.rs index 5e15e957..bbdadede 100644 --- a/src/escrow/notify.rs +++ b/src/escrow/notify.rs @@ -1,22 +1,18 @@ -use { - serde::{Deserialize, Serialize}, - std::{ - pin::Pin, - task::{Context, Poll}, - }, +use serde::{Deserialize, Serialize}; +use std::{ + pin::Pin, + task::{Context, Poll}, }; use tezedge::OperationHash; use super::types::ContractId; -use { - futures::stream::Stream, - std::{ - cmp::Reverse, - future::Future, - hash::Hash, - ops::{Add, Sub}, - }, +use futures::stream::Stream; +use std::{ + cmp::Reverse, + future::Future, + hash::Hash, + ops::{Add, Sub}, }; pub struct Notifications {} diff --git a/src/escrow/tezos.rs b/src/escrow/tezos.rs index 3314e83c..e6897fcf 100644 --- a/src/escrow/tezos.rs +++ b/src/escrow/tezos.rs @@ -1,20 +1,18 @@ -use { - crate::escrow::types::*, - canonicalize_json_micheline::{canonicalize_json_micheline, CanonicalizeError}, - futures::Future, - inline_python::{pyo3, pyo3::conversion::FromPyObject, python}, - serde::{Deserialize, Serialize}, - std::{ - convert::{TryFrom, TryInto}, - str::FromStr, - time::{Duration, SystemTime}, - }, - tezedge::{OriginatedAddress, ToBase58Check}, - tokio::task::JoinError, - zkabacus_crypto::{ - customer::ClosingMessage, revlock::RevocationSecret, ChannelId, CloseState, - CustomerBalance, MerchantBalance, PublicKey, RevocationLock, - }, +use crate::escrow::types::*; +use canonicalize_json_micheline::{canonicalize_json_micheline, CanonicalizeError}; +use futures::Future; +use inline_python::{pyo3, pyo3::conversion::FromPyObject, python}; +use serde::{Deserialize, Serialize}; +use std::{ + convert::{TryFrom, TryInto}, + str::FromStr, + time::{Duration, SystemTime}, +}; +use tezedge::{OriginatedAddress, ToBase58Check}; +use tokio::task::JoinError; +use zkabacus_crypto::{ + customer::ClosingMessage, revlock::RevocationSecret, ChannelId, CloseState, CustomerBalance, + MerchantBalance, PublicKey, RevocationLock, }; /// The Micheline JSON for the ZkChannels contract. diff --git a/src/merchant.rs b/src/merchant.rs index 1abf7405..65b345e2 100644 --- a/src/merchant.rs +++ b/src/merchant.rs @@ -1,6 +1,8 @@ -pub use crate::cli::{merchant as cli, merchant::Cli}; -pub use crate::config::{merchant as config, merchant::Config}; -pub use crate::database::merchant as database; -pub use crate::defaults::merchant as defaults; -pub use crate::zkchannels::merchant as zkchannels; +pub use crate::{ + cli::{merchant as cli, merchant::Cli}, + config::{merchant as config, merchant::Config}, + database::merchant as database, + defaults::merchant as defaults, + zkchannels::merchant as zkchannels, +}; pub use transport::server::{self as server, Chan, Server}; diff --git a/src/protocol.rs b/src/protocol.rs index 44d1a7ad..546547f8 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -1,12 +1,10 @@ +use dialectic::prelude::*; +use serde::{Deserialize, Serialize}; +use std::fmt::{self, Display, Formatter}; +use thiserror::Error; use zkabacus_crypto::{ revlock::*, ClosingSignature, CustomerRandomness, MerchantRandomness, Nonce, PayProof, PayToken, }; -use { - dialectic::prelude::*, - serde::{Deserialize, Serialize}, - std::fmt::{self, Display, Formatter}, - thiserror::Error, -}; #[cfg(test)] use strum_macros::EnumIter; @@ -289,10 +287,8 @@ pub mod establish { }; } pub mod close { - use { - dialectic::types::Done, - zkabacus_crypto::{CloseState, CloseStateSignature}, - }; + use dialectic::types::Done; + use zkabacus_crypto::{CloseState, CloseStateSignature}; use crate::{database::customer::StateName, escrow::tezos::MutualCloseAuthorizationSignature}; diff --git a/src/timeout.rs b/src/timeout.rs index 08cadc34..713825e1 100644 --- a/src/timeout.rs +++ b/src/timeout.rs @@ -1,4 +1,7 @@ -use {async_trait::async_trait, futures::Future, std::time::Duration, tokio::time::Timeout}; +use async_trait::async_trait; +use futures::Future; +use std::time::Duration; +use tokio::time::Timeout; #[async_trait] pub trait WithTimeout { diff --git a/src/transport.rs b/src/transport.rs index 9b0a7552..440823dc 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -1,10 +1,6 @@ -use crate::customer; -use crate::transport::client::Address; -use http::uri::InvalidUri; -use http::Uri; -use std::fmt; -use std::fmt::Display; -use std::str::FromStr; +use crate::{customer, transport::client::Address}; +use http::{uri::InvalidUri, Uri}; +use std::{fmt, fmt::Display, str::FromStr}; use thiserror::Error; use webpki::{DnsName, DnsNameRef, InvalidDnsNameError}; diff --git a/src/zkchannels/customer.rs b/src/zkchannels/customer.rs index 610442bd..79154e76 100644 --- a/src/zkchannels/customer.rs +++ b/src/zkchannels/customer.rs @@ -4,14 +4,12 @@ use tracing::warn; use webpki::DnsNameRef; -use { - anyhow::Context, - async_trait::async_trait, - rand::rngs::StdRng, - sqlx::SqlitePool, - std::{sync::Arc, time::Duration}, - thiserror::Error, -}; +use anyhow::Context; +use async_trait::async_trait; +use rand::rngs::StdRng; +use sqlx::SqlitePool; +use std::{sync::Arc, time::Duration}; +use thiserror::Error; use crate::{ customer::{ diff --git a/src/zkchannels/customer/close.rs b/src/zkchannels/customer/close.rs index 0f965dd0..8c012819 100644 --- a/src/zkchannels/customer/close.rs +++ b/src/zkchannels/customer/close.rs @@ -5,12 +5,10 @@ //* This architecture is flexible; we could alternately allow the customer CLI to wait (hang) until //* it receives confirmation (e.g. call `process_mutual_close_confirmation` directly from //* `mutual_close()`). -use { - async_trait::async_trait, - rand::rngs::StdRng, - serde::Serialize, - std::{convert::Infallible, fs::File, path::PathBuf}, -}; +use async_trait::async_trait; +use rand::rngs::StdRng; +use serde::Serialize; +use std::{convert::Infallible, fs::File, path::PathBuf}; use crate::{ abort, diff --git a/src/zkchannels/customer/establish.rs b/src/zkchannels/customer/establish.rs index 173b95d5..826ed8ae 100644 --- a/src/zkchannels/customer/establish.rs +++ b/src/zkchannels/customer/establish.rs @@ -1,10 +1,8 @@ -use { - anyhow::Context, - async_trait::async_trait, - rand::rngs::StdRng, - serde::Serialize, - std::{convert::TryInto, fs::File, path::PathBuf}, -}; +use anyhow::Context; +use async_trait::async_trait; +use rand::rngs::StdRng; +use serde::Serialize; +use std::{convert::TryInto, fs::File, path::PathBuf}; use std::convert::Infallible; diff --git a/src/zkchannels/customer/manage.rs b/src/zkchannels/customer/manage.rs index 0652ea6f..b3cb29e6 100644 --- a/src/zkchannels/customer/manage.rs +++ b/src/zkchannels/customer/manage.rs @@ -1,12 +1,10 @@ -use { - anyhow::Context, - async_trait::async_trait, - comfy_table::{Cell, Table}, - rand::rngs::StdRng, - serde::{Deserialize, Serialize}, - serde_with::{serde_as, DisplayFromStr}, - zkabacus_crypto::{ChannelId, CustomerBalance, MerchantBalance}, -}; +use anyhow::Context; +use async_trait::async_trait; +use comfy_table::{Cell, Table}; +use rand::rngs::StdRng; +use serde::{Deserialize, Serialize}; +use serde_with::{serde_as, DisplayFromStr}; +use zkabacus_crypto::{ChannelId, CustomerBalance, MerchantBalance}; use crate::{ amount::Amount, diff --git a/src/zkchannels/customer/pay.rs b/src/zkchannels/customer/pay.rs index 729f84c2..f3d00780 100644 --- a/src/zkchannels/customer/pay.rs +++ b/src/zkchannels/customer/pay.rs @@ -1,10 +1,8 @@ +use anyhow::Context; +use async_trait::async_trait; +use rand::rngs::StdRng; +use std::convert::{Infallible, TryInto}; use tracing::info; -use { - anyhow::Context, - async_trait::async_trait, - rand::rngs::StdRng, - std::convert::{Infallible, TryInto}, -}; use zkabacus_crypto::{ customer::{LockMessage, StartMessage}, diff --git a/src/zkchannels/customer/watch.rs b/src/zkchannels/customer/watch.rs index 7ce0765d..bc069c70 100644 --- a/src/zkchannels/customer/watch.rs +++ b/src/zkchannels/customer/watch.rs @@ -1,15 +1,19 @@ use std::time::Duration; use tracing::{error, info}; -use { - anyhow::Context, async_trait::async_trait, rand::rngs::StdRng, std::sync::Arc, tokio::signal, -}; +use anyhow::Context; +use async_trait::async_trait; +use rand::rngs::StdRng; +use std::sync::Arc; +use tokio::signal; use crate::{ - customer::database::zkchannels_state::{self, ZkChannelState}, customer::{ cli::Watch, - database::{ChannelDetails, QueryCustomer}, + database::{ + zkchannels_state::{self, ZkChannelState}, + ChannelDetails, QueryCustomer, + }, Config, }, escrow::types::ContractStatus, diff --git a/src/zkchannels/merchant.rs b/src/zkchannels/merchant.rs index 46ca2b42..03695a9b 100644 --- a/src/zkchannels/merchant.rs +++ b/src/zkchannels/merchant.rs @@ -1,17 +1,14 @@ //! Complete merchant logic for the zkchannels protocol -use { - anyhow::Context, - async_trait::async_trait, - dialectic::offer, - futures::stream::{FuturesUnordered, StreamExt}, - rand::{rngs::StdRng, SeedableRng}, - sqlx::SqlitePool, - std::{sync::Arc, time::Duration}, - tokio::signal, - tokio::sync::broadcast, - tracing::{error, info}, -}; +use anyhow::Context; +use async_trait::async_trait; +use dialectic::offer; +use futures::stream::{FuturesUnordered, StreamExt}; +use rand::{rngs::StdRng, SeedableRng}; +use sqlx::SqlitePool; +use std::{sync::Arc, time::Duration}; +use tokio::{signal, sync::broadcast}; +use tracing::{error, info}; use crate::{ escrow::{ diff --git a/src/zkchannels/merchant/approve.rs b/src/zkchannels/merchant/approve.rs index d6ad79c2..95b45dd7 100644 --- a/src/zkchannels/merchant/approve.rs +++ b/src/zkchannels/merchant/approve.rs @@ -1,4 +1,5 @@ -use {anyhow::Context, url::Url}; +use anyhow::Context; +use url::Url; use zkabacus_crypto::{CustomerBalance, MerchantBalance, PaymentAmount}; diff --git a/src/zkchannels/merchant/close.rs b/src/zkchannels/merchant/close.rs index 4745b97b..27d8f5f2 100644 --- a/src/zkchannels/merchant/close.rs +++ b/src/zkchannels/merchant/close.rs @@ -1,5 +1,6 @@ //* Close functionalities for a merchant. -use {anyhow::Context, async_trait::async_trait}; +use anyhow::Context; +use async_trait::async_trait; use super::{database, load_tezos_client, Command}; diff --git a/src/zkchannels/merchant/establish.rs b/src/zkchannels/merchant/establish.rs index 7809333c..adb417a3 100644 --- a/src/zkchannels/merchant/establish.rs +++ b/src/zkchannels/merchant/establish.rs @@ -1,4 +1,5 @@ -use {anyhow::Context, rand::rngs::StdRng}; +use anyhow::Context; +use rand::rngs::StdRng; use zkabacus_crypto::{ merchant::Config as ZkAbacusConfig, ChannelId, Context as ProofContext, CustomerBalance, diff --git a/src/zkchannels/merchant/manage.rs b/src/zkchannels/merchant/manage.rs index 3b581066..0c94a5f9 100644 --- a/src/zkchannels/merchant/manage.rs +++ b/src/zkchannels/merchant/manage.rs @@ -9,14 +9,12 @@ use crate::{ }, protocol::ChannelStatus, }; -use { - anyhow::Context, - async_trait::async_trait, - comfy_table::{Cell, Table}, - serde::{Deserialize, Serialize}, - serde_with::{serde_as, DisplayFromStr}, - zkabacus_crypto::ChannelId, -}; +use anyhow::Context; +use async_trait::async_trait; +use comfy_table::{Cell, Table}; +use serde::{Deserialize, Serialize}; +use serde_with::{serde_as, DisplayFromStr}; +use zkabacus_crypto::ChannelId; /// The contents of a row of the database for a particular channel that are suitable to share with /// the user (especially for testing). diff --git a/src/zkchannels/merchant/pay.rs b/src/zkchannels/merchant/pay.rs index 7dc2658a..82007028 100644 --- a/src/zkchannels/merchant/pay.rs +++ b/src/zkchannels/merchant/pay.rs @@ -1,4 +1,5 @@ -use {anyhow::Context, rand::rngs::StdRng}; +use anyhow::Context; +use rand::rngs::StdRng; use crate::{ abort, From c858fcd4c7c539a7e7b3d72ae9b4ce3cb32856c9 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Wed, 20 Apr 2022 09:33:35 +0200 Subject: [PATCH 09/14] Change transport crate to main branch #366 --- Cargo.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0fd50bf..33b60f9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,8 +82,7 @@ canonicalize_json_micheline = { path = "src/canonicalize_json_micheline" } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-futures = "0.2" -#TODO: change transport to main branch -transport = { git = "https://github.com/boltlabs-inc/transport.git", branch = "fix-integration-test", features = ["allow_explicit_certificate_trust"] } +transport = { git = "https://github.com/boltlabs-inc/transport.git", branch = "main", features = ["allow_explicit_certificate_trust"] } [dev-dependencies] rand = "0.8.3" @@ -96,4 +95,4 @@ canonicalize_json_micheline = { path = "src/canonicalize_json_micheline" } [[test]] name = "integration_tests" path = "integration_tests/main.rs" -harness = false \ No newline at end of file +harness = false From cfcd6e1bfb87e9732e9f3a4ad875542caa2d25da Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Wed, 20 Apr 2022 09:57:58 +0200 Subject: [PATCH 10/14] Add Cargo.toml to cache-hash #366 --- .github/workflows/rust.yml | 2 +- Cargo.lock | 151 +++++++++++++++++++++++++------------ 2 files changed, 104 insertions(+), 49 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cdad9c83..fa6d5339 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,7 +17,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.**') }} - uses: actions/checkout@v2 with: diff --git a/Cargo.lock b/Cargo.lock index 85cc371f..16352790 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,6 +126,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + [[package]] name = "block-padding" version = "0.2.1" @@ -333,6 +342,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "crypto-common" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "darling" version = "0.13.4" @@ -478,6 +497,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer 0.10.2", + "crypto-common", +] + [[package]] name = "directories" version = "3.0.2" @@ -532,6 +561,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "event-listener" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" + [[package]] name = "explorer_api" version = "0.1.0" @@ -566,9 +601,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" +checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" dependencies = [ "cfg-if 1.0.0", "crc32fast", @@ -585,7 +620,7 @@ dependencies = [ "futures-core", "futures-sink", "pin-project", - "spin 0.9.2", + "spin 0.9.3", ] [[package]] @@ -816,6 +851,15 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "hermit-abi" version = "0.1.19" @@ -833,9 +877,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hidapi" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "253bfb01a7a31d71212dc3e920540546fa4a4fe08e2d87fc3299c42bae7ee2f9" +checksum = "38b1717343691998deb81766bfcd1dce6df0d5d6c37070b5a3de2bb6d39f7822" dependencies = [ "cc", "libc", @@ -876,9 +920,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" +checksum = "6330e8a36bd8c859f3fa6d9382911fbb7147ec39807f63b923933a247240b9ba" [[package]] name = "httpdate" @@ -1022,9 +1066,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] name = "itertools" @@ -1122,9 +1166,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.122" +version = "0.2.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259" +checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" [[package]] name = "libsodium-sys" @@ -1140,9 +1184,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.23.2" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cafc7c74096c336d9d27145f7ebd4f4b6f95ba16aa5a282387267e6925cb58" +checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" dependencies = [ "cc", "pkg-config", @@ -1215,12 +1259,11 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" dependencies = [ "adler", - "autocfg", ] [[package]] @@ -1740,9 +1783,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ "proc-macro2", ] @@ -2204,21 +2247,32 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if 1.0.0", "cpufeatures", - "digest", + "digest 0.9.0", "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.3", +] + [[package]] name = "sha3" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" dependencies = [ - "block-buffer", - "digest", + "block-buffer 0.9.0", + "digest 0.9.0", "keccak", "opaque-debug", ] @@ -2324,9 +2378,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spin" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5" +checksum = "c530c2b0d0bf8b69304b39fe2001993e267461948b890cd037d8ad4293fa1a0d" dependencies = [ "lock_api", ] @@ -2344,9 +2398,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc15591eb44ffb5816a4a70a7efd5dd87bfd3aa84c4c200401c4396140525826" +checksum = "551873805652ba0d912fec5bbb0f8b4cdd96baf8e2ebf5970e5671092966019b" dependencies = [ "sqlx-core", "sqlx-macros", @@ -2354,9 +2408,9 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195183bf6ff8328bb82c0511a83faf60aacf75840103388851db61d7a9854ae3" +checksum = "e48c61941ccf5ddcada342cd59e3e5173b007c509e1e8e990dafc830294d9dc5" dependencies = [ "ahash", "atoi", @@ -2366,6 +2420,7 @@ dependencies = [ "crc", "crossbeam-queue", "either", + "event-listener", "flume", "futures-channel", "futures-core", @@ -2385,7 +2440,7 @@ dependencies = [ "percent-encoding", "rustls 0.19.1", "serde", - "sha2", + "sha2 0.10.2", "smallvec", "sqlformat", "sqlx-rt", @@ -2399,20 +2454,20 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee35713129561f5e55c554bba1c378e2a7e67f81257b7311183de98c50e6f94" +checksum = "bc0fba2b0cae21fc00fe6046f8baa4c7fcb49e379f0f592b04696607f69ed2e1" dependencies = [ "dotenv", "either", - "heck", + "heck 0.4.0", "hex", "once_cell", "proc-macro2", "quote", "serde", "serde_json", - "sha2", + "sha2 0.10.2", "sqlx-core", "sqlx-rt", "syn", @@ -2421,9 +2476,9 @@ dependencies = [ [[package]] name = "sqlx-rt" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b555e70fbbf84e269ec3858b7a6515bcfe7a166a7cc9c636dd6efd20431678b6" +checksum = "4db708cd3e459078f85f39f96a00960bd841f66ee2a669e90bf36907f5a79aae" dependencies = [ "once_cell", "tokio", @@ -2475,7 +2530,7 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ - "heck", + "heck 0.3.3", "proc-macro-error", "proc-macro2", "quote", @@ -2494,7 +2549,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" dependencies = [ - "heck", + "heck 0.3.3", "proc-macro2", "quote", "syn", @@ -2722,9 +2777,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ "serde", ] @@ -2737,9 +2792,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.32" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" +checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", @@ -2760,9 +2815,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90442985ee2f57c9e1b548ee72ae842f4a9a20e3f417cc38dbc5dc684d9bb4ee" +checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" dependencies = [ "lazy_static", "valuable", @@ -2791,9 +2846,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9df98b037d039d03400d9dd06b0f8ce05486b5f25e9a2d7d36196e142ebbc52" +checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" dependencies = [ "ansi_term", "lazy_static", @@ -2810,7 +2865,7 @@ dependencies = [ [[package]] name = "transport" version = "0.1.0" -source = "git+https://github.com/boltlabs-inc/transport.git?branch=fix-integration-test#2e2c15adc65dad89a34a428178a93c58ee50adbf" +source = "git+https://github.com/boltlabs-inc/transport.git?branch=main#8bacae6e2eb50721d897136ffc7c6048993f43bc" dependencies = [ "bincode", "dialectic", @@ -3261,7 +3316,7 @@ dependencies = [ "dialectic-reconnect", "dialectic-tokio-serde", "dialectic-tokio-serde-bincode", - "digest", + "digest 0.9.0", "directories", "edit", "futures", @@ -3287,7 +3342,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "sha2", + "sha2 0.9.9", "sha3", "skiplist", "sqlx", From 9df81a88c64fe4445023f54f08709d0b243375b0 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Wed, 20 Apr 2022 10:10:26 +0200 Subject: [PATCH 11/14] Change cache key #366 --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fa6d5339..7af81dee 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,7 +17,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.**') }} + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml', 'Cargo.lock) }} - uses: actions/checkout@v2 with: From 8b44016ecc915539b4f8393fff8b9763c7b2b9be Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Wed, 20 Apr 2022 10:11:00 +0200 Subject: [PATCH 12/14] Change cache key #366 --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7af81dee..e71214b8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,7 +17,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml', 'Cargo.lock) }} + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml', 'Cargo.lock') }} - uses: actions/checkout@v2 with: From 5efc89e4cc9d76498e649af772ebc86f8297388b Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Wed, 20 Apr 2022 10:14:41 +0200 Subject: [PATCH 13/14] Change cache key #366 --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e71214b8..f03f2996 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,7 +17,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml', 'Cargo.lock') }} + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }} - uses: actions/checkout@v2 with: From 89da486c2ede6a0404a8bc2bb2ebda05ae658197 Mon Sep 17 00:00:00 2001 From: Gijs Van Laer Date: Wed, 20 Apr 2022 10:17:51 +0200 Subject: [PATCH 14/14] Checkout before cache #366 --- .github/workflows/e2e-test.yml | 8 ++++---- .github/workflows/rust.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 7ad9a568..c48da234 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -12,6 +12,10 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: actions/cache@v2 with: path: /tmp/.buildx-cache @@ -21,10 +25,6 @@ jobs: ${{ runner.os }}-buildx-docker- ${{ runner.os }}- - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Prepare Tags id: tags run: | diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f03f2996..19ac5380 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,6 +11,10 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: actions/cache@v2 with: path: | @@ -19,10 +23,6 @@ jobs: target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }} - - uses: actions/checkout@v2 - with: - submodules: recursive - - uses: actions-rs/toolchain@v1 with: components: rustfmt, clippy