Skip to content

Commit

Permalink
Removed PARANOID build option (ethereum#5631)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjgf committed Jul 7, 2019
1 parent 71f9ba6 commit 0db16d0
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 108 deletions.
13 changes: 0 additions & 13 deletions cmake/EthOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ macro(configure_project)
# Features:
option(EVM_OPTIMIZE "Enable VM optimizations (can distort tracing)" ON)
option(FATDB "Enable fat state database" ON)
option(PARANOID "Enable additional checks when validating transactions (deprecated)" OFF)
option(MINIUPNPC "Build with UPnP support" OFF)
option(FASTCTEST "Enable fast ctest" OFF)
option(ROCKSDB "Build with rocksdb as optional database implementation" OFF)
Expand All @@ -24,24 +23,13 @@ macro(configure_project)
# components
option(TESTS "Build with tests" ON)
option(TOOLS "Build additional tools" ON)
# Resolve any clashes between incompatible options.
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if (PARANOID)
message(WARNING "Paranoia requires debug - disabling for release build.")
set(PARANOID OFF)
endif ()
endif ()

# FATDB is an option to include the reverse hashes for the trie,
# i.e. it allows you to iterate over the contents of the state.
if (FATDB)
add_definitions(-DETH_FATDB)
endif ()

if (PARANOID)
add_definitions(-DETH_PARANOIA)
endif ()

# CI Builds should provide (for user builds this is totally optional)
# -DBUILD_NUMBER - A number to identify the current build with. Becomes TWEAK component of project version.
# -DVERSION_SUFFIX - A string to append to the end of the version string where applicable.
Expand Down Expand Up @@ -73,7 +61,6 @@ macro(print_config)
message("-- EVM_OPTIMIZE Enable VM optimizations ${EVM_OPTIMIZE}")
message("-- FATDB Full database exploring ${FATDB}")
message("-- ROCKSDB RocksDB as optional DB implementation ${ROCKSDB}")
message("-- PARANOID - ${PARANOID}")
message("-- MINIUPNPC - ${MINIUPNPC}")
message("------------------------------------------------------------- components")
message("-- TESTS Build tests ${TESTS}")
Expand Down
2 changes: 1 addition & 1 deletion libdevcore/OverlayDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ bool OverlayDB::exists(h256 const& _h) const

void OverlayDB::kill(h256 const& _h)
{
#if ETH_PARANOIA || 1
#if 1
if (!StateCacheDB::kill(_h))
{
if (m_db)
Expand Down
16 changes: 0 additions & 16 deletions libdevcore/StateCacheDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ void StateCacheDB::insert(h256 const& _h, bytesConstRef _v)
}
else
m_main[_h] = make_pair(_v.toString(), 1);
#if ETH_PARANOIA
cdebug << "INST" << _h << "=>" << m_main[_h].second;
#endif
}

bool StateCacheDB::kill(h256 const& _h)
Expand All @@ -106,19 +103,6 @@ bool StateCacheDB::kill(h256 const& _h)
m_main[_h].second--;
return true;
}
#if ETH_PARANOIA
else
{
// If we get to this point, then there was probably a node in the level DB which we need to remove and which we have previously
// used as part of the memory-based StateCacheDB. Nothing to be worried about *as long as the node exists in the DB*.
cdebug << "NOKILL-WAS" << _h;
}
cdebug << "KILL" << _h << "=>" << m_main[_h].second;
}
else
{
cdebug << "NOKILL" << _h;
#endif
}
return false;
}
Expand Down
18 changes: 0 additions & 18 deletions libdevcore/TrieDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,17 +553,8 @@ template <class DB> void GenericTrieDB<DB>::iterator::next(NibbleSlice _key)
}
if (!rlp.isList() || (rlp.itemCount() != 2 && rlp.itemCount() != 17))
{
#if ETH_PARANOIA
cwarn << "BIG FAT ERROR. STATE TRIE CORRUPTED!!!!!";
cwarn << b.rlp.size() << toHex(b.rlp);
cwarn << rlp;
auto c = rlp.itemCount();
cwarn << c;
BOOST_THROW_EXCEPTION(InvalidTrie());
#else
m_that = nullptr;
return;
#endif
}
if (rlp.itemCount() == 2)
{
Expand Down Expand Up @@ -688,17 +679,8 @@ template <class DB> void GenericTrieDB<DB>::iterator::next()
}
if (!(rlp.isList() && (rlp.itemCount() == 2 || rlp.itemCount() == 17)))
{
#if ETH_PARANOIA
cwarn << "BIG FAT ERROR. STATE TRIE CORRUPTED!!!!!";
cwarn << b.rlp.size() << toHex(b.rlp);
cwarn << rlp;
auto c = rlp.itemCount();
cwarn << c;
BOOST_THROW_EXCEPTION(InvalidTrie());
#else
m_that = nullptr;
return;
#endif
}
if (rlp.itemCount() == 2)
{
Expand Down
24 changes: 0 additions & 24 deletions libethereum/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,30 +207,6 @@ bool Block::sync(BlockChain const& _bc, h256 const& _block, BlockHeader const& _
bool ret = false;
// BLOCK
BlockHeader bi = _bi ? _bi : _bc.info(_block);
#if ETH_PARANOIA
if (!bi)
while (1)
{
try
{
auto b = _bc.block(_block);
bi.populate(b);
break;
}
catch (Exception const& _e)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
cerr << diagnostic_information(_e) << endl;
}
catch (std::exception const& _e)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
cerr << _e.what() << endl;
}
}
#endif
if (bi == m_currentBlock)
{
// We mined the last block.
Expand Down
36 changes: 0 additions & 36 deletions libethereum/BlockChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ unsigned BlockChain::open(fs::path const& _path, WithExisting _we)
assert(isKnown(gb.hash()));
}

#if ETH_PARANOIA
checkConsistency();
#endif

// TODO: Implement ability to rebuild details map from DB.
auto const l = m_extrasDB->lookup(db::Slice("best"));
m_lastBlockHash = l.empty() ? m_genesisHash : h256(l, h256::FromBinary);
Expand Down Expand Up @@ -706,10 +702,6 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const&
td = pd.totalDifficulty + tdIncrease;

performanceLogger.onStageFinished("enactment");

#if ETH_PARANOIA
checkConsistency();
#endif // ETH_PARANOIA
}
catch (BadRoot& ex)
{
Expand Down Expand Up @@ -919,30 +911,6 @@ ImportRoute BlockChain::insertBlockAndExtras(VerifiedBlockRef const& _block, byt
cwarn << "Fail writing to extras database. Bombing out.";
exit(-1);
}

#if ETH_PARANOIA
if (isKnown(_block.info.hash()) && !details(_block.info.hash()))
{
LOG(m_loggerError) << "Known block just inserted has no details.";
LOG(m_loggerError) << "Block: " << _block.info;
LOG(m_loggerError) << "DATABASE CORRUPTION: CRITICAL FAILURE";
exit(-1);
}

try
{
State canary(_db, BaseState::Empty);
canary.populateFromChain(*this, _block.info.hash());
}
catch (...)
{
LOG(m_loggerError) << "Failed to initialise State object form imported block.";
LOG(m_loggerError) << "Block: " << _block.info;
LOG(m_loggerError) << "DATABASE CORRUPTION: CRITICAL FAILURE";
exit(-1);
}
#endif // ETH_PARANOIA

if (m_lastBlockHash != newLastBlockHash)
DEV_WRITE_GUARDED(x_lastBlockHash)
{
Expand All @@ -962,10 +930,6 @@ ImportRoute BlockChain::insertBlockAndExtras(VerifiedBlockRef const& _block, byt
}
}

#if ETH_PARANOIA
checkConsistency();
#endif // ETH_PARANOIA

_performanceLogger.onStageFinished("checkBest");

unsigned const gasPerSecond = static_cast<double>(_block.info.gasUsed()) / _performanceLogger.stageDuration("enactment");
Expand Down

0 comments on commit 0db16d0

Please sign in to comment.