Make validatepegin default to true if has parent chain

This commit is contained in:
Steven Roose 2019-03-21 14:39:45 +00:00
parent 3c8206a36c
commit aba54b3f92
No known key found for this signature in database
GPG key ID: 7FC91380BB4CE800
8 changed files with 8 additions and 6 deletions

View file

@ -529,7 +529,7 @@ void SetupServerArgs()
std::vector<std::string> elements_hidden_args = {"-con_fpowallowmindifficultyblocks", "-con_fpownoretargeting", "-con_nsubsidyhalvinginterval", "-con_bip16exception", "-con_bip34height", "-con_bip65height", "-con_bip66height", "-con_npowtargettimespan", "-con_npowtargetspacing", "-con_nrulechangeactivationthreshold", "-con_nminerconfirmationwindow", "-con_powlimit", "-con_bip34hash", "-con_nminimumchainwork", "-con_defaultassumevalid", "-npruneafterheight", "-fdefaultconsistencychecks", "-fmineblocksondemand", "-fallback_fee_enabled", "-pchmessagestart"};
gArgs.AddArg("-initialfreecoins", strprintf("The amount of OP_TRUE coins created in the genesis block. Primarily for testing. (default: %d)", 0), true, OptionsCategory::DEBUG_TEST);
gArgs.AddArg("-validatepegin", strprintf("Validate peg-in claims. An RPC connection will be attempted to the trusted bitcoind using the `mainchain*` settings below. All functionaries must run this enabled. (default: %u)", DEFAULT_VALIDATE_PEGIN), false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-validatepegin", "Validate peg-in claims. An RPC connection will be attempted to the trusted bitcoind using the `mainchain*` settings below. All functionaries must run this enabled. (default: true if chain has federated peg)", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-mainchainrpchost=<host>", "The address which the daemon will try to connect to the trusted bitcoind to validate peg-ins, if enabled. (default: 127.0.0.1)", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-mainchainrpcport=<n>", strprintf("The port which the daemon will try to connect to the trusted bitcoind to validate peg-ins, if enabled. (default: %u)", defaultBaseParams->MainchainRPCPort()), false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-mainchainrpcuser=<user>", "The rpc username that the daemon will use to connect to the trusted bitcoind to validate peg-ins, if enabled. (default: cookie auth)", false, OptionsCategory::ELEMENTS);

View file

@ -353,7 +353,7 @@ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& p
}
// Finally, validate peg-in via rpc call
if (check_depth && gArgs.GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
if (check_depth && gArgs.GetBoolArg("-validatepegin", Params().GetConsensus().has_parent_chain)) {
if (!IsConfirmedBitcoinBlock(block_hash, Params().GetConsensus().pegin_min_depth, num_txs)) {
err_msg = "Needs more confirmations.";
return false;

View file

@ -43,8 +43,6 @@ static const int MAX_STACK_SIZE = 1000;
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
// ELEMENTS:
// Validate pegin proof by checking Bitcoin transaction inclusion in mainchain.
static const bool DEFAULT_VALIDATE_PEGIN = false;
// Number of confirms on parent chain required to confirm on sidechain.
static const unsigned int DEFAULT_PEGIN_CONFIRMATION_DEPTH = 8;

View file

@ -67,6 +67,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::st
if (!fedpegscript.empty()) {
gArgs.SoftSetArg("-fedpegscript", fedpegscript);
gArgs.SoftSetBoolArg("-con_has_parent_chain", true);
gArgs.SoftSetBoolArg("-validatepegin", false);
}
// CreateAndProcessBlock() does not support building SegWit blocks, so don't activate in these tests.
// TODO: fix the code to support SegWit blocks.

View file

@ -5128,7 +5128,7 @@ bool BitcoindRPCCheck(const bool init)
pblocktree->WriteInvalidBlockQueue(vblocksToReconsider);
// Next, check for working and valid rpc
if (gArgs.GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
if (gArgs.GetBoolArg("-validatepegin", Params().GetConsensus().has_parent_chain)) {
// During init try until a non-RPC_IN_WARMUP result
while (true) {
try {

View file

@ -5239,7 +5239,7 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef
ret.pushKV("hex", strHex);
// Additional block lee-way to avoid bitcoin block races
if (gArgs.GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
if (gArgs.GetBoolArg("-validatepegin", Params().GetConsensus().has_parent_chain)) {
ret.pushKV("mature", IsConfirmedBitcoinBlock(merkleBlock.header.GetHash(), Params().GetConsensus().pegin_min_depth+2, merkleBlock.txn.GetNumTransactions()));
}

View file

@ -305,6 +305,8 @@ def initialize_datadir(dirname, n, chain):
# Elements:
f.write("con_blocksubsidy=5000000000\n")
f.write("con_connect_coinbase=0\n")
f.write("con_has_parent_chain=0\n")
f.write("parentgenesisblockhash=0\n")
f.write("anyonecanspendaremine=0\n")
f.write("con_blockheightinheader=0\n")
f.write("con_elementsmode=0\n")

View file

@ -319,6 +319,7 @@ def initialize_datadir(dirname, n, chain):
f.write("listenonion=0\n")
f.write("printtoconsole=0\n")
# Elements:
f.write("validatepegin=0\n")
f.write("con_parent_pegged_asset=" + BITCOIN_ASSET + "\n")
f.write("con_blocksubsidy=5000000000\n")
f.write("con_connect_coinbase=0\n")