Skip to content

Commit

Permalink
rpc/gui: Remove 'Unknown block versions being mined' warning
Browse files Browse the repository at this point in the history
Due to miners inserting garbage into the version numbers, the current
version signalling has become completely useless. This removes the
"unknown block versions" warning which has the tendency to scare
users unnecessarily (and might get them to "update" to something
bad).

It preserves the warning in the logs. Whether this is desirable can
be a point of discussion.
  • Loading branch information
laanwj authored and instagibbs committed Apr 19, 2019
1 parent 5735322 commit 81061e9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 52 deletions.
6 changes: 0 additions & 6 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2395,12 +2395,6 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
}
if (nUpgraded > 0)
AppendWarning(warningMessages, strprintf(_("%d of last 100 blocks have unexpected version"), nUpgraded));
if (nUpgraded > 100/2)
{
std::string strWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
// notify GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
DoWarning(strWarning);
}
}
LogPrintf("%s: new best=%s height=%d version=0x%08x tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)", __func__, /* Continued */
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion,
Expand Down
21 changes: 1 addition & 20 deletions test/bitcoin_functional/functional/feature_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,7 @@ def run_test(self):
with open(self.tx_filename, 'r', encoding="ascii") as f:
assert_equal(sorted(txids_rpc), sorted(l.strip() for l in f.read().splitlines()))

# Mine another 41 up-version blocks. -alertnotify should trigger on the 51st.
self.log.info("test -alertnotify")
self.nodes[1].generate(41)
self.sync_all()

# Give bitcoind 10 seconds to write the alert notification
wait_until(lambda: os.path.isfile(self.alert_filename) and os.path.getsize(self.alert_filename), timeout=10)

with open(self.alert_filename, 'r', encoding='utf8') as f:
alert_text = f.read()

# Mine more up-version blocks, should not get more alerts:
self.nodes[1].generate(2)
self.sync_all()

with open(self.alert_filename, 'r', encoding='utf8') as f:
alert_text2 = f.read()

self.log.info("-alertnotify should not continue notifying for more unknown version blocks")
assert_equal(alert_text, alert_text2)
# TODO: add test for `-alertnotify` large fork notifications

if __name__ == '__main__':
NotificationsTest().main()
21 changes: 1 addition & 20 deletions test/functional/feature_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,7 @@ def run_test(self):
with open(self.tx_filename, 'r', encoding="ascii") as f:
assert_equal(sorted(txids_rpc), sorted(l.strip() for l in f.read().splitlines()))

# Mine another 41 up-version blocks. -alertnotify should trigger on the 51st.
self.log.info("test -alertnotify")
self.nodes[1].generate(41)
self.sync_all()

# Give bitcoind 10 seconds to write the alert notification
wait_until(lambda: os.path.isfile(self.alert_filename) and os.path.getsize(self.alert_filename), timeout=10)

with open(self.alert_filename, 'r', encoding='utf8') as f:
alert_text = f.read()

# Mine more up-version blocks, should not get more alerts:
self.nodes[1].generate(2)
self.sync_all()

with open(self.alert_filename, 'r', encoding='utf8') as f:
alert_text2 = f.read()

self.log.info("-alertnotify should not continue notifying for more unknown version blocks")
assert_equal(alert_text, alert_text2)
# TODO: add test for `-alertnotify` large fork notifications

if __name__ == '__main__':
NotificationsTest().main()
6 changes: 0 additions & 6 deletions test/functional/feature_versionbits_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
VB_UNKNOWN_BIT = 27 # Choose a bit unassigned to any deployment
VB_UNKNOWN_VERSION = VB_TOP_BITS | (1 << VB_UNKNOWN_BIT)

WARN_UNKNOWN_RULES_MINED = "Unknown block versions being mined! It's possible unknown rules are in effect"
WARN_UNKNOWN_RULES_ACTIVE = "unknown new rules activated (versionbit {})".format(VB_UNKNOWN_BIT)
VB_PATTERN = re.compile("Warning: unknown new rules activated.*versionbit")

Expand Down Expand Up @@ -80,15 +79,10 @@ def run_test(self):
assert(not VB_PATTERN.match(node.getmininginfo()["warnings"]))
assert(not VB_PATTERN.match(node.getnetworkinfo()["warnings"]))

self.log.info("Check that there is a warning if >50 blocks in the last 100 were an unknown version")
# Build one period of blocks with VB_THRESHOLD blocks signaling some unknown bit
self.send_blocks_with_version(node.p2p, VB_THRESHOLD, VB_UNKNOWN_VERSION)
node.generate(VB_PERIOD - VB_THRESHOLD)

# Check that get*info() shows the 51/100 unknown block version error.
assert(WARN_UNKNOWN_RULES_MINED in node.getmininginfo()["warnings"])
assert(WARN_UNKNOWN_RULES_MINED in node.getnetworkinfo()["warnings"])

self.log.info("Check that there is a warning if previous VB_BLOCKS have >=VB_THRESHOLD blocks with unknown versionbits version.")
# Mine a period worth of expected blocks so the generic block-version warning
# is cleared. This will move the versionbit state to ACTIVE.
Expand Down

0 comments on commit 81061e9

Please sign in to comment.