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
crypto: remove use of BUILD_BITCOIN_INTERNAL macro in sha256 #29180
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Ping @TheCharlatan @hebasto I went around in circles several times on this. I think it accomplishes what we need, but please sanity check me :) |
@@ -1012,7 +1012,7 @@ libbitcoinconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_ | |||
|
|||
libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) | |||
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) | |||
libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL | |||
libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL -DDISABLE_OPTIMIZED_SHA256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it needed to keep -DBUILD_BITCOIN_INTERNAL
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this macro is now exclusively used to control exports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated for @fanquake's request: it's now exclusively used to control libbitcoinconsensus exports. libbitcoinkernel will get a new define when the time comes.
2fe00dc
to
dcfb9ee
Compare
Concept ACK. It makes the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the master branch, the following code:
Lines 635 to 640 in dcfb9ee
if (have_sse4) { | |
#if defined(__x86_64__) || defined(__amd64__) | |
Transform = sha256_sse4::Transform; | |
TransformD64 = TransformD64Wrapper<sha256_sse4::Transform>; | |
ret = "sse4(1way)"; | |
#endif |
BUILD_BITCOIN_INTERNAL
macro. Now it is gated with the DISABLE_OPTIMIZED_SHA256
one. Is it intentional?
Re comment #29180 (review)
That code seems to be unused currently if |
Thanks for pointing this out. Yes it was intentional as I believe this is currently wonky in master. Note that libbitcoinconsensus is the only direct user of I'll push another commit to clean that up. It was a bit of an outlier before because it didn't require any special As a bonus, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK 9235801.
Replace it with a more explicit DISABLE_OPTIMIZED_SHA256 and clean up some. The macro was originally used by libbitcoinconsensus which opts out of optimized sha256 for the sake of simplicity. Also remove the BUILD_BITCOIN_INTERNAL define from libbitcoinkernel for now as it does not export an api. When it does we can pick a less confusing define to control its exports. Removing the define should have the effect of enabling sha256 optimizations for the kernel.
9235801
to
86712c3
Compare
Added a brief description of crypto_base. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 86712c3.
It was unused there and a confusing outlier.
86712c3
to
bbf218d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 86712c3
Guix builds (aarch64):
e00ac9d2dbf9d1b6a0255d7c6669ee3925696109cf4ca549dbf411da235f52bc guix-build-86712c313578/output/aarch64-linux-gnu/SHA256SUMS.part
871f7e66c454ac08d4e04f0d86d23e2b34a6c3a6a3b60aabcb9485c086cdad37 guix-build-86712c313578/output/aarch64-linux-gnu/bitcoin-86712c313578-aarch64-linux-gnu-debug.tar.gz
f0553ca6ebaaf5eb8d00196a681a20c21d4b81cb3ec907cce01ac6a446de02e7 guix-build-86712c313578/output/aarch64-linux-gnu/bitcoin-86712c313578-aarch64-linux-gnu.tar.gz
476395fad048ca38b226d3c108b18262127c9c0731afb1c8048ff5e4643039f8 guix-build-86712c313578/output/arm-linux-gnueabihf/SHA256SUMS.part
7de1c5c3685ca1d81a78d4b0a3e62b716e65341bbfdf4a0c56d154889c08ef26 guix-build-86712c313578/output/arm-linux-gnueabihf/bitcoin-86712c313578-arm-linux-gnueabihf-debug.tar.gz
9558f4afa8c466324cfbd046731e0915fc1041aa250d05ecd7bf74a41594b928 guix-build-86712c313578/output/arm-linux-gnueabihf/bitcoin-86712c313578-arm-linux-gnueabihf.tar.gz
f008cb1a5ef888be0a82dcffe6d58bb8379d429448e5c4de1cef208533847b69 guix-build-86712c313578/output/arm64-apple-darwin/SHA256SUMS.part
acd7300c467e06ebfc3b632a61fe2f5b1ad8d35d0181d18107bc24b7a66e0947 guix-build-86712c313578/output/arm64-apple-darwin/bitcoin-86712c313578-arm64-apple-darwin-unsigned.tar.gz
e36e3ff8d05dd6e53b9e2ec60b42e2fa0f14933c571eda8117c93656249590c3 guix-build-86712c313578/output/arm64-apple-darwin/bitcoin-86712c313578-arm64-apple-darwin-unsigned.zip
4a923b366e185a1eb4065c3ae6175bc7459cb15177b6cc036b48b63b94214846 guix-build-86712c313578/output/arm64-apple-darwin/bitcoin-86712c313578-arm64-apple-darwin.tar.gz
0d09788c222ca4d25fb08c504e1b8b472f15b476c22be27470e33dc963e1433b guix-build-86712c313578/output/dist-archive/bitcoin-86712c313578.tar.gz
63ba5f9d412197d0a5ce83ce4eb2627a7fb571199fda97ce393fb66d5537e121 guix-build-86712c313578/output/powerpc64-linux-gnu/SHA256SUMS.part
c9a5dc8214e196d3ae211f0c30ed4ed93b19926eebc9fff35c1eee92011141a1 guix-build-86712c313578/output/powerpc64-linux-gnu/bitcoin-86712c313578-powerpc64-linux-gnu-debug.tar.gz
681549c7fe284c4bc03257ce0030482e95da6514a4e8e4a75bb19381f3994fa6 guix-build-86712c313578/output/powerpc64-linux-gnu/bitcoin-86712c313578-powerpc64-linux-gnu.tar.gz
4b3feaaed2fd14d67e5887a195badfebf8a6593ce7f8a2342e1d2f7a1c68d721 guix-build-86712c313578/output/powerpc64le-linux-gnu/SHA256SUMS.part
7dd7e448ae90b385ad5b2da4159a6e4d26fde5cf08538cc34f40d957c78bc2bb guix-build-86712c313578/output/powerpc64le-linux-gnu/bitcoin-86712c313578-powerpc64le-linux-gnu-debug.tar.gz
c09d3836baca1588e991018b4ae5dcba3cfa7ecf6dfb72f202e0473dcc871e02 guix-build-86712c313578/output/powerpc64le-linux-gnu/bitcoin-86712c313578-powerpc64le-linux-gnu.tar.gz
3f807e417a77cc5be8343f1749df217b8a52ad470d9e3450d92c9e9a33a985b6 guix-build-86712c313578/output/riscv64-linux-gnu/SHA256SUMS.part
795712a2e5360acb9934de561bb5db160087b8457a2835e81f2cdb5020a90daa guix-build-86712c313578/output/riscv64-linux-gnu/bitcoin-86712c313578-riscv64-linux-gnu-debug.tar.gz
f893f98a7adca6ef33acfd12f584993e92b13516f4bd3c80a815b9820b091fb7 guix-build-86712c313578/output/riscv64-linux-gnu/bitcoin-86712c313578-riscv64-linux-gnu.tar.gz
886e2d9c45f175cd03d6fb4c2adf6c4d12a692ee3dca9008d89413e8410ba536 guix-build-86712c313578/output/x86_64-apple-darwin/SHA256SUMS.part
c6db2e2a00823c3498857eb41845dcee1b9785e1957fab3d27e6825a8d1956a6 guix-build-86712c313578/output/x86_64-apple-darwin/bitcoin-86712c313578-x86_64-apple-darwin-unsigned.tar.gz
a8109a1c62f92cd90f1ded5103afd09fefc69399709ca1d876894006075b8bda guix-build-86712c313578/output/x86_64-apple-darwin/bitcoin-86712c313578-x86_64-apple-darwin-unsigned.zip
77d38fb208ebd511af86385601c26c6feb8c33b92339bd6bcc202735502b4770 guix-build-86712c313578/output/x86_64-apple-darwin/bitcoin-86712c313578-x86_64-apple-darwin.tar.gz
fd5cd76982bb97d75a55aa9bac2a576b9381dab09416ee5b30556198c9177ce2 guix-build-86712c313578/output/x86_64-linux-gnu/SHA256SUMS.part
a028a47e0c75df4c392c140c5116ad1a2173db1e1b050eab195a9464e6162714 guix-build-86712c313578/output/x86_64-linux-gnu/bitcoin-86712c313578-x86_64-linux-gnu-debug.tar.gz
c5319b1b2d9d20838e0e7c7ff6682e549fd6c5b64f0ead7a51ca8db1433f6632 guix-build-86712c313578/output/x86_64-linux-gnu/bitcoin-86712c313578-x86_64-linux-gnu.tar.gz
2810be230ef3a97a7d9b7564790a96ab1a849bec6459cc8a06b3793d875ecd29 guix-build-86712c313578/output/x86_64-w64-mingw32/SHA256SUMS.part
b6fc5f7482500c121475c4dc34a2e599bf9391d6c0617f06dd96bfb20175768c guix-build-86712c313578/output/x86_64-w64-mingw32/bitcoin-86712c313578-win64-debug.zip
19469f9da899670700788e38beccd8a675a2c44e30cbc91595ac684ff69e10b8 guix-build-86712c313578/output/x86_64-w64-mingw32/bitcoin-86712c313578-win64-setup-unsigned.exe
ee1c879b3f28628443109c9b255fd300480659044a34f3db6d5c72bbaa659061 guix-build-86712c313578/output/x86_64-w64-mingw32/bitcoin-86712c313578-win64-unsigned.tar.gz
e5e0c780627a54f6bee3877ceae1e60cc62af9a96dd337cd0707b34e790447e2 guix-build-86712c313578/output/x86_64-w64-mingw32/bitcoin-86712c313578-win64.zip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-ACK bbf218d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK bbf218d
I've reviewed the changes and they appear correct to me. libbitcoinconsensus will continue to not get SSE4 ASM (nor any other optimisations) and libbitcoinkernel (external?) will now get all of them (if available and enabled by ./configure). I think If I've read it correctly, the Is there any mileage in extending this to do the following? :
Apologies if this is a bit out of scope for this PR. I'm also new to this code so may not have read things correctly. |
25dc87e libconsensus: deprecate (Cory Fields) Pull request description: This library has existed for nearly 10 years with very little known uptake or impact. It has become a maintenance burden. In several cases it dictates our code/library structure (for example necessitating LIBBITCOIN_CRYPTO_BASE), as well as build-system procedures (building multiple copies of object files especially for the lib). Several discussions have arisen wrt migrating it to CMake and it has become difficult to justify adding more complexity for a library that is virtually unused anyway. See for example the discussions: hebasto#41 #29123 And here: #29180 Where it is pointed out that the libbitcoinconsensus functions are slower than those the internal bitcoind equivalents due to the missing sha2 implementations. Instead, we (fanquake, hebasto, TheCharlatan, and I) propose simply not migrating it to CMake and letting it end with v27. Any remaining use-cases could be handled in the future by libbitcoinkernel. If there are any users currently using libbitcoinconsensus, please chime in with your use-case! Edit: Corrected final release to be v27. ACKs for top commit: TheCharlatan: ACK 25dc87e fanquake: ACK 25dc87e - this library has very little, if any impactful real world usage. It has been entirely broken (on various platforms) for long periods of its existence, where nobody even noticed. Pruning this out to save porting, and starting anew with the kernel, is the sane thing to do. Tree-SHA512: baff2b3c4f76f520c96021035f751fdcb51bedf00e767660249e92a7bc7c5c176786bcf2c4cfe2d2351c200f932b39eb886bcfb22fbec824a41617590d6a1638
Replace it with a more explicit
DISABLE_OPTIMIZED_SHA256
and clean up some.The macro was originally used by libbitcoinconsensus which opts out of optimized sha256 for the sake of simplicity.
Also remove the
BUILD_BITCOIN_INTERNAL
define from libbitcoinkernel for now as it does not export an api. When it does we can pick a less confusing define to control its exports.Removing the define should have the effect of enabling sha256 optimizations for the kernel.