diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -828,10 +828,9 @@ DEFAULT_ACCEPT_DATACARRIER)); strUsage += HelpMessageOpt( "-datacarriersize", - strprintf( - _("Maximum size of data in data carrier transactions we relay and " - "mine (pre-fork default: %u, post-fork default: %u)"), - MAX_OP_RETURN_RELAY, MAX_OP_RETURN_RELAY_LARGE)); + strprintf(_("Maximum size of data in data carrier transactions we " + "relay and mine (default: %u)"), + MAX_OP_RETURN_RELAY)); strUsage += HelpMessageGroup(_("Block creation options:")); strUsage += HelpMessageOpt( diff --git a/src/policy/policy.h b/src/policy/policy.h --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -68,16 +68,14 @@ static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE | LOCKTIME_MEDIAN_TIME_PAST; -bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType, - bool allowLargeOpReturn = false); +bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType); /** * Check for standard transaction types * @return True if all outputs (scriptPubKeys) use only standard transaction * forms */ -bool IsStandardTx(const CTransaction &tx, std::string &reason, - bool allowLargeOpReturn = false); +bool IsStandardTx(const CTransaction &tx, std::string &reason); /** * Check for standard transaction types diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -27,8 +27,7 @@ * expensive-to-check-upon-redemption script like: * DUP CHECKSIG DROP ... repeated 100 times... OP_1 */ -bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType, - bool allowLargeOpReturn) { +bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType) { std::vector> vSolutions; if (!Solver(scriptPubKey, whichType, vSolutions)) { return false; @@ -46,9 +45,7 @@ } unsigned nMaxDatacarrierBytes = - gArgs.GetArg("-datacarriersize", - allowLargeOpReturn ? MAX_OP_RETURN_RELAY_LARGE - : MAX_OP_RETURN_RELAY); + gArgs.GetArg("-datacarriersize", MAX_OP_RETURN_RELAY); if (scriptPubKey.size() > nMaxDatacarrierBytes) { return false; } @@ -57,8 +54,7 @@ return whichType != TX_NONSTANDARD; } -bool IsStandardTx(const CTransaction &tx, std::string &reason, - bool allowLargeOpReturn) { +bool IsStandardTx(const CTransaction &tx, std::string &reason) { if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) { reason = "version"; return false; @@ -94,7 +90,7 @@ unsigned int nDataOut = 0; txnouttype whichType; for (const CTxOut &txout : tx.vout) { - if (!::IsStandard(txout.scriptPubKey, whichType, allowLargeOpReturn)) { + if (!::IsStandard(txout.scriptPubKey, whichType)) { reason = "scriptpubkey"; return false; } diff --git a/src/script/standard.h b/src/script/standard.h --- a/src/script/standard.h +++ b/src/script/standard.h @@ -27,8 +27,7 @@ }; //!< bytes (+1 for OP_RETURN, +2 for the pushdata opcodes) -static const unsigned int MAX_OP_RETURN_RELAY = 83; -static const unsigned int MAX_OP_RETURN_RELAY_LARGE = 223; +static const unsigned int MAX_OP_RETURN_RELAY = 223; extern bool fAcceptDatacarrier; /** diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -646,30 +646,6 @@ BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); // MAX_OP_RETURN_RELAY-byte TX_NULL_DATA (standard) - t.vout[0].scriptPubKey = - CScript() << OP_RETURN - << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909" - "a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548" - "271967f1a67130b7105cd6a828e03909a67962e0ea1f61de" - "b649f6bc3f4cef38"); - BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY, t.vout[0].scriptPubKey.size()); - BOOST_CHECK(IsStandardTx(CTransaction(t), reason)); - - // MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard) - t.vout[0].scriptPubKey = - CScript() << OP_RETURN - << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909" - "a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548" - "271967f1a67130b7105cd6a828e03909a67962e0ea1f61de" - "b649f6bc3f4cef3800"); - BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size()); - BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); - - /** - * Check acceptance of larger op_return when asked to. - */ - - // New default size of 223 byte is standard t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("646578784062697477617463682e636f2092c558ed52c56d" @@ -682,10 +658,10 @@ "732ba6677520a893d75d9a966cb8f85dc301656b1635c631" "f5d00d4adf73f2dd112ca75cf19754651909becfbe65aed1" "3afb2ab8"); - BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY_LARGE, t.vout[0].scriptPubKey.size()); - BOOST_CHECK(IsStandardTx(CTransaction(t), reason, true)); + BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY, t.vout[0].scriptPubKey.size()); + BOOST_CHECK(IsStandardTx(CTransaction(t), reason)); - // Larger than default size of 223 byte is non-standard + // MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard) t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("646578784062697477617463682e636f2092c558ed52c56d" @@ -698,14 +674,13 @@ "732ba6677520a893d75d9a966cb8f85dc301656b1635c631" "f5d00d4adf73f2dd112ca75cf19754651909becfbe65aed1" "3afb2ab800"); - BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY_LARGE + 1, - t.vout[0].scriptPubKey.size()); - BOOST_CHECK(!IsStandardTx(CTransaction(t), reason, true)); + BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size()); + BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); /** * Check when a custom value is used for -datacarriersize . */ - unsigned newMaxSize = MAX_OP_RETURN_RELAY + 7; + unsigned newMaxSize = 90; gArgs.ForceSetArg("-datacarriersize", std::to_string(newMaxSize)); // Max user provided payload size is standard @@ -716,8 +691,7 @@ "271967f1a67130b7105cd6a828e03909a67962e0ea1f61de" "b649f6bc3f4cef3877696e64657878"); BOOST_CHECK_EQUAL(t.vout[0].scriptPubKey.size(), newMaxSize); - BOOST_CHECK(IsStandardTx(CTransaction(t), reason, false)); - BOOST_CHECK(IsStandardTx(CTransaction(t), reason, true)); + BOOST_CHECK(IsStandardTx(CTransaction(t), reason)); // Max user provided payload size + 1 is non-standard t.vout[0].scriptPubKey = @@ -727,8 +701,7 @@ "271967f1a67130b7105cd6a828e03909a67962e0ea1f61de" "b649f6bc3f4cef3877696e6465787800"); BOOST_CHECK_EQUAL(t.vout[0].scriptPubKey.size(), newMaxSize + 1); - BOOST_CHECK(!IsStandardTx(CTransaction(t), reason, false)); - BOOST_CHECK(!IsStandardTx(CTransaction(t), reason, true)); + BOOST_CHECK(!IsStandardTx(CTransaction(t), reason)); // Clear custom confirguration. gArgs.ClearArg("-datacarriersize"); diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -753,12 +753,9 @@ return false; } - // After the May, 15 hard fork, we start accepting larger op_return. - const bool hasMonolith = IsMonolithEnabled(config, chainActive.Tip()); - // Rather not work on nonstandard transactions (unless -testnet/-regtest) std::string reason; - if (fRequireStandard && !IsStandardTx(tx, reason, hasMonolith)) { + if (fRequireStandard && !IsStandardTx(tx, reason)) { return state.DoS(0, false, REJECT_NONSTANDARD, reason); } @@ -987,7 +984,7 @@ // Set extraFlags as a set of flags that needs to be activated. uint32_t extraFlags = SCRIPT_VERIFY_NONE; - if (hasMonolith) { + if (IsMonolithEnabled(config, chainActive.Tip())) { extraFlags |= SCRIPT_ENABLE_MONOLITH_OPCODES; } diff --git a/test/functional/abc-opreturn.py b/test/functional/abc-opreturn.py deleted file mode 100755 --- a/test/functional/abc-opreturn.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2018 The Bitcoin developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. -""" -This test checks activation of larger op_return -""" - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import satoshi_round, assert_equal, assert_raises_rpc_error -from test_framework.blocktools import * -from test_framework.script import * - -# far into the future -MONOLITH_START_TIME = 2000000000 - - -class OpReturnActivationTest(BitcoinTestFramework): - - def set_test_params(self): - self.num_nodes = 1 - self.extra_args = [['-whitelist=127.0.0.1', - '-acceptnonstdtxn=0', - "-monolithactivationtime=%d" % MONOLITH_START_TIME, - "-replayprotectionactivationtime=%d" % (2 * MONOLITH_START_TIME)]] - - def create_null_data_tx(self, data_size): - node = self.nodes[0] - utxos = node.listunspent() - assert(len(utxos) > 0) - utxo = utxos[0] - tx = CTransaction() - value = int(satoshi_round(utxo["amount"] - self.relayfee) * COIN) - tx.vin = [CTxIn(COutPoint(int(utxo["txid"], 16), utxo["vout"]))] - script = CScript([OP_RETURN, b'x' * data_size]) - tx.vout = [CTxOut(value, script)] - tx_signed = node.signrawtransaction(ToHex(tx))["hex"] - return tx_signed - - def run_test(self): - node = self.nodes[0] - self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] - - # First, we generate some coins to spend. - node.generate(125) - - # Check that large opreturn are not accepted yet. - self.log.info("Running null-data test, before large data activation") - - # 80 bytes opreturn are ok. - tx = self.create_null_data_tx(80) - txid = node.sendrawtransaction(tx) - assert(txid in set(node.getrawmempool())) - - # 81 bytes opreturn is non standard - tx = self.create_null_data_tx(81) - assert_raises_rpc_error(-26, 'scriptpubkey', - node.sendrawtransaction, tx) - - # Push MTP forward just before activation. - self.log.info("Pushing MTP just before the activation") - node.setmocktime(MONOLITH_START_TIME) - - def next_block(block_time): - # get block height - blockchaininfo = node.getblockchaininfo() - height = int(blockchaininfo['blocks']) - - # create the block - coinbase = create_coinbase(height) - coinbase.rehash() - block = create_block( - int(node.getbestblockhash(), 16), coinbase, block_time) - - # Do PoW, which is cheap on regnet - block.solve() - node.submitblock(ToHex(block)) - - for i in range(6): - next_block(MONOLITH_START_TIME + i - 1) - - # Check we are just before the activation time - assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], - MONOLITH_START_TIME - 1) - - # Check that large opreturn are not accepted yet. - self.log.info("Re-running null-data test just before activation") - - # 80 bytes opreturn are ok. - tx = self.create_null_data_tx(80) - txid = node.sendrawtransaction(tx) - assert(txid in set(node.getrawmempool())) - - # 81 bytes opreturn is non standard - tx = self.create_null_data_tx(81) - assert_raises_rpc_error(-26, 'scriptpubkey', - node.sendrawtransaction, tx) - - # Activate larger opreturn. - self.log.info("Running null-data test, after large data activation") - next_block(MONOLITH_START_TIME + 6) - - assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], - MONOLITH_START_TIME) - - # 81 bytes is now accepted. - tx = self.create_null_data_tx(81) - txid = node.sendrawtransaction(tx) - assert(txid in set(node.getrawmempool())) - - # 220 bytes are now accepted. - tx = self.create_null_data_tx(220) - txid = node.sendrawtransaction(tx) - assert(txid in set(node.getrawmempool())) - - # 221 bytes are rejected. - tx = self.create_null_data_tx(221) - assert_raises_rpc_error(-26, 'scriptpubkey', - node.sendrawtransaction, tx) - - # Because these transaction are valid regardless, there is - # no point checking for reorg. Worst case scenario if a reorg - # happens, we have a fe transaction in the mempool that won't - # propagate to node that aren't aware of them already. - - -if __name__ == '__main__': - OpReturnActivationTest().main()