diff --git a/include/xrpl/basics/Buffer.h b/include/xrpl/basics/Buffer.h index 08e01b2f6be..0b7bf6cbc0c 100644 --- a/include/xrpl/basics/Buffer.h +++ b/include/xrpl/basics/Buffer.h @@ -112,7 +112,7 @@ class Buffer operator=(Slice s) { // Ensure the slice isn't a subset of the buffer. - XRPL_ASSERT( + XRPL_ASSERT("Buffer assignment from Slice", s.size() == 0 || size_ == 0 || s.data() < p_.get() || s.data() >= p_.get() + size_); diff --git a/include/xrpl/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h index 0a74d881089..ed2de1acd1b 100644 --- a/include/xrpl/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -417,9 +417,9 @@ mulDivU(Source1 value, Dest mul, Source2 div) { // split the asserts so if one hits, the user can tell which // without a debugger. - XRPL_ASSERT(value.value() >= 0); - XRPL_ASSERT(mul.value() >= 0); - XRPL_ASSERT(div.value() >= 0); + XRPL_ASSERT("feeunit::mulDivU value check", value.value() >= 0); + XRPL_ASSERT("feeunit::mulDivU mul check", mul.value() >= 0); + XRPL_ASSERT("feeunit::mulDivU div check", div.value() >= 0); return std::nullopt; } diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index d247456f647..d33a35dcb71 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED #define RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED +#include #include #include @@ -32,6 +33,7 @@ #include #include #include +#include #if BOOST_OS_LINUX #include @@ -141,7 +143,7 @@ class SlabAllocator void deallocate(std::uint8_t* ptr) noexcept { - XRPL_ASSERT(own(ptr)); + XRPL_ASSERT("SlabAllocator::SlabBlock::deallocate", own(ptr)); std::lock_guard l(m_); @@ -184,7 +186,7 @@ class SlabAllocator boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_)) , slabSize_(alloc) { - XRPL_ASSERT((itemAlignment_ & (itemAlignment_ - 1)) == 0); + XRPL_ASSERT("SlabAllocator constructor", (itemAlignment_ & (itemAlignment_ - 1)) == 0); } SlabAllocator(SlabAllocator const& other) = delete; @@ -294,7 +296,7 @@ class SlabAllocator bool deallocate(std::uint8_t* ptr) noexcept { - XRPL_ASSERT(ptr); + XRPL_ASSERT("SlabAllocator::deallocate", ptr); for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next_) { diff --git a/include/xrpl/basics/Slice.h b/include/xrpl/basics/Slice.h index 86977d2a23a..4dd3c96713e 100644 --- a/include/xrpl/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -103,7 +103,7 @@ class Slice std::uint8_t operator[](std::size_t i) const noexcept { - XRPL_ASSERT(i < size_); + XRPL_ASSERT("Slice const indexing", i < size_); return data_[i]; } diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index f204235ebee..bf9850ca765 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -290,7 +290,7 @@ class base_uint std::is_trivially_copyable::value>> explicit base_uint(Container const& c) { - XRPL_ASSERT( + XRPL_ASSERT("base_uint constructor from a container", c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); } @@ -302,7 +302,7 @@ class base_uint base_uint&> operator=(Container const& c) { - XRPL_ASSERT( + XRPL_ASSERT("base_uint assignment from a container", c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); return *this; diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index a7672a74140..0a27e73f665 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -246,7 +246,7 @@ class partitioned_unordered_map ? *partitions : std::thread::hardware_concurrency(); map_.resize(partitions_); - XRPL_ASSERT(partitions_); + XRPL_ASSERT("partitioned_unordered_map constructor from an optional", partitions_); } std::size_t diff --git a/include/xrpl/basics/random.h b/include/xrpl/basics/random.h index aa042979557..fcbc264f686 100644 --- a/include/xrpl/basics/random.h +++ b/include/xrpl/basics/random.h @@ -114,7 +114,7 @@ std::enable_if_t< Integral> rand_int(Engine& engine, Integral min, Integral max) { - XRPL_ASSERT(max > min); + XRPL_ASSERT("rand_int", max > min); // This should have no state and constructing it should // be very cheap. If that turns out not to be the case diff --git a/include/xrpl/basics/spinlock.h b/include/xrpl/basics/spinlock.h index b4c84e832f1..b1923fc70c9 100644 --- a/include/xrpl/basics/spinlock.h +++ b/include/xrpl/basics/spinlock.h @@ -117,7 +117,7 @@ class packed_spinlock packed_spinlock(std::atomic& lock, int index) : bits_(lock), mask_(static_cast(1) << index) { - XRPL_ASSERT(index >= 0 && (mask_ != 0)); + XRPL_ASSERT("packed_spinlock constructor", index >= 0 && (mask_ != 0)); } [[nodiscard]] bool diff --git a/include/xrpl/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h index b38a228efbd..3ff8a5ad578 100644 --- a/include/xrpl/beast/asio/io_latency_probe.h +++ b/include/xrpl/beast/asio/io_latency_probe.h @@ -174,7 +174,7 @@ class io_latency_probe , m_repeat(repeat) , m_probe(probe) { - XRPL_ASSERT(m_probe); + XRPL_ASSERT("beast::io_latency_probe::sample_op constructor", m_probe); m_probe->addref(); } @@ -184,7 +184,7 @@ class io_latency_probe , m_repeat(from.m_repeat) , m_probe(from.m_probe) { - XRPL_ASSERT(m_probe); + XRPL_ASSERT("beast::io_latency_probe::sample_op move constructor",m_probe); from.m_probe = nullptr; } diff --git a/include/xrpl/beast/clock/manual_clock.h b/include/xrpl/beast/clock/manual_clock.h index 59bbefc6a89..6a5ce60d434 100644 --- a/include/xrpl/beast/clock/manual_clock.h +++ b/include/xrpl/beast/clock/manual_clock.h @@ -61,7 +61,7 @@ class manual_clock : public abstract_clock void set(time_point const& when) { - XRPL_ASSERT(!Clock::is_steady || when >= now_); + XRPL_ASSERT("beast::manual_clock::set from time_point", !Clock::is_steady || when >= now_); now_ = when; } @@ -78,7 +78,7 @@ class manual_clock : public abstract_clock void advance(std::chrono::duration const& elapsed) { - XRPL_ASSERT(!Clock::is_steady || (now_ + elapsed) >= now_); + XRPL_ASSERT("beast::manual_clock::advance duration",!Clock::is_steady || (now_ + elapsed) >= now_); now_ += elapsed; } diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index 5744f0aad21..180abe2cd17 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -1329,7 +1329,7 @@ class aged_unordered_container size_type bucket(Key const& k) const { - XRPL_ASSERT(bucket_count() != 0); + XRPL_ASSERT("beast::detail::aged_unordered_container::bucket", bucket_count() != 0); return m_cont.bucket(k, std::cref(m_config.hash_function())); } @@ -1470,7 +1470,7 @@ class aged_unordered_container { if (would_exceed(additional)) m_buck.resize(size() + additional, m_cont); - XRPL_ASSERT(load_factor() <= max_load_factor()); + XRPL_ASSERT("beast::detail::aged_unordered_container::maybe_rehash",load_factor() <= max_load_factor()); } // map, set diff --git a/include/xrpl/beast/core/LexicalCast.h b/include/xrpl/beast/core/LexicalCast.h index 747a3a0ae0a..74fc7de3fd8 100644 --- a/include/xrpl/beast/core/LexicalCast.h +++ b/include/xrpl/beast/core/LexicalCast.h @@ -160,7 +160,7 @@ struct LexicalCast bool operator()(Out& out, char const* in) const { - XRPL_ASSERT(in); + XRPL_ASSERT("beast::detail::LexicalCast from char const*", in); return LexicalCast()(out, in); } }; @@ -175,7 +175,7 @@ struct LexicalCast bool operator()(Out& out, char* in) const { - XRPL_ASSERT(in); + XRPL_ASSERT("beast::detail::LexicalCast from char*", in); return LexicalCast()(out, in); } }; diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index 57019c5d099..902bc252817 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -96,7 +96,7 @@ hash_append(Hasher& h, beast::IP::Address const& addr) noexcept else if (addr.is_v6()) hash_append(h, addr.to_v6().to_bytes()); else - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("beast::hash_append invalid address type"); } } // namespace beast diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 5adb416e611..018e4b3a9e2 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -205,7 +205,7 @@ class Journal */ Stream(Sink& sink, Severity level) : m_sink(sink), m_level(level) { - XRPL_ASSERT(m_level < severities::kDisabled); + XRPL_ASSERT("beast::Journal::Stream constructor", m_level < severities::kDisabled); } /** Construct or copy another Stream. */ diff --git a/include/xrpl/beast/utility/instrumentation.h b/include/xrpl/beast/utility/instrumentation.h index 9a0beb0e5a5..4adac878a04 100644 --- a/include/xrpl/beast/utility/instrumentation.h +++ b/include/xrpl/beast/utility/instrumentation.h @@ -36,11 +36,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #ifndef NDEBUG -#define XRPL_ASSERT(...) ALWAYS_OR_UNREACHABLE(((bool)(__VA_ARGS__)), "", {}) -#define XRPL_UNREACHABLE() UNREACHABLE("", {}) +#define XRPL_ASSERT(M, ...) ALWAYS_OR_UNREACHABLE(((bool)(__VA_ARGS__)), M, {}) +#define XRPL_UNREACHABLE(M) UNREACHABLE(M, {}) #else #define XRPL_ASSERT(...) -#define XRPL_UNREACHABLE() +#define XRPL_UNREACHABLE(M) #endif #endif diff --git a/include/xrpl/beast/utility/rngfill.h b/include/xrpl/beast/utility/rngfill.h index f049f84ee80..750b28dc817 100644 --- a/include/xrpl/beast/utility/rngfill.h +++ b/include/xrpl/beast/utility/rngfill.h @@ -42,7 +42,7 @@ rngfill(void* buffer, std::size_t bytes, Generator& g) bytes -= sizeof(v); } - XRPL_ASSERT(bytes < sizeof(result_type)); + XRPL_ASSERT("beast::rngfill from void*", bytes < sizeof(result_type)); #ifdef __GNUC__ // gcc 11.1 (falsely) warns about an array-bounds overflow in release mode. diff --git a/include/xrpl/json/detail/json_assert.h b/include/xrpl/json/detail/json_assert.h index 10074062d90..264bcd90f3d 100644 --- a/include/xrpl/json/detail/json_assert.h +++ b/include/xrpl/json/detail/json_assert.h @@ -22,9 +22,6 @@ #include -#define JSON_ASSERT_UNREACHABLE XRPL_UNREACHABLE() -#define JSON_ASSERT(condition) \ - XRPL_ASSERT(condition); // @todo <= change this into an exception throw #define JSON_ASSERT_MESSAGE(condition, message) \ if (!(condition)) \ ripple::Throw(message); diff --git a/include/xrpl/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h index e8c7a53c131..b8fc2f45257 100644 --- a/include/xrpl/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -59,7 +59,7 @@ toSTAmount(XRPAmount const& xrp) inline STAmount toSTAmount(XRPAmount const& xrp, Issue const& iss) { - XRPL_ASSERT(isXRP(iss.account) && isXRP(iss.currency)); + XRPL_ASSERT("toSTAmount", isXRP(iss.account) && isXRP(iss.currency)); return toSTAmount(xrp); } @@ -78,12 +78,12 @@ template <> inline IOUAmount toAmount(STAmount const& amt) { - XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT("toAmount for IOUAmount mantissa", amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - XRPL_ASSERT(!isXRP(amt)); + XRPL_ASSERT("toAmount for IOUAmount is not XRP", !isXRP(amt)); return IOUAmount(sMant, amt.exponent()); } @@ -91,12 +91,12 @@ template <> inline XRPAmount toAmount(STAmount const& amt) { - XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT("toAmount for XRPAmount mantissa", amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - XRPL_ASSERT(isXRP(amt)); + XRPL_ASSERT("toAmount for XRPAmount is XRP", isXRP(amt)); return XRPAmount(sMant); } diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index 5449118e992..94478a74331 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -151,14 +151,14 @@ class FeatureBitset : private std::bitset explicit FeatureBitset(base const& b) : base(b) { - XRPL_ASSERT(b.count() == count()); + XRPL_ASSERT("FeatureBitset constructor from base", b.count() == count()); } template explicit FeatureBitset(uint256 const& f, Fs&&... fs) { initFromFeatures(f, std::forward(fs)...); - XRPL_ASSERT(count() == (sizeof...(fs) + 1)); + XRPL_ASSERT("FeatureBitset constructor from uint256", count() == (sizeof...(fs) + 1)); } template @@ -166,7 +166,7 @@ class FeatureBitset : private std::bitset { for (auto const& f : fs) set(featureToBitsetIndex(f)); - XRPL_ASSERT(fs.size() == count()); + XRPL_ASSERT("FeatureBitset constructor from a container",fs.size() == count()); } auto diff --git a/include/xrpl/protocol/Indexes.h b/include/xrpl/protocol/Indexes.h index 00ddbfd7591..3c1bdfeddcf 100644 --- a/include/xrpl/protocol/Indexes.h +++ b/include/xrpl/protocol/Indexes.h @@ -213,7 +213,7 @@ page(uint256 const& root, std::uint64_t index = 0) noexcept; inline Keylet page(Keylet const& root, std::uint64_t index = 0) noexcept { - XRPL_ASSERT(root.type == ltDIR_NODE); + XRPL_ASSERT("keylet::page", root.type == ltDIR_NODE); return page(root.key, index); } /** @} */ diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 7b6a678d0fa..cdb5c6daa58 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -158,7 +158,7 @@ struct MultiApiJson -> std:: invoke_result_t { - XRPL_ASSERT( + XRPL_ASSERT("detail::MultiApiJson functor with extra arguments version check", valid(version) && index(version) >= 0 && index(version) < size); return std::invoke( fn, @@ -175,7 +175,7 @@ struct MultiApiJson operator()(Json& json, Version version, Fn fn) const -> std::invoke_result_t { - XRPL_ASSERT( + XRPL_ASSERT("detail::MultiApiJson functor Json only version check", valid(version) && index(version) >= 0 && index(version) < size); return std::invoke(fn, json.val[index(version)]); } diff --git a/include/xrpl/protocol/Quality.h b/include/xrpl/protocol/Quality.h index 9fee7fd4cf8..159d933bf1c 100644 --- a/include/xrpl/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -298,7 +298,7 @@ class Quality friend double relativeDistance(Quality const& q1, Quality const& q2) { - XRPL_ASSERT(q1.m_value > 0 && q2.m_value > 0); + XRPL_ASSERT("Quality::relativeDistance positive qualities", q1.m_value > 0 && q2.m_value > 0); if (q1.m_value == q2.m_value) // make expected common case fast return 0; diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index e810c784dc0..ab03bd51f31 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -162,8 +162,8 @@ template void STBitString::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == getSType()); + XRPL_ASSERT("STBitString::add binary field", getFName().isBinary()); + XRPL_ASSERT("STBitString::add field type check", getFName().fieldType == getSType()); s.addBitString(value_); } diff --git a/include/xrpl/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h index 747d9a9dddb..9417b771297 100644 --- a/include/xrpl/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -110,8 +110,8 @@ template inline void STInteger::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == getSType()); + XRPL_ASSERT("STInteger::add binary field", getFName().isBinary()); + XRPL_ASSERT("STInteger::add field type check", getFName().fieldType == getSType()); s.addInteger(value_); } diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 4e2094695c0..fd24360d262 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -715,7 +715,7 @@ STObject::Proxy::assign(U&& u) t = dynamic_cast(st_->getPField(*f_, true)); else t = dynamic_cast(st_->makeFieldPresent(*f_)); - XRPL_ASSERT(t); + XRPL_ASSERT("STObject::Proxy::assign type check", t); *t = std::forward(u); } @@ -993,13 +993,13 @@ STObject::at(TypedField const& f) const if (auto const u = dynamic_cast(b)) return u->value(); - XRPL_ASSERT(mType); - XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT("STObject::at from a TypedField template set", mType); + XRPL_ASSERT("STObject::at from a TypedField not present", b->getSType() == STI_NOTPRESENT); if (mType->style(f) == soeOPTIONAL) Throw("Missing optional field: " + f.getName()); - XRPL_ASSERT(mType->style(f) == soeDEFAULT); + XRPL_ASSERT("STObject::at from a TypedField template default style", mType->style(f) == soeDEFAULT); // Used to help handle the case where value_type is a const reference, // otherwise we would return the address of a temporary. @@ -1017,11 +1017,11 @@ STObject::at(OptionaledField const& of) const auto const u = dynamic_cast(b); if (!u) { - XRPL_ASSERT(mType); - XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT("STObject::at from an OptionaledField template set", mType); + XRPL_ASSERT("STObject::at from an OptionaledField not present", b->getSType() == STI_NOTPRESENT); if (mType->style(*of.f) == soeOPTIONAL) return std::nullopt; - XRPL_ASSERT(mType->style(*of.f) == soeDEFAULT); + XRPL_ASSERT("STObject::at from an OptionaledField template default style", mType->style(*of.f) == soeDEFAULT); return typename T::value_type{}; } return u->value(); diff --git a/include/xrpl/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h index 7792f59983f..77c876c154c 100644 --- a/include/xrpl/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -257,7 +257,7 @@ inline STPathElement::STPathElement( is_offer_ = false; mAccountID = *account; mType |= typeAccount; - XRPL_ASSERT(mAccountID != noAccount()); + XRPL_ASSERT("STPathElement constructor account set", mAccountID != noAccount()); } if (currency) @@ -270,7 +270,7 @@ inline STPathElement::STPathElement( { mIssuerID = *issuer; mType |= typeIssuer; - XRPL_ASSERT(mIssuerID != noAccount()); + XRPL_ASSERT("STPathElement constructor issuer set", mIssuerID != noAccount()); } hash_value_ = get_hash(*this); diff --git a/include/xrpl/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h index a28bcd3b6e5..4b5c9a74b89 100644 --- a/include/xrpl/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -176,7 +176,7 @@ STValidation::STValidation( Throw("Invalid signature in validation"); } - XRPL_ASSERT(nodeID_.isNonZero()); + XRPL_ASSERT("STValidation constructor from serializer node check", nodeID_.isNonZero()); } /** Construct, sign and trust a new STValidation issued by this node. @@ -199,7 +199,7 @@ STValidation::STValidation( , nodeID_(nodeID) , seenTime_(signTime) { - XRPL_ASSERT(nodeID_.isNonZero()); + XRPL_ASSERT("STValidation constructor with keys node check", nodeID_.isNonZero()); // First, set our own public key: if (publicKeyType(pk) != KeyType::secp256k1) diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index f72bd71a73a..41ae42c31c9 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -55,7 +55,7 @@ class Serializer if (size) { - XRPL_ASSERT(data != nullptr); + XRPL_ASSERT("Serializer constructor from void const* not null", data != nullptr); std::memcpy(mData.data(), data, size); } } @@ -300,7 +300,7 @@ Serializer::addVL(Iter begin, Iter end, int len) len -= begin->size(); #endif } - XRPL_ASSERT(len == 0); + XRPL_ASSERT("Serializer::addVL len match", len == 0); return ret; } diff --git a/include/xrpl/protocol/TxMeta.h b/include/xrpl/protocol/TxMeta.h index 32a0b3601a0..36d45e353ac 100644 --- a/include/xrpl/protocol/TxMeta.h +++ b/include/xrpl/protocol/TxMeta.h @@ -116,7 +116,7 @@ class TxMeta STAmount getDeliveredAmount() const { - XRPL_ASSERT(hasDeliveredAmount()); + XRPL_ASSERT("TxMeta::getDeliveredAmount", hasDeliveredAmount()); return *mDelivered; } diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index bc07cac9b38..da920680f07 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -126,7 +126,7 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) { // should never happen, but if it does then it seems natural to define // the a null set of numbers to be zero, so the remainder is also zero. - XRPL_ASSERT(0); + XRPL_UNREACHABLE("b58_fast::detail::inplace_bigint_div_rem empty numerator"); return 0; } @@ -142,8 +142,8 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) unsigned __int128 const denom128 = denom; unsigned __int128 const d = num / denom128; unsigned __int128 const r = num - (denom128 * d); - XRPL_ASSERT(d >> 64 == 0); - XRPL_ASSERT(r >> 64 == 0); + XRPL_ASSERT("b58_fast::detail::inplace_bigint_div_rem::div_rem_64 d check", d >> 64 == 0); + XRPL_ASSERT("b58_fast::detail::inplace_bigint_div_rem::div_rem_64 r check", r >> 64 == 0); return {static_cast(d), static_cast(r)}; }; diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index b06ebe2ff95..18b90235ed4 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -401,7 +401,7 @@ class Logic { std::lock_guard _(lock_); Entry& entry(iter->second); - XRPL_ASSERT(entry.refcount == 0); + XRPL_ASSERT("Resource::Logic::erase entry not used", entry.refcount == 0); inactive_.erase(inactive_.iterator_to(entry)); table_.erase(iter); } @@ -433,7 +433,7 @@ class Logic admin_.erase(admin_.iterator_to(entry)); break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("Resource::Logic::release invalid entry kind"); break; } inactive_.push_back(entry); diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 396f6151b93..5745ad43079 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -25,14 +25,17 @@ #include #include #include +#include #include #include #include #include #include +#include #include +#include namespace ripple { @@ -509,7 +512,7 @@ template void BaseWSPeer::fail(error_code ec, String const& what) { - XRPL_ASSERT(strand_.running_in_this_thread()); + XRPL_ASSERT("BaseWSPeer::fail strand check", strand_.running_in_this_thread()); cancel_timer(); if (!ec_ && ec != boost::asio::error::operation_aborted) diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index 029fd8cfd62..6bdf6c717ed 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -224,7 +224,7 @@ Logs::fromSeverity(beast::severities::Severity level) return lsERROR; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("Logs::fromSeverity invalid severity"); [[fallthrough]]; case kFatal: break; @@ -250,7 +250,7 @@ Logs::toSeverity(LogSeverity level) case lsERROR: return kError; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("Logs::toSeverity invalid severity"); [[fallthrough]]; case lsFATAL: break; @@ -277,7 +277,7 @@ Logs::toString(LogSeverity s) case lsFATAL: return "Fatal"; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("Logs::toString invalid severity"); return "Unknown"; } } @@ -341,7 +341,7 @@ Logs::format( output += "ERR "; break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("Logs::format invalid severity"); [[fallthrough]]; case kFatal: output += "FTL "; diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 8f7dccd26f9..615dec2fbf3 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -235,7 +235,7 @@ Number::operator+=(Number const& y) *this = Number{}; return *this; } - XRPL_ASSERT(isnormal() && y.isnormal()); + XRPL_ASSERT("Number operator+= is normal", isnormal() && y.isnormal()); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -374,7 +374,7 @@ Number::operator*=(Number const& y) *this = y; return *this; } - XRPL_ASSERT(isnormal() && y.isnormal()); + XRPL_ASSERT("Number operator*= is normal", isnormal() && y.isnormal()); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -428,7 +428,7 @@ Number::operator*=(Number const& y) std::to_string(xe)); mantissa_ = xm * zn; exponent_ = xe; - XRPL_ASSERT(isnormal() || *this == Number{}); + XRPL_ASSERT("Number operator*= result is normal", isnormal() || *this == Number{}); return *this; } @@ -531,7 +531,7 @@ to_string(Number const& amount) negative = true; } - XRPL_ASSERT(exponent + 43 > 0); + XRPL_ASSERT("to_string from Number minimum exponent", exponent + 43 > 0); ptrdiff_t const pad_prefix = 27; ptrdiff_t const pad_suffix = 23; @@ -557,7 +557,7 @@ to_string(Number const& amount) if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT("to_string from Number first distance check", post_to >= post_from); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -566,7 +566,7 @@ to_string(Number const& amount) if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT("to_string from Number second distance check", post_to >= post_from); post_to = std::find_if( std::make_reverse_iterator(post_to), diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index b6351530596..f4eb4c5735e 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -48,7 +48,7 @@ class AsyncObject ~AsyncObject() { // Destroying the object with I/O pending? Not a clean exit! - XRPL_ASSERT(m_pending.load() == 0); + XRPL_ASSERT("AsyncObject destructor nothing pending", m_pending.load() == 0); } /** RAII container that maintains the count of pending I/O. @@ -153,8 +153,8 @@ class ResolverAsioImpl : public ResolverAsio, ~ResolverAsioImpl() override { - XRPL_ASSERT(m_work.empty()); - XRPL_ASSERT(m_stopped); + XRPL_ASSERT("ResolverAsioImpl destructor no work", m_work.empty()); + XRPL_ASSERT("ResolverAsioImpl destructor stopped", m_stopped); } //------------------------------------------------------------------------- @@ -176,8 +176,8 @@ class ResolverAsioImpl : public ResolverAsio, void start() override { - XRPL_ASSERT(m_stopped == true); - XRPL_ASSERT(m_stop_called == false); + XRPL_ASSERT("ResolverAsioImpl::start stopped", m_stopped == true); + XRPL_ASSERT("ResolverAsioImpl::start not stopping", m_stop_called == false); if (m_stopped.exchange(false) == true) { @@ -217,8 +217,8 @@ class ResolverAsioImpl : public ResolverAsio, resolve(std::vector const& names, HandlerType const& handler) override { - XRPL_ASSERT(m_stop_called == false); - XRPL_ASSERT(!names.empty()); + XRPL_ASSERT("ResolverAsioImpl::resolve not stopping", m_stop_called == false); + XRPL_ASSERT("ResolverAsioImpl::resolve names check", !names.empty()); // TODO NIKB use rvalue references to construct and move // reducing cost. @@ -234,7 +234,7 @@ class ResolverAsioImpl : public ResolverAsio, // Resolver void do_stop(CompletionCounter) { - XRPL_ASSERT(m_stop_called == true); + XRPL_ASSERT("ResolverAsioImpl::do_stop stopping", m_stop_called == true); if (m_stopped.exchange(true) == false) { @@ -379,7 +379,7 @@ class ResolverAsioImpl : public ResolverAsio, HandlerType const& handler, CompletionCounter) { - XRPL_ASSERT(!names.empty()); + XRPL_ASSERT("ResolverAsioImpl::do_resolve names check", !names.empty()); if (m_stop_called == false) { diff --git a/src/libxrpl/beast/clock/basic_seconds_clock.cpp b/src/libxrpl/beast/clock/basic_seconds_clock.cpp index 3f3f819033b..5860b55e58a 100644 --- a/src/libxrpl/beast/clock/basic_seconds_clock.cpp +++ b/src/libxrpl/beast/clock/basic_seconds_clock.cpp @@ -57,7 +57,7 @@ static_assert(std::atomic::is_always_lock_free); seconds_clock_thread::~seconds_clock_thread() { - XRPL_ASSERT(thread_.joinable()); + XRPL_ASSERT("seconds_clock_thread destructor thread joinable", thread_.joinable()); { std::lock_guard lock(mut_); stop_ = true; diff --git a/src/libxrpl/beast/core/SemanticVersion.cpp b/src/libxrpl/beast/core/SemanticVersion.cpp index 8ec30a4133f..6984af2d003 100644 --- a/src/libxrpl/beast/core/SemanticVersion.cpp +++ b/src/libxrpl/beast/core/SemanticVersion.cpp @@ -304,7 +304,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) if (isNumeric(left)) { - XRPL_ASSERT(isNumeric(right)); + XRPL_ASSERT("beast::compare SemanticVersion both numeric", isNumeric(right)); int const iLeft(lexicalCastThrow(left)); int const iRight(lexicalCastThrow(right)); @@ -316,7 +316,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) } else { - XRPL_ASSERT(!isNumeric(right)); + XRPL_ASSERT("beast::compare SemanticVersion both non-numeric", !isNumeric(right)); int result = left.compare(right); diff --git a/src/libxrpl/beast/insight/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp index d5b52b92a34..b66670168ce 100644 --- a/src/libxrpl/beast/insight/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -400,7 +400,7 @@ class StatsDCollectorImp for (auto const& s : *keepAlive) { std::size_t const length(s.size()); - XRPL_ASSERT(!s.empty()); + XRPL_ASSERT("beast::insight::detail::StatsDCollectorImp::send_buffers not empty check", !s.empty()); if (!buffers.empty() && (size + length) > max_packet_size) { log(buffers); diff --git a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp index 436ec617560..6f4897130b8 100644 --- a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp @@ -199,7 +199,7 @@ PropertyStream::Source::add(Source& source) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(source.lock_, std::adopt_lock); - XRPL_ASSERT(source.parent_ == nullptr); + XRPL_ASSERT("beast::PropertyStream::Source::add null source parent", source.parent_ == nullptr); children_.push_back(source.item_); source.parent_ = this; } @@ -211,7 +211,7 @@ PropertyStream::Source::remove(Source& child) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(child.lock_, std::adopt_lock); - XRPL_ASSERT(child.parent_ == this); + XRPL_ASSERT("beast::PropertyStream::Source::remove child parent match", child.parent_ == this); children_.erase(children_.iterator_to(child.item_)); child.parent_ = nullptr; } diff --git a/src/libxrpl/crypto/RFC1751.cpp b/src/libxrpl/crypto/RFC1751.cpp index 74e2dad3a09..a011ba30b48 100644 --- a/src/libxrpl/crypto/RFC1751.cpp +++ b/src/libxrpl/crypto/RFC1751.cpp @@ -270,10 +270,10 @@ RFC1751::extract(char const* s, int start, int length) unsigned char cr; unsigned long x; - XRPL_ASSERT(length <= 11); - XRPL_ASSERT(start >= 0); - XRPL_ASSERT(length >= 0); - XRPL_ASSERT(start + length <= 66); + XRPL_ASSERT("RFC1751::extract maximum length", length <= 11); + XRPL_ASSERT("RFC1751::extract minimum start", start >= 0); + XRPL_ASSERT("RFC1751::extract minimum length", length >= 0); + XRPL_ASSERT("RFC1751::extract maximum start + length", start + length <= 66); int const shiftR = 24 - (length + (start % 8)); cl = s[start / 8]; // get components @@ -320,10 +320,10 @@ RFC1751::insert(char* s, int x, int start, int length) unsigned long y; int shift; - XRPL_ASSERT(length <= 11); - XRPL_ASSERT(start >= 0); - XRPL_ASSERT(length >= 0); - XRPL_ASSERT(start + length <= 66); + XRPL_ASSERT("RFC1751::insert maximum length", length <= 11); + XRPL_ASSERT("RFC1751::insert minimum start", start >= 0); + XRPL_ASSERT("RFC1751::insert minimum length", length >= 0); + XRPL_ASSERT("RFC1751::insert maximum start + length", start + length <= 66); shift = ((8 - ((start + length) % 8)) % 8); y = (long)x << shift; diff --git a/src/libxrpl/json/Object.cpp b/src/libxrpl/json/Object.cpp index 8e726f216f3..8eedca68675 100644 --- a/src/libxrpl/json/Object.cpp +++ b/src/libxrpl/json/Object.cpp @@ -168,7 +168,7 @@ Array::append(Json::Value const& v) return; } } - XRPL_UNREACHABLE(); // Can't get here. + XRPL_UNREACHABLE("Json::Array::append invalid type"); // Can't get here. } void @@ -203,7 +203,7 @@ Object::set(std::string const& k, Json::Value const& v) return; } } - XRPL_UNREACHABLE(); // Can't get here. + XRPL_UNREACHABLE("Json::Object::set invalid type"); // Can't get here. } //------------------------------------------------------------------------------ @@ -214,7 +214,7 @@ template void doCopyFrom(Object& to, Json::Value const& from) { - XRPL_ASSERT(from.isObjectOrNull()); + XRPL_ASSERT("Json::doCopyFrom from check", from.isObjectOrNull()); auto members = from.getMemberNames(); for (auto& m : members) to[m] = from[m]; diff --git a/src/libxrpl/json/json_reader.cpp b/src/libxrpl/json/json_reader.cpp index 42488b3ec87..9e4c429b82c 100644 --- a/src/libxrpl/json/json_reader.cpp +++ b/src/libxrpl/json/json_reader.cpp @@ -953,7 +953,7 @@ operator>>(std::istream& sin, Value& root) Json::Reader reader; bool ok = reader.parse(sin, root); - // JSON_ASSERT( ok ); + // XRPL_ASSERT( ok ); if (!ok) ripple::Throw(reader.getFormatedErrorMessages()); diff --git a/src/libxrpl/json/json_value.cpp b/src/libxrpl/json/json_value.cpp index 155c3e1e044..e57c987b04c 100644 --- a/src/libxrpl/json/json_value.cpp +++ b/src/libxrpl/json/json_value.cpp @@ -207,7 +207,7 @@ Value::Value(ValueType type) : type_(type), allocated_(0) break; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value constructor from ValueType invalid type"); } } @@ -277,7 +277,7 @@ Value::Value(const Value& other) : type_(other.type_) break; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value copy constructor invalid type"); } } @@ -305,7 +305,7 @@ Value::~Value() break; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value deconstructor invalid type"); } } @@ -406,7 +406,7 @@ operator<(const Value& x, const Value& y) } default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value operator< invalid type"); } return 0; // unreachable @@ -452,7 +452,7 @@ operator==(const Value& x, const Value& y) *x.value_.map_ == *y.value_.map_; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value operator== invalid type"); } return 0; // unreachable @@ -461,7 +461,7 @@ operator==(const Value& x, const Value& y) const char* Value::asCString() const { - JSON_ASSERT(type_ == stringValue); + XRPL_ASSERT("Json::Value::asCString", type_ == stringValue); return value_.string_; } @@ -493,7 +493,7 @@ Value::asString() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to string"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asString invalid type"); } return ""; // unreachable @@ -535,7 +535,7 @@ Value::asInt() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to int"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asInt invalid type"); } return 0; // unreachable; @@ -577,7 +577,7 @@ Value::asUInt() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to uint"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asUInt invalid type"); } return 0; // unreachable; @@ -609,7 +609,7 @@ Value::asDouble() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to double"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asDouble invalid type"); } return 0; // unreachable; @@ -641,7 +641,7 @@ Value::asBool() const return value_.map_->size() != 0; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asBool invalid type"); } return false; // unreachable; @@ -695,7 +695,7 @@ Value::isConvertibleTo(ValueType other) const (other == nullValue && value_.map_->size() == 0); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::isConvertible invalid type"); } return false; // unreachable; @@ -729,7 +729,7 @@ Value::size() const return Int(value_.map_->size()); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::size invalid type"); } return 0; // unreachable; @@ -752,7 +752,7 @@ Value::operator bool() const void Value::clear() { - JSON_ASSERT( + XRPL_ASSERT("Json::Value::clear", type_ == nullValue || type_ == arrayValue || type_ == objectValue); switch (type_) @@ -770,7 +770,7 @@ Value::clear() Value& Value::operator[](UInt index) { - JSON_ASSERT(type_ == nullValue || type_ == arrayValue); + XRPL_ASSERT("Json::Value mutating indexing by UInt", type_ == nullValue || type_ == arrayValue); if (type_ == nullValue) *this = Value(arrayValue); @@ -789,7 +789,7 @@ Value::operator[](UInt index) const Value& Value::operator[](UInt index) const { - JSON_ASSERT(type_ == nullValue || type_ == arrayValue); + XRPL_ASSERT("Json::Value const indexing by UInt", type_ == nullValue || type_ == arrayValue); if (type_ == nullValue) return null; @@ -812,7 +812,7 @@ Value::operator[](const char* key) Value& Value::resolveReference(const char* key, bool isStatic) { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT("Json::Value::resolveReference",type_ == nullValue || type_ == objectValue); if (type_ == nullValue) *this = Value(objectValue); @@ -846,7 +846,7 @@ Value::isValidIndex(UInt index) const const Value& Value::operator[](const char* key) const { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT("Json::Value const indexing by char const*", type_ == nullValue || type_ == objectValue); if (type_ == nullValue) return null; @@ -906,7 +906,7 @@ Value::get(std::string const& key, const Value& defaultValue) const Value Value::removeMember(const char* key) { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT("Json::Value::removeMember", type_ == nullValue || type_ == objectValue); if (type_ == nullValue) return null; @@ -947,7 +947,7 @@ Value::isMember(std::string const& key) const Value::Members Value::getMemberNames() const { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT("Json::Value::getMemberNames", type_ == nullValue || type_ == objectValue); if (type_ == nullValue) return Value::Members(); diff --git a/src/libxrpl/json/json_writer.cpp b/src/libxrpl/json/json_writer.cpp index 5f852b241f0..05366a7794b 100644 --- a/src/libxrpl/json/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -70,7 +70,7 @@ valueToString(Int value) if (isNegative) *--current = '-'; - XRPL_ASSERT(current >= buffer); + XRPL_ASSERT("Json::valueToString from Int buffer check", current >= buffer); return current; } @@ -80,7 +80,7 @@ valueToString(UInt value) char buffer[32]; char* current = buffer + sizeof(buffer); uintToString(value, current); - XRPL_ASSERT(current >= buffer); + XRPL_ASSERT("Json::valueToString from UInt buffer check", current >= buffer); return current; } @@ -391,7 +391,7 @@ StyledWriter::writeArrayValue(const Value& value) } else // output on a single line { - XRPL_ASSERT(childValues_.size() == size); + XRPL_ASSERT("StyledWriter::writeArrayValue child size match", childValues_.size() == size); document_ += "[ "; for (unsigned index = 0; index < size; ++index) @@ -483,7 +483,7 @@ StyledWriter::indent() void StyledWriter::unindent() { - XRPL_ASSERT(int(indentString_.size()) >= indentSize_); + XRPL_ASSERT("StyledWriter::unindent indent size", int(indentString_.size()) >= indentSize_); indentString_.resize(indentString_.size() - indentSize_); } @@ -613,7 +613,7 @@ StyledStreamWriter::writeArrayValue(const Value& value) } else // output on a single line { - XRPL_ASSERT(childValues_.size() == size); + XRPL_ASSERT("StyledStreamWriter::writeArrayValue child size match", childValues_.size() == size); *document_ << "[ "; for (unsigned index = 0; index < size; ++index) @@ -706,7 +706,7 @@ StyledStreamWriter::indent() void StyledStreamWriter::unindent() { - XRPL_ASSERT(indentString_.size() >= indentation_.size()); + XRPL_ASSERT("StyledStreamWriter::unindent indent size", indentString_.size() >= indentation_.size()); indentString_.resize(indentString_.size() - indentation_.size()); } diff --git a/src/libxrpl/protocol/AMMCore.cpp b/src/libxrpl/protocol/AMMCore.cpp index 9934df24a13..a4e056b114f 100644 --- a/src/libxrpl/protocol/AMMCore.cpp +++ b/src/libxrpl/protocol/AMMCore.cpp @@ -109,7 +109,7 @@ ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot) // It should be impossible for expiration to be < TOTAL_TIME_SLOT_SECS, // but check just to be safe auto const expiration = auctionSlot[sfExpiration]; - XRPL_ASSERT(expiration >= TOTAL_TIME_SLOT_SECS); + XRPL_ASSERT("ammAuctionTimeSlot minimum expiration", expiration >= TOTAL_TIME_SLOT_SECS); if (expiration >= TOTAL_TIME_SLOT_SECS) { if (auto const start = expiration - TOTAL_TIME_SLOT_SECS; diff --git a/src/libxrpl/protocol/AccountID.cpp b/src/libxrpl/protocol/AccountID.cpp index ab13bfc4c37..1908a641506 100644 --- a/src/libxrpl/protocol/AccountID.cpp +++ b/src/libxrpl/protocol/AccountID.cpp @@ -77,7 +77,7 @@ class AccountIdCache auto ret = encodeBase58Token(TokenType::AccountID, id.data(), id.size()); - XRPL_ASSERT(ret.size() <= 38); + XRPL_ASSERT("detail::AccountIdCache maximum result size", ret.size() <= 38); { std::lock_guard lock(sl); diff --git a/src/libxrpl/protocol/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp index 073dabd6ec1..8287809fd25 100644 --- a/src/libxrpl/protocol/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -212,7 +212,7 @@ error_code_http_status(error_code_i code) std::string rpcErrorString(Json::Value const& jv) { - XRPL_ASSERT(RPC::contains_error(jv)); + XRPL_ASSERT("RPC::rpcErrorString contains error", RPC::contains_error(jv)); return jv[jss::error].asString() + jv[jss::error_message].asString(); } diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index 7148bbbf2c7..e6c87f02764 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -221,7 +221,7 @@ FeatureCollections::FeatureCollections() std::optional FeatureCollections::getRegisteredFeature(std::string const& name) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT("FeatureCollections::getRegisteredFeature startup completed", readOnly); Feature const* feature = getByName(name); if (feature) return feature->feature; @@ -303,7 +303,7 @@ FeatureCollections::registrationIsDone() size_t FeatureCollections::featureToBitsetIndex(uint256 const& f) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT("FeatureCollections::featureToBitsetIndex startup completed", readOnly); Feature const* feature = getByFeature(f); if (!feature) @@ -315,7 +315,7 @@ FeatureCollections::featureToBitsetIndex(uint256 const& f) const uint256 const& FeatureCollections::bitsetIndexToFeature(size_t i) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT("FeatureCollections::bitsetIndexToFeature startup completed", readOnly); Feature const& feature = getByIndex(i); return feature.feature; } @@ -323,7 +323,7 @@ FeatureCollections::bitsetIndexToFeature(size_t i) const std::string FeatureCollections::featureToName(uint256 const& f) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT("FeatureCollections::featureToName startup completed", readOnly); Feature const* feature = getByFeature(f); return feature ? feature->name : to_string(f); } diff --git a/src/libxrpl/protocol/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp index 5389d12d8a9..c3c17aff67c 100644 --- a/src/libxrpl/protocol/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -91,7 +91,7 @@ indexHash(LedgerNameSpace space, Args const&... args) uint256 getBookBase(Book const& book) { - XRPL_ASSERT(isConsistent(book)); + XRPL_ASSERT("getBookBase book consistent", isConsistent(book)); auto const index = indexHash( LedgerNameSpace::BOOK_DIR, @@ -131,7 +131,7 @@ getTicketIndex(AccountID const& account, std::uint32_t ticketSeq) uint256 getTicketIndex(AccountID const& account, SeqProxy ticketSeq) { - XRPL_ASSERT(ticketSeq.isTicket()); + XRPL_ASSERT("getTicketIndex is ticket", ticketSeq.isTicket()); return getTicketIndex(account, ticketSeq.value()); } @@ -237,7 +237,7 @@ offer(AccountID const& id, std::uint32_t seq) noexcept Keylet quality(Keylet const& k, std::uint64_t q) noexcept { - XRPL_ASSERT(k.type == ltDIR_NODE); + XRPL_ASSERT("keylet::quality type check", k.type == ltDIR_NODE); // Indexes are stored in big endian format: they print as hex as stored. // Most significant bytes are first and the least significant bytes @@ -255,7 +255,7 @@ quality(Keylet const& k, std::uint64_t q) noexcept Keylet next_t::operator()(Keylet const& k) const { - XRPL_ASSERT(k.type == ltDIR_NODE); + XRPL_ASSERT("keylet::next_t functor type check", k.type == ltDIR_NODE); return {ltDIR_NODE, getQualityNext(k.key)}; } @@ -357,7 +357,7 @@ nftpage_max(AccountID const& owner) Keylet nftpage(Keylet const& k, uint256 const& token) { - XRPL_ASSERT(k.type == ltNFTOKEN_PAGE); + XRPL_ASSERT("keylet::nftpage type check", k.type == ltNFTOKEN_PAGE); return {ltNFTOKEN_PAGE, (k.key & ~nft::pageMask) + (token & nft::pageMask)}; } diff --git a/src/libxrpl/protocol/Keylet.cpp b/src/libxrpl/protocol/Keylet.cpp index 2c0fdd974e3..562bb212bb0 100644 --- a/src/libxrpl/protocol/Keylet.cpp +++ b/src/libxrpl/protocol/Keylet.cpp @@ -25,7 +25,7 @@ namespace ripple { bool Keylet::check(STLedgerEntry const& sle) const { - XRPL_ASSERT(sle.getType() != ltANY || sle.getType() != ltCHILD); + XRPL_ASSERT("Keylet::check SLE type check", sle.getType() != ltANY || sle.getType() != ltCHILD); if (type == ltANY) return true; diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index bdd0c84e54e..cd564c99547 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -35,7 +35,7 @@ Quality::Quality(Amounts const& amount) Quality& Quality::operator++() { - XRPL_ASSERT(m_value > 0); + XRPL_ASSERT("Quality operator++ minimum value", m_value > 0); --m_value; return *this; } @@ -51,7 +51,7 @@ Quality::operator++(int) Quality& Quality::operator--() { - XRPL_ASSERT(m_value < std::numeric_limits::max()); + XRPL_ASSERT("Quality operator-- maximum value", m_value < std::numeric_limits::max()); ++m_value; return *this; } @@ -81,10 +81,10 @@ ceil_in_impl( // Clamp out if (result.out > amount.out) result.out = amount.out; - XRPL_ASSERT(result.in == limit); + XRPL_ASSERT("ceil_in_impl calculated result check", result.in == limit); return result; } - XRPL_ASSERT(amount.in <= limit); + XRPL_ASSERT("ceil_in_impl no-op result check", amount.in <= limit); return amount; } @@ -120,10 +120,10 @@ ceil_out_impl( // Clamp in if (result.in > amount.in) result.in = amount.in; - XRPL_ASSERT(result.out == limit); + XRPL_ASSERT("ceil_out_impl calculated result check", result.out == limit); return result; } - XRPL_ASSERT(amount.out <= limit); + XRPL_ASSERT("ceil_out_impl no-op result check", amount.out <= limit); return amount; } @@ -146,17 +146,17 @@ Quality composed_quality(Quality const& lhs, Quality const& rhs) { STAmount const lhs_rate(lhs.rate()); - XRPL_ASSERT(lhs_rate != beast::zero); + XRPL_ASSERT("composed_quality nonzero lhs", lhs_rate != beast::zero); STAmount const rhs_rate(rhs.rate()); - XRPL_ASSERT(rhs_rate != beast::zero); + XRPL_ASSERT("composed_quality nonzero rhs", rhs_rate != beast::zero); STAmount const rate(mulRound(lhs_rate, rhs_rate, lhs_rate.issue(), true)); std::uint64_t const stored_exponent(rate.exponent() + 100); std::uint64_t const stored_mantissa(rate.mantissa()); - XRPL_ASSERT((stored_exponent > 0) && (stored_exponent <= 255)); + XRPL_ASSERT("composed_quality exponent", (stored_exponent > 0) && (stored_exponent <= 255)); return Quality((stored_exponent << (64 - 8)) | stored_mantissa); } diff --git a/src/libxrpl/protocol/Rate2.cpp b/src/libxrpl/protocol/Rate2.cpp index fe968c8bccc..dd5072a5a37 100644 --- a/src/libxrpl/protocol/Rate2.cpp +++ b/src/libxrpl/protocol/Rate2.cpp @@ -46,7 +46,7 @@ transferFeeAsRate(std::uint16_t fee) STAmount multiply(STAmount const& amount, Rate const& rate) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("nft::multiply nonzero rate", rate.value != 0); if (rate == parityRate) return amount; @@ -57,7 +57,7 @@ multiply(STAmount const& amount, Rate const& rate) STAmount multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("nft::multiplyRound nonzero rate", rate.value != 0); if (rate == parityRate) return amount; @@ -72,7 +72,7 @@ multiplyRound( Issue const& issue, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("nft::multiplyRound with issue nonzero rate", rate.value != 0); if (rate == parityRate) { @@ -85,7 +85,7 @@ multiplyRound( STAmount divide(STAmount const& amount, Rate const& rate) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("nft::divide nonzero rate", rate.value != 0); if (rate == parityRate) return amount; @@ -96,7 +96,7 @@ divide(STAmount const& amount, Rate const& rate) STAmount divideRound(STAmount const& amount, Rate const& rate, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("nft::divideRound nonzero rate", rate.value != 0); if (rate == parityRate) return amount; @@ -111,7 +111,7 @@ divideRound( Issue const& issue, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("nft::divideRound with issue nonzero rate", rate.value != 0); if (rate == parityRate) return amount; diff --git a/src/libxrpl/protocol/Rules.cpp b/src/libxrpl/protocol/Rules.cpp index 613f882d609..6d6a7e4577c 100644 --- a/src/libxrpl/protocol/Rules.cpp +++ b/src/libxrpl/protocol/Rules.cpp @@ -91,7 +91,7 @@ class Rules::Impl return true; if (!digest_ || !other.digest_) return false; - XRPL_ASSERT(presets_ == other.presets_); + XRPL_ASSERT("Rules::Impl operator== presets match", presets_ == other.presets_); return *digest_ == *other.digest_; } }; @@ -118,7 +118,7 @@ Rules::presets() const bool Rules::enabled(uint256 const& feature) const { - XRPL_ASSERT(impl_); + XRPL_ASSERT("Rules::enabled initialized", impl_); // The functionality of the "NonFungibleTokensV1_1" amendment is // precisely the functionality of the following three amendments @@ -137,7 +137,7 @@ Rules::enabled(uint256 const& feature) const bool Rules::operator==(Rules const& other) const { - XRPL_ASSERT(impl_ && other.impl_); + XRPL_ASSERT("Rules operator== both initialized", impl_ && other.impl_); if (impl_.get() == other.impl_.get()) return true; return *impl_ == *other.impl_; diff --git a/src/libxrpl/protocol/STAccount.cpp b/src/libxrpl/protocol/STAccount.cpp index cce005a5b3f..651a55c3c9a 100644 --- a/src/libxrpl/protocol/STAccount.cpp +++ b/src/libxrpl/protocol/STAccount.cpp @@ -80,8 +80,8 @@ STAccount::getSType() const void STAccount::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == STI_ACCOUNT); + XRPL_ASSERT("STAccount::add binary field", getFName().isBinary()); + XRPL_ASSERT("STAccount::add field type check", getFName().fieldType == STI_ACCOUNT); // Preserve the serialization behavior of an STBlob: // o If we are default (all zeros) serialize as an empty blob. diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index d23928a23de..07895dbb6f6 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -70,7 +70,7 @@ getSNValue(STAmount const& amount) auto ret = static_cast(amount.mantissa()); - XRPL_ASSERT(static_cast(ret) == amount.mantissa()); + XRPL_ASSERT("getSNValue result check", static_cast(ret) == amount.mantissa()); if (amount.negative()) ret = -ret; @@ -220,7 +220,7 @@ STAmount::STAmount(SField const& name, std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(negative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT("STAmount constructor from SField and mantissa maximum value check", mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -235,7 +235,7 @@ STAmount::STAmount( , mOffset(exponent) , mIsNegative(negative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT("STAmount constructor from SField,Issue,mantissa and exponent maximum value check", mValue <= std::numeric_limits::max()); canonicalize(); } @@ -246,7 +246,7 @@ STAmount::STAmount(SField const& name, STAmount const& from) , mOffset(from.mOffset) , mIsNegative(from.mIsNegative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT("STAmount constructor from SField and STAmount maximum value check", mValue <= std::numeric_limits::max()); canonicalize(); } @@ -258,7 +258,7 @@ STAmount::STAmount(std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(mantissa != 0 && negative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT("STAmount constructor from mantissa maximum value check", mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -374,7 +374,7 @@ STAmount::iou() const STAmount& STAmount::operator=(IOUAmount const& iou) { - XRPL_ASSERT(mIsNative == false); + XRPL_ASSERT("STAmount assignment not native", mIsNative == false); mOffset = iou.exponent(); mIsNegative = iou < beast::zero; if (mIsNegative) @@ -512,7 +512,7 @@ getRate(STAmount const& offerOut, STAmount const& offerIn) STAmount r = divide(offerIn, offerOut, noIssue()); if (r == beast::zero) // offer is too good return 0; - XRPL_ASSERT((r.exponent() >= -100) && (r.exponent() <= 155)); + XRPL_ASSERT("getRate exponent within range", (r.exponent() >= -100) && (r.exponent() <= 155)); std::uint64_t ret = r.exponent() + 100; return (ret << (64 - 8)) | r.mantissa(); } @@ -594,7 +594,7 @@ STAmount::getText() const return ret; } - XRPL_ASSERT(mOffset + 43 > 0); + XRPL_ASSERT("STAmount::getText minimum offset", mOffset + 43 > 0); size_t const pad_prefix = 27; size_t const pad_suffix = 23; @@ -618,7 +618,7 @@ STAmount::getText() const if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT("STAmount::getText first distance check", post_to >= post_from); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -627,7 +627,7 @@ STAmount::getText() const if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT("STAmount::getText second distance check", post_to >= post_from); post_to = std::find_if( std::make_reverse_iterator(post_to), @@ -662,7 +662,7 @@ STAmount::add(Serializer& s) const { if (mIsNative) { - XRPL_ASSERT(mOffset == 0); + XRPL_ASSERT("STAmount::add zero offset", mOffset == 0); if (!mIsNegative) s.add64(mValue | cPosNative); @@ -823,11 +823,12 @@ STAmount::canonicalize() if (mOffset > cMaxOffset) Throw("value overflow"); - XRPL_ASSERT( + XRPL_ASSERT("STAmount::canonicalize value in range", (mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue))); - XRPL_ASSERT( + XRPL_ASSERT("STAmount::canonicalize zero value or offset in range", (mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset))); - XRPL_ASSERT((mValue != 0) || (mOffset != -100)); + XRPL_ASSERT("STAmount::canonicalize value and offset check", + (mValue != 0) || (mOffset != -100)); } void diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index 85607d5569d..89cd15e18bf 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -20,7 +20,6 @@ #include #include #include -#include namespace ripple { @@ -30,7 +29,7 @@ STBase::STBase() : fName(&sfGeneric) STBase::STBase(SField const& n) : fName(&n) { - XRPL_ASSERT(fName); + XRPL_ASSERT("STBase constructor field is set", fName); } STBase& @@ -105,13 +104,13 @@ void STBase::add(Serializer& s) const { // Should never be called - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("STBase::add not available"); } bool STBase::isEquivalent(const STBase& t) const { - XRPL_ASSERT(getSType() == STI_NOTPRESENT); + XRPL_ASSERT("STBase::isEquivalent not present", getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; } @@ -125,7 +124,7 @@ void STBase::setFName(SField const& n) { fName = &n; - XRPL_ASSERT(fName); + XRPL_ASSERT("STBase::setFName field is set", fName); } SField const& @@ -137,7 +136,7 @@ STBase::getFName() const void STBase::addFieldID(Serializer& s) const { - XRPL_ASSERT(fName->isBinary()); + XRPL_ASSERT("STBase::addFieldID binary field", fName->isBinary()); s.addFieldID(fName->fieldType, fName->fieldValue); } diff --git a/src/libxrpl/protocol/STBlob.cpp b/src/libxrpl/protocol/STBlob.cpp index 04480575f0f..026699a4b56 100644 --- a/src/libxrpl/protocol/STBlob.cpp +++ b/src/libxrpl/protocol/STBlob.cpp @@ -54,8 +54,8 @@ STBlob::getText() const void STBlob::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT( + XRPL_ASSERT("STBlob::add binary field", getFName().isBinary()); + XRPL_ASSERT("STBlob::add field type check", (getFName().fieldType == STI_VL) || (getFName().fieldType == STI_ACCOUNT)); s.addVL(value_.data(), value_.size()); diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 257c8248cf7..f014cb80772 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -196,7 +196,7 @@ Json::Value STUInt64::getJson(JsonOptions) const { std::string str(16, 0); auto ret = std::to_chars(str.data(), str.data() + str.size(), value_, 16); - XRPL_ASSERT(ret.ec == std::errc()); + XRPL_ASSERT("STUInt64::getJson to_chars result", ret.ec == std::errc()); str.resize(std::distance(str.data(), ret.ptr)); return str; } diff --git a/src/libxrpl/protocol/STLedgerEntry.cpp b/src/libxrpl/protocol/STLedgerEntry.cpp index aa1c5cb66f6..72a2d875167 100644 --- a/src/libxrpl/protocol/STLedgerEntry.cpp +++ b/src/libxrpl/protocol/STLedgerEntry.cpp @@ -157,7 +157,7 @@ STLedgerEntry::thread( if (oldPrevTxID == txID) { // this transaction is already threaded - XRPL_ASSERT(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); + XRPL_ASSERT("STLedgerEntry::thread ledger sequence match", getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); return false; } diff --git a/src/libxrpl/protocol/STObject.cpp b/src/libxrpl/protocol/STObject.cpp index dbb96fffbfd..6176660659d 100644 --- a/src/libxrpl/protocol/STObject.cpp +++ b/src/libxrpl/protocol/STObject.cpp @@ -842,7 +842,7 @@ STObject::add(Serializer& s, WhichFields whichFields) const // the type associated by rule with this field name // must be OBJECT, or the object cannot be deserialized SerializedTypeID const sType{field->getSType()}; - XRPL_ASSERT( + XRPL_ASSERT("STObject::add field type check", (sType != STI_OBJECT) || (field->getFName().fieldType == STI_OBJECT)); field->addFieldID(s); diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index 3bce80cbb73..1794465c256 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -208,8 +208,8 @@ STPathSet::getSType() const void STPathSet::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == STI_PATHSET); + XRPL_ASSERT("STPathSet::add binary field", getFName().isBinary()); + XRPL_ASSERT("STPathSet::add field type check", getFName().fieldType == STI_PATHSET); bool first = true; for (auto const& spPath : value) diff --git a/src/libxrpl/protocol/STTx.cpp b/src/libxrpl/protocol/STTx.cpp index 12e844acdb6..e9fd6580d2b 100644 --- a/src/libxrpl/protocol/STTx.cpp +++ b/src/libxrpl/protocol/STTx.cpp @@ -137,7 +137,7 @@ STTx::getMentionedAccounts() const { if (auto sacc = dynamic_cast(&it)) { - XRPL_ASSERT(!sacc->isDefault()); + XRPL_ASSERT("STTx::getMentionedAccounts non empty account", !sacc->isDefault()); if (!sacc->isDefault()) list.insert(sacc->value()); } @@ -298,7 +298,7 @@ STTx::getMetaSQL( std::string rTxn = sqlBlobLiteral(rawTxn.peekData()); auto format = TxFormats::getInstance().findByType(tx_type_); - XRPL_ASSERT(format != nullptr); + XRPL_ASSERT("STTx::getMetaSQL type format check", format != nullptr); return str( boost::format(bfTrans) % to_string(getTransactionID()) % diff --git a/src/libxrpl/protocol/Serializer.cpp b/src/libxrpl/protocol/Serializer.cpp index b54d1f63f48..7d0fe40b99a 100644 --- a/src/libxrpl/protocol/Serializer.cpp +++ b/src/libxrpl/protocol/Serializer.cpp @@ -132,7 +132,7 @@ int Serializer::addFieldID(int type, int name) { int ret = mData.size(); - XRPL_ASSERT((type > 0) && (type < 256) && (name > 0) && (name < 256)); + XRPL_ASSERT("Serializer::addFieldID type and name range check", (type > 0) && (type < 256) && (name > 0) && (name < 256)); if (type < 16) { @@ -201,7 +201,7 @@ Serializer::addVL(Blob const& vector) { int ret = addEncoded(vector.size()); addRaw(vector); - XRPL_ASSERT( + XRPL_ASSERT("Serializer::addVL size match", mData.size() == (ret + vector.size() + encodeLengthLength(vector.size()))); return ret; @@ -483,7 +483,7 @@ SerialIter::getVLDataLength() } else { - XRPL_ASSERT(lenLen == 3); + XRPL_ASSERT("SerialIter::getVLDataLength lenLen", lenLen == 3); int b2 = get8(); int b3 = get8(); datLen = Serializer::decodeVLLength(b1, b2, b3); diff --git a/src/xrpld/app/ledger/OpenLedger.h b/src/xrpld/app/ledger/OpenLedger.h index b41113c7806..955f706d55d 100644 --- a/src/xrpld/app/ledger/OpenLedger.h +++ b/src/xrpld/app/ledger/OpenLedger.h @@ -263,7 +263,7 @@ OpenLedger::apply( // If there are any transactions left, we must have // tried them in at least one final pass - XRPL_ASSERT(retries.empty() || !retry); + XRPL_ASSERT("OpenLedger::apply", retries.empty() || !retry); } //------------------------------------------------------------------------------ diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index a2d5a7da789..e20b72be80f 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -104,7 +104,7 @@ class NetworkOPsImp final : public NetworkOPs FailHard f) : transaction(t), admin(a), local(l), failType(f) { - XRPL_ASSERT(local || failType == FailHard::no); + XRPL_ASSERT("NetworkOPsImp::TransactionStatus constructor", local || failType == FailHard::no); } }; @@ -1215,7 +1215,7 @@ NetworkOPsImp::processTransaction( *transaction->getSTransaction(), view->rules(), app_.config()); - XRPL_ASSERT(validity == Validity::Valid); + XRPL_ASSERT("NetworkOPsImp::processTransaction validity", validity == Validity::Valid); // Not concerned with local checks at this point. if (validity == Validity::SigBad) @@ -1321,9 +1321,9 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) std::vector submit_held; std::vector transactions; mTransactions.swap(transactions); - XRPL_ASSERT(!transactions.empty()); + XRPL_ASSERT("NetworkOPsImp::apply not empty", !transactions.empty()); + XRPL_ASSERT("NetworkOPsImp::apply not running", mDispatchState != DispatchState::running); - XRPL_ASSERT(mDispatchState != DispatchState::running); mDispatchState = DispatchState::running; batchLock.unlock(); @@ -1539,7 +1539,7 @@ NetworkOPsImp::getOwnerInfo( for (auto const& uDirEntry : sleNode->getFieldV256(sfIndexes)) { auto sleCur = lpLedger->read(keylet::child(uDirEntry)); - XRPL_ASSERT(sleCur); + XRPL_ASSERT("NetworkOPsImp::getOwnerInfo child SLE", sleCur); switch (sleCur->getType()) { @@ -1566,7 +1566,7 @@ NetworkOPsImp::getOwnerInfo( case ltACCOUNT_ROOT: case ltDIR_NODE: default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("NetworkOPsImp::getOwnerInfo invalid SLE type"); break; } } @@ -1576,7 +1576,7 @@ NetworkOPsImp::getOwnerInfo( if (uNodeDir) { sleNode = lpLedger->read(keylet::page(root, uNodeDir)); - XRPL_ASSERT(sleNode); + XRPL_ASSERT("NetworkOPsImp::getOwnerInfo next SLE page", sleNode); } } while (uNodeDir); } @@ -1806,7 +1806,7 @@ NetworkOPsImp::switchLastClosedLedger( bool NetworkOPsImp::beginConsensus(uint256 const& networkClosed) { - XRPL_ASSERT(networkClosed.isNonZero()); + XRPL_ASSERT("NetworkOPsImp::beginConsensus networkClosed", networkClosed.isNonZero()); auto closingInfo = m_ledgerMaster.getCurrentLedger()->info(); @@ -1827,8 +1827,8 @@ NetworkOPsImp::beginConsensus(uint256 const& networkClosed) return false; } - XRPL_ASSERT(prevLedger->info().hash == closingInfo.parentHash); - XRPL_ASSERT( + XRPL_ASSERT("NetworkOPsImp::beginConsensus prevLedger hash", prevLedger->info().hash == closingInfo.parentHash); + XRPL_ASSERT("NetworkOPsImp::beginConsensus closedLedger hash", closingInfo.parentHash == m_ledgerMaster.getClosedLedger()->info().hash); @@ -2955,7 +2955,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) lpAccepted->info().hash, alpAccepted); } - XRPL_ASSERT(alpAccepted->getLedger().get() == lpAccepted.get()); + XRPL_ASSERT("NetworkOPsImp::pubLedger accepted", alpAccepted->getLedger().get() == lpAccepted.get()); { JLOG(m_journal.debug()) @@ -3358,7 +3358,7 @@ NetworkOPsImp::pubAccountTransaction( if (last) jvObj.set(jss::account_history_boundary, true); - XRPL_ASSERT( + XRPL_ASSERT("NetworkOPsImp::pubAccountTransaction account_history_tx_stream", jvObj.isMember(jss::account_history_tx_stream) == MultiApiJson::none); for (auto& info : accountHistoryNotify) @@ -3433,7 +3433,7 @@ NetworkOPsImp::pubProposedAccountTransaction( isrListener->getApiVersion(), // [&](Json::Value const& jv) { isrListener->send(jv, true); }); - XRPL_ASSERT( + XRPL_ASSERT("NetworkOPs::pubProposedAccountTransaction account_history_tx_stream", jvObj.isMember(jss::account_history_tx_stream) == MultiApiJson::none); for (auto& info : accountHistoryNotify) @@ -3713,7 +3713,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) return db->newestAccountTxPage(options); } default: { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("NetworkOPsImp::addAccountHistoryJob::getMoreTxns invalid db type"); return {}; } } @@ -3909,7 +3909,7 @@ NetworkOPsImp::subAccountHistoryStart( } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("NetworkOPsImp::subAccountHistoryStart genesis account"); return; } } @@ -4017,7 +4017,7 @@ NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book) if (auto listeners = app_.getOrderBookDB().makeBookListeners(book)) listeners->addSubscriber(isrListener); else - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("NetworkOPsImp::subBook listeners"); return true; } @@ -4036,7 +4036,7 @@ NetworkOPsImp::acceptLedger( { // This code-path is exclusively used when the server is in standalone // mode via `ledger_accept` - XRPL_ASSERT(m_standalone); + XRPL_ASSERT("NetworkOPsImp::acceptLedger standalone", m_standalone); if (!m_standalone) Throw( diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 3ec8befb75a..3dc1f6a6a67 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -52,7 +52,7 @@ getFeeLevelPaid(ReadView const& view, STTx const& tx) return std::pair{baseFee + mod, feePaid + mod}; }(); - XRPL_ASSERT(baseFee.signum() > 0); + XRPL_ASSERT("getFeeLevelPaid positive fee", baseFee.signum() > 0); if (effectiveFeePaid.signum() <= 0 || baseFee.signum() <= 0) { return FeeLevel64(0); @@ -95,7 +95,7 @@ TxQ::FeeMetrics::update( feeLevels.push_back(getFeeLevelPaid(view, *tx.first)); }); std::sort(feeLevels.begin(), feeLevels.end()); - XRPL_ASSERT(size == feeLevels.size()); + XRPL_ASSERT("TxQ::FeeMetrics::update fee levels size", size == feeLevels.size()); JLOG((timeLeap ? j_.warn() : j_.debug())) << "Ledger " << view.info().seq << " has " << size << " transactions. " @@ -247,7 +247,7 @@ TxQ::FeeMetrics::escalatedSeriesFeeLevel( auto const target = snapshot.txnsExpected; auto const multiplier = snapshot.escalationMultiplier; - XRPL_ASSERT(current > target); + XRPL_ASSERT("TxQ::FeeMetrics::escalatedSeriesFeeLevel", current > target); /* Calculate (apologies for the terrible notation) sum(n = current -> last) : multiplier * n * n / (target * target) @@ -292,7 +292,7 @@ std::pair TxQ::MaybeTx::apply(Application& app, OpenView& view, beast::Journal j) { // If the rules or flags change, preflight again - XRPL_ASSERT(pfresult); + XRPL_ASSERT("TxQ::MaybeTx::apply preflight result", pfresult); STAmountSO stAmountSO{view.rules().enabled(fixSTAmountCanonicalize)}; NumberSO stNumberSO{view.rules().enabled(fixUniversalNumber)}; @@ -337,8 +337,8 @@ TxQ::TxQAccount::add(MaybeTx&& txn) auto const seqProx = txn.seqProxy; auto result = transactions.emplace(seqProx, std::move(txn)); - XRPL_ASSERT(result.second); - XRPL_ASSERT(&result.first->second != &txn); + XRPL_ASSERT("TxQ::TxQAccount::add success", result.second); + XRPL_ASSERT("TxQ::TxQAccount::add transaction moved", &result.first->second != &txn); return result.first->second; } @@ -448,7 +448,7 @@ TxQ::erase(TxQ::FeeMultiSet::const_iterator_type candidateIter) // so the memory can be freed. auto const found = txQAccount.remove(seqProx); (void)found; - XRPL_ASSERT(found); + XRPL_ASSERT("TxQ::erase account removed", found); return newCandidateIter; } @@ -460,15 +460,15 @@ TxQ::eraseAndAdvance(TxQ::FeeMultiSet::const_iterator_type candidateIter) auto& txQAccount = byAccount_.at(candidateIter->account); auto const accountIter = txQAccount.transactions.find(candidateIter->seqProxy); - XRPL_ASSERT(accountIter != txQAccount.transactions.end()); + XRPL_ASSERT("TxQ::eraseAndAdvance account found", accountIter != txQAccount.transactions.end()); // Note that sequence-based transactions must be applied in sequence order // from smallest to largest. But ticket-based transactions can be // applied in any order. - XRPL_ASSERT( + XRPL_ASSERT("TxQ::eraseAndAdvance ticket or sequence", candidateIter->seqProxy.isTicket() || accountIter == txQAccount.transactions.begin()); - XRPL_ASSERT(byFee_.iterator_to(accountIter->second) == candidateIter); + XRPL_ASSERT("TxQ::eraseAndAdvance found in byFee", byFee_.iterator_to(accountIter->second) == candidateIter); auto const accountNextIter = std::next(accountIter); // Check if the next transaction for this account is earlier in the queue, @@ -515,7 +515,7 @@ TxQ::tryClearAccountQueueUpThruTx( beast::Journal j) { SeqProxy const tSeqProx{tx.getSeqProxy()}; - XRPL_ASSERT(beginTxIter != accountIter->second.transactions.end()); + XRPL_ASSERT("TxQ::tryClearAccountQueueUpThruTx account not empty", beginTxIter != accountIter->second.transactions.end()); // This check is only concerned with the range from // [aSeqProxy, tSeqProxy) @@ -998,7 +998,7 @@ TxQ::apply( // o The current first thing in the queue has a Ticket and // * The tx has a Ticket that precedes it or // * txSeqProx == acctSeqProx. - XRPL_ASSERT(prevIter != txIter->end); + XRPL_ASSERT("TxQ::apply not end", prevIter != txIter->end); if (prevIter == txIter->end || txSeqProx < prevIter->first) { // The first Sequence number in the queue must be the @@ -1119,7 +1119,7 @@ TxQ::apply( // inserted in the middle from fouling up later transactions. auto const potentialTotalSpend = totalFee + std::min(balance - std::min(balance, reserve), potentialSpend); - XRPL_ASSERT( + XRPL_ASSERT("TxQ::apply spend check", potentialTotalSpend > XRPAmount{0} || (potentialTotalSpend == XRPAmount{0} && multiTxn->applyView.fees().base == 0)); @@ -1152,7 +1152,7 @@ TxQ::apply( return {pcresult.ter, false}; // Too low of a fee should get caught by preclaim - XRPL_ASSERT(feeLevelPaid >= baseLevel); + XRPL_ASSERT("TxQ::apply fee check", feeLevelPaid >= baseLevel); JLOG(j_.trace()) << "Transaction " << transactionID << " from account " << account << " has fee level of " << feeLevelPaid @@ -1277,7 +1277,7 @@ TxQ::apply( // The queue is full, and this transaction is more // valuable, so kick out the cheapest transaction. auto dropRIter = endAccount.transactions.rbegin(); - XRPL_ASSERT(dropRIter->second.account == lastRIter->account); + XRPL_ASSERT("TxQ::apply drop cheapest", dropRIter->second.account == lastRIter->account); JLOG(j_.info()) << "Removing last item of account " << lastRIter->account << " from queue with average fee of " << endEffectiveFeeLevel @@ -1307,7 +1307,7 @@ TxQ::apply( std::tie(accountIter, created) = byAccount_.emplace(account, TxQAccount(tx)); (void)created; - XRPL_ASSERT(created); + XRPL_ASSERT("TxQ::apply account created", created); } // Modify the flags for use when coming out of the queue. // These changes _may_ cause an extra `preflight`, but as long as @@ -1520,7 +1520,7 @@ TxQ::accept(Application& app, OpenView& view) // making things worse, drop the _last_ transaction for // this account. auto dropRIter = account.transactions.rbegin(); - XRPL_ASSERT( + XRPL_ASSERT("TxQ::accept account check", dropRIter->second.account == candidateIter->account); @@ -1553,7 +1553,7 @@ TxQ::accept(Application& app, OpenView& view) LedgerHash const& parentHash = view.info().parentHash; #if !NDEBUG auto const startingSize = byFee_.size(); - XRPL_ASSERT(parentHash != parentHash_); + XRPL_ASSERT("TxQ::accept new parent hash", parentHash != parentHash_); parentHash_ = parentHash; #endif // byFee_ doesn't "own" the candidate objects inside it, so it's @@ -1575,7 +1575,7 @@ TxQ::accept(Application& app, OpenView& view) byFee_.insert(candidate); } } - XRPL_ASSERT(byFee_.size() == startingSize); + XRPL_ASSERT("TxQ::accept byFee size", byFee_.size() == startingSize); return ledgerChanged; } @@ -1734,10 +1734,10 @@ TxQ::removeFromByFee( // If the transaction we're holding replaces a transaction in the // queue, remove the transaction that is being replaced. auto deleteIter = byFee_.iterator_to((*replacedTxIter)->second); - XRPL_ASSERT(deleteIter != byFee_.end()); - XRPL_ASSERT(&(*replacedTxIter)->second == &*deleteIter); - XRPL_ASSERT(deleteIter->seqProxy == tx->getSeqProxy()); - XRPL_ASSERT(deleteIter->account == (*tx)[sfAccount]); + XRPL_ASSERT("TxQ::removeFromByFee found in byFee", deleteIter != byFee_.end()); + XRPL_ASSERT("TxQ::removeFromByFee matching transaction", &(*replacedTxIter)->second == &*deleteIter); + XRPL_ASSERT("TxQ::removeFromByFee matching sequence", deleteIter->seqProxy == tx->getSeqProxy()); + XRPL_ASSERT("TxQ::removeFromByFee matching account", deleteIter->account == (*tx)[sfAccount]); erase(deleteIter); }