diff --git a/src/chainparams.cpp b/src/chainparams.cpp index fb5a830fdf..6ec33f2f1d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -966,9 +966,10 @@ class CLiquidV1Params : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - // Not active yet. + // Activated from block 1,000,000. consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].bit = 25; - consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nStartTime = 1000000; + // Allow blocksigners to delay activation. + consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nStartTime = gArgs.GetArg("-con_dyna_deploy_start", 1000000); consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 479b8cb77e..850eebc634 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1459,6 +1459,8 @@ RPCHelpMan getblockchaininfo() obj.pushKV("current_signblock_asm", ScriptToAsmStr(entry.m_signblockscript)); obj.pushKV("current_signblock_hex", HexStr(entry.m_signblockscript)); obj.pushKV("max_block_witness", (uint64_t)entry.m_signblock_witness_limit); + obj.pushKV("current_fedpeg_program", HexStr(entry.m_fedpeg_program)); + obj.pushKV("current_fedpeg_script", HexStr(entry.m_fedpegscript)); UniValue arr(UniValue::VARR); for (const auto& extension : entry.m_extension_space) { arr.push_back(HexStr(extension)); diff --git a/src/validation.cpp b/src/validation.cpp index a4ee969da3..5b4841244c 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3741,49 +3741,56 @@ static bool ContextualCheckDynaFedHeader(const CBlockHeader& block, BlockValidat return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "dynamic block header's current parameters do not match expected"); } - // Lastly, enforce rules on proposals. - const DynaFedParamEntry& proposed = dynafed_params.m_proposed; - if (!proposed.IsNull()) { - - // signblockscript proposals *must* be segwit versions - int block_version = 0; - std::vector block_program; - if (!proposed.m_signblockscript.IsWitnessProgram(block_version, block_program)) { - return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "proposed signblockscript must be native segwit scriptPubkey"); - } - - int fedpeg_version = 0; - std::vector fedpeg_program; - if (!proposed.m_fedpeg_program.IsWitnessProgram(fedpeg_version, fedpeg_program)) { - return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "proposed fedpegs program must be native segwit scriptPubkey"); - } - - // for v0, fedpegscript's scriptPubKey must match. v1+ is unencumbered. - if (fedpeg_version == 0) { - uint256 fedpeg_program; - CSHA256().Write(proposed.m_fedpegscript.data(), proposed.m_fedpegscript.size()).Finalize(fedpeg_program.begin()); - CScript computed_program = CScript() << OP_0 << ToByteVector(fedpeg_program); - if (computed_program != proposed.m_fedpeg_program) { - return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "proposed v0 segwit fedpegscript must match proposed fedpeg witness program"); + // Lastly, enforce rules on proposals if they make changes. + if (!dynafed_params.m_proposed.IsNull()) { + // Compare the new proposed parameters with the current full parameters. + const DynaFedParamEntry current = ComputeNextBlockFullCurrentParameters(pindexPrev, params.GetConsensus()); + const DynaFedParamEntry& proposed = dynafed_params.m_proposed; + + if (proposed.m_signblockscript != current.m_signblockscript) { + // signblockscript proposals *must* be segwit versions + int block_version = 0; + std::vector block_program; + if (!proposed.m_signblockscript.IsWitnessProgram(block_version, block_program)) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "proposed signblockscript must be native segwit scriptPubkey"); } + } - // fedpegscript proposals *must not* start with OP_DEPTH - // This forbids the first Liquid watchman script which is a hack. - // Use miniscript, which doesn't even have OP_DEPTH. - // We don't encumber future segwit versions as opcodes may change. - if (!proposed.m_fedpegscript.empty() && - proposed.m_fedpegscript.front() == OP_DEPTH) { - return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "Proposed fedpegscript starts with OP_DEPTH, which is illegal"); + if (proposed.m_fedpeg_program != current.m_fedpeg_program || proposed.m_fedpegscript != current.m_fedpegscript) { + int fedpeg_version = 0; + std::vector fedpeg_program; + if (!proposed.m_fedpeg_program.IsWitnessProgram(fedpeg_version, fedpeg_program)) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "proposed signblockscript must be native segwit scriptPubkey"); + } + + // for v0, fedpegscript's scriptPubKey must match. v1+ is unencumbered. + if (fedpeg_version == 0) { + uint256 fedpeg_program; + CSHA256().Write(proposed.m_fedpegscript.data(), proposed.m_fedpegscript.size()).Finalize(fedpeg_program.begin()); + CScript computed_program = CScript() << OP_0 << ToByteVector(fedpeg_program); + if (computed_program != proposed.m_fedpeg_program) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "proposed v0 segwit fedpegscript must match proposed fedpeg witness program"); + } + + // fedpegscript proposals *must not* start with OP_DEPTH + // This forbids the first Liquid watchman script which is a hack. + // Use miniscript, which doesn't even have OP_DEPTH. + // We don't encumber future segwit versions as opcodes may change. + if (!proposed.m_fedpegscript.empty() && proposed.m_fedpegscript.front() == OP_DEPTH) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "Proposed fedpegscript starts with OP_DEPTH, which is illegal"); + } } } - // When enforcing PAK, extension_space must give non-empty PAK list when - // the vector itself is non-empty. Otherwise this means there were "junk" - // entries - if (params.GetEnforcePak()) { - if (!proposed.m_extension_space.empty() && - CreatePAKListFromExtensionSpace(proposed.m_extension_space).IsReject()) { - return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "Extension space is not list of valid PAK entries"); + if (proposed.m_extension_space != current.m_extension_space) { + // When enforcing PAK, extension_space must give non-empty PAK list when + // the vector itself is non-empty. Otherwise this means there were "junk" + // entries + if (params.GetEnforcePak()) { + if (!proposed.m_extension_space.empty() && + CreatePAKListFromExtensionSpace(proposed.m_extension_space).IsReject()) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "invalid-dyna-fed", "Extension space is not list of valid PAK entries"); + } } } } diff --git a/test/functional/feature_dynafed.py b/test/functional/feature_dynafed.py index e8f98fb062..921d8d3796 100755 --- a/test/functional/feature_dynafed.py +++ b/test/functional/feature_dynafed.py @@ -66,6 +66,8 @@ def set_test_params(self): self.extra_args = [["-con_dyna_deploy_start=1000", "-enforce_pak=1", "-con_parent_chain_signblockscript=51", "-peginconfirmationdepth=1", "-parentscriptprefix=75", "-parent_bech32_hrp=ert"] for i in range(self.num_nodes)] # second node will not mine transactions self.extra_args[1].append("-blocksonly=1") + # Make sure nothing breaks if peers have a different activation. + self.extra_args[1][0] = "-con_dyna_deploy_start=937" def skip_test_if_missing_module(self): self.skip_if_no_wallet()