Page MenuHomePhabricator

D6597.id21439.diff
No OneTemporary

D6597.id21439.diff

diff --git a/src/chainparams.cpp b/src/chainparams.cpp
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -506,13 +506,12 @@
consensus.nSubsidyHalvingInterval = 150;
// always enforce P2SH BIP16 on regtest
consensus.BIP16Height = 0;
- // BIP34 has not activated on regtest (far in the future so block v1 are
- // not rejected in tests)
- consensus.BIP34Height = 100000000;
+ // BIP34 activated on regtest (Used in functional tests)
+ consensus.BIP34Height = 600;
consensus.BIP34Hash = BlockHash();
- // BIP65 activated on regtest (Used in rpc activation tests)
+ // BIP65 activated on regtest (Used in functioanl tests)
consensus.BIP65Height = 1351;
- // BIP66 activated on regtest (Used in rpc activation tests)
+ // BIP66 activated on regtest (Used in functional tests)
consensus.BIP66Height = 1251;
// CSV activated on regtest (Used in rpc activation tests)
consensus.CSVHeight = 576;
diff --git a/test/functional/abc-miner-fund.py b/test/functional/abc-miner-fund.py
--- a/test/functional/abc-miner-fund.py
+++ b/test/functional/abc-miner-fund.py
@@ -199,7 +199,7 @@
block_height = node.getblockcount()
block = create_block(
- fork_block_hash, create_coinbase(block_height), PHONON_ACTIVATION_TIME + 99)
+ fork_block_hash, create_coinbase(block_height), PHONON_ACTIVATION_TIME + 99, version=4)
block.solve()
assert_equal(node.submitblock(ToHex(block)), 'bad-cb-minerfund')
diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py
--- a/test/functional/feature_block.py
+++ b/test/functional/feature_block.py
@@ -1008,7 +1008,7 @@
blocks = []
spend = out[32]
for i in range(89, LARGE_REORG_SIZE + 89):
- b = self.next_block(i, spend)
+ b = self.next_block(i, spend, version=4)
tx = CTransaction()
script_length = LEGACY_MAX_BLOCK_SIZE - len(b.serialize()) - 69
script_output = CScript([b'\x00' * script_length])
@@ -1027,20 +1027,40 @@
self.move_tip(88)
blocks2 = []
for i in range(89, LARGE_REORG_SIZE + 89):
- blocks2.append(self.next_block("alt" + str(i)))
+ blocks2.append(self.next_block("alt" + str(i), version=4))
self.send_blocks(blocks2, False, force_send=True)
# extend alt chain to trigger re-org
- block = self.next_block("alt" + str(chain1_tip + 1))
+ block = self.next_block("alt" + str(chain1_tip + 1), version=4)
self.send_blocks([block], True, timeout=960)
# ... and re-org back to the first chain
self.move_tip(chain1_tip)
- block = self.next_block(chain1_tip + 1)
+ block = self.next_block(chain1_tip + 1, version=4)
self.send_blocks([block], False, force_send=True)
- block = self.next_block(chain1_tip + 2)
+ block = self.next_block(chain1_tip + 2, version=4)
self.send_blocks([block], True, timeout=960)
+ self.log.info("Reject a block with an invalid block header version")
+ b_v1 = self.next_block('b_v1', version=1)
+ self.send_blocks(
+ [b_v1],
+ success=False,
+ force_send=True,
+ reject_reason='bad-version(0x00000001)')
+
+ self.move_tip(chain1_tip + 2)
+ b_cb34 = self.next_block('b_cb34', version=4)
+ b_cb34.vtx[0].vin[0].scriptSig = b_cb34.vtx[0].vin[0].scriptSig[:-1]
+ b_cb34.vtx[0].rehash()
+ b_cb34.hashMerkleRoot = b_cb34.calc_merkle_root()
+ b_cb34.solve()
+ self.send_blocks(
+ [b_cb34],
+ success=False,
+ reject_reason='bad-cb-height',
+ reconnect=True)
+
# Helper methods
################
@@ -1074,7 +1094,7 @@
return tx
def next_block(self, number, spend=None, additional_coinbase_value=0,
- script=CScript([OP_TRUE]), solve=True):
+ script=CScript([OP_TRUE]), solve=True, *, version=1):
if self.tip is None:
base_block_hash = self.genesis_hash
block_time = int(time.time()) + 1
@@ -1087,12 +1107,20 @@
coinbase.vout[0].nValue += additional_coinbase_value
coinbase.rehash()
if spend is None:
- block = create_block(base_block_hash, coinbase, block_time)
+ block = create_block(
+ base_block_hash,
+ coinbase,
+ block_time,
+ version=version)
else:
# all but one satoshi to fees
coinbase.vout[0].nValue += spend.vout[0].nValue - 1
coinbase.rehash()
- block = create_block(base_block_hash, coinbase, block_time)
+ block = create_block(
+ base_block_hash,
+ coinbase,
+ block_time,
+ version=version)
# spend 1 satoshi
tx = self.create_tx(spend, 0, 1, script)
self.sign_tx(tx, spend)
diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py
--- a/test/functional/test_framework/blocktools.py
+++ b/test/functional/test_framework/blocktools.py
@@ -31,9 +31,10 @@
TIME_GENESIS_BLOCK = 1296688602
-def create_block(hashprev, coinbase, ntime=None):
+def create_block(hashprev, coinbase, ntime=None, *, version=1):
"""Create a block (with regtest difficulty)."""
block = CBlock()
+ block.nVersion = version
if ntime is None:
import time
block.nTime = int(time.time() + 600)

File Metadata

Mime Type
text/plain
Expires
Thu, Feb 6, 17:22 (21 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5082771
Default Alt Text
D6597.id21439.diff (5 KB)

Event Timeline