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
Conversation
…or halving height
…or halving height
… py test for halving chan height
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"); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/consensus/params.h
Outdated
@@ -55,9 +55,6 @@ struct Params { | |||
*/ | |||
int SubsidySlowStartShift() const { return nSubsidySlowStartInterval / 2; } | |||
int nSubsidyHalvingInterval; | |||
int _deprecatedGetLastCommunityRewardBlockHeight() const { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") ) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
self.rpc = rpc | ||
|
||
def show_debug_msg(self, msg): | ||
#print msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…and added relevant privkey in comments
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") ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not useful on testnet
There was a problem hiding this comment.
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") ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
To be rebased on top of current development to make a new CI run pass, ready to be merged once CI passes. |
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