Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As/test halving + minor bug fixing #342

Merged
merged 16 commits into from Mar 22, 2021
Merged

As/test halving + minor bug fixing #342

merged 16 commits into from Mar 22, 2021

Conversation

alsala
Copy link
Contributor

@alsala alsala commented Oct 28, 2020

Added regtest only option for setting halving period; added a new py test for verifying coinbase subsidy amounts and halving height crossing; minor bug fixes

src/init.cpp Outdated
__func__, __LINE__, Params().GetConsensus().nSubsidyHalvingInterval);

// the first halving must be at least as the fork2 value, which is 101 in regtest
if (val <= 100) assert(!"subsidyhalvinginterval must be greater than 100");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than hardcoding value 100, use something like zen::ReplayProtectionFork.getHeight(CBaseChainParams::REGTEST)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -55,9 +55,6 @@ struct Params {
*/
int SubsidySlowStartShift() const { return nSubsidySlowStartInterval / 2; }
int nSubsidyHalvingInterval;
int _deprecatedGetLastCommunityRewardBlockHeight() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't move this out of consensus/params.h into chainparams.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, reverted back

@@ -6891,7 +6897,7 @@ int getCheckBlockAtHeightMinAge()

static bool getInitRequireStandard()
{
if ( (Params().NetworkIDString() == "regtest") || (Params().NetworkIDString() == "testnet") )
if ( (Params().NetworkIDString() == "regtest") || (Params().NetworkIDString() == "test") )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an actual bug which does not allow accepting non-standard tx in testnet!
Same for changes above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

src/main.cpp Outdated
if (output.scriptPubKey == Params().GetCommunityFundScriptAtHeight(nHeight, cfType)) {
BOOST_FOREACH(const CTxOut& output, block.vtx[0].vout)
{
if (output.scriptPubKey == refScript) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are going to change this, we may as well aggregate these two ifs together, rather than nesting them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/zen/forks/fork4_nulltransactionfork.cpp Outdated Show resolved Hide resolved
self.rpc = rpc

def show_debug_msg(self, msg):
#print msg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -1457,6 +1472,7 @@ def send_message(self, message, pushbuf=False):
if self.state != "connected" and not pushbuf:
return
self.show_debug_msg("Send %s" % repr(message))
#print "\n---> Sending %s\n" % repr(message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -30,6 +30,7 @@
from threading import Thread
import logging
import copy
import time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look unused really. If so, remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@abi87 abi87 changed the title As/test halving As/test halving + minor bug fixing Oct 30, 2020
qa/rpc-tests/test_framework/blocktools.py Outdated Show resolved Hide resolved
@alsala alsala removed the request for review from VolodymyrBabaiev November 5, 2020 15:38
src/main.cpp Outdated
@@ -6855,7 +6859,7 @@ bool getHeadersIsOnMain(const CBlockLocator& locator, const uint256& hashStop, C

static int getInitCbhSafeDepth()
{
if ( (Params().NetworkIDString() == "regtest") || (Params().NetworkIDString() == "testnet") )
if ( (Params().NetworkIDString() == "regtest") || (Params().NetworkIDString() == "test") )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not useful on testnet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, removed

src/main.cpp Outdated
@@ -6873,7 +6877,7 @@ int getCheckBlockAtHeightSafeDepth()

static int getInitCbhMinAge()
{
if ( (Params().NetworkIDString() == "regtest") || (Params().NetworkIDString() == "testnet") )
if ( (Params().NetworkIDString() == "regtest") || (Params().NetworkIDString() == "test") )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

assert_equal(cb_subsidy, cb_subsidy_pre_halving)

print "---> Make sure that a block with pre-halving subsidy is rejected."
block3 = create_block(self.tip, create_coinbase_h(chainHeight+1), self.block_time, get_nBits(chainHeight))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block3 = create_block(self.tip, create_coinbase_h(chainHeight+1, SUBS_HALV_INTERVAL +1 /*force not trigger halving */), self.block_time, get_nBits(chainHeight))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cronicc
Copy link
Member

cronicc commented Feb 10, 2021

To be rebased on top of current development to make a new CI run pass, ready to be merged once CI passes.

@cronicc cronicc merged commit f963370 into development Mar 22, 2021
@lander86 lander86 deleted the as/test_halving branch April 5, 2022 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants