Including bson crate in binary with arti-client breaks bootstrap
This makes no sense, and if it weren't for the min-repro I wouldn't believe it.
Background
(skip to min-repro to avoid a rant)
I have an arti-client
-based implementation of my TorProvider
trait that I have been incrementally implementing as features come online in arti. The last of my required features (restricted discovery) recently came online so I've been wrapping it with my own implementation. I have various tests in my tor-interface
crate which verify bootstrapping, hosting/connecting to onion services, restricted discovery, etc. They all pass with the new ArtiClientTorClient
and even interop with my legacy c-tor client wrapper as well.
With all of my features implemented in tor-interface
, it was time to verify my ArtiClientTorClient
worked in my gosling
crate, which depends on tor-interface
(of course it would, why wouldn't it?). After wiring up the necessary feature flags, I implemented a test and... ArtiClientTorClient
always gets stuck at 8% bootstrapping. Ok, nbd maybe some of the gosling
stuff is somehow interfering? So I moved my working bootstrapping tests from tor-interface
into gosling
and... same behvaiour, stuck at 8%.
Ok... maybe it's a tokio build thing, or a config flag problem? Nope! Integrated it into an example app with no testing anything, same behaviour. Finally, I stripped out all of the functionality from my gosling
crate except for bootstrapping, removed all but the bare minimmum dependencies in the Cargo.toml to make it build. FINALLY, bootstrap succeeds. So I start adding things back and discover including my honk-rpc
crate triggers the same failing bootstrap behaviour. The honk-rpc
crate has no concept of anything to do with tor, or Arti, or anything. THEN, I discover if I just include the bson
crate (which honk-rpc
depends on) in gosling
I get the failing bootstrap behaviour.
Jackpot!
why tho??????
min-repro
So here is what we have, a bare-minimum arti-client
bootstrapping application which when you include the bson
crate in the build, will fail to bootstrap (on Debian bookworm at least).
main.rs
use std::path::PathBuf;
use arti_client::config::{CfgPath, TorClientConfigBuilder};
use arti_client::{BootstrapBehavior, TorClient};
use tokio::runtime::Handle;
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() {
// set custom config options
let mut config_builder: TorClientConfigBuilder = Default::default();
let mut data_path = std::env::temp_dir();
data_path.push("min-repro");
// manually set arti cache and data directories so we can have
// multiple concurrent instances and control where it writes
let mut cache_dir = PathBuf::from(data_path.clone());
cache_dir.push("cache");
config_builder
.storage()
.cache_dir(CfgPath::new_literal(cache_dir))
.keystore()
.enabled(arti_client::config::BoolOrAuto::Explicit(true));
let mut state_dir = PathBuf::from(data_path);
state_dir.push("state");
config_builder
.storage()
.state_dir(CfgPath::new_literal(state_dir));
// disable access to clearnet addresses and enable access to onion services
config_builder
.address_filter()
.allow_local_addrs(true);
let config = config_builder.build().unwrap();
let arti_client = TorClient::builder()
.config(config)
.bootstrap_behavior(BootstrapBehavior::Manual)
.create_unbootstrapped()
.unwrap();
let mut bootstrap_events = arti_client.bootstrap_events();
Handle::current().spawn(async move {
while let Some(evt) = bootstrap_events.next().await {
println!("event: {evt}");
}
});
let _ = arti_client.bootstrap().await;
println!("bootstrapped!");
}
Cargo.toml
[package]
name = "min-repro"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
arti-client = { version = "0.22.0", features = ["keymgr", "tokio"]}
# uncomment me to break bootstrap (always gets stuck at 8%)
# bson = "2.0"
tokio = { version = "1", features = ["full"] }
tokio-stream = { version = "0" }
Failing output
event: 0%: connecting to the internet; not downloading
event: 0%: connecting to the internet; directory is fetching a consensus
event: 0%: connecting to the internet; directory is fetching a consensus
event: 8%: handshaking with Tor relays; directory is fetching a consensus
event: 8%: handshaking with Tor relays; directory is fetching a consensus
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
event: Stuck at 8%: Our internet connection seems filtered (our internet connection seems to be filtered)
...
$ rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)