Skip to content

Commit aba54b3

Browse files
committed
Make validatepegin default to true if has parent chain
1 parent 3c8206a commit aba54b3

File tree

8 files changed

+8
-6
lines changed

8 files changed

+8
-6
lines changed

src/init.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ void SetupServerArgs()
529529
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"};
530530

531531
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);
532-
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);
532+
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);
533533
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);
534534
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);
535535
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);

src/pegins.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& p
353353
}
354354

355355
// Finally, validate peg-in via rpc call
356-
if (check_depth && gArgs.GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
356+
if (check_depth && gArgs.GetBoolArg("-validatepegin", Params().GetConsensus().has_parent_chain)) {
357357
if (!IsConfirmedBitcoinBlock(block_hash, Params().GetConsensus().pegin_min_depth, num_txs)) {
358358
err_msg = "Needs more confirmations.";
359359
return false;

src/script/script.h

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ static const int MAX_STACK_SIZE = 1000;
4343
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
4444

4545
// ELEMENTS:
46-
// Validate pegin proof by checking Bitcoin transaction inclusion in mainchain.
47-
static const bool DEFAULT_VALIDATE_PEGIN = false;
4846
// Number of confirms on parent chain required to confirm on sidechain.
4947
static const unsigned int DEFAULT_PEGIN_CONFIRMATION_DEPTH = 8;
5048

src/test/test_bitcoin.cpp

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

src/validation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5128,7 +5128,7 @@ bool BitcoindRPCCheck(const bool init)
51285128
pblocktree->WriteInvalidBlockQueue(vblocksToReconsider);
51295129

51305130
// Next, check for working and valid rpc
5131-
if (gArgs.GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
5131+
if (gArgs.GetBoolArg("-validatepegin", Params().GetConsensus().has_parent_chain)) {
51325132
// During init try until a non-RPC_IN_WARMUP result
51335133
while (true) {
51345134
try {

src/wallet/rpcwallet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5239,7 +5239,7 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef
52395239
ret.pushKV("hex", strHex);
52405240

52415241
// Additional block lee-way to avoid bitcoin block races
5242-
if (gArgs.GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) {
5242+
if (gArgs.GetBoolArg("-validatepegin", Params().GetConsensus().has_parent_chain)) {
52435243
ret.pushKV("mature", IsConfirmedBitcoinBlock(merkleBlock.header.GetHash(), Params().GetConsensus().pegin_min_depth+2, merkleBlock.txn.GetNumTransactions()));
52445244
}
52455245

test/bitcoin_functional/functional/test_framework/util.py

+2
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ def initialize_datadir(dirname, n, chain):
305305
# Elements:
306306
f.write("con_blocksubsidy=5000000000\n")
307307
f.write("con_connect_coinbase=0\n")
308+
f.write("con_has_parent_chain=0\n")
309+
f.write("parentgenesisblockhash=0\n")
308310
f.write("anyonecanspendaremine=0\n")
309311
f.write("con_blockheightinheader=0\n")
310312
f.write("con_elementsmode=0\n")

test/functional/test_framework/util.py

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ def initialize_datadir(dirname, n, chain):
319319
f.write("listenonion=0\n")
320320
f.write("printtoconsole=0\n")
321321
# Elements:
322+
f.write("validatepegin=0\n")
322323
f.write("con_parent_pegged_asset=" + BITCOIN_ASSET + "\n")
323324
f.write("con_blocksubsidy=5000000000\n")
324325
f.write("con_connect_coinbase=0\n")

0 commit comments

Comments
 (0)