Remove dependency of main on OpenSSL bignum #4076

pull sipa wants to merge 5 commits into bitcoin:master from sipa:uintstuff changing 13 files +473 −508
  1. sipa commented at 1:35 am on April 20, 2014: member

    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.

  2. jgarzik commented at 1:31 pm on April 21, 2014: contributor
    ACK
  3. laanwj commented at 2:17 pm on April 22, 2014: member
    This is great!
  4. sipa commented at 2:44 pm on April 25, 2014: member

    Some benchmarks:

    • operator/ is up to 10 times slower than the CBigNum version (10us vs 0.8us at -O2; 4us at -O3).
    • operator* seems significantly faster (0.08us vs 0.5us), probably due to avoiding allocation overhead.
  5. sipa commented at 11:28 pm on April 25, 2014: member

    Added another commit that removes some duplicated code.

    Also replaced the bits() implementation with a faster one, making division 10% faster.

  6. BitcoinPullTester commented at 11:51 pm on April 25, 2014: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/66d5a5364a2c06a94e650d1184e92cce2b166e2a for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
  7. gmaxwell commented at 8:39 am on April 26, 2014: contributor

    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.)

  8. laanwj commented at 2:19 pm on May 9, 2014: member
    Needs rebase after #3965 and #3884
  9. Deduplicate shared code between uint160 and uint256 eb2cbd754d
  10. Exception instead of assigning 0 in case of wrong vector length 4d480c8a3f
  11. Add multiplication and division to uint160/uint256 a7031507e6
  12. Move {Get,Set}Compact from bignum to uint256 df9eb5e14f
  13. Deduplicate uint* comparison operator logic 397668ea63
  14. laanwj merged this on May 9, 2014
  15. laanwj closed this on May 9, 2014

  16. laanwj referenced this in commit 8bcfccbc2d on May 9, 2014
  17. laanwj referenced this in commit 4def248b2b on May 9, 2014
  18. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me