-
Notifications
You must be signed in to change notification settings - Fork 37.7k
RFC: Rust code integration #15798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Rust code integration #15798
Conversation
…st code. The demonstration library compiles a rust hello world example and auto-generates a header which can be included in C++ code. Co-Authored-By: Jeremy Rubin <j@rubin.io> Co-Authored-By: Cory Fields <cory-nospam-@coryfields.com>
NACK Rust. There's no reasonable way to bootstrap a Rust compiler without using trusted third party binaries. |
@luke-jr Objection noted. |
@luke-jr So this is insufficient: https://www.gnu.org/software/guix/blog/2018/bootstrapping-rust/ ? |
Needs rebase |
@MarcoFalke As noted in the summary, for now, gitian requires net access to download the dependencies. That will be fixed before merge. Also, It requires a toolchain tarball that hasn't been trimmed, so it's very large. That means that the size of the gitian disk needs to be increased: $ dd if=/dev/zero of=base-bionic-amd64 bs=1k seek=20480k count=1 Afaik that won't affect builds in any other way, but be sure to make a backup to be safe. The toolchain package can be created by running this script: https://github.com/bitcoin/bitcoin/pull/15798/files#diff-8acecf4a86a4f206bddfcf142d451a05 |
Thanks for working on this. I think this is great work, and I think it's good to be able to bridge the gap to the bitcoin-rust world. I also understand the concerns with merging this right now, so I think it makes sense to maintain this as a separate branch for now. I'm willing to do this. |
FYI, Zcash makes extensive use of Rust code. You're welcome (of course, since it's MIT-licensed) to look at and reuse our build support for that. It's fully deterministic and statically linked, and all of the transitively depended-on Rust crates, as well as the toolchain, are pinned by hash. Support was initially added in zcash/zcash#2183 , but you would also need some of this list of merged PRs mentioning Rust. |
🚀
There was some CRust related discussion on IRC here (line 401). |
If anyone's interested, I'll be maintaining a rebased version of this branch (with a couple simple commits on top) here: https://github.com/fanquake/bitcoin/tree/theuni-with-rust-example-working-rebased, and branching off of that to play with more Rust integration. I'm using a |
My branch has been re-rebased and I've added a commit to update |
There is a new |
I personally like cbindgen, but I still think that generated code should be tracked in the version control(aka git) so we can easily notice changes done via cbindgen. |
What would be nice for messing around with this is a way to log (e.g. call Edit: log!("hello from rust {}\n", domain_str);
log_cat!(LogFlags::NET, "(cat) hello from rust {}\n", domain_str); |
Closing this in favour of #17090. Please engage in "Rust inside Bitcoin Core" discussions there instead. |
This is work from Jeremy Rubin integrated into our buildsystem. It allows for rust code to be used directly inside of Bitcoin Core. In its current form, it demonstrates calling a single hello_world function from rust code.
This is not intended to be merged as-is, but instead to serve as a reference for anyone who might be interested in trying out some rust code inside of Bitcoin Core. I have no idea what works. I have lots of questions about debugging, threading, etc. But instead of trying to hack and document how things work, we thought it'd be fun for everyone to be able to poke at it and scratch our heads together :). If something interesting comes out of it, a discussion about merging can happen then.
It is surprisingly functional. The rust tools are impeccable. I would've thought this would be a project that would take months/years, but the rust devs have done such a good job that mostly everything already just works. The gitian descriptors have been modified to actually incorporate working rust code. All of our currently supported platforms seem to already work (even macOS cross!) with the exception of 32bit windows and ancient linux distros. The specific issues are documented in the gitian descriptors. For now, Gitian needs net access and a larger disk volume, but those are both very temporary issues
Why rust? I don't know. Maybe not. But I think it's a fair assumption to say that Rust code will eventually end up in Bitcoin Core as the result of adding a new dependency. Adoption is happing quickly. So, I think it prudent to look ahead and not only be prepared, but actively help usher it in. Already I have a few things that I would like to work on and upstream to rust-lang to make our integration nicer, and I assume that more will be uncovered as it actually gets used.
Anybody have any fun ideas?