diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -143,7 +143,7 @@ consensus.axionHeight = 661647; // May 15, 2022 12:00:00 UTC protocol upgrade - consensus.gluonActivationTime = 1652616000; + consensus.gluonHeight = 739535; // Nov 15, 2022 12:00:00 UTC protocol upgrade consensus.jeffersonActivationTime = 1668513600; @@ -307,7 +307,7 @@ consensus.axionHeight = 1421481; // May 15, 2022 12:00:00 UTC protocol upgrade - consensus.gluonActivationTime = 1652616000; + consensus.gluonHeight = 1503556; // Nov 15, 2022 12:00:00 UTC protocol upgrade consensus.jeffersonActivationTime = 1668513600; @@ -448,7 +448,7 @@ consensus.axionHeight = 0; // May 15, 2022 12:00:00 UTC protocol upgrade - consensus.gluonActivationTime = 1652616000; + consensus.gluonHeight = 0; // Nov 15, 2022 12:00:00 UTC protocol upgrade consensus.jeffersonActivationTime = 1668513600; diff --git a/src/consensus/activation.cpp b/src/consensus/activation.cpp --- a/src/consensus/activation.cpp +++ b/src/consensus/activation.cpp @@ -88,12 +88,15 @@ return IsAxionEnabled(params, pindexPrev->nHeight); } +static bool IsGluonEnabled(const Consensus::Params ¶ms, int32_t nHeight) { + return nHeight >= params.gluonHeight; +} + bool IsGluonEnabled(const Consensus::Params ¶ms, const CBlockIndex *pindexPrev) { if (pindexPrev == nullptr) { return false; } - return pindexPrev->GetMedianTimePast() >= - gArgs.GetIntArg("-gluonactivationtime", params.gluonActivationTime); + return IsGluonEnabled(params, pindexPrev->nHeight); } diff --git a/src/consensus/params.h b/src/consensus/params.h --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -82,8 +82,8 @@ int phononHeight; /** Block height at which the axion activation becomes active */ int axionHeight; - /** Unix time used for MTP activation of 15 May 2022 12:00:00 UTC upgrade */ - int gluonActivationTime; + /** Block height at which the gluon activation becomes active */ + int gluonHeight; /** Unix time used for MTP activation of 15 Nov 2022 12:00:00 UTC upgrade */ int jeffersonActivationTime; /** Unix time used for MTP activation of 15 May 2023 12:00:00 UTC upgrade */ diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -427,8 +427,6 @@ "-rootcertificates=", "-splash", "-uiplatform", - // TODO remove after the May 2022 upgrade - "-gluonactivationtime", }; // Set all of the args and their help diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -270,10 +270,11 @@ "--run_test=${_test_name}" "--logger=${HRF_LOGGER}${JUNIT_LOGGER}" "--catch_system_errors=no" - # Dec. 1st, 2019 at 00:00:00 -- "-testsuitename=Bitcoin ABC unit tests with next upgrade activated" - -gluonactivationtime=1644922800 + # TODO This needs to be updated to match next upgrade + # Dec. 1st, 2019 at 00:00:00 + # -gluonactivationtime=1644922800 ) endforeach() endfunction() diff --git a/src/test/activation_tests.cpp b/src/test/activation_tests.cpp --- a/src/test/activation_tests.cpp +++ b/src/test/activation_tests.cpp @@ -13,7 +13,8 @@ BOOST_FIXTURE_TEST_SUITE(activation_tests, BasicTestingSetup) -static void SetMTP(std::array &blocks, int64_t mtp) { +[[maybe_unused]] static void SetMTP(std::array &blocks, + int64_t mtp) { size_t len = blocks.size(); for (size_t i = 0; i < len; ++i) { @@ -48,30 +49,7 @@ testPastActivation(IsGravitonEnabled, consensus, consensus.gravitonHeight); testPastActivation(IsPhononEnabled, consensus, consensus.phononHeight); testPastActivation(IsAxionEnabled, consensus, consensus.axionHeight); -} - -BOOST_AUTO_TEST_CASE(isgluonenabled) { - const Consensus::Params ¶ms = Params().GetConsensus(); - const auto activation = - gArgs.GetIntArg("-gluonactivationtime", params.gluonActivationTime); - SetMockTime(activation - 1000000); - - BOOST_CHECK(!IsGluonEnabled(params, nullptr)); - - std::array blocks; - for (size_t i = 1; i < blocks.size(); ++i) { - blocks[i].pprev = &blocks[i - 1]; - } - BOOST_CHECK(!IsGluonEnabled(params, &blocks.back())); - - SetMTP(blocks, activation - 1); - BOOST_CHECK(!IsGluonEnabled(params, &blocks.back())); - - SetMTP(blocks, activation); - BOOST_CHECK(IsGluonEnabled(params, &blocks.back())); - - SetMTP(blocks, activation + 1); - BOOST_CHECK(IsGluonEnabled(params, &blocks.back())); + testPastActivation(IsGluonEnabled, consensus, consensus.gluonHeight); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/functional/abc_feature_minerfund.py b/test/functional/abc_feature_minerfund.py --- a/test/functional/abc_feature_minerfund.py +++ b/test/functional/abc_feature_minerfund.py @@ -13,12 +13,9 @@ from test_framework.txtools import pad_tx from test_framework.util import assert_equal, assert_greater_than_or_equal -GLUON_ACTIVATION_TIME = 2100000600 - MINER_FUND_RATIO = 8 - -MINER_FUND_ADDR_AXION = 'ecregtest:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgz0wv9ltl' MINER_FUND_ADDR = 'ecregtest:prfhcnyqnl5cgrnmlfmms675w93ld7mvvq9jcw0zsn' +MINER_FUND_ADDR_AXION = 'ecregtest:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgz0wv9ltl' class MinerFundTest(BitcoinTestFramework): @@ -27,7 +24,6 @@ self.num_nodes = 1 self.extra_args = [[ '-enableminerfund', - '-gluonactivationtime={}'.format(GLUON_ACTIVATION_TIME), ]] def run_test(self): @@ -49,16 +45,6 @@ assert_greater_than_or_equal(len(coinbase['vout']), 2) block_reward = sum([vout['value'] for vout in coinbase['vout']]) - # Move MTP forward to gluon activation - node.setmocktime(GLUON_ACTIVATION_TIME) - node.generatetoaddress(6, address) - assert_equal( - node.getblockchaininfo()['mediantime'], - GLUON_ACTIVATION_TIME) - - # Let's remember the hash of this block for later use. - gluon_fork_block_hash = int(node.getbestblockhash(), 16) - def check_miner_fund_output(expected_address): coinbase = get_best_coinbase() assert_equal(len(coinbase['vout']), 2) @@ -75,28 +61,24 @@ coinbase['vout'][1]['value'], (MINER_FUND_RATIO * total) / 100) - # The coinbase has an output to the legacy miner fund address + # The coinbase has an output to the miner fund address. # Now we send part of the coinbase to the fund. - check_miner_fund_output(MINER_FUND_ADDR_AXION) - - # First block with the miner fund address. - node.generatetoaddress(1, address) check_miner_fund_output(MINER_FUND_ADDR) - # Invalidate top block. - node.invalidateblock(node.getbestblockhash()) - - def check_bad_miner_fund(prev_hash, time, coinbase=None): + def check_bad_miner_fund(prev_hash, coinbase=None): if coinbase is None: coinbase = create_coinbase(node.getblockcount() + 1) - block = create_block(prev_hash, coinbase, time, version=4) + block_time = node.getblock(prev_hash)['time'] + 1 + block = create_block(int(prev_hash, 16), + coinbase, block_time, version=4) block.solve() assert_equal(node.submitblock(ToHex(block)), 'bad-cb-minerfund') # A block with no miner fund coinbase should be rejected. - check_bad_miner_fund(gluon_fork_block_hash, GLUON_ACTIVATION_TIME + 1) + tip = node.getbestblockhash() + check_bad_miner_fund(tip) def create_cb_pay_to_address(address): _, _, script_hash = decode(address) @@ -122,16 +104,15 @@ # Build a custom coinbase that spend to the legacy miner fund address # and check it is rejected. check_bad_miner_fund( - gluon_fork_block_hash, - GLUON_ACTIVATION_TIME + 1, + tip, create_cb_pay_to_address(MINER_FUND_ADDR_AXION)) # Build a custom coinbase that spend to the new miner fund address # and check it is accepted. good_block = create_block( - gluon_fork_block_hash, + int(tip, 16), create_cb_pay_to_address(MINER_FUND_ADDR), - GLUON_ACTIVATION_TIME + 1, + node.getblock(tip)['time'] + 1, version=4) good_block.solve() diff --git a/test/functional/abc_mining_basic.py b/test/functional/abc_mining_basic.py --- a/test/functional/abc_mining_basic.py +++ b/test/functional/abc_mining_basic.py @@ -6,8 +6,6 @@ Tests for Bitcoin ABC mining RPCs """ -from decimal import Decimal - from test_framework.cdefs import ( BLOCK_MAXBYTES_MAXSIGCHECKS_RATIO, DEFAULT_MAX_BLOCK_SIZE, @@ -17,13 +15,8 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_greater_than_or_equal -GLUON_ACTIVATION_TIME = 2100000600 - -MINER_FUND_ADDR_AXION = 'ecregtest:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgz0wv9ltl' -MINER_FUND_LEGACY_ADDR_AXION = '2MviGxxFciGeWTgkUgYgjqehWt18c4ZsShd' - -MINER_FUND_ADDR_GLUON = 'ecregtest:prfhcnyqnl5cgrnmlfmms675w93ld7mvvq9jcw0zsn' -MINER_FUND_LEGACY_ADDR_GLUON = '2NCXTUCFd1Q3EteVpVVDTrBBoKqvMPAoeEn' +MINER_FUND_ADDR = 'ecregtest:prfhcnyqnl5cgrnmlfmms675w93ld7mvvq9jcw0zsn' +MINER_FUND_LEGACY_ADDR = '2NCXTUCFd1Q3EteVpVVDTrBBoKqvMPAoeEn' class AbcMiningRPCTest(BitcoinTestFramework): @@ -32,11 +25,9 @@ self.extra_args = [ [ '-enableminerfund', - '-gluonactivationtime={}'.format(GLUON_ACTIVATION_TIME), ], [ '-enableminerfund', '-usecashaddr=0', - '-gluonactivationtime={}'.format(GLUON_ACTIVATION_TIME), ], ] * 2 @@ -44,15 +35,12 @@ self.setup_nodes() # Don't connect the nodes - def run_for_node(self, node, beforedMinerFundAddress, - afterMinerFundAddress): + def run_for_node(self, node, minerFundAddress): # Connect to a peer so getblocktemplate will return results # (getblocktemplate has a sanity check that ensures it's connected to a # network). node.add_p2p_connection(P2PInterface()) - address = node.get_deterministic_priv_key().address - # Assert the results of getblocktemplate have expected values. Keys not # in 'expected' are not checked. def assert_getblocktemplate(expected): @@ -65,10 +53,6 @@ for key, value in expected.items(): assert_equal(blockTemplate[key], value) - # Move block time to just before axion activation - node.setmocktime(GLUON_ACTIVATION_TIME) - node.generatetoaddress(5, address) - def get_best_coinbase(): return node.getblock(node.getbestblockhash(), 2)['tx'][0] @@ -76,30 +60,11 @@ assert_greater_than_or_equal(len(coinbase['vout']), 2) block_reward = sum([vout['value'] for vout in coinbase['vout']]) - assert_getblocktemplate({ - 'coinbasetxn': { - 'minerfund': { - 'addresses': [beforedMinerFundAddress], - 'minimumvalue': block_reward * 8 // 100 * XEC, - }, - }, - }) - - # Move MTP forward to activation - node.generatetoaddress(1, address) - assert_equal( - node.getblockchaininfo()['mediantime'], - GLUON_ACTIVATION_TIME) - - # We don't need to test all fields in getblocktemplate since many of - # them are covered in mining_basic.py assert_equal(node.getmempoolinfo()['size'], 0) assert_getblocktemplate({ 'coinbasetxn': { - # We expect to start seeing the miner fund addresses since the - # next block will start enforcing them. 'minerfund': { - 'addresses': [afterMinerFundAddress], + 'addresses': [minerFundAddress], 'minimumvalue': block_reward * 8 // 100 * XEC, }, }, @@ -108,55 +73,17 @@ # since we are not crossing a halving boundary and there are no # transactions in the mempool. 'coinbasevalue': block_reward * XEC, - 'mintime': GLUON_ACTIVATION_TIME + 1, - }) - - # First block with the new rules - node.generatetoaddress(1, address) - - # We expect the coinbase to have multiple outputs now - coinbase = get_best_coinbase() - assert_greater_than_or_equal(len(coinbase['vout']), 2) - total = Decimal() - for o in coinbase['vout']: - total += o['value'] - - assert_equal(total, block_reward) - assert_getblocktemplate({ - 'coinbasetxn': { - 'minerfund': { - 'addresses': [afterMinerFundAddress], - 'minimumvalue': block_reward * 8 // 100 * XEC, - }, - }, - # Again, we assume the coinbase value is the same as prior blocks. - 'coinbasevalue': block_reward * XEC, - 'mintime': GLUON_ACTIVATION_TIME + 1, - }) - - # Move MTP forward - node.setmocktime(GLUON_ACTIVATION_TIME + 1) - node.generatetoaddress(6, address) - assert_getblocktemplate({ - 'coinbasetxn': { - 'minerfund': { - 'addresses': [afterMinerFundAddress], - 'minimumvalue': block_reward * 8 // 100 * XEC, - }, - }, - 'coinbasevalue': block_reward * XEC, - 'mintime': GLUON_ACTIVATION_TIME + 2, }) def run_test(self): self.run_for_node( self.nodes[0], - MINER_FUND_ADDR_AXION, - MINER_FUND_ADDR_GLUON) + MINER_FUND_ADDR, + ) self.run_for_node( self.nodes[1], - MINER_FUND_LEGACY_ADDR_AXION, - MINER_FUND_LEGACY_ADDR_GLUON) + MINER_FUND_LEGACY_ADDR, + ) if __name__ == '__main__': diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -467,9 +467,11 @@ use_valgrind=self.options.valgrind, descriptors=self.options.descriptors, )) - if self.options.gluonactivation: - self.nodes[i].extend_default_args( - ["-gluonactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) + + # TODO This needs to be updated to match the next upgrade + # if self.options.gluonactivation: + # self.nodes[i].extend_default_args( + # ["-gluonactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) def start_node(self, i, *args, **kwargs): """Start a bitcoind""" @@ -748,9 +750,10 @@ emulator=self.options.emulator, )) - if self.options.gluonactivation: - self.nodes[CACHE_NODE_ID].extend_default_args( - ["-gluonactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) + # TODO This needs to be updated to match the next upgrade + # if self.options.gluonactivation: + # self.nodes[CACHE_NODE_ID].extend_default_args( + # ["-gluonactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) self.start_node(CACHE_NODE_ID) cache_node = self.nodes[CACHE_NODE_ID] diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -53,8 +53,6 @@ '-automaticunparking', # Removed arguments that now just print a helpful error message '-zapwallettxes', - # Remove after May 2022 upgrade - '-gluonactivationtime', '-replayprotectionactivationtime', ])