mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
HF: Publish full dynafed block no matter epoch age
This commit is contained in:
parent
1d7847305c
commit
7b15b4802c
2 changed files with 13 additions and 11 deletions
|
|
@ -91,12 +91,13 @@ DynaFedParamEntry ComputeNextBlockCurrentParameters(const CBlockIndex* pindexPre
|
|||
const uint32_t epoch_length = consensus.dynamic_epoch_length;
|
||||
uint32_t epoch_age = next_height % epoch_length;
|
||||
|
||||
// Return appropriate format based on epoch age
|
||||
if (epoch_age > 0) {
|
||||
// TODO implement "prune" function to remove fields in place and change serialize type
|
||||
return DynaFedParamEntry(entry.m_signblockscript, entry.m_signblock_witness_limit, entry.CalculateExtraRoot());
|
||||
} else {
|
||||
// Return appropriate format based on epoch age or if we *just* activated
|
||||
// dynafed via BIP9
|
||||
if (epoch_age == 0 || pindexPrev->dynafed_params.IsNull()) {
|
||||
return entry;
|
||||
} else {
|
||||
return DynaFedParamEntry(entry.m_signblockscript, entry.m_signblock_witness_limit, entry.CalculateExtraRoot());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def go_to_epoch_end(node):
|
|||
blocks_to_mine = epoch_info["epoch_length"] - epoch_info["epoch_age"] - 1
|
||||
node.generatetoaddress(blocks_to_mine, node.getnewaddress())
|
||||
|
||||
def validate_no_vote_op_true(node, block):
|
||||
def validate_no_vote_op_true(node, block, first_dynafed_active_block):
|
||||
|
||||
block_info = node.getblock(block)
|
||||
dynamic_parameters = block_info["dynamic_parameters"]
|
||||
|
|
@ -44,7 +44,7 @@ def validate_no_vote_op_true(node, block):
|
|||
# signblockscript is now the P2WSH-ification of OP_TRUE
|
||||
WSH_OP_TRUE = node.decodescript("51")["segwit"]["hex"]
|
||||
assert_equal(dynamic_parameters["current"]["signblockscript"], WSH_OP_TRUE)
|
||||
if block_height % 10 == 0:
|
||||
if block_height % 10 == 0 or first_dynafed_active_block:
|
||||
assert_equal(dynamic_parameters["current"]["fedpegscript"], "51")
|
||||
assert_equal(dynamic_parameters["current"]["extension_space"], initial_extension)
|
||||
else:
|
||||
|
|
@ -118,8 +118,9 @@ class DynaFedTest(BitcoinTestFramework):
|
|||
# Next block is first dynamic federation block
|
||||
block = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())[0]
|
||||
self.sync_all()
|
||||
# We publish full block on BIP9 transition
|
||||
for i in range(self.num_nodes):
|
||||
validate_no_vote_op_true(self.nodes[i], block)
|
||||
validate_no_vote_op_true(self.nodes[i], block, True)
|
||||
|
||||
def test_illegal_proposals(self):
|
||||
|
||||
|
|
@ -148,14 +149,14 @@ class DynaFedTest(BitcoinTestFramework):
|
|||
|
||||
for i in range(self.num_nodes):
|
||||
for block in blocks:
|
||||
validate_no_vote_op_true(self.nodes[i], block)
|
||||
validate_no_vote_op_true(self.nodes[i], block, False)
|
||||
|
||||
# Now transition using vanilla getnewblockhex, nothing changed
|
||||
block = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())[0]
|
||||
self.sync_all()
|
||||
|
||||
for i in range(self.num_nodes):
|
||||
validate_no_vote_op_true(self.nodes[i], block)
|
||||
validate_no_vote_op_true(self.nodes[i], block, False)
|
||||
|
||||
def test_under_vote(self):
|
||||
self.log.info("Testing failed voting epoch...")
|
||||
|
|
@ -176,7 +177,7 @@ class DynaFedTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
for i in range(self.num_nodes):
|
||||
validate_no_vote_op_true(self.nodes[i], block)
|
||||
validate_no_vote_op_true(self.nodes[i], block, False)
|
||||
|
||||
def test_four_fifth_vote(self):
|
||||
self.log.info("Testing just-successful transition epoch...")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue