# Arti: A pure-Rust Tor Implementation for Zcash and beyond

**URL:** <https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776>\
**Category:** Community Grants\
**Created:** [March 3, 2021, 5:45pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776 "2021-03-03T17:45:37Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![holmesworcester](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/holmesworcester/32/15710_2.png) [@holmesworcester](https://forum.zcashcommunity.com/u/holmesworcester)\
**Post date:** [April 30, 2021, 12:37pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/42 "2021-04-30T12:37:30Z")

</div>

> [@nickm\_tor](#):
>
> … But we would be more than happy to put forth the work and effort to support wallet developers at every stage of their integration plans. We especially want to make sure that their needs are met by our APIs, and have included the cost of that that needs-discovery within the Zcash ecosystem as part of our project estimates.

This makes sense to me and is helpful for our decision!

> [@nickm\_tor](#):
>
> Once we are in communication with the right folks at ECC & ZF (we hope you can set this conversation up, to make sure we’re talking with the right people), we can figure out the best details for this collaboration, possibly with refinements to the roadmap.

We can! And we’re waiting to hear back now from the various teams to make sure that Arti integration will be on their roadmap.

---

<div class="post-metadata">

**Author:** ![teor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/teor/32/17846_2.png) [@teor](https://forum.zcashcommunity.com/u/teor)\
**Post date:** [May 4, 2021, 12:22am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/43 "2021-05-04T00:22:44Z")

</div>

> [@nickm\_tor](#):
>
> > [@teor](#):
> >
> > Most wallets just use DNS, and the Zebra and zcashd nodes use generic IP address objects. But the Tor protocol still makes quite a few internal distinctions between IPv4 and IPv6. So IPv6 support isn’t automatic.
> 
> Given this need, here’s what I see as the best way forward. I think we should move minimal IPv6-only client support forward from 1.0.0 into 0.0.1, but leave complete support for 1.0.0. This way integrators and beta testers can run on IPv6-only networks from the beginning.
> 
> By “minimal IPv6-only client support”, I mean that clients that only have IPv6 should be able to bootstrap and connect to the Tor network and work reasonably okay. (This would probably involve a not-very-optimized ‘happy eyeballs’ style approach.) Unless I’m wrong, doing this part won’t add more than a day or two to our 0.0.1 estimates.
> 
> …
> 
> How does that sound?

I remember writing a few happy-eyeballs proposals for Tor.

Now there are more Tor relays and authorities on IPv6, happy eyeballs should be efficient enough for testing. (And much easier to implement than in the legacy Tor codebase.)

> [@nickm\_tor](#):
>
> > [@teor](#):
> >
> > Looking at the milestones and tickets, it seems like Arti is aiming for a similar async architecture to Zebra:
> 
> That’s right. We’ve been trying to structure our crates into (roughly) three tiers with respect to async-ness:
> 
> 1. The lowest level of code doesn’t know about async-ness at all. It’s just straightforward blocking code.[^\*]
> 2. The middle tier knows about async programming and futures, but nothing about specific async runtimes. Because of that, it can’t spawn tasks, listen, launch network connections, sleep, etc.
> 3. The top tier knows about runtimes, as abstracted through a [compatibility crate](https://gitlab.torproject.org/tpo/core/arti/-/tree/main/tor-rtcompat).
> 
> [\*]: To make it easier to add asyncness later on, we require that expensive cryptographic operations are in different function calls from everything else though. For example, signature checking and parsing are always separate calls.
> 
> > [@teor](#):
> >
> > The Zebra team is happy to do an architecture walkthrough if you’d like. We’re also working on a list of common async Rust pitfalls.
> 
> Both of those sound excellent to me. I’d also love to bring Zebra devs in on an Arti walkthrough some time, if you’re interested. (I don’t expect I’d teach you much, but you would probably spot areas where we could do better.)

That would be great! Let’s wait on any grant decision, and then do the walkthroughs soon after.

We also just merged our “Async Rust in Zebra” documentation today:

> <https://github.com/ZcashFoundation/zebra/blob/main/book/src/dev/rfcs/0011-async-rust-in-zebra.md#summary>

The difference in priority between the `select()` function and `select! { }` macro was particularly surprising to us.

---

<div class="post-metadata">

**Author:** ![teor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/teor/32/17846_2.png) [@teor](https://forum.zcashcommunity.com/u/teor)\
**Post date:** [May 5, 2021, 11:33pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/44 "2021-05-05T23:33:26Z")

</div>

> [@holmesworcester](#):
>
> Finally, the most important factor in us choosing to fund this grant will be, “is this important for Zcash, and will it definitely benefit Zcash users by becoming part of popular Zcash tools?” Most of us here are big fans of Tor, obviously. But our mandate is to fund work that strengthens Zcash and we take that seriously. We have key people at the ZF, ECC, and Nighthawk saying here in this thread that it is useful and will be used. But given the grant size we’re hoping to get an official thumbs-up from both organizations. So we’ll be reaching out to them both about that!
> 
> We’re also wondering if there’s any work we should budget for on your end that would increase our confidence that Arti will be integrated in Zcash tools.

Here are some other things I’ve been thinking about as I’ve looked over arti’s milestones:

There’s an experienced Rust developer review as part of the 1.0.0 release. By that time, your architecture and data design will be pretty fixed - can you get an experienced Rust dev to look at them before your APIs stabilise? (0.0.1 or 0.1.0)

The Zebra team has had a similar lock-in experience in some of our async Rust code. For example, we wish we had made our `std::thread::Mutex<AddressBook>` into a `tower::Service` much earlier. Because now we’ve built on top of the mutex abstraction, it’s going to take more work to make all its callers async. (And it’s exposed in the API of the `zebra-network` crate, but it really shouldn’t be. More refactor work!)

But in general, we’ve really benefited from having experienced Rust developers work on our designs, implementations, and code reviews. I’ve definitely learned a lot!

I also wonder if the security audit cost is potentially a bit low for a protocol as complex as Tor? (That said, there will obviously be legacy features that you will never implement in arti.)

And thinking about timeframes for that audit: it might be helpful for the arti security audit to be done around the time Zebra has its first audited client release. But we haven’t done detailed planning for our client work yet, so I don’t have any specific timeframes for Zebra. And I suspect `zcashd`’s requirements will be the real driver here, because they’re in production already.

---

<div class="post-metadata">

**Author:** ![nickm\_tor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/nickm_tor/32/17845_2.png) [@nickm\_tor](https://forum.zcashcommunity.com/u/nickm_tor)\
**Post date:** [May 12, 2021, 7:53pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/45 "2021-05-12T19:53:34Z")

</div>

Hi again, @teor, and sorry for the delay. My schedule has been wild and I’ve been more distracted than useful.

> Can you get an experienced Rust dev to look at them before your APIs stabilise? (0.0.1 or 0.1.0)

Yes; we’re hoping to actually start getting our API feedback as soon as we can, especially for developer-visible APIs.

Incidentally, as for Tower stuff, I’m hoping you or somebody will have time someday to introduce us to the _why_ of Tower in a system like ours. I’m getting a sense what Tower does and what its APIs are for, but not a great sense of where Tower would logically fit into Arti. (Maybe there’s a part of Zebra I should look at, in order to get the key idea here?)

---

<div class="post-metadata">

**Author:** ![teor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/teor/32/17846_2.png) [@teor](https://forum.zcashcommunity.com/u/teor)\
**Post date:** [May 14, 2021, 3:24am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/46 "2021-05-14T03:24:42Z")

</div>

> [@nickm\_tor](#):
>
> Incidentally, as for Tower stuff, I’m hoping you or somebody will have time someday to introduce us to the _why_ of Tower in a system like ours. I’m getting a sense what Tower does and what its APIs are for, but not a great sense of where Tower would logically fit into Arti. (Maybe there’s a part of Zebra I should look at, in order to get the key idea here?)

Zebra is designed as a series of microservices: [A New Network Stack For Zcash – Zcash Foundation](https://www.zfnd.org/blog/a-new-network-stack-for-zcash/)

One of the benefits of Tower is that [`Service`s](https://docs.rs/tower-layer/0.3.1/tower/trait.Service.html) are composable with [`Layer`s](https://docs.rs/tower-layer/0.3.1/tower_layer/). So it’s very easy to wrap a network service in a `hedge`, `timeout`, concurrency `limit`, or `buffer`. And if you’ve used Rust generics for your service types, the rest of your code doesn’t need to change at all.

Zebra uses about half the layers listed here: [tower - Rust](https://docs.rs/tower/0.4.7/tower/index.html#modules)

And we also have our own tower-based batch verifiers for zero-knowledge proofs and signatures: [https://www.zfnd.org/blog/futures-batch-verification/](https://www.zfnd.org/blog/futures-batch-verification/)

A similar design might be helpful for arti - you could have:

- a directory microservice,
- a guard-set microservice for guard connections (like tower-discover),
- a microservice that handle circuits and cell decryption, and
- an ed25519 batch verification service (like Zebra!)

---

<div class="post-metadata">

**Author:** ![nickm\_tor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/nickm_tor/32/17845_2.png) [@nickm\_tor](https://forum.zcashcommunity.com/u/nickm_tor)\
**Post date:** [June 4, 2021, 10:12pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/47 "2021-06-04T22:12:47Z")

</div>

A small update that might be of interest, as a proof-of-concept:

We’ve heard from a group of researchers who had the need to integrate anonymous communications into a contact tracing app that’s going to be used by several million users. The addition of anonymous communications would enable the privacy-preserving collection of usage statistics, key to assess the performance of the app. It would also enhance the security and privacy of new functionalities.

They decided to use the Tor network to safely route communications without deploying any new infrastructure. They decided to use Arti because—for their particular use case and threat model—the security features that Arti currently lacks are not necessary.

They’ve experimented with adding Arti support and they report:

- Arti worked for them out-of-the-box on Android and iOS
- They haven’t had trouble integrating it or making it work for them in practice.
- There is a fairly good chance that the app version using Arti will be soon in production.

They don’t want to go public yet, since the feature is a work in progress, but they are happy to be contacted to answer questions about their use case and plans, and how further development of Arti would help their projects. But please ping me if you’d like me to put you in touch with them to discuss their experience.

---

<div class="post-metadata">

**Author:** ![Shawn](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/shawn/32/187_2.png) [@Shawn](https://forum.zcashcommunity.com/u/Shawn)\
**Post date:** [June 8, 2021, 10:18am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/48 "2021-06-08T10:18:42Z")

</div>

@nickm_tor — great news! ZOMG is pleased to announce that “Arti: A pure rust Tor Implementation for Zcash and Beyond” has been approved to Milestone 1.1.0! 🎉

Funding to milestone 1.1.0 is approximately $670,000. With this grant, we’re going to begin offering some projects a choice between fixing the values of milestone payouts in ZEC or USD.  
If you choose USD, you’ll receive exactly the USD values you proposed. If you choose ZEC, the ZEC amounts will be determined at today’s market prices, and you’ll receive those ZEC amounts for your milestones as they are met whether the market value of ZEC goes up or down. Given our understanding of Tor’s structure and needs, and given the size of the grant, we assume you prefer to fix the values of milestone payments in USD. If so, can you confirm this? Thanks!!

(Note for others following this discussion: we’re working on a separate post to explain why we came to this decision about ZEC vs USD milestones and what the caveats will be, and that will be posted soon! The short version is that we realized that in our current process ZOMG could potentially have become unable to meet its commitments, so we’re changing our process to address that.)

Please feel free to DM us [@ZcashGrants](https://forum.zcashcommunity.com/groups/zcashgrants) so we can schedule a meeting to discuss next steps and answer any questions. We will also need to revise your existing grant proposal on the grant’s platform before we can proceed with approval there.

Congratulations!! We look forward to seeing Arti and the impact it can have on Zcash users network level privacy!

---

<div class="post-metadata">

**Author:** ![Shawn](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/shawn/32/187_2.png) [@Shawn](https://forum.zcashcommunity.com/u/Shawn)\
**Post date:** [June 8, 2021, 10:32am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/49 "2021-06-08T10:32:58Z")

</div>

Also, we have reason to believe that this project may receive media coverage.

Our press release for any inquiries:

> **[Zcash Community Grants](https://zcashcommunitygrants.org/)**
>
> The Zcash Community Grants program funds independent teams entering the Zcash ecosystem, to perform major ongoing development (or other work) for the public good of the Zcash ecosystem.

---

<div class="post-metadata">

**Author:** ![tokidoki](https://avatars.discourse-cdn.com/v4/letter/t/dc4da7/32.png) [@tokidoki](https://forum.zcashcommunity.com/u/tokidoki)\
**Post date:** [June 8, 2021, 12:10pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/50 "2021-06-08T12:10:43Z")

</div>

Congrats @nickm_tor and all people at Tor 😀

Happy to be a part of community who cares about the future of privacy for all 🛡

[https://twitter.com/ZcashID/status/1402235896649293825](https://twitter.com/ZcashID/status/1402235896649293825)

---

<div class="post-metadata">

**Author:** ![Shawn](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/shawn/32/187_2.png) [@Shawn](https://forum.zcashcommunity.com/u/Shawn)\
**Post date:** [June 8, 2021, 1:17pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/51 "2021-06-08T13:17:11Z")

</div>

> **[Tor Project Receives $670K From Zcash Open Major Grants for Coding Language...](https://www.coindesk.com/tech/2021/06/08/tor-project-receives-670k-from-zcash-open-major-grants-for-coding-language-upgrade/)**
>
> The funding will go toward developer salaries as they develop Arti.

---

<div class="post-metadata">

**Author:** ![extrapo](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/extrapo/32/17568_2.png) [@extrapo](https://forum.zcashcommunity.com/u/extrapo)\
**Post date:** [June 10, 2021, 6:23pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/52 "2021-06-10T18:23:17Z")

</div>

Congrats for the Tor Team!

Heavy Tor user here, 5 years ago on the CaosComputerCamp I gave a workshop on making a crawler for Hidden Services, also generating some DataVizualizations… Was very lucky to meet some of you with Gabriella Coleman in the train back to Berlin… lots of intellectual generosity…

Long Live to Tor!

[https://events.ccc.de/camp/2015/wiki/Session:Deep\_Graphics](https://events.ccc.de/camp/2015/wiki/Session:Deep_Graphics)

---

<div class="post-metadata">

**Author:** ![bdavila](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@bdavila](https://forum.zcashcommunity.com/u/bdavila)\
**Post date:** [November 9, 2021, 4:48pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/53 "2021-11-09T16:48:09Z")

</div>

On October 29th we launched the first release of Arti, v0.0.1 [0]. This release is ready for general testing, but not yet ready for production use. You can read about the features and changes in the changelog for this release [1][2…8].

1. release: [Arti 0.0.1 is released: An embeddable Tor client in Rust - News - Tor Project Forum](https://forum.torproject.net/t/arti-0-0-1-is-released-an-embeddable-tor-client-in-rust/281)

2. changelog: [CHANGELOG.md · main · The Tor Project / Core / Arti · GitLab](https://gitlab.torproject.org/tpo/core/arti/-/blob/main/CHANGELOG.md)

3. [[tor-dev] Arti development report: 23 June through July 7](https://lists.torproject.org/pipermail/tor-dev/2021-July/014577.html)

4. [[tor-dev] Arti Report 3: July 21 through August 4](https://lists.torproject.org/pipermail/tor-dev/2021-August/014607.html)

5. [[tor-dev] Arti report 4: August 4 through August 18](https://lists.torproject.org/pipermail/tor-dev/2021-August/014611.html)

6. [[tor-dev] Arti report 5: August 18 through September 15](https://lists.torproject.org/pipermail/tor-dev/2021-September/014634.html)

7. [[tor-dev] (Short) Arti Report 6: September 15 through September 30](https://lists.torproject.org/pipermail/tor-dev/2021-October/014640.html)

8. [[tor-dev] Arti report 7: September 30 through October 13](https://lists.torproject.org/pipermail/tor-dev/2021-October/014656.html)

9. [[tor-dev] Arti report 7: September 30 through October 13](https://lists.torproject.org/pipermail/tor-dev/2021-October/014656.html)

---

<div class="post-metadata">

**Author:** ![bdavila](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@bdavila](https://forum.zcashcommunity.com/u/bdavila)\
**Post date:** [December 1, 2021, 7:04pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/54 "2021-12-01T19:04:05Z")

</div>

Arti 0.0.2 is released: API groundwork, refactoring, config, and optimism

> **[Arti 0.0.2 is released: API groundwork, refactoring, config, and optimism](https://forum.torproject.net/t/arti-0-0-2-is-released-api-groundwork-refactoring-config-and-optimism/939)**
>
> Arti 0.0.2 is released: API groundwork, refactoring, config, and optimism Arti is our ongoing project to create a working embeddable Tor client in Rust. It’s nowhere near ready to replace the main Tor implementation in C, but we believe that it’s...

---

<div class="post-metadata">

**Author:** ![teor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/teor/32/17846_2.png) [@teor](https://forum.zcashcommunity.com/u/teor)\
**Post date:** [December 28, 2021, 3:35am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/55 "2021-12-28T03:35:06Z")

</div>

> [@nickm\_tor](#):
>
> we at Tor aren’t necessarily the right team to develop patches for apps in the Zcash ecosystem. (That’s not where our expertise lies, and our performance at this task would probably be less efficient than more experienced cryptocurrency developers.) But we would be more than happy to put forth the work and effort to support wallet developers at every stage of their integration plans. We especially want to make sure that their needs are met by our APIs, and have included the cost of that that needs-discovery within the Zcash ecosystem as part of our project estimates.

I recently spent about a day [adding Tor support to Zebra’s isolated connection API using `arti-client`](https://github.com/ZcashFoundation/zebra/pull/3303).

When Zebra adds support for sending user-generated transactions, we can use this API to make sure they aren’t linked to the sender’s IP address. (Or to any other transactions we send.)

Overall the process went really smoothly. The API was easy to understand, the code is short and easy to read, and basic tests seem to work. (I wasn’t able to do comprehensive end-to-end tests, because Zebra doesn’t support creating transactions yet.)

Here’s some detailed feedback about some tricky parts of the integration.

**Dependency Versions**

The dependency versions that `arti` requires seem quite strict for a library crate. We needed to do a few dependency upgrades for Zebra as part of integration. These upgrades were simple using `cargo upgrade`. But sometimes dependency upgrades might need code changes.

Can `arti` depend on the earliest supported minor release of each dependency in `Cargo.toml`?  
You can use `Cargo.lock` to specify exact dependencies for binary crates.

**Dependency Troubleshooting**

It would be helpful to mention:

- installing `pkg-config`, and
- setting `OPENSSL_DIR` and `SQLITE3_LIB_DIR` for troubleshooting header or linker errors.

I also needed to set `LD_LIBRARY_PATH`, but that’s probably a `Nix` derivation bug.

The troubleshooting doc was a bit hard to find, maybe it could be linked from the readme.

**Useful APIs**

There are a few missing APIs that would help make our code more efficient, and might reduce our load on the Tor network:

_An API that bootstraps Tor if needed, then returns a cloned Tor client_

Making a shared `TorClient` instance [was a bit tricky](https://github.com/ZcashFoundation/zebra/pull/3303/files#diff-96f6cfb3b74801828eb0d7430a6e2f6307d28ab01c63a1d208ec600c559c6aa9R50-R54), because it’s hard to lazily call async code in Rust, and then share the result. So I ended up wrapping the shared value in an `Arc<Mutex<_>>`. But this seems like a bit of a waste, because there’s already a lot of locking inside `TorClient`.

Here are some API changes that might have made that easier:

- an API or example code that initializes a shared `TorClient` when it is first used, then clones the shared instance for future requests
- a non-async API that configures and allocates a shared `TorClient`, then bootstraps it when it actually gets its first request (or when an async bootstrap method gets called)
- if possible, making `arti_client::Error` cloneable, so `arti` futures be used with [FutureExt::shared](https://docs.rs/futures/0.3.19/futures/future/trait.FutureExt.html#method.shared)

_A `TorClient` config that makes sure all connections are isolated_

In Zebra, we don’t plan on sending blockchain blocks over Tor, because it’s all public information. So we’ll just be occasionally sending new user-generated transactions over Tor.

So it would be helpful to have a `TorClient` config that guarantees all connections are isolated. It might also save some preemptive circuit load on the network. (Unless all preemptive circuits are guaranteed to be isolated already - I can’t remember.)

But I can understand if you don’t want to expose this as a configurable client mode. Because it will place more load on the network.

_Minor API nitpicks_

`arti_client::Result` is a useful type alias, it would be nice for it to be available outside the `arti` crates. That way, our tor-specific APIs don’t have to use `BoxError` everywhere.

It seems like the stream timeout config builder isn’t exposed by the client config builder. But we didn’t need it anyway.

In Zebra we’ll probably end up creating a [tower::Service](https://docs.rs/tower/latest/tower/trait.Service.html) that takes hostnames, and returns `arti_client::DataStream`s. So we might not actually need any of these API changes - we can do it all in the service. Cloneable errors would be nice though!

---

<div class="post-metadata">

**Author:** ![nickm\_tor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/nickm_tor/32/17845_2.png) [@nickm\_tor](https://forum.zcashcommunity.com/u/nickm_tor)\
**Post date:** [December 29, 2021, 5:55pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/56 "2021-12-29T17:55:49Z")

</div>

Thanks for the detailed feedback, @teor! So you know, we’re on vacation till 6 January, but once we’re back we’ll be opening a bunch of tickets for these issues, and probably asking some questions too. I want to give this feedback a high priority in January. (And a happy new year to you!)

---

<div class="post-metadata">

**Author:** ![teor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/teor/32/17846_2.png) [@teor](https://forum.zcashcommunity.com/u/teor)\
**Post date:** [December 30, 2021, 2:11am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/57 "2021-12-30T02:11:48Z")

</div>

Thanks @nickm_tor!

Just letting you know that I’m taking some leave in January. I can answer questions once I’m back.

I’m happy to answer questions on individual tickets on your bug tracker. It would be hard to track all those details on a single forum thread. (But we should post the ticket links here, so interested people can follow along.)

---

<div class="post-metadata">

**Author:** ![nickm\_tor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/nickm_tor/32/17845_2.png) [@nickm\_tor](https://forum.zcashcommunity.com/u/nickm_tor)\
**Post date:** [January 10, 2022, 1:56pm UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/58 "2022-01-10T13:56:40Z")

</div>

> [@teor](#):
>
> Overall the process went really smoothly. The API was easy to understand, the code is short and easy to read, and basic tests seem to work. (I wasn’t able to do comprehensive end-to-end tests, because Zebra doesn’t support creating transactions yet.)

Thanks, @teor! This is really helpful. Below I’ll link to the tickets we’ve opened on our tracking system, and include any questions or comments we have for you.

> [@](#):
>
> Here’s some detailed feedback about some tricky parts of the integration.
> 
> **Dependency Versions**
> 
> The dependency versions that `arti` requires seem quite strict for a library crate. We needed to do a few dependency upgrades for Zebra as part of integration. These upgrades were simple using `cargo upgrade`. But sometimes dependency upgrades might need code changes.
> 
> Can `arti` depend on the earliest supported minor release of each dependency in `Cargo.toml`?  
> You can use `Cargo.lock` to specify exact dependencies for binary crates.

This is [arti#275](https://gitlab.torproject.org/tpo/core/arti/-/issues/275) and [arti!228](https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/228), now merged. One question we had here, though, is why `cargo upgrade` was necessary on your end. (Were you using earlier versions that weren’t forward-compatible with the ones that Arti required? Do you happen to remember which crates were trouble?)

> [@](#):
>
> **Dependency Troubleshooting**
> 
> It would be helpful to mention:
> 
> - installing `pkg-config`, and
> - setting `OPENSSL_DIR` and `SQLITE3_LIB_DIR` for troubleshooting header or linker errors.
> 
> I also needed to set `LD_LIBRARY_PATH`, but that’s probably a `Nix` derivation bug.
> 
> The troubleshooting doc was a bit hard to find, maybe it could be linked from the readme.

This all sounds like a good idea; it’s now [arti#277](https://gitlab.torproject.org/tpo/core/arti/-/issues/277).

> [@](#):
>
> **Useful APIs**
> 
> There are a few missing APIs that would help make our code more efficient, and might reduce our load on the Tor network:
> 
> _An API that bootstraps Tor if needed, then returns a cloned Tor client_
> 
> Making a shared `TorClient` instance [was a bit tricky](https://github.com/ZcashFoundation/zebra/pull/3303/files#diff-96f6cfb3b74801828eb0d7430a6e2f6307d28ab01c63a1d208ec600c559c6aa9R50-R54), because it’s hard to lazily call async code in Rust, and then share the result. So I ended up wrapping the shared value in an `Arc<Mutex<_>>`. But this seems like a bit of a waste, because there’s already a lot of locking inside `TorClient`.
> 
> […]

Agreed that this is a good idea. The cloneable-Error issue falls under [arti#247](https://gitlab.torproject.org/tpo/core/arti/-/issues/247); I’ve opened [arti#278](https://gitlab.torproject.org/tpo/core/arti/-/issues/278) for the rest.

> [@](#):
>
> _A `TorClient` config that makes sure all connections are isolated_
> 
> In Zebra, we don’t plan on sending blockchain blocks over Tor, because it’s all public information. So we’ll just be occasionally sending new user-generated transactions over Tor.
> 
> So it would be helpful to have a `TorClient` config that guarantees all connections are isolated. It might also save some preemptive circuit load on the network. (Unless all preemptive circuits are guaranteed to be isolated already - I can’t remember.)
> 
> But I can understand if you don’t want to expose this as a configurable client mode. Because it will place more load on the network.

I think we should try to find a way to provide this feature without too much risk of people turning it unnecessarily. I’ve opened [arti#279](https://gitlab.torproject.org/tpo/core/arti/-/issues/279) for this.

(As an aside: preemptive circuits are treated normally with respect to circuit isolation. That is, two isolated streams can be placed on the same preemptive circuit iff those streams can share a circuit.)

> [@](#):
>
> _Minor API nitpicks_
> 
> `arti_client::Result` is a useful type alias, it would be nice for it to be available outside the `arti` crates. That way, our tor-specific APIs don’t have to use `BoxError` everywhere.

Agreed; this is now [arti#280](https://gitlab.torproject.org/tpo/core/arti/-/issues/280).

[qoute]  
It seems like the stream timeout config builder isn’t exposed by the client config builder. But we didn’t need it anyway.  
[/quote]

Thanks; that omission sounds like an oversight. It’s now [arti#281](https://gitlab.torproject.org/tpo/core/arti/-/issues/281)

> [@](#):
>
> In Zebra we’ll probably end up creating a [tower::Service](https://docs.rs/tower/latest/tower/trait.Service.html) that takes hostnames, and returns `arti_client::DataStream`s. So we might not actually need any of these API changes - we can do it all in the service. Cloneable errors would be nice though!

Thanks for the feedback: It’s exactly the kind of thing we were looking for at this stage, and it’s been extremely helpful Even if Zebra does wind up doing all of this with a [`tower::Service`], making these changes will probably help other projects as well.

---

<div class="post-metadata">

**Author:** ![teor](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/teor/32/17846_2.png) [@teor](https://forum.zcashcommunity.com/u/teor)\
**Post date:** [January 25, 2022, 12:38am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/59 "2022-01-25T00:38:56Z")

</div>

> [@nickm\_tor](#):
>
> > [@teor](#):
> >
> > **Dependency Versions**
> > 
> > > The dependency versions that `arti` requires seem quite strict for a library crate. We needed to do a few dependency upgrades for Zebra as part of integration. These upgrades were simple using `cargo upgrade` . But sometimes dependency upgrades might need code changes.
> > > 
> > > Can `arti` depend on the earliest supported minor release of each dependency in `Cargo.toml` ?  
> > > You can use `Cargo.lock` to specify exact dependencies for binary crates.
> 
> …
> 
> One question we had here, though, is why `cargo upgrade` was necessary on your end. (Were you using earlier versions that weren’t forward-compatible with the ones that Arti required? Do you happen to remember which crates were trouble?)

In 2021 we paused our dependency upgrades for a few months while we focused on implementing the Zcash consensus rules. We also delayed some upgrades until the rest of the ecosystem caught up, because we wanted all our dependencies to use the same version of common crates.

So sometimes we run behind the latest crate versions by 3-12 months.

We also try to minimise the number of duplicate crate versions we have. I wrote a [detailed comment on the arti issue explaining our reasons.](https://gitlab.torproject.org/tpo/core/arti/-/issues/275#note_2772075)

Here are the exact lists of dependencies we upgraded at each stage:

[Dependencies that Zebra uses even when arti is turned off](https://github.com/ZcashFoundation/zebra/pull/3302/commits/4593eed48fb4be87fda1d8ff3c598b479a558544):

- upgraded `bytes` 0.5.6 via `http` 0.2.1, this got rid of some duplicate dependencies
- upgraded a bunch of proc macro crates, more duplicate reduction

I’m not sure if there were any specific incompatibilities here. But `bytes` has had some in the past.

The rest of the version changes probably aren’t that interesting. But I’m listing them just in case.

[Arti-only dependencies, after unification with Zebra’s existing dependencies.](https://github.com/ZcashFoundation/zebra/pull/3303/commits/677e9b879dda03751a22e400ce8967b6939a15c5)

[Version changes when we moved from a specific commit to the tagged 0.0.2 release.](https://github.com/ZcashFoundation/zebra/pull/3303/commits/3c407e212088e8d67efe174ad250a3d47842b8a5)

[Version changes since I opened the PR at the end of December.](https://github.com/ZcashFoundation/zebra/pull/3303/commits/3f266cdb9bbc4af5471c5c38b97222a3ff897c22)

---

<div class="post-metadata">

**Author:** ![Shawn](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/shawn/32/187_2.png) [@Shawn](https://forum.zcashcommunity.com/u/Shawn)\
**Post date:** [February 2, 2022, 2:45am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/60 "2022-02-02T02:45:22Z")

</div>

> **[Arti 0.0.4 is released: Refactoring, rustls, and more! | Tor Project](https://blog.torproject.org/arti_004_released/)**
>
> Arti 0.0.4 is released, and available for download.

---

<div class="post-metadata">

**Author:** ![anon35140610](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon35140610](https://forum.zcashcommunity.com/u/anon35140610)\
**Post date:** [February 2, 2022, 2:58am UTC](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/61 "2022-02-02T02:58:23Z")

</div>

I love that they always post blog updates and that at the end of the updates, they always give a shoutout to ZOMG / Zcash Community Grants. It’s a good way to bring exposure to the program.

[Previous page](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776.md?page=2)

[Next page](https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776.md?page=4)
