Skip to content

Commit 7b15b48

Browse files
committed
HF: Publish full dynafed block no matter epoch age
1 parent 1d78473 commit 7b15b48

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/dynafed.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ DynaFedParamEntry ComputeNextBlockCurrentParameters(const CBlockIndex* pindexPre
9191
const uint32_t epoch_length = consensus.dynamic_epoch_length;
9292
uint32_t epoch_age = next_height % epoch_length;
9393

94-
// Return appropriate format based on epoch age
95-
if (epoch_age > 0) {
96-
// TODO implement "prune" function to remove fields in place and change serialize type
97-
return DynaFedParamEntry(entry.m_signblockscript, entry.m_signblock_witness_limit, entry.CalculateExtraRoot());
98-
} else {
94+
// Return appropriate format based on epoch age or if we *just* activated
95+
// dynafed via BIP9
96+
if (epoch_age == 0 || pindexPrev->dynafed_params.IsNull()) {
9997
return entry;
98+
} else {
99+
return DynaFedParamEntry(entry.m_signblockscript, entry.m_signblock_witness_limit, entry.CalculateExtraRoot());
100+
100101
}
101102
}
102103

test/functional/feature_dynafed.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def go_to_epoch_end(node):
3434
blocks_to_mine = epoch_info["epoch_length"] - epoch_info["epoch_age"] - 1
3535
node.generatetoaddress(blocks_to_mine, node.getnewaddress())
3636

37-
def validate_no_vote_op_true(node, block):
37+
def validate_no_vote_op_true(node, block, first_dynafed_active_block):
3838

3939
block_info = node.getblock(block)
4040
dynamic_parameters = block_info["dynamic_parameters"]
@@ -44,7 +44,7 @@ def validate_no_vote_op_true(node, block):
4444
# signblockscript is now the P2WSH-ification of OP_TRUE
4545
WSH_OP_TRUE = node.decodescript("51")["segwit"]["hex"]
4646
assert_equal(dynamic_parameters["current"]["signblockscript"], WSH_OP_TRUE)
47-
if block_height % 10 == 0:
47+
if block_height % 10 == 0 or first_dynafed_active_block:
4848
assert_equal(dynamic_parameters["current"]["fedpegscript"], "51")
4949
assert_equal(dynamic_parameters["current"]["extension_space"], initial_extension)
5050
else:
@@ -118,8 +118,9 @@ def test_dynafed_activation(self):
118118
# Next block is first dynamic federation block
119119
block = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())[0]
120120
self.sync_all()
121+
# We publish full block on BIP9 transition
121122
for i in range(self.num_nodes):
122-
validate_no_vote_op_true(self.nodes[i], block)
123+
validate_no_vote_op_true(self.nodes[i], block, True)
123124

124125
def test_illegal_proposals(self):
125126

@@ -148,14 +149,14 @@ def test_no_vote(self):
148149

149150
for i in range(self.num_nodes):
150151
for block in blocks:
151-
validate_no_vote_op_true(self.nodes[i], block)
152+
validate_no_vote_op_true(self.nodes[i], block, False)
152153

153154
# Now transition using vanilla getnewblockhex, nothing changed
154155
block = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())[0]
155156
self.sync_all()
156157

157158
for i in range(self.num_nodes):
158-
validate_no_vote_op_true(self.nodes[i], block)
159+
validate_no_vote_op_true(self.nodes[i], block, False)
159160

160161
def test_under_vote(self):
161162
self.log.info("Testing failed voting epoch...")
@@ -176,7 +177,7 @@ def test_under_vote(self):
176177
self.sync_all()
177178

178179
for i in range(self.num_nodes):
179-
validate_no_vote_op_true(self.nodes[i], block)
180+
validate_no_vote_op_true(self.nodes[i], block, False)
180181

181182
def test_four_fifth_vote(self):
182183
self.log.info("Testing just-successful transition epoch...")

0 commit comments

Comments
 (0)