Skip to content
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

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
7 participants
@theuni
Copy link
Member

commented Apr 11, 2019

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?

Jeremy Rubin and others added some commits Mar 29, 2019

Adds a rust library to bitcoin to demonstrate linking and building ru…
…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>
@luke-jr

This comment has been minimized.

Copy link
Member

commented Apr 11, 2019

NACK Rust. There's no reasonable way to bootstrap a Rust compiler without using trusted third party binaries.

@theuni

This comment has been minimized.

Copy link
Member Author

commented Apr 11, 2019

@luke-jr Objection noted.

@MarcoFalke

This comment has been minimized.

Copy link
Member

commented Apr 11, 2019

@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2019

Needs rebase
@theuni

This comment has been minimized.

Copy link
Member Author

commented Apr 11, 2019

@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

@laanwj

This comment has been minimized.

Copy link
Member

commented Apr 12, 2019

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.

@daira

This comment has been minimized.

Copy link
Contributor

commented Apr 12, 2019

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.

@fanquake

This comment has been minimized.

Copy link
Member

commented Apr 12, 2019

Why rust? I don't know. Maybe not.

🚀
I used a brew installed rust & cargo. Worked out of the box. Keen to have a play around.

make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all-am'.

src/bitcoind
Hello World!
2019-04-12T13:10:35Z Bitcoin Core version v0.18.99.0-0bb8b2e99 (release build)

There was some CRust related discussion on IRC here (line 401).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.