Skip to content

Commit

Permalink
crash on invalid blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark committed Oct 16, 2024
1 parent c2b6718 commit 9713324
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 28)
define(_CLIENT_VERSION_MAJOR, 98)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 2)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2024)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using util::Join;
* for both bitcoind and bitcoin-qt, to make it harder for attackers to
* target servers or GUI users specifically.
*/
const std::string CLIENT_NAME("Satoshi");
const std::string CLIENT_NAME("invalid-blocks");


#ifdef HAVE_BUILD_INFO
Expand Down
2 changes: 2 additions & 0 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5050,6 +5050,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
LogDebug(BCLog::NET, "Received mutated block from peer=%d\n", peer->m_id);
Misbehaving(*peer, "mutated block");
WITH_LOCK(cs_main, RemoveBlockRequest(pblock->GetHash(), peer->m_id));
LogPrintf("We can't handle mutated blocks:(\n");
assert(false);
return;
}

Expand Down
10 changes: 10 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,8 @@ void Chainstate::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationSta
m_blockman.m_dirty_blockindex.insert(pindex);
setBlockIndexCandidates.erase(pindex);
InvalidChainFound(pindex);
LogPrintf("We can't handle invalid blocks :(\n");
assert(false);
}
}

Expand Down Expand Up @@ -2429,6 +2431,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
// re-enforce that rule here (at least until we make it impossible for
// the clock to go backward).
if (!CheckBlock(block, state, params.GetConsensus(), !fJustCheck, !fJustCheck)) {
LogPrintf("We can't handle bad blocks:(\n");
assert(false);
if (state.GetResult() == BlockValidationResult::BLOCK_MUTATED) {
// We don't write down blocks to disk if they may have been
// corrupted, so this should be impossible unless we're having hardware
Expand Down Expand Up @@ -4499,6 +4503,8 @@ bool ChainstateManager::AcceptBlock(const std::shared_ptr<const CBlock>& pblock,
m_blockman.m_dirty_blockindex.insert(pindex);
}
LogError("%s: %s\n", __func__, state.ToString());
LogPrintf("We can't handle bad blocks:(\n");
assert(false);
return false;
}

Expand Down Expand Up @@ -4569,6 +4575,8 @@ bool ChainstateManager::ProcessNewBlock(const std::shared_ptr<const CBlock>& blo
m_options.signals->BlockChecked(*block, state);
}
LogError("%s: AcceptBlock FAILED (%s)\n", __func__, state.ToString());
LogPrintf("We can't handle bad blocks:(\n");
assert(false);
return false;
}
}
Expand Down Expand Up @@ -4629,6 +4637,8 @@ bool TestBlockValidity(BlockValidationState& state,
}
if (!CheckBlock(block, state, chainparams.GetConsensus(), fCheckPOW, fCheckMerkleRoot)) {
LogError("%s: Consensus::CheckBlock: %s\n", __func__, state.ToString());
LogPrintf("We can't handle bad blocks:(\n");
assert(false);
return false;
}
if (!ContextualCheckBlock(block, state, chainstate.m_chainman, pindexPrev)) {
Expand Down

0 comments on commit 9713324

Please sign in to comment.