Skip to content

Commit

Permalink
HF: Publish full dynafed block no matter epoch age
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Nov 12, 2019
1 parent aec8b6c commit 3751e14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/dynafed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

}
}

13 changes: 7 additions & 6 deletions test/functional/feature_dynafed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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:
Expand Down Expand Up @@ -118,8 +118,9 @@ def test_dynafed_activation(self):
# 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):

Expand Down Expand Up @@ -148,14 +149,14 @@ def test_no_vote(self):

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...")
Expand All @@ -176,7 +177,7 @@ def test_under_vote(self):
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...")
Expand Down

0 comments on commit 3751e14

Please sign in to comment.