Skip to content

Commit

Permalink
Merge branch 'master' into elements-22-fix-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
psgreco committed Apr 17, 2023
2 parents a03fe8d + 1443d30 commit b37e09c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ UniValue paramEntryToJSON(const DynaFedParamEntry& entry)
}

// fields all params have
result.pushKV("root", HexStr(entry.CalculateRoot()));
result.pushKV("root", entry.CalculateRoot().GetHex());
result.pushKV("signblockscript", HexStr(entry.m_signblockscript));
result.pushKV("max_block_witness", (uint64_t)entry.m_signblock_witness_limit);

// add the extra root which is stored for compact and calculated for full
if (entry.m_serialize_type == 1) {
// compact
result.pushKV("extra_root", HexStr(entry.m_elided_root));
result.pushKV("extra_root", entry.m_elided_root.GetHex());
} else if (entry.m_serialize_type == 2) {
// full
result.pushKV("extra_root", HexStr(entry.CalculateExtraRoot()));
result.pushKV("extra_root", entry.CalculateExtraRoot().GetHex());
}

// some extra fields only present on full params
Expand Down
8 changes: 8 additions & 0 deletions test/functional/feature_dynafed.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
initial_extension = [initial_online+initial_online]
new_extension = [initial_offline+initial_online]

initial_cpe_root = "3700bdb2975ff8e0dadaaba2b33857b0ca2610c950a92b1db725025e3647a8e1"

ERR_MP_INVALID_PEGOUT = "invalid-pegout-proof"
ERR_MP_INVALID_PEGIN = "pegin-no-witness"

Expand All @@ -48,16 +50,19 @@ def validate_no_vote_op_true(node, block, first_dynafed_active_block):
assert_equal(dynamic_parameters["current"]["signblockscript"], WSH_OP_TRUE)
if block_height % 10 == 0 or first_dynafed_active_block:
assert_equal(dynamic_parameters["current"]["type"], "full")
assert_equal(dynamic_parameters["current"]["root"], initial_cpe_root)
assert_equal(dynamic_parameters["current"]["fedpegscript"], "51")
assert_equal(dynamic_parameters["current"]["extension_space"], initial_extension)
else:
assert_equal(dynamic_parameters["current"]["type"], "compact")
assert_equal(dynamic_parameters["current"]["root"], initial_cpe_root)
assert not "fedpegscript" in dynamic_parameters["proposed"]
assert not "extension_space" in dynamic_parameters["proposed"]
assert_equal(dynamic_parameters["current"]["max_block_witness"], 74)
# nothing was proposed, null fields make impossible to be valid blockheader
# due to script rules requiring bool true on stack
assert_equal(dynamic_parameters["proposed"]["type"], "null")
assert not "root" in dynamic_parameters["proposed"]
assert not "signblockscript" in dynamic_parameters["proposed"]
assert not "max_block_witness" in dynamic_parameters["proposed"]
assert not "fedpegscript" in dynamic_parameters["proposed"]
Expand Down Expand Up @@ -134,6 +139,9 @@ def test_dynafed_activation(self):
self.sync_blocks(timeout=240)
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["dynafed"]["bip9"]["status"], "active")

# Check the root hash
assert_equal(self.nodes[0].getblockchaininfo()["current_params_root"], initial_cpe_root)

# Existing blocks should have null dynafed fields
for block in blocks:
assert "dynamic_parameters" not in self.nodes[0].getblock(block)
Expand Down

0 comments on commit b37e09c

Please sign in to comment.