mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Merge #7935: Versionbits: GBT support
12c708agetblocktemplate: Use version/force mutation to support pre-BIP9 clients (Luke Dashjr)9879060getblocktemplate: Explicitly handle the distinction between GBT-affecting softforks vs not (Luke Dashjr)72cd6b2qa/rpc-tests: bip9-softforks: Add tests for getblocktemplate versionbits updates (Luke Dashjr)d3df40eImplement BIP 9 GBT changes (Luke Dashjr)
This commit is contained in:
@@ -80,7 +80,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
info = self.nodes[0].getblockchaininfo()
|
||||
return info['bip9_softforks'][key]
|
||||
|
||||
def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignature):
|
||||
def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignature, bitno):
|
||||
# generate some coins for later
|
||||
self.coinbase_blocks = self.nodes[0].generate(2)
|
||||
self.height = 3 # height of the next block to build
|
||||
@@ -89,6 +89,11 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
self.last_block_time = int(time.time())
|
||||
|
||||
assert_equal(self.get_bip9_status(bipName)['status'], 'defined')
|
||||
tmpl = self.nodes[0].getblocktemplate({})
|
||||
assert(bipName not in tmpl['rules'])
|
||||
assert(bipName not in tmpl['vbavailable'])
|
||||
assert_equal(tmpl['vbrequired'], 0)
|
||||
assert_equal(tmpl['version'], 0x20000000)
|
||||
|
||||
# Test 1
|
||||
# Advance from DEFINED to STARTED
|
||||
@@ -96,6 +101,11 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
yield TestInstance(test_blocks, sync_every_block=False)
|
||||
|
||||
assert_equal(self.get_bip9_status(bipName)['status'], 'started')
|
||||
tmpl = self.nodes[0].getblocktemplate({})
|
||||
assert(bipName not in tmpl['rules'])
|
||||
assert_equal(tmpl['vbavailable'][bipName], bitno)
|
||||
assert_equal(tmpl['vbrequired'], 0)
|
||||
assert(tmpl['version'] & activated_version)
|
||||
|
||||
# Test 2
|
||||
# Fail to achieve LOCKED_IN 100 out of 144 signal bit 1
|
||||
@@ -107,6 +117,11 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
yield TestInstance(test_blocks, sync_every_block=False)
|
||||
|
||||
assert_equal(self.get_bip9_status(bipName)['status'], 'started')
|
||||
tmpl = self.nodes[0].getblocktemplate({})
|
||||
assert(bipName not in tmpl['rules'])
|
||||
assert_equal(tmpl['vbavailable'][bipName], bitno)
|
||||
assert_equal(tmpl['vbrequired'], 0)
|
||||
assert(tmpl['version'] & activated_version)
|
||||
|
||||
# Test 3
|
||||
# 108 out of 144 signal bit 1 to achieve LOCKED_IN
|
||||
@@ -118,6 +133,8 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
yield TestInstance(test_blocks, sync_every_block=False)
|
||||
|
||||
assert_equal(self.get_bip9_status(bipName)['status'], 'locked_in')
|
||||
tmpl = self.nodes[0].getblocktemplate({})
|
||||
assert(bipName not in tmpl['rules'])
|
||||
|
||||
# Test 4
|
||||
# 143 more version 536870913 blocks (waiting period-1)
|
||||
@@ -125,6 +142,8 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
yield TestInstance(test_blocks, sync_every_block=False)
|
||||
|
||||
assert_equal(self.get_bip9_status(bipName)['status'], 'locked_in')
|
||||
tmpl = self.nodes[0].getblocktemplate({})
|
||||
assert(bipName not in tmpl['rules'])
|
||||
|
||||
# Test 5
|
||||
# Check that the new rule is enforced
|
||||
@@ -148,6 +167,11 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
yield TestInstance([[block, True]])
|
||||
|
||||
assert_equal(self.get_bip9_status(bipName)['status'], 'active')
|
||||
tmpl = self.nodes[0].getblocktemplate({})
|
||||
assert(bipName in tmpl['rules'])
|
||||
assert(bipName not in tmpl['vbavailable'])
|
||||
assert_equal(tmpl['vbrequired'], 0)
|
||||
assert(not (tmpl['version'] & (1 << bitno)))
|
||||
|
||||
# Test 6
|
||||
# Check that the new sequence lock rules are enforced
|
||||
@@ -183,9 +207,9 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||
|
||||
def get_tests(self):
|
||||
for test in itertools.chain(
|
||||
self.test_BIP('csv', 536870913, self.sequence_lock_invalidate, self.donothing),
|
||||
self.test_BIP('csv', 536870913, self.mtp_invalidate, self.donothing),
|
||||
self.test_BIP('csv', 536870913, self.donothing, self.csv_invalidate)
|
||||
self.test_BIP('csv', 0x20000001, self.sequence_lock_invalidate, self.donothing, 0),
|
||||
self.test_BIP('csv', 0x20000001, self.mtp_invalidate, self.donothing, 0),
|
||||
self.test_BIP('csv', 0x20000001, self.donothing, self.csv_invalidate, 0)
|
||||
):
|
||||
yield test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user