Skip to content
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

Remove buggy and confusing IncrementExtraNonce #24732

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Apr 1, 2022

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. See Race in generatetoaddress? #24730 (comment)
  • 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.

@laanwj
Copy link
Member

laanwj commented Apr 1, 2022

Concept ACK, nice cleanup.

@ajtowns
Copy link
Contributor

ajtowns commented Apr 1, 2022

Concept ACK

1 similar comment
@theStack
Copy link
Contributor

theStack commented Apr 1, 2022

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 1, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24629 (Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block by luke-jr)
  • #24202 (rpc: allow dumptxoutset to dump human-readable data by w0xlt)
  • #21726 (Improve Indices on pruned nodes via prune blockers by fjahr)
  • #18933 (rpc: Add submit option to generateblock by MarcoFalke)

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.

@laanwj
Copy link
Member

laanwj commented Apr 4, 2022

Code review ACK fa38b1c

Copy link
Contributor

@ajtowns ajtowns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa38b1c

src/rpc/mining.cpp Outdated Show resolved Hide resolved
@maflcko
Copy link
Member Author

maflcko commented Apr 5, 2022

Removed more code

@ajtowns
Copy link
Contributor

ajtowns commented Apr 6, 2022

ACK cccc4e8

@fanquake fanquake requested a review from laanwj April 6, 2022 09:13
@maflcko maflcko merged commit 79bf1a0 into bitcoin:master Apr 6, 2022
@maflcko maflcko deleted the 2204-remove-code-🌗 branch April 6, 2022 09:16
@Sjors
Copy link
Member

Sjors commented Aug 6, 2022

The RPC should probably throw an error if maxtries >= 2^32.

@maflcko
Copy link
Member Author

maflcko commented Aug 6, 2022

Yeah, and also when max_tries==0, as explained in the pull request description

bitcoinhodler added a commit to bitcoinhodler/GlacierProtocol that referenced this pull request Oct 27, 2022
bitcoin/bitcoin#24732 changes how new blocks
are mined in regtest, which changes all the txids for our regtest
transactions.

I ran:

    t/online_regtest_wallet.py recreate-all-tests

All of these tests are failing now because the golden no longer
matches, which I will update next, but I first wanted to commit the
automated step here separately.

t/create-withdrawal-data.address-needs-correction.run required
hand-editing because the input transaction appears twice.
bitcoinhodler added a commit to bitcoinhodler/GlacierProtocol that referenced this pull request Oct 27, 2022
Created by running `make remake`.

All tests passing again on bitcoin built from
79bf1a0fa2c72911bb964f7303dd3acee3db584f (just after
bitcoin/bitcoin#24732 was merged).
bitcoinhodler added a commit to bitcoinhodler/GlacierProtocol that referenced this pull request Oct 28, 2022
bitcoin/bitcoin#24732 changes the coinbase
output of new blocks in regtest, which changes all the txids for our
regtest transactions.

I ran:

    t/online_regtest_wallet.py recreate-all-tests
    make remake

t/create-withdrawal-data.address-needs-correction.run required
hand-editing because the input transaction appears twice.
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 27, 2023
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 bitcoin/bitcoin@fad84b7 (*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 [[bitcoin/bitcoin#24732 | core#24732]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14312
@bitcoin bitcoin locked and limited conversation to collaborators Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants