-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Set BIP34Height = 2 for regtest #16333
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
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
Fails with |
This didn't quite make sense to me, but I think it works. I think the two behaviours that warrant testing are:
I think this adds a test for the second case (with X completely unspent), but not the first? (And duplicates are at block 120 not block 3) |
31e927a
to
da2d9b2
Compare
c3de476
to
48ed8fd
Compare
Based on the comments in #14633 our implementation doesn't match BIP34 for blocks at heights lower than 17 (since we do If so, could be worth adding Alternatively, seems like BIP34 probably should be updated to at least note the divergence to the original specification for bitcoind's regtest (and potentially signet or "tapnet" or similar, which might actually require interoperability with other clients). (Edited to add: ACK once the above is dealt with one way or another, fwiw) |
fa8489a test: Add test for BIP30 duplicate tx (MarcoFalke) 77770d9 test: Properly serialize BIP34 coinbase height (MarcoFalke) Pull request description: This adds a test for BIP30 to check that duplicate txs can exist in the blockchain given the first one was completely spent when the second one is added. (Requested by ajtowns in bitcoin#16333 (comment)) We can not add a test that a later duplicate tx overwrites a previous one, because BIP30 is always enforced on regtest. If someone feels strongly about such a test, some Bitcoin Core code would have to be modified, which can be done in a follow up pull request. Also, add a commit to fix the BIP34 test failures reported in bitcoin#14633 (comment) ACKs for top commit: laanwj: Code review ACK fa8489a Tree-SHA512: c707d0bdc93937263876b603425b53322a2a9f9ec3f50716ae2fa9de8ddc644beb22b26c1bfde7f4aab102633e096b354ef380db919176bd2cb44a2828f884aa
Adding this assert would break existing test networks such as
So I will keep this pull request as-is for now. |
faf345f
to
fa573fd
Compare
fa8489a test: Add test for BIP30 duplicate tx (MarcoFalke) 77770d9 test: Properly serialize BIP34 coinbase height (MarcoFalke) Pull request description: This adds a test for BIP30 to check that duplicate txs can exist in the blockchain given the first one was completely spent when the second one is added. (Requested by ajtowns in bitcoin#16333 (comment)) We can not add a test that a later duplicate tx overwrites a previous one, because BIP30 is always enforced on regtest. If someone feels strongly about such a test, some Bitcoin Core code would have to be modified, which can be done in a follow up pull request. Also, add a commit to fix the BIP34 test failures reported in bitcoin#14633 (comment) ACKs for top commit: laanwj: Code review ACK fa8489a Tree-SHA512: c707d0bdc93937263876b603425b53322a2a9f9ec3f50716ae2fa9de8ddc644beb22b26c1bfde7f4aab102633e096b354ef380db919176bd2cb44a2828f884aa
fa7284c
to
faf0aac
Compare
Concept ACK |
Huh, the second commit changes nothing other than that the tests mine version 4 blocks instead of version 1 blocks. If version 1 blocks were accepted, then version 4 blocks are accepted as well under our current consensus rules. So the second commit should pass. And I am pretty sure I did check that it passed. |
fa82ab5
to
fa1cd7d
Compare
Concept ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -615,7 +615,7 @@ def __init__(self, header=None): | |||
self.calc_sha256() | |||
|
|||
def set_null(self): | |||
self.nVersion = 1 | |||
self.nVersion = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fac90c5 it seems that using from test_framework.blocktools import VERSIONBITS_LAST_OLD_BLOCK_VERSION
in messages.py
would be a circular import, but perhaps
self.nVersion = 4 | |
self.nVersion = 4 # VERSIONBITS_LAST_OLD_BLOCK_VERSION in test_framework.blocktools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might do if I have to re-touch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- test: Create all blocks with version 4 or higher:
Now that BIP34 is activated earlier, we need to create blocks with a higher version number from where it activated. Just bump it up to at least 4.
This confused me a little. The block version required after BIP34 activation is fixed and hard-coded to >= 2, I don't think it depends on anything related to what version was used prior the activation (maybe I misunderstood your explanation though?):
Line 3159 in 6499928
if ((block.nVersion < 2 && DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_HEIGHTINCB)) || |
All tests still pass with nVersion=2 instead of 4 in the first commit. That said, bumping already to 4 for future similar PRs to activate soft-forks in regtest earlier can't hurt. Will code-review tomorrow, just wanted to get sure that I understand the motivation for choosing 4 in the first commit.
Edited OP comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajtowns Mind to re-ACK/NACK based on your
? |
ACK 222290f Still seems sad this isn't documented accurately outside the source, but bip34's final and a new bip just for the first ~16 blocks on signet or regtest seems weak too. |
…ck` parameters e57c0eb test: refactor: replace OP_1/OP_TRUE magic numbers by constants (Sebastian Falbesoner) df5d783 test: refactor: take use of `create_block` txlist parameter (Sebastian Falbesoner) ae9df4e test: refactor: take use of `create_block` version parameter (or use default) (Sebastian Falbesoner) Pull request description: The helper `create_block` offers two parameters `version` and `txlist` which set the `nVersion` field / extend the `vtx` array of the block, respectively. By taking use of those, we can remove a lot of code, including the recalculation of the merkle root. Both passing txs in string and `CTransaction` format is supported, i.e. we also save potential calls to `tx_from_hex`. The PR also contains another commit which replaces magic numbers for OP_TRUE/OP_1 (0x51) with the proper constant from the `script` module. Instances setting the block version of 4 explicitely after calling `create_block` are removed, as this is the default since #16333 got merged (see #23521 (comment)). ACKs for top commit: stratospher: tested ACK e57c0eb. Tree-SHA512: a56965168d36b40b84e7f334b00472b82c31e8482c9e2651c97a791abd7fee3b40ca15e943a7acafa3acf172066fdace38bb13240084b789fd6ff4f6e510e23a
fa8489a test: Add test for BIP30 duplicate tx (MarcoFalke) 77770d9 test: Properly serialize BIP34 coinbase height (MarcoFalke) Pull request description: This adds a test for BIP30 to check that duplicate txs can exist in the blockchain given the first one was completely spent when the second one is added. (Requested by ajtowns in bitcoin#16333 (comment)) We can not add a test that a later duplicate tx overwrites a previous one, because BIP30 is always enforced on regtest. If someone feels strongly about such a test, some Bitcoin Core code would have to be modified, which can be done in a follow up pull request. Also, add a commit to fix the BIP34 test failures reported in bitcoin#14633 (comment) ACKs for top commit: laanwj: Code review ACK fa8489a Tree-SHA512: c707d0bdc93937263876b603425b53322a2a9f9ec3f50716ae2fa9de8ddc644beb22b26c1bfde7f4aab102633e096b354ef380db919176bd2cb44a2828f884aa
fa8489a test: Add test for BIP30 duplicate tx (MarcoFalke) 77770d9 test: Properly serialize BIP34 coinbase height (MarcoFalke) Pull request description: This adds a test for BIP30 to check that duplicate txs can exist in the blockchain given the first one was completely spent when the second one is added. (Requested by ajtowns in bitcoin#16333 (comment)) We can not add a test that a later duplicate tx overwrites a previous one, because BIP30 is always enforced on regtest. If someone feels strongly about such a test, some Bitcoin Core code would have to be modified, which can be done in a follow up pull request. Also, add a commit to fix the BIP34 test failures reported in bitcoin#14633 (comment) ACKs for top commit: laanwj: Code review ACK fa8489a Tree-SHA512: c707d0bdc93937263876b603425b53322a2a9f9ec3f50716ae2fa9de8ddc644beb22b26c1bfde7f4aab102633e096b354ef380db919176bd2cb44a2828f884aa
fa8489a test: Add test for BIP30 duplicate tx (MarcoFalke) 77770d9 test: Properly serialize BIP34 coinbase height (MarcoFalke) Pull request description: This adds a test for BIP30 to check that duplicate txs can exist in the blockchain given the first one was completely spent when the second one is added. (Requested by ajtowns in bitcoin#16333 (comment)) We can not add a test that a later duplicate tx overwrites a previous one, because BIP30 is always enforced on regtest. If someone feels strongly about such a test, some Bitcoin Core code would have to be modified, which can be done in a follow up pull request. Also, add a commit to fix the BIP34 test failures reported in bitcoin#14633 (comment) ACKs for top commit: laanwj: Code review ACK fa8489a Tree-SHA512: c707d0bdc93937263876b603425b53322a2a9f9ec3f50716ae2fa9de8ddc644beb22b26c1bfde7f4aab102633e096b354ef380db919176bd2cb44a2828f884aa
BIP34 is active on the current tip of mainnet, so all miners must obey it. It would be nice if it also was active in fresh regtest instances from the earliest time possible.
I changed the BIP34 height to
2
, so that the block at height=1 may be used to mine a duplicate coinbase. (Needed to test mainnet behaviour)This pull is done in two commits:
test: Create all blocks with version 4 or higher:
Now that BIP34 is activated earlier, we need to create blocks with a higher version number. Just bump it to 4 instead of 2 to avoid having to bump it again later.
test: Set BIP34Height = 2 for regtest:
This fixes the BIP34 implementation in the tests (to match the one of the Core codebase) and updates the tests where needed