romanz / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
1.05k stars 391 forks source link

Deterministic builds #290

Open Kixunil opened 4 years ago

Kixunil commented 4 years ago

It'd be great to have electrs buildable deterministically. I looked at it a bit as a part of my effort to deterministically build all packages and it looks like the main source of non-determinism is (unsurprisingly) in the rocksdb code.

Not sure how to fix it, but one idea I had is linking rocksdb dynamically and relying on system rocksdb to be valid. This can work for systems that have the library packaged but unfortunately it's not general. Still may be a good place to start with. The bad news is I didn't manage to compile electrs with dynamic linking yet. The library needs patching and electrs too.

Regarding codegen, configure_me is fine, it uses HashMap at one place which isn't used by electrs. (It happens to be used by lnp/bp, so @dr-orlovsky LMK if/when you need deterministic builds to fix it for you.) serde appears to be deterministic too.

Kixunil commented 3 years ago

Update: the idea of linking with system rocksdb worked and it's documented. :tada:

Anyone wants to build electrs against Debian stable and publish the signature? I can post a script or a Debian source package to make it simpler. I will publish signature for individual file for convenience if anyone joins.

@romanz @shesek @sentree you reacted with thumbs up, perhaps you could join?

Kixunil commented 3 years ago
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I herby declare that compiling electrs 0.8.8 on Debian 10 amd64 produced binary
with sha256sum = 88a320c42f1a372e0b3fa4681bc65425159df421f5530710ab9552e3842908f9
Using dynamic linking with system rocksdb (361951ae6d0700bf6b47ef543203628d0202dc2817baf4102019baf63aa33010)
Rustc 1.41.1 (6e2ff14e0422484a60cffedf71fbec894323765ba3ebd633296a45009046d68c)
Cargo 1.42.0 (f6fc45657b8bdfcbf1c4d0fecab182c5293902fca09aa604a8d60021dac3e3d0)

Sha256sums of libraries:
33d1a9e01d16b74354e6be8546cf3d11dd4d773417c15c1e601a934fce1ad1e9  /usr/lib/x86_64-linux-gnu/librustc_driver-d678deced8a70d91.so
40697396d99881210e98e93f1b04e7e725427046e4593e3513fadce14fcec4fb  /usr/lib/x86_64-linux-gnu/librustc_macros-9b225b85ad29ef14.so
d3a2e800cc895a7150d8516369183c167587b459b91f4548b759aafe3d4b579e  /usr/lib/x86_64-linux-gnu/libstd-2b8ce385717c133f.so
ad13d36254ee2c9f8b58979b5d8f0dd83a97909d3cc9fd11d393e2060d0a670a  /usr/lib/x86_64-linux-gnu/libtest-850b337de7e4b0f8.so
ed59c179f0194421e75b59b6799888452dc424779eeba76145a0665637e55da1  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-e28446567bdd0cc8.rlib
6ee74a69080853b9f30aa8d86fc6199c3640d9076f2ddeab187bbac70a0096a9  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace-8ed76b3ed1b96667.rlib
1f532857c463402d1aa6999405dd455bc603959558caea22faeb64a2b3cb9cd2  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-2b9293c7b8f41cd3.rlib
66b2f55699d7c9ebbeaac6635d833e1a67b0f65884581027fc7560022e922f83  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-1c0cf4a4fbb9635d.rlib
0588d5f06d78f9d2012ff64fe550ca05447a98f20be964dcf569c3b1464c158c  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-a5f50861fed71e63.rlib
20fd83d4a0201e81342b65b3749e4c7c031f1978c5bb843ab7bfe976744e5249  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-ef8dee7216df56b3.rlib
935ee4321dd9aa466519961e707de8717d6296642ce689e369a51409ed8d9e3a  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-bbd87b5cc385b09d.rlib
17946da8c3f38e4de4dfee9a1e558b3b18165703256be209361a72704d2ba045  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-7519d6bf50917898.rlib
f53964410d957674c152a8ca8e7f5cb760aaa3e3559644a60dc95b054fb78e4f  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-efaf138ef5c1d0b8.rlib
5d885c8cb493922c642e8ca9ba73bd15696b6b4ec330d6f129e0201eecff2145  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_abort-86ab80814e18e083.rlib
d99897fe29a3ecae307679fa807eaead8ac9d4399c1c652c63a680fdff070c4b  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-bfdb904b514c26fa.rlib
a1cba378d2e113192e3d83656192e05fe8efe5180aa6ab9172bf3dc170486f32  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-94b3637a48fb7f00.rlib
a62c66a9cd7fa877f4bb569a392e6f938aa969ed354d10a9f949cc02b9ab6a2b  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_asan-eeef63de9a1addcd.rlib
2ba7f299a97c90ca52abee83433512a47615df44e885801289b63bea4027fb0a  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-854234105dc1a978.rlib
7bab93b1773fee21615342754e77d25fd7885756ebf36c6ac10b163fdbcf01fe  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_lsan-20fe7473dd5d6a8b.rlib
0fcbbcc5dc9248977021217b8b368498ed57f94cb6335390826681f0a4da5f0b  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_msan-d5cebc2b43f62aaf.rlib
a092c7e0ee38cc2e827676b7b0af66a77e6e611e454ae01f4e809bedd0f49b89  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-16e1de1aad2c3dfc.rlib
f2282017bf17c7bc6cd294a8850d03d2ae71c40914dc682145d6b31babc46c6f  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-7d724940c36772e7.rlib
1b54e182c9dcf0f6760bc53d8a3ab86d53180c1c234101faf802618c174cc773  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-5b45107480fa06f8.rlib
9024e563b85d2ce6c18d6124ad6524db70fba33cace16720590043bc1ad0878f  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_tsan-24ca9514e228809e.rlib
b54c8ebcafa1e063c711db0a672bb686d035b5522a2ecf7756a38b9eb2c526c3  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-2b8ce385717c133f.rlib
704483dff0bf60e241eefebee4c348d718c95cedb7991681422f1f574ba3d3e7  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm-412ce191429410c2.rlib
e339deddc82dff2d436812a17d1ffff361e4777083eca5f71dd230fd7f32316a  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-850b337de7e4b0f8.rlib
49e22e3a66d3a937b99d86b87346749767c37baf5d06e606accff10ef8d358cf  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-83cc36a5c1a62c36.rlib
98d0154d020610f6805413d3a420c74e25c7267c023a93d6b67bd751a4df3bba  /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-a6a6d047de166dab.rlib
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEPZ6B08p2zcvnaMS03GtPjmC4z0wFAmA6HY8ACgkQ3GtPjmC4
z0xYGg//a1W/E+zNx3Ib4LBsWdxz80sMrSO7+FVScsgokURMbvKx4oFyMfN7FE6N
KyjP6khqfjEi8Yx8VqN1KB/YLYGD6vqRBBBn1IrD/Fg7v+BknGx0Il2k/Nv41D7l
ZdpTo8u21f0wNu5HjHovmD6t7kusfcB9Ni1KkMkYH8LD7tBtbGg1C+nD/s+0kJQk
29MSFzS5+GwyokN1ft+SfeiFpf5pnlsZvFAVSe9KvSwUg1kFFtDrCyX+iqkoM5dQ
XXzwXoQDZbISjVmZ5YwGIeW5ZYmCn50ttr4U51+JRx7m100DeHmYCdL/QR3/T5Yy
My+HNKLHnZ7sJJMUbcITi6b8NDvb89jYnwjC6ORKgjYDFsWOoYtvJakib7AbHmsQ
BfROZdw2DDs9MFVejlnbry0rOzXDMd3Ipk7SoMmCmqg2i989gZeOf5iPhWyOTof0
ZdhhzQamOj6t7iP4ymtZ0Giw/dpjC5rM6cTk4nP2dveU0k7ZIZDd8SWFyBTX+mxz
mqmQxyBISEXpwZmDk0FmVGVeAzGFOSP41u7K6bplIQiIMhM4Ki09FjS/QoTZhevS
qDBG9YzEDWZJbl2/ooK8JNGh8bRpZGWmR2ZUVUzZsUKeZyaoo4h9j6bfaT4Z+s5R
XOy5LLUzbF0AitacCantkcl+HhxbiSxjkHuhv/JQKA8F0TCvGdc=
=ryZR
-----END PGP SIGNATURE-----