Skip to content

Commit

Permalink
Revert "cleanup- replaced assert with releaseAssert to maintain consi…
Browse files Browse the repository at this point in the history
…stency in codebase stellar#2852"

This reverts commit 9eb12bc.
  • Loading branch information
seekaddo committed Jan 12, 2021
1 parent 9eb12bc commit 0905248
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 108 deletions.
13 changes: 6 additions & 7 deletions src/bucket/Bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
#include "util/XDRStream.h"
#include "xdrpp/message.h"
#include <Tracy.hpp>
//#include <cassert>
#include "util/GlobalChecks.h"
#include <cassert>
#include <fmt/format.h>
#include <future>

Expand All @@ -36,7 +35,7 @@ namespace stellar
Bucket::Bucket(std::string const& filename, Hash const& hash)
: mFilename(filename), mHash(hash)
{
releaseAssert(filename.empty() || fs::exists(filename));
assert(filename.empty() || fs::exists(filename));
if (!filename.empty())
{
CLOG_TRACE(Bucket, "Bucket::Bucket() created, file exists : {}",
Expand Down Expand Up @@ -128,7 +127,7 @@ Bucket::convertToBucketEntry(bool useInit,

BucketEntryIdCmp cmp;
std::sort(bucket.begin(), bucket.end(), cmp);
releaseAssert(std::adjacent_find(
assert(std::adjacent_find(
bucket.begin(), bucket.end(),
[&cmp](BucketEntry const& lhs, BucketEntry const& rhs) {
return !cmp(lhs, rhs);
Expand Down Expand Up @@ -601,8 +600,8 @@ Bucket::merge(BucketManager& bucketManager, uint32_t maxProtocolVersion,
// buckets together into a new 3rd bucket, while calculating its hash,
// in a single pass.

releaseAssert(oldBucket);
releaseAssert(newBucket);
assert(oldBucket);
assert(newBucket);

MergeCounters mc;
BucketInputIterator oi(oldBucket);
Expand Down Expand Up @@ -661,7 +660,7 @@ Bucket::merge(BucketManager& bucketManager, uint32_t maxProtocolVersion,
uint32_t
Bucket::getBucketVersion(std::shared_ptr<Bucket> const& bucket)
{
releaseAssert(bucket);
assert(bucket);
BucketInputIterator it(bucket);
return it.getMetadata().ledgerVersion;
}
Expand Down
6 changes: 2 additions & 4 deletions src/bucket/BucketInputIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ BucketInputIterator::operator bool() const
return mEntryPtr != nullptr;
}

BucketEntry const&
BucketInputIterator::operator*()
BucketEntry const& BucketInputIterator::operator*()
{
return *mEntryPtr;
}
Expand Down Expand Up @@ -111,8 +110,7 @@ BucketInputIterator::~BucketInputIterator()
mIn.close();
}

BucketInputIterator&
BucketInputIterator::operator++()
BucketInputIterator& BucketInputIterator::operator++()
{
if (mIn)
{
Expand Down
37 changes: 18 additions & 19 deletions src/bucket/BucketList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#include "util/XDRStream.h"
#include "util/types.h"
#include <Tracy.hpp>
//#include <cassert>
#include "util/GlobalChecks.h"
#include <cassert>
#include <fmt/format.h>

namespace stellar
Expand Down Expand Up @@ -113,7 +112,7 @@ BucketLevel::commit()
{
setCurr(mNextCurr.resolve());
}
releaseAssert(!mNextCurr.isMerging());
assert(!mNextCurr.isMerging());
}

// prepare builds a FutureBucket for the _next state_ of the current level,
Expand Down Expand Up @@ -159,7 +158,7 @@ BucketLevel::prepare(Application& app, uint32_t currLedger,
ZoneScoped;
// If more than one absorb is pending at the same time, we have a logic
// error in our caller (and all hell will break loose).
releaseAssert(!mNextCurr.isMerging());
assert(!mNextCurr.isMerging());
auto curr = BucketList::shouldMergeWithEmptyCurr(currLedger, mLevel)
? std::make_shared<Bucket>()
: mCurr;
Expand All @@ -170,7 +169,7 @@ BucketLevel::prepare(Application& app, uint32_t currLedger,
: shadows;
mNextCurr = FutureBucket(app, curr, snap, shadowsBasedOnProtocol,
currLedgerProtocol, countMergeEvents, mLevel);
releaseAssert(mNextCurr.isMerging());
assert(mNextCurr.isMerging());
}

std::shared_ptr<Bucket>
Expand Down Expand Up @@ -215,7 +214,7 @@ BucketListDepth::operator uint32_t() const
uint32_t
BucketList::levelSize(uint32_t level)
{
releaseAssert(level < kNumLevels);
assert(level < kNumLevels);
return 1UL << (2 * (level + 1));
}

Expand Down Expand Up @@ -249,8 +248,8 @@ BucketList::mask(uint32_t v, uint32_t m)
uint32_t
BucketList::sizeOfCurr(uint32_t ledger, uint32_t level)
{
releaseAssert(ledger != 0);
releaseAssert(level < kNumLevels);
assert(ledger != 0);
assert(level < kNumLevels);
if (level == 0)
{
return (ledger == 1) ? 1 : (1 + ledger % 2);
Expand Down Expand Up @@ -296,8 +295,8 @@ BucketList::sizeOfCurr(uint32_t ledger, uint32_t level)
uint32_t
BucketList::sizeOfSnap(uint32_t ledger, uint32_t level)
{
releaseAssert(ledger != 0);
releaseAssert(level < kNumLevels);
assert(ledger != 0);
assert(level < kNumLevels);
if (level == BucketList::kNumLevels - 1)
{
return 0;
Expand All @@ -322,8 +321,8 @@ BucketList::sizeOfSnap(uint32_t ledger, uint32_t level)
uint32_t
BucketList::oldestLedgerInCurr(uint32_t ledger, uint32_t level)
{
releaseAssert(ledger != 0);
releaseAssert(level < kNumLevels);
assert(ledger != 0);
assert(level < kNumLevels);
if (sizeOfCurr(ledger, level) == 0)
{
return std::numeric_limits<uint32_t>::max();
Expand All @@ -342,8 +341,8 @@ BucketList::oldestLedgerInCurr(uint32_t ledger, uint32_t level)
uint32_t
BucketList::oldestLedgerInSnap(uint32_t ledger, uint32_t level)
{
releaseAssert(ledger != 0);
releaseAssert(level < kNumLevels);
assert(ledger != 0);
assert(level < kNumLevels);
if (sizeOfSnap(ledger, level) == 0)
{
return std::numeric_limits<uint32_t>::max();
Expand Down Expand Up @@ -437,7 +436,7 @@ bool
BucketList::futuresAllResolved(uint32_t maxLevel) const
{
ZoneScoped;
releaseAssert(maxLevel < mLevels.size());
assert(maxLevel < mLevels.size());

for (uint32_t i = 0; i <= maxLevel; i++)
{
Expand Down Expand Up @@ -471,7 +470,7 @@ BucketList::addBatch(Application& app, uint32_t currLedger,
std::vector<LedgerKey> const& deadEntries)
{
ZoneScoped;
releaseAssert(currLedger > 0);
assert(currLedger > 0);

std::vector<std::shared_ptr<Bucket>> shadows;
for (auto& level : mLevels)
Expand Down Expand Up @@ -506,13 +505,13 @@ BucketList::addBatch(Application& app, uint32_t currLedger,
// elements of 'shadows', and then inside the loop we pop two more for each
// iteration.

releaseAssert(shadows.size() >= 2);
assert(shadows.size() >= 2);
shadows.pop_back();
shadows.pop_back();

for (uint32_t i = static_cast<uint32>(mLevels.size()) - 1; i != 0; --i)
{
releaseAssert(shadows.size() >= 2);
assert(shadows.size() >= 2);
shadows.pop_back();
shadows.pop_back();

Expand Down Expand Up @@ -562,7 +561,7 @@ BucketList::addBatch(Application& app, uint32_t currLedger,
bool countMergeEvents =
!app.getConfig().ARTIFICIALLY_REDUCE_MERGE_COUNTS_FOR_TESTING;
bool doFsync = !app.getConfig().DISABLE_XDR_FSYNC;
releaseAssert(shadows.size() == 0);
assert(shadows.size() == 0);
mLevels[0].prepare(app, currLedger, currLedgerProtocol,
Bucket::fresh(app.getBucketManager(), currLedgerProtocol,
initEntries, liveEntries, deadEntries,
Expand Down
6 changes: 3 additions & 3 deletions src/bucket/BucketManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <map>
#include <regex>
#include <set>
#include "util/GlobalChecks.h"

#include "medida/counter.h"
#include "medida/meter.h"
#include "medida/metrics_registry.h"
Expand Down Expand Up @@ -219,7 +219,7 @@ BucketManagerImpl::deleteTmpDirAndUnlockBucketDir()
{
std::string d = mApp.getConfig().BUCKET_DIR_PATH;
std::string lock = d + "/" + kLockFilename;
releaseAssert(fs::exists(lock));
assert(fs::exists(lock));
fs::unlockFile(lock);
mLockedBucketDir.reset();
}
Expand Down Expand Up @@ -412,7 +412,7 @@ BucketManagerImpl::adoptFileAsBucket(std::string const& filename,
mSharedBucketsSize.set_count(mSharedBuckets.size());
}
}
releaseAssert(b);
assert(b);
if (mergeKey)
{
// Second half of the mergeKey record-keeping, above: if we successfully
Expand Down
3 changes: 1 addition & 2 deletions src/bucket/BucketMergeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "crypto/Hex.h"
#include "util/Logging.h"
#include <Tracy.hpp>
#include "util/GlobalChecks.h"

namespace
{
Expand Down Expand Up @@ -55,7 +54,7 @@ BucketMergeMap::forgetAllMergesProducing(Hash const& outputBeingDropped)
{
auto const& output = mergeProducingOutput->first;
auto const& mergeKeyProducingOutput = mergeProducingOutput->second;
releaseAssert(output == outputBeingDropped);
assert(output == outputBeingDropped);
ret.emplace(mergeKeyProducingOutput);

// It's possible for the same output to occur for multiple
Expand Down
7 changes: 3 additions & 4 deletions src/bucket/BucketOutputIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "bucket/BucketManager.h"
#include "crypto/Random.h"
#include <Tracy.hpp>
#include "util/GlobalChecks.h"

namespace stellar
{
Expand Down Expand Up @@ -89,7 +88,7 @@ BucketOutputIterator::put(BucketEntry const& e)
{
// mCmp(e, *mBuf) means e < *mBuf; this should never be true since
// it would mean that we're getting entries out of order.
releaseAssert(!mCmp(e, *mBuf));
assert(!mCmp(e, *mBuf));

// Check to see if the new entry should flush (greater identity), or
// merely replace (same identity), the buffered entry.
Expand Down Expand Up @@ -125,8 +124,8 @@ BucketOutputIterator::getBucket(BucketManager& bucketManager,
mOut.close();
if (mObjectsPut == 0 || mBytesPut == 0)
{
releaseAssert(mObjectsPut == 0);
releaseAssert(mBytesPut == 0);
assert(mObjectsPut == 0);
assert(mBytesPut == 0);
CLOG_DEBUG(Bucket, "Deleting empty bucket file {}", mFilename);
std::remove(mFilename.c_str());
if (mergeKey)
Expand Down

0 comments on commit 0905248

Please sign in to comment.