-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Remove dependency of main on OpenSSL bignum #4076
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
Conversation
|
ACK |
|
This is great! |
|
Some benchmarks:
|
|
Added another commit that removes some duplicated code. Also replaced the bits() implementation with a faster one, making division 10% faster. |
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/66d5a5364a2c06a94e650d1184e92cce2b166e2a for binaries and test log. |
|
ACK. (reviewed the code, tested a mainnet and a testnet resync, and added some errors and checked that they were caught— I do note that triggering divide by zero in— say— block validation results in the exception being caught which surprised me momentarily). The division can be made another 10% faster by using CLZ instead of the inner loop, but further optimizations do not need to happen now. (We call the divide in GetBlockWork, which we do for every block, and it appears to make a difference in the very early sync for me; though I consider these measurements somewhat suspect.) |
397668e Deduplicate uint* comparison operator logic (Pieter Wuille) df9eb5e Move {Get,Set}Compact from bignum to uint256 (Pieter Wuille) a703150 Add multiplication and division to uint160/uint256 (Pieter Wuille) 4d480c8 Exception instead of assigning 0 in case of wrong vector length (Pieter Wuille) eb2cbd7 Deduplicate shared code between uint160 and uint256 (Pieter Wuille)
After bitcoin#4076, bitcoin#3965 and bitcoin#4048 bignum.h is only used for verifying scriptnum.
This patch moves/implements all logic (multiplication, division, GetCompact, SetCompact) that main used from CBigNum to base_uint or uint256, and replaces its call sites by equivalent uint256 operations.
The division and multiplication operations are very straightforward, but not very efficient. None of their call sites require that, though.
Together with #3965 and #4048, this will allow up to drop bignum.h entirely.