Skip to content

Commit

Permalink
UNDO: Remove SigNetParams for being a special case
Browse files Browse the repository at this point in the history
signet chains, including the default can be just a concrete cases in custom chains
For example:

chain=signet
[signet]
con_signet_blocks=1
signet_blockscript=512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be43051ae
seednode=178.128.221.177
seednode=2a01:7c8:d005:390::5
seednode=ntv3mtqw5wt63red.onion:38333
  • Loading branch information
jtimon committed Sep 10, 2019
1 parent 38a6133 commit ba973ae
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 95 deletions.
83 changes: 0 additions & 83 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ static CBlock CreateGenesisBlockHashNonce(const uint256& hash, uint32_t block_no
return CreateGenesisBlock(coinbase_sig, genesis_out, 1534313275, block_nonce, 0x1e2adc28, 1, 50 * COIN);
}

static CBlock CreateSignetGenesisBlock(const std::string& chain_name, const CScript& block_script, uint32_t block_nonce)
{
CHashWriter h(SER_DISK, 0);
h << chain_name;
h << block_script;
return CreateGenesisBlockHashNonce(h.GetHash(), block_nonce);
}

static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CScript coinbase_sig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
Expand Down Expand Up @@ -271,78 +263,6 @@ class CTestNetParams : public CChainParams {
}
};

/**
* SigNet
*/
class SigNetParams : public CChainParams {
public:
SigNetParams(const ArgsManager& args) {

const std::string signet_blockscript_str = "512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be43051ae";
LogPrintf("Using default signet network (script: %s)\n", signet_blockscript_str);
vSeeds.clear();
vSeeds.emplace_back("178.128.221.177");
vSeeds.emplace_back("2a01:7c8:d005:390::5");
vSeeds.emplace_back("ntv3mtqw5wt63red.onion:38333");
std::vector<uint8_t> bin = ParseHex(signet_blockscript_str);
g_signet_blockscript = CScript(bin.begin(), bin.end());

strNetworkID = "signet";
consensus.signet_blocks = true;
consensus.nSubsidyHalvingInterval = 210000;
consensus.BIP34Height = 1;
consensus.BIP65Height = 1;
consensus.BIP66Height = 1;
consensus.CSVHeight = 0;
consensus.SegwitHeight = 0;
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 10 * 60;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1916;
consensus.nMinerConfirmationWindow = 2016;
consensus.powLimit = uint256S("00002adc28cf53b63c82faa55d83e40ac63b5f100aa5d8df62a429192f9e8ce5");
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1539478800;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;

pchMessageStart[0] = 0xf0;
pchMessageStart[1] = 0xc7;
pchMessageStart[2] = 0x70;
pchMessageStart[3] = 0x6a;
nDefaultPort = 38333;
nPruneAfterHeight = 1000;

genesis = CreateSignetGenesisBlock(strNetworkID, g_signet_blockscript, 621297);
consensus.hashGenesisBlock = genesis.GetHash();

// Now that genesis block has been generated, we check if there is an enforcescript, and switch
// to that one, as we will not be using the real block script anymore
if (args.IsArgSet("-signet_enforcescript")) {
if (args.GetArgs("-signet_enforcescript").size() != 1) {
throw std::runtime_error(strprintf("%s: -signet_enforcescript cannot be multiple values.", __func__));
}
bin = ParseHex(args.GetArgs("-signet_enforcescript")[0]);
g_signet_blockscript = CScript(bin.begin(), bin.end());
LogPrintf("SigNet enforce script %s\n", gArgs.GetArgs("-signet_enforcescript")[0]);
}

vFixedSeeds.clear();

base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>{125};
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>{87};
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>{217};
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};

bech32_hrp = "sb";

fDefaultConsistencyChecks = false;
fRequireStandard = true;
m_is_test_chain = true;
}
};

/**
* Regression test
*/
Expand Down Expand Up @@ -583,9 +503,6 @@ std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain)
return std::unique_ptr<CChainParams>(new CTestNetParams());
else if (chain == CBaseChainParams::REGTEST)
return std::unique_ptr<CChainParams>(new CRegTestParams(gArgs));
else if (chain == CBaseChainParams::SIGNET) {
return std::unique_ptr<CChainParams>(new SigNetParams(gArgs));
}

return std::unique_ptr<CChainParams>(new CCustomParams(chain, gArgs));
}
Expand Down
4 changes: 0 additions & 4 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

const std::string CBaseChainParams::MAIN = "main";
const std::string CBaseChainParams::TESTNET = "test";
const std::string CBaseChainParams::SIGNET = "signet";
const std::string CBaseChainParams::REGTEST = "regtest";

void SetupChainParamsBaseOptions()
Expand All @@ -22,7 +21,6 @@ void SetupChainParamsBaseOptions()
gArgs.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-signet", "Use the default signet chain. Note that the network is defined by the signet_blockscript parameter. equivalent to -chain=signet.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-signet_blockscript", "Blocks must satisfy the given script to be considered valid. If not set, the chain is not considered a signet chain. (custom only)", ArgsManager::ALLOW_STRING, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-signet_enforcescript", "Blocks must satisfy the given script to be considered valid (this replaces -signet_blockscript, and is used for opt-in-reorg mode, custom or signet only)", ArgsManager::ALLOW_STRING, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest or custom only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
Expand Down Expand Up @@ -75,8 +73,6 @@ std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain
return MakeUnique<CBaseChainParams>("testnet3", 18332);
else if (chain == CBaseChainParams::REGTEST)
return MakeUnique<CBaseChainParams>("regtest", 18443);
else if (chain == CBaseChainParams::SIGNET)
return MakeUnique<CBaseChainParams>("signet", 38332);

return MakeUnique<CBaseChainParams>(chain, 18553);
}
Expand Down
1 change: 0 additions & 1 deletion src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class CBaseChainParams
/** BIP70 chain name strings (main, test, signet or regtest) */
static const std::string MAIN;
static const std::string TESTNET;
static const std::string SIGNET;
static const std::string REGTEST;

const std::string& DataDir() const { return strDataDir; }
Expand Down
2 changes: 1 addition & 1 deletion src/test/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
// Results file is formatted like:
//
// <input> || <output>
BOOST_CHECK_EQUAL(out_sha_hex, "c6856c9f644482552b3c78ae3d5bcfeb51983de918606c564bffafac61d09d1d");
BOOST_CHECK_EQUAL(out_sha_hex, "40e5f92b19fc43eaa06eae257b366c449c0f3fd57e46894850a54aed785a19fc");
}

BOOST_AUTO_TEST_CASE(util_FormatMoney)
Expand Down
9 changes: 3 additions & 6 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,19 +941,16 @@ std::string ArgsManager::GetChainName() const
LOCK(cs_args);
bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest");
bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet");
bool signet = ArgsManagerHelper::GetNetBoolArg(*this, "-signet");
const bool is_chain_arg_set = IsArgSet("-chain");

if ((int)is_chain_arg_set + (int)fTestNet + (int)fRegTest + (int)signet > 1) {
throw std::runtime_error("Invalid combination of -regtest, -testnet, -signet and -chain. Can use at most one");
if ((int)is_chain_arg_set + (int)fTestNet + (int)fRegTest > 1) {
throw std::runtime_error("Invalid combination of -regtest, -testnet and -chain. Can use at most one");
}
if (fRegTest)
return CBaseChainParams::REGTEST;
if (fTestNet)
return CBaseChainParams::TESTNET;
if (signet) {
return CBaseChainParams::SIGNET;
}

return GetArg("-chain", CBaseChainParams::MAIN);
}

Expand Down

0 comments on commit ba973ae

Please sign in to comment.