Skip to content

Commit

Permalink
Merge bitcoin#22632: test: Set regtest.BIP66Height = 102 to speed up …
Browse files Browse the repository at this point in the history
…tests

fafe896 test: Set regtest.BIP66Height = 102 to speed up tests (MarcoFalke)

Pull request description:

  No need to waste time by forcing creation of more than 1000 blocks to get the benefits of being able to test BIP 66. Also, reducing the height makes it more likely that (third-party) tests are conforming to BIP 66, which is enforced on mainnet for all new blocks.

ACKs for top commit:
  GeneFerneau:
    Concept + code review ACK [fafe896](bitcoin@fafe896)
  0xB10C:
    crACK fafe896
  laanwj:
    ACK fafe896
  Zero-1729:
    tACK fafe896
  kristapsk:
    ACK fafe896. Full functional test suite showed few second speed incrase on my laptop (although I didn't do proper benchmarking with multiple runs, just single `time ./test/functional/test_runner.py` on current master vs this PR).
  theStack:
    Tested ACK fafe896
  hg333:
    tACK bitcoin@fafe896

Tree-SHA512: 4bbee3c8587d612e74a59fde49b6439c1296f2fc27d3a7cf59a35e920f729fdd581c930290bd04def618f81412236676ddb99b4ceb4d80dfb9fd610b128a04b1
  • Loading branch information
laanwj authored and knst committed Aug 12, 2024
1 parent cbd2be8 commit fc25503
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions doc/release-notes-6189.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Tests
-----

- For the `regtest` network the BIP 66 (DERSIG) activation height was changed
from 1251 to 102. (dash#6189)
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ class CRegTestParams : public CChainParams {
consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
consensus.BIP34Hash = uint256();
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
consensus.BIP66Height = 102; // BIP66 activated on regtest (Block at height 101 and earlier not enforced for testing purposes)
consensus.BIP147Height = 432; // BIP147 activated on regtest (Used in functional tests)
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
consensus.DIP0001Height = 2000;
Expand Down
7 changes: 4 additions & 3 deletions test/functional/feature_dersig.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP66 (DER SIG).
Test that the DERSIG soft-fork activates at (regtest) height 1251.
Test the DERSIG soft-fork activation on regtest.
"""

from test_framework.blocktools import (
DERSIG_HEIGHT,
create_block,
create_coinbase,
)
Expand All @@ -24,8 +25,6 @@
MiniWalletMode,
)

DERSIG_HEIGHT = 1251


# A canonical signature consists of:
# <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
Expand Down Expand Up @@ -88,8 +87,10 @@ def run_test(self):
block.rehash()
block.solve()

assert_equal(self.nodes[0].getblockcount(), DERSIG_HEIGHT - 2)
self.test_dersig_info(is_active=False) # Not active as of current tip and next block does not need to obey rules
peer.send_and_ping(msg_block(block))
assert_equal(self.nodes[0].getblockcount(), DERSIG_HEIGHT - 1)
self.test_dersig_info(is_active=True) # Not active as of current tip, but next block must obey rules
assert_equal(self.nodes[0].getbestblockhash(), block.hash)

Expand Down
3 changes: 2 additions & 1 deletion test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from test_framework.address import ADDRESS_BCRT1_P2SH_OP_TRUE
from test_framework.blocktools import (
DERSIG_HEIGHT,
create_block,
create_coinbase,
TIME_GENESIS_BLOCK,
Expand Down Expand Up @@ -143,7 +144,7 @@ def _test_getblockchaininfo(self):
assert_greater_than(res['size_on_disk'], 0)
assert_equal(res['softforks'], {
'bip34': {'type': 'buried', 'active': False, 'height': 500},
'bip66': {'type': 'buried', 'active': False, 'height': 1251},
'bip66': {'type': 'buried', 'active': True, 'height': DERSIG_HEIGHT},
'bip65': {'type': 'buried', 'active': False, 'height': 1351},
'bip147': { 'type': 'buried', 'active': False, 'height': 432},
'csv': {'type': 'buried', 'active': False, 'height': 432},
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_framework/blocktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
COINBASE_MATURITY = 100

# Soft-fork activation heights
DERSIG_HEIGHT = 102 # BIP 66
CLTV_HEIGHT = 1351
CSV_ACTIVATION_HEIGHT = 432

Expand Down

0 comments on commit fc25503

Please sign in to comment.