diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 26c97909c5..7f239a92e1 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1007,7 +1007,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request) { {"signblockscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded block signing script to propose"}, {"max_block_witness", RPCArg::Type::NUM, RPCArg::Optional::NO, "Total size in witness bytes that are allowed in the dynamic federations block witness for blocksigning"}, - {"fedpegscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded fedpegscript for dynamic block proposal"}, + {"fedpegscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded fedpegscript for dynamic block proposal. This is interpreted as a v0 segwit witnessScript, and fills out the fedpeg_program as such."}, {"extension_space", RPCArg::Type::ARR, RPCArg::Optional::NO, "Array of additional fields to embed in the dynamic blockheader. Has no consensus meaning aside from serialized size changes. This space is currently is only used for PAK enforcement.", { {"", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex encoded string for extension entries."}, diff --git a/test/functional/feature_fedpeg.py b/test/functional/feature_fedpeg.py index faa13276db..55d5495135 100755 --- a/test/functional/feature_fedpeg.py +++ b/test/functional/feature_fedpeg.py @@ -52,6 +52,10 @@ class FedPegTest(BitcoinTestFramework): help="Use a different binary for launching nodes") parser.add_argument("--parent_bitcoin", dest="parent_bitcoin", default=False, action="store_true", help="Parent nodes are Bitcoin") + parser.add_argument("--pre_transition", dest="pre_transition", default=False, action="store_true", + help="Run test in dynafed activated chain, without a transition") + parser.add_argument("--post_transition", dest="post_transition", default=False, action="store_true", + help="Run test in dynafed activated chain, after transition and additional epoch to invalidate old fedpegscript") def skip_test_if_missing_module(self): self.skip_if_no_wallet() @@ -134,6 +138,10 @@ class FedPegTest(BitcoinTestFramework): '-con_parent_pegged_asset=%s' % parent_pegged_asset, ]) + # Immediate activation of dynafed when requested versus "never" from conf + if self.options.pre_transition or self.options.post_transition: + extra_args.extend(["-con_dyna_deploy_start=-1"]) + # Use rpcuser auth only for first parent. if n==0: # Extract username and password from cookie file and use directly. @@ -182,6 +190,22 @@ class FedPegTest(BitcoinTestFramework): #parent2 = self.nodes[1] sidechain = self.nodes[2] sidechain2 = self.nodes[3] + + # If we're testing post-transition, force a fedpegscript transition and + # getting rid of old fedpegscript by making at least another epoch pass by + WSH_OP_TRUE = self.nodes[0].decodescript("51")["segwit"]["hex"] + # We just randomize the keys a bit to get another valid fedpegscript + new_fedpegscript = sidechain.tweakfedpegscript("f00dbabe")["script"] + if self.options.post_transition: + print("Running test post-transition") + for _ in range(30): + block_hex = sidechain.getnewblockhex(0, {"signblockscript":WSH_OP_TRUE, "max_block_witness":10, "fedpegscript":new_fedpegscript, "extension_space":[]}) + sidechain.submitblock(block_hex) + assert_equal(sidechain.getsidechaininfo()["current_fedpegscripts"], [new_fedpegscript]*2) + + if self.options.pre_transition: + print("Running test pre-transition, dynafed activated from first block") + for node in self.nodes: node.importprivkey(privkey=node.get_deterministic_priv_key().key, label="mining") util.node_fastmerkle = sidechain diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 7b71eaa5d7..9f5712a62a 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -70,6 +70,8 @@ BASE_SCRIPTS = [ # Scripts that are run by the travis build process. # vv First elements tests vv 'feature_fedpeg.py', + 'feature_fedpeg.py --pre_transition', + 'feature_fedpeg.py --post_transition', 'feature_mandatory_coinbase.py', 'feature_block_subsidy.py', 'feature_connect_genesis_outputs.py',