Chainparams: Introduce -con_has_parent_chain option

This commit is contained in:
Jorge Timón 2018-07-18 01:13:45 +02:00
parent e991626ad6
commit 38dc2e71b6
No known key found for this signature in database
GPG key ID: 8866C18EA1C944A2
5 changed files with 14 additions and 2 deletions

View file

@ -23,7 +23,7 @@ REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
# list unsupported, deprecated and duplicate args as they need no documentation
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize'])
SET_DOC_OPTIONAL.update(['-con_fpowallowmindifficultyblocks', '-con_fpownoretargeting', '-con_nsubsidyhalvinginterval', '-con_bip34height', '-con_bip65height', '-con_bip66height', '-con_npowtargettimespan', '-con_npowtargetspacing', '-con_nrulechangeactivationthreshold', '-con_nminerconfirmationwindow', '-con_powlimit', '-con_parentpowlimit', '-con_bip34hash', '-con_nminimumchainwork', '-con_defaultassumevalid', '-parentgenesisblockhash', '-ndefaultport', '-npruneafterheight', '-fdefaultconsistencychecks', '-frequirestandard', '-fmineblocksondemand', '-mainchainrpccookiefile', '-testnet', '-ct_bits', '-ct_exponent', '-anyonecanspendaremine', '-fminingrequirespeers', '-fmineblocksondemand', '-con_mandatorycoinbase'])
SET_DOC_OPTIONAL.update(['-con_fpowallowmindifficultyblocks', '-con_fpownoretargeting', '-con_nsubsidyhalvinginterval', '-con_bip34height', '-con_bip65height', '-con_bip66height', '-con_npowtargettimespan', '-con_npowtargetspacing', '-con_nrulechangeactivationthreshold', '-con_nminerconfirmationwindow', '-con_powlimit', '-con_parentpowlimit', '-con_bip34hash', '-con_nminimumchainwork', '-con_defaultassumevalid', '-parentgenesisblockhash', '-ndefaultport', '-npruneafterheight', '-fdefaultconsistencychecks', '-frequirestandard', '-fmineblocksondemand', '-mainchainrpccookiefile', '-testnet', '-ct_bits', '-ct_exponent', '-anyonecanspendaremine', '-fminingrequirespeers', '-fmineblocksondemand', '-con_mandatorycoinbase', '-con_has_parent_chain'])
def main():
used = check_output(CMD_GREP_ARGS, shell=True)

View file

@ -56,7 +56,9 @@ class BlockSignTest(test_framework.BitcoinTestFramework):
signblockscript = make_signblockscript(num_nodes, required_signers, self.keys)
self.extra_args = [[
"-chain=blocksign",
# We can't validate pegins since we don't run the parent chain.
# We can't validate pegins since this chain doesn't have a parent chain
"-con_has_parent_chain=0",
"-parentgenesisblockhash=00",
"-validatepegin=0",
"-signblockscript={}".format(signblockscript)
]] * self.num_nodes

View file

@ -134,6 +134,10 @@ protected:
parentGenesisBlockHash = uint256S(GetArg("-parentgenesisblockhash", "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
initialFreeCoins = GetArg("-initialfreecoins", 0);
initial_reissuance_tokens = GetArg("-initialreissuancetokens", 0);
consensus.has_parent_chain = GetBoolArg("-con_has_parent_chain", true);
// Either it has a parent chain or not
const bool parent_genesis_is_null = parentGenesisBlockHash == uint256();
assert(consensus.has_parent_chain != parent_genesis_is_null);
const CScript default_script(CScript() << OP_TRUE);
consensus.signblockscript = StrHexToScriptWithDefault(GetArg("-signblockscript", ""), default_script);

View file

@ -72,6 +72,7 @@ struct Params {
uint32_t pegin_min_depth;
CScript mandatory_coinbase_destination;
CScript signblockscript;
bool has_parent_chain;
};
} // namespace Consensus

View file

@ -2442,6 +2442,11 @@ static bool CheckPeginTx(const std::vector<unsigned char>& tx_data, T& pegtx, co
bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& prevout, bool check_depth) {
// 0) Return false if !consensus.has_parent_chain
if (!Params().GetConsensus().has_parent_chain) {
return false;
}
// Format on stack is as follows:
// 1) value - the value of the pegin output
// 2) asset type - the asset type being pegged in