diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index e7026940cbba9..ffbfc58a96146 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -826,9 +826,6 @@ static RPCHelpMan getblocktemplate() UpdateTime(&block, consensusParams, pindexPrev); block.nNonce = 0; - // NOTE: If at some point we support pre-segwit miners post-segwit-activation, this needs to take segwit support into consideration - const bool fPreSegWit = !DeploymentActiveAfter(pindexPrev, chainman, Consensus::DEPLOYMENT_SEGWIT); - UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal"); UniValue transactions(UniValue::VARR); @@ -862,10 +859,6 @@ static RPCHelpMan getblocktemplate() int index_in_template = i - 1; entry.pushKV("fee", tx_fees.at(index_in_template)); int64_t nTxSigOps{tx_sigops.at(index_in_template)}; - if (fPreSegWit) { - CHECK_NONFATAL(nTxSigOps % WITNESS_SCALE_FACTOR == 0); - nTxSigOps /= WITNESS_SCALE_FACTOR; - } entry.pushKV("sigops", nTxSigOps); entry.pushKV("weight", GetTransactionWeight(tx)); @@ -889,10 +882,9 @@ static RPCHelpMan getblocktemplate() // ! indicates a more subtle change to the block structure or generation transaction // Otherwise clients may assume the rule will not impact usage of the template as-is. aRules.push_back("csv"); - if (!fPreSegWit) { - aRules.push_back("!segwit"); - aRules.push_back("taproot"); - } + // BIP 145: the '!' rule prefix MUST be enabled on the "segwit" rule for templates including transactions with witness data. + aRules.push_back("!segwit"); + aRules.push_back("taproot"); if (consensusParams.signet_blocks) { // indicate to miner that they must understand signet rules // when attempting to mine with this template @@ -955,17 +947,9 @@ static RPCHelpMan getblocktemplate() result.pushKV("noncerange", "00000000ffffffff"); int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST; int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE; - if (fPreSegWit) { - CHECK_NONFATAL(nSigOpLimit % WITNESS_SCALE_FACTOR == 0); - nSigOpLimit /= WITNESS_SCALE_FACTOR; - CHECK_NONFATAL(nSizeLimit % WITNESS_SCALE_FACTOR == 0); - nSizeLimit /= WITNESS_SCALE_FACTOR; - } result.pushKV("sigoplimit", nSigOpLimit); result.pushKV("sizelimit", nSizeLimit); - if (!fPreSegWit) { - result.pushKV("weightlimit", (int64_t)MAX_BLOCK_WEIGHT); - } + result.pushKV("weightlimit", (int64_t)MAX_BLOCK_WEIGHT); result.pushKV("curtime", block.GetBlockTime()); result.pushKV("bits", strprintf("%08x", block.nBits)); result.pushKV("height", (int64_t)(pindexPrev->nHeight+1)); diff --git a/test/functional/feature_segwit.py b/test/functional/feature_segwit.py index f98f326e8f441..e0a60b763f49f 100755 --- a/test/functional/feature_segwit.py +++ b/test/functional/feature_segwit.py @@ -84,21 +84,18 @@ def add_options(self, parser): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 3 - # This test tests SegWit both pre and post-activation, so use the normal BIP9 activation. + # This test tests SegWit post-activation self.extra_args = [ [ "-acceptnonstdtxn=1", - "-testactivationheight=segwit@165", "-addresstype=legacy", ], [ "-acceptnonstdtxn=1", - "-testactivationheight=segwit@165", "-addresstype=legacy", ], [ "-acceptnonstdtxn=1", - "-testactivationheight=segwit@165", "-addresstype=legacy", ], ] @@ -124,17 +121,6 @@ def fail_accept(self, node, error_msg, txid, sign, redeem_script=""): def run_test(self): self.generate(self.nodes[0], 161) # block 161 - self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork") - txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) - tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']}) - assert_equal(tmpl['sizelimit'], 1000000) - assert 'weightlimit' not in tmpl - assert_equal(tmpl['sigoplimit'], 20000) - assert_equal(tmpl['transactions'][0]['hash'], txid) - assert_equal(tmpl['transactions'][0]['sigops'], 2) - assert '!segwit' not in tmpl['rules'] - self.generate(self.nodes[0], 1) # block 162 - balance_presetup = self.nodes[0].getbalance() self.pubkey = [] p2sh_ids = [] # p2sh_ids[NODE][TYPE] is an array of txids that spend to P2WPKH (TYPE=0) or P2WSH (TYPE=1) scripts to an address for NODE embedded in p2sh