hhanh00/zcash-sync

Publish as a rust crate?

Closed this issue · 10 comments

I'm interested in possibly using warp sync in another zcash wallet app. This tech is amazing and no zcash wallet should be without it.
But spawning another process and using RPC to interact with it adds complexity and runtime cost.
I'd like to expose warp sync to the .NET ecosystem so that wallets, financial apps, and other tools can be written in .NET and access it.
I already have a .NET assembly that calls into a rust dll that links in zcash-related rust crates. I'd like warp sync to be among its functionality.

Are you willing to do this (or accept a PR) to this repo to publish a rust crate with all this code?

It looks from https://hhanh00.github.io/zcash-sync/developer/ffi/ that perhaps this has already been done. But the docs suggest it only supports sapling. Is the doc old, or does this form of warp sync really lack support for orchard?

warp sync supports orchard.
Unfortunately, crates cannot be published if they depend on git branches or revs. And since I have made modifications to librustzcash and orchard, I have forked these repos.

Now that I can build this repo locally, I'm wondering how to take it to the next step by incorporating it into my own rust .dll (which I already consume from an app). This may be a basic rust question, but assuming I have your repo as a submodule of my own, how do I get my rust project to 'reference' yours so I can link in the code?

That's more a question for Stackoverflow than this issue tracker...

Fair enough. But if you had an example rust project that depended on this one (or zwallet) via Cargo.toml, I'd love to look at it. This is what I tried:

[dependencies]
"warp_api_ffi" = { git = "https://github.com/hhanh00/zwallet.git", features = ["dart_ffi"] }

But cargo check fails with:

error: failed to get `warp_api_ffi` as a dependency of package `my-zcash-sync v0.1.0 (/home/andrew/git/my-zcash-sync)`

Caused by:
  failed to load source for dependency `warp_api_ffi`

Caused by:
  Unable to update https://github.com/hhanh00/zwallet.git

Caused by:
  Could not find Cargo.toml in `/home/andrew/.cargo/git/checkouts/zwallet-9089bfd46a576ff5/95aec7b`

In case anyone else comes across this, I posted on StackOverflow here: https://stackoverflow.com/questions/76889481/how-to-depend-on-a-rust-crate-in-a-git-repos-submodule

Zwallet is a flutter repo, the right one to use is zcash-sync.

But per #14 you suggested it can only be built in the context of the super-repo. So now I'm confused. FWIW, when I tried having the dependency in my own Cargo.toml file point to this repo directly, I saw the same errors in building that I reported over there.

It's easier because you don't have to deal with pointing to a specific revision. If you want to go your route, you need to add a rev=git_commit_hash. Welcome to rust dependency hell.

I think by default cargo is bringing down the tip of the default branch. If that's the wrong commit, what would the right one be?

And are you suggesting that somehow the rev requirement only happens if I go via the super-repo? I am familiar with git submodules in general and how they latch on to a specific commit that requires manual maintenance. But at this point I have no changes I want to apply to your repos. I just want to use them as-is, so the tip of the default branch seems adequate.

When you say "It's easier", are you referring to depending on zcash-sync directly? I'm totally happy to do that. But it just means I have to know how to get past the problems of #14.