From 3d7d609922586e5824420dcb9d0017440cba66d4 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 25 Feb 2022 10:31:01 -0500 Subject: [PATCH 01/11] Make coarsetime dependency and traffic-timestamping non-optional. Previously coarsetime and the traffic-timestamp feature were enabled, since they were only required for a small corner of the guardmgr algorithm. But in 1.0 and beyond we'll be adding a bunch of other features (eg, netflow padding, DoS prevention) that will need coarsetime all over the place. And since we're going to be doing coarsetime all over the place, the previous justification for making traffic-timestamping optional (the tiny performance hit) is no longer relevant. --- crates/tor-guardmgr/Cargo.toml | 2 +- crates/tor-proto/Cargo.toml | 4 +--- crates/tor-proto/src/lib.rs | 9 +-------- crates/tor-proto/src/util.rs | 1 - 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/crates/tor-guardmgr/Cargo.toml b/crates/tor-guardmgr/Cargo.toml index 07df94622..f72fa443d 100644 --- a/crates/tor-guardmgr/Cargo.toml +++ b/crates/tor-guardmgr/Cargo.toml @@ -24,7 +24,7 @@ tor-netdir = { path="../tor-netdir", version = "0.0.4"} tor-linkspec = { path="../tor-linkspec", version = "0.0.3"} tor-llcrypto = { path="../tor-llcrypto", version = "0.0.3"} tor-persist = { path="../tor-persist", version = "0.0.3"} -tor-proto = { path="../tor-proto", version = "0.0.4", features=["traffic-timestamp"] } +tor-proto = { path="../tor-proto", version = "0.0.4" } tor-rtcompat = { path="../tor-rtcompat", version = "0.0.4"} tor-units = { path="../tor-units", version = "0.0.3"} diff --git a/crates/tor-proto/Cargo.toml b/crates/tor-proto/Cargo.toml index 432739f84..ae80299e1 100644 --- a/crates/tor-proto/Cargo.toml +++ b/crates/tor-proto/Cargo.toml @@ -15,7 +15,6 @@ default = [] hs = [] ntor_v3 = [] tokio = ["tokio-crate", "tokio-util"] -traffic-timestamp = ["coarsetime"] [dependencies] tor-llcrypto = { path = "../tor-llcrypto", version = "0.0.3"} @@ -30,6 +29,7 @@ tor-cell = { path = "../tor-cell", version = "0.0.3"} arrayref = "0.3" bytes = "1" cipher = "0.3.0" +coarsetime = "0.1.20" digest = "0.10.0" futures = "0.3.14" asynchronous-codec = "0.6.0" @@ -47,8 +47,6 @@ zeroize = "1" tokio-crate = { package = "tokio", version = "1.4", optional = true } tokio-util = { version = "0.6", features = ["compat"], optional = true } -coarsetime = { version = "0.1.20", optional = true } - [dev-dependencies] tor-rtcompat = { path = "../tor-rtcompat", version = "0.0.4", features = [ "tokio", "native-tls" ] } hex-literal = "0.3" diff --git a/crates/tor-proto/src/lib.rs b/crates/tor-proto/src/lib.rs index d638c2d47..9ffc6fba5 100644 --- a/crates/tor-proto/src/lib.rs +++ b/crates/tor-proto/src/lib.rs @@ -130,7 +130,6 @@ pub type Result = std::result::Result; /// Timestamp object that we update whenever we get incoming traffic. /// /// Used to implement [`time_since_last_incoming_traffic`] -#[cfg(feature = "traffic-timestamp")] static LAST_INCOMING_TRAFFIC: util::ts::OptTimestamp = util::ts::OptTimestamp::new(); /// Called whenever we receive incoming traffic. @@ -138,16 +137,11 @@ static LAST_INCOMING_TRAFFIC: util::ts::OptTimestamp = util::ts::OptTimestamp::n /// Used to implement [`time_since_last_incoming_traffic`] #[inline] pub(crate) fn note_incoming_traffic() { - #[cfg(feature = "traffic-timestamp")] - { - LAST_INCOMING_TRAFFIC.update(); - } + LAST_INCOMING_TRAFFIC.update(); } /// Return the amount of time since we last received "incoming traffic". /// -/// Requires that the `traffic-timestamp` feature is enabled. -/// /// This is a global counter, and is subject to interference from /// other users of the `tor_proto`. Its only permissible use is for /// checking how recently we have been definitely able to receive @@ -157,7 +151,6 @@ pub(crate) fn note_incoming_traffic() { /// cell, and whenever we complete a channel handshake. /// /// Returns `None` if we never received "incoming traffic". -#[cfg(feature = "traffic-timestamp")] pub fn time_since_last_incoming_traffic() -> Option { LAST_INCOMING_TRAFFIC.time_since_update().map(Into::into) } diff --git a/crates/tor-proto/src/util.rs b/crates/tor-proto/src/util.rs index f184637e8..515ef5a26 100644 --- a/crates/tor-proto/src/util.rs +++ b/crates/tor-proto/src/util.rs @@ -2,5 +2,4 @@ pub(crate) mod ct; pub(crate) mod err; -#[cfg(feature = "traffic-timestamp")] pub(crate) mod ts; From 4bd620b4ff6260e1eb9148060a0fec5eacc2b267 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 25 Feb 2022 11:32:09 -0500 Subject: [PATCH 02/11] Run "cargo upgrade" in preparation for 0.1.0. (It's good to do this a couple of days in advance in case it turns up any bugs. That's how we caught the panic bug in simple_asn1 0.6.0) --- Cargo.lock | 372 +++++++++++++++++++++++++++++------------------------ 1 file changed, 204 insertions(+), 168 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0cc2e5e72..65aebaac1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,7 +36,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.4", + "getrandom 0.2.5", "once_cell", "version_check", ] @@ -52,9 +52,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.53" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" +checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd" [[package]] name = "arrayref" @@ -100,7 +100,7 @@ dependencies = [ "clap", "float-ord", "futures", - "rand 0.8.4", + "rand 0.8.5", "serde", "serde_json", "tokio", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" dependencies = [ "event-listener", ] @@ -406,7 +406,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -428,15 +428,18 @@ dependencies = [ [[package]] name = "autocfg" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] [[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 = "backtrace" @@ -493,9 +496,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" dependencies = [ "generic-array", ] @@ -556,9 +559,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad" [[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" dependencies = [ "jobserver", ] @@ -648,9 +651,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[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", @@ -673,9 +676,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if 1.0.0", ] @@ -692,9 +695,9 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b979d76c9fcb84dffc80a73f7290da0f83e4c95773494674cb44b76d13a7a110" +checksum = "4dd435b205a4842da59efd07628f921c096bc1cc0a156835b4fa0bcb9a19bcce" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -702,9 +705,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" +checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" dependencies = [ "cfg-if 1.0.0", "lazy_static", @@ -723,11 +726,12 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ "generic-array", + "typenum", ] [[package]] @@ -761,9 +765,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" dependencies = [ "byteorder", "digest 0.9.0", @@ -872,13 +876,12 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "block-buffer 0.10.0", + "block-buffer 0.10.2", "crypto-common", - "generic-array", "subtle", ] @@ -1118,9 +1121,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", @@ -1154,9 +1157,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", "futures-sink", @@ -1164,15 +1167,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-executor" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", @@ -1181,9 +1184,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-lite" @@ -1202,9 +1205,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ "proc-macro2", "quote", @@ -1213,21 +1216,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-channel", "futures-core", @@ -1264,9 +1267,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1334,20 +1337,20 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hkdf" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "158bc31e00a68e380286904cc598715f861f2b0ccf7aa6fe20c6d0c49ca5d0f6" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" dependencies = [ "hmac", ] [[package]] name = "hmac" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddca131f3e7f2ce2df364b57949a9d47915cfbd35e46cfee355ccebbf794d6a2" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.1", + "digest 0.10.3", ] [[package]] @@ -1358,7 +1361,7 @@ checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes", "fnv", - "itoa 1.0.1", + "itoa", ] [[package]] @@ -1374,9 +1377,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" @@ -1402,9 +1405,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.16" +version = "0.14.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" +checksum = "043f0e083e9901b6cc658a77d1eb86f4fc650bbb977a4337dd63192826aa85dd" dependencies = [ "bytes", "futures-channel", @@ -1414,7 +1417,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 0.4.8", + "itoa", "pin-project-lite", "socket2", "tokio", @@ -1487,12 +1490,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "itoa" version = "1.0.1" @@ -1559,15 +1556,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.115" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "libm" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" +checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" [[package]] name = "libsqlite3-sys" @@ -1582,9 +1579,9 @@ 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", ] @@ -1633,9 +1630,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memmap2" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe3179b85e1fd8b14447cbebadb75e45a1002f541b925f0bfec366d56a81c56d" +checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f" dependencies = [ "libc", ] @@ -1646,7 +1643,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -1674,7 +1671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -1698,9 +1695,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.14" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" dependencies = [ "libc", "log", @@ -1815,9 +1812,9 @@ dependencies = [ [[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 0.3.9", ] @@ -1828,7 +1825,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -1839,14 +1836,14 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4547ee5541c18742396ae2c895d0717d0f886d8823b8399cdaf7b07d63ad0480" dependencies = [ - "autocfg 0.1.7", + "autocfg 0.1.8", "byteorder", "lazy_static", "libm", "num-integer", "num-iter", "num-traits", - "rand 0.8.4", + "rand 0.8.5", "smallvec", "zeroize", ] @@ -1857,7 +1854,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-traits", ] @@ -1867,7 +1864,7 @@ version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -1878,7 +1875,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "libm", ] @@ -1957,7 +1954,7 @@ version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "cc", "libc", "openssl-src", @@ -1973,27 +1970,25 @@ checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ "cfg-if 1.0.0", - "instant", "libc", "redox_syscall", "smallvec", - "winapi 0.3.9", + "windows-sys", ] [[package]] @@ -2035,7 +2030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ "phf_shared", - "rand 0.8.4", + "rand 0.8.5", ] [[package]] @@ -2177,7 +2172,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ - "rand 0.8.4", + "rand 0.8.5", ] [[package]] @@ -2199,19 +2194,18 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_hc", ] [[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 0.3.1", "rand_core 0.6.3", - "rand_hc 0.3.1", ] [[package]] @@ -2249,7 +2243,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.4", + "getrandom 0.2.5", ] [[package]] @@ -2261,15 +2255,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[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 = "redox_syscall" version = "0.2.10" @@ -2285,7 +2270,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.2.4", + "getrandom 0.2.5", "redox_syscall", ] @@ -2324,9 +2309,9 @@ dependencies = [ [[package]] name = "retain_mut" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11000e6ba5020e53e7cc26f73b91ae7d5496b4977851479edb66b694c0675c21" +checksum = "8c31b5c4033f8fdde8700e4657be2c497e7288f01515be52168c631e2e4d4086" [[package]] name = "retry-error" @@ -2374,7 +2359,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8", - "rand 0.8.4", + "rand 0.8.5", "subtle", "zeroize", ] @@ -2476,9 +2461,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce" +checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" dependencies = [ "bitflags", "core-foundation", @@ -2489,9 +2474,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ "core-foundation-sys", "libc", @@ -2499,9 +2484,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" +checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d" [[package]] name = "serde" @@ -2525,11 +2510,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ - "itoa 1.0.1", + "itoa", "ryu", "serde", ] @@ -2551,7 +2536,7 @@ checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.1", + "digest 0.10.3", ] [[package]] @@ -2569,22 +2554,22 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.1", + "digest 0.10.3", ] [[package]] name = "sha3" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f935e31cf406e8c0e96c2815a5516181b7004ae8c5f296293221e9b1e356bd" +checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" dependencies = [ - "digest 0.10.1", + "digest 0.10.3", "keccak", ] @@ -2791,7 +2776,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "004cbc98f30fa233c61a38bc77e96a9106e65c88f2d3bef182ae952027e5753d" dependencies = [ - "itoa 1.0.1", + "itoa", "libc", "num_threads", "quickcheck", @@ -2821,19 +2806,20 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.16.1" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ "bytes", "libc", "memchr", - "mio 0.7.14", + "mio 0.8.0", "num_cpus", "once_cell", "parking_lot", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", "winapi 0.3.9", ] @@ -2891,9 +2877,9 @@ version = "0.0.3" dependencies = [ "arrayref", "bytes", - "digest 0.10.1", + "digest 0.10.3", "generic-array", - "getrandom 0.2.4", + "getrandom 0.2.5", "hex-literal", "signature", "thiserror", @@ -2911,7 +2897,7 @@ dependencies = [ "caret", "hex", "hex-literal", - "rand 0.8.4", + "rand 0.8.5", "thiserror", "tor-bytes", "tor-cert", @@ -2926,7 +2912,7 @@ version = "0.0.3" dependencies = [ "base64", "caret", - "digest 0.10.1", + "digest 0.10.3", "hex-literal", "signature", "tor-bytes", @@ -2945,7 +2931,7 @@ dependencies = [ "futures-await-test", "hex-literal", "postage", - "rand 0.8.4", + "rand 0.8.5", "thiserror", "tor-error", "tor-linkspec", @@ -2977,7 +2963,7 @@ dependencies = [ "humantime-serde", "itertools", "pin-project", - "rand 0.8.4", + "rand 0.8.5", "retry-error", "serde", "static_assertions", @@ -3018,7 +3004,7 @@ dependencies = [ name = "tor-consdiff" version = "0.0.3" dependencies = [ - "digest 0.10.1", + "digest 0.10.3", "hex", "thiserror", "tor-llcrypto", @@ -3056,7 +3042,7 @@ dependencies = [ "base64", "derive_builder", "derive_more", - "digest 0.10.1", + "digest 0.10.3", "event-listener", "float_eq", "fslock", @@ -3069,7 +3055,7 @@ dependencies = [ "memmap2", "once_cell", "postage", - "rand 0.8.4", + "rand 0.8.5", "retry-error", "rusqlite", "serde", @@ -3122,7 +3108,7 @@ dependencies = [ "humantime-serde", "itertools", "pin-project", - "rand 0.8.4", + "rand 0.8.5", "retain_mut", "serde", "thiserror", @@ -3160,19 +3146,19 @@ dependencies = [ "cargo-husky", "cipher", "curve25519-dalek", - "digest 0.10.1", + "digest 0.10.3", "ed25519-dalek", - "getrandom 0.2.4", + "getrandom 0.2.5", "hex", "hex-literal", - "rand 0.8.4", + "rand 0.8.5", "rand_core 0.5.1", "rand_core 0.6.3", "rsa", "serde", "serde_test", "sha-1", - "sha2 0.10.1", + "sha2 0.10.2", "sha3", "signature", "simple_asn1", @@ -3191,7 +3177,7 @@ dependencies = [ "derive_more", "hex", "hex-literal", - "rand 0.8.4", + "rand 0.8.5", "rand_chacha 0.3.1", "serde", "signature", @@ -3213,12 +3199,12 @@ dependencies = [ "base64", "bitflags", "derive_more", - "digest 0.10.1", + "digest 0.10.3", "hex", "hex-literal", "once_cell", "phf", - "rand 0.8.4", + "rand 0.8.5", "serde", "signature", "thiserror", @@ -3254,14 +3240,14 @@ dependencies = [ "bytes", "cipher", "coarsetime", - "digest 0.10.1", + "digest 0.10.3", "futures", "generic-array", "hex", "hex-literal", "hkdf", "hmac", - "rand 0.8.4", + "rand 0.8.5", "rand_core 0.6.3", "subtle", "thiserror", @@ -3316,7 +3302,7 @@ dependencies = [ "futures", "futures-await-test", "pin-project", - "rand 0.8.4", + "rand 0.8.5", "thiserror", "tor-rtcompat", "tracing", @@ -3350,9 +3336,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", @@ -3373,9 +3359,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716" dependencies = [ "proc-macro2", "quote", @@ -3384,18 +3370,19 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" dependencies = [ "lazy_static", + "valuable", ] [[package]] name = "tracing-journald" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9863a586a2ede0c98ccfd14cedecaa1f59a94eb1029bc33a71c7518235d5e886" +checksum = "36a63bcca9cab23195673d7c3c7db8aff5fc062b82cd1e51c396d9dc26968c3c" dependencies = [ "libc", "tracing-core", @@ -3415,9 +3402,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5312f325fe3588e277415f5a6cca1f4ccad0f248c4cd5a4bd33032d7286abc22" +checksum = "9e0ab7bdc962035a87fba73f3acca9b8a8d0034c2e6f60b84aeaaddddc155dce" dependencies = [ "ansi_term", "lazy_static", @@ -3511,6 +3498,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "value-bag" version = "1.0.0-alpha.8" @@ -3728,6 +3721,49 @@ 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 = "ws2_32-sys" version = "0.2.1" @@ -3779,9 +3815,9 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81e8f13fef10b63c06356d65d416b070798ddabcadc10d3ece0c5be9b3c7eddb" +checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" dependencies = [ "proc-macro2", "quote", From ee4ea7469805092d5d0ef8bf9772f2e70931bb6d Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Fri, 25 Feb 2022 17:38:52 +0100 Subject: [PATCH 03/11] attempt at making CI faster Move rust-nightly to stage test so it runs in parallel with coverage, which are the two longest jobs, and currently run in sequence. Don't document dependancies, should make the step about 50% faster Use about 12M of cache to not recompile grcov each time Don't compile grcov with coverage, we don't need it, it's probably slower both to compile and execute --- .gitlab-ci.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c9f54f57..d8868eef3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,7 +57,7 @@ rust-latest-async-std-rustls: - amd64 rust-nightly: - stage: build + stage: test image: rustlang/rust:nightly allow_failure: true script: @@ -71,7 +71,7 @@ rust-nightly: # and similar, for when nightly clippy has false positives. (There is no builtin # cfg flag for nightly, and a cargo "feature" would be bad with --all-features.) - cargo clippy --all-features --tests -- --cfg ci_arti_nightly -D clippy::dbg_macro -D clippy::print_stdout -D clippy::print_stderr - - RUSTDOCFLAGS="-Dwarnings" cargo doc --all-features --document-private-items + - RUSTDOCFLAGS="-Dwarnings" cargo doc --all-features --document-private-items --no-deps tags: - amd64 @@ -79,19 +79,20 @@ coverage: stage: test image: rust:latest allow_failure: true - variables: - RUSTFLAGS: "-Zinstrument-coverage" - LLVM_PROFILE_FILE: "arti-%p-%m.profraw" script: - apt-get update && apt-get install -y python3-pip python3-setuptools - pip3 install beautifulsoup4 lxml - rustup toolchain add nightly - rustup default nightly - rustup component add llvm-tools-preview - - cargo install grcov + - cp grcov $CARGO_HOME/bin/ || cargo install grcov + - cp $CARGO_HOME/bin/grcov . # Generate report - ./maint/with_coverage cargo test --verbose --all-features - ./maint/with_coverage -f cobertura -o coverage.xml -c true + cache: + paths: + - grcov artifacts: paths: - 'coverage' From 6b615b4766a641f6d1814079881d426ed935785e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 25 Feb 2022 17:13:52 +0000 Subject: [PATCH 04/11] impl Debug for various internal types I wanted this while debugging something. The ad-hoc impl Debug with f.debug_struct is getting repetitive and I've already perpetrated one copy-paste mistake. We should consider using something like the `educe` crate's Clone. --- crates/tor-circmgr/src/impls.rs | 12 ++++++++++++ crates/tor-circmgr/src/mgr.rs | 15 ++++++++++++--- crates/tor-circmgr/src/path.rs | 2 +- crates/tor-guardmgr/src/pending.rs | 11 +++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/crates/tor-circmgr/src/impls.rs b/crates/tor-circmgr/src/impls.rs index 8d9d3904b..999d786f1 100644 --- a/crates/tor-circmgr/src/impls.rs +++ b/crates/tor-circmgr/src/impls.rs @@ -7,6 +7,7 @@ use crate::{DirInfo, Error, Result}; use async_trait::async_trait; use futures::future::OptionFuture; use std::convert::TryInto; +use std::fmt::{self, Debug}; use std::sync::Arc; use tor_error::internal; use tor_proto::circuit::{CircParameters, ClientCirc}; @@ -41,6 +42,17 @@ pub(crate) struct Plan { guard_usable: Option, } +impl Debug for Plan { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Planr") + .field("final_spec", &self.final_spec) + .field("path", &self.path) + .field("params", &self.params) + .field("guard_status", &self.guard_status) + .finish_non_exhaustive() + } +} + impl MockablePlan for Plan {} #[async_trait] diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index fff1c80b9..5e11efcb0 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -37,7 +37,7 @@ use futures::stream::{FuturesUnordered, StreamExt}; use futures::task::SpawnExt; use std::collections::HashMap; use std::convert::TryInto; -use std::fmt::Debug; +use std::fmt::{self, Debug}; use std::hash::Hash; use std::panic::AssertUnwindSafe; use std::sync::{self, Arc, Weak}; @@ -160,7 +160,7 @@ pub(crate) trait MockablePlan { pub(crate) trait AbstractCircBuilder: Send + Sync { /// The specification type describing what operations circuits can /// be used for. - type Spec: AbstractSpec + Send + Sync; + type Spec: AbstractSpec + Debug + Send + Sync; /// The circuit type that this builder knows how to build. type Circ: AbstractCirc + Send + Sync; /// An opaque type describing how a given circuit will be built. @@ -170,7 +170,7 @@ pub(crate) trait AbstractCircBuilder: Send + Sync { // But I don't think that rust can do that. // HACK(eta): I don't like the fact that `MockablePlan` is necessary here. - type Plan: Send + MockablePlan; + type Plan: Send + Debug + MockablePlan; // TODO: I'd like to have a Dir type here to represent // create::DirInfo, but that would need to be parameterized too, @@ -457,6 +457,15 @@ struct CircBuildPlan { pending: Arc>, } +impl Debug for CircBuildPlan { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("CircBuildPlna") + .field("plan", &self.plan) + .field("sender", &self.sender) + .finish_non_exhaustive() + } +} + /// The inner state of an [`AbstractCircMgr`]. struct CircList { /// A map from circuit ID to [`OpenEntry`] values for all managed diff --git a/crates/tor-circmgr/src/path.rs b/crates/tor-circmgr/src/path.rs index cc3600cad..b02afa40f 100644 --- a/crates/tor-circmgr/src/path.rs +++ b/crates/tor-circmgr/src/path.rs @@ -87,7 +87,7 @@ impl<'a> TorPath<'a> { } /// A path composed entirely of owned components. -#[derive(Clone)] +#[derive(Clone, Debug)] pub(crate) enum OwnedPath { /// A path where we only know how to make circuits via CREATE_FAST. ChannelOnly(OwnedChanTarget), diff --git a/crates/tor-guardmgr/src/pending.rs b/crates/tor-guardmgr/src/pending.rs index 58b83e762..cc6222f76 100644 --- a/crates/tor-guardmgr/src/pending.rs +++ b/crates/tor-guardmgr/src/pending.rs @@ -14,6 +14,7 @@ use futures::{ Future, }; use pin_project::pin_project; +use std::fmt::{self, Debug}; use std::pin::Pin; use std::sync::atomic::{AtomicU64, Ordering}; use std::task::{Context, Poll}; @@ -121,6 +122,16 @@ pub struct GuardMonitor { snd: Option>, } +impl Debug for GuardMonitor { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("GuardMonitor") + .field("id", &self.id) + .field("pending_status", &self.pending_status) + .field("ignore_indeterminate", &self.ignore_indeterminate) + .finish_non_exhaustive() + } +} + impl GuardMonitor { /// Create a new GuardMonitor object. pub(crate) fn new(id: RequestId, snd: UnboundedSender) -> Self { From 489da37fe4f005e1ce0b0d35b88a33ed1a697f4e Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 25 Feb 2022 13:05:25 -0500 Subject: [PATCH 05/11] Split "static" into sqlite and native-tls features. Otherwise, it's impossible to get a static sqlite linkage without also getting native-tls, even if you wanted rustls. Closes #302. --- crates/arti-client/Cargo.toml | 4 +++- crates/arti-client/src/lib.rs | 23 +++++++++++++++++++---- crates/arti/Cargo.toml | 4 +++- crates/arti/src/main.rs | 17 ++++++++++++++++- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/crates/arti-client/Cargo.toml b/crates/arti-client/Cargo.toml index 5647f15f7..728a673dd 100644 --- a/crates/arti-client/Cargo.toml +++ b/crates/arti-client/Cargo.toml @@ -16,7 +16,9 @@ async-std = [ "tor-rtcompat/async-std" ] tokio = [ "tor-rtcompat/tokio", "tor-proto/tokio" ] native-tls = [ "tor-rtcompat/native-tls" ] rustls = [ "tor-rtcompat/rustls" ] -static = [ "tor-rtcompat/static", "tor-dirmgr/static" ] +static = [ "static-sqlite", "static-native-tls" ] +static-sqlite = [ "tor-dirmgr/static" ] +static-native-tls = [ "tor-rtcompat/static", "native-tls" ] error_detail = [ ] # Enable experimental APIs that are not yet officially supported. diff --git a/crates/arti-client/src/lib.rs b/crates/arti-client/src/lib.rs index c8b91566f..d9065ec76 100644 --- a/crates/arti-client/src/lib.rs +++ b/crates/arti-client/src/lib.rs @@ -143,12 +143,27 @@ //! //! # Feature flags //! -//! `tokio` -- (Default) Build with support for the Tokio backend. +//! `tokio` -- (Default) Build with support for the Tokio async +//! backend. (default) //! -//! `async-std` -- Build with support for the `async_std` backend. +//! `async-std` -- Build with support for the `async_std` async backend. //! -//! `static` -- Link with static versions of your system dependencies, including -//! sqlite and/or openssl. +//! `native-tls` -- Build with support for the `native_tls` TLS +//! backend. (default) +//! +//! `rustls` -- Build with support for the `rustls` TLS backend. +//! +//! `static` -- Link with static versions of your system dependencies, +//! including sqlite and/or openssl. (⚠ Warning ⚠: this feature will +//! include a dependency on native-tls, even if you weren't planning +//! to use native-tls. If you only want to build with a static sqlite +//! library, enable the `static-sqlite` feature. We'll look for +//! better solutions here in the future.) +//! +//! `static-sqlite` -- Link with a static version of sqlite. +//! +//! `static-native-tls` -- Link with a static version of `native-tls`. +//! Enables `native-tls`. //! //! `experimental-api` -- Build with experimental, unstable API support. Note //! that these APIs are NOT covered by semantic versioning guarantees: we might diff --git a/crates/arti/Cargo.toml b/crates/arti/Cargo.toml index e0fd251ec..48b6bff5a 100644 --- a/crates/arti/Cargo.toml +++ b/crates/arti/Cargo.toml @@ -16,7 +16,9 @@ async-std = [ "arti-client/async-std", "tor-rtcompat/async-std", "async-ctrlc", tokio = [ "tokio-crate", "arti-client/tokio", "tor-rtcompat/tokio" ] native-tls = [ "arti-client/native-tls", "tor-rtcompat/native-tls" ] rustls = [ "arti-client/rustls", "tor-rtcompat/rustls" ] -static = [ "arti-client/static" ] +static = [ "static-sqlite", "static-native-tls" ] +static-sqlite = [ "arti-client/static-sqlite" ] +static-native-tls = [ "arti-client/static-native-tls", "native-tls" ] journald = [ "tracing-journald" ] [dependencies] diff --git a/crates/arti/src/main.rs b/crates/arti/src/main.rs index 46d1b2580..3a86aaa10 100644 --- a/crates/arti/src/main.rs +++ b/crates/arti/src/main.rs @@ -40,8 +40,23 @@ //! `async-std`: Use the async-std runtime library as our backend. //! This feature has no effect unless building with `--no-default-features` //! to disable tokio. + +//! `native-tls` -- Build with support for the `native_tls` TLS +//! backend. (default) //! -//! `static`: Try to link a single static binary. +//! `rustls` -- Build with support for the `rustls` TLS backend. +//! +//! `static` -- Link with static versions of your system dependencies, +//! including sqlite and/or openssl. (⚠ Warning ⚠: this feature will +//! include a dependency on native-tls, even if you weren't planning +//! to use native-tls. If you only want to build with a static sqlite +//! library, enable the `static-sqlite` feature. We'll look for +//! better solutions here in the future.) +//! +//! `static-sqlite` -- Link with a static version of sqlite. +//! +//! `static-native-tls` -- Link with a static version of `native-tls`. +//! Enables `native-tls`. //! //! # Limitations //! From dbf019e4265c4a1b361844df5b142f1553d8956e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 25 Feb 2022 17:47:19 +0000 Subject: [PATCH 06/11] tor-circmgr: take_action: Handle Cancelled from the oneshot Fixes #365 Inspection of the code and logs shows that: * One of the plan futures' oneshots must be returning Cancelled * This means that the corresponding sender must have been dropped * The sender is owned by the task spawned by spawn_launch Presumably that entire task gets dropped as part of executor shutdown, or something. The correct response in this situation is to declare that we are shutting down, and stop trying to do stuff. Unfortunately, despite trying quite hard by putting sleeps in various strategic places, I have not been able to reproduce the problem. So I can't be 100% sure that the new behaviour is correct. But I am reasonably confident that this ought not to be able to occur unless either 1. the task from spawn_launch is dropped, or 2. that task somehow panics despite its attempts to trap panics and report them as errors through the oneshot. So this "burn it all down" action ought only to occur in actually serious situations. I observe that 3ff9b187ea26aaec4875067fcdbf485ecc9f597d Handle panics from circuit construction. changed the EK for PendingCanceled to EK::ReactorShuttingDown, and there's From impl. I think, therefore, that it is right to reuse this Error variant. I don't quite understand why when take_action gets an actual error it doesn't push it, but just logs it. But I am not changing that for now. Arguably the two instances of retry_error.push are a sign of an inferior flow control pattern - maybe the loop body including the code I am adding ought to be an IEFE returning `Result, crate::Error>`. --- crates/tor-circmgr/src/mgr.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index fff1c80b9..5ce2796fa 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -926,7 +926,14 @@ impl AbstractCircMgr { let mut retry_error = RetryError::in_attempt_to("wait for circuits"); while let Some((src, id)) = incoming.next().await { - if let Ok(Ok(ref id)) = id { + let id = match id { + Err(oneshot::Canceled) => { + retry_error.push(Error::PendingCanceled); + return Err(retry_error); + }, + Ok(id) => id, + }; + if let Ok(ref id) = id { // Great, we have a circuit. See if we can use it! let mut list = self.circs.lock().expect("poisoned lock"); if let Some(ent) = list.get_open_mut(id) { From 5323825964263b5d59d7f22d0d11d763566ed8d9 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Sun, 27 Feb 2022 13:16:03 +0100 Subject: [PATCH 07/11] don't return already errored pending circuit when searching new circuit matching spec --- crates/tor-circmgr/src/mgr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index fff1c80b9..1cadd0daa 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -576,6 +576,7 @@ impl CircList { .pending_circs .iter() .filter(|p| p.supports(usage)) + .filter(|p| !matches!(p.receiver.peek(), Some(Err(_)))) .collect(); if result.is_empty() { @@ -1701,7 +1702,6 @@ mod test { } #[test] - #[ignore] // This test is unreliable; see arti#210 fn request_retried() { tor_rtcompat::test_with_one_runtime!(|rt| async { let rt = MockSleepRuntime::new(rt); From 76d8338640a3d192f69039b6ec086cddb98e71e8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 28 Feb 2022 11:21:52 +0000 Subject: [PATCH 08/11] Fix two typos --- crates/tor-circmgr/src/impls.rs | 2 +- crates/tor-circmgr/src/mgr.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tor-circmgr/src/impls.rs b/crates/tor-circmgr/src/impls.rs index 999d786f1..f15c39d96 100644 --- a/crates/tor-circmgr/src/impls.rs +++ b/crates/tor-circmgr/src/impls.rs @@ -44,7 +44,7 @@ pub(crate) struct Plan { impl Debug for Plan { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Planr") + f.debug_struct("Plan") .field("final_spec", &self.final_spec) .field("path", &self.path) .field("params", &self.params) diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index 5e11efcb0..1d911e493 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -459,7 +459,7 @@ struct CircBuildPlan { impl Debug for CircBuildPlan { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("CircBuildPlna") + f.debug_struct("CircBuildPlan") .field("plan", &self.plan) .field("sender", &self.sender) .finish_non_exhaustive() From 6d01c60925c3f42bb91f3aa295d4b71261a18aa6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 28 Feb 2022 12:36:48 +0000 Subject: [PATCH 09/11] Fix rustfmt --- crates/tor-circmgr/src/mgr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index 5ce2796fa..149aec5dd 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -930,7 +930,7 @@ impl AbstractCircMgr { Err(oneshot::Canceled) => { retry_error.push(Error::PendingCanceled); return Err(retry_error); - }, + } Ok(id) => id, }; if let Ok(ref id) = id { From 23f8d33d4db406275b22f507ae8174a2a5c421c7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 28 Feb 2022 12:52:38 +0000 Subject: [PATCH 10/11] Add a debug! log message for source cancellation --- crates/tor-circmgr/src/mgr.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index 149aec5dd..9d7d3583b 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -928,6 +928,10 @@ impl AbstractCircMgr { while let Some((src, id)) = incoming.next().await { let id = match id { Err(oneshot::Canceled) => { + debug!( + "{:?} went away (Canceled), quitting take_action right away", + src + ); retry_error.push(Error::PendingCanceled); return Err(retry_error); } From cb6cd4aa5c910b4f184f50cf83aefff9ef803731 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 28 Feb 2022 08:42:09 -0500 Subject: [PATCH 11/11] Update to new arti-corpora --- arti-corpora | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arti-corpora b/arti-corpora index ae2b97eae..bd32029da 160000 --- a/arti-corpora +++ b/arti-corpora @@ -1 +1 @@ -Subproject commit ae2b97eae71beee596ba4bce8c126d6990cffb7c +Subproject commit bd32029dad1bd8920d71a41ad93ec06c86e0401a