Skip to content

Commit fa62304

Browse files
author
MarcoFalke
committed
Remove dead CheckForkWarningConditionsOnNewFork
1 parent 218fe60 commit fa62304

File tree

3 files changed

+5
-84
lines changed

3 files changed

+5
-84
lines changed

src/validation.cpp

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,8 +1312,6 @@ bool CChainState::IsInitialBlockDownload() const
13121312
return false;
13131313
}
13141314

1315-
static CBlockIndex *pindexBestForkTip = nullptr, *pindexBestForkBase = nullptr;
1316-
13171315
static void AlertNotify(const std::string& strMessage)
13181316
{
13191317
uiInterface.NotifyAlertChanged();
@@ -1342,72 +1340,17 @@ static void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
13421340
if (::ChainstateActive().IsInitialBlockDownload())
13431341
return;
13441342

1345-
// If our best fork is no longer within 72 blocks (+/- 12 hours if no one mines it)
1346-
// of our head, drop it
1347-
if (pindexBestForkTip && ::ChainActive().Height() - pindexBestForkTip->nHeight >= 72)
1348-
pindexBestForkTip = nullptr;
1349-
1350-
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > ::ChainActive().Tip()->nChainWork + (GetBlockProof(*::ChainActive().Tip()) * 6)))
1343+
if (pindexBestInvalid && pindexBestInvalid->nChainWork > ::ChainActive().Tip()->nChainWork + (GetBlockProof(*::ChainActive().Tip()) * 6))
13511344
{
1352-
if (!GetfLargeWorkForkFound() && pindexBestForkBase)
1353-
{
1354-
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
1355-
pindexBestForkBase->phashBlock->ToString() + std::string("'");
1356-
AlertNotify(warning);
1357-
}
1358-
if (pindexBestForkTip && pindexBestForkBase)
1359-
{
1360-
LogPrintf("%s: Warning: Large valid fork found\n forking the chain at height %d (%s)\n lasting to height %d (%s).\nChain state database corruption likely.\n", __func__,
1361-
pindexBestForkBase->nHeight, pindexBestForkBase->phashBlock->ToString(),
1362-
pindexBestForkTip->nHeight, pindexBestForkTip->phashBlock->ToString());
1363-
SetfLargeWorkForkFound(true);
1364-
}
1365-
else
1366-
{
1367-
LogPrintf("%s: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n", __func__);
1368-
SetfLargeWorkInvalidChainFound(true);
1369-
}
1345+
LogPrintf("%s: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n", __func__);
1346+
SetfLargeWorkInvalidChainFound(true);
13701347
}
13711348
else
13721349
{
1373-
SetfLargeWorkForkFound(false);
13741350
SetfLargeWorkInvalidChainFound(false);
13751351
}
13761352
}
13771353

1378-
static void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1379-
{
1380-
AssertLockHeld(cs_main);
1381-
// If we are on a fork that is sufficiently large, set a warning flag
1382-
CBlockIndex* pfork = pindexNewForkTip;
1383-
CBlockIndex* plonger = ::ChainActive().Tip();
1384-
while (pfork && pfork != plonger)
1385-
{
1386-
while (plonger && plonger->nHeight > pfork->nHeight)
1387-
plonger = plonger->pprev;
1388-
if (pfork == plonger)
1389-
break;
1390-
pfork = pfork->pprev;
1391-
}
1392-
1393-
// We define a condition where we should warn the user about as a fork of at least 7 blocks
1394-
// with a tip within 72 blocks (+/- 12 hours if no one mines it) of ours
1395-
// We use 7 blocks rather arbitrarily as it represents just under 10% of sustained network
1396-
// hash rate operating on the fork.
1397-
// or a chain that is entirely longer than ours and invalid (note that this should be detected by both)
1398-
// We define it this way because it allows us to only store the highest fork tip (+ base) which meets
1399-
// the 7-block condition and from this always have the most-likely-to-cause-warning fork
1400-
if (pfork && (!pindexBestForkTip || pindexNewForkTip->nHeight > pindexBestForkTip->nHeight) &&
1401-
pindexNewForkTip->nChainWork - pfork->nChainWork > (GetBlockProof(*pfork) * 7) &&
1402-
::ChainActive().Height() - pindexNewForkTip->nHeight < 72)
1403-
{
1404-
pindexBestForkTip = pindexNewForkTip;
1405-
pindexBestForkBase = pfork;
1406-
}
1407-
1408-
CheckForkWarningConditions();
1409-
}
1410-
14111354
// Called both upon regular invalid block discovery *and* InvalidateBlock
14121355
void static InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
14131356
{
@@ -2821,11 +2764,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
28212764
}
28222765
m_mempool.check(&CoinsTip());
28232766

2824-
// Callbacks/notifications for a new best chain.
2825-
if (fInvalidFound)
2826-
CheckForkWarningConditionsOnNewFork(vpindexToConnect.back());
2827-
else
2828-
CheckForkWarningConditions();
2767+
CheckForkWarningConditions();
28292768

28302769
return true;
28312770
}

src/warnings.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
static Mutex g_warnings_mutex;
1616
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
17-
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
1817
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
1918

2019
void SetMiscWarning(const bilingual_str& warning)
@@ -23,18 +22,6 @@ void SetMiscWarning(const bilingual_str& warning)
2322
g_misc_warnings = warning;
2423
}
2524

26-
void SetfLargeWorkForkFound(bool flag)
27-
{
28-
LOCK(g_warnings_mutex);
29-
fLargeWorkForkFound = flag;
30-
}
31-
32-
bool GetfLargeWorkForkFound()
33-
{
34-
LOCK(g_warnings_mutex);
35-
return fLargeWorkForkFound;
36-
}
37-
3825
void SetfLargeWorkInvalidChainFound(bool flag)
3926
{
4027
LOCK(g_warnings_mutex);
@@ -60,10 +47,7 @@ bilingual_str GetWarnings(bool verbose)
6047
warnings_verbose.emplace_back(warnings_concise);
6148
}
6249

63-
if (fLargeWorkForkFound) {
64-
warnings_concise = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
65-
warnings_verbose.emplace_back(warnings_concise);
66-
} else if (fLargeWorkInvalidChainFound) {
50+
if (fLargeWorkInvalidChainFound) {
6751
warnings_concise = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
6852
warnings_verbose.emplace_back(warnings_concise);
6953
}

src/warnings.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
struct bilingual_str;
1212

1313
void SetMiscWarning(const bilingual_str& warning);
14-
void SetfLargeWorkForkFound(bool flag);
15-
bool GetfLargeWorkForkFound();
1614
void SetfLargeWorkInvalidChainFound(bool flag);
1715
/** Format a string that describes several potential problems detected by the core.
1816
* @param[in] verbose bool

0 commit comments

Comments
 (0)