diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -139,9 +139,6 @@ // November 13, 2017 hard fork consensus.daaHeight = 504031; - // May 15, 2018 hard fork - consensus.monolithActivationTime = 1526400000; - // Nov 15, 2018 hard fork consensus.magneticAnomalyActivationTime = 1542300000; @@ -317,9 +314,6 @@ // November 13, 2017 hard fork consensus.daaHeight = 1188697; - // May 15, 2018 hard fork - consensus.monolithActivationTime = 1526400000; - // Nov 15, 2018 hard fork consensus.magneticAnomalyActivationTime = 1542300000; @@ -445,9 +439,6 @@ // November 13, 2017 hard fork is always on on regtest. consensus.daaHeight = 0; - // May 15, 2018 hard fork. - consensus.monolithActivationTime = 1526400000; - // Nov 15, 2018 hard fork consensus.magneticAnomalyActivationTime = 1542300000; diff --git a/src/consensus/params.h b/src/consensus/params.h --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -28,8 +28,10 @@ struct BIP9Deployment { /** Bit position to select the particular bit in nVersion. */ int bit; - /** Start MedianTime for version bits miner confirmation. Can be a date in - * the past */ + /** + * Start MedianTime for version bits miner confirmation. Can be a date in + * the past. + */ int64_t nStartTime; /** Timeout/expiry MedianTime for the deployment attempt. */ int64_t nTimeout; @@ -52,8 +54,6 @@ int uahfHeight; /** Block height at which the new DAA becomes active */ int daaHeight; - /** Unix time used for MTP activation of May 15 2018, hardfork */ - int monolithActivationTime; /** Unix time used for MTP activation of Nov 15 2018, hardfork */ int magneticAnomalyActivationTime; /** diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -87,13 +87,6 @@ std::max(uint64_t(1000), std::min(config.GetMaxBlockSize() - 1000, nMaxGeneratedBlockSize)); - // If May 15, 2018 HF is not activated yet, we also want to limit the max - // generated block size to 8MB - 1000 - if (!IsMonolithEnabled(config, pindexPrev)) { - nMaxGeneratedBlockSize = - std::min(8 * ONE_MEGABYTE - 1000, nMaxGeneratedBlockSize); - } - return nMaxGeneratedBlockSize; } diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -735,36 +735,9 @@ CheckBlockMaxSize(chainparams, ONE_MEGABYTE - 999, ONE_MEGABYTE - 999); CheckBlockMaxSize(chainparams, ONE_MEGABYTE, ONE_MEGABYTE - 999); - // The maximum block size to be generated before the May 15, 2018 HF - static const auto EIGHT_MEGABYTES = 8 * ONE_MEGABYTE; - static const auto LEGACY_CAP = EIGHT_MEGABYTES - 1000; - - // Test around historical 8MB cap. - config.SetMaxBlockSize(EIGHT_MEGABYTES + 1); - CheckBlockMaxSize(chainparams, EIGHT_MEGABYTES - 1001, - EIGHT_MEGABYTES - 1001); - CheckBlockMaxSize(chainparams, EIGHT_MEGABYTES - 1000, LEGACY_CAP); - CheckBlockMaxSize(chainparams, EIGHT_MEGABYTES - 999, LEGACY_CAP); - CheckBlockMaxSize(chainparams, EIGHT_MEGABYTES, EIGHT_MEGABYTES - 1000); - // Test around default cap config.SetMaxBlockSize(DEFAULT_MAX_BLOCK_SIZE); - // We are stuck at the legacy cap before activation. - CheckBlockMaxSize(chainparams, DEFAULT_MAX_BLOCK_SIZE, LEGACY_CAP); - - // Activate May 15, 2018 HF the dirty way - const int64_t monolithTime = - config.GetChainParams().GetConsensus().monolithActivationTime; - auto pindex = chainActive.Tip(); - for (size_t i = 0; pindex && i < 5; i++) { - BOOST_CHECK(!IsMonolithEnabled(config, chainActive.Tip())); - pindex->nTime = monolithTime; - pindex = pindex->pprev; - } - - BOOST_CHECK(IsMonolithEnabled(config, chainActive.Tip())); - // Now we can use the default max block size. CheckBlockMaxSize(chainparams, DEFAULT_MAX_BLOCK_SIZE - 1001, DEFAULT_MAX_BLOCK_SIZE - 1001); diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -443,9 +443,6 @@ /** Check if DAA HF has activated. */ bool IsDAAEnabled(const Config &config, const CBlockIndex *pindexPrev); -/** Check if May 15, 2018 HF has activated. */ -bool IsMonolithEnabled(const Config &config, const CBlockIndex *pindexPrev); - /** * (try to) add transaction to memory pool */ diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -612,21 +612,6 @@ return IsDAAEnabled(config, pindexPrev->nHeight); } -static bool IsMonolithEnabled(const Config &config, int64_t nMedianTimePast) { - return nMedianTimePast >= - gArgs.GetArg( - "-monolithactivationtime", - config.GetChainParams().GetConsensus().monolithActivationTime); -} - -bool IsMonolithEnabled(const Config &config, const CBlockIndex *pindexPrev) { - if (pindexPrev == nullptr) { - return false; - } - - return IsMonolithEnabled(config, pindexPrev->GetMedianTimePast()); -} - static bool IsReplayProtectionEnabled(const Config &config, int64_t nMedianTimePast) { return nMedianTimePast >= gArgs.GetArg("-replayprotectionactivationtime", @@ -2630,13 +2615,8 @@ // remove transactions that are replay protected from the mempool. There is // no easy way to do this so we'll just discard the whole mempool and then // add the transaction of the block we just disconnected back. - // - // Samewise, if this block enabled the monolith opcodes, then we need to - // clear the mempool of any transaction using them. - if ((IsReplayProtectionEnabled(config, pindexDelete) && - !IsReplayProtectionEnabled(config, pindexDelete->pprev)) || - (IsMonolithEnabled(config, pindexDelete) && - !IsMonolithEnabled(config, pindexDelete->pprev))) { + if (IsReplayProtectionEnabled(config, pindexDelete) && + !IsReplayProtectionEnabled(config, pindexDelete->pprev)) { LogPrint(BCLog::MEMPOOL, "Clearing mempool for reorg"); mempool.clear(); @@ -3722,17 +3702,6 @@ nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST; } - if (!IsMonolithEnabled(config, pindexPrev)) { - // When the May 15, 2018 HF is not enabled, block cannot be bigger - // than 8MB . - const uint64_t currentBlockSize = - ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION); - if (currentBlockSize > 8 * ONE_MEGABYTE) { - return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", - false, "size limits failed"); - } - } - const int64_t nMedianTimePast = pindexPrev == nullptr ? 0 : pindexPrev->GetMedianTimePast(); diff --git a/test/functional/abc-monolith-activation.py b/test/functional/abc-monolith-activation.py deleted file mode 100755 --- a/test/functional/abc-monolith-activation.py +++ /dev/null @@ -1,163 +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 monolith opcodes -""" - -from test_framework.test_framework import ComparisonTestFramework -from test_framework.util import satoshi_round, assert_equal, assert_raises_rpc_error -from test_framework.comptool import TestManager, TestInstance, RejectResult -from test_framework.blocktools import * -from test_framework.script import * - -# far into the future -MONOLITH_START_TIME = 2000000000 - -# Error due to invalid opcodes -DISABLED_OPCODE_ERROR = b'non-mandatory-script-verify-flag (Attempted to use a disabled opcode)' -RPC_DISABLED_OPCODE_ERROR = "64: " + \ - DISABLED_OPCODE_ERROR.decode("utf-8") - - -class PreviousSpendableOutput(): - - def __init__(self, tx=CTransaction(), n=-1): - self.tx = tx - self.n = n # the output we're spending - - -class MonolithActivationTest(ComparisonTestFramework): - - def set_test_params(self): - self.num_nodes = 1 - self.setup_clean_chain = True - self.extra_args = [['-whitelist=127.0.0.1', - "-monolithactivationtime=%d" % MONOLITH_START_TIME, - "-replayprotectionactivationtime=%d" % (2 * MONOLITH_START_TIME)]] - - def create_and_tx(self, count): - 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) // count - tx.vin = [CTxIn(COutPoint(int(utxo["txid"], 16), utxo["vout"]))] - tx.vout = [] - for _ in range(count): - tx.vout.append(CTxOut(value, CScript([OP_1, OP_1, OP_AND]))) - tx_signed = node.signrawtransaction(ToHex(tx))["hex"] - return tx_signed - - def run_test(self): - self.test = TestManager(self, self.options.tmpdir) - self.test.add_all_connections(self.nodes) - # Start up network handling in another thread - NetworkThread().start() - self.test.run() - - def get_tests(self): - node = self.nodes[0] - self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] - - # First, we generate some coins to spend. - node.generate(125) - - # Create various outputs using the OP_AND to check for activation. - tx_hex = self.create_and_tx(25) - txid = node.sendrawtransaction(tx_hex) - assert(txid in set(node.getrawmempool())) - - node.generate(1) - assert(txid not in set(node.getrawmempool())) - - # Push MTP forward just before activation. - self.log.info("Pushing MTP just before the activation and check again") - node.setmocktime(MONOLITH_START_TIME) - - # returns a test case that asserts that the current tip was accepted - def accepted(tip): - return TestInstance([[tip, True]]) - - # returns a test case that asserts that the current tip was rejected - def rejected(tip, reject=None): - if reject is None: - return TestInstance([[tip, False]]) - else: - return TestInstance([[tip, reject]]) - - 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() - return block - - for i in range(6): - b = next_block(MONOLITH_START_TIME + i - 1) - yield accepted(b) - - self.log.info("Activates the new opcodes") - fork_block = next_block(MONOLITH_START_TIME + 6) - yield accepted(fork_block) - - # register the spendable outputs. - tx = FromHex(CTransaction(), tx_hex) - tx.rehash() - spendable_ands = [PreviousSpendableOutput( - tx, i) for i in range(len(tx.vout))] - - def spend_and(): - outpoint = spendable_ands.pop() - out = outpoint.tx.vout[outpoint.n] - value = int(out.nValue - (self.relayfee * COIN)) - tx = CTransaction() - tx.vin = [CTxIn(COutPoint(outpoint.tx.sha256, outpoint.n))] - tx.vout = [CTxOut(value, CScript([]))] - tx.rehash() - return tx - - tx0 = spend_and() - tx0_hex = ToHex(tx0) - - assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], - MONOLITH_START_TIME) - - tx0id = node.sendrawtransaction(tx0_hex) - assert(tx0id in set(node.getrawmempool())) - - def add_tx(block, tx): - block.vtx.append(tx) - block.hashMerkleRoot = block.calc_merkle_root() - block.solve() - - # Transactions can also be included in blocks. - monolithblock = next_block(MONOLITH_START_TIME + 7) - add_tx(monolithblock, tx0) - yield accepted(monolithblock) - - self.log.info("Cause a reorg that deactivate the monolith opcodes") - - # Invalidate the monolith block, ensure tx0 gets back to the mempool. - assert(tx0id not in set(node.getrawmempool())) - - node.invalidateblock(format(monolithblock.sha256, 'x')) - assert(tx0id in set(node.getrawmempool())) - - node.invalidateblock(format(fork_block.sha256, 'x')) - assert(tx0id not in set(node.getrawmempool())) - - -if __name__ == '__main__': - MonolithActivationTest().main() diff --git a/test/functional/abc-p2p-compactblocks.py b/test/functional/abc-p2p-compactblocks.py --- a/test/functional/abc-p2p-compactblocks.py +++ b/test/functional/abc-p2p-compactblocks.py @@ -21,9 +21,6 @@ MAX_BLOCK_SIGOPS_PER_MB, MAX_TX_SIGOPS_COUNT) from collections import deque -# far into the future -MONOLITH_START_TIME = 2000000000 - class PreviousSpendableOutput(): @@ -83,9 +80,7 @@ '-limitdescendantcount=999999', '-limitdescendantsize=999999', '-maxmempool=99999', - "-monolithactivationtime=%d" % MONOLITH_START_TIME, - "-excessiveblocksize=%d" - % self.excessive_block_size]] + "-excessiveblocksize=%d" % self.excessive_block_size]] def add_options(self, parser): super().add_options(parser) @@ -99,7 +94,6 @@ NetworkThread().start() # Set the blocksize to 2MB as initial condition self.nodes[0].setexcessiveblock(self.excessive_block_size) - self.nodes[0].setmocktime(MONOLITH_START_TIME) self.test.run() def add_transactions_to_block(self, block, tx_list): @@ -274,14 +268,8 @@ test.blocks_and_transactions.append([self.tip, True]) save_spendable_output() - # Fork block - bfork = block(5555) - bfork.nTime = MONOLITH_START_TIME - update_block(5555, []) - test.blocks_and_transactions.append([self.tip, True]) - # Get to one block of the May 15, 2018 HF activation - for i in range(5): + for i in range(6): block(5100 + i) test.blocks_and_transactions.append([self.tip, True]) diff --git a/test/functional/abc-p2p-fullblocktest.py b/test/functional/abc-p2p-fullblocktest.py --- a/test/functional/abc-p2p-fullblocktest.py +++ b/test/functional/abc-p2p-fullblocktest.py @@ -22,8 +22,7 @@ MAX_BLOCK_SIGOPS_PER_MB, MAX_TX_SIGOPS_COUNT) from collections import deque -# far into the future -MONOLITH_START_TIME = 2000000000 +REPLAY_PROTECTION_START_TIME = 2000000000 class PreviousSpendableOutput(): @@ -47,11 +46,8 @@ self.blocks = {} self.excessive_block_size = 100 * ONE_MEGABYTE self.extra_args = [['-whitelist=127.0.0.1', - "-monolithactivationtime=%d" % MONOLITH_START_TIME, - "-replayprotectionactivationtime=%d" % ( - 2 * MONOLITH_START_TIME), - "-excessiveblocksize=%d" - % self.excessive_block_size]] + "-replayprotectionactivationtime=%d" % REPLAY_PROTECTION_START_TIME, + "-excessiveblocksize=%d" % self.excessive_block_size]] def add_options(self, parser): super().add_options(parser) @@ -65,7 +61,6 @@ NetworkThread().start() # Set the blocksize to 2MB as initial condition self.nodes[0].setexcessiveblock(self.excessive_block_size) - self.nodes[0].setmocktime(MONOLITH_START_TIME) self.test.run() def add_transactions_to_block(self, block, tx_list): @@ -249,42 +244,11 @@ out.append(get_spendable_output()) # Let's build some blocks and test them. - for i in range(15): + for i in range(16): n = i + 1 - block(n, spend=out[i], block_size=n * ONE_MEGABYTE // 2) + block(n, spend=out[i], block_size=n * ONE_MEGABYTE) yield accepted() - # Start moving MTP forward - bfork = block(5555, out[15], block_size=8 * ONE_MEGABYTE) - bfork.nTime = MONOLITH_START_TIME - 1 - update_block(5555, []) - yield accepted() - - # Get to one block of the May 15, 2018 HF activation - for i in range(5): - block(5100 + i) - test.blocks_and_transactions.append([self.tip, True]) - yield test - - # Check that the MTP is just before the configured fork point. - assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], - MONOLITH_START_TIME - 1) - - # Before we acivate the May 15, 2018 HF, 8MB is the limit. - block(4444, spend=out[16], block_size=8 * ONE_MEGABYTE + 1) - yield rejected(RejectResult(16, b'bad-blk-length')) - - # Rewind bad block. - tip(5104) - - # Actiavte the May 15, 2018 HF - block(5556) - yield accepted() - - # Now MTP is exactly the fork time. Bigger blocks are now accepted. - assert_equal(node.getblockheader(node.getbestblockhash())['mediantime'], - MONOLITH_START_TIME) - # block of maximal size block(17, spend=out[16], block_size=self.excessive_block_size) yield accepted() diff --git a/test/functional/mempool_reorg.py b/test/functional/mempool_reorg.py --- a/test/functional/mempool_reorg.py +++ b/test/functional/mempool_reorg.py @@ -17,7 +17,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.extra_args = [["-checkmempool", "-monolithactivationtime=0"]] * 2 + self.extra_args = [["-checkmempool"]] * 2 alert_filename = None # Set by setup_network