Page MenuHomePhabricator

Remove buggy and confusing IncrementExtraNonce
ClosedPublic

Authored by PiRK on Jul 26 2023, 13:29.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC00a6ea72f750: Remove buggy and confusing IncrementExtraNonce
Summary

PR description:

IncrementExtraNonce has many issues:

  • It is test-only code, but part of bitcoind
  • It is using the block height of the tip, as opposed to the block's previous block as reference for the new height.
  • It has no use case in regtest testing. With a low difficulty the extra nonce won't be incremented. With a high difficulty the test-only functions are clumsy to handle anyway. For example, the generate* RPCs will return an empty array once they reached maxtries, as opposed to an error. Also the calls can't be aborted early unless the node shuts down completely. So I think it is fine to just remove the extra nonce functionality and leave it to the outside to implement, if needed. For example, a wrapper script can call the generate* RPCs once every second, to use the timestamp as extra nonce.

Note that core did not need to update m_assumeutxo_data because their TestChain100Setup no longer used IncrementExtraNonce since https://github.com/bitcoin/bitcoin/pull/19775/commits/fad84b7e14ff92465bc17bfdaf1362bcffe092f6 (*test: Activate segwit in TestChain100Setup*)

The changes in feature_utxo_set_hash are not relevant for now as we are still checking the hashes generated from the chain loaded from cache (we are missing the core#21390 ackport).

This is a backport of core#24732

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Jul 26 2023, 13:29

remove commented code (debugging)

PiRK planned changes to this revision.Jul 26 2023, 13:46

I will try to backport core#21390 to include the changes in feature_utxo_set_hash

PiRK requested review of this revision.Jul 26 2023, 15:14
PiRK edited the summary of this revision. (Show Details)

don't backport #21390 for now

Fabien requested changes to this revision.Jul 26 2023, 15:33
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/node/miner.cpp
19 ↗(On Diff #41596)

unrelated ?

src/test/util/setup_common.h
258 ↗(On Diff #41596)

It's better suited for test/util/mining.h

This revision now requires changes to proceed.Jul 26 2023, 15:33
src/node/miner.cpp
19 ↗(On Diff #41596)

It was included for getSubVersionEB which was used in getExcessiveBlockSizeSig

move new function to test/util/mining

This revision is now accepted and ready to land.Jul 26 2023, 19:03