Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dsnotificationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
llmq::quorumManager->UpdatedBlockTip(pindexNew, fInitialDownload);
llmq::quorumDKGSessionManager->UpdatedBlockTip(pindexNew, fInitialDownload);

if (!fLiteMode) governance.UpdatedBlockTip(pindexNew, connman);
if (!fDisableGovernance) governance.UpdatedBlockTip(pindexNew, connman);
}

void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx, int64_t nAcceptTime)
Expand Down
5 changes: 2 additions & 3 deletions src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ bool CGovernanceManager::SerializeVoteForHash(const uint256& nHash, CDataStream&

void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman, bool enable_bip61)
{
// lite mode is not supported
if (fLiteMode) return;
if (fDisableGovernance) return;
if (!masternodeSync.IsBlockchainSynced()) return;

// ANOTHER USER IS ASKING US TO HELP THEM SYNC GOVERNANCE OBJECT DATA
Expand Down Expand Up @@ -547,7 +546,7 @@ struct sortProposalsByVotes {

void CGovernanceManager::DoMaintenance(CConnman& connman)
{
if (fLiteMode || !masternodeSync.IsSynced() || ShutdownRequested()) return;
if (fDisableGovernance || !masternodeSync.IsSynced() || ShutdownRequested()) return;

// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES

Expand Down
32 changes: 20 additions & 12 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void PrepareShutdown()
flatdb4.Dump(netfulfilledman);
CFlatDB<CSporkManager> flatdb6("sporks.dat", "magicSporkCache");
flatdb6.Dump(sporkManager);
if (!fLiteMode) {
if (!fDisableGovernance) {
CFlatDB<CGovernanceManager> flatdb3("governance.dat", "magicGovernanceCache");
flatdb3.Dump(governance);
}
Expand Down Expand Up @@ -617,7 +617,7 @@ std::string HelpMessage(HelpMessageMode mode)
}
strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on client startup (default: 1 when no -debug)"));
AppendParamsHelpMessages(strUsage, showDebug);
strUsage += HelpMessageOpt("-litemode", strprintf(_("Disable governance validation (0-1, default: %u)"), 0));
strUsage += HelpMessageOpt("-disablegovernance", strprintf(_("Disable governance validation (0-1, default: %u)"), 0));
strUsage += HelpMessageOpt("-sporkaddr=<dashaddress>", strprintf(_("Override spork address. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.")));
strUsage += HelpMessageOpt("-minsporkkeys=<n>", strprintf(_("Overrides minimum spork signers to change spork value. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.")));

Expand Down Expand Up @@ -1199,6 +1199,14 @@ bool AppInitParameterInteraction()
if (gArgs.IsArgSet("-blockminsize"))
InitWarning("Unsupported argument -blockminsize ignored.");

if (gArgs.GetBoolArg("-litemode", false)) {
InitWarning(_("Warning: -litemode is deprecated, please use -disablegovernance.\n"));
if (gArgs.SoftSetBoolArg("-disablegovernance", true)) {
LogPrintf("%s: parameter interaction: -litemode=true -> setting -disablegovernance=true\n", __func__);
}
gArgs.ForceRemoveArg("-litemode");
}

// Checkmempool and checkblockindex default to true in regtest mode
int ratio = std::min<int>(std::max<int>(gArgs.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
if (ratio != 0) {
Expand Down Expand Up @@ -1505,8 +1513,8 @@ bool AppInitParameterInteraction()
if (gArgs.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) < DEFAULT_MAX_PEER_CONNECTIONS) {
return InitError(strprintf("Masternode must be able to handle at least %d connections, set -maxconnections=%d", DEFAULT_MAX_PEER_CONNECTIONS, DEFAULT_MAX_PEER_CONNECTIONS));
}
if (gArgs.GetBoolArg("-litemode", false)) {
return InitError(_("You can not start a masternode in lite mode."));
if (gArgs.GetBoolArg("-disablegovernance", false)) {
return InitError(_("You can not disable governance validation on a masternode."));
}
}

Expand Down Expand Up @@ -1782,11 +1790,11 @@ bool AppInitMain()
// ********************************************************* Step 7a: check lite mode and load sporks

// lite mode disables governance validation
fLiteMode = gArgs.GetBoolArg("-litemode", false);
LogPrintf("fLiteMode %d\n", fLiteMode);
fDisableGovernance = gArgs.GetBoolArg("-disablegovernance", false);
LogPrintf("fDisableGovernance %d\n", fDisableGovernance);

if(fLiteMode) {
InitWarning(_("You are starting in lite mode, governance validation is disabled."));
if(fDisableGovernance) {
InitWarning(_("You are starting with governance validation disabled."));
}

uiInterface.InitMessage(_("Loading sporks cache..."));
Expand Down Expand Up @@ -1866,9 +1874,9 @@ bool AppInitMain()
break;
}

if (!fLiteMode && !fTxIndex
if (!fDisableGovernance && !fTxIndex
&& chainparams.NetworkIDString() != CBaseChainParams::REGTEST) { // TODO remove this when pruning is fixed. See https://github.com/dashpay/dash/pull/1817 and https://github.com/dashpay/dash/pull/1743
return InitError(_("Transaction index can't be disabled in full mode. Either start with -litemode command line switch or enable transaction index."));
return InitError(_("Transaction index can't be disabled with governance validation enabled. Either start with -disablegovernance command line switch or enable transaction index."));
}

// If the loaded chain has a wrong genesis, bail out immediately
Expand Down Expand Up @@ -2134,7 +2142,7 @@ bool AppInitMain()
strDBName = "governance.dat";
uiInterface.InitMessage(_("Loading governance cache..."));
CFlatDB<CGovernanceManager> flatdb3(strDBName, "magicGovernanceCache");
if (fLoadCacheFiles && !fLiteMode) {
if (fLoadCacheFiles && !fDisableGovernance) {
if(!flatdb3.Load(governance)) {
return InitError(_("Failed to load governance cache from") + "\n" + (pathDB / strDBName).string());
}
Expand Down Expand Up @@ -2166,7 +2174,7 @@ bool AppInitMain()
scheduler.scheduleEvery(boost::bind(&CMasternodeSync::DoMaintenance, boost::ref(masternodeSync), boost::ref(*g_connman)), 1 * 1000);
scheduler.scheduleEvery(boost::bind(&CMasternodeUtils::DoMaintenance, boost::ref(*g_connman)), 1 * 1000);

if (!fLiteMode) {
if (!fDisableGovernance) {
scheduler.scheduleEvery(boost::bind(&CGovernanceManager::DoMaintenance, boost::ref(governance), boost::ref(*g_connman)), 60 * 5 * 1000);
}

Expand Down
4 changes: 2 additions & 2 deletions src/masternode/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ bool IsBlockValueValid(const CBlock& block, int nBlockHeight, CAmount blockRewar
return false;
}

if(!masternodeSync.IsSynced() || fLiteMode) {
if(!masternodeSync.IsSynced() || fDisableGovernance) {
LogPrint(BCLog::MNPAYMENTS, "%s -- WARNING: Not enough data, checked superblock max bounds only\n", __func__);
// not enough data for full checks but at least we know that the superblock limits were honored.
// We rely on the network to have followed the correct chain in this case
Expand Down Expand Up @@ -161,7 +161,7 @@ bool IsBlockValueValid(const CBlock& block, int nBlockHeight, CAmount blockRewar

bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward)
{
if(fLiteMode) {
if(fDisableGovernance) {
//there is no budget data to use to check anything, let's just accept the longest chain
LogPrint(BCLog::MNPAYMENTS, "%s -- WARNING: Not enough data, skipping block payee checks\n", __func__);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/masternode/masternode-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
// GOVOBJ : SYNC GOVERNANCE ITEMS FROM OUR PEERS

if(nCurrentAsset == MASTERNODE_SYNC_GOVERNANCE) {
if (fLiteMode) {
if (fDisableGovernance) {
SwitchToNextAsset(connman);
connman.ReleaseNodeVector(vNodesCopy);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
tooltip += QString("<br>");
tooltip += tr("Transactions after this will not yet be visible.");
} else if (fLiteMode) {
} else if (fDisableGovernance) {
setAdditionalDataSyncProgress(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const int64_t nStartupTime = GetTime();

//Dash only features
bool fMasternodeMode = false;
bool fLiteMode = false;
bool fDisableGovernance = false;
/**
nWalletBackups:
1..10 - number of automatic backups to keep
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//Dash only features

extern bool fMasternodeMode;
extern bool fLiteMode;
extern bool fDisableGovernance;
extern int nWalletBackups;

// Application startup time (used for uptime calculation)
Expand Down
18 changes: 9 additions & 9 deletions test/functional/pruning.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def set_test_params(self):
# Create nodes 5 to test wallet in prune mode, but do not connect
self.extra_args = [self.full_node_default_args,
self.full_node_default_args,
["-litemode","-txindex=0","-maxreceivebuffer=20000","-prune=550"],
["-litemode","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"],
["-litemode","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"],
["-litemode","-txindex=0","-prune=550"]]
["-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-prune=550"],
["-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"],
["-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"],
["-disablegovernance","-txindex=0","-prune=550"]]

def setup_network(self):
self.setup_nodes()
Expand Down Expand Up @@ -223,14 +223,14 @@ def reorg_back(self):

def manual_test(self, node_number, use_timestamp):
# at this point, node has 995 blocks and has not yet run in prune mode
self.start_node(node_number, extra_args=["-litemode", "-txindex=0"])
self.start_node(node_number, extra_args=["-disablegovernance", "-txindex=0"])
node = self.nodes[node_number]
assert_equal(node.getblockcount(), 995)
assert_raises_rpc_error(-1, "not in prune mode", node.pruneblockchain, 500)

# now re-start in manual pruning mode
self.stop_node(node_number)
self.start_node(node_number, extra_args=["-litemode", "-txindex=0", "-prune=1"])
self.start_node(node_number, extra_args=["-disablegovernance", "-txindex=0", "-prune=1"])
node = self.nodes[node_number]
assert_equal(node.getblockcount(), 995)

Expand Down Expand Up @@ -312,15 +312,15 @@ def has_block(index):

# stop node, start back up with auto-prune at 550MB, make sure still runs
self.stop_node(node_number)
self.start_node(node_number, extra_args=["-litemode", "-txindex=0", "-prune=550"])
self.start_node(node_number, extra_args=["-disablegovernance", "-txindex=0", "-prune=550"])

self.log.info("Success")

def wallet_test(self):
# check that the pruning node's wallet is still in good shape
self.log.info("Stop and start pruning node to trigger wallet rescan")
self.stop_node(2)
self.start_node(2, extra_args=["-litemode", "-txindex=0", "-prune=550"])
self.start_node(2, extra_args=["-disablegovernance", "-txindex=0", "-prune=550"])
self.log.info("Success")

# check that wallet loads successfully when restarting a pruned node after IBD.
Expand All @@ -330,7 +330,7 @@ def wallet_test(self):
nds = [self.nodes[0], self.nodes[5]]
self.sync_blocks(nds, wait=5, timeout=300)
self.stop_node(5) #stop and start to trigger rescan
self.start_node(5, extra_args=["-litemode", "-txindex=0", "-prune=550"])
self.start_node(5, extra_args=["-disablegovernance", "-txindex=0", "-prune=550"])
self.log.info("Success")

def run_test(self):
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
EXTENDED_SCRIPTS = [
# These tests are not run by the travis build process.
# Longest test should go first, to favor running tests in parallel
'pruning.py', # NOTE: Prune mode is incompatible with -txindex, should work in litemode though.
'pruning.py', # NOTE: Prune mode is incompatible with -txindex, should work governance validation disabled though.
# vv Tests less than 20m vv
'smartfees.py',
# vv Tests less than 5m vv
Expand Down