Use a uint256 for bnChainWork #2418

pull sipa wants to merge 1 commits into bitcoin:master from sipa:uintwork changing 5 files +48 −36
  1. sipa commented at 11:02 PM on March 28, 2013: member

    Every block index entry currently requires a separately-allocated CBigNum. By replacing them with uint256, it's just 32 bytes extra in CBlockIndex itself.

    This should save us a few megabytes in RAM (around 32 bytes per block), and less allocation overhead.

  2. laanwj commented at 6:35 AM on March 30, 2013: member

    Are these numbers always guaranteed to fit in a uint256?

    A more general solution may be to change CBigNum to store numbers <2^256 inline, and only allocate for larger ones, like with some optimized string implementations.

  3. TheBlueMatt commented at 7:07 AM on March 30, 2013: member

    Our current work (printed as a uint256 with this patch) is 00000000000000000000000000000000000000000000003256b810087da1a920, assuming every 600MH card on the network is replaced with a 60GH ASIC and then we multiply that by 1000 for network growth, we get a network rate of 100,000x current, we are safe for another 92 septillion*time since genesis, so...I think we are safe.

  4. TheBlueMatt commented at 7:08 AM on March 30, 2013: member

    ACK

  5. laanwj commented at 12:50 PM on March 30, 2013: member

    ok, ACK

  6. sipa commented at 4:48 PM on March 30, 2013: member

    When 2^256 hashes are exceeded, it's quite likely we'll have found a preimage for double-SHA256, and Bitcoin is broken in the first place.

  7. sipa commented at 4:50 PM on March 30, 2013: member

    @BitcoinPullTester @TheBlueMatt I believe this will require a different pulltest, as I presume it tries to modify the global BigNums.

  8. TheBlueMatt commented at 6:06 PM on March 30, 2013: member

    Yea, this tries to modify the mindiff stuff so breaks on this pull. Ignore pulltester output for now and ping me before merge so I can update the patch.

  9. sipa commented at 1:11 PM on April 4, 2013: member

    Rebased.

  10. sipa commented at 1:21 AM on April 7, 2013: member

    Added a commit that prints the 2-log of nChainWork instead, which is somewhat more useful for human eyes.

  11. gmaxwell commented at 7:00 PM on April 8, 2013: contributor

    ACK. (Needs pulltester)

  12. sipa commented at 6:22 PM on April 9, 2013: member

    Rebased. This will need manual pulltester changes before it will succeed.

  13. Use a uint256 for bnChainWork
    Every block index entry currently requires a separately-allocated
    CBigNum. By replacing them with uint256, it's just 32 bytes extra
    in CBlockIndex itself.
    
    This should save us a few megabytes in RAM, and less allocation
    overhead.
    1657c4bc49
  14. sipa commented at 10:19 AM on April 12, 2013: member

    @TheBlueMatt I've added a patch to your patch in this pullreq. If you update pulltester to use the tests in contrib, this should apply cleanly.

  15. sipa closed this on Apr 12, 2013

  16. sipa reopened this on Apr 12, 2013

  17. BitcoinPullTester commented at 5:18 PM on April 12, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/1657c4bc495815febc2137972c3c63b99d2b0189 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.

  18. gavinandresen referenced this in commit 1b4b463c01 on Apr 12, 2013
  19. gavinandresen merged this on Apr 12, 2013
  20. gavinandresen closed this on Apr 12, 2013

  21. sipa deleted the branch on May 3, 2013
  22. laudney referenced this in commit 633486f6dc on Mar 19, 2014
  23. rebroad commented at 10:26 AM on June 25, 2015: contributor

    Would it be of any use to display a delta work (work since the last block) instead?

  24. sipa commented at 11:13 AM on June 25, 2015: member

    The work since last block is also called "difficulty".

  25. rebroad commented at 10:34 PM on June 25, 2015: contributor

    Doesn't seem like a very useful thing to display on every UpdateTip message.. Why not just output one debug line when the difficulty changes, and remove log2_work= altogether from the UpdateTip debug message?

  26. 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: 2026-04-19 09:15 UTC

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