From b4e3cfbc9b93503e7c1bf0d995e4ada917452901 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Thu, 13 Jun 2024 16:31:52 +0100 Subject: [PATCH] Add XRPL_ASSERT and XRPL_UNREACHABLE --- Builds/CMake/RippledCore.cmake | 1 + Builds/levelization/results/loops.txt | 5 +- Builds/levelization/results/ordering.txt | 1 - .../antithesis_instrumentation.h | 102 +- external/antithesis-sdk/antithesis_sdk.h | 1198 ++++++++++------- src/ripple/app/consensus/RCLConsensus.cpp | 14 +- src/ripple/app/consensus/RCLCxPeerPos.cpp | 3 +- src/ripple/app/consensus/RCLCxTx.h | 4 +- src/ripple/app/consensus/RCLValidations.cpp | 7 +- src/ripple/app/ledger/AcceptedLedgerTx.cpp | 4 +- src/ripple/app/ledger/ConsensusTransSetSF.cpp | 4 +- src/ripple/app/ledger/Ledger.cpp | 40 +- src/ripple/app/ledger/LedgerHistory.cpp | 26 +- src/ripple/app/ledger/OpenLedger.h | 4 +- src/ripple/app/ledger/OrderBookDB.cpp | 2 +- src/ripple/app/ledger/TransactionStateSF.cpp | 2 +- src/ripple/app/ledger/impl/BuildLedger.cpp | 6 +- src/ripple/app/ledger/impl/InboundLedger.cpp | 16 +- src/ripple/app/ledger/impl/InboundLedgers.cpp | 10 +- src/ripple/app/ledger/impl/LedgerCleaner.cpp | 4 +- .../app/ledger/impl/LedgerDeltaAcquire.cpp | 6 +- src/ripple/app/ledger/impl/LedgerMaster.cpp | 30 +- .../app/ledger/impl/LedgerReplayTask.cpp | 8 +- src/ripple/app/ledger/impl/LedgerReplayer.cpp | 2 +- .../app/ledger/impl/SkipListAcquire.cpp | 4 +- src/ripple/app/ledger/impl/TimeoutCounter.cpp | 2 +- src/ripple/app/main/Application.cpp | 34 +- src/ripple/app/main/GRPCServer.cpp | 4 +- src/ripple/app/main/LoadManager.cpp | 2 +- src/ripple/app/main/NodeStoreScheduler.cpp | 2 +- src/ripple/app/misc/FeeVoteImpl.cpp | 2 +- src/ripple/app/misc/HashRouter.cpp | 2 +- src/ripple/app/misc/NegativeUNLVote.cpp | 6 +- src/ripple/app/misc/NetworkOPs.cpp | 34 +- src/ripple/app/misc/SHAMapStoreImp.cpp | 6 +- src/ripple/app/misc/detail/WorkBase.h | 2 +- src/ripple/app/misc/detail/WorkFile.h | 4 +- src/ripple/app/misc/impl/AMMHelpers.cpp | 2 +- src/ripple/app/misc/impl/AMMUtils.cpp | 2 +- src/ripple/app/misc/impl/AmendmentTable.cpp | 2 +- src/ripple/app/misc/impl/Manifest.cpp | 2 +- src/ripple/app/misc/impl/Transaction.cpp | 2 +- src/ripple/app/misc/impl/TxQ.cpp | 46 +- src/ripple/app/misc/impl/ValidatorList.cpp | 51 +- src/ripple/app/misc/impl/ValidatorSite.cpp | 4 +- src/ripple/app/paths/Credit.cpp | 8 +- src/ripple/app/paths/Flow.cpp | 2 +- src/ripple/app/paths/PathRequest.cpp | 2 +- src/ripple/app/paths/Pathfinder.cpp | 13 +- src/ripple/app/paths/RippleLineCache.cpp | 6 +- src/ripple/app/paths/impl/AMMLiquidity.cpp | 2 +- src/ripple/app/paths/impl/AmountSpec.h | 12 +- src/ripple/app/paths/impl/BookStep.cpp | 12 +- src/ripple/app/paths/impl/DirectStep.cpp | 10 +- src/ripple/app/paths/impl/FlowDebugInfo.h | 4 +- src/ripple/app/paths/impl/PaySteps.cpp | 10 +- src/ripple/app/paths/impl/StepChecks.h | 2 +- src/ripple/app/paths/impl/StrandFlow.h | 16 +- src/ripple/app/paths/impl/XRPEndpointStep.cpp | 4 +- src/ripple/app/rdb/RelationalDatabase.h | 2 +- .../app/rdb/backend/detail/impl/Node.cpp | 9 +- .../app/rdb/backend/impl/PostgresDatabase.cpp | 84 +- src/ripple/app/rdb/impl/Vacuum.cpp | 4 +- src/ripple/app/reporting/ETLHelpers.h | 2 +- src/ripple/app/reporting/ETLSource.cpp | 8 +- src/ripple/app/reporting/ETLSource.h | 6 +- src/ripple/app/reporting/ReportingETL.cpp | 12 +- src/ripple/app/reporting/ReportingETL.h | 6 +- src/ripple/app/tx/impl/AMMBid.cpp | 4 +- src/ripple/app/tx/impl/AMMDeposit.cpp | 2 +- src/ripple/app/tx/impl/AMMVote.cpp | 2 +- src/ripple/app/tx/impl/AMMWithdraw.cpp | 2 +- src/ripple/app/tx/impl/ApplyContext.cpp | 4 +- src/ripple/app/tx/impl/Change.cpp | 4 +- src/ripple/app/tx/impl/CreateOffer.cpp | 20 +- src/ripple/app/tx/impl/DeleteAccount.cpp | 10 +- src/ripple/app/tx/impl/NFTokenCreateOffer.cpp | 2 +- src/ripple/app/tx/impl/NFTokenMint.cpp | 2 +- src/ripple/app/tx/impl/Offer.h | 2 +- src/ripple/app/tx/impl/OfferStream.cpp | 4 +- src/ripple/app/tx/impl/PayChan.cpp | 4 +- src/ripple/app/tx/impl/Payment.cpp | 2 +- src/ripple/app/tx/impl/SetSignerList.cpp | 12 +- src/ripple/app/tx/impl/Taker.cpp | 40 +- src/ripple/app/tx/impl/Transactor.cpp | 20 +- src/ripple/app/tx/impl/XChainBridge.cpp | 4 +- src/ripple/app/tx/impl/applySteps.cpp | 10 +- .../app/tx/impl/details/NFTokenUtils.cpp | 2 +- src/ripple/basics/Buffer.h | 4 +- src/ripple/basics/FeeUnits.h | 10 +- src/ripple/basics/SlabAllocator.h | 8 +- src/ripple/basics/Slice.h | 4 +- src/ripple/basics/base_uint.h | 7 +- src/ripple/basics/impl/Log.cpp | 10 +- src/ripple/basics/impl/Number.cpp | 14 +- src/ripple/basics/impl/ResolverAsio.cpp | 20 +- src/ripple/basics/instrumentation.h | 38 + src/ripple/basics/partitioned_unordered_map.h | 4 +- src/ripple/basics/random.h | 4 +- src/ripple/basics/spinlock.h | 4 +- src/ripple/beast/asio/io_latency_probe.h | 6 +- .../beast/clock/basic_seconds_clock.cpp | 4 +- src/ripple/beast/clock/manual_clock.h | 6 +- .../detail/aged_unordered_container.h | 4 +- src/ripple/beast/core/LexicalCast.h | 2 +- src/ripple/beast/core/SemanticVersion.cpp | 6 +- .../beast/insight/impl/StatsDCollector.cpp | 4 +- src/ripple/beast/net/IPAddress.h | 4 +- src/ripple/beast/net/IPAddressV6.h | 2 +- src/ripple/beast/utility/Journal.h | 4 +- src/ripple/beast/utility/rngfill.h | 4 +- .../beast/utility/src/beast_Journal.cpp | 2 +- .../utility/src/beast_PropertyStream.cpp | 6 +- src/ripple/consensus/Consensus.h | 18 +- src/ripple/consensus/ConsensusTypes.h | 2 +- src/ripple/consensus/LedgerTiming.h | 4 +- src/ripple/consensus/LedgerTrie.h | 22 +- src/ripple/consensus/Validations.h | 4 +- src/ripple/core/Coro.ipp | 4 +- src/ripple/core/DatabaseCon.h | 2 +- src/ripple/core/JobTypes.h | 6 +- src/ripple/core/Pg.cpp | 6 +- src/ripple/core/impl/Config.cpp | 10 +- src/ripple/core/impl/DatabaseCon.cpp | 2 +- src/ripple/core/impl/Job.cpp | 2 +- src/ripple/core/impl/JobQueue.cpp | 42 +- src/ripple/core/impl/LoadEvent.cpp | 4 +- src/ripple/core/impl/Workers.cpp | 4 +- src/ripple/crypto/impl/RFC1751.cpp | 18 +- src/ripple/crypto/impl/csprng.cpp | 2 +- src/ripple/json/impl/Object.cpp | 8 +- src/ripple/json/impl/json_assert.h | 4 +- src/ripple/json/impl/json_writer.cpp | 14 +- src/ripple/ledger/ApplyView.h | 2 +- src/ripple/ledger/ReadView.h | 2 +- src/ripple/ledger/detail/ReadViewFwdRange.ipp | 2 +- src/ripple/ledger/impl/ApplyStateTable.cpp | 20 +- src/ripple/ledger/impl/ApplyView.cpp | 4 +- src/ripple/ledger/impl/ApplyViewImpl.cpp | 2 +- src/ripple/ledger/impl/BookDirs.cpp | 14 +- src/ripple/ledger/impl/Directory.cpp | 10 +- src/ripple/ledger/impl/PaymentSandbox.cpp | 13 +- src/ripple/ledger/impl/RawStateTable.cpp | 6 +- src/ripple/ledger/impl/View.cpp | 60 +- src/ripple/net/impl/DatabaseBody.ipp | 2 +- src/ripple/net/impl/DatabaseDownloader.cpp | 4 +- src/ripple/net/impl/HTTPStream.cpp | 4 +- src/ripple/net/impl/InfoSub.cpp | 2 +- src/ripple/net/impl/RPCCall.cpp | 2 +- src/ripple/nodestore/Database.h | 8 +- .../nodestore/backend/CassandraFactory.cpp | 10 +- .../nodestore/backend/MemoryFactory.cpp | 6 +- src/ripple/nodestore/backend/NuDBFactory.cpp | 4 +- .../nodestore/backend/RocksDBFactory.cpp | 8 +- src/ripple/nodestore/impl/BatchWriter.cpp | 2 +- src/ripple/nodestore/impl/Database.cpp | 12 +- src/ripple/nodestore/impl/DatabaseNodeImp.h | 2 +- .../nodestore/impl/DatabaseShardImp.cpp | 33 +- src/ripple/nodestore/impl/DecodedBlob.cpp | 4 +- src/ripple/nodestore/impl/EncodedBlob.h | 6 +- src/ripple/nodestore/impl/ManagerImp.cpp | 2 +- src/ripple/nodestore/impl/Shard.cpp | 4 +- src/ripple/nodestore/impl/TaskQueue.cpp | 6 +- src/ripple/overlay/Compression.h | 4 +- src/ripple/overlay/Slot.h | 2 +- src/ripple/overlay/impl/ConnectAttempt.cpp | 2 +- src/ripple/overlay/impl/Message.cpp | 4 +- src/ripple/overlay/impl/OverlayImpl.cpp | 16 +- src/ripple/overlay/impl/OverlayImpl.h | 4 +- src/ripple/overlay/impl/PeerImp.cpp | 30 +- src/ripple/overlay/impl/ProtocolMessage.h | 4 +- src/ripple/overlay/impl/TrafficCount.h | 3 +- src/ripple/overlay/impl/ZeroCopyStream.h | 2 +- src/ripple/peerfinder/impl/Bootcache.cpp | 4 +- src/ripple/peerfinder/impl/Counts.h | 8 +- src/ripple/peerfinder/impl/Handouts.h | 4 +- src/ripple/peerfinder/impl/Livecache.h | 6 +- src/ripple/peerfinder/impl/Logic.h | 22 +- src/ripple/peerfinder/impl/SlotImp.cpp | 12 +- src/ripple/perflog/impl/PerfLogImp.cpp | 16 +- src/ripple/protocol/AmountConversions.h | 10 +- src/ripple/protocol/Feature.h | 6 +- src/ripple/protocol/Indexes.h | 2 +- src/ripple/protocol/Issue.h | 2 +- src/ripple/protocol/MultiApiJson.h | 6 +- src/ripple/protocol/Quality.h | 2 +- src/ripple/protocol/Rate.h | 2 +- src/ripple/protocol/STBitString.h | 4 +- src/ripple/protocol/STBlob.h | 2 +- src/ripple/protocol/STInteger.h | 4 +- src/ripple/protocol/STObject.h | 16 +- src/ripple/protocol/STPathSet.h | 6 +- src/ripple/protocol/STValidation.h | 6 +- src/ripple/protocol/Serializer.h | 6 +- src/ripple/protocol/TxMeta.h | 2 +- src/ripple/protocol/impl/AMMCore.cpp | 2 +- src/ripple/protocol/impl/AccountID.cpp | 2 +- src/ripple/protocol/impl/ErrorCodes.cpp | 4 +- src/ripple/protocol/impl/Feature.cpp | 8 +- src/ripple/protocol/impl/Indexes.cpp | 14 +- src/ripple/protocol/impl/Keylet.cpp | 2 +- src/ripple/protocol/impl/Quality.cpp | 20 +- src/ripple/protocol/impl/Rate2.cpp | 12 +- src/ripple/protocol/impl/Rules.cpp | 6 +- src/ripple/protocol/impl/SField.cpp | 2 +- src/ripple/protocol/impl/STAccount.cpp | 4 +- src/ripple/protocol/impl/STAmount.cpp | 29 +- src/ripple/protocol/impl/STBase.cpp | 12 +- src/ripple/protocol/impl/STBlob.cpp | 4 +- src/ripple/protocol/impl/STInteger.cpp | 2 +- src/ripple/protocol/impl/STLedgerEntry.cpp | 2 +- src/ripple/protocol/impl/STObject.cpp | 2 +- src/ripple/protocol/impl/STParsedJSON.cpp | 2 +- src/ripple/protocol/impl/STPathSet.cpp | 4 +- src/ripple/protocol/impl/STTx.cpp | 4 +- src/ripple/protocol/impl/STValidation.cpp | 2 +- src/ripple/protocol/impl/STVar.cpp | 2 +- src/ripple/protocol/impl/STVector256.cpp | 4 +- src/ripple/protocol/impl/Serializer.cpp | 6 +- src/ripple/protocol/impl/TxMeta.cpp | 18 +- src/ripple/protocol/impl/b58_utils.h | 8 +- src/ripple/protocol/impl/tokens.cpp | 8 +- src/ripple/resource/impl/Consumer.cpp | 10 +- src/ripple/resource/impl/Entry.h | 2 +- src/ripple/resource/impl/Key.h | 2 +- src/ripple/resource/impl/Logic.h | 6 +- src/ripple/rpc/Status.h | 6 +- src/ripple/rpc/handlers/AMMInfo.cpp | 6 +- src/ripple/rpc/handlers/AccountChannels.cpp | 2 +- src/ripple/rpc/handlers/AccountInfo.cpp | 4 +- src/ripple/rpc/handlers/AccountLines.cpp | 2 +- src/ripple/rpc/handlers/AccountOffers.cpp | 2 +- src/ripple/rpc/handlers/AccountTx.cpp | 6 +- src/ripple/rpc/handlers/Fee1.cpp | 2 +- src/ripple/rpc/handlers/LedgerClosed.cpp | 2 +- src/ripple/rpc/handlers/LedgerDiff.cpp | 2 +- src/ripple/rpc/handlers/LedgerHandler.cpp | 4 +- src/ripple/rpc/handlers/NodeToShard.cpp | 2 +- src/ripple/rpc/handlers/PayChanClaim.cpp | 2 +- src/ripple/rpc/handlers/Tx.cpp | 14 +- src/ripple/rpc/impl/Handler.cpp | 8 +- src/ripple/rpc/impl/RPCHelpers.cpp | 14 +- src/ripple/rpc/impl/RPCHelpers.h | 2 +- src/ripple/rpc/impl/Role.cpp | 2 +- src/ripple/rpc/impl/ShardArchiveHandler.cpp | 4 +- src/ripple/rpc/impl/Status.cpp | 4 +- src/ripple/rpc/impl/TransactionSign.cpp | 2 +- src/ripple/server/impl/BaseHTTPPeer.h | 2 +- src/ripple/server/impl/BasePeer.h | 2 +- src/ripple/server/impl/BaseWSPeer.h | 5 +- src/ripple/shamap/SHAMap.h | 8 +- src/ripple/shamap/SHAMapItem.h | 4 +- src/ripple/shamap/impl/SHAMap.cpp | 84 +- src/ripple/shamap/impl/SHAMapDelta.cpp | 8 +- src/ripple/shamap/impl/SHAMapInnerNode.cpp | 52 +- src/ripple/shamap/impl/SHAMapLeafNode.cpp | 10 +- src/ripple/shamap/impl/SHAMapNodeID.cpp | 14 +- src/ripple/shamap/impl/SHAMapSync.cpp | 16 +- src/ripple/shamap/impl/ShardFamily.cpp | 2 +- src/ripple/shamap/impl/TaggedPointer.ipp | 14 +- src/test/app/AMM_test.cpp | 2 +- src/test/app/AmendmentTable_test.cpp | 2 +- src/test/app/Check_test.cpp | 2 +- src/test/app/DepositAuth_test.cpp | 4 +- src/test/app/LedgerHistory_test.cpp | 2 +- src/test/app/LedgerLoad_test.cpp | 2 +- src/test/app/LedgerReplay_test.cpp | 6 +- src/test/app/Manifest_test.cpp | 2 +- src/test/app/PayChan_test.cpp | 32 +- src/test/app/PayStrand_test.cpp | 8 +- src/test/app/Regression_test.cpp | 2 +- src/test/app/TheoreticalQuality_test.cpp | 6 +- src/test/app/XChain_test.cpp | 15 +- src/test/basics/base58_test.cpp | 2 +- src/test/basics/base_uint_test.cpp | 2 +- src/test/consensus/NegativeUNL_test.cpp | 2 +- src/test/csf/BasicNetwork.h | 4 +- src/test/csf/Histogram.h | 4 +- src/test/csf/PeerGroup.h | 2 +- src/test/csf/README.md | 2 +- src/test/csf/collectors.h | 4 +- src/test/csf/ledgers.h | 2 +- src/test/jtx/impl/AMM.cpp | 8 +- src/test/jtx/impl/Account.cpp | 2 +- src/test/jtx/impl/Env.cpp | 2 +- src/test/jtx/impl/Oracle.cpp | 4 +- src/test/jtx/impl/amount.cpp | 4 +- src/test/jtx/impl/quality2.cpp | 4 +- src/test/jtx/impl/xchain_bridge.cpp | 8 +- src/test/nodestore/DatabaseShard_test.cpp | 4 +- src/test/overlay/reduce_relay_test.cpp | 30 +- src/test/overlay/short_read_test.cpp | 4 +- src/test/overlay/tx_reduce_relay_test.cpp | 2 +- src/test/rpc/Handler_test.cpp | 2 +- src/test/rpc/JSONRPC_test.cpp | 4 +- src/test/shamap/FetchPack_test.cpp | 2 +- src/test/unit_test/multi_runner.cpp | 5 +- 297 files changed, 2004 insertions(+), 1644 deletions(-) create mode 100644 src/ripple/basics/instrumentation.h diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index 92c28240a99..d614f757223 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -270,6 +270,7 @@ install ( src/ripple/basics/comparators.h src/ripple/basics/contract.h src/ripple/basics/hardened_hash.h + src/ripple/basics/instrumentation.h src/ripple/basics/join.h src/ripple/basics/make_SSLContext.h src/ripple/basics/mulDiv.h diff --git a/Builds/levelization/results/loops.txt b/Builds/levelization/results/loops.txt index cb137f497cb..4770fc7ff6f 100644 --- a/Builds/levelization/results/loops.txt +++ b/Builds/levelization/results/loops.txt @@ -22,11 +22,14 @@ Loop: ripple.app ripple.rpc Loop: ripple.app ripple.shamap ripple.app > ripple.shamap +Loop: ripple.basics ripple.beast + ripple.basics > ripple.beast + Loop: ripple.basics ripple.core ripple.core > ripple.basics Loop: ripple.basics ripple.json - ripple.json ~= ripple.basics + ripple.json > ripple.basics Loop: ripple.basics ripple.protocol ripple.protocol > ripple.basics diff --git a/Builds/levelization/results/ordering.txt b/Builds/levelization/results/ordering.txt index ed54065d03e..642e8e76978 100644 --- a/Builds/levelization/results/ordering.txt +++ b/Builds/levelization/results/ordering.txt @@ -7,7 +7,6 @@ ripple.app > ripple.json ripple.app > ripple.protocol ripple.app > ripple.resource ripple.app > test.unit_test -ripple.basics > ripple.beast ripple.conditions > ripple.basics ripple.conditions > ripple.protocol ripple.consensus > ripple.basics diff --git a/external/antithesis-sdk/antithesis_instrumentation.h b/external/antithesis-sdk/antithesis_instrumentation.h index b36fc5832ca..a29764114cf 100644 --- a/external/antithesis-sdk/antithesis_instrumentation.h +++ b/external/antithesis-sdk/antithesis_instrumentation.h @@ -1,70 +1,87 @@ #pragma once /* -This header file enables code coverage instrumentation. It is distributed with the Antithesis C++ SDK. +This header file enables code coverage instrumentation. It is distributed with +the Antithesis C++ SDK. -This header file can be used in both C and C++ programs. (The rest of the SDK works only for C++ programs.) +This header file can be used in both C and C++ programs. (The rest of the SDK +works only for C++ programs.) You should include it in a single .cpp or .c file. -The instructions (such as required compiler flags) and usage guidance are found at https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. +The instructions (such as required compiler flags) and usage guidance are found +at https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. */ -#include -#include #include #include #include +#include +#include #ifndef __cplusplus #include #include #endif -// If the libvoidstar(determ) library is present, +// If the libvoidstar(determ) library is present, // pass thru trace_pc_guard related callbacks to it -typedef void (*trace_pc_guard_init_fn)(uint32_t *start, uint32_t *stop); -typedef void (*trace_pc_guard_fn)(uint32_t *guard, uint64_t edge); +typedef void (*trace_pc_guard_init_fn)(uint32_t* start, uint32_t* stop); +typedef void (*trace_pc_guard_fn)(uint32_t* guard, uint64_t edge); static trace_pc_guard_init_fn trace_pc_guard_init = NULL; static trace_pc_guard_fn trace_pc_guard = NULL; static bool did_check_libvoidstar = false; static bool has_libvoidstar = false; -static __attribute__((no_sanitize("coverage"))) void debug_message_out(const char *msg) { - (void)printf("%s\n", msg); - return; +static __attribute__((no_sanitize("coverage"))) void +debug_message_out(const char* msg) +{ + (void)printf("%s\n", msg); + return; } extern #ifdef __cplusplus "C" #endif -__attribute__((no_sanitize("coverage"))) void antithesis_load_libvoidstar() { + __attribute__((no_sanitize("coverage"))) void + antithesis_load_libvoidstar() +{ #ifdef __cplusplus constexpr #endif - const char* LIB_PATH = "/usr/lib/libvoidstar.so"; + const char* LIB_PATH = "/usr/lib/libvoidstar.so"; - if (did_check_libvoidstar) { - return; + if (did_check_libvoidstar) + { + return; } debug_message_out("TRYING TO LOAD libvoidstar"); did_check_libvoidstar = true; void* shared_lib = dlopen(LIB_PATH, RTLD_NOW); - if (!shared_lib) { + if (!shared_lib) + { debug_message_out("Can not load the Antithesis native library"); return; } - void* trace_pc_guard_init_sym = dlsym(shared_lib, "__sanitizer_cov_trace_pc_guard_init"); - if (!trace_pc_guard_init_sym) { - debug_message_out("Can not forward calls to libvoidstar for __sanitizer_cov_trace_pc_guard_init"); + void* trace_pc_guard_init_sym = + dlsym(shared_lib, "__sanitizer_cov_trace_pc_guard_init"); + if (!trace_pc_guard_init_sym) + { + debug_message_out( + "Can not forward calls to libvoidstar for " + "__sanitizer_cov_trace_pc_guard_init"); return; } - void* trace_pc_guard_sym = dlsym(shared_lib, "__sanitizer_cov_trace_pc_guard_internal"); - if (!trace_pc_guard_sym) { - debug_message_out("Can not forward calls to libvoidstar for __sanitizer_cov_trace_pc_guard"); + void* trace_pc_guard_sym = + dlsym(shared_lib, "__sanitizer_cov_trace_pc_guard_internal"); + if (!trace_pc_guard_sym) + { + debug_message_out( + "Can not forward calls to libvoidstar for " + "__sanitizer_cov_trace_pc_guard"); return; } @@ -74,38 +91,51 @@ __attribute__((no_sanitize("coverage"))) void antithesis_load_libvoidstar() { debug_message_out("LOADED libvoidstar"); } -// The following symbols are indeed reserved identifiers, since we're implementing functions defined -// in the compiler runtime. Not clear how to get Clang on board with that besides narrowly suppressing -// the warning in this case. The sample code on the CoverageSanitizer documentation page fails this +// The following symbols are indeed reserved identifiers, since we're +// implementing functions defined in the compiler runtime. Not clear how to get +// Clang on board with that besides narrowly suppressing the warning in this +// case. The sample code on the CoverageSanitizer documentation page fails this // warning! #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-identifier" -extern +extern #ifdef __cplusplus "C" #endif -void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) { - debug_message_out("SDK forwarding to libvoidstar for __sanitizer_cov_trace_pc_guard_init()"); - if (!did_check_libvoidstar) { + void + __sanitizer_cov_trace_pc_guard_init(uint32_t* start, uint32_t* stop) +{ + debug_message_out( + "SDK forwarding to libvoidstar for " + "__sanitizer_cov_trace_pc_guard_init()"); + if (!did_check_libvoidstar) + { antithesis_load_libvoidstar(); } - if (has_libvoidstar) { + if (has_libvoidstar) + { trace_pc_guard_init(start, stop); } return; } -extern +extern #ifdef __cplusplus "C" #endif -void __sanitizer_cov_trace_pc_guard( uint32_t *guard ) { - if (has_libvoidstar) { + void + __sanitizer_cov_trace_pc_guard(uint32_t* guard) +{ + if (has_libvoidstar) + { uint64_t edge = (uint64_t)(__builtin_return_address(0)); trace_pc_guard(guard, edge); - } else { - if (guard) { - *guard = 0; + } + else + { + if (guard) + { + *guard = 0; } } return; diff --git a/external/antithesis-sdk/antithesis_sdk.h b/external/antithesis-sdk/antithesis_sdk.h index 60fb1e882f0..a3ec3763e66 100644 --- a/external/antithesis-sdk/antithesis_sdk.h +++ b/external/antithesis-sdk/antithesis_sdk.h @@ -1,57 +1,80 @@ #pragma once -// This header file contains the Antithesis C++ SDK, which enables C++ applications to integrate with the [Antithesis platform]. +// This header file contains the Antithesis C++ SDK, which enables C++ +// applications to integrate with the [Antithesis platform]. // -// Documentation for the SDK is found at https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. +// Documentation for the SDK is found at +// https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. #include -#include -#include #include +#include #include +#include #include #include namespace antithesis { - inline const char* SDK_VERSION = "0.3.1"; - inline const char* PROTOCOL_VERSION = "1.0.0"; +inline const char* SDK_VERSION = "0.3.1"; +inline const char* PROTOCOL_VERSION = "1.0.0"; - struct LocalRandom { - std::random_device device; - std::mt19937_64 gen; - std::uniform_int_distribution distribution; +struct LocalRandom +{ + std::random_device device; + std::mt19937_64 gen; + std::uniform_int_distribution distribution; - LocalRandom() : device(), gen(device()), distribution() {} + LocalRandom() : device(), gen(device()), distribution() + { + } - uint64_t random() { + uint64_t + random() + { #ifdef ANTITHESIS_RANDOM_OVERRIDE - return ANTITHESIS_RANDOM_OVERRIDE(); + return ANTITHESIS_RANDOM_OVERRIDE(); #else - return distribution(gen); + return distribution(gen); #endif - } - }; - - struct JSON; - typedef std::variant BasicValueType; - typedef std::vector JSON_ARRAY; - typedef std::variant ValueType; - - struct JSON : std::map { - JSON( std::initializer_list> args) : std::map(args) {} - }; + } +}; + +struct JSON; +typedef std::variant< + std::string, + bool, + char, + int, + uint64_t, + float, + double, + const char*, + JSON> + BasicValueType; +typedef std::vector JSON_ARRAY; +typedef std::variant ValueType; + +struct JSON : std::map +{ + JSON(std::initializer_list> args) + : std::map(args) + { + } +}; - // Declarations that we expose - uint64_t get_random(); -} +// Declarations that we expose +uint64_t +get_random(); +} // namespace antithesis -#if defined(NO_ANTITHESIS_SDK) || __cplusplus < 202000L || (defined(__clang__) && __clang_major__ < 16) +#if defined(NO_ANTITHESIS_SDK) || __cplusplus < 202000L || \ + (defined(__clang__) && __clang_major__ < 16) #if __cplusplus < 202000L - #error "The Antithesis C++ API requires C++20 or higher" +#error "The Antithesis C++ API requires C++20 or higher" #endif #if defined(__clang__) && __clang_major__ < 16 - #error "The Antithesis C++ API requires clang version 16 or higher" +#error "The Antithesis C++ API requires clang version 16 or higher" #endif #define ALWAYS(cond, message, ...) @@ -60,547 +83,796 @@ namespace antithesis { #define REACHABLE(message, ...) #define UNREACHABLE(message, ...) - namespace antithesis { - inline uint64_t get_random() { - static LocalRandom random_gen; - return random_gen.random(); - } +inline uint64_t +get_random() +{ + static LocalRandom random_gen; + return random_gen.random(); +} - inline void setup_complete(const JSON& details) { - } +inline void +setup_complete(const JSON& details) +{ +} - inline void send_event(const char* name, const JSON& details) { - } +inline void +send_event(const char* name, const JSON& details) +{ } +} // namespace antithesis #else -#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include #include -#include +#include +#include +#include +#include +#include #include +#include namespace antithesis { - constexpr const char* const ERROR_LOG_LINE_PREFIX = "[* antithesis-sdk-cpp *]"; - constexpr const char* LIB_PATH = "/usr/lib/libvoidstar.so"; - constexpr const char* LOCAL_OUTPUT_ENVIRONMENT_VARIABLE = "ANTITHESIS_SDK_LOCAL_OUTPUT"; - - static std::ostream& operator<<(std::ostream& out, const JSON& details); - - struct LibHandler { - virtual ~LibHandler() = default; - virtual void output(const char* message) const = 0; - virtual uint64_t random() = 0; - - void output(const JSON& json) const { - std::ostringstream out; - out << json; - output(out.str().c_str()); +constexpr const char* const ERROR_LOG_LINE_PREFIX = "[* antithesis-sdk-cpp *]"; +constexpr const char* LIB_PATH = "/usr/lib/libvoidstar.so"; +constexpr const char* LOCAL_OUTPUT_ENVIRONMENT_VARIABLE = + "ANTITHESIS_SDK_LOCAL_OUTPUT"; + +static std::ostream& +operator<<(std::ostream& out, const JSON& details); + +struct LibHandler +{ + virtual ~LibHandler() = default; + virtual void + output(const char* message) const = 0; + virtual uint64_t + random() = 0; + + void + output(const JSON& json) const + { + std::ostringstream out; + out << json; + output(out.str().c_str()); + } +}; + +struct AntithesisHandler : LibHandler +{ + void + output(const char* message) const override + { + if (message != nullptr) + { + fuzz_json_data(message, strlen(message)); + fuzz_flush(); } - }; + } - struct AntithesisHandler : LibHandler { - void output(const char* message) const override { - if (message != nullptr) { - fuzz_json_data(message, strlen(message)); - fuzz_flush(); - } - } + uint64_t + random() override + { + return fuzz_get_random(); + } - uint64_t random() override { - return fuzz_get_random(); + static std::unique_ptr + create() + { + void* shared_lib = dlopen(LIB_PATH, RTLD_NOW); + if (!shared_lib) + { + error("Can not load the Antithesis native library"); + return nullptr; } - static std::unique_ptr create() { - void* shared_lib = dlopen(LIB_PATH, RTLD_NOW); - if (!shared_lib) { - error("Can not load the Antithesis native library"); - return nullptr; - } - - void* fuzz_json_data = dlsym(shared_lib, "fuzz_json_data"); - if (!fuzz_json_data) { - error("Can not access symbol fuzz_json_data"); - return nullptr; - } - - void* fuzz_flush = dlsym(shared_lib, "fuzz_flush"); - if (!fuzz_flush) { - error("Can not access symbol fuzz_flush"); - return nullptr; - } - - void* fuzz_get_random = dlsym(shared_lib, "fuzz_get_random"); - if (!fuzz_get_random) { - error("Can not access symbol fuzz_get_random"); - return nullptr; - } - - return std::unique_ptr(new AntithesisHandler( - reinterpret_cast(fuzz_json_data), - reinterpret_cast(fuzz_flush), - reinterpret_cast(fuzz_get_random))); + void* fuzz_json_data = dlsym(shared_lib, "fuzz_json_data"); + if (!fuzz_json_data) + { + error("Can not access symbol fuzz_json_data"); + return nullptr; } - private: - typedef void (*fuzz_json_data_t)( const char* message, size_t length ); - typedef void (*fuzz_flush_t)(); - typedef uint64_t (*fuzz_get_random_t)(); + void* fuzz_flush = dlsym(shared_lib, "fuzz_flush"); + if (!fuzz_flush) + { + error("Can not access symbol fuzz_flush"); + return nullptr; + } + void* fuzz_get_random = dlsym(shared_lib, "fuzz_get_random"); + if (!fuzz_get_random) + { + error("Can not access symbol fuzz_get_random"); + return nullptr; + } - fuzz_json_data_t fuzz_json_data; - fuzz_flush_t fuzz_flush; - fuzz_get_random_t fuzz_get_random; + return std::unique_ptr(new AntithesisHandler( + reinterpret_cast(fuzz_json_data), + reinterpret_cast(fuzz_flush), + reinterpret_cast(fuzz_get_random))); + } - AntithesisHandler(fuzz_json_data_t fuzz_json_data, fuzz_flush_t fuzz_flush, fuzz_get_random_t fuzz_get_random) : - fuzz_json_data(fuzz_json_data), fuzz_flush(fuzz_flush), fuzz_get_random(fuzz_get_random) {} +private: + typedef void (*fuzz_json_data_t)(const char* message, size_t length); + typedef void (*fuzz_flush_t)(); + typedef uint64_t (*fuzz_get_random_t)(); + + fuzz_json_data_t fuzz_json_data; + fuzz_flush_t fuzz_flush; + fuzz_get_random_t fuzz_get_random; + + AntithesisHandler( + fuzz_json_data_t fuzz_json_data, + fuzz_flush_t fuzz_flush, + fuzz_get_random_t fuzz_get_random) + : fuzz_json_data(fuzz_json_data) + , fuzz_flush(fuzz_flush) + , fuzz_get_random(fuzz_get_random) + { + } - static void error(const char* message) { - fprintf(stderr, "%s %s: %s\n", ERROR_LOG_LINE_PREFIX, message, dlerror()); - } - }; + static void + error(const char* message) + { + fprintf( + stderr, "%s %s: %s\n", ERROR_LOG_LINE_PREFIX, message, dlerror()); + } +}; - struct LocalHandler : LibHandler{ - ~LocalHandler() override { - if (file != nullptr) { - fclose(file); - } +struct LocalHandler : LibHandler +{ + ~LocalHandler() override + { + if (file != nullptr) + { + fclose(file); } + } - void output(const char* message) const override { - if (file != nullptr && message != nullptr) { - fprintf(file, "%s\n", message); - } + void + output(const char* message) const override + { + if (file != nullptr && message != nullptr) + { + fprintf(file, "%s\n", message); } + } - uint64_t random() override { - return random_gen.random(); - } + uint64_t + random() override + { + return random_gen.random(); + } - static std::unique_ptr create() { - return std::unique_ptr(new LocalHandler(create_internal())); - } - private: - FILE* file; - LocalRandom random_gen; + static std::unique_ptr + create() + { + return std::unique_ptr( + new LocalHandler(create_internal())); + } - LocalHandler(FILE* file): file(file), random_gen() { - } +private: + FILE* file; + LocalRandom random_gen; - // If `localOutputEnvVar` is set to a non-empty path, attempt to open that path and truncate the file - // to serve as the log file of the local handler. - // Otherwise, we don't have a log file, and logging is a no-op in the local handler. - static FILE* create_internal() { - const char* path = std::getenv(LOCAL_OUTPUT_ENVIRONMENT_VARIABLE); - if (!path || !path[0]) { - return nullptr; - } + LocalHandler(FILE* file) : file(file), random_gen() + { + } - // Open the file for writing (create if needed and possible) and truncate it - FILE* file = fopen(path, "w"); - if (file == nullptr) { - fprintf(stderr, "%s Failed to open path %s: %s\n", ERROR_LOG_LINE_PREFIX, path, strerror(errno)); - return nullptr; - } - int ret = fchmod(fileno(file), 0644); - if (ret != 0) { - fprintf(stderr, "%s Failed to set permissions for path %s: %s\n", ERROR_LOG_LINE_PREFIX, path, strerror(errno)); - fclose(file); - return nullptr; - } + // If `localOutputEnvVar` is set to a non-empty path, attempt to open that + // path and truncate the file to serve as the log file of the local handler. + // Otherwise, we don't have a log file, and logging is a no-op in the local + // handler. + static FILE* + create_internal() + { + const char* path = std::getenv(LOCAL_OUTPUT_ENVIRONMENT_VARIABLE); + if (!path || !path[0]) + { + return nullptr; + } - return file; + // Open the file for writing (create if needed and possible) and + // truncate it + FILE* file = fopen(path, "w"); + if (file == nullptr) + { + fprintf( + stderr, + "%s Failed to open path %s: %s\n", + ERROR_LOG_LINE_PREFIX, + path, + strerror(errno)); + return nullptr; } - }; - - static std::unique_ptr init() { - struct stat stat_buf; - if (stat(LIB_PATH, &stat_buf) == 0) { - std::unique_ptr tmp = AntithesisHandler::create(); - if (!tmp) { - fprintf(stderr, "%s Failed to create handler for Antithesis library\n", ERROR_LOG_LINE_PREFIX); - exit(-1); - } - return tmp; - } else { - return LocalHandler::create(); + int ret = fchmod(fileno(file), 0644); + if (ret != 0) + { + fprintf( + stderr, + "%s Failed to set permissions for path %s: %s\n", + ERROR_LOG_LINE_PREFIX, + path, + strerror(errno)); + fclose(file); + return nullptr; } + + return file; + } +}; + +static std::unique_ptr +init() +{ + struct stat stat_buf; + if (stat(LIB_PATH, &stat_buf) == 0) + { + std::unique_ptr tmp = AntithesisHandler::create(); + if (!tmp) + { + fprintf( + stderr, + "%s Failed to create handler for Antithesis library\n", + ERROR_LOG_LINE_PREFIX); + exit(-1); + } + return tmp; + } + else + { + return LocalHandler::create(); } +} - struct AssertionState { - uint8_t false_not_seen : 1; - uint8_t true_not_seen : 1; - uint8_t rest : 6; +struct AssertionState +{ + uint8_t false_not_seen : 1; + uint8_t true_not_seen : 1; + uint8_t rest : 6; - AssertionState() : false_not_seen(true), true_not_seen(true), rest(0) {} - }; + AssertionState() : false_not_seen(true), true_not_seen(true), rest(0) + { + } +}; - template - inline constexpr bool always_false_v = false; +template +inline constexpr bool always_false_v = false; - static std::ostream& operator<<(std::ostream& out, const BasicValueType& basic_value) { - std::visit([&](auto&& arg) - { +static std::ostream& +operator<<(std::ostream& out, const BasicValueType& basic_value) +{ + std::visit( + [&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) + { out << std::quoted(arg); - } else if constexpr (std::is_same_v) { + } + else if constexpr (std::is_same_v) + { out << (arg ? "true" : "false"); - } else if constexpr (std::is_same_v) { + } + else if constexpr (std::is_same_v) + { char tmp[2] = {arg, '\0'}; out << std::quoted(tmp); - } else if constexpr (std::is_same_v) { + } + else if constexpr (std::is_same_v) + { out << arg; - } else if constexpr (std::is_same_v) { + } + else if constexpr (std::is_same_v) + { out << arg; - } else if constexpr (std::is_same_v) { + } + else if constexpr (std::is_same_v) + { out << arg; - } else if constexpr (std::is_same_v) { + } + else if constexpr (std::is_same_v) + { out << arg; - } else if constexpr (std::is_same_v) { + } + else if constexpr (std::is_same_v) + { out << std::quoted(arg); - } else if constexpr (std::is_same_v) { - if (arg.empty()) { + } + else if constexpr (std::is_same_v) + { + if (arg.empty()) + { out << "null"; - } else { + } + else + { out << arg; } - } else { - static_assert(always_false_v, "non-exhaustive BasicValueType visitor!"); } - }, basic_value); + else + { + static_assert( + always_false_v, + "non-exhaustive BasicValueType visitor!"); + } + }, + basic_value); - return out; - } + return out; +} - static std::ostream& operator<<(std::ostream& out, const ValueType& value) { - std::visit([&](auto&& arg) - { +static std::ostream& +operator<<(std::ostream& out, const ValueType& value) +{ + std::visit( + [&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) + { out << arg; - } else if constexpr (std::is_same_v>) { + } + else if constexpr (std::is_same_v>) + { out << '['; bool first = true; - for (auto &item : arg) { - if (!first) { - out << ','; - } - first = false; - out << item; + for (auto& item : arg) + { + if (!first) + { + out << ','; + } + first = false; + out << item; } out << ']'; - } else { - static_assert(always_false_v, "non-exhaustive ValueType visitor!"); } - }, value); - - return out; - } - - static std::ostream& operator<<(std::ostream& out, const JSON& details) { - out << "{ "; - - bool first = true; - for (auto [key, value] : details) { - if (!first) { - out << ", "; + else + { + static_assert( + always_false_v, "non-exhaustive ValueType visitor!"); } - out << std::quoted(key) << ": " << value; - first = false; - } + }, + value); - out << " }"; - return out; - } - - enum AssertionType { - ALWAYS_ASSERTION, - ALWAYS_OR_UNREACHABLE_ASSERTION, - SOMETIMES_ASSERTION, - REACHABLE_ASSERTION, - UNREACHABLE_ASSERTION, - }; - - inline constexpr bool get_must_hit(AssertionType type) { - switch (type) { - case ALWAYS_ASSERTION: - case SOMETIMES_ASSERTION: - case REACHABLE_ASSERTION: - return true; - case ALWAYS_OR_UNREACHABLE_ASSERTION: - case UNREACHABLE_ASSERTION: - return false; - } - } + return out; +} - inline constexpr const char* get_assert_type_string(AssertionType type) { - switch (type) { - case ALWAYS_ASSERTION: - case ALWAYS_OR_UNREACHABLE_ASSERTION: - return "always"; - case SOMETIMES_ASSERTION: - return "sometimes"; - case REACHABLE_ASSERTION: - case UNREACHABLE_ASSERTION: - return "reachability"; - } - } +static std::ostream& +operator<<(std::ostream& out, const JSON& details) +{ + out << "{ "; - inline constexpr const char* get_display_type_string(AssertionType type) { - switch (type) { - case ALWAYS_ASSERTION: return "Always"; - case ALWAYS_OR_UNREACHABLE_ASSERTION: return "AlwaysOrUnreachable"; - case SOMETIMES_ASSERTION: return "Sometimes"; - case REACHABLE_ASSERTION: return "Reachable"; - case UNREACHABLE_ASSERTION: return "Unreachable"; + bool first = true; + for (auto [key, value] : details) + { + if (!first) + { + out << ", "; } + out << std::quoted(key) << ": " << value; + first = false; } - struct LocationInfo { - const char* class_name; - const char* function_name; - const char* file_name; - const int line; - const int column; - - JSON to_json() const { - return JSON{ - {"class", class_name}, - {"function", function_name}, - {"file", file_name}, - {"begin_line", line}, - {"begin_column", column}, - }; - } - }; + out << " }"; + return out; +} - inline std::string make_key([[maybe_unused]] const char* message, const LocationInfo& location_info) { - return message; +enum AssertionType { + ALWAYS_ASSERTION, + ALWAYS_OR_UNREACHABLE_ASSERTION, + SOMETIMES_ASSERTION, + REACHABLE_ASSERTION, + UNREACHABLE_ASSERTION, +}; + +inline constexpr bool +get_must_hit(AssertionType type) +{ + switch (type) + { + case ALWAYS_ASSERTION: + case SOMETIMES_ASSERTION: + case REACHABLE_ASSERTION: + return true; + case ALWAYS_OR_UNREACHABLE_ASSERTION: + case UNREACHABLE_ASSERTION: + return false; } +} - inline LibHandler& get_lib_handler() { - static LibHandler* lib_handler = nullptr; - if (lib_handler == nullptr) { - lib_handler = init().release(); // Leak on exit, rather than exit-time-destructor - - JSON language_block{ - {"name", "C++"}, - {"version", __VERSION__} - }; - - JSON version_message{ - {"antithesis_sdk", JSON{ - {"language", language_block}, - {"sdk_version", SDK_VERSION}, - {"protocol_version", PROTOCOL_VERSION} - } - }}; - lib_handler->output(version_message); - } - - return *lib_handler; - } - - inline void assert_impl(bool cond, const char* message, const JSON& details, const LocationInfo& location_info, - bool hit, bool must_hit, const char* assert_type, const char* display_type, const char* id) { - JSON assertion{ - {"antithesis_assert", JSON{ - {"hit", hit}, - {"must_hit", must_hit}, - {"assert_type", assert_type}, - {"display_type", display_type}, - {"message", message}, - {"condition", cond}, - {"id", id}, - {"location", location_info.to_json()}, - {"details", details}, - }} - }; - get_lib_handler().output(assertion); +inline constexpr const char* +get_assert_type_string(AssertionType type) +{ + switch (type) + { + case ALWAYS_ASSERTION: + case ALWAYS_OR_UNREACHABLE_ASSERTION: + return "always"; + case SOMETIMES_ASSERTION: + return "sometimes"; + case REACHABLE_ASSERTION: + case UNREACHABLE_ASSERTION: + return "reachability"; } +} - inline void assert_raw(bool cond, const char* message, const JSON& details, - const char* class_name, const char* function_name, const char* file_name, const int line, const int column, - bool hit, bool must_hit, const char* assert_type, const char* display_type, const char* id) { - LocationInfo location_info{ class_name, function_name, file_name, line, column }; - assert_impl(cond, message, details, location_info, hit, must_hit, assert_type, display_type, id); +inline constexpr const char* +get_display_type_string(AssertionType type) +{ + switch (type) + { + case ALWAYS_ASSERTION: + return "Always"; + case ALWAYS_OR_UNREACHABLE_ASSERTION: + return "AlwaysOrUnreachable"; + case SOMETIMES_ASSERTION: + return "Sometimes"; + case REACHABLE_ASSERTION: + return "Reachable"; + case UNREACHABLE_ASSERTION: + return "Unreachable"; } +} - typedef std::set CatalogEntryTracker; - - inline CatalogEntryTracker& get_catalog_entry_tracker() { - static CatalogEntryTracker catalog_entry_tracker; - return catalog_entry_tracker; +struct LocationInfo +{ + const char* class_name; + const char* function_name; + const char* file_name; + const int line; + const int column; + + JSON + to_json() const + { + return JSON{ + {"class", class_name}, + {"function", function_name}, + {"file", file_name}, + {"begin_line", line}, + {"begin_column", column}, + }; } +}; + +inline std::string +make_key( + [[maybe_unused]] const char* message, + const LocationInfo& location_info) +{ + return message; +} - struct Assertion { - AssertionState state; - AssertionType type; - const char* message; - LocationInfo location; - - Assertion(const char* message, AssertionType type, LocationInfo&& location) : - state(), type(type), message(message), location(std::move(location)) { - this->add_to_catalog(); - } +inline LibHandler& +get_lib_handler() +{ + static LibHandler* lib_handler = nullptr; + if (lib_handler == nullptr) + { + lib_handler = + init().release(); // Leak on exit, rather than exit-time-destructor + + JSON language_block{{"name", "C++"}, {"version", __VERSION__}}; + + JSON version_message{ + {"antithesis_sdk", + JSON{ + {"language", language_block}, + {"sdk_version", SDK_VERSION}, + {"protocol_version", PROTOCOL_VERSION}}}}; + lib_handler->output(version_message); + } - void add_to_catalog() const { - std::string id = make_key(message, location); - CatalogEntryTracker& tracker = get_catalog_entry_tracker(); - if (!tracker.contains(id)) { - tracker.insert(id); - const bool condition = (type == REACHABLE_ASSERTION ? true : false); - const bool hit = false; - const char* assert_type = get_assert_type_string(type); - const bool must_hit = get_must_hit(type); - const char* display_type = get_display_type_string(type); - assert_impl(condition, message, {}, location, hit, must_hit, assert_type, display_type, id.c_str()); - } - } + return *lib_handler; +} - [[clang::always_inline]] inline void check_assertion(bool cond, const JSON& details) { - #if defined(NO_ANTITHESIS_SDK) - #error "Antithesis SDK has been disabled" - #endif - if (__builtin_expect(state.false_not_seen || state.true_not_seen, false)) { - check_assertion_internal(cond, details); - } - } +inline void +assert_impl( + bool cond, + const char* message, + const JSON& details, + const LocationInfo& location_info, + bool hit, + bool must_hit, + const char* assert_type, + const char* display_type, + const char* id) +{ + JSON assertion{ + {"antithesis_assert", + JSON{ + {"hit", hit}, + {"must_hit", must_hit}, + {"assert_type", assert_type}, + {"display_type", display_type}, + {"message", message}, + {"condition", cond}, + {"id", id}, + {"location", location_info.to_json()}, + {"details", details}, + }}}; + get_lib_handler().output(assertion); +} - private: - void check_assertion_internal(bool cond, const JSON& details) { - bool emit = false; - if (!cond && state.false_not_seen) { - emit = true; - state.false_not_seen = false; // TODO: is the race OK? - } +inline void +assert_raw( + bool cond, + const char* message, + const JSON& details, + const char* class_name, + const char* function_name, + const char* file_name, + const int line, + const int column, + bool hit, + bool must_hit, + const char* assert_type, + const char* display_type, + const char* id) +{ + LocationInfo location_info{ + class_name, function_name, file_name, line, column}; + assert_impl( + cond, + message, + details, + location_info, + hit, + must_hit, + assert_type, + display_type, + id); +} - if (cond && state.true_not_seen) { - emit = true; - state.true_not_seen = false; // TODO: is the race OK? - } +typedef std::set CatalogEntryTracker; - if (emit) { - const bool hit = true; - const char* assert_type = get_assert_type_string(type); - const bool must_hit = get_must_hit(type); - const char* display_type = get_display_type_string(type); - std::string id = make_key(message, location); - assert_impl(cond, message, details, location, hit, must_hit, assert_type, display_type, id.c_str()); - } - } - }; +inline CatalogEntryTracker& +get_catalog_entry_tracker() +{ + static CatalogEntryTracker catalog_entry_tracker; + return catalog_entry_tracker; +} - inline uint64_t get_random() { - return get_lib_handler().random(); +struct Assertion +{ + AssertionState state; + AssertionType type; + const char* message; + LocationInfo location; + + Assertion(const char* message, AssertionType type, LocationInfo&& location) + : state(), type(type), message(message), location(std::move(location)) + { + this->add_to_catalog(); } - inline void setup_complete(const JSON& details) { - JSON json{ - { "antithesis_setup", JSON{ - {"status", "complete"}, - {"details", details} - }} - }; - get_lib_handler().output(json); + void + add_to_catalog() const + { + std::string id = make_key(message, location); + CatalogEntryTracker& tracker = get_catalog_entry_tracker(); + if (!tracker.contains(id)) + { + tracker.insert(id); + const bool condition = (type == REACHABLE_ASSERTION ? true : false); + const bool hit = false; + const char* assert_type = get_assert_type_string(type); + const bool must_hit = get_must_hit(type); + const char* display_type = get_display_type_string(type); + assert_impl( + condition, + message, + {}, + location, + hit, + must_hit, + assert_type, + display_type, + id.c_str()); + } } - inline void send_event(const char* name, const JSON& details) { - JSON json = { { name, details } }; - get_lib_handler().output(json); + [[clang::always_inline]] inline void + check_assertion(bool cond, const JSON& details) + { +#if defined(NO_ANTITHESIS_SDK) +#error "Antithesis SDK has been disabled" +#endif + if (__builtin_expect( + state.false_not_seen || state.true_not_seen, false)) + { + check_assertion_internal(cond, details); + } } -} -namespace { - template - struct fixed_string { - std::array contents; - constexpr fixed_string() { - for(unsigned int i=0; i from_c_str( const char* s ) { - fixed_string it; - for(unsigned int i=0; i - fixed_string( const char (&arr)[N] ) -> fixed_string; +inline void +setup_complete(const JSON& details) +{ + JSON json{ + {"antithesis_setup", + JSON{{"status", "complete"}, {"details", details}}}}; + get_lib_handler().output(json); +} - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" - static constexpr size_t string_length( const char * s ) { - for(int l = 0; ; l++) - if (!s[l]) - return l; - } - #pragma clang diagnostic pop +inline void +send_event(const char* name, const JSON& details) +{ + JSON json = {{name, details}}; + get_lib_handler().output(json); +} +} // namespace antithesis - template - struct CatalogEntry { - [[clang::always_inline]] static inline antithesis::Assertion create() { - antithesis::LocationInfo location{ "", function_name.c_str(), file_name.c_str(), line, column }; - return antithesis::Assertion(message.c_str(), type, std::move(location)); - } +namespace { +template +struct fixed_string +{ + std::array contents; + constexpr fixed_string() + { + for (unsigned int i = 0; i < N; i++) + contents[i] = 0; + } - static inline antithesis::Assertion assertion = create(); - }; -} +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" + constexpr fixed_string(const char (&arr)[N]) + { + for (unsigned int i = 0; i < N; i++) + contents[i] = arr[i]; + } -#define FIXED_STRING_FROM_C_STR(s) (fixed_string::from_c_str(s)) + static constexpr fixed_string + from_c_str(const char* s) + { + fixed_string it; + for (unsigned int i = 0; i < N && s[i]; i++) + it.contents[i] = s[i]; + return it; + } +#pragma clang diagnostic pop -#define ANTITHESIS_ASSERT_RAW(type, cond, message, ...) ( \ - CatalogEntry< \ - type, \ - fixed_string(message), \ - FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ - FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ - std::source_location::current().line(), \ - std::source_location::current().column() \ - >::assertion.check_assertion(cond, (antithesis::JSON(__VA_ARGS__)) ) ) + const char* + c_str() const + { + return contents.data(); + } +}; + +template +fixed_string(const char (&arr)[N]) -> fixed_string; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +static constexpr size_t +string_length(const char* s) +{ + for (int l = 0;; l++) + if (!s[l]) + return l; +} +#pragma clang diagnostic pop + +template < + antithesis::AssertionType type, + fixed_string message, + fixed_string file_name, + fixed_string function_name, + int line, + int column> +struct CatalogEntry +{ + [[clang::always_inline]] static inline antithesis::Assertion + create() + { + antithesis::LocationInfo location{ + "", function_name.c_str(), file_name.c_str(), line, column}; + return antithesis::Assertion( + message.c_str(), type, std::move(location)); + } -#define ALWAYS(cond, message, ...) ANTITHESIS_ASSERT_RAW(antithesis::ALWAYS_ASSERTION, cond, message, __VA_ARGS__) -#define ALWAYS_OR_UNREACHABLE(cond, message, ...) ANTITHESIS_ASSERT_RAW(antithesis::ALWAYS_OR_UNREACHABLE_ASSERTION, cond, message, __VA_ARGS__) -#define SOMETIMES(cond, message, ...) ANTITHESIS_ASSERT_RAW(antithesis::SOMETIMES_ASSERTION, cond, message, __VA_ARGS__) -#define REACHABLE(message, ...) ANTITHESIS_ASSERT_RAW(antithesis::REACHABLE_ASSERTION, true, message, __VA_ARGS__) -#define UNREACHABLE(message, ...) ANTITHESIS_ASSERT_RAW(antithesis::UNREACHABLE_ASSERTION, false, message, __VA_ARGS__) + static inline antithesis::Assertion assertion = create(); +}; +} // namespace + +#define FIXED_STRING_FROM_C_STR(s) \ + (fixed_string::from_c_str(s)) + +#define ANTITHESIS_ASSERT_RAW(type, cond, message, ...) \ + (CatalogEntry< \ + type, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR( \ + std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column()>::assertion \ + .check_assertion(cond, (antithesis::JSON(__VA_ARGS__)))) + +#define ALWAYS(cond, message, ...) \ + ANTITHESIS_ASSERT_RAW( \ + antithesis::ALWAYS_ASSERTION, cond, message, __VA_ARGS__) +#define ALWAYS_OR_UNREACHABLE(cond, message, ...) \ + ANTITHESIS_ASSERT_RAW( \ + antithesis::ALWAYS_OR_UNREACHABLE_ASSERTION, \ + cond, \ + message, \ + __VA_ARGS__) +#define SOMETIMES(cond, message, ...) \ + ANTITHESIS_ASSERT_RAW( \ + antithesis::SOMETIMES_ASSERTION, cond, message, __VA_ARGS__) +#define REACHABLE(message, ...) \ + ANTITHESIS_ASSERT_RAW( \ + antithesis::REACHABLE_ASSERTION, true, message, __VA_ARGS__) +#define UNREACHABLE(message, ...) \ + ANTITHESIS_ASSERT_RAW( \ + antithesis::UNREACHABLE_ASSERTION, false, message, __VA_ARGS__) #endif namespace antithesis { - template - Iter random_choice(Iter begin, Iter end) { - ssize_t num_things = end - begin; - if (num_things == 0) { - return end; - } - - uint64_t uval = get_random(); - ssize_t index = uval % num_things; - return begin + index; +template +Iter +random_choice(Iter begin, Iter end) +{ + ssize_t num_things = end - begin; + if (num_things == 0) + { + return end; } + + uint64_t uval = get_random(); + ssize_t index = uval % num_things; + return begin + index; } +} // namespace antithesis diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/ripple/app/consensus/RCLConsensus.cpp index c0ebe06dd7e..05a3a6916ed 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/ripple/app/consensus/RCLConsensus.cpp @@ -93,7 +93,7 @@ RCLConsensus::Adaptor::Adaptor( std::numeric_limits::max() - 1)) , nUnlVote_(validatorKeys_.nodeID, j_) { - assert(valCookie_ != 0); + XRPL_ASSERT(valCookie_ != 0); JLOG(j_.info()) << "Consensus engine started (cookie: " + std::to_string(valCookie_) + ")"; @@ -143,8 +143,8 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) return std::nullopt; } - assert(!built->open() && built->isImmutable()); - assert(built->info().hash == hash); + XRPL_ASSERT(!built->open() && built->isImmutable()); + XRPL_ASSERT(built->info().hash == hash); // Notify inbound transactions of the new ledger sequence number inboundTransactions_.newRound(built->info().seq); @@ -670,8 +670,9 @@ RCLConsensus::Adaptor::doAccept( ledgerMaster_.switchLCL(built.ledger_); // Do these need to exist? - assert(ledgerMaster_.getClosedLedger()->info().hash == built.id()); - assert(app_.openLedger().current()->info().parentHash == built.id()); + XRPL_ASSERT(ledgerMaster_.getClosedLedger()->info().hash == built.id()); + XRPL_ASSERT( + app_.openLedger().current()->info().parentHash == built.id()); } //------------------------------------------------------------------------- @@ -767,7 +768,8 @@ RCLConsensus::Adaptor::buildLCL( std::shared_ptr built = [&]() { if (auto const replayData = ledgerMaster_.releaseReplay()) { - assert(replayData->parent()->info().hash == previousLedger.id()); + XRPL_ASSERT( + replayData->parent()->info().hash == previousLedger.id()); return buildLedger(*replayData, tapNONE, app_, j_); } return buildLedger( diff --git a/src/ripple/app/consensus/RCLCxPeerPos.cpp b/src/ripple/app/consensus/RCLCxPeerPos.cpp index ee5a45b943f..ff9aafee710 100644 --- a/src/ripple/app/consensus/RCLCxPeerPos.cpp +++ b/src/ripple/app/consensus/RCLCxPeerPos.cpp @@ -38,7 +38,8 @@ RCLCxPeerPos::RCLCxPeerPos( { // The maximum allowed size of a signature is 72 bytes; we verify // this elsewhere, but we want to be extra careful here: - assert(signature.size() != 0 && signature.size() <= signature_.capacity()); + XRPL_ASSERT( + signature.size() != 0 && signature.size() <= signature_.capacity()); if (signature.size() != 0 && signature.size() <= signature_.capacity()) signature_.assign(signature.begin(), signature.end()); diff --git a/src/ripple/app/consensus/RCLCxTx.h b/src/ripple/app/consensus/RCLCxTx.h index c6abfdfee94..21f5a08f9c4 100644 --- a/src/ripple/app/consensus/RCLCxTx.h +++ b/src/ripple/app/consensus/RCLCxTx.h @@ -111,7 +111,7 @@ class RCLTxSet */ RCLTxSet(std::shared_ptr m) : map_{std::move(m)} { - assert(map_); + XRPL_ASSERT(map_); } /** Constructor from a previously created MutableTxSet @@ -177,7 +177,7 @@ class RCLTxSet std::map ret; for (auto const& [k, v] : delta) { - assert((v.first && !v.second) || (v.second && !v.first)); + XRPL_ASSERT((v.first && !v.second) || (v.second && !v.first)); ret[k] = static_cast(v.first); } diff --git a/src/ripple/app/consensus/RCLValidations.cpp b/src/ripple/app/consensus/RCLValidations.cpp index ab9391385dd..46d5b80aa4e 100644 --- a/src/ripple/app/consensus/RCLValidations.cpp +++ b/src/ripple/app/consensus/RCLValidations.cpp @@ -49,7 +49,8 @@ RCLValidatedLedger::RCLValidatedLedger( auto const hashIndex = ledger->read(keylet::skip()); if (hashIndex) { - assert(hashIndex->getFieldU32(sfLastLedgerSequence) == (seq() - 1)); + XRPL_ASSERT( + hashIndex->getFieldU32(sfLastLedgerSequence) == (seq() - 1)); ancestors_ = hashIndex->getFieldV256(sfHashes).value(); } else @@ -142,8 +143,8 @@ RCLValidationsAdaptor::acquire(LedgerHash const& hash) return std::nullopt; } - assert(!ledger->open() && ledger->isImmutable()); - assert(ledger->info().hash == hash); + XRPL_ASSERT(!ledger->open() && ledger->isImmutable()); + XRPL_ASSERT(ledger->info().hash == hash); return RCLValidatedLedger(std::move(ledger), j_); } diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.cpp b/src/ripple/app/ledger/AcceptedLedgerTx.cpp index 613a91e437a..cc11b935fcb 100644 --- a/src/ripple/app/ledger/AcceptedLedgerTx.cpp +++ b/src/ripple/app/ledger/AcceptedLedgerTx.cpp @@ -33,7 +33,7 @@ AcceptedLedgerTx::AcceptedLedgerTx( , mMeta(txn->getTransactionID(), ledger->seq(), *met) , mAffected(mMeta.getAffectedAccounts()) { - assert(!ledger->open()); + XRPL_ASSERT(!ledger->open()); Serializer s; met->add(s); @@ -76,7 +76,7 @@ AcceptedLedgerTx::AcceptedLedgerTx( std::string AcceptedLedgerTx::getEscMeta() const { - assert(!mRawMeta.empty()); + XRPL_ASSERT(!mRawMeta.empty()); return sqlBlobLiteral(mRawMeta); } diff --git a/src/ripple/app/ledger/ConsensusTransSetSF.cpp b/src/ripple/app/ledger/ConsensusTransSetSF.cpp index 476c757515f..f1a5b165a83 100644 --- a/src/ripple/app/ledger/ConsensusTransSetSF.cpp +++ b/src/ripple/app/ledger/ConsensusTransSetSF.cpp @@ -60,7 +60,7 @@ ConsensusTransSetSF::gotNode( Serializer s(nodeData.data() + 4, nodeData.size() - 4); SerialIter sit(s.slice()); auto stx = std::make_shared(std::ref(sit)); - assert(stx->getTransactionID() == nodeHash.as_uint256()); + XRPL_ASSERT(stx->getTransactionID() == nodeHash.as_uint256()); auto const pap = &app_; app_.getJobQueue().addJob(jtTRANSACTION, "TXS->TXN", [pap, stx]() { pap->getOPs().submitTransaction(stx); @@ -92,7 +92,7 @@ ConsensusTransSetSF::getNode(SHAMapHash const& nodeHash) const Serializer s; s.add32(HashPrefix::transactionID); txn->getSTransaction()->add(s); - assert(sha512Half(s.slice()) == nodeHash.as_uint256()); + XRPL_ASSERT(sha512Half(s.slice()) == nodeHash.as_uint256()); nodeData = s.peekData(); return nodeData; } diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 7cd6f89cad3..6626bcd648f 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,6 @@ #include #include #include -#include #include #include @@ -381,7 +381,7 @@ Ledger::setAccepted( bool correctCloseTime) { // Used when we witnessed the consensus. - assert(!open()); + XRPL_ASSERT(!open()); info_.closeTime = closeTime; info_.closeTimeResolution = closeResolution; @@ -454,7 +454,7 @@ Ledger::read(Keylet const& k) const { if (k.key == beast::zero) { - assert(false); + XRPL_UNREACHABLE(); return nullptr; } auto const& item = stateMap_.peekItem(k.key); @@ -574,7 +574,7 @@ Ledger::rawTxInsert( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - assert(metaData); + XRPL_ASSERT(metaData); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -591,7 +591,7 @@ Ledger::rawTxInsertWithHash( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - assert(metaData); + XRPL_ASSERT(metaData); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -687,7 +687,7 @@ Ledger::setup() void Ledger::defaultFees(Config const& config) { - assert(fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0); + XRPL_ASSERT(fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0); if (fees_.base == 0) fees_.base = config.FEES.reference_fee; if (fees_.reserve == 0) @@ -883,7 +883,7 @@ Ledger::assertSensible(beast::Journal ledgerJ) const JLOG(ledgerJ.fatal()) << "ledger is not sensible" << j; - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -917,7 +917,7 @@ Ledger::updateSkipList() created = false; } - assert(hashes.size() <= 256); + XRPL_ASSERT(hashes.size() <= 256); hashes.push_back(info_.parentHash); sle->setFieldV256(sfHashes, STVector256(hashes)); sle->setFieldU32(sfLastLedgerSequence, prevIndex); @@ -942,7 +942,7 @@ Ledger::updateSkipList() hashes = static_cast(sle->getFieldV256(sfHashes)); created = false; } - assert(hashes.size() <= 256); + XRPL_ASSERT(hashes.size() <= 256); if (hashes.size() == 256) hashes.erase(hashes.begin()); hashes.push_back(info_.parentHash); @@ -1022,7 +1022,7 @@ pendSaveValidated( } } - assert(ledger->isImmutable()); + XRPL_ASSERT(ledger->isImmutable()); if (!app.pendingSaves().shouldWork(ledger->info().seq, isSynchronous)) { @@ -1099,7 +1099,7 @@ finishLoadByIndexOrHash( if (!ledger) return; - assert( + XRPL_ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees())); ledger->setImmutable(); @@ -1140,7 +1140,7 @@ loadByHash(uint256 const& ledgerHash, Application& app, bool acquire) { std::shared_ptr ledger = loadLedgerHelper(*info, app, acquire); finishLoadByIndexOrHash(ledger, app.config(), app.journal("Ledger")); - assert(!ledger || ledger->info().hash == ledgerHash); + XRPL_ASSERT(!ledger || ledger->info().hash == ledgerHash); return ledger; } return {}; @@ -1152,7 +1152,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) { if (!app.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions: not running in reporting mode"); } @@ -1165,7 +1165,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) dynamic_cast(&(app.getNodeStore())); if (!nodeDb) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Called flatFetchTransactions but database is not DatabaseNodeImp"); } @@ -1175,7 +1175,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) JLOG(app.journal("Ledger").debug()) << " Flat fetch time : " << ((end - start).count() / 1000000000.0) << " number of transactions " << nodestoreHashes.size(); - assert(objs.size() == nodestoreHashes.size()); + XRPL_ASSERT(objs.size() == nodestoreHashes.size()); for (size_t i = 0; i < objs.size(); ++i) { uint256& nodestoreHash = nodestoreHashes[i]; @@ -1186,21 +1186,21 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) makeSlice(obj->getData()), SHAMapHash{nodestoreHash}); if (!node) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Error making SHAMap node"); } auto item = (static_cast(node.get()))->peekItem(); if (!item) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Error reading SHAMap node"); } auto txnPlusMeta = deserializeTxPlusMeta(*item); if (!txnPlusMeta.first || !txnPlusMeta.second) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Error deserializing SHAMap node"); } @@ -1208,7 +1208,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) } else { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Containing SHAMap node not found"); } @@ -1221,7 +1221,7 @@ flatFetchTransactions(ReadView const& ledger, Application& app) { if (!app.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); return {}; } diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index ed2ccd07434..a9b830eb0b6 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -58,7 +58,7 @@ LedgerHistory::insert( if (!ledger->isImmutable()) LogicError("mutable Ledger in insert"); - assert(ledger->stateMap().getHash().isNonZero()); + XRPL_ASSERT(ledger->stateMap().getHash().isNonZero()); std::unique_lock sl(m_ledgers_by_hash.peekMutex()); @@ -99,13 +99,13 @@ LedgerHistory::getLedgerBySeq(LedgerIndex index) if (!ret) return ret; - assert(ret->info().seq == index); + XRPL_ASSERT(ret->info().seq == index); { // Add this ledger to the local tracking by index std::unique_lock sl(m_ledgers_by_hash.peekMutex()); - assert(ret->isImmutable()); + XRPL_ASSERT(ret->isImmutable()); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); mLedgersByIndex[ret->info().seq] = ret->info().hash; return (ret->info().seq == index) ? ret : nullptr; @@ -119,8 +119,8 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (ret) { - assert(ret->isImmutable()); - assert(ret->info().hash == hash); + XRPL_ASSERT(ret->isImmutable()); + XRPL_ASSERT(ret->info().hash == hash); return ret; } @@ -129,10 +129,10 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (!ret) return ret; - assert(ret->isImmutable()); - assert(ret->info().hash == hash); + XRPL_ASSERT(ret->isImmutable()); + XRPL_ASSERT(ret->info().hash == hash); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); - assert(ret->info().hash == hash); + XRPL_ASSERT(ret->info().hash == hash); return ret; } @@ -176,7 +176,7 @@ log_metadata_difference( auto validMetaData = getMeta(validLedger, tx); auto builtMetaData = getMeta(builtLedger, tx); - assert(validMetaData || builtMetaData); + XRPL_ASSERT(validMetaData || builtMetaData); if (validMetaData && builtMetaData) { @@ -322,7 +322,7 @@ LedgerHistory::handleMismatch( std::optional const& validatedConsensusHash, Json::Value const& consensus) { - assert(built != valid); + XRPL_ASSERT(built != valid); ++mismatch_counter_; auto builtLedger = getLedgerByHash(built); @@ -337,7 +337,7 @@ LedgerHistory::handleMismatch( return; } - assert(builtLedger->info().seq == validLedger->info().seq); + XRPL_ASSERT(builtLedger->info().seq == validLedger->info().seq); if (auto stream = j_.debug()) { @@ -430,7 +430,7 @@ LedgerHistory::builtLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - assert(!hash.isZero()); + XRPL_ASSERT(!hash.isZero()); std::unique_lock sl(m_consensus_validated.peekMutex()); @@ -470,7 +470,7 @@ LedgerHistory::validatedLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - assert(!hash.isZero()); + XRPL_ASSERT(!hash.isZero()); std::unique_lock sl(m_consensus_validated.peekMutex()); diff --git a/src/ripple/app/ledger/OpenLedger.h b/src/ripple/app/ledger/OpenLedger.h index e3cb2b10028..a9c76eaaa89 100644 --- a/src/ripple/app/ledger/OpenLedger.h +++ b/src/ripple/app/ledger/OpenLedger.h @@ -24,11 +24,11 @@ #include #include #include +#include #include #include #include #include -#include #include namespace ripple { @@ -263,7 +263,7 @@ OpenLedger::apply( // If there are any transactions left, we must have // tried them in at least one final pass - assert(retries.empty() || !retry); + XRPL_ASSERT(retries.empty() || !retry); } //------------------------------------------------------------------------------ diff --git a/src/ripple/app/ledger/OrderBookDB.cpp b/src/ripple/app/ledger/OrderBookDB.cpp index e1fc8a248f0..a6b8d6eb8eb 100644 --- a/src/ripple/app/ledger/OrderBookDB.cpp +++ b/src/ripple/app/ledger/OrderBookDB.cpp @@ -225,7 +225,7 @@ OrderBookDB::makeBookListeners(Book const& book) ret = std::make_shared(); mListeners[book] = ret; - assert(getBookListeners(book) == ret); + XRPL_ASSERT(getBookListeners(book) == ret); } return ret; diff --git a/src/ripple/app/ledger/TransactionStateSF.cpp b/src/ripple/app/ledger/TransactionStateSF.cpp index f65de5f9997..eafefbbd0cf 100644 --- a/src/ripple/app/ledger/TransactionStateSF.cpp +++ b/src/ripple/app/ledger/TransactionStateSF.cpp @@ -30,7 +30,7 @@ TransactionStateSF::gotNode( SHAMapNodeType type) const { - assert(type != SHAMapNodeType::tnTRANSACTION_NM); + XRPL_ASSERT(type != SHAMapNodeType::tnTRANSACTION_NM); db_.store( hotTRANSACTION_NODE, std::move(nodeData), diff --git a/src/ripple/app/ledger/impl/BuildLedger.cpp b/src/ripple/app/ledger/impl/BuildLedger.cpp index 363c110cd18..3d2e47741c3 100644 --- a/src/ripple/app/ledger/impl/BuildLedger.cpp +++ b/src/ripple/app/ledger/impl/BuildLedger.cpp @@ -57,7 +57,7 @@ buildLedgerImpl( { OpenView accum(&*built); - assert(!accum.open()); + XRPL_ASSERT(!accum.open()); applyTxs(accum, built); accum.apply(*built); } @@ -75,7 +75,7 @@ buildLedgerImpl( built->unshare(); // Accept ledger - assert( + XRPL_ASSERT( built->info().seq < XRP_LEDGER_EARLIEST_FEES || built->read(keylet::fees())); built->setAccepted(closeTime, closeResolution, closeTimeCorrect); @@ -169,7 +169,7 @@ applyTransactions( // If there are any transactions left, we must have // tried them in at least one final pass - assert(txns.empty() || !certainRetry); + XRPL_ASSERT(txns.empty() || !certainRetry); return count; } diff --git a/src/ripple/app/ledger/impl/InboundLedger.cpp b/src/ripple/app/ledger/impl/InboundLedger.cpp index 53475988cbf..2fef62ee110 100644 --- a/src/ripple/app/ledger/impl/InboundLedger.cpp +++ b/src/ripple/app/ledger/impl/InboundLedger.cpp @@ -155,7 +155,7 @@ InboundLedger::init(ScopedLockType& collectionLock) JLOG(journal_.debug()) << "Acquiring ledger we already have in " << " local store. " << hash_; - assert( + XRPL_ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || mLedger->read(keylet::fees())); mLedger->setImmutable(); @@ -389,7 +389,7 @@ InboundLedger::tryDB(NodeStore::Database& srcDB) { JLOG(journal_.debug()) << "Had everything locally"; complete_ = true; - assert( + XRPL_ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || mLedger->read(keylet::fees())); mLedger->setImmutable(); @@ -485,11 +485,11 @@ InboundLedger::done() std::to_string(timeouts_) + " ")) << mStats.get(); - assert(complete_ || failed_); + XRPL_ASSERT(complete_ || failed_); if (complete_ && !failed_ && mLedger) { - assert( + XRPL_ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || mLedger->read(keylet::fees())); mLedger->setImmutable(); @@ -656,7 +656,7 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) // if we wind up abandoning this fetch. if (mHaveHeader && !mHaveState && !failed_) { - assert(mLedger); + XRPL_ASSERT(mLedger); if (!mLedger->stateMap().isValid()) { @@ -728,7 +728,7 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) if (mHaveHeader && !mHaveTransactions && !failed_) { - assert(mLedger); + XRPL_ASSERT(mLedger); if (!mLedger->txMap().isValid()) { @@ -994,7 +994,7 @@ InboundLedger::takeAsRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -1019,7 +1019,7 @@ InboundLedger::takeTxRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/ripple/app/ledger/impl/InboundLedgers.cpp index 0bff434edbc..5d79f11983d 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/ripple/app/ledger/impl/InboundLedgers.cpp @@ -69,8 +69,8 @@ class InboundLedgersImp : public InboundLedgers std::uint32_t seq, InboundLedger::Reason reason) override { - assert(hash.isNonZero()); - assert( + XRPL_ASSERT(hash.isNonZero()); + XRPL_ASSERT( reason != InboundLedger::Reason::SHARD || (seq != 0 && app_.getShardStore())); @@ -144,7 +144,7 @@ class InboundLedgersImp : public InboundLedgers std::shared_ptr find(uint256 const& hash) override { - assert(hash.isNonZero()); + XRPL_ASSERT(hash.isNonZero()); std::shared_ptr ret; @@ -306,7 +306,7 @@ class InboundLedgersImp : public InboundLedgers acqs.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - assert(it.second); + XRPL_ASSERT(it.second); acqs.push_back(it); } for (auto const& it : mRecentFailures) @@ -341,7 +341,7 @@ class InboundLedgersImp : public InboundLedgers acquires.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - assert(it.second); + XRPL_ASSERT(it.second); acquires.push_back(it.second); } } diff --git a/src/ripple/app/ledger/impl/LedgerCleaner.cpp b/src/ripple/app/ledger/impl/LedgerCleaner.cpp index e5ee6409d34..33f2928a7a5 100644 --- a/src/ripple/app/ledger/impl/LedgerCleaner.cpp +++ b/src/ripple/app/ledger/impl/LedgerCleaner.cpp @@ -231,7 +231,7 @@ class LedgerCleanerImp : public LedgerCleaner }); if (shouldExit_) break; - assert(state_ == State::cleaning); + XRPL_ASSERT(state_ == State::cleaning); } doLedgerCleaner(); } @@ -353,7 +353,7 @@ class LedgerCleanerImp : public LedgerCleaner LedgerHash refHash = getLedgerHash(referenceLedger, refIndex); bool const nonzero(refHash.isNonZero()); - assert(nonzero); + XRPL_ASSERT(nonzero); if (nonzero) { // We found the hash and sequence of a better reference diff --git a/src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp b/src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp index 3c19c6ee156..919943a387d 100644 --- a/src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp +++ b/src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp @@ -199,8 +199,8 @@ LedgerDeltaAcquire::tryBuild(std::shared_ptr const& parent) if (failed_ || !complete_ || !replayTemp_) return {}; - assert(parent->seq() + 1 == replayTemp_->seq()); - assert(parent->info().hash == replayTemp_->info().parentHash); + XRPL_ASSERT(parent->seq() + 1 == replayTemp_->seq()); + XRPL_ASSERT(parent->info().hash == replayTemp_->info().parentHash); // build ledger LedgerReplay replayData(parent, replayTemp_, std::move(orderedTxns_)); fullLedger_ = buildLedger(replayData, tapNONE, app_, journal_); @@ -262,7 +262,7 @@ LedgerDeltaAcquire::onLedgerBuilt( void LedgerDeltaAcquire::notify(ScopedLockType& sl) { - assert(isDone()); + XRPL_ASSERT(isDone()); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index 9388a3005ba..77ed27f45f9 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -53,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -119,7 +119,7 @@ class ScopedUnlock */ explicit ScopedUnlock(std::unique_lock& lock) : lock_(lock) { - assert(lock_.owns_lock()); + XRPL_ASSERT(lock_.owns_lock()); lock_.unlock(); } @@ -368,7 +368,7 @@ LedgerMaster::setValidLedger(std::shared_ptr const& l) mValidLedger.set(l); mValidLedgerSign = signTime.time_since_epoch().count(); - assert( + XRPL_ASSERT( mValidLedgerSeq || !app_.getMaxDisallowedLedger() || l->info().seq + max_ledger_difference_ > app_.getMaxDisallowedLedger()); (void)max_ledger_difference_; @@ -435,7 +435,7 @@ LedgerMaster::addHeldTransaction( bool LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) { - assert(ledger); + XRPL_ASSERT(ledger); // Never jump to a candidate ledger that precedes our // last validated ledger @@ -503,7 +503,7 @@ LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) void LedgerMaster::switchLCL(std::shared_ptr const& lastClosed) { - assert(lastClosed); + XRPL_ASSERT(lastClosed); if (!lastClosed->isImmutable()) LogicError("mutable ledger in switchLCL"); @@ -623,7 +623,7 @@ LedgerMaster::isValidated(ReadView const& ledger) // This ledger's hash is not the hash of the validated ledger if (hash) { - assert(hash->isNonZero()); + XRPL_ASSERT(hash->isNonZero()); uint256 valHash = app_.getRelationalDatabase().getHashByIndex(seq); if (valHash == ledger.info().hash) @@ -964,7 +964,7 @@ LedgerMaster::setFullLedger( // A new ledger has been accepted as part of the trusted chain JLOG(m_journal.debug()) << "Ledger " << ledger->info().seq << " accepted :" << ledger->info().hash; - assert(ledger->stateMap().getHash().isNonZero()); + XRPL_ASSERT(ledger->stateMap().getHash().isNonZero()); ledger->setValidated(); ledger->setFull(); @@ -1429,7 +1429,7 @@ LedgerMaster::findNewLedgersToPublish( { JLOG(m_journal.fatal()) << "Ledger: " << valSeq << " does not have hash for " << seq; - assert(false); + XRPL_UNREACHABLE(); } else { @@ -1516,7 +1516,7 @@ LedgerMaster::tryAdvance() app_.getJobQueue().addJob(jtADVANCE, "advanceLedger", [this]() { std::unique_lock sl(m_mutex); - assert(!mValidLedger.empty() && mAdvanceThread); + XRPL_ASSERT(!mValidLedger.empty() && mAdvanceThread); JLOG(m_journal.trace()) << "advanceThread<"; @@ -1835,7 +1835,7 @@ LedgerMaster::walkHashBySeq( // be located easily and should contain the hash. LedgerIndex refIndex = getCandidateLedger(index); auto const refHash = hashOfSeq(*referenceLedger, refIndex, m_journal); - assert(refHash); + XRPL_ASSERT(refHash); if (refHash) { // Try the hash and sequence of a better reference ledger just found @@ -1860,7 +1860,7 @@ LedgerMaster::walkHashBySeq( *refHash, refIndex, reason)) { ledgerHash = hashOfSeq(*l, index, m_journal); - assert(ledgerHash); + XRPL_ASSERT(ledgerHash); } } } @@ -1972,7 +1972,7 @@ LedgerMaster::fetchForHistory( ScopedUnlock sul{sl}; if (auto hash = getLedgerHashForHistory(missing, reason)) { - assert(hash->isNonZero()); + XRPL_ASSERT(hash->isNonZero()); auto ledger = getLedgerByHash(*hash); if (!ledger) { @@ -1999,7 +1999,7 @@ LedgerMaster::fetchForHistory( if (ledger) { auto seq = ledger->info().seq; - assert(seq == missing); + XRPL_ASSERT(seq == missing); JLOG(m_journal.trace()) << "fetchForHistory acquired " << seq; if (reason == InboundLedger::Reason::SHARD) { @@ -2059,7 +2059,7 @@ LedgerMaster::fetchForHistory( std::uint32_t seq = missing - i; if (auto h = getLedgerHashForHistory(seq, reason)) { - assert(h->isNonZero()); + XRPL_ASSERT(h->isNonZero()); app_.getInboundLedgers().acquire(*h, seq, reason); } } @@ -2254,7 +2254,7 @@ populateFetchPack( std::uint32_t seq, bool withLeaves = true) { - assert(cnt != 0); + XRPL_ASSERT(cnt != 0); Serializer s(1024); diff --git a/src/ripple/app/ledger/impl/LedgerReplayTask.cpp b/src/ripple/app/ledger/impl/LedgerReplayTask.cpp index 46ce9815a6e..081aadd13ea 100644 --- a/src/ripple/app/ledger/impl/LedgerReplayTask.cpp +++ b/src/ripple/app/ledger/impl/LedgerReplayTask.cpp @@ -32,7 +32,7 @@ LedgerReplayTask::TaskParameter::TaskParameter( std::uint32_t totalNumLedgers) : reason_(r), finishHash_(finishLedgerHash), totalLedgers_(totalNumLedgers) { - assert(finishLedgerHash.isNonZero() && totalNumLedgers > 0); + XRPL_ASSERT(finishLedgerHash.isNonZero() && totalNumLedgers > 0); } bool @@ -48,7 +48,7 @@ LedgerReplayTask::TaskParameter::update( skipList_ = sList; skipList_.emplace_back(finishHash_); startHash_ = skipList_[skipList_.size() - totalLedgers_]; - assert(startHash_.isNonZero()); + XRPL_ASSERT(startHash_.isNonZero()); startSeq_ = finishSeq_ - totalLedgers_ + 1; full_ = true; return true; @@ -200,7 +200,7 @@ LedgerReplayTask::tryAdvance(ScopedLockType& sl) for (; deltaToBuild_ < deltas_.size(); ++deltaToBuild_) { auto& delta = deltas_[deltaToBuild_]; - assert(parent_->seq() + 1 == delta->ledgerSeq_); + XRPL_ASSERT(parent_->seq() + 1 == delta->ledgerSeq_); if (auto l = delta->tryBuild(parent_); l) { JLOG(journal_.debug()) @@ -289,7 +289,7 @@ LedgerReplayTask::addDelta(std::shared_ptr const& delta) JLOG(journal_.trace()) << "addDelta task " << hash_ << " deltaIndex=" << deltaToBuild_ << " totalDeltas=" << deltas_.size(); - assert( + XRPL_ASSERT( deltas_.empty() || deltas_.back()->ledgerSeq_ + 1 == delta->ledgerSeq_); deltas_.push_back(delta); diff --git a/src/ripple/app/ledger/impl/LedgerReplayer.cpp b/src/ripple/app/ledger/impl/LedgerReplayer.cpp index 903f72dd117..69f4456deeb 100644 --- a/src/ripple/app/ledger/impl/LedgerReplayer.cpp +++ b/src/ripple/app/ledger/impl/LedgerReplayer.cpp @@ -47,7 +47,7 @@ LedgerReplayer::replay( uint256 const& finishLedgerHash, std::uint32_t totalNumLedgers) { - assert( + XRPL_ASSERT( finishLedgerHash.isNonZero() && totalNumLedgers > 0 && totalNumLedgers <= LedgerReplayParameters::MAX_TASK_SIZE); diff --git a/src/ripple/app/ledger/impl/SkipListAcquire.cpp b/src/ripple/app/ledger/impl/SkipListAcquire.cpp index aa9b8564eb3..d9dc7dcbf4c 100644 --- a/src/ripple/app/ledger/impl/SkipListAcquire.cpp +++ b/src/ripple/app/ledger/impl/SkipListAcquire.cpp @@ -139,7 +139,7 @@ SkipListAcquire::processData( std::uint32_t ledgerSeq, boost::intrusive_ptr const& item) { - assert(ledgerSeq != 0 && item); + XRPL_ASSERT(ledgerSeq != 0 && item); ScopedLockType sl(mtx_); if (isDone()) return; @@ -224,7 +224,7 @@ SkipListAcquire::onSkipListAcquired( void SkipListAcquire::notify(ScopedLockType& sl) { - assert(isDone()); + XRPL_ASSERT(isDone()); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/ripple/app/ledger/impl/TimeoutCounter.cpp b/src/ripple/app/ledger/impl/TimeoutCounter.cpp index 9ea20c06384..5d76d863505 100644 --- a/src/ripple/app/ledger/impl/TimeoutCounter.cpp +++ b/src/ripple/app/ledger/impl/TimeoutCounter.cpp @@ -43,7 +43,7 @@ TimeoutCounter::TimeoutCounter( , queueJobParameter_(std::move(jobParameter)) , timer_(app_.getIOService()) { - assert((timerInterval_ > 10ms) && (timerInterval_ < 30s)); + XRPL_ASSERT((timerInterval_ > 10ms) && (timerInterval_ < 30s)); } void diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 4f994cfe5ac..45f24c80959 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -613,7 +613,7 @@ class ApplicationImp : public Application, public BasicApp virtual ServerHandler& getServerHandler() override { - assert(serverHandler_); + XRPL_ASSERT(serverHandler_); return *serverHandler_; } @@ -889,35 +889,35 @@ class ApplicationImp : public Application, public BasicApp Overlay& overlay() override { - assert(overlay_); + XRPL_ASSERT(overlay_); return *overlay_; } TxQ& getTxQ() override { - assert(txQ_.get() != nullptr); + XRPL_ASSERT(txQ_.get() != nullptr); return *txQ_; } RelationalDatabase& getRelationalDatabase() override { - assert(mRelationalDatabase.get() != nullptr); + XRPL_ASSERT(mRelationalDatabase.get() != nullptr); return *mRelationalDatabase; } DatabaseCon& getWalletDB() override { - assert(mWalletDB.get() != nullptr); + XRPL_ASSERT(mWalletDB.get() != nullptr); return *mWalletDB; } ReportingETL& getReportingETL() override { - assert(reportingETL_.get() != nullptr); + XRPL_ASSERT(reportingETL_.get() != nullptr); return *reportingETL_; } @@ -932,7 +932,7 @@ class ApplicationImp : public Application, public BasicApp bool initRelationalDatabase() { - assert(mWalletDB.get() == nullptr); + XRPL_ASSERT(mWalletDB.get() == nullptr); try { @@ -1375,7 +1375,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) for (auto const& [a, vote] : amendments) { auto const f = ripple::getRegisteredFeature(a); - assert(f); + XRPL_ASSERT(f); if (f) supported.emplace_back(a, *f, vote); } @@ -1904,7 +1904,7 @@ ApplicationImp::startGenesisLedger() auto const next = std::make_shared(*genesis, timeKeeper().closeTime()); next->updateSkipList(); - assert( + XRPL_ASSERT( next->info().seq < XRP_LEDGER_EARLIEST_FEES || next->read(keylet::fees())); next->setImmutable(); @@ -1925,7 +1925,7 @@ ApplicationImp::getLastFullLedger() if (!ledger) return ledger; - assert( + XRPL_ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees())); ledger->setImmutable(); @@ -2079,7 +2079,7 @@ ApplicationImp::loadLedgerFromFile(std::string const& name) loadLedger->stateMap().flushDirty(hotACCOUNT_NODE); - assert( + XRPL_ASSERT( loadLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || loadLedger->read(keylet::fees())); loadLedger->setAccepted( @@ -2179,7 +2179,7 @@ ApplicationImp::loadOldLedger( if (!loadLedger) { JLOG(m_journal.fatal()) << "Replay ledger missing/damaged"; - assert(false); + XRPL_UNREACHABLE(); return false; } } @@ -2208,21 +2208,21 @@ ApplicationImp::loadOldLedger( if (loadLedger->info().accountHash.isZero()) { JLOG(m_journal.fatal()) << "Ledger is empty."; - assert(false); + XRPL_UNREACHABLE(); return false; } if (!loadLedger->walkLedger(journal("Ledger"), true)) { JLOG(m_journal.fatal()) << "Ledger is missing nodes."; - assert(false); + XRPL_UNREACHABLE(); return false; } if (!loadLedger->assertSensible(journal("Ledger"))) { JLOG(m_journal.fatal()) << "Ledger is not sensible."; - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -2348,8 +2348,8 @@ ApplicationImp::journal(std::string const& name) bool ApplicationImp::nodeToShards() { - assert(overlay_); - assert(!config_->standalone()); + XRPL_ASSERT(overlay_); + XRPL_ASSERT(!config_->standalone()); if (config_->section(ConfigSection::shardDatabase()).empty()) { diff --git a/src/ripple/app/main/GRPCServer.cpp b/src/ripple/app/main/GRPCServer.cpp index a535a4a1a53..fd567800ff7 100644 --- a/src/ripple/app/main/GRPCServer.cpp +++ b/src/ripple/app/main/GRPCServer.cpp @@ -243,7 +243,7 @@ GRPCServerImpl::CallData::forwardToP2p( } else { - assert(false); + XRPL_UNREACHABLE(); Throw( "Attempting to forward but no client_ip field in " "protobuf message"); @@ -714,7 +714,7 @@ GRPCServer::stop() GRPCServer::~GRPCServer() { - assert(!running_); + XRPL_ASSERT(!running_); } } // namespace ripple diff --git a/src/ripple/app/main/LoadManager.cpp b/src/ripple/app/main/LoadManager.cpp index 5e87063f000..f64521431d7 100644 --- a/src/ripple/app/main/LoadManager.cpp +++ b/src/ripple/app/main/LoadManager.cpp @@ -73,7 +73,7 @@ void LoadManager::start() { JLOG(journal_.debug()) << "Starting"; - assert(!thread_.joinable()); + XRPL_ASSERT(!thread_.joinable()); thread_ = std::thread{&LoadManager::run, this}; } diff --git a/src/ripple/app/main/NodeStoreScheduler.cpp b/src/ripple/app/main/NodeStoreScheduler.cpp index 0ac89096410..8ff78cff9bd 100644 --- a/src/ripple/app/main/NodeStoreScheduler.cpp +++ b/src/ripple/app/main/NodeStoreScheduler.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include namespace ripple { diff --git a/src/ripple/app/misc/FeeVoteImpl.cpp b/src/ripple/app/misc/FeeVoteImpl.cpp index 0d60dc6b78e..2f93a676148 100644 --- a/src/ripple/app/misc/FeeVoteImpl.cpp +++ b/src/ripple/app/misc/FeeVoteImpl.cpp @@ -200,7 +200,7 @@ FeeVoteImpl::doVoting( std::shared_ptr const& initialPosition) { // LCL must be flag ledger - assert(lastClosedLedger && isFlagLedger(lastClosedLedger->seq())); + XRPL_ASSERT(lastClosedLedger && isFlagLedger(lastClosedLedger->seq())); detail::VotableValue baseFeeVote( lastClosedLedger->fees().base, target_.reference_fee); diff --git a/src/ripple/app/misc/HashRouter.cpp b/src/ripple/app/misc/HashRouter.cpp index 8085d6892ab..d49e9e15181 100644 --- a/src/ripple/app/misc/HashRouter.cpp +++ b/src/ripple/app/misc/HashRouter.cpp @@ -101,7 +101,7 @@ HashRouter::getFlags(uint256 const& key) bool HashRouter::setFlags(uint256 const& key, int flags) { - assert(flags != 0); + XRPL_ASSERT(flags != 0); std::lock_guard lock(mutex_); diff --git a/src/ripple/app/misc/NegativeUNLVote.cpp b/src/ripple/app/misc/NegativeUNLVote.cpp index 9b616be6ce1..898a2053cd2 100644 --- a/src/ripple/app/misc/NegativeUNLVote.cpp +++ b/src/ripple/app/misc/NegativeUNLVote.cpp @@ -89,7 +89,7 @@ NegativeUNLVote::doVoting( { auto n = choose(prevLedger->info().hash, candidates.toDisableCandidates); - assert(nidToKeyMap.count(n)); + XRPL_ASSERT(nidToKeyMap.count(n)); addTx(seq, nidToKeyMap.at(n), ToDisable, initialSet); } @@ -97,7 +97,7 @@ NegativeUNLVote::doVoting( { auto n = choose( prevLedger->info().hash, candidates.toReEnableCandidates); - assert(nidToKeyMap.count(n)); + XRPL_ASSERT(nidToKeyMap.count(n)); addTx(seq, nidToKeyMap.at(n), ToReEnable, initialSet); } } @@ -140,7 +140,7 @@ NegativeUNLVote::choose( uint256 const& randomPadData, std::vector const& candidates) { - assert(!candidates.empty()); + XRPL_ASSERT(!candidates.empty()); static_assert(NodeID::bytes <= uint256::bytes); NodeID randomPad = NodeID::fromVoid(randomPadData.data()); NodeID txNodeID = candidates[0]; diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index cd85bc9e4e1..da1ddfae292 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -104,7 +104,7 @@ class NetworkOPsImp final : public NetworkOPs FailHard f) : transaction(t), admin(a), local(l), failType(f) { - assert(local || failType == FailHard::no); + XRPL_ASSERT(local || failType == FailHard::no); } }; @@ -1215,7 +1215,7 @@ NetworkOPsImp::processTransaction( *transaction->getSTransaction(), view->rules(), app_.config()); - assert(validity == Validity::Valid); + XRPL_ASSERT(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); - assert(!transactions.empty()); + XRPL_ASSERT(!transactions.empty()); - assert(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)); - assert(sleCur); + XRPL_ASSERT(sleCur); switch (sleCur->getType()) { @@ -1566,7 +1566,7 @@ NetworkOPsImp::getOwnerInfo( case ltACCOUNT_ROOT: case ltDIR_NODE: default: - assert(false); + XRPL_UNREACHABLE(); break; } } @@ -1576,7 +1576,7 @@ NetworkOPsImp::getOwnerInfo( if (uNodeDir) { sleNode = lpLedger->read(keylet::page(root, uNodeDir)); - assert(sleNode); + XRPL_ASSERT(sleNode); } } while (uNodeDir); } @@ -1806,7 +1806,7 @@ NetworkOPsImp::switchLastClosedLedger( bool NetworkOPsImp::beginConsensus(uint256 const& networkClosed) { - assert(networkClosed.isNonZero()); + XRPL_ASSERT(networkClosed.isNonZero()); auto closingInfo = m_ledgerMaster.getCurrentLedger()->info(); @@ -1827,8 +1827,8 @@ NetworkOPsImp::beginConsensus(uint256 const& networkClosed) return false; } - assert(prevLedger->info().hash == closingInfo.parentHash); - assert( + XRPL_ASSERT(prevLedger->info().hash == closingInfo.parentHash); + XRPL_ASSERT( closingInfo.parentHash == m_ledgerMaster.getClosedLedger()->info().hash); @@ -2955,7 +2955,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) lpAccepted->info().hash, alpAccepted); } - assert(alpAccepted->getLedger().get() == lpAccepted.get()); + XRPL_ASSERT(alpAccepted->getLedger().get() == lpAccepted.get()); { JLOG(m_journal.debug()) @@ -3358,7 +3358,7 @@ NetworkOPsImp::pubAccountTransaction( if (last) jvObj.set(jss::account_history_boundary, true); - assert( + XRPL_ASSERT( 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); }); - assert( + XRPL_ASSERT( 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: { - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -3909,7 +3909,7 @@ NetworkOPsImp::subAccountHistoryStart( } else { - assert(false); + XRPL_UNREACHABLE(); return; } } @@ -4017,7 +4017,7 @@ NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book) if (auto listeners = app_.getOrderBookDB().makeBookListeners(book)) listeners->addSubscriber(isrListener); else - assert(false); + XRPL_UNREACHABLE(); return true; } @@ -4036,7 +4036,7 @@ NetworkOPsImp::acceptLedger( { // This code-path is exclusively used when the server is in standalone // mode via `ledger_accept` - assert(m_standalone); + XRPL_ASSERT(m_standalone); if (!m_standalone) Throw( diff --git a/src/ripple/app/misc/SHAMapStoreImp.cpp b/src/ripple/app/misc/SHAMapStoreImp.cpp index d5cb07792dc..d49fa1904a2 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.cpp +++ b/src/ripple/app/misc/SHAMapStoreImp.cpp @@ -281,7 +281,7 @@ SHAMapStoreImp::run() { if (app_.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Reporting does not support online_delete. Remove " "online_delete info from config"); @@ -553,7 +553,7 @@ SHAMapStoreImp::clearSql( std::function()> const& getMinSeq, std::function const& deleteBeforeSeq) { - assert(deleteInterval_); + XRPL_ASSERT(deleteInterval_); LedgerIndex min = std::numeric_limits::max(); { @@ -618,7 +618,7 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated) { if (app_.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Reporting does not support online_delete. Remove " "online_delete info from config"); diff --git a/src/ripple/app/misc/detail/WorkBase.h b/src/ripple/app/misc/detail/WorkBase.h index 4b2c88f71a1..f2a18e64c3b 100644 --- a/src/ripple/app/misc/detail/WorkBase.h +++ b/src/ripple/app/misc/detail/WorkBase.h @@ -282,7 +282,7 @@ WorkBase::onResponse(error_code const& ec) return fail(ec); close(); - assert(cb_); + XRPL_ASSERT(cb_); cb_(ec, lastEndpoint_, std::move(res_)); cb_ = nullptr; } diff --git a/src/ripple/app/misc/detail/WorkFile.h b/src/ripple/app/misc/detail/WorkFile.h index 2dc451feaca..9ed8402a6d8 100644 --- a/src/ripple/app/misc/detail/WorkFile.h +++ b/src/ripple/app/misc/detail/WorkFile.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include namespace ripple { @@ -88,7 +88,7 @@ WorkFile::run() error_code ec; auto const fileContents = getFileContents(ec, path_, megabytes(1)); - assert(cb_); + XRPL_ASSERT(cb_); cb_(ec, fileContents); cb_ = nullptr; } diff --git a/src/ripple/app/misc/impl/AMMHelpers.cpp b/src/ripple/app/misc/impl/AMMHelpers.cpp index 5ad59ea1c28..15fe6eb2cbb 100644 --- a/src/ripple/app/misc/impl/AMMHelpers.cpp +++ b/src/ripple/app/misc/impl/AMMHelpers.cpp @@ -209,7 +209,7 @@ adjustAmountsByLPTokens( return std::make_tuple(amountActual, std::nullopt, lpTokensActual); } - assert(lpTokensActual == lpTokens); + XRPL_ASSERT(lpTokensActual == lpTokens); return {amount, amount2, lpTokensActual}; } diff --git a/src/ripple/app/misc/impl/AMMUtils.cpp b/src/ripple/app/misc/impl/AMMUtils.cpp index 4f6f0fbd3b5..5ec8d15d45f 100644 --- a/src/ripple/app/misc/impl/AMMUtils.cpp +++ b/src/ripple/app/misc/impl/AMMUtils.cpp @@ -145,7 +145,7 @@ std::uint16_t getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account) { using namespace std::chrono; - assert( + XRPL_ASSERT( !view.rules().enabled(fixInnerObjTemplate) || ammSle.isFieldPresent(sfAuctionSlot)); if (ammSle.isFieldPresent(sfAuctionSlot)) diff --git a/src/ripple/app/misc/impl/AmendmentTable.cpp b/src/ripple/app/misc/impl/AmendmentTable.cpp index 8f9556e0714..2981793f6e2 100644 --- a/src/ripple/app/misc/impl/AmendmentTable.cpp +++ b/src/ripple/app/misc/impl/AmendmentTable.cpp @@ -656,7 +656,7 @@ AmendmentTableImpl::persistVote( std::string const& name, AmendmentVote vote) const { - assert(vote != AmendmentVote::obsolete); + XRPL_ASSERT(vote != AmendmentVote::obsolete); auto db = db_.checkoutDb(); voteAmendment(*db, amendment, name, vote); } diff --git a/src/ripple/app/misc/impl/Manifest.cpp b/src/ripple/app/misc/impl/Manifest.cpp index 2916d6d2f32..0b10aa901f5 100644 --- a/src/ripple/app/misc/impl/Manifest.cpp +++ b/src/ripple/app/misc/impl/Manifest.cpp @@ -390,7 +390,7 @@ ManifestCache::applyManifest(Manifest m) auto prewriteCheck = [this, &m](auto const& iter, bool checkSignature, auto const& lock) -> std::optional { - assert(lock.owns_lock()); + XRPL_ASSERT(lock.owns_lock()); (void)lock; // not used. parameter is present to ensure the mutex is // locked when the lambda is called. if (iter != map_.end() && m.sequence <= iter->second.sequence) diff --git a/src/ripple/app/misc/impl/Transaction.cpp b/src/ripple/app/misc/impl/Transaction.cpp index e3ec41a25d4..99cdb5af606 100644 --- a/src/ripple/app/misc/impl/Transaction.cpp +++ b/src/ripple/app/misc/impl/Transaction.cpp @@ -84,7 +84,7 @@ Transaction::sqlTransactionStatus(boost::optional const& status) return INCLUDED; } - assert(c == txnSqlUnknown); + XRPL_ASSERT(c == txnSqlUnknown); return INVALID; } diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/ripple/app/misc/impl/TxQ.cpp index faaca0655cf..cce332a7794 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/ripple/app/misc/impl/TxQ.cpp @@ -52,7 +52,7 @@ getFeeLevelPaid(ReadView const& view, STTx const& tx) return std::pair{baseFee + mod, feePaid + mod}; }(); - assert(baseFee.signum() > 0); + XRPL_ASSERT(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()); - assert(size == feeLevels.size()); + XRPL_ASSERT(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; - assert(current > target); + XRPL_ASSERT(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 - assert(pfresult); + XRPL_ASSERT(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)); - assert(result.second); - assert(&result.first->second != &txn); + XRPL_ASSERT(result.second); + XRPL_ASSERT(&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; - assert(found); + XRPL_ASSERT(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); - assert(accountIter != txQAccount.transactions.end()); + XRPL_ASSERT(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. - assert( + XRPL_ASSERT( candidateIter->seqProxy.isTicket() || accountIter == txQAccount.transactions.begin()); - assert(byFee_.iterator_to(accountIter->second) == candidateIter); + XRPL_ASSERT(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()}; - assert(beginTxIter != accountIter->second.transactions.end()); + XRPL_ASSERT(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. - assert(prevIter != txIter->end); + XRPL_ASSERT(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); - assert( + XRPL_ASSERT( 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 - assert(feeLevelPaid >= baseLevel); + XRPL_ASSERT(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(); - assert(dropRIter->second.account == lastRIter->account); + XRPL_ASSERT(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; - assert(created); + XRPL_ASSERT(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(); - assert( + XRPL_ASSERT( 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(); - assert(parentHash != parentHash_); + XRPL_ASSERT(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); } } - assert(byFee_.size() == startingSize); + XRPL_ASSERT(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); - assert(deleteIter != byFee_.end()); - assert(&(*replacedTxIter)->second == &*deleteIter); - assert(deleteIter->seqProxy == tx->getSeqProxy()); - assert(deleteIter->account == (*tx)[sfAccount]); + XRPL_ASSERT(deleteIter != byFee_.end()); + XRPL_ASSERT(&(*replacedTxIter)->second == &*deleteIter); + XRPL_ASSERT(deleteIter->seqProxy == tx->getSeqProxy()); + XRPL_ASSERT(deleteIter->account == (*tx)[sfAccount]); erase(deleteIter); } diff --git a/src/ripple/app/misc/impl/ValidatorList.cpp b/src/ripple/app/misc/impl/ValidatorList.cpp index ff5fbd90eac..3faad541359 100644 --- a/src/ripple/app/misc/impl/ValidatorList.cpp +++ b/src/ripple/app/misc/impl/ValidatorList.cpp @@ -276,7 +276,8 @@ ValidatorList::buildFileData( { Json::Value value(Json::objectValue); - assert(pubCollection.rawVersion == 2 || pubCollection.remaining.empty()); + XRPL_ASSERT( + pubCollection.rawVersion == 2 || pubCollection.remaining.empty()); auto const effectiveVersion = forceVersion ? *forceVersion : pubCollection.rawVersion; @@ -376,7 +377,7 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) ValidatorBlobInfo& info = result.emplace_back(); info.blob = body[jss::blob].asString(); info.signature = body[jss::signature].asString(); - assert(result.size() == 1); + XRPL_ASSERT(result.size() == 1); return result; } // Treat unknown versions as if they're the latest version. This @@ -411,7 +412,7 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) info.manifest = blobInfo[jss::manifest].asString(); } } - assert(result.size() == blobs.size()); + XRPL_ASSERT(result.size() == blobs.size()); return result; } } @@ -442,7 +443,7 @@ ValidatorList::parseBlobs(protocol::TMValidatorListCollection const& body) info.manifest = blob.manifest(); } } - assert(result.size() == body.blobs_size()); + XRPL_ASSERT(result.size() == body.blobs_size()); return result; } @@ -464,7 +465,7 @@ splitMessage( { if (begin == 0 && end == 0) end = largeMsg.blobs_size(); - assert(begin < end); + XRPL_ASSERT(begin < end); if (end <= begin) return 0; @@ -498,7 +499,7 @@ splitMessageParts( if (blob.has_manifest()) smallMsg.set_manifest(blob.manifest()); - assert(Message::totalSize(smallMsg) <= maximiumMessageSize); + XRPL_ASSERT(Message::totalSize(smallMsg) <= maximiumMessageSize); messages.emplace_back( std::make_shared(smallMsg, protocol::mtVALIDATORLIST), @@ -546,7 +547,7 @@ buildValidatorListMessage( ValidatorBlobInfo const& currentBlob, std::size_t maxSize) { - assert(messages.empty()); + XRPL_ASSERT(messages.empty()); protocol::TMValidatorList msg; auto const manifest = currentBlob.manifest ? *currentBlob.manifest : rawManifest; @@ -557,7 +558,7 @@ buildValidatorListMessage( // Override the version msg.set_version(version); - assert(Message::totalSize(msg) <= maximiumMessageSize); + XRPL_ASSERT(Message::totalSize(msg) <= maximiumMessageSize); messages.emplace_back( std::make_shared(msg, protocol::mtVALIDATORLIST), sha512Half(msg), @@ -576,7 +577,7 @@ buildValidatorListMessage( std::map const& blobInfos, std::size_t maxSize) { - assert(messages.empty()); + XRPL_ASSERT(messages.empty()); protocol::TMValidatorListCollection msg; auto const version = rawVersion < 2 ? 2 : rawVersion; msg.set_version(version); @@ -592,7 +593,7 @@ buildValidatorListMessage( if (blobInfo.manifest) blob.set_manifest(*blobInfo.manifest); } - assert(msg.blobs_size() > 0); + XRPL_ASSERT(msg.blobs_size() > 0); if (Message::totalSize(msg) > maxSize) { // split into smaller messages @@ -621,7 +622,7 @@ ValidatorList::buildValidatorListMessages( std::vector& messages, std::size_t maxSize /*= maximiumMessageSize*/) { - assert(!blobInfos.empty()); + XRPL_ASSERT(!blobInfos.empty()); auto const& [currentSeq, currentBlob] = *blobInfos.begin(); auto numVLs = std::accumulate( messages.begin(), @@ -705,7 +706,7 @@ ValidatorList::sendValidatorList( messages); if (newPeerSequence) { - assert(!messages.empty()); + XRPL_ASSERT(!messages.empty()); // Don't send it next time. peer.setPublisherListSequence(publisherKey, newPeerSequence); @@ -721,7 +722,7 @@ ValidatorList::sendValidatorList( } // The only way sent wil be false is if the messages was too big, and // thus there will only be one entry without a message - assert(sent || messages.size() == 1); + XRPL_ASSERT(sent || messages.size() == 1); if (sent) { if (messageVersion > 1) @@ -735,7 +736,7 @@ ValidatorList::sendValidatorList( << "]"; else { - assert(numVLs == 1); + XRPL_ASSERT(numVLs == 1); JLOG(j.debug()) << "Sent validator list for " << strHex(publisherKey) << " with sequence " << newPeerSequence << " to " @@ -830,7 +831,7 @@ ValidatorList::broadcastBlobs( // be built to hold info for all of the valid VLs. std::map blobInfos; - assert( + XRPL_ASSERT( lists.current.sequence == maxSequence || lists.remaining.count(maxSequence) == 1); // Can't use overlay.foreach here because we need to modify @@ -976,7 +977,7 @@ ValidatorList::applyLists( for (auto iter = remaining.begin(); iter != remaining.end();) { auto next = std::next(iter); - assert(next == remaining.end() || next->first > iter->first); + XRPL_ASSERT(next == remaining.end() || next->first > iter->first); if (iter->first <= current.sequence || (next != remaining.end() && next->second.validFrom <= iter->second.validFrom)) @@ -1148,7 +1149,7 @@ ValidatorList::applyList( // Remove the entry in "remaining" pubCollection.remaining.erase(sequence); // Done - assert(publisher.sequence == sequence); + XRPL_ASSERT(publisher.sequence == sequence); } else { @@ -1442,7 +1443,7 @@ ValidatorList::removePublisherList( PublicKey const& publisherKey, PublisherStatus reason) { - assert( + XRPL_ASSERT( reason != PublisherStatus::available && reason != PublisherStatus::unavailable); auto const iList = publisherLists_.find(publisherKey); @@ -1629,7 +1630,7 @@ ValidatorList::getJson() const Json::Value& r = remaining.append(Json::objectValue); appendList(future, r); // Race conditions can happen, so make this check "fuzzy" - assert(future.validFrom > timeKeeper_.now() + 600s); + XRPL_ASSERT(future.validFrom > timeKeeper_.now() + 600s); } if (remaining.size()) curr[jss::remaining] = std::move(remaining); @@ -1694,7 +1695,7 @@ ValidatorList::for_each_available( { if (plCollection.status != PublisherStatus::available) continue; - assert(plCollection.maxSequence); + XRPL_ASSERT(plCollection.maxSequence); func( plCollection.rawManifest, plCollection.rawVersion, @@ -1828,21 +1829,21 @@ ValidatorList::updateTrusted( next->second.validFrom <= closeTime; ++iter, ++next) { - assert(std::next(iter) == next); + XRPL_ASSERT(std::next(iter) == next); } - assert(iter != remaining.end()); + XRPL_ASSERT(iter != remaining.end()); // Rotate the pending list in to current auto sequence = iter->first; auto& candidate = iter->second; auto& current = collection.current; - assert(candidate.validFrom <= closeTime); + XRPL_ASSERT(candidate.validFrom <= closeTime); auto const oldList = current.list; current = std::move(candidate); if (collection.status != PublisherStatus::available) collection.status = PublisherStatus::available; - assert(current.sequence == sequence); + XRPL_ASSERT(current.sequence == sequence); // If the list is expired, remove the validators so they don't // get processed in. The expiration check below will do the rest // of the work @@ -1919,7 +1920,7 @@ ValidatorList::updateTrusted( { std::optional const signingKey = validatorManifests_.getSigningKey(k); - assert(signingKey); + XRPL_ASSERT(signingKey); trustedSigningKeys_.insert(*signingKey); } } diff --git a/src/ripple/app/misc/impl/ValidatorSite.cpp b/src/ripple/app/misc/impl/ValidatorSite.cpp index 013d7e96ffd..bcaacb02d80 100644 --- a/src/ripple/app/misc/impl/ValidatorSite.cpp +++ b/src/ripple/app/misc/impl/ValidatorSite.cpp @@ -411,7 +411,7 @@ ValidatorSite::parseJsonResponse( } auto const manifest = body[jss::manifest].asString(); - assert(version == body[jss::version].asUInt()); + XRPL_ASSERT(version == body[jss::version].asUInt()); auto const& uri = sites_[siteIdx].activeResource->uri; auto const hash = sha512Half(manifest, blobs, version); auto const applyResult = app_.validators().applyListsAndBroadcast( @@ -586,7 +586,7 @@ ValidatorSite::onSiteFetch( case status::temporary_redirect: { auto newLocation = processRedirect(res, siteIdx, lock_sites); - assert(newLocation); + XRPL_ASSERT(newLocation); // for perm redirects, also update our starting URI if (res.result() == status::moved_permanently || res.result() == status::permanent_redirect) diff --git a/src/ripple/app/paths/Credit.cpp b/src/ripple/app/paths/Credit.cpp index b9b19d29f90..8cc9e7031bd 100644 --- a/src/ripple/app/paths/Credit.cpp +++ b/src/ripple/app/paths/Credit.cpp @@ -42,8 +42,8 @@ creditLimit( result.setIssuer(account); } - assert(result.getIssuer() == account); - assert(result.getCurrency() == currency); + XRPL_ASSERT(result.getIssuer() == account); + XRPL_ASSERT(result.getCurrency() == currency); return result; } @@ -76,8 +76,8 @@ creditBalance( result.setIssuer(account); } - assert(result.getIssuer() == account); - assert(result.getCurrency() == currency); + XRPL_ASSERT(result.getIssuer() == account); + XRPL_ASSERT(result.getCurrency() == currency); return result; } diff --git a/src/ripple/app/paths/Flow.cpp b/src/ripple/app/paths/Flow.cpp index 83379d34e79..4ae967cd8f8 100644 --- a/src/ripple/app/paths/Flow.cpp +++ b/src/ripple/app/paths/Flow.cpp @@ -193,7 +193,7 @@ flow( flowDebugInfo)); } - assert(!srcIsXRP && !dstIsXRP); + XRPL_ASSERT(!srcIsXRP && !dstIsXRP); return finishFlow( sb, srcIssue, diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp index 948c6698ad1..bcde671abd8 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/ripple/app/paths/PathRequest.cpp @@ -158,7 +158,7 @@ PathRequest::updateComplete() { std::lock_guard sl(mIndexLock); - assert(mInProgress); + XRPL_ASSERT(mInProgress); mInProgress = false; if (fCompletion) diff --git a/src/ripple/app/paths/Pathfinder.cpp b/src/ripple/app/paths/Pathfinder.cpp index 556622ee7bf..b1948637e73 100644 --- a/src/ripple/app/paths/Pathfinder.cpp +++ b/src/ripple/app/paths/Pathfinder.cpp @@ -188,7 +188,8 @@ Pathfinder::Pathfinder( , app_(app) , j_(app.journal("Pathfinder")) { - assert(!uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value())); + XRPL_ASSERT( + !uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value())); } bool @@ -577,7 +578,7 @@ Pathfinder::getBestPaths( if (mCompletePaths.empty() && extraPaths.empty()) return mCompletePaths; - assert(fullLiquidityPath.empty()); + XRPL_ASSERT(fullLiquidityPath.empty()); const bool issuerIsSender = isXRP(mSrcCurrency) || (srcIssuer == mSrcAccount); @@ -638,7 +639,7 @@ Pathfinder::getBestPaths( if (path.empty()) { - assert(false); + XRPL_UNREACHABLE(); continue; } @@ -681,7 +682,7 @@ Pathfinder::getBestPaths( if (remaining > beast::zero) { - assert(fullLiquidityPath.empty()); + XRPL_ASSERT(fullLiquidityPath.empty()); JLOG(j_.info()) << "Paths could not send " << remaining << " of " << mDstAmount; } @@ -830,7 +831,7 @@ Pathfinder::addPathsForType( { case nt_SOURCE: // Source must always be at the start, so pathsOut has to be empty. - assert(pathsOut.empty()); + XRPL_ASSERT(pathsOut.empty()); pathsOut.push_back(STPath()); break; @@ -1282,7 +1283,7 @@ void fillPaths(Pathfinder::PaymentType type, PathCostList const& costs) { auto& list = mPathTable[type]; - assert(list.empty()); + XRPL_ASSERT(list.empty()); for (auto& cost : costs) list.push_back({cost.cost, makePath(cost.path)}); } diff --git a/src/ripple/app/paths/RippleLineCache.cpp b/src/ripple/app/paths/RippleLineCache.cpp index 2487924ff0e..b98d4ec1cd8 100644 --- a/src/ripple/app/paths/RippleLineCache.cpp +++ b/src/ripple/app/paths/RippleLineCache.cpp @@ -79,7 +79,7 @@ RippleLineCache::getRippleLines( // to be replaced by the full set. The full set will be built // below, and will be returned, if needed, on subsequent calls // for either value of outgoing. - assert(size <= totalLineCount_); + XRPL_ASSERT(size <= totalLineCount_); totalLineCount_ -= size; lines_.erase(otheriter); } @@ -99,7 +99,7 @@ RippleLineCache::getRippleLines( if (inserted) { - assert(it->second == nullptr); + XRPL_ASSERT(it->second == nullptr); auto lines = PathFindTrustLine::getItems(accountID, *ledger_, direction); if (lines.size()) @@ -110,7 +110,7 @@ RippleLineCache::getRippleLines( } } - assert(!it->second || (it->second->size() > 0)); + XRPL_ASSERT(!it->second || (it->second->size() > 0)); auto const size = it->second ? it->second->size() : 0; JLOG(journal_.trace()) << "getRippleLines for ledger " << ledger_->info().seq << " found " << size diff --git a/src/ripple/app/paths/impl/AMMLiquidity.cpp b/src/ripple/app/paths/impl/AMMLiquidity.cpp index 9ec23d08a1a..d3042fda4bd 100644 --- a/src/ripple/app/paths/impl/AMMLiquidity.cpp +++ b/src/ripple/app/paths/impl/AMMLiquidity.cpp @@ -77,7 +77,7 @@ AMMLiquidity::generateFibSeqOffer( 196418, 317811, 514229, 832040, 1346269}; // clang-format on - assert(!ammContext_.maxItersReached()); + XRPL_ASSERT(!ammContext_.maxItersReached()); cur.out = toAmount( getIssue(balances.out), diff --git a/src/ripple/app/paths/impl/AmountSpec.h b/src/ripple/app/paths/impl/AmountSpec.h index ca814c7b3ac..b1f9f3c5952 100644 --- a/src/ripple/app/paths/impl/AmountSpec.h +++ b/src/ripple/app/paths/impl/AmountSpec.h @@ -125,7 +125,7 @@ template <> inline IOUAmount& get(EitherAmount& amt) { - assert(!amt.native); + XRPL_ASSERT(!amt.native); return amt.iou; } @@ -133,7 +133,7 @@ template <> inline XRPAmount& get(EitherAmount& amt) { - assert(amt.native); + XRPL_ASSERT(amt.native); return amt.xrp; } @@ -149,7 +149,7 @@ template <> inline IOUAmount const& get(EitherAmount const& amt) { - assert(!amt.native); + XRPL_ASSERT(!amt.native); return amt.iou; } @@ -157,14 +157,14 @@ template <> inline XRPAmount const& get(EitherAmount const& amt) { - assert(amt.native); + XRPL_ASSERT(amt.native); return amt.xrp; } inline AmountSpec toAmountSpec(STAmount const& amt) { - assert(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); @@ -199,7 +199,7 @@ toAmountSpec(EitherAmount const& ea, std::optional const& c) AmountSpec r; r.native = (!c || isXRP(*c)); r.currency = c; - assert(ea.native == r.native); + XRPL_ASSERT(ea.native == r.native); if (r.native) { r.xrp = ea.xrp; diff --git a/src/ripple/app/paths/impl/BookStep.cpp b/src/ripple/app/paths/impl/BookStep.cpp index af0c40b1925..d0efc5dac6d 100644 --- a/src/ripple/app/paths/impl/BookStep.cpp +++ b/src/ripple/app/paths/impl/BookStep.cpp @@ -381,7 +381,7 @@ class BookOfferCrossingStep getQuality(std::optional const& limitQuality) { // It's really a programming error if the quality is missing. - assert(limitQuality); + XRPL_ASSERT(limitQuality); if (!limitQuality) Throw(tefINTERNAL, "Offer requires quality."); return *limitQuality; @@ -1109,7 +1109,7 @@ BookStep::revImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingOut < 0 " << to_string(remainingOut); - assert(0); + XRPL_ASSERT(0); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1132,7 +1132,7 @@ BookStep::fwdImp( boost::container::flat_set& ofrsToRm, TIn const& in) { - assert(cache_); + XRPL_ASSERT(cache_); TAmounts result(beast::zero, beast::zero); @@ -1151,7 +1151,7 @@ BookStep::fwdImp( TOut const& ownerGives, std::uint32_t transferRateIn, std::uint32_t transferRateOut) mutable -> bool { - assert(cache_); + XRPL_ASSERT(cache_); if (remainingIn <= beast::zero) return false; @@ -1279,7 +1279,7 @@ BookStep::fwdImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingIn < 0 " << to_string(remainingIn); - assert(0); + XRPL_ASSERT(0); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1414,7 +1414,7 @@ bookStepEqual(Step const& step, ripple::Book const& book) bool const outXRP = isXRP(book.out.currency); if (inXRP && outXRP) { - assert(0); + XRPL_ASSERT(0); return false; // no such thing as xrp/xrp book step } if (inXRP && !outXRP) diff --git a/src/ripple/app/paths/impl/DirectStep.cpp b/src/ripple/app/paths/impl/DirectStep.cpp index 00647121b74..77d0f0aaac2 100644 --- a/src/ripple/app/paths/impl/DirectStep.cpp +++ b/src/ripple/app/paths/impl/DirectStep.cpp @@ -514,7 +514,7 @@ DirectStepI::revImp( auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::reverse); - assert(static_cast(this)->verifyDstQualityIn(dstQIn)); + XRPL_ASSERT(static_cast(this)->verifyDstQualityIn(dstQIn)); Issue const srcToDstIss(currency_, redeems(srcDebtDir) ? dst_ : src_); @@ -633,7 +633,7 @@ DirectStepI::fwdImp( boost::container::flat_set& /*ofrsToRm*/, IOUAmount const& in) { - assert(cache_); + XRPL_ASSERT(cache_); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -720,7 +720,7 @@ DirectStepI::validFwd( auto const savCache = *cache_; - assert(!in.native); + XRPL_ASSERT(!in.native); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -784,7 +784,7 @@ DirectStepI::qualitiesSrcIssues( { // Charge a transfer rate when issuing and previous step redeems - assert(static_cast(this)->verifyPrevStepDebtDirection( + XRPL_ASSERT(static_cast(this)->verifyPrevStepDebtDirection( prevStepDebtDirection)); std::uint32_t const srcQOut = redeems(prevStepDebtDirection) @@ -924,7 +924,7 @@ DirectStepI::check(StrandContext const& ctx) const { if (!ctx.prevStep) { - assert(0); // prev seen book without a prev step!?! + XRPL_ASSERT(0); // prev seen book without a prev step!?! return temBAD_PATH_LOOP; } diff --git a/src/ripple/app/paths/impl/FlowDebugInfo.h b/src/ripple/app/paths/impl/FlowDebugInfo.h index 2d1728b5f88..151730b2d22 100644 --- a/src/ripple/app/paths/impl/FlowDebugInfo.h +++ b/src/ripple/app/paths/impl/FlowDebugInfo.h @@ -89,7 +89,7 @@ struct FlowDebugInfo void pushLiquiditySrc(EitherAmount const& eIn, EitherAmount const& eOut) { - assert(!liquiditySrcIn.empty()); + XRPL_ASSERT(!liquiditySrcIn.empty()); liquiditySrcIn.back().push_back(eIn); liquiditySrcOut.back().push_back(eOut); } @@ -122,7 +122,7 @@ struct FlowDebugInfo auto i = timePoints.find(tag); if (i == timePoints.end()) { - assert(0); + XRPL_ASSERT(0); return std::chrono::duration(0); } auto const& t = i->second; diff --git a/src/ripple/app/paths/impl/PaySteps.cpp b/src/ripple/app/paths/impl/PaySteps.cpp index b96d6ee57b2..c619a893c6d 100644 --- a/src/ripple/app/paths/impl/PaySteps.cpp +++ b/src/ripple/app/paths/impl/PaySteps.cpp @@ -100,11 +100,11 @@ toStep( // should already be taken care of JLOG(j.error()) << "Found offer/account payment step. Aborting payment strand."; - assert(0); + XRPL_ASSERT(0); return {temBAD_PATH, std::unique_ptr{}}; } - assert( + XRPL_ASSERT( (e2->getNodeType() & STPathElement::typeCurrency) || (e2->getNodeType() & STPathElement::typeIssuer)); auto const outCurrency = e2->getNodeType() & STPathElement::typeCurrency @@ -120,7 +120,7 @@ toStep( return {temBAD_PATH, std::unique_ptr{}}; } - assert(e2->isOffer()); + XRPL_ASSERT(e2->isOffer()); if (isXRP(outCurrency)) return make_BookStepIX(ctx, curIssue); @@ -391,7 +391,7 @@ toStrand( next->getCurrency() != curIssue.currency) { // Should never happen - assert(0); + XRPL_ASSERT(0); return {temBAD_PATH, Strand{}}; } @@ -457,7 +457,7 @@ toStrand( if (!checkStrand()) { JLOG(j.warn()) << "Flow check strand failed"; - assert(0); + XRPL_ASSERT(0); return {temBAD_PATH, Strand{}}; } diff --git a/src/ripple/app/paths/impl/StepChecks.h b/src/ripple/app/paths/impl/StepChecks.h index 9d8664a8dc1..d15fe534852 100644 --- a/src/ripple/app/paths/impl/StepChecks.h +++ b/src/ripple/app/paths/impl/StepChecks.h @@ -35,7 +35,7 @@ checkFreeze( AccountID const& dst, Currency const& currency) { - assert(src != dst); + XRPL_ASSERT(src != dst); // check freeze if (auto sle = view.read(keylet::account(dst))) diff --git a/src/ripple/app/paths/impl/StrandFlow.h b/src/ripple/app/paths/impl/StrandFlow.h index 2df496d8311..800da7f0957 100644 --- a/src/ripple/app/paths/impl/StrandFlow.h +++ b/src/ripple/app/paths/impl/StrandFlow.h @@ -171,7 +171,7 @@ flow( << "Re-executed limiting step failed. r.first: " << to_string(get(r.first)) << " maxIn: " << to_string(*maxIn); - assert(0); + XRPL_ASSERT(0); return Result{strand, std::move(ofrsToRm)}; } } @@ -207,7 +207,7 @@ flow( #else JLOG(j.fatal()) << "Re-executed limiting step failed"; #endif - assert(0); + XRPL_ASSERT(0); return Result{strand, std::move(ofrsToRm)}; } } @@ -241,7 +241,7 @@ flow( #else JLOG(j.fatal()) << "Re-executed forward pass failed"; #endif - assert(0); + XRPL_ASSERT(0); return Result{strand, std::move(ofrsToRm)}; } stepIn = r.second; @@ -493,7 +493,7 @@ class ActiveStrands { if (i >= cur_.size()) { - assert(0); + XRPL_ASSERT(0); return nullptr; } return cur_[i]; @@ -700,7 +700,7 @@ flow( flowDebugInfo->pushLiquiditySrc( EitherAmount(f.in), EitherAmount(f.out)); - assert( + XRPL_ASSERT( f.out <= remainingOut && f.sandbox && (!remainingIn || f.in <= *remainingIn)); @@ -725,7 +725,7 @@ flow( if (baseView.rules().enabled(featureFlowSortStrands)) { - assert(!best); + XRPL_ASSERT(!best); if (!f.inactive) activeStrands.push(strand); best.emplace(f.in, f.out, std::move(*f.sandbox), *strand, q); @@ -839,7 +839,7 @@ flow( // running debug builds of rippled. While this issue still needs to // be resolved, the assert is causing more harm than good at this // point. - // assert(0); + // XRPL_ASSERT(0); return {tefEXCEPTION, std::move(ofrsToRmOnFail)}; } @@ -876,7 +876,7 @@ flow( // Handles both cases 1. and 2. // fixFillOrKill amendment: // Handles 2. 1. is handled above and falls through for tfSell. - assert(remainingIn); + XRPL_ASSERT(remainingIn); if (remainingIn && *remainingIn != beast::zero) return { tecPATH_PARTIAL, diff --git a/src/ripple/app/paths/impl/XRPEndpointStep.cpp b/src/ripple/app/paths/impl/XRPEndpointStep.cpp index 4878463801c..480f305151b 100644 --- a/src/ripple/app/paths/impl/XRPEndpointStep.cpp +++ b/src/ripple/app/paths/impl/XRPEndpointStep.cpp @@ -282,7 +282,7 @@ XRPEndpointStep::fwdImp( boost::container::flat_set& ofrsToRm, XRPAmount const& in) { - assert(cache_); + XRPL_ASSERT(cache_); auto const balance = static_cast(this)->xrpLiquid(sb); auto const result = isLast_ ? in : std::min(balance, in); @@ -310,7 +310,7 @@ XRPEndpointStep::validFwd( return {false, EitherAmount(XRPAmount(beast::zero))}; } - assert(in.native); + XRPL_ASSERT(in.native); auto const& xrpIn = in.xrp; auto const balance = static_cast(this)->xrpLiquid(sb); diff --git a/src/ripple/app/rdb/RelationalDatabase.h b/src/ripple/app/rdb/RelationalDatabase.h index a269bf256c8..5aaa5f5a222 100644 --- a/src/ripple/app/rdb/RelationalDatabase.h +++ b/src/ripple/app/rdb/RelationalDatabase.h @@ -258,7 +258,7 @@ rangeCheckedCast(C c) c < std::numeric_limits::lowest())) { /* This should never happen */ - assert(0); + XRPL_ASSERT(0); JLOG(debugLog().error()) << "rangeCheckedCast domain error:" << " value = " << c << " min = " << std::numeric_limits::lowest() diff --git a/src/ripple/app/rdb/backend/detail/impl/Node.cpp b/src/ripple/app/rdb/backend/detail/impl/Node.cpp index 0905d6121ae..b74c10a999a 100644 --- a/src/ripple/app/rdb/backend/detail/impl/Node.cpp +++ b/src/ripple/app/rdb/backend/detail/impl/Node.cpp @@ -58,7 +58,7 @@ to_string(TableType type) case TableType::AccountTransactions: return "AccountTransactions"; default: - assert(false); + XRPL_UNREACHABLE(); return "Unknown"; } } @@ -201,7 +201,7 @@ saveValidatedLedger( if (!ledger->info().accountHash.isNonZero()) { JLOG(j.fatal()) << "AH is zero: " << getJson({*ledger, {}}); - assert(false); + XRPL_UNREACHABLE(); } if (ledger->info().accountHash != ledger->stateMap().getHash().as_uint256()) @@ -210,10 +210,11 @@ saveValidatedLedger( << " != " << ledger->stateMap().getHash(); JLOG(j.fatal()) << "saveAcceptedLedger: seq=" << seq << ", current=" << current; - assert(false); + XRPL_UNREACHABLE(); } - assert(ledger->info().txHash == ledger->txMap().getHash().as_uint256()); + XRPL_ASSERT( + ledger->info().txHash == ledger->txMap().getHash().as_uint256()); // Save the ledger header in the hashed object store { diff --git a/src/ripple/app/rdb/backend/impl/PostgresDatabase.cpp b/src/ripple/app/rdb/backend/impl/PostgresDatabase.cpp index c57dee30610..9b13e002394 100644 --- a/src/ripple/app/rdb/backend/impl/PostgresDatabase.cpp +++ b/src/ripple/app/rdb/backend/impl/PostgresDatabase.cpp @@ -61,7 +61,7 @@ class PostgresDatabaseImp final : public PostgresDatabase #endif ) { - assert(config.reporting()); + XRPL_ASSERT(config.reporting()); #ifdef RIPPLED_REPORTING if (config.reporting() && !config.reportingReadOnly()) // use pg { @@ -169,7 +169,7 @@ loadLedgerInfos( std::vector infos; #ifdef RIPPLED_REPORTING auto log = app.journal("Ledger"); - assert(app.config().reporting()); + XRPL_ASSERT(app.config().reporting()); std::stringstream sql; sql << "SELECT ledger_hash, prev_hash, account_set_hash, trans_set_hash, " "total_coins, closing_time, prev_closing_time, close_time_res, " @@ -204,7 +204,7 @@ loadLedgerInfos( { JLOG(log.error()) << __func__ << " : Postgres response is null - sql = " << sql.str(); - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -214,7 +214,7 @@ loadLedgerInfos( "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - sql = " << sql.str(); - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -234,7 +234,7 @@ loadLedgerInfos( << " : Wrong number of fields in Postgres " "response. Expected 10, but got " << res.nfields() << " . sql = " << sql.str(); - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -267,11 +267,11 @@ loadLedgerInfos( LedgerInfo info; if (!info.parentHash.parseHex(prevHash + 2)) - assert(false); + XRPL_UNREACHABLE(); if (!info.txHash.parseHex(txHash + 2)) - assert(false); + XRPL_UNREACHABLE(); if (!info.accountHash.parseHex(accountHash + 2)) - assert(false); + XRPL_UNREACHABLE(); info.drops = totalCoins; info.closeTime = time_point{duration{closeTime}}; info.parentCloseTime = time_point{duration{parentCloseTime}}; @@ -279,7 +279,7 @@ loadLedgerInfos( info.closeTimeResolution = duration{closeTimeRes}; info.seq = ledgerSeq; if (!info.hash.parseHex(hash + 2)) - assert(false); + XRPL_UNREACHABLE(); info.validated = true; infos.push_back(info); } @@ -308,7 +308,7 @@ loadLedgerHelper( infos = loadLedgerInfos(pgPool, arg, app); }, whichLedger); - assert(infos.size() <= 1); + XRPL_ASSERT(infos.size() <= 1); if (!infos.size()) return {}; return infos[0]; @@ -410,7 +410,7 @@ processAccountTxStoredProcedureResult( nodestoreHashHex.erase(0, 2); uint256 nodestoreHash; if (!nodestoreHash.parseHex(nodestoreHashHex)) - assert(false); + XRPL_UNREACHABLE(); if (nodestoreHash.isNonZero()) { @@ -419,18 +419,18 @@ processAccountTxStoredProcedureResult( } else { - assert(false); + XRPL_UNREACHABLE(); return {ret, {rpcINTERNAL, "nodestoreHash is zero"}}; } } else { - assert(false); + XRPL_UNREACHABLE(); return {ret, {rpcINTERNAL, "missing postgres fields"}}; } } - assert(nodestoreHashes.size() == ledgerSequences.size()); + XRPL_ASSERT(nodestoreHashes.size() == ledgerSequences.size()); ret.transactions = flatFetchTransactions( app, nodestoreHashes, @@ -442,13 +442,13 @@ processAccountTxStoredProcedureResult( if (result.isMember("marker")) { auto& marker = result["marker"]; - assert(marker.isMember("ledger")); - assert(marker.isMember("seq")); + XRPL_ASSERT(marker.isMember("ledger")); + XRPL_ASSERT(marker.isMember("seq")); ret.marker = { marker["ledger"].asUInt(), marker["seq"].asUInt()}; } - assert(result.isMember("ledger_index_min")); - assert(result.isMember("ledger_index_max")); + XRPL_ASSERT(result.isMember("ledger_index_min")); + XRPL_ASSERT(result.isMember("ledger_index_max")); ret.ledgerRange = { result["ledger_index_min"].asUInt(), result["ledger_index_max"].asUInt()}; @@ -599,7 +599,7 @@ PostgresDatabaseImp::writeLedgerAndTransactions( { std::stringstream msg; msg << "bulkWriteToTable : Postgres insert error: " << res.msg(); - assert(false); + XRPL_UNREACHABLE(); Throw(msg.str()); } @@ -612,7 +612,7 @@ PostgresDatabaseImp::writeLedgerAndTransactions( JLOG(j_.error()) << __func__ << "Caught exception writing to Postgres : " << e.what(); - assert(false); + XRPL_UNREACHABLE(); return false; } #else @@ -642,7 +642,7 @@ uint256 PostgresDatabaseImp::getHashByIndex(LedgerIndex ledgerIndex) { auto infos = loadLedgerInfos(pgPool_, ledgerIndex, app_); - assert(infos.size() <= 1); + XRPL_ASSERT(infos.size() <= 1); if (infos.size()) return infos[0].hash; return {}; @@ -653,7 +653,7 @@ PostgresDatabaseImp::getHashesByIndex(LedgerIndex ledgerIndex) { LedgerHashPair p; auto infos = loadLedgerInfos(pgPool_, ledgerIndex, app_); - assert(infos.size() <= 1); + XRPL_ASSERT(infos.size() <= 1); if (infos.size()) { p.ledgerHash = infos[0].hash; @@ -694,7 +694,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) { JLOG(log.error()) << __func__ << " : Postgres response is null - query = " << query; - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -704,7 +704,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - query = " << query; - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -724,7 +724,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) << " : Wrong number of fields in Postgres " "response. Expected 1, but got " << res.nfields() << " . query = " << query; - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -736,7 +736,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) char const* nodestoreHash = res.c_str(i, 0); uint256 hash; if (!hash.parseHex(nodestoreHash + 2)) - assert(false); + XRPL_UNREACHABLE(); nodestoreHashes.push_back(hash); } @@ -753,7 +753,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) #ifdef RIPPLED_REPORTING if (!app_.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "called getTxHistory but not in reporting mode"); } @@ -771,7 +771,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) { JLOG(j_.error()) << __func__ << " : Postgres response is null - sql = " << sql; - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -781,7 +781,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - sql = " << sql; - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -790,7 +790,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) if (res.isNull() || res.ntuples() == 0) { JLOG(j_.debug()) << __func__ << " : Empty postgres response"; - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.ntuples() > 0) @@ -801,7 +801,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) << " : Wrong number of fields in Postgres " "response. Expected 1, but got " << res.nfields() << " . sql = " << sql; - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -814,7 +814,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) { uint256 hash; if (!hash.parseHex(res.c_str(i, 0) + 2)) - assert(false); + XRPL_UNREACHABLE(); nodestoreHashes.push_back(hash); ledgerSequences.push_back(res.asBigInt(i, 1)); } @@ -823,7 +823,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) for (size_t i = 0; i < txns.size(); ++i) { auto const& [sttx, meta] = txns[i]; - assert(sttx); + XRPL_ASSERT(sttx); std::string reason; auto txn = std::make_shared(sttx, reason, app_); @@ -904,7 +904,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) JLOG(j_.error()) << __func__ << " : Postgres response is null - account = " << strHex(args.account); - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Postgres error"}}; } else if (res.status() != PGRES_TUPLES_OK) @@ -914,7 +914,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - account = " << strHex(args.account); - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Postgres error"}}; } @@ -925,7 +925,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) << " : No data returned from Postgres : account = " << strHex(args.account); - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Postgres error"}}; } @@ -943,7 +943,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) } #endif // This shouldn't happen. Postgres should return a parseable error - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Failed to deserialize Postgres result"}}; } @@ -963,7 +963,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) JLOG(app_.journal("Transaction").error()) << __func__ << " : Postgres response is null - tx ID = " << strHex(id); - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -974,7 +974,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - tx ID = " << strHex(id); - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -986,7 +986,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) << __func__ << " : No data returned from Postgres : tx ID = " << strHex(id); // This shouldn't happen - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -1004,7 +1004,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) uint256 nodestoreHash; if (!nodestoreHash.parseHex( v["nodestore_hash"].asString().substr(2))) - assert(false); + XRPL_UNREACHABLE(); uint32_t ledgerSeq = v["ledger_seq"].asUInt(); if (nodestoreHash.isNonZero()) return {std::make_pair(nodestoreHash, ledgerSeq)}; @@ -1018,7 +1018,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) #endif // Shouldn' happen. Postgres should return the ledger range searched if // the transaction was not found - assert(false); + XRPL_UNREACHABLE(); Throw( "Transaction::Locate - Invalid Postgres response"); return {}; diff --git a/src/ripple/app/rdb/impl/Vacuum.cpp b/src/ripple/app/rdb/impl/Vacuum.cpp index aad456cc5a8..f8212b117c5 100644 --- a/src/ripple/app/rdb/impl/Vacuum.cpp +++ b/src/ripple/app/rdb/impl/Vacuum.cpp @@ -28,7 +28,7 @@ doVacuumDB(DatabaseCon::Setup const& setup) boost::filesystem::path dbPath = setup.dataDir / TxDBName; uintmax_t const dbSize = file_size(dbPath); - assert(dbSize != static_cast(-1)); + XRPL_ASSERT(dbSize != static_cast(-1)); if (auto available = space(dbPath.parent_path()).available; available < dbSize) @@ -54,7 +54,7 @@ doVacuumDB(DatabaseCon::Setup const& setup) std::cout << "VACUUM beginning. page_size: " << pageSize << std::endl; session << "VACUUM;"; - assert(setup.globalPragma); + XRPL_ASSERT(setup.globalPragma); for (auto const& p : *setup.globalPragma) session << p; session << "PRAGMA page_size;", soci::into(pageSize); diff --git a/src/ripple/app/reporting/ETLHelpers.h b/src/ripple/app/reporting/ETLHelpers.h index 04f282ca53e..8e09eacc2dc 100644 --- a/src/ripple/app/reporting/ETLHelpers.h +++ b/src/ripple/app/reporting/ETLHelpers.h @@ -176,7 +176,7 @@ class ThreadSafeQueue inline std::vector getMarkers(size_t numMarkers) { - assert(numMarkers <= 256); + XRPL_ASSERT(numMarkers <= 256); unsigned char incr = 256 / numMarkers; diff --git a/src/ripple/app/reporting/ETLSource.cpp b/src/ripple/app/reporting/ETLSource.cpp index 73ba9816950..1b9a4e5d0eb 100644 --- a/src/ripple/app/reporting/ETLSource.cpp +++ b/src/ripple/app/reporting/ETLSource.cpp @@ -452,7 +452,7 @@ class AsyncCallData << " . prefix = " << strHex(std::string(1, prefix)) << " . nextPrefix_ = " << strHex(std::string(1, nextPrefix_)); - assert(nextPrefix_ > prefix || nextPrefix_ == 0x00); + XRPL_ASSERT(nextPrefix_ > prefix || nextPrefix_ == 0x00); cur_ = std::make_unique(); @@ -487,7 +487,7 @@ class AsyncCallData JLOG(journal_.warn()) << "AsyncCallData is_unlimited is false. Make sure " "secure_gateway is set correctly at the ETL source"; - assert(false); + XRPL_UNREACHABLE(); } std::swap(cur_, next_); @@ -589,7 +589,7 @@ ETLSource::loadInitialLedger( while (numFinished < calls.size() && !etl_.isStopping() && cq.Next(&tag, &ok)) { - assert(tag); + XRPL_ASSERT(tag); auto ptr = static_cast(tag); @@ -642,7 +642,7 @@ ETLSource::fetchLedger(uint32_t ledgerSequence, bool getObjects) "false. Make sure secure_gateway is set " "correctly on the ETL source. source = " << toString(); - assert(false); + XRPL_UNREACHABLE(); } return {status, std::move(response)}; } diff --git a/src/ripple/app/reporting/ETLSource.h b/src/ripple/app/reporting/ETLSource.h index b9f27a1bf1f..36711905969 100644 --- a/src/ripple/app/reporting/ETLSource.h +++ b/src/ripple/app/reporting/ETLSource.h @@ -173,7 +173,7 @@ class ETLSource } else { - assert(minAndMax.size() == 2); + XRPL_ASSERT(minAndMax.size() == 2); uint32_t min = std::stoll(minAndMax[0]); uint32_t max = std::stoll(minAndMax[1]); pairs.push_back(std::make_pair(min, max)); @@ -206,7 +206,7 @@ class ETLSource JLOG(journal_.debug()) << __func__ << " : " << "Closing websocket"; - assert(ws_); + XRPL_ASSERT(ws_); close(false); } @@ -378,7 +378,7 @@ class ETLLoadBalancer { for (auto& src : sources_) { - assert(src); + XRPL_ASSERT(src); // We pick the first ETLSource encountered that is connected if (src->isConnected()) { diff --git a/src/ripple/app/reporting/ReportingETL.cpp b/src/ripple/app/reporting/ReportingETL.cpp index d8d6af36881..9d52d9611d6 100644 --- a/src/ripple/app/reporting/ReportingETL.cpp +++ b/src/ripple/app/reporting/ReportingETL.cpp @@ -59,7 +59,7 @@ ReportingETL::consumeLedgerData( size_t num = 0; while (!stopping_ && (sle = writeQueue.pop())) { - assert(sle); + XRPL_ASSERT(sle); if (!ledger->exists(sle->key())) ledger->rawInsert(sle); @@ -113,7 +113,7 @@ ReportingETL::loadInitialLedger(uint32_t startingSequence) { JLOG(journal_.fatal()) << __func__ << " : " << "Database is not empty"; - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -189,7 +189,7 @@ ReportingETL::flushLedger(std::shared_ptr& ledger) auto& txHash = ledger->info().txHash; auto& ledgerHash = ledger->info().hash; - assert( + XRPL_ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees())); ledger->setImmutable(false); @@ -230,7 +230,7 @@ ReportingETL::flushLedger(std::shared_ptr& ledger) { JLOG(journal_.fatal()) << __func__ << " : " << "Flushed 0 nodes from state map"; - assert(false); + XRPL_UNREACHABLE(); } if (numTxFlushed == 0) { @@ -495,7 +495,7 @@ ReportingETL::runETLPipeline(uint32_t startSequence) app_.getLedgerMaster().getLedgerBySeq(startSequence - 1)); if (!parent) { - assert(false); + XRPL_UNREACHABLE(); Throw("runETLPipeline: parent ledger is null"); } @@ -564,7 +564,7 @@ ReportingETL::runETLPipeline(uint32_t startSequence) &transformQueue]() { beast::setCurrentThreadName("rippled: ReportingETL transform"); - assert(parent); + XRPL_ASSERT(parent); parent = std::make_shared(*parent, NetClock::time_point{}); while (!writeConflict) { diff --git a/src/ripple/app/reporting/ReportingETL.h b/src/ripple/app/reporting/ReportingETL.h index 71e08adf1f3..dcf53b0a11d 100644 --- a/src/ripple/app/reporting/ReportingETL.h +++ b/src/ripple/app/reporting/ReportingETL.h @@ -326,9 +326,9 @@ class ReportingETL start() { JLOG(journal_.info()) << "Starting reporting etl"; - assert(app_.config().reporting()); - assert(app_.config().standalone()); - assert(app_.config().reportingReadOnly() == readOnly_); + XRPL_ASSERT(app_.config().reporting()); + XRPL_ASSERT(app_.config().standalone()); + XRPL_ASSERT(app_.config().reportingReadOnly() == readOnly_); stopping_ = false; diff --git a/src/ripple/app/tx/impl/AMMBid.cpp b/src/ripple/app/tx/impl/AMMBid.cpp index e49c378ceeb..6b4f455e374 100644 --- a/src/ripple/app/tx/impl/AMMBid.cpp +++ b/src/ripple/app/tx/impl/AMMBid.cpp @@ -181,7 +181,7 @@ applyBid( } else { - assert(ammSle->isFieldPresent(sfAuctionSlot)); + XRPL_ASSERT(ammSle->isFieldPresent(sfAuctionSlot)); if (!ammSle->isFieldPresent(sfAuctionSlot)) return {tecINTERNAL, false}; } @@ -304,7 +304,7 @@ applyBid( { // Price the slot was purchased at. STAmount const pricePurchased = auctionSlot[sfPrice]; - assert(timeSlot); + XRPL_ASSERT(timeSlot); auto const fractionUsed = (Number(*timeSlot) + 1) / AUCTION_SLOT_TIME_INTERVALS; auto const fractionRemaining = Number(1) - fractionUsed; diff --git a/src/ripple/app/tx/impl/AMMDeposit.cpp b/src/ripple/app/tx/impl/AMMDeposit.cpp index 74cba160edc..72636259415 100644 --- a/src/ripple/app/tx/impl/AMMDeposit.cpp +++ b/src/ripple/app/tx/impl/AMMDeposit.cpp @@ -435,7 +435,7 @@ AMMDeposit::applyGuts(Sandbox& sb) if (result == tesSUCCESS) { - assert(newLPTokenBalance > beast::zero); + XRPL_ASSERT(newLPTokenBalance > beast::zero); ammSle->setFieldAmount(sfLPTokenBalance, newLPTokenBalance); // LP depositing into AMM empty state gets the auction slot // and the voting diff --git a/src/ripple/app/tx/impl/AMMVote.cpp b/src/ripple/app/tx/impl/AMMVote.cpp index d908a93c383..a6a027c3f1e 100644 --- a/src/ripple/app/tx/impl/AMMVote.cpp +++ b/src/ripple/app/tx/impl/AMMVote.cpp @@ -200,7 +200,7 @@ applyVote( } } - assert( + XRPL_ASSERT( !ctx_.view().rules().enabled(fixInnerObjTemplate) || ammSle->isFieldPresent(sfAuctionSlot)); diff --git a/src/ripple/app/tx/impl/AMMWithdraw.cpp b/src/ripple/app/tx/impl/AMMWithdraw.cpp index c8d0d67dc97..a29f11932e7 100644 --- a/src/ripple/app/tx/impl/AMMWithdraw.cpp +++ b/src/ripple/app/tx/impl/AMMWithdraw.cpp @@ -711,7 +711,7 @@ AMMWithdraw::equalWithdrawLimit( tfee); frac = Number{amount2} / amount2Balance; auto const amountWithdraw = amountBalance * frac; - assert(amountWithdraw <= amount); + XRPL_ASSERT(amountWithdraw <= amount); return withdraw( view, ammAccount, diff --git a/src/ripple/app/tx/impl/ApplyContext.cpp b/src/ripple/app/tx/impl/ApplyContext.cpp index 27287241637..b29daafbb57 100644 --- a/src/ripple/app/tx/impl/ApplyContext.cpp +++ b/src/ripple/app/tx/impl/ApplyContext.cpp @@ -21,10 +21,10 @@ #include #include #include +#include #include #include #include -#include namespace ripple { @@ -146,7 +146,7 @@ ApplyContext::checkInvariantsHelper( TER ApplyContext::checkInvariants(TER const result, XRPAmount const fee) { - assert(isTesSuccess(result) || isTecClaim(result)); + XRPL_ASSERT(isTesSuccess(result) || isTecClaim(result)); return checkInvariantsHelper( result, diff --git a/src/ripple/app/tx/impl/Change.cpp b/src/ripple/app/tx/impl/Change.cpp index b36ae88a75e..ceb4e27cef7 100644 --- a/src/ripple/app/tx/impl/Change.cpp +++ b/src/ripple/app/tx/impl/Change.cpp @@ -149,7 +149,7 @@ Change::doApply() case ttUNL_MODIFY: return applyUNLModify(); default: - assert(0); + XRPL_ASSERT(0); return tefFAILURE; } } @@ -157,7 +157,7 @@ Change::doApply() void Change::preCompute() { - assert(account_ == beast::zero); + XRPL_ASSERT(account_ == beast::zero); } void diff --git a/src/ripple/app/tx/impl/CreateOffer.cpp b/src/ripple/app/tx/impl/CreateOffer.cpp index 17f7e2853db..b298eabb6ee 100644 --- a/src/ripple/app/tx/impl/CreateOffer.cpp +++ b/src/ripple/app/tx/impl/CreateOffer.cpp @@ -210,7 +210,7 @@ CreateOffer::checkAcceptAsset( Issue const& issue) { // Only valid for custom currencies - assert(!isXRP(issue.currency)); + XRPL_ASSERT(!isXRP(issue.currency)); auto const issuerAccount = view.read(keylet::account(issue.account)); @@ -283,7 +283,7 @@ CreateOffer::select_path( OfferStream const& leg2) { // If we don't have any viable path, why are we here?! - assert(have_direct || have_bridge); + XRPL_ASSERT(have_direct || have_bridge); // If there's no bridged path, the direct is the best by default. if (!have_bridge) @@ -327,7 +327,7 @@ CreateOffer::bridged_cross( { auto const& takerAmount = taker.original_offer(); - assert(!isXRP(takerAmount.in) && !isXRP(takerAmount.out)); + XRPL_ASSERT(!isXRP(takerAmount.in) && !isXRP(takerAmount.out)); if (isXRP(takerAmount.in) || isXRP(takerAmount.out)) Throw("Bridging with XRP and an endpoint."); @@ -497,7 +497,7 @@ CreateOffer::bridged_cross( // Postcondition: If we aren't done, then we *must* have consumed at // least one offer fully. - assert(direct_consumed || leg1_consumed || leg2_consumed); + XRPL_ASSERT(direct_consumed || leg1_consumed || leg2_consumed); if (!direct_consumed && !leg1_consumed && !leg2_consumed) Throw( @@ -587,7 +587,7 @@ CreateOffer::direct_cross( // Postcondition: If we aren't done, then we *must* have consumed the // offer on the books fully! - assert(direct_consumed); + XRPL_ASSERT(direct_consumed); if (!direct_consumed) Throw( @@ -849,7 +849,7 @@ CreateOffer::flowCross( // remaining output. This too preserves the offer // Quality. afterCross.out -= result.actualAmountOut; - assert(afterCross.out >= beast::zero); + XRPL_ASSERT(afterCross.out >= beast::zero); if (afterCross.out < beast::zero) afterCross.out.clear(); afterCross.in = mulRound( @@ -1046,7 +1046,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) // We expect the implementation of cross to succeed // or give a tec. - assert(result == tesSUCCESS || isTecClaim(result)); + XRPL_ASSERT(result == tesSUCCESS || isTecClaim(result)); if (auto stream = j_.trace()) { @@ -1064,8 +1064,8 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) return {result, true}; } - assert(saTakerGets.issue() == place_offer.in.issue()); - assert(saTakerPays.issue() == place_offer.out.issue()); + XRPL_ASSERT(saTakerGets.issue() == place_offer.in.issue()); + XRPL_ASSERT(saTakerPays.issue() == place_offer.out.issue()); if (takerAmount != place_offer) crossed = true; @@ -1093,7 +1093,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) saTakerGets = place_offer.in; } - assert(saTakerPays > zero && saTakerGets > zero); + XRPL_ASSERT(saTakerPays > zero && saTakerGets > zero); if (result != tesSUCCESS) { diff --git a/src/ripple/app/tx/impl/DeleteAccount.cpp b/src/ripple/app/tx/impl/DeleteAccount.cpp index efa38a4b74e..68b0889b043 100644 --- a/src/ripple/app/tx/impl/DeleteAccount.cpp +++ b/src/ripple/app/tx/impl/DeleteAccount.cpp @@ -211,7 +211,7 @@ DeleteAccount::preclaim(PreclaimContext const& ctx) } auto sleAccount = ctx.view.read(keylet::account(account)); - assert(sleAccount); + XRPL_ASSERT(sleAccount); if (!sleAccount) return terNO_ACCOUNT; @@ -314,10 +314,10 @@ TER DeleteAccount::doApply() { auto src = view().peek(keylet::account(account_)); - assert(src); + XRPL_ASSERT(src); auto dst = view().peek(keylet::account(ctx_.tx[sfDestination])); - assert(dst); + XRPL_ASSERT(dst); if (!src || !dst) return tefBAD_LEDGER; @@ -337,7 +337,7 @@ DeleteAccount::doApply() return {result, SkipEntry::No}; } - assert(!"Undeletable entry should be found in preclaim."); + XRPL_ASSERT(!"Undeletable entry should be found in preclaim."); JLOG(j_.error()) << "DeleteAccount undeletable item not " "found in preclaim."; return {tecHAS_OBLIGATIONS, SkipEntry::No}; @@ -351,7 +351,7 @@ DeleteAccount::doApply() (*src)[sfBalance] = (*src)[sfBalance] - mSourceBalance; ctx_.deliver(mSourceBalance); - assert((*src)[sfBalance] == XRPAmount(0)); + XRPL_ASSERT((*src)[sfBalance] == XRPAmount(0)); // If there's still an owner directory associated with the source account // delete it. diff --git a/src/ripple/app/tx/impl/NFTokenCreateOffer.cpp b/src/ripple/app/tx/impl/NFTokenCreateOffer.cpp index 22eca2dffdd..235f2415f18 100644 --- a/src/ripple/app/tx/impl/NFTokenCreateOffer.cpp +++ b/src/ripple/app/tx/impl/NFTokenCreateOffer.cpp @@ -134,7 +134,7 @@ NFTokenCreateOffer::preclaim(PreclaimContext const& ctx) if (issuer != ctx.tx[sfAccount] && !(nftFlags & nft::flagTransferable)) { auto const root = ctx.view.read(keylet::account(issuer)); - assert(root); + XRPL_ASSERT(root); if (auto minter = (*root)[~sfNFTokenMinter]; minter != ctx.tx[sfAccount]) diff --git a/src/ripple/app/tx/impl/NFTokenMint.cpp b/src/ripple/app/tx/impl/NFTokenMint.cpp index c26fb1fb12a..b33442e4d23 100644 --- a/src/ripple/app/tx/impl/NFTokenMint.cpp +++ b/src/ripple/app/tx/impl/NFTokenMint.cpp @@ -124,7 +124,7 @@ NFTokenMint::createNFTokenID( std::memcpy(ptr, &tokenSeq, sizeof(tokenSeq)); ptr += sizeof(tokenSeq); - assert(std::distance(buf.data(), ptr) == buf.size()); + XRPL_ASSERT(std::distance(buf.data(), ptr) == buf.size()); return uint256::fromVoid(buf.data()); } diff --git a/src/ripple/app/tx/impl/Offer.h b/src/ripple/app/tx/impl/Offer.h index 53253426c40..4ceeab8fa20 100644 --- a/src/ripple/app/tx/impl/Offer.h +++ b/src/ripple/app/tx/impl/Offer.h @@ -209,7 +209,7 @@ void TOffer::setFieldAmounts() { #ifdef _MSC_VER - assert(0); + XRPL_ASSERT(0); #else static_assert(sizeof(TOut) == -1, "Must be specialized"); #endif diff --git a/src/ripple/app/tx/impl/OfferStream.cpp b/src/ripple/app/tx/impl/OfferStream.cpp index 5933d9c3838..450b7d97c23 100644 --- a/src/ripple/app/tx/impl/OfferStream.cpp +++ b/src/ripple/app/tx/impl/OfferStream.cpp @@ -51,7 +51,7 @@ TOfferStreamBase::TOfferStreamBase( , tip_(view, book_) , counter_(counter) { - assert(validBook_); + XRPL_ASSERT(validBook_); } // Handle the case where a directory item with no corresponding ledger entry @@ -339,7 +339,7 @@ TOfferStreamBase::step() std::is_same_v)) return shouldRmSmallIncreasedQOffer(); } - assert(0); // xrp/xrp offer!?! should never happen + XRPL_ASSERT(0); // xrp/xrp offer!?! should never happen return false; }(); diff --git a/src/ripple/app/tx/impl/PayChan.cpp b/src/ripple/app/tx/impl/PayChan.cpp index 3fe2a28a7cf..41c199655d4 100644 --- a/src/ripple/app/tx/impl/PayChan.cpp +++ b/src/ripple/app/tx/impl/PayChan.cpp @@ -149,7 +149,7 @@ closeChannel( if (!sle) return tefINTERNAL; - assert((*slep)[sfAmount] >= (*slep)[sfBalance]); + XRPL_ASSERT((*slep)[sfAmount] >= (*slep)[sfBalance]); (*sle)[sfBalance] = (*sle)[sfBalance] + (*slep)[sfAmount] - (*slep)[sfBalance]; adjustOwnerCount(view, sle, -1, j); @@ -532,7 +532,7 @@ PayChanClaim::doApply() (*slep)[sfBalance] = ctx_.tx[sfBalance]; XRPAmount const reqDelta = reqBalance - chanBalance; - assert(reqDelta >= beast::zero); + XRPL_ASSERT(reqDelta >= beast::zero); (*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta; ctx_.view().update(sled); ctx_.view().update(slep); diff --git a/src/ripple/app/tx/impl/Payment.cpp b/src/ripple/app/tx/impl/Payment.cpp index 3903aa75045..54384ef48e1 100644 --- a/src/ripple/app/tx/impl/Payment.cpp +++ b/src/ripple/app/tx/impl/Payment.cpp @@ -421,7 +421,7 @@ Payment::doApply() return terResult; } - assert(saDstAmount.native()); + XRPL_ASSERT(saDstAmount.native()); // Direct XRP payment. diff --git a/src/ripple/app/tx/impl/SetSignerList.cpp b/src/ripple/app/tx/impl/SetSignerList.cpp index 07cc705bad1..0401b4230cd 100644 --- a/src/ripple/app/tx/impl/SetSignerList.cpp +++ b/src/ripple/app/tx/impl/SetSignerList.cpp @@ -128,7 +128,7 @@ SetSignerList::doApply() default: break; } - assert(false); // Should not be possible to get here. + XRPL_UNREACHABLE(); // Should not be possible to get here. return temMALFORMED; } @@ -137,8 +137,8 @@ SetSignerList::preCompute() { // Get the quorum and operation info. auto result = determineOperation(ctx_.tx, view().flags(), j_); - assert(std::get<0>(result) == tesSUCCESS); - assert(std::get<3>(result) != unknown); + XRPL_ASSERT(std::get<0>(result) == tesSUCCESS); + XRPL_ASSERT(std::get<3>(result) != unknown); quorum_ = std::get<1>(result); signers_ = std::get<2>(result); @@ -171,8 +171,8 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules) // The static_cast should always be safe since entryCount should always // be in the range from 1 to 8 (or 32 if ExpandedSignerList is enabled). // We've got a lot of room to grow. - assert(entryCount >= STTx::minMultiSigners); - assert(entryCount <= STTx::maxMultiSigners(&rules)); + XRPL_ASSERT(entryCount >= STTx::minMultiSigners); + XRPL_ASSERT(entryCount <= STTx::maxMultiSigners(&rules)); return 2 + static_cast(entryCount); } @@ -260,7 +260,7 @@ SetSignerList::validateQuorumAndSignerEntries( } // Make sure there are no duplicate signers. - assert(std::is_sorted(signers.begin(), signers.end())); + XRPL_ASSERT(std::is_sorted(signers.begin(), signers.end())); if (std::adjacent_find(signers.begin(), signers.end()) != signers.end()) { JLOG(j.trace()) << "Duplicate signers in signer list"; diff --git a/src/ripple/app/tx/impl/Taker.cpp b/src/ripple/app/tx/impl/Taker.cpp index f463ce41198..c351497802d 100644 --- a/src/ripple/app/tx/impl/Taker.cpp +++ b/src/ripple/app/tx/impl/Taker.cpp @@ -54,24 +54,24 @@ BasicTaker::BasicTaker( , cross_type_(cross_type) , journal_(journal) { - assert(remaining_.in > beast::zero); - assert(remaining_.out > beast::zero); + XRPL_ASSERT(remaining_.in > beast::zero); + XRPL_ASSERT(remaining_.out > beast::zero); - assert(m_rate_in.value != 0); - assert(m_rate_out.value != 0); + XRPL_ASSERT(m_rate_in.value != 0); + XRPL_ASSERT(m_rate_out.value != 0); // If we are dealing with a particular flavor, make sure that it's the // flavor we expect: - assert( + XRPL_ASSERT( cross_type != CrossType::XrpToIou || (isXRP(issue_in()) && !isXRP(issue_out()))); - assert( + XRPL_ASSERT( cross_type != CrossType::IouToXrp || (!isXRP(issue_in()) && isXRP(issue_out()))); // And make sure we're not crossing XRP for XRP - assert(!isXRP(issue_in()) || !isXRP(issue_out())); + XRPL_ASSERT(!isXRP(issue_in()) || !isXRP(issue_out())); // If this is a passive order, we adjust the quality so as to prevent offers // at the same quality level from being consumed. @@ -150,7 +150,7 @@ BasicTaker::remaining_offer() const if (sell_) { - assert(remaining_.in > beast::zero); + XRPL_ASSERT(remaining_.in > beast::zero); // We scale the output based on the remaining input: return Amounts( @@ -158,7 +158,7 @@ BasicTaker::remaining_offer() const divRound(remaining_.in, quality_.rate(), issue_out_, true)); } - assert(remaining_.out > beast::zero); + XRPL_ASSERT(remaining_.out > beast::zero); // We scale the input based on the remaining output: return Amounts( @@ -424,7 +424,7 @@ BasicTaker::do_cross(Amounts offer, Quality quality, AccountID const& owner) remaining_.out -= result.order.out; remaining_.in -= result.order.in; - assert(remaining_.in >= beast::zero); + XRPL_ASSERT(remaining_.in >= beast::zero); return result; } @@ -439,10 +439,10 @@ BasicTaker::do_cross( Quality quality2, AccountID const& owner2) { - assert(!offer1.in.native()); - assert(offer1.out.native()); - assert(offer2.in.native()); - assert(!offer2.out.native()); + XRPL_ASSERT(!offer1.in.native()); + XRPL_ASSERT(offer1.out.native()); + XRPL_ASSERT(offer2.in.native()); + XRPL_ASSERT(!offer2.out.native()); // If the taker owns the first leg of the offer, then the taker's available // funds aren't the limiting factor for the input - the offer itself is. @@ -559,8 +559,8 @@ Taker::Taker( , direct_crossings_(0) , bridge_crossings_(0) { - assert(issue_in() == offer.in.issue()); - assert(issue_out() == offer.out.issue()); + XRPL_ASSERT(issue_in() == offer.in.issue()); + XRPL_ASSERT(issue_out() == offer.out.issue()); if (auto stream = journal_.debug()) { @@ -689,7 +689,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) if (cross_type() != CrossType::XrpToIou) { - assert(!isXRP(flow.order.in)); + XRPL_ASSERT(!isXRP(flow.order.in)); if (result == tesSUCCESS) result = @@ -701,7 +701,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - assert(isXRP(flow.order.in)); + XRPL_ASSERT(isXRP(flow.order.in)); if (result == tesSUCCESS) result = transferXRP(account(), offer.owner(), flow.order.in); @@ -710,7 +710,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) // Now send funds from the account whose offer we're taking if (cross_type() != CrossType::IouToXrp) { - assert(!isXRP(flow.order.out)); + XRPL_ASSERT(!isXRP(flow.order.out)); if (result == tesSUCCESS) result = redeemIOU( @@ -722,7 +722,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - assert(isXRP(flow.order.out)); + XRPL_ASSERT(isXRP(flow.order.out)); if (result == tesSUCCESS) result = transferXRP(offer.owner(), account(), flow.order.out); diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index c02b57a3ae4..4b8225838c9 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -367,7 +367,7 @@ Transactor::checkPriorTxAndLastLedger(PreclaimContext const& ctx) TER Transactor::consumeSeqProxy(SLE::pointer const& sleAccount) { - assert(sleAccount); + XRPL_ASSERT(sleAccount); SeqProxy const seqProx = ctx_.tx.getSeqProxy(); if (seqProx.isSeq()) { @@ -439,7 +439,7 @@ Transactor::ticketDelete( void Transactor::preCompute() { - assert(account_ != beast::zero); + XRPL_ASSERT(account_ != beast::zero); } TER @@ -453,7 +453,7 @@ Transactor::apply() // sle must exist except for transactions // that allow zero account. - assert(sle != nullptr || account_ == beast::zero); + XRPL_ASSERT(sle != nullptr || account_ == beast::zero); if (sle) { @@ -578,8 +578,8 @@ Transactor::checkMultiSign(PreclaimContext const& ctx) // We have plans to support multiple SignerLists in the future. The // presence and defaulted value of the SignerListID field will enable that. - assert(sleAccountSigners->isFieldPresent(sfSignerListID)); - assert(sleAccountSigners->getFieldU32(sfSignerListID) == 0); + XRPL_ASSERT(sleAccountSigners->isFieldPresent(sfSignerListID)); + XRPL_ASSERT(sleAccountSigners->getFieldU32(sfSignerListID) == 0); auto accountSigners = SignerEntries::deserialize(*sleAccountSigners, ctx.j, "ledger"); @@ -802,7 +802,7 @@ Transactor::reset(XRPAmount fee) auto const balance = txnAcct->getFieldAmount(sfBalance).xrp(); // balance should have already been checked in checkFee / preFlight. - assert(balance != beast::zero && (!view().open() || balance >= fee)); + XRPL_ASSERT(balance != beast::zero && (!view().open() || balance >= fee)); // We retry/reject the transaction if the account balance is zero or we're // applying against an open ledger and the balance is less than the fee @@ -817,7 +817,7 @@ Transactor::reset(XRPAmount fee) // reject the transaction. txnAcct->setFieldAmount(sfBalance, balance - fee); TER const ter{consumeSeqProxy(txnAcct)}; - assert(isTesSuccess(ter)); + XRPL_ASSERT(isTesSuccess(ter)); if (isTesSuccess(ter)) view().update(txnAcct); @@ -849,7 +849,7 @@ Transactor::operator()() JLOG(j_.fatal()) << "Transaction serdes mismatch"; JLOG(j_.info()) << to_string(ctx_.tx.getJson(JsonOptions::none)); JLOG(j_.fatal()) << s2.getJson(JsonOptions::none); - assert(false); + XRPL_UNREACHABLE(); } } #endif @@ -866,7 +866,7 @@ Transactor::operator()() // No transaction can return temUNKNOWN from apply, // and it can't be passed in from a preclaim. - assert(result != temUNKNOWN); + XRPL_ASSERT(result != temUNKNOWN); if (auto stream = j_.trace()) stream << "preclaim result: " << transToken(result); @@ -918,7 +918,7 @@ Transactor::operator()() std::shared_ptr const& after) { if (isDelete) { - assert(before && after); + XRPL_ASSERT(before && after); if (doOffers && before && after && (before->getType() == ltOFFER) && (before->getFieldAmount(sfTakerPays) == diff --git a/src/ripple/app/tx/impl/XChainBridge.cpp b/src/ripple/app/tx/impl/XChainBridge.cpp index be315236f2c..41ae86d9673 100644 --- a/src/ripple/app/tx/impl/XChainBridge.cpp +++ b/src/ripple/app/tx/impl/XChainBridge.cpp @@ -222,7 +222,7 @@ claimHelper( auto i = signersList.find(a.keyAccount); if (i == signersList.end()) { - assert(0); // should have already been checked + XRPL_ASSERT(0); // should have already been checked continue; } weight += i->second; @@ -437,7 +437,7 @@ transferHelper( if (amt.native()) { auto const sleSrc = psb.peek(keylet::account(src)); - assert(sleSrc); + XRPL_ASSERT(sleSrc); if (!sleSrc) return tecINTERNAL; diff --git a/src/ripple/app/tx/impl/applySteps.cpp b/src/ripple/app/tx/impl/applySteps.cpp index 1a1fc343e3c..e01bfdae9d3 100644 --- a/src/ripple/app/tx/impl/applySteps.cpp +++ b/src/ripple/app/tx/impl/applySteps.cpp @@ -228,7 +228,7 @@ invoke_preflight(PreflightContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preflight: " << e.txnType; - assert(false); + XRPL_UNREACHABLE(); return {temUNKNOWN, TxConsequences{temUNKNOWN}}; } } @@ -277,7 +277,7 @@ invoke_preclaim(PreclaimContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preclaim: " << e.txnType; - assert(false); + XRPL_UNREACHABLE(); return temUNKNOWN; } } @@ -293,7 +293,7 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx) } catch (UnknownTxnType const& e) { - assert(false); + XRPL_UNREACHABLE(); return XRPAmount{0}; } } @@ -305,7 +305,7 @@ TxConsequences::TxConsequences(NotTEC pfresult) , seqProx_(SeqProxy::sequence(0)) , sequencesConsumed_(0) { - assert(!isTesSuccess(pfresult)); + XRPL_ASSERT(!isTesSuccess(pfresult)); } TxConsequences::TxConsequences(STTx const& tx) @@ -352,7 +352,7 @@ invoke_apply(ApplyContext& ctx) // Should never happen JLOG(ctx.journal.fatal()) << "Unknown transaction type in apply: " << e.txnType; - assert(false); + XRPL_UNREACHABLE(); return {temUNKNOWN, false}; } } diff --git a/src/ripple/app/tx/impl/details/NFTokenUtils.cpp b/src/ripple/app/tx/impl/details/NFTokenUtils.cpp index 09ff8f13caa..c33ed4f03c8 100644 --- a/src/ripple/app/tx/impl/details/NFTokenUtils.cpp +++ b/src/ripple/app/tx/impl/details/NFTokenUtils.cpp @@ -242,7 +242,7 @@ compareTokens(uint256 const& a, uint256 const& b) TER insertToken(ApplyView& view, AccountID owner, STObject&& nft) { - assert(nft.isFieldPresent(sfNFTokenID)); + XRPL_ASSERT(nft.isFieldPresent(sfNFTokenID)); // First, we need to locate the page the NFT belongs to, creating it // if necessary. This operation may fail if it is impossible to insert diff --git a/src/ripple/basics/Buffer.h b/src/ripple/basics/Buffer.h index 706b8b627f1..b8c9632cd7d 100644 --- a/src/ripple/basics/Buffer.h +++ b/src/ripple/basics/Buffer.h @@ -21,7 +21,7 @@ #define RIPPLE_BASICS_BUFFER_H_INCLUDED #include -#include +#include #include #include #include @@ -112,7 +112,7 @@ class Buffer operator=(Slice s) { // Ensure the slice isn't a subset of the buffer. - assert( + XRPL_ASSERT( s.size() == 0 || size_ == 0 || s.data() < p_.get() || s.data() >= p_.get() + size_); diff --git a/src/ripple/basics/FeeUnits.h b/src/ripple/basics/FeeUnits.h index 35e0ff24d05..ba86a597a1d 100644 --- a/src/ripple/basics/FeeUnits.h +++ b/src/ripple/basics/FeeUnits.h @@ -20,11 +20,11 @@ #define BASICS_FEES_H_INCLUDED #include +#include #include + #include #include - -#include #include #include #include @@ -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. - assert(value.value() >= 0); - assert(mul.value() >= 0); - assert(div.value() >= 0); + XRPL_ASSERT(value.value() >= 0); + XRPL_ASSERT(mul.value() >= 0); + XRPL_ASSERT(div.value() >= 0); return std::nullopt; } diff --git a/src/ripple/basics/SlabAllocator.h b/src/ripple/basics/SlabAllocator.h index ece96d0b873..36d196cf620 100644 --- a/src/ripple/basics/SlabAllocator.h +++ b/src/ripple/basics/SlabAllocator.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED #define RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED +#include #include #include @@ -28,7 +29,6 @@ #include #include -#include #include #include #include @@ -141,7 +141,7 @@ class SlabAllocator void deallocate(std::uint8_t* ptr) noexcept { - assert(own(ptr)); + XRPL_ASSERT(own(ptr)); std::lock_guard l(m_); @@ -184,7 +184,7 @@ class SlabAllocator boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_)) , slabSize_(alloc) { - assert((itemAlignment_ & (itemAlignment_ - 1)) == 0); + XRPL_ASSERT((itemAlignment_ & (itemAlignment_ - 1)) == 0); } SlabAllocator(SlabAllocator const& other) = delete; @@ -294,7 +294,7 @@ class SlabAllocator bool deallocate(std::uint8_t* ptr) noexcept { - assert(ptr); + XRPL_ASSERT(ptr); for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next_) { diff --git a/src/ripple/basics/Slice.h b/src/ripple/basics/Slice.h index 0ba6a94b62b..a4cf2a872dc 100644 --- a/src/ripple/basics/Slice.h +++ b/src/ripple/basics/Slice.h @@ -21,10 +21,10 @@ #define RIPPLE_BASICS_SLICE_H_INCLUDED #include +#include #include #include #include -#include #include #include #include @@ -103,7 +103,7 @@ class Slice std::uint8_t operator[](std::size_t i) const noexcept { - assert(i < size_); + XRPL_ASSERT(i < size_); return data_[i]; } diff --git a/src/ripple/basics/base_uint.h b/src/ripple/basics/base_uint.h index 8b15b082647..9c345d46485 100644 --- a/src/ripple/basics/base_uint.h +++ b/src/ripple/basics/base_uint.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -289,7 +290,8 @@ class base_uint std::is_trivially_copyable::value>> explicit base_uint(Container const& c) { - assert(c.size() * sizeof(typename Container::value_type) == size()); + XRPL_ASSERT( + c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); } @@ -300,7 +302,8 @@ class base_uint base_uint&> operator=(Container const& c) { - assert(c.size() * sizeof(typename Container::value_type) == size()); + XRPL_ASSERT( + c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); return *this; } diff --git a/src/ripple/basics/impl/Log.cpp b/src/ripple/basics/impl/Log.cpp index c023bc16485..c9b0b5f328c 100644 --- a/src/ripple/basics/impl/Log.cpp +++ b/src/ripple/basics/impl/Log.cpp @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -224,7 +224,7 @@ Logs::fromSeverity(beast::severities::Severity level) return lsERROR; default: - assert(false); + XRPL_UNREACHABLE(); [[fallthrough]]; case kFatal: break; @@ -250,7 +250,7 @@ Logs::toSeverity(LogSeverity level) case lsERROR: return kError; default: - assert(false); + XRPL_UNREACHABLE(); [[fallthrough]]; case lsFATAL: break; @@ -277,7 +277,7 @@ Logs::toString(LogSeverity s) case lsFATAL: return "Fatal"; default: - assert(false); + XRPL_UNREACHABLE(); return "Unknown"; } } @@ -341,7 +341,7 @@ Logs::format( output += "ERR "; break; default: - assert(false); + XRPL_UNREACHABLE(); [[fallthrough]]; case kFatal: output += "FTL "; diff --git a/src/ripple/basics/impl/Number.cpp b/src/ripple/basics/impl/Number.cpp index 9b3247536f9..37e5086260f 100644 --- a/src/ripple/basics/impl/Number.cpp +++ b/src/ripple/basics/impl/Number.cpp @@ -18,9 +18,9 @@ //============================================================================== #include +#include #include #include -#include #include #include #include @@ -235,7 +235,7 @@ Number::operator+=(Number const& y) *this = Number{}; return *this; } - assert(isnormal() && y.isnormal()); + XRPL_ASSERT(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; } - assert(isnormal() && y.isnormal()); + XRPL_ASSERT(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; - assert(isnormal() || *this == Number{}); + XRPL_ASSERT(isnormal() || *this == Number{}); return *this; } @@ -531,7 +531,7 @@ to_string(Number const& amount) negative = true; } - assert(exponent + 43 > 0); + XRPL_ASSERT(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; - assert(post_to >= post_from); + XRPL_ASSERT(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; - assert(post_to >= post_from); + XRPL_ASSERT(post_to >= post_from); post_to = std::find_if( std::make_reverse_iterator(post_to), diff --git a/src/ripple/basics/impl/ResolverAsio.cpp b/src/ripple/basics/impl/ResolverAsio.cpp index f75a390304b..b39f809d1d6 100644 --- a/src/ripple/basics/impl/ResolverAsio.cpp +++ b/src/ripple/basics/impl/ResolverAsio.cpp @@ -19,11 +19,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -48,7 +48,7 @@ class AsyncObject ~AsyncObject() { // Destroying the object with I/O pending? Not a clean exit! - assert(m_pending.load() == 0); + XRPL_ASSERT(m_pending.load() == 0); } /** RAII container that maintains the count of pending I/O. @@ -153,8 +153,8 @@ class ResolverAsioImpl : public ResolverAsio, ~ResolverAsioImpl() override { - assert(m_work.empty()); - assert(m_stopped); + XRPL_ASSERT(m_work.empty()); + XRPL_ASSERT(m_stopped); } //------------------------------------------------------------------------- @@ -176,8 +176,8 @@ class ResolverAsioImpl : public ResolverAsio, void start() override { - assert(m_stopped == true); - assert(m_stop_called == false); + XRPL_ASSERT(m_stopped == true); + XRPL_ASSERT(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 { - assert(m_stop_called == false); - assert(!names.empty()); + XRPL_ASSERT(m_stop_called == false); + XRPL_ASSERT(!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) { - assert(m_stop_called == true); + XRPL_ASSERT(m_stop_called == true); if (m_stopped.exchange(true) == false) { @@ -379,7 +379,7 @@ class ResolverAsioImpl : public ResolverAsio, HandlerType const& handler, CompletionCounter) { - assert(!names.empty()); + XRPL_ASSERT(!names.empty()); if (m_stop_called == false) { diff --git a/src/ripple/basics/instrumentation.h b/src/ripple/basics/instrumentation.h new file mode 100644 index 00000000000..0beae20b073 --- /dev/null +++ b/src/ripple/basics/instrumentation.h @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +/* +This file is part of rippled: https://github.com/ripple/rippled +Copyright (c) 2024 Ripple Labs Inc. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef RIPPLE_BASICS_INSTRUMENTATION_H_INCLUDED +#define RIPPLE_BASICS_INSTRUMENTATION_H_INCLUDED + +#include + +#ifdef ENABLE_VOIDSTAR +#include +#else +#define ALWAYS(cond, message, ...) +#define ALWAYS_OR_UNREACHABLE(cond, message, ...) assert(message&& cond) +#define SOMETIMES(cond, message, ...) +#define REACHABLE(message, ...) +#define UNREACHABLE(message, ...) assert(message && false) +#endif + +#define XRPL_ASSERT(...) ALWAYS_OR_UNREACHABLE(((bool)(__VA_ARGS__)), "", {}) +#define XRPL_UNREACHABLE() UNREACHABLE("", {}) + +#endif diff --git a/src/ripple/basics/partitioned_unordered_map.h b/src/ripple/basics/partitioned_unordered_map.h index 08f4cba9d3e..c8e7f46ad0c 100644 --- a/src/ripple/basics/partitioned_unordered_map.h +++ b/src/ripple/basics/partitioned_unordered_map.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_PARTITIONED_UNORDERED_MAP_H #define RIPPLE_BASICS_PARTITIONED_UNORDERED_MAP_H -#include +#include #include #include #include @@ -246,7 +246,7 @@ class partitioned_unordered_map ? *partitions : std::thread::hardware_concurrency(); map_.resize(partitions_); - assert(partitions_); + XRPL_ASSERT(partitions_); } std::size_t diff --git a/src/ripple/basics/random.h b/src/ripple/basics/random.h index 3af8be54109..8457739f64d 100644 --- a/src/ripple/basics/random.h +++ b/src/ripple/basics/random.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_RANDOM_H_INCLUDED #define RIPPLE_BASICS_RANDOM_H_INCLUDED +#include #include -#include #include #include #include @@ -114,7 +114,7 @@ std::enable_if_t< Integral> rand_int(Engine& engine, Integral min, Integral max) { - assert(max > min); + XRPL_ASSERT(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/src/ripple/basics/spinlock.h b/src/ripple/basics/spinlock.h index 85a2ac41d51..70700b5ce80 100644 --- a/src/ripple/basics/spinlock.h +++ b/src/ripple/basics/spinlock.h @@ -18,8 +18,8 @@ #ifndef RIPPLE_BASICS_SPINLOCK_H_INCLUDED #define RIPPLE_BASICS_SPINLOCK_H_INCLUDED +#include #include -#include #include #include @@ -117,7 +117,7 @@ class packed_spinlock packed_spinlock(std::atomic& lock, int index) : bits_(lock), mask_(static_cast(1) << index) { - assert(index >= 0 && (mask_ != 0)); + XRPL_ASSERT(index >= 0 && (mask_ != 0)); } [[nodiscard]] bool diff --git a/src/ripple/beast/asio/io_latency_probe.h b/src/ripple/beast/asio/io_latency_probe.h index bbde13af687..d46d9ae0396 100644 --- a/src/ripple/beast/asio/io_latency_probe.h +++ b/src/ripple/beast/asio/io_latency_probe.h @@ -20,8 +20,10 @@ #ifndef BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED #define BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED +#include #include #include + #include #include #include @@ -172,7 +174,7 @@ class io_latency_probe , m_repeat(repeat) , m_probe(probe) { - assert(m_probe); + XRPL_ASSERT(m_probe); m_probe->addref(); } @@ -182,7 +184,7 @@ class io_latency_probe , m_repeat(from.m_repeat) , m_probe(from.m_probe) { - assert(m_probe); + XRPL_ASSERT(m_probe); from.m_probe = nullptr; } diff --git a/src/ripple/beast/clock/basic_seconds_clock.cpp b/src/ripple/beast/clock/basic_seconds_clock.cpp index 7c55a3f8bc0..284bd56f934 100644 --- a/src/ripple/beast/clock/basic_seconds_clock.cpp +++ b/src/ripple/beast/clock/basic_seconds_clock.cpp @@ -17,10 +17,10 @@ */ //============================================================================== +#include #include #include -#include #include #include #include @@ -57,7 +57,7 @@ static_assert(std::atomic::is_always_lock_free); seconds_clock_thread::~seconds_clock_thread() { - assert(thread_.joinable()); + XRPL_ASSERT(thread_.joinable()); { std::lock_guard lock(mut_); stop_ = true; diff --git a/src/ripple/beast/clock/manual_clock.h b/src/ripple/beast/clock/manual_clock.h index 808b0071006..9a259eb7c62 100644 --- a/src/ripple/beast/clock/manual_clock.h +++ b/src/ripple/beast/clock/manual_clock.h @@ -20,8 +20,8 @@ #ifndef BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED #define BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED +#include #include -#include namespace beast { @@ -61,7 +61,7 @@ class manual_clock : public abstract_clock void set(time_point const& when) { - assert(!Clock::is_steady || when >= now_); + XRPL_ASSERT(!Clock::is_steady || when >= now_); now_ = when; } @@ -78,7 +78,7 @@ class manual_clock : public abstract_clock void advance(std::chrono::duration const& elapsed) { - assert(!Clock::is_steady || (now_ + elapsed) >= now_); + XRPL_ASSERT(!Clock::is_steady || (now_ + elapsed) >= now_); now_ += elapsed; } diff --git a/src/ripple/beast/container/detail/aged_unordered_container.h b/src/ripple/beast/container/detail/aged_unordered_container.h index fcdccd2a637..c648eb3c351 100644 --- a/src/ripple/beast/container/detail/aged_unordered_container.h +++ b/src/ripple/beast/container/detail/aged_unordered_container.h @@ -1329,7 +1329,7 @@ class aged_unordered_container size_type bucket(Key const& k) const { - assert(bucket_count() != 0); + XRPL_ASSERT(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); - assert(load_factor() <= max_load_factor()); + XRPL_ASSERT(load_factor() <= max_load_factor()); } // map, set diff --git a/src/ripple/beast/core/LexicalCast.h b/src/ripple/beast/core/LexicalCast.h index f4c78341b91..96905aa945c 100644 --- a/src/ripple/beast/core/LexicalCast.h +++ b/src/ripple/beast/core/LexicalCast.h @@ -20,8 +20,8 @@ #ifndef BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED #define BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED +#include #include -#include #include #include #include diff --git a/src/ripple/beast/core/SemanticVersion.cpp b/src/ripple/beast/core/SemanticVersion.cpp index 9d127a09513..588d0ce4f67 100644 --- a/src/ripple/beast/core/SemanticVersion.cpp +++ b/src/ripple/beast/core/SemanticVersion.cpp @@ -17,11 +17,11 @@ */ //============================================================================== +#include #include #include #include -#include #include namespace beast { @@ -304,7 +304,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) if (isNumeric(left)) { - assert(isNumeric(right)); + XRPL_ASSERT(isNumeric(right)); int const iLeft(lexicalCastThrow(left)); int const iRight(lexicalCastThrow(right)); @@ -316,7 +316,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) } else { - assert(!isNumeric(right)); + XRPL_ASSERT(!isNumeric(right)); int result = left.compare(right); diff --git a/src/ripple/beast/insight/impl/StatsDCollector.cpp b/src/ripple/beast/insight/impl/StatsDCollector.cpp index 6949a7f86e7..89399b98787 100644 --- a/src/ripple/beast/insight/impl/StatsDCollector.cpp +++ b/src/ripple/beast/insight/impl/StatsDCollector.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -400,7 +400,7 @@ class StatsDCollectorImp for (auto const& s : *keepAlive) { std::size_t const length(s.size()); - assert(!s.empty()); + XRPL_ASSERT(!s.empty()); if (!buffers.empty() && (size + length) > max_packet_size) { log(buffers); diff --git a/src/ripple/beast/net/IPAddress.h b/src/ripple/beast/net/IPAddress.h index d8820ec40b5..320c8a5bf14 100644 --- a/src/ripple/beast/net/IPAddress.h +++ b/src/ripple/beast/net/IPAddress.h @@ -20,13 +20,13 @@ #ifndef BEAST_NET_IPADDRESS_H_INCLUDED #define BEAST_NET_IPADDRESS_H_INCLUDED +#include #include #include #include #include #include #include -#include #include #include #include @@ -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 - assert(false); + XRPL_UNREACHABLE(); } } // namespace beast diff --git a/src/ripple/beast/net/IPAddressV6.h b/src/ripple/beast/net/IPAddressV6.h index 74eb6b96d8e..b55fa2bc977 100644 --- a/src/ripple/beast/net/IPAddressV6.h +++ b/src/ripple/beast/net/IPAddressV6.h @@ -20,8 +20,8 @@ #ifndef BEAST_NET_IPADDRESSV6_H_INCLUDED #define BEAST_NET_IPADDRESSV6_H_INCLUDED +#include #include -#include #include #include #include diff --git a/src/ripple/beast/utility/Journal.h b/src/ripple/beast/utility/Journal.h index 0738748b6c5..a81187f50c7 100644 --- a/src/ripple/beast/utility/Journal.h +++ b/src/ripple/beast/utility/Journal.h @@ -20,7 +20,7 @@ #ifndef BEAST_UTILITY_JOURNAL_H_INCLUDED #define BEAST_UTILITY_JOURNAL_H_INCLUDED -#include +#include #include namespace beast { @@ -205,7 +205,7 @@ class Journal */ Stream(Sink& sink, Severity level) : m_sink(sink), m_level(level) { - assert(m_level < severities::kDisabled); + XRPL_ASSERT(m_level < severities::kDisabled); } /** Construct or copy another Stream. */ diff --git a/src/ripple/beast/utility/rngfill.h b/src/ripple/beast/utility/rngfill.h index 71f434bdaf9..a52636d96c1 100644 --- a/src/ripple/beast/utility/rngfill.h +++ b/src/ripple/beast/utility/rngfill.h @@ -20,8 +20,8 @@ #ifndef BEAST_RANDOM_RNGFILL_H_INCLUDED #define BEAST_RANDOM_RNGFILL_H_INCLUDED +#include #include -#include #include #include #include @@ -42,7 +42,7 @@ rngfill(void* buffer, std::size_t bytes, Generator& g) bytes -= sizeof(v); } - assert(bytes < sizeof(result_type)); + XRPL_ASSERT(bytes < sizeof(result_type)); #ifdef __GNUC__ // gcc 11.1 (falsely) warns about an array-bounds overflow in release mode. diff --git a/src/ripple/beast/utility/src/beast_Journal.cpp b/src/ripple/beast/utility/src/beast_Journal.cpp index 7c332bf6b52..fd02d985851 100644 --- a/src/ripple/beast/utility/src/beast_Journal.cpp +++ b/src/ripple/beast/utility/src/beast_Journal.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include namespace beast { diff --git a/src/ripple/beast/utility/src/beast_PropertyStream.cpp b/src/ripple/beast/utility/src/beast_PropertyStream.cpp index ecd707e9554..aa0621b0cb2 100644 --- a/src/ripple/beast/utility/src/beast_PropertyStream.cpp +++ b/src/ripple/beast/utility/src/beast_PropertyStream.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include #include #include @@ -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); - assert(source.parent_ == nullptr); + XRPL_ASSERT(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); - assert(child.parent_ == this); + XRPL_ASSERT(child.parent_ == this); children_.erase(children_.iterator_to(child.item_)); child.parent_ = nullptr; } diff --git a/src/ripple/consensus/Consensus.h b/src/ripple/consensus/Consensus.h index 248bbdc4a1b..5fdbabd32bd 100644 --- a/src/ripple/consensus/Consensus.h +++ b/src/ripple/consensus/Consensus.h @@ -863,7 +863,7 @@ Consensus::gotTxSet( { // Our position is added to acquired_ as soon as we create it, // so this txSet must differ - assert(id != result_->position.position()); + XRPL_ASSERT(id != result_->position.position()); bool any = false; for (auto const& [nodeId, peerPos] : currPeerPositions_) { @@ -1008,7 +1008,7 @@ template void Consensus::handleWrongLedger(typename Ledger_t::ID const& lgrId) { - assert(lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); + XRPL_ASSERT(lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); // Stop proposing because we are out of sync leaveConsensus(); @@ -1261,7 +1261,7 @@ void Consensus::phaseEstablish() { // can only establish consensus if we already took a stance - assert(result_); + XRPL_ASSERT(result_); using namespace std::chrono; ConsensusParms const& parms = adaptor_.parms(); @@ -1309,7 +1309,7 @@ void Consensus::closeLedger() { // We should not be closing if we already have a position - assert(!result_); + XRPL_ASSERT(!result_); phase_ = ConsensusPhase::establish; JLOG(j_.debug()) << "transitioned to ConsensusPhase::establish"; @@ -1362,7 +1362,7 @@ void Consensus::updateOurPositions() { // We must have a position if we are updating it - assert(result_); + XRPL_ASSERT(result_); ConsensusParms const& parms = adaptor_.parms(); // Compute a cutoff time @@ -1546,7 +1546,7 @@ bool Consensus::haveConsensus() { // Must have a stance if we are checking for consensus - assert(result_); + XRPL_ASSERT(result_); // CHECKME: should possibly count unacquired TX sets as disagreeing int agree = 0, disagree = 0; @@ -1621,7 +1621,7 @@ void Consensus::createDisputes(TxSet_t const& o) { // Cannot create disputes without our stance - assert(result_); + XRPL_ASSERT(result_); // Only create disputes if this is a new set if (!result_->compares.emplace(o.id()).second) @@ -1642,7 +1642,7 @@ Consensus::createDisputes(TxSet_t const& o) { ++dc; // create disputed transactions (from the ledger that has them) - assert( + XRPL_ASSERT( (inThisSet && result_->txns.find(txId) && !o.find(txId)) || (!inThisSet && !result_->txns.find(txId) && o.find(txId))); @@ -1680,7 +1680,7 @@ void Consensus::updateDisputes(NodeID_t const& node, TxSet_t const& other) { // Cannot updateDisputes without our stance - assert(result_); + XRPL_ASSERT(result_); // Ensure we have created disputes against this set if we haven't seen // it before diff --git a/src/ripple/consensus/ConsensusTypes.h b/src/ripple/consensus/ConsensusTypes.h index 05d03c8a9c6..fe5eb67ef55 100644 --- a/src/ripple/consensus/ConsensusTypes.h +++ b/src/ripple/consensus/ConsensusTypes.h @@ -214,7 +214,7 @@ struct ConsensusResult ConsensusResult(TxSet_t&& s, Proposal_t&& p) : txns{std::move(s)}, position{std::move(p)} { - assert(txns.id() == position.position()); + XRPL_ASSERT(txns.id() == position.position()); } //! The set of transactions consensus agrees go in the ledger diff --git a/src/ripple/consensus/LedgerTiming.h b/src/ripple/consensus/LedgerTiming.h index 9320cf07de1..4bfdb51904f 100644 --- a/src/ripple/consensus/LedgerTiming.h +++ b/src/ripple/consensus/LedgerTiming.h @@ -82,7 +82,7 @@ getNextLedgerTimeResolution( bool previousAgree, Seq ledgerSeq) { - assert(ledgerSeq != Seq{0}); + XRPL_ASSERT(ledgerSeq != Seq{0}); using namespace std::chrono; // Find the current resolution: @@ -90,7 +90,7 @@ getNextLedgerTimeResolution( std::begin(ledgerPossibleTimeResolutions), std::end(ledgerPossibleTimeResolutions), previousResolution); - assert(iter != std::end(ledgerPossibleTimeResolutions)); + XRPL_ASSERT(iter != std::end(ledgerPossibleTimeResolutions)); // This should never happen, but just as a precaution if (iter == std::end(ledgerPossibleTimeResolutions)) diff --git a/src/ripple/consensus/LedgerTrie.h b/src/ripple/consensus/LedgerTrie.h index 12cd0d3cbbc..5e70022dc83 100644 --- a/src/ripple/consensus/LedgerTrie.h +++ b/src/ripple/consensus/LedgerTrie.h @@ -21,7 +21,9 @@ #define RIPPLE_APP_CONSENSUS_LEDGERS_TRIE_H_INCLUDED #include +#include #include + #include #include #include @@ -62,7 +64,7 @@ class SpanTip ID ancestor(Seq const& s) const { - assert(s <= seq); + XRPL_ASSERT(s <= seq); return ledger[s]; } @@ -88,7 +90,7 @@ class Span Span() : ledger_{typename Ledger::MakeGenesis{}} { // Require default ledger to be genesis seq - assert(ledger_.seq() == start_); + XRPL_ASSERT(ledger_.seq() == start_); } Span(Ledger ledger) @@ -157,7 +159,7 @@ class Span : start_{start}, end_{end}, ledger_{l} { // Spans cannot be empty - assert(start < end); + XRPL_ASSERT(start < end); } Seq @@ -230,7 +232,7 @@ struct Node [child](std::unique_ptr const& curr) { return curr.get() == child; }); - assert(it != children.end()); + XRPL_ASSERT(it != children.end()); std::swap(*it, children.back()); children.pop_back(); } @@ -338,7 +340,7 @@ struct Node // For all Seq s: if(a[s] == b[s]); for(Seq p = 0; p < s; ++p) - assert(a[p] == b[p]); + XRPL_ASSERT(a[p] == b[p]); @endcode @tparam Ledger A type representing a ledger and its history @@ -371,7 +373,7 @@ class LedgerTrie Node* curr = root.get(); // Root is always defined and is in common with all ledgers - assert(curr); + XRPL_ASSERT(curr); Seq pos = curr->span.diff(ledger); bool done = false; @@ -452,7 +454,7 @@ class LedgerTrie auto const [loc, diffSeq] = find(ledger); // There is always a place to insert - assert(loc); + XRPL_ASSERT(loc); // Node from which to start incrementing branchSupport Node* incNode = loc; @@ -487,12 +489,12 @@ class LedgerTrie newNode->tipSupport = loc->tipSupport; newNode->branchSupport = loc->branchSupport; newNode->children = std::move(loc->children); - assert(loc->children.empty()); + XRPL_ASSERT(loc->children.empty()); for (std::unique_ptr& child : newNode->children) child->parent = newNode.get(); // Loc truncates to prefix and newNode is its child - assert(prefix); + XRPL_ASSERT(prefix); loc->span = *prefix; newNode->parent = loc; loc->children.emplace_back(std::move(newNode)); @@ -545,7 +547,7 @@ class LedgerTrie loc->tipSupport -= count; auto const it = seqSupport.find(ledger.seq()); - assert(it != seqSupport.end() && it->second >= count); + XRPL_ASSERT(it != seqSupport.end() && it->second >= count); it->second -= count; if (it->second == 0) seqSupport.erase(it->first); diff --git a/src/ripple/consensus/Validations.h b/src/ripple/consensus/Validations.h index 1bef76d961c..da2f8176a6e 100644 --- a/src/ripple/consensus/Validations.h +++ b/src/ripple/consensus/Validations.h @@ -434,7 +434,7 @@ class Validations Validation const& val, std::optional> prior) { - assert(val.trusted()); + XRPL_ASSERT(val.trusted()); // Clear any prior acquiring ledger for this node if (prior) @@ -714,7 +714,7 @@ class Validations setSeqToKeep(Seq const& low, Seq const& high) { std::lock_guard lock{mutex_}; - assert(low < high); + XRPL_ASSERT(low < high); toKeep_ = {low, high}; } diff --git a/src/ripple/core/Coro.ipp b/src/ripple/core/Coro.ipp index 2b07c5a4584..394a690316b 100644 --- a/src/ripple/core/Coro.ipp +++ b/src/ripple/core/Coro.ipp @@ -53,7 +53,7 @@ JobQueue::Coro::Coro( inline JobQueue::Coro::~Coro() { #ifndef NDEBUG - assert(finished_); + XRPL_ASSERT(finished_); #endif } @@ -103,7 +103,7 @@ JobQueue::Coro::resume() auto saved = detail::getLocalValues().release(); detail::getLocalValues().reset(&lvs_); std::lock_guard lock(mutex_); - assert(coro_); + XRPL_ASSERT(coro_); coro_(); detail::getLocalValues().release(); detail::getLocalValues().reset(saved); diff --git a/src/ripple/core/DatabaseCon.h b/src/ripple/core/DatabaseCon.h index 59eec3a32e9..e289c4b8b2a 100644 --- a/src/ripple/core/DatabaseCon.h +++ b/src/ripple/core/DatabaseCon.h @@ -96,7 +96,7 @@ class DatabaseCon std::vector const* commonPragma() const { - assert(!useGlobalPragma || globalPragma); + XRPL_ASSERT(!useGlobalPragma || globalPragma); return useGlobalPragma && globalPragma ? globalPragma.get() : nullptr; } diff --git a/src/ripple/core/JobTypes.h b/src/ripple/core/JobTypes.h index 2803537f115..4b9b766e08a 100644 --- a/src/ripple/core/JobTypes.h +++ b/src/ripple/core/JobTypes.h @@ -53,7 +53,7 @@ class JobTypes int limit, std::chrono::milliseconds avgLatency, std::chrono::milliseconds peakLatency) { - assert(m_map.find(jt) == m_map.end()); + XRPL_ASSERT(m_map.find(jt) == m_map.end()); auto const [_, inserted] = m_map.emplace( std::piecewise_construct, @@ -61,7 +61,7 @@ class JobTypes std::forward_as_tuple( jt, name, limit, avgLatency, peakLatency)); - assert(inserted == true); + XRPL_ASSERT(inserted == true); (void)_; (void)inserted; }; @@ -138,7 +138,7 @@ class JobTypes get(JobType jt) const { Map::const_iterator const iter(m_map.find(jt)); - assert(iter != m_map.end()); + XRPL_ASSERT(iter != m_map.end()); if (iter != m_map.end()) return iter->second; diff --git a/src/ripple/core/Pg.cpp b/src/ripple/core/Pg.cpp index df0f6da5ef5..a13aa15c6c0 100644 --- a/src/ripple/core/Pg.cpp +++ b/src/ripple/core/Pg.cpp @@ -30,12 +30,12 @@ #endif #include +#include #include #include #include #include #include -#include #include #include #include @@ -242,7 +242,7 @@ void Pg::bulkInsert(char const* table, std::string const& records) { // https://www.postgresql.org/docs/12/libpq-copy.html#LIBPQ-COPY-SEND - assert(conn_.get()); + XRPL_ASSERT(conn_.get()); static auto copyCmd = boost::format(R"(COPY %s FROM stdin)"); auto res = query(boost::str(copyCmd % table).c_str()); if (!res || res.status() != PGRES_COPY_IN) @@ -1326,7 +1326,7 @@ applySchema( { if (currentVersion != 0 && schemaVersion != currentVersion + 1) { - assert(false); + XRPL_UNREACHABLE(); std::stringstream ss; ss << "Schema upgrade versions past initial deployment must increase " "monotonically. Versions: current, target: " diff --git a/src/ripple/core/impl/Config.cpp b/src/ripple/core/impl/Config.cpp index 2f26b8ba525..266ced4e8db 100644 --- a/src/ripple/core/impl/Config.cpp +++ b/src/ripple/core/impl/Config.cpp @@ -266,7 +266,7 @@ Config::Config() void Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) { - assert(NODE_SIZE == 0); + XRPL_ASSERT(NODE_SIZE == 0); QUIET = bQuiet || bSilent; SILENT = bSilent; @@ -287,7 +287,7 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) return (limit == 0) || (ramSize_ < limit); }); - assert(ns != threshold.second.end()); + XRPL_ASSERT(ns != threshold.second.end()); if (ns != threshold.second.end()) NODE_SIZE = std::distance(threshold.second.begin(), ns); @@ -298,7 +298,7 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) NODE_SIZE = std::min(hc / 2, NODE_SIZE); } - assert(NODE_SIZE <= 4); + XRPL_ASSERT(NODE_SIZE <= 4); } void @@ -1009,8 +1009,8 @@ int Config::getValueFor(SizedItem item, std::optional node) const { auto const index = static_cast>(item); - assert(index < sizedItems.size()); - assert(!node || *node <= 4); + XRPL_ASSERT(index < sizedItems.size()); + XRPL_ASSERT(!node || *node <= 4); return sizedItems.at(index).second.at(node.value_or(NODE_SIZE)); } diff --git a/src/ripple/core/impl/DatabaseCon.cpp b/src/ripple/core/impl/DatabaseCon.cpp index 4f65f7003f6..d5b39c1dc89 100644 --- a/src/ripple/core/impl/DatabaseCon.cpp +++ b/src/ripple/core/impl/DatabaseCon.cpp @@ -232,7 +232,7 @@ setup_DatabaseCon(Config const& c, std::optional j) "nodes storing large amounts of history, because of the " "difficulty inherent in rebuilding corrupted data."; } - assert(result->size() == 3); + XRPL_ASSERT(result->size() == 3); return result; }(); } diff --git a/src/ripple/core/impl/Job.cpp b/src/ripple/core/impl/Job.cpp index 780a9f49cdf..7beb24e7ba4 100644 --- a/src/ripple/core/impl/Job.cpp +++ b/src/ripple/core/impl/Job.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include namespace ripple { diff --git a/src/ripple/core/impl/JobQueue.cpp b/src/ripple/core/impl/JobQueue.cpp index 28947300cc6..c5355b3efb9 100644 --- a/src/ripple/core/impl/JobQueue.cpp +++ b/src/ripple/core/impl/JobQueue.cpp @@ -55,7 +55,7 @@ JobQueue::JobQueue( std::piecewise_construct, std::forward_as_tuple(jt.type()), std::forward_as_tuple(jt, m_collector, logs))); - assert(result.second == true); + XRPL_ASSERT(result.second == true); (void)result.second; } } @@ -80,10 +80,10 @@ JobQueue::addRefCountedJob( std::string const& name, JobFunction const& func) { - assert(type != jtINVALID); + XRPL_ASSERT(type != jtINVALID); auto iter(m_jobData.find(type)); - assert(iter != m_jobData.end()); + XRPL_ASSERT(iter != m_jobData.end()); if (iter == m_jobData.end()) return false; @@ -93,7 +93,7 @@ JobQueue::addRefCountedJob( // FIXME: Workaround incorrect client shutdown ordering // do not add jobs to a queue with no threads - assert( + XRPL_ASSERT( (type >= jtCLIENT && type <= jtCLIENT_WEBSOCKET) || m_workers.getNumberOfThreads() > 0); @@ -104,8 +104,8 @@ JobQueue::addRefCountedJob( auto const& job = *result.first; JobType const type(job.getType()); - assert(type != jtINVALID); - assert(m_jobSet.find(job) != m_jobSet.end()); + XRPL_ASSERT(type != jtINVALID); + XRPL_ASSERT(m_jobSet.find(job) != m_jobSet.end()); perfLog_.jobQueue(type); JobTypeData& data(getJobTypeData(type)); @@ -165,7 +165,7 @@ std::unique_ptr JobQueue::makeLoadEvent(JobType t, std::string const& name) { JobDataMap::iterator iter(m_jobData.find(t)); - assert(iter != m_jobData.end()); + XRPL_ASSERT(iter != m_jobData.end()); if (iter == m_jobData.end()) return {}; @@ -180,7 +180,7 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed) LogicError("JobQueue::addLoadEvents() called after JobQueue stopped"); JobDataMap::iterator iter(m_jobData.find(t)); - assert(iter != m_jobData.end()); + XRPL_ASSERT(iter != m_jobData.end()); iter->second.load().addSamples(count, elapsed); } @@ -206,7 +206,7 @@ JobQueue::getJson(int c) for (auto& x : m_jobData) { - assert(x.first != jtINVALID); + XRPL_ASSERT(x.first != jtINVALID); if (x.first == jtGENERIC) continue; @@ -261,7 +261,7 @@ JobTypeData& JobQueue::getJobTypeData(JobType type) { JobDataMap::iterator c(m_jobData.find(type)); - assert(c != m_jobData.end()); + XRPL_ASSERT(c != m_jobData.end()); // NIKB: This is ugly and I hate it. We must remove jtINVALID completely // and use something sane. @@ -286,9 +286,9 @@ JobQueue::stop() std::unique_lock lock(m_mutex); cv_.wait( lock, [this] { return m_processCount == 0 && m_jobSet.empty(); }); - assert(m_processCount == 0); - assert(m_jobSet.empty()); - assert(nSuspend_ == 0); + XRPL_ASSERT(m_processCount == 0); + XRPL_ASSERT(m_jobSet.empty()); + XRPL_ASSERT(nSuspend_ == 0); stopped_ = true; } } @@ -302,28 +302,28 @@ JobQueue::isStopped() const void JobQueue::getNextJob(Job& job) { - assert(!m_jobSet.empty()); + XRPL_ASSERT(!m_jobSet.empty()); std::set::const_iterator iter; for (iter = m_jobSet.begin(); iter != m_jobSet.end(); ++iter) { JobType const type = iter->getType(); - assert(type != jtINVALID); + XRPL_ASSERT(type != jtINVALID); JobTypeData& data(getJobTypeData(type)); - assert(data.running <= getJobLimit(type)); + XRPL_ASSERT(data.running <= getJobLimit(type)); // Run this job if we're running below the limit. if (data.running < getJobLimit(data.type())) { - assert(data.waiting > 0); + XRPL_ASSERT(data.waiting > 0); --data.waiting; ++data.running; break; } } - assert(iter != m_jobSet.end()); + XRPL_ASSERT(iter != m_jobSet.end()); job = *iter; m_jobSet.erase(iter); } @@ -331,14 +331,14 @@ JobQueue::getNextJob(Job& job) void JobQueue::finishJob(JobType type) { - assert(type != jtINVALID); + XRPL_ASSERT(type != jtINVALID); JobTypeData& data = getJobTypeData(type); // Queue a deferred task if possible if (data.deferred > 0) { - assert(data.running + data.waiting >= getJobLimit(type)); + XRPL_ASSERT(data.running + data.waiting >= getJobLimit(type)); --data.deferred; m_workers.addTask(); @@ -404,7 +404,7 @@ int JobQueue::getJobLimit(JobType type) { JobTypeInfo const& j(JobTypes::instance().get(type)); - assert(j.type() != jtINVALID); + XRPL_ASSERT(j.type() != jtINVALID); return j.limit(); } diff --git a/src/ripple/core/impl/LoadEvent.cpp b/src/ripple/core/impl/LoadEvent.cpp index 38617e7f541..6a4aa3e08c6 100644 --- a/src/ripple/core/impl/LoadEvent.cpp +++ b/src/ripple/core/impl/LoadEvent.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include #include namespace ripple { @@ -83,7 +83,7 @@ LoadEvent::start() void LoadEvent::stop() { - assert(running_); + XRPL_ASSERT(running_); auto const now = std::chrono::steady_clock::now(); diff --git a/src/ripple/core/impl/Workers.cpp b/src/ripple/core/impl/Workers.cpp index 732e6f0ec8a..727519c3509 100644 --- a/src/ripple/core/impl/Workers.cpp +++ b/src/ripple/core/impl/Workers.cpp @@ -18,9 +18,9 @@ //============================================================================== #include +#include #include #include -#include namespace ripple { @@ -119,7 +119,7 @@ Workers::stop() m_cv.wait(lk, [this] { return m_allPaused; }); lk.unlock(); - assert(numberOfCurrentlyRunningTasks() == 0); + XRPL_ASSERT(numberOfCurrentlyRunningTasks() == 0); } void diff --git a/src/ripple/crypto/impl/RFC1751.cpp b/src/ripple/crypto/impl/RFC1751.cpp index 6b6b2c31fb1..36f731f4599 100644 --- a/src/ripple/crypto/impl/RFC1751.cpp +++ b/src/ripple/crypto/impl/RFC1751.cpp @@ -17,10 +17,10 @@ */ //============================================================================== +#include #include #include #include -#include #include #include @@ -270,10 +270,10 @@ RFC1751::extract(char const* s, int start, int length) unsigned char cr; unsigned long x; - assert(length <= 11); - assert(start >= 0); - assert(length >= 0); - assert(start + length <= 66); + XRPL_ASSERT(length <= 11); + XRPL_ASSERT(start >= 0); + XRPL_ASSERT(length >= 0); + XRPL_ASSERT(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; - assert(length <= 11); - assert(start >= 0); - assert(length >= 0); - assert(start + length <= 66); + XRPL_ASSERT(length <= 11); + XRPL_ASSERT(start >= 0); + XRPL_ASSERT(length >= 0); + XRPL_ASSERT(start + length <= 66); shift = ((8 - ((start + length) % 8)) % 8); y = (long)x << shift; diff --git a/src/ripple/crypto/impl/csprng.cpp b/src/ripple/crypto/impl/csprng.cpp index 04b3b3fc385..d2853bee4ad 100644 --- a/src/ripple/crypto/impl/csprng.cpp +++ b/src/ripple/crypto/impl/csprng.cpp @@ -18,9 +18,9 @@ //============================================================================== #include +#include #include #include -#include #include #include #include diff --git a/src/ripple/json/impl/Object.cpp b/src/ripple/json/impl/Object.cpp index a855fc31a2c..0631b178cf3 100644 --- a/src/ripple/json/impl/Object.cpp +++ b/src/ripple/json/impl/Object.cpp @@ -18,8 +18,8 @@ //============================================================================== #include +#include #include -#include namespace Json { @@ -168,7 +168,7 @@ Array::append(Json::Value const& v) return; } } - assert(false); // Can't get here. + XRPL_UNREACHABLE(); // Can't get here. } void @@ -203,7 +203,7 @@ Object::set(std::string const& k, Json::Value const& v) return; } } - assert(false); // Can't get here. + XRPL_UNREACHABLE(); // Can't get here. } //------------------------------------------------------------------------------ @@ -214,7 +214,7 @@ template void doCopyFrom(Object& to, Json::Value const& from) { - assert(from.isObjectOrNull()); + XRPL_ASSERT(from.isObjectOrNull()); auto members = from.getMemberNames(); for (auto& m : members) to[m] = from[m]; diff --git a/src/ripple/json/impl/json_assert.h b/src/ripple/json/impl/json_assert.h index b7297e016c6..635ac47b36a 100644 --- a/src/ripple/json/impl/json_assert.h +++ b/src/ripple/json/impl/json_assert.h @@ -22,9 +22,9 @@ #include -#define JSON_ASSERT_UNREACHABLE assert(false) +#define JSON_ASSERT_UNREACHABLE XRPL_UNREACHABLE() #define JSON_ASSERT(condition) \ - assert(condition); // @todo <= change this into an exception throw + XRPL_ASSERT(condition); // @todo <= change this into an exception throw #define JSON_ASSERT_MESSAGE(condition, message) \ if (!(condition)) \ ripple::Throw(message); diff --git a/src/ripple/json/impl/json_writer.cpp b/src/ripple/json/impl/json_writer.cpp index 4d696ab55bc..f1e2aed4839 100644 --- a/src/ripple/json/impl/json_writer.cpp +++ b/src/ripple/json/impl/json_writer.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include #include #include #include @@ -70,7 +70,7 @@ valueToString(Int value) if (isNegative) *--current = '-'; - assert(current >= buffer); + XRPL_ASSERT(current >= buffer); return current; } @@ -80,7 +80,7 @@ valueToString(UInt value) char buffer[32]; char* current = buffer + sizeof(buffer); uintToString(value, current); - assert(current >= buffer); + XRPL_ASSERT(current >= buffer); return current; } @@ -391,7 +391,7 @@ StyledWriter::writeArrayValue(const Value& value) } else // output on a single line { - assert(childValues_.size() == size); + XRPL_ASSERT(childValues_.size() == size); document_ += "[ "; for (unsigned index = 0; index < size; ++index) @@ -483,7 +483,7 @@ StyledWriter::indent() void StyledWriter::unindent() { - assert(int(indentString_.size()) >= indentSize_); + XRPL_ASSERT(int(indentString_.size()) >= indentSize_); indentString_.resize(indentString_.size() - indentSize_); } @@ -613,7 +613,7 @@ StyledStreamWriter::writeArrayValue(const Value& value) } else // output on a single line { - assert(childValues_.size() == size); + XRPL_ASSERT(childValues_.size() == size); *document_ << "[ "; for (unsigned index = 0; index < size; ++index) @@ -706,7 +706,7 @@ StyledStreamWriter::indent() void StyledStreamWriter::unindent() { - assert(indentString_.size() >= indentation_.size()); + XRPL_ASSERT(indentString_.size() >= indentation_.size()); indentString_.resize(indentString_.size() - indentation_.size()); } diff --git a/src/ripple/ledger/ApplyView.h b/src/ripple/ledger/ApplyView.h index a37ba6c46a1..63951b29828 100644 --- a/src/ripple/ledger/ApplyView.h +++ b/src/ripple/ledger/ApplyView.h @@ -276,7 +276,7 @@ class ApplyView : public ReadView { if (key.type != ltOFFER) { - assert(!"Only Offers are appended to book directories. " + XRPL_ASSERT(!"Only Offers are appended to book directories. " "Call dirInsert() instead."); return std::nullopt; } diff --git a/src/ripple/ledger/ReadView.h b/src/ripple/ledger/ReadView.h index 2ea3ab492ed..9b2ffa26c2c 100644 --- a/src/ripple/ledger/ReadView.h +++ b/src/ripple/ledger/ReadView.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/ledger/detail/ReadViewFwdRange.ipp b/src/ripple/ledger/detail/ReadViewFwdRange.ipp index ae84259d7ce..d06ab1f8a3c 100644 --- a/src/ripple/ledger/detail/ReadViewFwdRange.ipp +++ b/src/ripple/ledger/detail/ReadViewFwdRange.ipp @@ -80,7 +80,7 @@ template bool ReadViewFwdRange::iterator::operator==(iterator const& other) const { - assert(view_ == other.view_); + XRPL_ASSERT(view_ == other.view_); if (impl_ != nullptr && other.impl_ != nullptr) return impl_->equal(*other.impl_); diff --git a/src/ripple/ledger/impl/ApplyStateTable.cpp b/src/ripple/ledger/impl/ApplyStateTable.cpp index ab2f0ca8cdb..9c42f79f7d4 100644 --- a/src/ripple/ledger/impl/ApplyStateTable.cpp +++ b/src/ripple/ledger/impl/ApplyStateTable.cpp @@ -18,11 +18,11 @@ //============================================================================== #include +#include #include #include #include #include -#include namespace ripple { namespace detail { @@ -155,7 +155,7 @@ ApplyStateTable::apply( meta.setAffectedNode(item.first, *type, nodeType); if (type == &sfDeletedNode) { - assert(origNode && curNode); + XRPL_ASSERT(origNode && curNode); threadOwners(to, meta, origNode, newMod, j); STObject prevs(sfPreviousFields); @@ -187,7 +187,7 @@ ApplyStateTable::apply( } else if (type == &sfModifiedNode) { - assert(curNode && origNode); + XRPL_ASSERT(curNode && origNode); if (curNode->isThreadedType( to.rules())) // thread transaction to node @@ -222,7 +222,7 @@ ApplyStateTable::apply( } else if (type == &sfCreatedNode) // if created, thread to owner(s) { - assert(curNode && !origNode); + XRPL_ASSERT(curNode && !origNode); threadOwners(to, meta, curNode, newMod, j); if (curNode->isThreadedType( @@ -245,7 +245,7 @@ ApplyStateTable::apply( } else { - assert(false); + XRPL_UNREACHABLE(); } } @@ -536,13 +536,13 @@ ApplyStateTable::threadItem(TxMeta& meta, std::shared_ptr const& sle) if (node.getFieldIndex(sfPreviousTxnID) == -1) { - assert(node.getFieldIndex(sfPreviousTxnLgrSeq) == -1); + XRPL_ASSERT(node.getFieldIndex(sfPreviousTxnLgrSeq) == -1); node.setFieldH256(sfPreviousTxnID, prevTxID); node.setFieldU32(sfPreviousTxnLgrSeq, prevLgrID); } - assert(node.getFieldH256(sfPreviousTxnID) == prevTxID); - assert(node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID); + XRPL_ASSERT(node.getFieldH256(sfPreviousTxnID) == prevTxID); + XRPL_ASSERT(node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID); } } @@ -557,7 +557,7 @@ ApplyStateTable::getForMod( auto miter = mods.find(key); if (miter != mods.end()) { - assert(miter->second); + XRPL_ASSERT(miter->second); return miter->second; } } @@ -613,7 +613,7 @@ ApplyStateTable::threadTx( return; } // threadItem only applied to AccountRoot - assert(sle->isThreadedType(base.rules())); + XRPL_ASSERT(sle->isThreadedType(base.rules())); threadItem(meta, sle); } diff --git a/src/ripple/ledger/impl/ApplyView.cpp b/src/ripple/ledger/impl/ApplyView.cpp index eced521fb5d..22278ab9103 100644 --- a/src/ripple/ledger/impl/ApplyView.cpp +++ b/src/ripple/ledger/impl/ApplyView.cpp @@ -18,9 +18,9 @@ //============================================================================== #include +#include #include #include -#include namespace ripple { @@ -133,7 +133,7 @@ ApplyView::emptyDirDelete(Keylet const& directory) if (directory.type != ltDIR_NODE || node->getFieldH256(sfRootIndex) != directory.key) { - assert(!"emptyDirDelete() called with wrong node type"); + XRPL_ASSERT(!"emptyDirDelete() called with wrong node type"); return false; } diff --git a/src/ripple/ledger/impl/ApplyViewImpl.cpp b/src/ripple/ledger/impl/ApplyViewImpl.cpp index 155ff4df99f..6a4e3dc4e30 100644 --- a/src/ripple/ledger/impl/ApplyViewImpl.cpp +++ b/src/ripple/ledger/impl/ApplyViewImpl.cpp @@ -18,8 +18,8 @@ //============================================================================== #include +#include #include -#include namespace ripple { diff --git a/src/ripple/ledger/impl/BookDirs.cpp b/src/ripple/ledger/impl/BookDirs.cpp index f8589d5575c..67cdfa9a2e0 100644 --- a/src/ripple/ledger/impl/BookDirs.cpp +++ b/src/ripple/ledger/impl/BookDirs.cpp @@ -30,12 +30,12 @@ BookDirs::BookDirs(ReadView const& view, Book const& book) , next_quality_(getQualityNext(root_)) , key_(view_->succ(root_, next_quality_).value_or(beast::zero)) { - assert(root_ != beast::zero); + XRPL_ASSERT(root_ != beast::zero); if (key_ != beast::zero) { if (!cdirFirst(*view_, key_, sle_, entry_, index_)) { - assert(false); + XRPL_UNREACHABLE(); } } } @@ -70,7 +70,7 @@ BookDirs::const_iterator::operator==( if (view_ == nullptr || other.view_ == nullptr) return false; - assert(view_ == other.view_ && root_ == other.root_); + XRPL_ASSERT(view_ == other.view_ && root_ == other.root_); return entry_ == other.entry_ && cur_key_ == other.cur_key_ && index_ == other.index_; } @@ -78,7 +78,7 @@ BookDirs::const_iterator::operator==( BookDirs::const_iterator::reference BookDirs::const_iterator::operator*() const { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); if (!cache_) cache_ = view_->read(keylet::offer(index_)); return *cache_; @@ -89,7 +89,7 @@ BookDirs::const_iterator::operator++() { using beast::zero; - assert(index_ != zero); + XRPL_ASSERT(index_ != zero); if (!cdirNext(*view_, cur_key_, sle_, entry_, index_)) { if (index_ != 0 || @@ -102,7 +102,7 @@ BookDirs::const_iterator::operator++() } else if (!cdirFirst(*view_, cur_key_, sle_, entry_, index_)) { - assert(false); + XRPL_UNREACHABLE(); } } @@ -113,7 +113,7 @@ BookDirs::const_iterator::operator++() BookDirs::const_iterator BookDirs::const_iterator::operator++(int) { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); const_iterator tmp(*this); ++(*this); return tmp; diff --git a/src/ripple/ledger/impl/Directory.cpp b/src/ripple/ledger/impl/Directory.cpp index 759b4d71b74..23a589382a7 100644 --- a/src/ripple/ledger/impl/Directory.cpp +++ b/src/ripple/ledger/impl/Directory.cpp @@ -60,14 +60,14 @@ const_iterator::operator==(const_iterator const& other) const if (view_ == nullptr || other.view_ == nullptr) return false; - assert(view_ == other.view_ && root_.key == other.root_.key); + XRPL_ASSERT(view_ == other.view_ && root_.key == other.root_.key); return page_.key == other.page_.key && index_ == other.index_; } const_iterator::reference const_iterator::operator*() const { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); if (!cache_) cache_ = view_->read(keylet::child(index_)); return *cache_; @@ -76,7 +76,7 @@ const_iterator::operator*() const const_iterator& const_iterator::operator++() { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); if (++it_ != std::end(*indexes_)) { index_ = *it_; @@ -90,7 +90,7 @@ const_iterator::operator++() const_iterator const_iterator::operator++(int) { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); const_iterator tmp(*this); ++(*this); return tmp; @@ -109,7 +109,7 @@ const_iterator::next_page() { page_ = keylet::page(root_, next); sle_ = view_->read(page_); - assert(sle_); + XRPL_ASSERT(sle_); indexes_ = &sle_->getFieldV256(sfIndexes); if (indexes_->empty()) { diff --git a/src/ripple/ledger/impl/PaymentSandbox.cpp b/src/ripple/ledger/impl/PaymentSandbox.cpp index bbe2c313491..ed34cc985b0 100644 --- a/src/ripple/ledger/impl/PaymentSandbox.cpp +++ b/src/ripple/ledger/impl/PaymentSandbox.cpp @@ -18,14 +18,13 @@ //============================================================================== #include +#include #include #include #include #include #include -#include - namespace ripple { namespace detail { @@ -49,8 +48,8 @@ DeferredCredits::credit( STAmount const& amount, STAmount const& preCreditSenderBalance) { - assert(sender != receiver); - assert(!amount.negative()); + XRPL_ASSERT(sender != receiver); + XRPL_ASSERT(!amount.negative()); auto const k = makeKey(sender, receiver, amount.getCurrency()); auto i = credits_.find(k); @@ -253,14 +252,14 @@ PaymentSandbox::adjustOwnerCountHook( void PaymentSandbox::apply(RawView& to) { - assert(!ps_); + XRPL_ASSERT(!ps_); items_.apply(to); } void PaymentSandbox::apply(PaymentSandbox& to) { - assert(ps_ == &to); + XRPL_ASSERT(ps_ == &to); items_.apply(to); tab_.apply(to.tab_); } @@ -344,7 +343,7 @@ PaymentSandbox::balanceChanges(ReadView const& view) const { // modify auto const at = after->getType(); - assert(at == before->getType()); + XRPL_ASSERT(at == before->getType()); switch (at) { case ltACCOUNT_ROOT: diff --git a/src/ripple/ledger/impl/RawStateTable.cpp b/src/ripple/ledger/impl/RawStateTable.cpp index 019ef6156c2..aa6c289a9b8 100644 --- a/src/ripple/ledger/impl/RawStateTable.cpp +++ b/src/ripple/ledger/impl/RawStateTable.cpp @@ -63,7 +63,7 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base { if (auto const p = dynamic_cast(&impl)) { - assert(end1_ == p->end1_ && end0_ == p->end0_); + XRPL_ASSERT(end1_ == p->end1_ && end0_ == p->end0_); return iter1_ == p->iter1_ && iter0_ == p->iter0_; } @@ -73,7 +73,7 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base void increment() override { - assert(sle1_ || sle0_); + XRPL_ASSERT(sle1_ || sle0_); if (sle1_ && !sle0_) { @@ -179,7 +179,7 @@ RawStateTable::apply(RawView& to) const bool RawStateTable::exists(ReadView const& base, Keylet const& k) const { - assert(k.key.isNonZero()); + XRPL_ASSERT(k.key.isNonZero()); auto const iter = items_.find(k.key); if (iter == items_.end()) return base.exists(k); diff --git a/src/ripple/ledger/impl/View.cpp b/src/ripple/ledger/impl/View.cpp index b71b4f39e5e..c34af2f7527 100644 --- a/src/ripple/ledger/impl/View.cpp +++ b/src/ripple/ledger/impl/View.cpp @@ -20,13 +20,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include namespace ripple { @@ -48,7 +48,7 @@ internalDirNext( uint256& entry) { auto const& svIndexes = page->getFieldV256(sfIndexes); - assert(index <= svIndexes.size()); + XRPL_ASSERT(index <= svIndexes.size()); if (index >= svIndexes.size()) { @@ -65,7 +65,7 @@ internalDirNext( else page = view.peek(keylet::page(root, next)); - assert(page); + XRPL_ASSERT(page); if (!page) return false; @@ -336,7 +336,7 @@ confineOwnerCount( << "Account " << *id << " owner count set below 0!"; } adjusted = 0; - assert(!id); + XRPL_ASSERT(!id); } } return adjusted; @@ -386,7 +386,7 @@ forEachItem( Keylet const& root, std::function const&)> const& f) { - assert(root.type == ltDIR_NODE); + XRPL_ASSERT(root.type == ltDIR_NODE); if (root.type != ltDIR_NODE) return; @@ -416,7 +416,7 @@ forEachItemAfter( unsigned int limit, std::function const&)> const& f) { - assert(root.type == ltDIR_NODE); + XRPL_ASSERT(root.type == ltDIR_NODE); if (root.type != ltDIR_NODE) return false; @@ -678,7 +678,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) auto const hashIndex = ledger.read(keylet::skip()); if (hashIndex) { - assert( + XRPL_ASSERT( hashIndex->getFieldU32(sfLastLedgerSequence) == (ledger.seq() - 1)); STVector256 vec = hashIndex->getFieldV256(sfHashes); @@ -708,8 +708,8 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) if (hashIndex) { auto const lastSeq = hashIndex->getFieldU32(sfLastLedgerSequence); - assert(lastSeq >= seq); - assert((lastSeq & 0xff) == 0); + XRPL_ASSERT(lastSeq >= seq); + XRPL_ASSERT((lastSeq & 0xff) == 0); auto const diff = (lastSeq - seq) >> 8; STVector256 vec = hashIndex->getFieldV256(sfHashes); if (vec.size() > diff) @@ -735,7 +735,7 @@ adjustOwnerCount( { if (!sle) return; - assert(amount != 0); + XRPL_ASSERT(amount != 0); std::uint32_t const current{sle->getFieldU32(sfOwnerCount)}; AccountID const id = (*sle)[sfAccount]; std::uint32_t const adjusted = confineOwnerCount(current, amount, id, j); @@ -800,11 +800,11 @@ trustCreate( const bool bSetDst = saLimit.getIssuer() == uDstAccountID; const bool bSetHigh = bSrcHigh ^ bSetDst; - assert(sleAccount); + XRPL_ASSERT(sleAccount); if (!sleAccount) return tefINTERNAL; - assert( + XRPL_ASSERT( sleAccount->getAccountID(sfAccount) == (bSetHigh ? uHighAccountID : uLowAccountID)); auto const slePeer = @@ -959,17 +959,17 @@ rippleCredit( Currency const& currency = saAmount.getCurrency(); // Make sure issuer is involved. - assert(!bCheckIssuer || uSenderID == issuer || uReceiverID == issuer); + XRPL_ASSERT(!bCheckIssuer || uSenderID == issuer || uReceiverID == issuer); (void)issuer; // Disallow sending to self. - assert(uSenderID != uReceiverID); + XRPL_ASSERT(uSenderID != uReceiverID); bool const bSenderHigh = uSenderID > uReceiverID; auto const index = keylet::line(uSenderID, uReceiverID, currency); - assert(!isXRP(uSenderID) && uSenderID != noAccount()); - assert(!isXRP(uReceiverID) && uReceiverID != noAccount()); + XRPL_ASSERT(!isXRP(uSenderID) && uSenderID != noAccount()); + XRPL_ASSERT(!isXRP(uReceiverID) && uReceiverID != noAccount()); // If the line exists, modify it accordingly. if (auto const sleRippleState = view.peek(index)) @@ -1103,8 +1103,8 @@ rippleSend( { auto const issuer = saAmount.getIssuer(); - assert(!isXRP(uSenderID) && !isXRP(uReceiverID)); - assert(uSenderID != uReceiverID); + XRPL_ASSERT(!isXRP(uSenderID) && !isXRP(uReceiverID)); + XRPL_ASSERT(uSenderID != uReceiverID); if (uSenderID == issuer || uReceiverID == issuer || issuer == noAccount()) { @@ -1156,7 +1156,7 @@ accountSend( } else { - assert(saAmount >= beast::zero); + XRPL_ASSERT(saAmount >= beast::zero); } /* If we aren't sending anything or if the sender is the same as the @@ -1317,13 +1317,13 @@ issueIOU( Issue const& issue, beast::Journal j) { - assert(!isXRP(account) && !isXRP(issue.account)); + XRPL_ASSERT(!isXRP(account) && !isXRP(issue.account)); // Consistency check - assert(issue == amount.issue()); + XRPL_ASSERT(issue == amount.issue()); // Can't send to self! - assert(issue.account != account); + XRPL_ASSERT(issue.account != account); JLOG(j.trace()) << "issueIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1413,13 +1413,13 @@ redeemIOU( Issue const& issue, beast::Journal j) { - assert(!isXRP(account) && !isXRP(issue.account)); + XRPL_ASSERT(!isXRP(account) && !isXRP(issue.account)); // Consistency check - assert(issue == amount.issue()); + XRPL_ASSERT(issue == amount.issue()); // Can't send to self! - assert(issue.account != account); + XRPL_ASSERT(issue.account != account); JLOG(j.trace()) << "redeemIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1483,10 +1483,10 @@ transferXRP( STAmount const& amount, beast::Journal j) { - assert(from != beast::zero); - assert(to != beast::zero); - assert(from != to); - assert(amount.native()); + XRPL_ASSERT(from != beast::zero); + XRPL_ASSERT(to != beast::zero); + XRPL_ASSERT(from != to); + XRPL_ASSERT(amount.native()); SLE::pointer const sender = view.peek(keylet::account(from)); SLE::pointer const receiver = view.peek(keylet::account(to)); @@ -1596,7 +1596,7 @@ cleanupOnAccountDelete( // // 3. So we verify that uDirEntry is indeed 'it'+1. Then we jam it // back to 'it' to "un-invalidate" the iterator. - assert(uDirEntry >= 1); + XRPL_ASSERT(uDirEntry >= 1); if (uDirEntry == 0) { JLOG(j.error()) diff --git a/src/ripple/net/impl/DatabaseBody.ipp b/src/ripple/net/impl/DatabaseBody.ipp index cdc7da2bc41..4b2dfd834d2 100644 --- a/src/ripple/net/impl/DatabaseBody.ipp +++ b/src/ripple/net/impl/DatabaseBody.ipp @@ -89,7 +89,7 @@ DatabaseBody::reader::init( boost::system::error_code& ec) { // The connection must already be available for writing - assert(body_.conn_); + XRPL_ASSERT(body_.conn_); // The error_code specification requires that we // either set the error to some value, or set it diff --git a/src/ripple/net/impl/DatabaseDownloader.cpp b/src/ripple/net/impl/DatabaseDownloader.cpp index eab0d74d7d9..dd91e212d9a 100644 --- a/src/ripple/net/impl/DatabaseDownloader.cpp +++ b/src/ripple/net/impl/DatabaseDownloader.cpp @@ -72,7 +72,7 @@ DatabaseDownloader::closeBody(std::shared_ptr p) auto databaseBodyParser = std::dynamic_pointer_cast>(p); - assert(databaseBodyParser); + XRPL_ASSERT(databaseBodyParser); databaseBodyParser->get().body().close(); } @@ -84,7 +84,7 @@ DatabaseDownloader::size(std::shared_ptr p) auto databaseBodyParser = std::dynamic_pointer_cast>(p); - assert(databaseBodyParser); + XRPL_ASSERT(databaseBodyParser); return databaseBodyParser->get().body().size(); } diff --git a/src/ripple/net/impl/HTTPStream.cpp b/src/ripple/net/impl/HTTPStream.cpp index d235767739d..5555c0910af 100644 --- a/src/ripple/net/impl/HTTPStream.cpp +++ b/src/ripple/net/impl/HTTPStream.cpp @@ -33,7 +33,7 @@ SSLStream::SSLStream( boost::asio::ip::tcp::socket& SSLStream::getStream() { - assert(stream_); + XRPL_ASSERT(stream_); return stream_->next_layer(); } @@ -126,7 +126,7 @@ RawStream::RawStream(boost::asio::io_service::strand& strand) : strand_(strand) boost::asio::ip::tcp::socket& RawStream::getStream() { - assert(stream_); + XRPL_ASSERT(stream_); return *stream_; } diff --git a/src/ripple/net/impl/InfoSub.cpp b/src/ripple/net/impl/InfoSub.cpp index 5b37cf0759b..b5d0305c1e9 100644 --- a/src/ripple/net/impl/InfoSub.cpp +++ b/src/ripple/net/impl/InfoSub.cpp @@ -145,7 +145,7 @@ InfoSub::setApiVersion(unsigned int apiVersion) unsigned int InfoSub::getApiVersion() const noexcept { - assert(apiVersion_ > 0); + XRPL_ASSERT(apiVersion_ > 0); return apiVersion_; } diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 8537f76b703..351f36d6afa 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -992,7 +992,7 @@ class RPCParser parseTransactionEntry(Json::Value const& jvParams) { // Parameter count should have already been verified. - assert(jvParams.size() == 2); + XRPL_ASSERT(jvParams.size() == 2); std::string const txHash = jvParams[0u].asString(); if (txHash.length() != 64) diff --git a/src/ripple/nodestore/Database.h b/src/ripple/nodestore/Database.h index 0f9e95b23e1..eecb144f3fb 100644 --- a/src/ripple/nodestore/Database.h +++ b/src/ripple/nodestore/Database.h @@ -256,7 +256,7 @@ class Database [[nodiscard]] std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const noexcept { - assert(shardIndex >= earliestShardIndex_); + XRPL_ASSERT(shardIndex >= earliestShardIndex_); if (shardIndex <= earliestShardIndex_) return earliestLedgerSeq_; return 1 + (shardIndex * ledgersPerShard_); @@ -270,7 +270,7 @@ class Database [[nodiscard]] std::uint32_t lastLedgerSeq(std::uint32_t shardIndex) const noexcept { - assert(shardIndex >= earliestShardIndex_); + XRPL_ASSERT(shardIndex >= earliestShardIndex_); return (shardIndex + 1) * ledgersPerShard_; } @@ -282,7 +282,7 @@ class Database [[nodiscard]] std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const noexcept { - assert(ledgerSeq >= earliestLedgerSeq_); + XRPL_ASSERT(ledgerSeq >= earliestLedgerSeq_); return (ledgerSeq - 1) / ledgersPerShard_; } @@ -332,7 +332,7 @@ class Database void storeStats(std::uint64_t count, std::uint64_t sz) { - assert(count <= sz); + XRPL_ASSERT(count <= sz); storeCount_ += count; storeSz_ += sz; } diff --git a/src/ripple/nodestore/backend/CassandraFactory.cpp b/src/ripple/nodestore/backend/CassandraFactory.cpp index d13cd71827b..984a1468c18 100644 --- a/src/ripple/nodestore/backend/CassandraFactory.cpp +++ b/src/ripple/nodestore/backend/CassandraFactory.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -164,7 +164,7 @@ class CassandraBackend : public Backend { if (open_) { - assert(false); + XRPL_UNREACHABLE(); JLOG(j_.error()) << "database is already open"; return; } @@ -342,7 +342,7 @@ class CassandraBackend : public Backend { std::this_thread::sleep_for(std::chrono::seconds(1)); session_.reset(cass_session_new()); - assert(session_); + XRPL_ASSERT(session_); fut = cass_session_connect_keyspace( session_.get(), cluster, keyspace.c_str()); @@ -625,7 +625,7 @@ class CassandraBackend : public Backend numHashes)); read(*cbs[i]); } - assert(results.size() == cbs.size()); + XRPL_ASSERT(results.size() == cbs.size()); std::unique_lock lck(mtx); cv.wait(lck, [&numFinished, &numHashes]() { @@ -789,7 +789,7 @@ class CassandraBackend : public Backend void for_each(std::function)> f) override { - assert(false); + XRPL_UNREACHABLE(); Throw("not implemented"); } diff --git a/src/ripple/nodestore/backend/MemoryFactory.cpp b/src/ripple/nodestore/backend/MemoryFactory.cpp index f82c14429ee..81fae64a76b 100644 --- a/src/ripple/nodestore/backend/MemoryFactory.cpp +++ b/src/ripple/nodestore/backend/MemoryFactory.cpp @@ -131,7 +131,7 @@ class MemoryBackend : public Backend Status fetch(void const* key, std::shared_ptr* pObject) override { - assert(db_); + XRPL_ASSERT(db_); uint256 const hash(uint256::fromVoid(key)); std::lock_guard _(db_->mutex); @@ -167,7 +167,7 @@ class MemoryBackend : public Backend void store(std::shared_ptr const& object) override { - assert(db_); + XRPL_ASSERT(db_); std::lock_guard _(db_->mutex); db_->table.emplace(object->getHash(), object); } @@ -187,7 +187,7 @@ class MemoryBackend : public Backend void for_each(std::function)> f) override { - assert(db_); + XRPL_ASSERT(db_); for (auto const& e : db_->table) f(e.second); } diff --git a/src/ripple/nodestore/backend/NuDBFactory.cpp b/src/ripple/nodestore/backend/NuDBFactory.cpp index 30b848e82af..e516e52fe50 100644 --- a/src/ripple/nodestore/backend/NuDBFactory.cpp +++ b/src/ripple/nodestore/backend/NuDBFactory.cpp @@ -18,13 +18,13 @@ //============================================================================== #include +#include #include #include #include #include #include #include -#include #include #include #include @@ -117,7 +117,7 @@ class NuDBBackend : public Backend using namespace boost::filesystem; if (db_.is_open()) { - assert(false); + XRPL_UNREACHABLE(); JLOG(j_.error()) << "database is already open"; return; } diff --git a/src/ripple/nodestore/backend/RocksDBFactory.cpp b/src/ripple/nodestore/backend/RocksDBFactory.cpp index b34560dba89..87470bbfdfa 100644 --- a/src/ripple/nodestore/backend/RocksDBFactory.cpp +++ b/src/ripple/nodestore/backend/RocksDBFactory.cpp @@ -228,7 +228,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback { if (m_db) { - assert(false); + XRPL_UNREACHABLE(); JLOG(m_journal.error()) << "database is already open"; return; } @@ -273,7 +273,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback Status fetch(void const* key, std::shared_ptr* pObject) override { - assert(m_db); + XRPL_ASSERT(m_db); pObject->reset(); Status status(ok); @@ -349,7 +349,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void storeBatch(Batch const& batch) override { - assert(m_db); + XRPL_ASSERT(m_db); rocksdb::WriteBatch wb; for (auto const& e : batch) @@ -381,7 +381,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void for_each(std::function)> f) override { - assert(m_db); + XRPL_ASSERT(m_db); rocksdb::ReadOptions const options; std::unique_ptr it(m_db->NewIterator(options)); diff --git a/src/ripple/nodestore/impl/BatchWriter.cpp b/src/ripple/nodestore/impl/BatchWriter.cpp index 692032016cc..56af1d2740f 100644 --- a/src/ripple/nodestore/impl/BatchWriter.cpp +++ b/src/ripple/nodestore/impl/BatchWriter.cpp @@ -83,7 +83,7 @@ BatchWriter::writeBatch() std::lock_guard sl(mWriteMutex); mWriteSet.swap(set); - assert(mWriteSet.empty()); + XRPL_ASSERT(mWriteSet.empty()); mWriteLoad = set.size(); if (set.empty()) diff --git a/src/ripple/nodestore/impl/Database.cpp b/src/ripple/nodestore/impl/Database.cpp index 70416c873d5..1402d2efcd8 100644 --- a/src/ripple/nodestore/impl/Database.cpp +++ b/src/ripple/nodestore/impl/Database.cpp @@ -46,7 +46,7 @@ Database::Database( , requestBundle_(get(config, "rq_bundle", 4)) , readThreads_(std::max(1, readThreads)) { - assert(readThreads != 0); + XRPL_ASSERT(readThreads != 0); if (ledgersPerShard_ == 0 || ledgersPerShard_ % 256 != 0) Throw("Invalid ledgers_per_shard"); @@ -96,7 +96,7 @@ Database::Database( for (auto it = read.begin(); it != read.end(); ++it) { - assert(!it->second.empty()); + XRPL_ASSERT(!it->second.empty()); auto const& hash = it->first; auto const& data = it->second; @@ -157,7 +157,7 @@ Database::maxLedgers(std::uint32_t shardIndex) const noexcept if (shardIndex == earliestShardIndex_) return lastLedgerSeq(shardIndex) - firstLedgerSeq(shardIndex) + 1; - assert(!"Invalid shard index"); + XRPL_ASSERT(!"Invalid shard index"); return 0; } @@ -183,7 +183,7 @@ Database::stop() while (readThreads_.load() != 0) { - assert(steady_clock::now() - start < 30s); + XRPL_ASSERT(steady_clock::now() - start < 30s); std::this_thread::yield(); } @@ -234,7 +234,7 @@ Database::importInternal(Backend& dstBackend, Database& srcDB) }; srcDB.for_each([&](std::shared_ptr nodeObject) { - assert(nodeObject); + XRPL_ASSERT(nodeObject); if (!nodeObject) // This should never happen return; @@ -377,7 +377,7 @@ Database::storeLedger( void Database::getCountsJson(Json::Value& obj) { - assert(obj.isObject()); + XRPL_ASSERT(obj.isObject()); { std::unique_lock lock(readLock_); diff --git a/src/ripple/nodestore/impl/DatabaseNodeImp.h b/src/ripple/nodestore/impl/DatabaseNodeImp.h index 452bd8d27fe..a806f4ee9d0 100644 --- a/src/ripple/nodestore/impl/DatabaseNodeImp.h +++ b/src/ripple/nodestore/impl/DatabaseNodeImp.h @@ -76,7 +76,7 @@ class DatabaseNodeImp : public Database j); } - assert(backend_); + XRPL_ASSERT(backend_); } ~DatabaseNodeImp() diff --git a/src/ripple/nodestore/impl/DatabaseShardImp.cpp b/src/ripple/nodestore/impl/DatabaseShardImp.cpp index 33000b5d24c..8714a63f781 100644 --- a/src/ripple/nodestore/impl/DatabaseShardImp.cpp +++ b/src/ripple/nodestore/impl/DatabaseShardImp.cpp @@ -233,7 +233,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (acquireIndex_ != 0) { @@ -241,7 +241,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) return it->second->prepare(); // Should never get here - assert(false); + XRPL_UNREACHABLE(); return std::nullopt; } @@ -325,7 +325,7 @@ DatabaseShardImp::prepareShards(std::vector const& shardIndexes) return fail("invalid shard indexes"); std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (!canAdd_) return fail("cannot be stored at this time"); @@ -417,7 +417,7 @@ void DatabaseShardImp::removePreShard(std::uint32_t shardIndex) { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (preparedIndexes_.erase(shardIndex)) updatePeers(lock); @@ -429,7 +429,7 @@ DatabaseShardImp::getPreShards() RangeSet rs; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); for (auto const& shardIndex : preparedIndexes_) rs.insert(shardIndex); @@ -557,7 +557,7 @@ DatabaseShardImp::fetchLedger(uint256 const& hash, std::uint32_t ledgerSeq) std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); auto const it{shards_.find(shardIndex)}; if (it == shards_.end()) @@ -661,7 +661,7 @@ DatabaseShardImp::setStored(std::shared_ptr const& ledger) std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (shardIndex != acquireIndex_) { @@ -766,14 +766,14 @@ void DatabaseShardImp::importDatabase(Database& source) { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); // Only the application local node store can be imported - assert(&source == &app_.getNodeStore()); + XRPL_ASSERT(&source == &app_.getNodeStore()); if (databaseImporter_.joinable()) { - assert(false); + XRPL_UNREACHABLE(); JLOG(j_.error()) << "database import already in progress"; return; } @@ -865,7 +865,7 @@ DatabaseShardImp::doImportDatabase() { std::lock_guard lock(mutex_); - assert(!databaseImportStatus_); + XRPL_ASSERT(!databaseImportStatus_); databaseImportStatus_ = std::make_unique( earliestIndex, latestIndex, 0); } @@ -1088,7 +1088,7 @@ DatabaseShardImp::getWriteLoad() const std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); auto const it{shards_.find(acquireIndex_)}; if (it == shards_.end()) @@ -1141,7 +1141,7 @@ DatabaseShardImp::storeLedger(std::shared_ptr const& srcLedger) std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (shardIndex != acquireIndex_) { @@ -1174,7 +1174,7 @@ DatabaseShardImp::sweep() std::vector> shards; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); shards.reserve(shards_.size()); for (auto const& e : shards_) @@ -1460,7 +1460,7 @@ DatabaseShardImp::findAcquireIndex( } } - assert(false); + XRPL_UNREACHABLE(); return std::nullopt; } @@ -1515,7 +1515,8 @@ DatabaseShardImp::finalizeShard( else { // Not a historical shard. Shift recent shards if necessary - assert(!boundaryIndex || shard->index() - boundaryIndex <= 1); + XRPL_ASSERT( + !boundaryIndex || shard->index() - boundaryIndex <= 1); relocateOutdatedShards(lock); // Set the appropriate recent shard index diff --git a/src/ripple/nodestore/impl/DecodedBlob.cpp b/src/ripple/nodestore/impl/DecodedBlob.cpp index 13175d36295..26b792cf074 100644 --- a/src/ripple/nodestore/impl/DecodedBlob.cpp +++ b/src/ripple/nodestore/impl/DecodedBlob.cpp @@ -17,10 +17,10 @@ */ //============================================================================== +#include #include #include #include -#include namespace ripple { namespace NodeStore { @@ -72,7 +72,7 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) std::shared_ptr DecodedBlob::createObject() { - assert(m_success); + XRPL_ASSERT(m_success); std::shared_ptr object; diff --git a/src/ripple/nodestore/impl/EncodedBlob.h b/src/ripple/nodestore/impl/EncodedBlob.h index 77f8fbf3c6c..c1be81df21f 100644 --- a/src/ripple/nodestore/impl/EncodedBlob.h +++ b/src/ripple/nodestore/impl/EncodedBlob.h @@ -21,11 +21,11 @@ #define RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED #include +#include #include #include #include #include -#include #include namespace ripple { @@ -80,7 +80,7 @@ class EncodedBlob public: explicit EncodedBlob(std::shared_ptr const& obj) : size_([&obj]() { - assert(obj); + XRPL_ASSERT(obj); if (!obj) throw std::runtime_error( @@ -100,7 +100,7 @@ class EncodedBlob ~EncodedBlob() { - assert( + XRPL_ASSERT( ((ptr_ == payload_.data()) && (size_ <= payload_.size())) || ((ptr_ != payload_.data()) && (size_ > payload_.size()))); diff --git a/src/ripple/nodestore/impl/ManagerImp.cpp b/src/ripple/nodestore/impl/ManagerImp.cpp index d5ea29059df..163f89e3159 100644 --- a/src/ripple/nodestore/impl/ManagerImp.cpp +++ b/src/ripple/nodestore/impl/ManagerImp.cpp @@ -97,7 +97,7 @@ ManagerImp::erase(Factory& factory) std::find_if(list_.begin(), list_.end(), [&factory](Factory* other) { return other == &factory; }); - assert(iter != list_.end()); + XRPL_ASSERT(iter != list_.end()); list_.erase(iter); } diff --git a/src/ripple/nodestore/impl/Shard.cpp b/src/ripple/nodestore/impl/Shard.cpp index 10adf298361..960cc05f4b3 100644 --- a/src/ripple/nodestore/impl/Shard.cpp +++ b/src/ripple/nodestore/impl/Shard.cpp @@ -711,7 +711,7 @@ Shard::finalize(bool writeSQLite, std::optional const& referenceHash) if (writeSQLite && !storeSQLite(ledger)) return fail("failed storing to SQLite databases"); - assert( + XRPL_ASSERT( ledger->info().seq == ledgerSeq && (ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees()))); @@ -813,7 +813,7 @@ Shard::finalize(bool writeSQLite, std::optional const& referenceHash) if (!open(lock)) return fail("failed to open"); - assert(state_ == ShardState::finalized); + XRPL_ASSERT(state_ == ShardState::finalized); // Allow all other threads work with the shard busy_ = false; diff --git a/src/ripple/nodestore/impl/TaskQueue.cpp b/src/ripple/nodestore/impl/TaskQueue.cpp index 90b6ba3451a..1e6f16bd9aa 100644 --- a/src/ripple/nodestore/impl/TaskQueue.cpp +++ b/src/ripple/nodestore/impl/TaskQueue.cpp @@ -17,10 +17,8 @@ */ //============================================================================== +#include #include - -#include - namespace ripple { namespace NodeStore { @@ -59,7 +57,7 @@ TaskQueue::processTask(int instance) { std::lock_guard lock{mutex_}; - assert(!tasks_.empty()); + XRPL_ASSERT(!tasks_.empty()); task = std::move(tasks_.front()); tasks_.pop(); diff --git a/src/ripple/overlay/Compression.h b/src/ripple/overlay/Compression.h index 6bb94792b43..4efdf5b4ce8 100644 --- a/src/ripple/overlay/Compression.h +++ b/src/ripple/overlay/Compression.h @@ -64,7 +64,7 @@ decompress( JLOG(debugLog().warn()) << "decompress: invalid compression algorithm " << static_cast(algorithm); - assert(0); + XRPL_ASSERT(0); } } catch (...) @@ -99,7 +99,7 @@ compress( { JLOG(debugLog().warn()) << "compress: invalid compression algorithm" << static_cast(algorithm); - assert(0); + XRPL_ASSERT(0); } } catch (...) diff --git a/src/ripple/overlay/Slot.h b/src/ripple/overlay/Slot.h index e58619e66f8..7cf0623182f 100644 --- a/src/ripple/overlay/Slot.h +++ b/src/ripple/overlay/Slot.h @@ -362,7 +362,7 @@ Slot::update( << consideredPoolSize << " selected " << *s << " " << *std::next(s, 1) << " " << *std::next(s, 2); - assert(peers_.size() >= MAX_SELECTED_PEERS); + XRPL_ASSERT(peers_.size() >= MAX_SELECTED_PEERS); // squelch peers which are not selected and // not already squelched diff --git a/src/ripple/overlay/impl/ConnectAttempt.cpp b/src/ripple/overlay/impl/ConnectAttempt.cpp index f1d1c6ffe00..38cf4b2efcb 100644 --- a/src/ripple/overlay/impl/ConnectAttempt.cpp +++ b/src/ripple/overlay/impl/ConnectAttempt.cpp @@ -90,7 +90,7 @@ ConnectAttempt::run() void ConnectAttempt::close() { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); if (socket_.is_open()) { error_code ec; diff --git a/src/ripple/overlay/impl/Message.cpp b/src/ripple/overlay/impl/Message.cpp index b4cb1f192aa..325c373545b 100644 --- a/src/ripple/overlay/impl/Message.cpp +++ b/src/ripple/overlay/impl/Message.cpp @@ -34,7 +34,7 @@ Message::Message( auto const messageBytes = messageSize(message); - assert(messageBytes != 0); + XRPL_ASSERT(messageBytes != 0); buffer_.resize(headerBytes + messageBytes); @@ -43,7 +43,7 @@ Message::Message( if (messageBytes != 0) message.SerializeToArray(buffer_.data() + headerBytes, messageBytes); - assert(getBufferSize() == totalSize(message)); + XRPL_ASSERT(getBufferSize() == totalSize(message)); } // static diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 1bb9a381edd..4a47d8554d1 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -296,7 +296,7 @@ OverlayImpl::onHandoff( std::lock_guard lock(mutex_); { auto const result = m_peers.emplace(peer->slot(), peer); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } list_.emplace(peer.get(), peer); @@ -389,7 +389,7 @@ OverlayImpl::makeErrorResponse( void OverlayImpl::connect(beast::IP::Endpoint const& remote_endpoint) { - assert(work_); + XRPL_ASSERT(work_); auto usage = resourceManager().newOutboundEndpoint(remote_endpoint); if (usage.disconnect(journal_)) @@ -431,7 +431,7 @@ OverlayImpl::add_active(std::shared_ptr const& peer) { auto const result = m_peers.emplace(peer->slot(), peer); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } @@ -440,7 +440,7 @@ OverlayImpl::add_active(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer)); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } @@ -463,7 +463,7 @@ OverlayImpl::remove(std::shared_ptr const& slot) { std::lock_guard lock(mutex_); auto const iter = m_peers.find(slot); - assert(iter != m_peers.end()); + XRPL_ASSERT(iter != m_peers.end()); m_peers.erase(iter); } @@ -597,7 +597,7 @@ OverlayImpl::activate(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer))); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } @@ -608,7 +608,7 @@ OverlayImpl::activate(std::shared_ptr const& peer) << ")"; // We just accepted this peer so we have non-zero active peers - assert(size() != 0); + XRPL_ASSERT(size() != 0); } void @@ -647,7 +647,7 @@ OverlayImpl::onManifests( // the loaded Manifest out of the optional so we need to // reload it here. mo = deserializeManifest(serialized); - assert(mo); + XRPL_ASSERT(mo); app_.getOPs().pubManifest(*mo); diff --git a/src/ripple/overlay/impl/OverlayImpl.h b/src/ripple/overlay/impl/OverlayImpl.h index 2ba7999cbe0..618dfa0bd4a 100644 --- a/src/ripple/overlay/impl/OverlayImpl.h +++ b/src/ripple/overlay/impl/OverlayImpl.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -616,7 +616,7 @@ class OverlayImpl : public Overlay, public reduce_relay::SquelchHandler { auto counts = m_traffic.getCounts(); std::lock_guard lock(m_statsMutex); - assert(counts.size() == m_stats.trafficGauges.size()); + XRPL_ASSERT(counts.size() == m_stats.trafficGauges.size()); for (std::size_t i = 0; i < counts.size(); ++i) { diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index f93c9f135ad..9c88ce09b1e 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -577,7 +577,7 @@ PeerImp::hasRange(std::uint32_t uMin, std::uint32_t uMax) void PeerImp::close() { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); if (socket_.is_open()) { detaching_ = true; // DEPRECATED @@ -618,7 +618,7 @@ PeerImp::fail(std::string const& reason) void PeerImp::fail(std::string const& name, error_code ec) { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); if (socket_.is_open()) { JLOG(journal_.warn()) @@ -638,9 +638,9 @@ PeerImp::getPeerShardInfos() const void PeerImp::gracefulClose() { - assert(strand_.running_in_this_thread()); - assert(socket_.is_open()); - assert(!gracefulClose_); + XRPL_ASSERT(strand_.running_in_this_thread()); + XRPL_ASSERT(socket_.is_open()); + XRPL_ASSERT(!gracefulClose_); gracefulClose_ = true; if (send_queue_.size() > 0) return; @@ -766,7 +766,7 @@ PeerImp::onShutdown(error_code ec) void PeerImp::doAccept() { - assert(read_buffer_.size() == 0); + XRPL_ASSERT(read_buffer_.size() == 0); JLOG(journal_.debug()) << "doAccept: " << remote_address_; @@ -964,7 +964,7 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred) metrics_.sent.add_message(bytes_transferred); - assert(!send_queue_.empty()); + XRPL_ASSERT(!send_queue_.empty()); send_queue_.pop(); if (!send_queue_.empty()) { @@ -2321,13 +2321,13 @@ PeerImp::onValidatorListMessage( case ListDisposition::pending: { std::lock_guard sl(recentLock_); - assert(applyResult.publisherKey); + XRPL_ASSERT(applyResult.publisherKey); auto const& pubKey = *applyResult.publisherKey; #ifndef NDEBUG if (auto const iter = publisherListSequences_.find(pubKey); iter != publisherListSequences_.end()) { - assert(iter->second < applyResult.sequence); + XRPL_ASSERT(iter->second < applyResult.sequence); } #endif publisherListSequences_[pubKey] = applyResult.sequence; @@ -2338,8 +2338,8 @@ PeerImp::onValidatorListMessage( #ifndef NDEBUG { std::lock_guard sl(recentLock_); - assert(applyResult.sequence && applyResult.publisherKey); - assert( + XRPL_ASSERT(applyResult.sequence && applyResult.publisherKey); + XRPL_ASSERT( publisherListSequences_[*applyResult.publisherKey] <= applyResult.sequence); } @@ -2352,7 +2352,7 @@ PeerImp::onValidatorListMessage( case ListDisposition::unsupported_version: break; default: - assert(false); + XRPL_UNREACHABLE(); } // Charge based on the worst result @@ -2391,7 +2391,7 @@ PeerImp::onValidatorListMessage( fee_ = Resource::feeBadData; break; default: - assert(false); + XRPL_UNREACHABLE(); } // Log based on all the results. @@ -2449,7 +2449,7 @@ PeerImp::onValidatorListMessage( << "(s) from peer " << remote_address_; break; default: - assert(false); + XRPL_UNREACHABLE(); } } } @@ -3132,7 +3132,7 @@ PeerImp::checkPropose( JLOG(p_journal_.trace()) << "Checking " << (isTrusted ? "trusted" : "UNTRUSTED") << " proposal"; - assert(packet); + XRPL_ASSERT(packet); if (!cluster() && !peerPos.checkSign()) { diff --git a/src/ripple/overlay/impl/ProtocolMessage.h b/src/ripple/overlay/impl/ProtocolMessage.h index d6fb14bc78c..b54ce595ae1 100644 --- a/src/ripple/overlay/impl/ProtocolMessage.h +++ b/src/ripple/overlay/impl/ProtocolMessage.h @@ -21,6 +21,7 @@ #define RIPPLE_OVERLAY_PROTOCOLMESSAGE_H_INCLUDED #include +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -183,7 +183,7 @@ parseMessageHeader( MessageHeader hdr; auto iter = buffersBegin(bufs); - assert(iter != buffersEnd(bufs)); + XRPL_ASSERT(iter != buffersEnd(bufs)); // Check valid header compressed message: // - 4 bits are the compression algorithm, 1st bit is always set to 1 diff --git a/src/ripple/overlay/impl/TrafficCount.h b/src/ripple/overlay/impl/TrafficCount.h index 9e212da7917..d9a77438983 100644 --- a/src/ripple/overlay/impl/TrafficCount.h +++ b/src/ripple/overlay/impl/TrafficCount.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_OVERLAY_TRAFFIC_H_INCLUDED #define RIPPLE_OVERLAY_TRAFFIC_H_INCLUDED +#include #include #include @@ -172,7 +173,7 @@ class TrafficCount void addCount(category cat, bool inbound, int bytes) { - assert(cat <= category::unknown); + XRPL_ASSERT(cat <= category::unknown); if (inbound) { diff --git a/src/ripple/overlay/impl/ZeroCopyStream.h b/src/ripple/overlay/impl/ZeroCopyStream.h index da0f0d380d8..40a37b5845f 100644 --- a/src/ripple/overlay/impl/ZeroCopyStream.h +++ b/src/ripple/overlay/impl/ZeroCopyStream.h @@ -204,7 +204,7 @@ template void ZeroCopyOutputStream::BackUp(int count) { - assert(count <= commit_); + XRPL_ASSERT(count <= commit_); auto const n = commit_ - count; streambuf_.commit(n); count_ += n; diff --git a/src/ripple/peerfinder/impl/Bootcache.cpp b/src/ripple/peerfinder/impl/Bootcache.cpp index a07c53417d2..3bdaeeffc38 100644 --- a/src/ripple/peerfinder/impl/Bootcache.cpp +++ b/src/ripple/peerfinder/impl/Bootcache.cpp @@ -159,7 +159,7 @@ Bootcache::on_success(beast::IP::Endpoint const& endpoint) ++entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - assert(result.second); + XRPL_ASSERT(result.second); } Entry const& entry(result.first->right); JLOG(m_journal.info()) << beast::leftw(18) << "Bootcache connect " @@ -185,7 +185,7 @@ Bootcache::on_failure(beast::IP::Endpoint const& endpoint) --entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - assert(result.second); + XRPL_ASSERT(result.second); } Entry const& entry(result.first->right); auto const n(std::abs(entry.valence())); diff --git a/src/ripple/peerfinder/impl/Counts.h b/src/ripple/peerfinder/impl/Counts.h index 5d9e318594f..9b0e024e89a 100644 --- a/src/ripple/peerfinder/impl/Counts.h +++ b/src/ripple/peerfinder/impl/Counts.h @@ -71,7 +71,7 @@ class Counts can_activate(Slot const& s) const { // Must be handshaked and in the right state - assert(s.state() == Slot::connected || s.state() == Slot::accept); + XRPL_ASSERT(s.state() == Slot::connected || s.state() == Slot::accept); if (s.fixed() || s.reserved()) return true; @@ -262,13 +262,13 @@ class Counts switch (s.state()) { case Slot::accept: - assert(s.inbound()); + XRPL_ASSERT(s.inbound()); m_acceptCount += n; break; case Slot::connect: case Slot::connected: - assert(!s.inbound()); + XRPL_ASSERT(!s.inbound()); m_attempts += n; break; @@ -290,7 +290,7 @@ class Counts break; default: - assert(false); + XRPL_UNREACHABLE(); break; }; } diff --git a/src/ripple/peerfinder/impl/Handouts.h b/src/ripple/peerfinder/impl/Handouts.h index 00e163bbeaa..074d93c9e02 100644 --- a/src/ripple/peerfinder/impl/Handouts.h +++ b/src/ripple/peerfinder/impl/Handouts.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PEERFINDER_HANDOUTS_H_INCLUDED #define RIPPLE_PEERFINDER_HANDOUTS_H_INCLUDED +#include #include #include #include -#include #include #include @@ -43,7 +43,7 @@ template std::size_t handout_one(Target& t, HopContainer& h) { - assert(!t.full()); + XRPL_ASSERT(!t.full()); for (auto it = h.begin(); it != h.end(); ++it) { auto const& e = *it; diff --git a/src/ripple/peerfinder/impl/Livecache.h b/src/ripple/peerfinder/impl/Livecache.h index 8ecd68e845e..d3e780a114d 100644 --- a/src/ripple/peerfinder/impl/Livecache.h +++ b/src/ripple/peerfinder/impl/Livecache.h @@ -432,7 +432,7 @@ Livecache::insert(Endpoint const& ep) // but we will use it to make connections and hand it out // when redirecting. // - assert(ep.hops <= (Tuning::maxHops + 1)); + XRPL_ASSERT(ep.hops <= (Tuning::maxHops + 1)); auto result = m_cache.emplace(ep.address, ep); Element& e(result.first->second); if (result.second) @@ -530,7 +530,7 @@ template void Livecache::hops_t::insert(Element& e) { - assert(e.endpoint.hops <= Tuning::maxHops + 1); + XRPL_ASSERT(e.endpoint.hops <= Tuning::maxHops + 1); // This has security implications without a shuffle m_lists[e.endpoint.hops].push_front(e); ++m_hist[e.endpoint.hops]; @@ -540,7 +540,7 @@ template void Livecache::hops_t::reinsert(Element& e, std::uint32_t numHops) { - assert(numHops <= Tuning::maxHops + 1); + XRPL_ASSERT(numHops <= Tuning::maxHops + 1); auto& list = m_lists[e.endpoint.hops]; list.erase(list.iterator_to(e)); diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h index 7a2b6a7543a..3edc22e1d99 100644 --- a/src/ripple/peerfinder/impl/Logic.h +++ b/src/ripple/peerfinder/impl/Logic.h @@ -305,7 +305,7 @@ class Logic // Add slot to table auto const result(slots_.emplace(slot->remote_endpoint(), slot)); // Remote address must not already exist - assert(result.second); + XRPL_ASSERT(result.second); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -340,7 +340,7 @@ class Logic // Add slot to table auto const result = slots_.emplace(slot->remote_endpoint(), slot); // Remote address must not already exist - assert(result.second); + XRPL_ASSERT(result.second); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -363,7 +363,7 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - assert(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); // Assign the local endpoint now that it's known slot->local_endpoint(local_endpoint); @@ -372,7 +372,7 @@ class Logic auto const iter(slots_.find(local_endpoint)); if (iter != slots_.end()) { - assert( + XRPL_ASSERT( iter->second->local_endpoint() == slot->remote_endpoint()); JLOG(m_journal.warn()) << beast::leftw(18) << "Logic dropping " @@ -398,9 +398,9 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - assert(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); // Must be accepted or connected - assert( + XRPL_ASSERT( slot->state() == Slot::accept || slot->state() == Slot::connected); // Check for duplicate connection by key @@ -427,7 +427,7 @@ class Logic { [[maybe_unused]] bool const inserted = keys_.insert(key).second; // Public key must not already exist - assert(inserted); + XRPL_ASSERT(inserted); } // Change state and update counts @@ -789,10 +789,10 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - assert(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); // Must be handshaked! - assert(slot->state() == Slot::active); + XRPL_ASSERT(slot->state() == Slot::active); clock_type::time_point const now(m_clock.now()); @@ -804,7 +804,7 @@ class Logic for (auto const& ep : list) { - assert(ep.hops != 0); + XRPL_ASSERT(ep.hops != 0); slot->recent.insert(ep.address, ep.hops); @@ -957,7 +957,7 @@ class Logic break; default: - assert(false); + XRPL_UNREACHABLE(); break; } } diff --git a/src/ripple/peerfinder/impl/SlotImp.cpp b/src/ripple/peerfinder/impl/SlotImp.cpp index c41aeb9d5d8..1d5802a8d47 100644 --- a/src/ripple/peerfinder/impl/SlotImp.cpp +++ b/src/ripple/peerfinder/impl/SlotImp.cpp @@ -64,19 +64,19 @@ void SlotImp::state(State state_) { // Must go through activate() to set active state - assert(state_ != active); + XRPL_ASSERT(state_ != active); // The state must be different - assert(state_ != m_state); + XRPL_ASSERT(state_ != m_state); // You can't transition into the initial states - assert(state_ != accept && state_ != connect); + XRPL_ASSERT(state_ != accept && state_ != connect); // Can only become connected from outbound connect state - assert(state_ != connected || (!m_inbound && m_state == connect)); + XRPL_ASSERT(state_ != connected || (!m_inbound && m_state == connect)); // Can't gracefully close on an outbound connection attempt - assert(state_ != closing || m_state != connect); + XRPL_ASSERT(state_ != closing || m_state != connect); m_state = state_; } @@ -85,7 +85,7 @@ void SlotImp::activate(clock_type::time_point const& now) { // Can only become active from the accept or connected state - assert(m_state == accept || m_state == connected); + XRPL_ASSERT(m_state == accept || m_state == connected); m_state = active; whenAcceptEndpoints = now; diff --git a/src/ripple/perflog/impl/PerfLogImp.cpp b/src/ripple/perflog/impl/PerfLogImp.cpp index 3d07d0ed625..da3870742d5 100644 --- a/src/ripple/perflog/impl/PerfLogImp.cpp +++ b/src/ripple/perflog/impl/PerfLogImp.cpp @@ -55,7 +55,7 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - assert(false); + XRPL_UNREACHABLE(); } } } @@ -68,7 +68,7 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - assert(false); + XRPL_UNREACHABLE(); } } } @@ -330,7 +330,7 @@ PerfLogImp::rpcStart(std::string const& method, std::uint64_t const requestId) auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } @@ -352,7 +352,7 @@ PerfLogImp::rpcEnd( auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } steady_time_point startTime; @@ -366,7 +366,7 @@ PerfLogImp::rpcEnd( } else { - assert(false); + XRPL_UNREACHABLE(); } } std::lock_guard lock(counter->second.mutex); @@ -384,7 +384,7 @@ PerfLogImp::jobQueue(JobType const type) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } std::lock_guard lock(counter->second.mutex); @@ -401,7 +401,7 @@ PerfLogImp::jobStart( auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } { @@ -420,7 +420,7 @@ PerfLogImp::jobFinish(JobType const type, microseconds dur, int instance) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } { diff --git a/src/ripple/protocol/AmountConversions.h b/src/ripple/protocol/AmountConversions.h index dc0defe6972..9f07ea6c93d 100644 --- a/src/ripple/protocol/AmountConversions.h +++ b/src/ripple/protocol/AmountConversions.h @@ -59,7 +59,7 @@ toSTAmount(XRPAmount const& xrp) inline STAmount toSTAmount(XRPAmount const& xrp, Issue const& iss) { - assert(isXRP(iss.account) && isXRP(iss.currency)); + XRPL_ASSERT(isXRP(iss.account) && isXRP(iss.currency)); return toSTAmount(xrp); } @@ -78,12 +78,12 @@ template <> inline IOUAmount toAmount(STAmount const& amt) { - assert(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - assert(!isXRP(amt)); + XRPL_ASSERT(!isXRP(amt)); return IOUAmount(sMant, amt.exponent()); } @@ -91,12 +91,12 @@ template <> inline XRPAmount toAmount(STAmount const& amt) { - assert(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - assert(isXRP(amt)); + XRPL_ASSERT(isXRP(amt)); return XRPAmount(sMant); } diff --git a/src/ripple/protocol/Feature.h b/src/ripple/protocol/Feature.h index 91cf4d97ca4..9713bacd836 100644 --- a/src/ripple/protocol/Feature.h +++ b/src/ripple/protocol/Feature.h @@ -145,14 +145,14 @@ class FeatureBitset : private std::bitset explicit FeatureBitset(base const& b) : base(b) { - assert(b.count() == count()); + XRPL_ASSERT(b.count() == count()); } template explicit FeatureBitset(uint256 const& f, Fs&&... fs) { initFromFeatures(f, std::forward(fs)...); - assert(count() == (sizeof...(fs) + 1)); + XRPL_ASSERT(count() == (sizeof...(fs) + 1)); } template @@ -160,7 +160,7 @@ class FeatureBitset : private std::bitset { for (auto const& f : fs) set(featureToBitsetIndex(f)); - assert(fs.size() == count()); + XRPL_ASSERT(fs.size() == count()); } auto diff --git a/src/ripple/protocol/Indexes.h b/src/ripple/protocol/Indexes.h index d83599f892f..85b67bc2dc5 100644 --- a/src/ripple/protocol/Indexes.h +++ b/src/ripple/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 { - assert(root.type == ltDIR_NODE); + XRPL_ASSERT(root.type == ltDIR_NODE); return page(root.key, index); } /** @} */ diff --git a/src/ripple/protocol/Issue.h b/src/ripple/protocol/Issue.h index 1956b942e2b..dfd19b26d8c 100644 --- a/src/ripple/protocol/Issue.h +++ b/src/ripple/protocol/Issue.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_ISSUE_H_INCLUDED #define RIPPLE_PROTOCOL_ISSUE_H_INCLUDED +#include #include #include -#include #include #include diff --git a/src/ripple/protocol/MultiApiJson.h b/src/ripple/protocol/MultiApiJson.h index b6d1843ae69..9b216c62822 100644 --- a/src/ripple/protocol/MultiApiJson.h +++ b/src/ripple/protocol/MultiApiJson.h @@ -23,8 +23,8 @@ #include #include +#include #include -#include #include #include #include @@ -158,7 +158,7 @@ struct MultiApiJson -> std:: invoke_result_t { - assert( + XRPL_ASSERT( 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 { - assert( + XRPL_ASSERT( valid(version) && index(version) >= 0 && index(version) < size); return std::invoke(fn, json.val[index(version)]); } diff --git a/src/ripple/protocol/Quality.h b/src/ripple/protocol/Quality.h index 06b8254df5e..f16b2131747 100644 --- a/src/ripple/protocol/Quality.h +++ b/src/ripple/protocol/Quality.h @@ -298,7 +298,7 @@ class Quality friend double relativeDistance(Quality const& q1, Quality const& q2) { - assert(q1.m_value > 0 && q2.m_value > 0); + XRPL_ASSERT(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/src/ripple/protocol/Rate.h b/src/ripple/protocol/Rate.h index 3524eabb627..76dd7b9ca82 100644 --- a/src/ripple/protocol/Rate.h +++ b/src/ripple/protocol/Rate.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_RATE_H_INCLUDED #define RIPPLE_PROTOCOL_RATE_H_INCLUDED +#include #include #include -#include #include #include diff --git a/src/ripple/protocol/STBitString.h b/src/ripple/protocol/STBitString.h index decdfa64861..8eae8352008 100644 --- a/src/ripple/protocol/STBitString.h +++ b/src/ripple/protocol/STBitString.h @@ -162,8 +162,8 @@ template void STBitString::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == getSType()); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == getSType()); s.addBitString(value_); } diff --git a/src/ripple/protocol/STBlob.h b/src/ripple/protocol/STBlob.h index 3b2731be7f0..7eb33bf9579 100644 --- a/src/ripple/protocol/STBlob.h +++ b/src/ripple/protocol/STBlob.h @@ -23,9 +23,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/src/ripple/protocol/STInteger.h b/src/ripple/protocol/STInteger.h index aaf0f8c904e..33d945e27e2 100644 --- a/src/ripple/protocol/STInteger.h +++ b/src/ripple/protocol/STInteger.h @@ -110,8 +110,8 @@ template inline void STInteger::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == getSType()); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == getSType()); s.addInteger(value_); } diff --git a/src/ripple/protocol/STObject.h b/src/ripple/protocol/STObject.h index 38678f67a55..1f0e99c8308 100644 --- a/src/ripple/protocol/STObject.h +++ b/src/ripple/protocol/STObject.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -716,7 +716,7 @@ STObject::Proxy::assign(U&& u) t = dynamic_cast(st_->getPField(*f_, true)); else t = dynamic_cast(st_->makeFieldPresent(*f_)); - assert(t); + XRPL_ASSERT(t); *t = std::forward(u); } @@ -994,13 +994,13 @@ STObject::at(TypedField const& f) const if (auto const u = dynamic_cast(b)) return u->value(); - assert(mType); - assert(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT(mType); + XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); if (mType->style(f) == soeOPTIONAL) Throw("Missing optional field: " + f.getName()); - assert(mType->style(f) == soeDEFAULT); + XRPL_ASSERT(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. @@ -1018,11 +1018,11 @@ STObject::at(OptionaledField const& of) const auto const u = dynamic_cast(b); if (!u) { - assert(mType); - assert(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT(mType); + XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); if (mType->style(*of.f) == soeOPTIONAL) return std::nullopt; - assert(mType->style(*of.f) == soeDEFAULT); + XRPL_ASSERT(mType->style(*of.f) == soeDEFAULT); return typename T::value_type{}; } return u->value(); diff --git a/src/ripple/protocol/STPathSet.h b/src/ripple/protocol/STPathSet.h index 8102bc76eb0..af83386e9ec 100644 --- a/src/ripple/protocol/STPathSet.h +++ b/src/ripple/protocol/STPathSet.h @@ -21,11 +21,11 @@ #define RIPPLE_PROTOCOL_STPATHSET_H_INCLUDED #include +#include #include #include #include #include -#include #include #include @@ -257,7 +257,7 @@ inline STPathElement::STPathElement( is_offer_ = false; mAccountID = *account; mType |= typeAccount; - assert(mAccountID != noAccount()); + XRPL_ASSERT(mAccountID != noAccount()); } if (currency) @@ -270,7 +270,7 @@ inline STPathElement::STPathElement( { mIssuerID = *issuer; mType |= typeIssuer; - assert(mIssuerID != noAccount()); + XRPL_ASSERT(mIssuerID != noAccount()); } hash_value_ = get_hash(*this); diff --git a/src/ripple/protocol/STValidation.h b/src/ripple/protocol/STValidation.h index edd922e7bfa..c6967649371 100644 --- a/src/ripple/protocol/STValidation.h +++ b/src/ripple/protocol/STValidation.h @@ -22,10 +22,10 @@ #include #include +#include #include #include #include -#include #include #include #include @@ -176,7 +176,7 @@ STValidation::STValidation( Throw("Invalid signature in validation"); } - assert(nodeID_.isNonZero()); + XRPL_ASSERT(nodeID_.isNonZero()); } /** Construct, sign and trust a new STValidation issued by this node. @@ -199,7 +199,7 @@ STValidation::STValidation( , nodeID_(nodeID) , seenTime_(signTime) { - assert(nodeID_.isNonZero()); + XRPL_ASSERT(nodeID_.isNonZero()); // First, set our own public key: if (publicKeyType(pk) != KeyType::secp256k1) diff --git a/src/ripple/protocol/Serializer.h b/src/ripple/protocol/Serializer.h index e3ef00eaf65..a1a2074a572 100644 --- a/src/ripple/protocol/Serializer.h +++ b/src/ripple/protocol/Serializer.h @@ -25,11 +25,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -55,7 +55,7 @@ class Serializer if (size) { - assert(data != nullptr); + XRPL_ASSERT(data != nullptr); std::memcpy(mData.data(), data, size); } } @@ -300,7 +300,7 @@ Serializer::addVL(Iter begin, Iter end, int len) len -= begin->size(); #endif } - assert(len == 0); + XRPL_ASSERT(len == 0); return ret; } diff --git a/src/ripple/protocol/TxMeta.h b/src/ripple/protocol/TxMeta.h index 0a6578b1930..64825a94330 100644 --- a/src/ripple/protocol/TxMeta.h +++ b/src/ripple/protocol/TxMeta.h @@ -116,7 +116,7 @@ class TxMeta STAmount getDeliveredAmount() const { - assert(hasDeliveredAmount()); + XRPL_ASSERT(hasDeliveredAmount()); return *mDelivered; } diff --git a/src/ripple/protocol/impl/AMMCore.cpp b/src/ripple/protocol/impl/AMMCore.cpp index b774ee4ee3b..1968d902639 100644 --- a/src/ripple/protocol/impl/AMMCore.cpp +++ b/src/ripple/protocol/impl/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]; - assert(expiration >= TOTAL_TIME_SLOT_SECS); + XRPL_ASSERT(expiration >= TOTAL_TIME_SLOT_SECS); if (expiration >= TOTAL_TIME_SLOT_SECS) { if (auto const start = expiration - TOTAL_TIME_SLOT_SECS; diff --git a/src/ripple/protocol/impl/AccountID.cpp b/src/ripple/protocol/impl/AccountID.cpp index c615807cf84..3ae38044367 100644 --- a/src/ripple/protocol/impl/AccountID.cpp +++ b/src/ripple/protocol/impl/AccountID.cpp @@ -77,7 +77,7 @@ class AccountIdCache auto ret = encodeBase58Token(TokenType::AccountID, id.data(), id.size()); - assert(ret.size() <= 38); + XRPL_ASSERT(ret.size() <= 38); { std::lock_guard lock(sl); diff --git a/src/ripple/protocol/impl/ErrorCodes.cpp b/src/ripple/protocol/impl/ErrorCodes.cpp index 3af48891c78..4e03aa707e5 100644 --- a/src/ripple/protocol/impl/ErrorCodes.cpp +++ b/src/ripple/protocol/impl/ErrorCodes.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include #include namespace ripple { @@ -212,7 +212,7 @@ error_code_http_status(error_code_i code) std::string rpcErrorString(Json::Value const& jv) { - assert(RPC::contains_error(jv)); + XRPL_ASSERT(RPC::contains_error(jv)); return jv[jss::error].asString() + jv[jss::error_message].asString(); } diff --git a/src/ripple/protocol/impl/Feature.cpp b/src/ripple/protocol/impl/Feature.cpp index 4c347375766..16d225750d0 100644 --- a/src/ripple/protocol/impl/Feature.cpp +++ b/src/ripple/protocol/impl/Feature.cpp @@ -213,7 +213,7 @@ FeatureCollections::FeatureCollections() std::optional FeatureCollections::getRegisteredFeature(std::string const& name) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const* feature = getByName(name); if (feature) return feature->feature; @@ -284,7 +284,7 @@ FeatureCollections::registrationIsDone() size_t FeatureCollections::featureToBitsetIndex(uint256 const& f) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const* feature = getByFeature(f); if (!feature) @@ -296,7 +296,7 @@ FeatureCollections::featureToBitsetIndex(uint256 const& f) const uint256 const& FeatureCollections::bitsetIndexToFeature(size_t i) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const& feature = getByIndex(i); return feature.feature; } @@ -304,7 +304,7 @@ FeatureCollections::bitsetIndexToFeature(size_t i) const std::string FeatureCollections::featureToName(uint256 const& f) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const* feature = getByFeature(f); return feature ? feature->name : to_string(f); } diff --git a/src/ripple/protocol/impl/Indexes.cpp b/src/ripple/protocol/impl/Indexes.cpp index 0ee52aab297..fee2d65f45d 100644 --- a/src/ripple/protocol/impl/Indexes.cpp +++ b/src/ripple/protocol/impl/Indexes.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -26,7 +27,6 @@ #include #include -#include namespace ripple { @@ -91,7 +91,7 @@ indexHash(LedgerNameSpace space, Args const&... args) uint256 getBookBase(Book const& book) { - assert(isConsistent(book)); + XRPL_ASSERT(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) { - assert(ticketSeq.isTicket()); + XRPL_ASSERT(ticketSeq.isTicket()); return getTicketIndex(account, ticketSeq.value()); } @@ -208,7 +208,7 @@ line( // There is code in SetTrust that calls us with id0 == id1, to allow users // to locate and delete such "weird" trustlines. If we remove that code, we // could enable this assert: - // assert(id0 != id1); + // XRPL_ASSERT(id0 != id1); // A trust line is shared between two accounts; while we typically think // of this as an "issuer" and a "holder" the relationship is actually fully @@ -237,7 +237,7 @@ offer(AccountID const& id, std::uint32_t seq) noexcept Keylet quality(Keylet const& k, std::uint64_t q) noexcept { - assert(k.type == ltDIR_NODE); + XRPL_ASSERT(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 { - assert(k.type == ltDIR_NODE); + XRPL_ASSERT(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) { - assert(k.type == ltNFTOKEN_PAGE); + XRPL_ASSERT(k.type == ltNFTOKEN_PAGE); return {ltNFTOKEN_PAGE, (k.key & ~nft::pageMask) + (token & nft::pageMask)}; } diff --git a/src/ripple/protocol/impl/Keylet.cpp b/src/ripple/protocol/impl/Keylet.cpp index 2488e8b45b6..32d4ce95006 100644 --- a/src/ripple/protocol/impl/Keylet.cpp +++ b/src/ripple/protocol/impl/Keylet.cpp @@ -25,7 +25,7 @@ namespace ripple { bool Keylet::check(STLedgerEntry const& sle) const { - assert(sle.getType() != ltANY || sle.getType() != ltCHILD); + XRPL_ASSERT(sle.getType() != ltANY || sle.getType() != ltCHILD); if (type == ltANY) return true; diff --git a/src/ripple/protocol/impl/Quality.cpp b/src/ripple/protocol/impl/Quality.cpp index 2cb60f738d8..a8b9dfead6b 100644 --- a/src/ripple/protocol/impl/Quality.cpp +++ b/src/ripple/protocol/impl/Quality.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include #include namespace ripple { @@ -35,7 +35,7 @@ Quality::Quality(Amounts const& amount) Quality& Quality::operator++() { - assert(m_value > 0); + XRPL_ASSERT(m_value > 0); --m_value; return *this; } @@ -51,7 +51,7 @@ Quality::operator++(int) Quality& Quality::operator--() { - assert(m_value < std::numeric_limits::max()); + XRPL_ASSERT(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; - assert(result.in == limit); + XRPL_ASSERT(result.in == limit); return result; } - assert(amount.in <= limit); + XRPL_ASSERT(amount.in <= limit); return amount; } @@ -120,10 +120,10 @@ ceil_out_impl( // Clamp in if (result.in > amount.in) result.in = amount.in; - assert(result.out == limit); + XRPL_ASSERT(result.out == limit); return result; } - assert(amount.out <= limit); + XRPL_ASSERT(amount.out <= limit); return amount; } @@ -146,17 +146,17 @@ Quality composed_quality(Quality const& lhs, Quality const& rhs) { STAmount const lhs_rate(lhs.rate()); - assert(lhs_rate != beast::zero); + XRPL_ASSERT(lhs_rate != beast::zero); STAmount const rhs_rate(rhs.rate()); - assert(rhs_rate != beast::zero); + XRPL_ASSERT(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()); - assert((stored_exponent > 0) && (stored_exponent <= 255)); + XRPL_ASSERT((stored_exponent > 0) && (stored_exponent <= 255)); return Quality((stored_exponent << (64 - 8)) | stored_mantissa); } diff --git a/src/ripple/protocol/impl/Rate2.cpp b/src/ripple/protocol/impl/Rate2.cpp index 340b6719bca..13e3e8a5b4d 100644 --- a/src/ripple/protocol/impl/Rate2.cpp +++ b/src/ripple/protocol/impl/Rate2.cpp @@ -46,7 +46,7 @@ transferFeeAsRate(std::uint16_t fee) STAmount multiply(STAmount const& amount, Rate const& rate) { - assert(rate.value != 0); + XRPL_ASSERT(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) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; @@ -72,7 +72,7 @@ multiplyRound( Issue const& issue, bool roundUp) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) { @@ -85,7 +85,7 @@ multiplyRound( STAmount divide(STAmount const& amount, Rate const& rate) { - assert(rate.value != 0); + XRPL_ASSERT(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) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; @@ -111,7 +111,7 @@ divideRound( Issue const& issue, bool roundUp) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; diff --git a/src/ripple/protocol/impl/Rules.cpp b/src/ripple/protocol/impl/Rules.cpp index e65a9678f65..7f48ee3a542 100644 --- a/src/ripple/protocol/impl/Rules.cpp +++ b/src/ripple/protocol/impl/Rules.cpp @@ -91,7 +91,7 @@ class Rules::Impl return true; if (!digest_ || !other.digest_) return false; - assert(presets_ == other.presets_); + XRPL_ASSERT(presets_ == other.presets_); return *digest_ == *other.digest_; } }; @@ -118,7 +118,7 @@ Rules::presets() const bool Rules::enabled(uint256 const& feature) const { - assert(impl_); + XRPL_ASSERT(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 { - assert(impl_ && other.impl_); + XRPL_ASSERT(impl_ && other.impl_); if (impl_.get() == other.impl_.get()) return true; return *impl_ == *other.impl_; diff --git a/src/ripple/protocol/impl/SField.cpp b/src/ripple/protocol/impl/SField.cpp index 6d034db75ef..f2a27064176 100644 --- a/src/ripple/protocol/impl/SField.cpp +++ b/src/ripple/protocol/impl/SField.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include #include #include #include diff --git a/src/ripple/protocol/impl/STAccount.cpp b/src/ripple/protocol/impl/STAccount.cpp index 5881ae5b264..4be7c40413f 100644 --- a/src/ripple/protocol/impl/STAccount.cpp +++ b/src/ripple/protocol/impl/STAccount.cpp @@ -80,8 +80,8 @@ STAccount::getSType() const void STAccount::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == STI_ACCOUNT); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(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/ripple/protocol/impl/STAmount.cpp b/src/ripple/protocol/impl/STAmount.cpp index a02dc9e89e1..c3297c8a4ae 100644 --- a/src/ripple/protocol/impl/STAmount.cpp +++ b/src/ripple/protocol/impl/STAmount.cpp @@ -70,7 +70,7 @@ getSNValue(STAmount const& amount) auto ret = static_cast(amount.mantissa()); - assert(static_cast(ret) == amount.mantissa()); + XRPL_ASSERT(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) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -235,7 +235,7 @@ STAmount::STAmount( , mOffset(exponent) , mIsNegative(negative) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); canonicalize(); } @@ -246,7 +246,7 @@ STAmount::STAmount(SField const& name, STAmount const& from) , mOffset(from.mOffset) , mIsNegative(from.mIsNegative) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); canonicalize(); } @@ -258,7 +258,7 @@ STAmount::STAmount(std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(mantissa != 0 && negative) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -374,7 +374,7 @@ STAmount::iou() const STAmount& STAmount::operator=(IOUAmount const& iou) { - assert(mIsNative == false); + XRPL_ASSERT(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; - assert((r.exponent() >= -100) && (r.exponent() <= 155)); + XRPL_ASSERT((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; } - assert(mOffset + 43 > 0); + XRPL_ASSERT(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; - assert(post_to >= post_from); + XRPL_ASSERT(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; - assert(post_to >= post_from); + XRPL_ASSERT(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) { - assert(mOffset == 0); + XRPL_ASSERT(mOffset == 0); if (!mIsNegative) s.add64(mValue | cPosNative); @@ -823,10 +823,11 @@ STAmount::canonicalize() if (mOffset > cMaxOffset) Throw("value overflow"); - assert((mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue))); - assert( + XRPL_ASSERT( + (mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue))); + XRPL_ASSERT( (mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset))); - assert((mValue != 0) || (mOffset != -100)); + XRPL_ASSERT((mValue != 0) || (mOffset != -100)); } void diff --git a/src/ripple/protocol/impl/STBase.cpp b/src/ripple/protocol/impl/STBase.cpp index b49b65bf25d..0306e4cef5d 100644 --- a/src/ripple/protocol/impl/STBase.cpp +++ b/src/ripple/protocol/impl/STBase.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include #include namespace ripple { @@ -30,7 +30,7 @@ STBase::STBase() : fName(&sfGeneric) STBase::STBase(SField const& n) : fName(&n) { - assert(fName); + XRPL_ASSERT(fName); } STBase& @@ -105,13 +105,13 @@ void STBase::add(Serializer& s) const { // Should never be called - assert(false); + XRPL_UNREACHABLE(); } bool STBase::isEquivalent(const STBase& t) const { - assert(getSType() == STI_NOTPRESENT); + XRPL_ASSERT(getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; } @@ -125,7 +125,7 @@ void STBase::setFName(SField const& n) { fName = &n; - assert(fName); + XRPL_ASSERT(fName); } SField const& @@ -137,7 +137,7 @@ STBase::getFName() const void STBase::addFieldID(Serializer& s) const { - assert(fName->isBinary()); + XRPL_ASSERT(fName->isBinary()); s.addFieldID(fName->fieldType, fName->fieldValue); } diff --git a/src/ripple/protocol/impl/STBlob.cpp b/src/ripple/protocol/impl/STBlob.cpp index 871c535e9dd..8c26e56091f 100644 --- a/src/ripple/protocol/impl/STBlob.cpp +++ b/src/ripple/protocol/impl/STBlob.cpp @@ -54,8 +54,8 @@ STBlob::getText() const void STBlob::add(Serializer& s) const { - assert(getFName().isBinary()); - assert( + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT( (getFName().fieldType == STI_VL) || (getFName().fieldType == STI_ACCOUNT)); s.addVL(value_.data(), value_.size()); diff --git a/src/ripple/protocol/impl/STInteger.cpp b/src/ripple/protocol/impl/STInteger.cpp index 2b154e369e4..e786fff3165 100644 --- a/src/ripple/protocol/impl/STInteger.cpp +++ b/src/ripple/protocol/impl/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); - assert(ret.ec == std::errc()); + XRPL_ASSERT(ret.ec == std::errc()); str.resize(std::distance(str.data(), ret.ptr)); return str; } diff --git a/src/ripple/protocol/impl/STLedgerEntry.cpp b/src/ripple/protocol/impl/STLedgerEntry.cpp index 10ec5627aa3..32ef04479f1 100644 --- a/src/ripple/protocol/impl/STLedgerEntry.cpp +++ b/src/ripple/protocol/impl/STLedgerEntry.cpp @@ -157,7 +157,7 @@ STLedgerEntry::thread( if (oldPrevTxID == txID) { // this transaction is already threaded - assert(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); + XRPL_ASSERT(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); return false; } diff --git a/src/ripple/protocol/impl/STObject.cpp b/src/ripple/protocol/impl/STObject.cpp index dbcb47e8794..e8bdefc5540 100644 --- a/src/ripple/protocol/impl/STObject.cpp +++ b/src/ripple/protocol/impl/STObject.cpp @@ -833,7 +833,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()}; - assert( + XRPL_ASSERT( (sType != STI_OBJECT) || (field->getFName().fieldType == STI_OBJECT)); field->addFieldID(s); diff --git a/src/ripple/protocol/impl/STParsedJSON.cpp b/src/ripple/protocol/impl/STParsedJSON.cpp index 6727fe7388c..83f22f423ea 100644 --- a/src/ripple/protocol/impl/STParsedJSON.cpp +++ b/src/ripple/protocol/impl/STParsedJSON.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include -#include #include #include diff --git a/src/ripple/protocol/impl/STPathSet.cpp b/src/ripple/protocol/impl/STPathSet.cpp index cc1e367ba45..9913eef6b22 100644 --- a/src/ripple/protocol/impl/STPathSet.cpp +++ b/src/ripple/protocol/impl/STPathSet.cpp @@ -208,8 +208,8 @@ STPathSet::getSType() const void STPathSet::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == STI_PATHSET); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == STI_PATHSET); bool first = true; for (auto const& spPath : value) diff --git a/src/ripple/protocol/impl/STTx.cpp b/src/ripple/protocol/impl/STTx.cpp index 51fb11ad761..e3b4cc1c88a 100644 --- a/src/ripple/protocol/impl/STTx.cpp +++ b/src/ripple/protocol/impl/STTx.cpp @@ -137,7 +137,7 @@ STTx::getMentionedAccounts() const { if (auto sacc = dynamic_cast(&it)) { - assert(!sacc->isDefault()); + XRPL_ASSERT(!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_); - assert(format != nullptr); + XRPL_ASSERT(format != nullptr); return str( boost::format(bfTrans) % to_string(getTransactionID()) % diff --git a/src/ripple/protocol/impl/STValidation.cpp b/src/ripple/protocol/impl/STValidation.cpp index e62a81733bd..c6e08f39567 100644 --- a/src/ripple/protocol/impl/STValidation.cpp +++ b/src/ripple/protocol/impl/STValidation.cpp @@ -107,7 +107,7 @@ STValidation::isValid() const noexcept { if (!valid_) { - assert(publicKeyType(getSignerPublic()) == KeyType::secp256k1); + XRPL_ASSERT(publicKeyType(getSignerPublic()) == KeyType::secp256k1); valid_ = verifyDigest( getSignerPublic(), diff --git a/src/ripple/protocol/impl/STVar.cpp b/src/ripple/protocol/impl/STVar.cpp index adda165901f..7801076791a 100644 --- a/src/ripple/protocol/impl/STVar.cpp +++ b/src/ripple/protocol/impl/STVar.cpp @@ -178,7 +178,7 @@ STVar::STVar(SerialIter& sit, SField const& name, int depth) STVar::STVar(SerializedTypeID id, SField const& name) { - assert((id == STI_NOTPRESENT) || (id == name.fieldType)); + XRPL_ASSERT((id == STI_NOTPRESENT) || (id == name.fieldType)); switch (id) { case STI_NOTPRESENT: diff --git a/src/ripple/protocol/impl/STVector256.cpp b/src/ripple/protocol/impl/STVector256.cpp index 0ef1295b16a..cf3dc9745f8 100644 --- a/src/ripple/protocol/impl/STVector256.cpp +++ b/src/ripple/protocol/impl/STVector256.cpp @@ -68,8 +68,8 @@ STVector256::isDefault() const void STVector256::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == STI_VECTOR256); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == STI_VECTOR256); s.addVL(mValue.begin(), mValue.end(), mValue.size() * (256 / 8)); } diff --git a/src/ripple/protocol/impl/Serializer.cpp b/src/ripple/protocol/impl/Serializer.cpp index 42f79cfc518..fa9db036c5c 100644 --- a/src/ripple/protocol/impl/Serializer.cpp +++ b/src/ripple/protocol/impl/Serializer.cpp @@ -132,7 +132,7 @@ int Serializer::addFieldID(int type, int name) { int ret = mData.size(); - assert((type > 0) && (type < 256) && (name > 0) && (name < 256)); + XRPL_ASSERT((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); - assert( + XRPL_ASSERT( mData.size() == (ret + vector.size() + encodeLengthLength(vector.size()))); return ret; @@ -483,7 +483,7 @@ SerialIter::getVLDataLength() } else { - assert(lenLen == 3); + XRPL_ASSERT(lenLen == 3); int b2 = get8(); int b3 = get8(); datLen = Serializer::decodeVLLength(b1, b2, b3); diff --git a/src/ripple/protocol/impl/TxMeta.cpp b/src/ripple/protocol/impl/TxMeta.cpp index 20fa61de2a8..b5694c035d1 100644 --- a/src/ripple/protocol/impl/TxMeta.cpp +++ b/src/ripple/protocol/impl/TxMeta.cpp @@ -55,7 +55,7 @@ TxMeta::TxMeta(uint256 const& txid, std::uint32_t ledger, STObject const& obj) auto affectedNodes = dynamic_cast(obj.peekAtPField(sfAffectedNodes)); - assert(affectedNodes); + XRPL_ASSERT(affectedNodes); if (affectedNodes) mNodes = *affectedNodes; @@ -106,7 +106,7 @@ TxMeta::setAffectedNode( mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - assert(obj.getFName() == type); + XRPL_ASSERT(obj.getFName() == type); obj.setFieldH256(sfLedgerIndex, node); obj.setFieldU16(sfLedgerEntryType, nodeType); } @@ -127,14 +127,14 @@ TxMeta::getAffectedAccounts() const if (index != -1) { auto inner = dynamic_cast(&it.peekAtIndex(index)); - assert(inner); + XRPL_ASSERT(inner); if (inner) { for (auto const& field : *inner) { if (auto sa = dynamic_cast(&field)) { - assert(!sa->isDefault()); + XRPL_ASSERT(!sa->isDefault()); if (!sa->isDefault()) list.insert(sa->value()); } @@ -145,7 +145,7 @@ TxMeta::getAffectedAccounts() const (field.getFName() == sfTakerGets)) { auto lim = dynamic_cast(&field); - assert(lim); + XRPL_ASSERT(lim); if (lim != nullptr) { @@ -175,7 +175,7 @@ TxMeta::getAffectedNode(SLE::ref node, SField const& type) mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - assert(obj.getFName() == type); + XRPL_ASSERT(obj.getFName() == type); obj.setFieldH256(sfLedgerIndex, index); obj.setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType)); @@ -190,7 +190,7 @@ TxMeta::getAffectedNode(uint256 const& node) if (n.getFieldH256(sfLedgerIndex) == node) return n; } - assert(false); + XRPL_UNREACHABLE(); Throw("Affected node not found"); return *(mNodes.begin()); // Silence compiler warning. } @@ -199,7 +199,7 @@ STObject TxMeta::getAsObject() const { STObject metaData(sfTransactionMetaData); - assert(mResult != 255); + XRPL_ASSERT(mResult != 255); metaData.setFieldU8(sfTransactionResult, mResult); metaData.setFieldU32(sfTransactionIndex, mIndex); metaData.emplace_back(mNodes); @@ -213,7 +213,7 @@ TxMeta::addRaw(Serializer& s, TER result, std::uint32_t index) { mResult = TERtoInt(result); mIndex = index; - assert((mResult == 0) || ((mResult > 100) && (mResult <= 255))); + XRPL_ASSERT((mResult == 0) || ((mResult > 100) && (mResult <= 255))); mNodes.sort([](STObject const& o1, STObject const& o2) { return o1.getFieldH256(sfLedgerIndex) < o2.getFieldH256(sfLedgerIndex); diff --git a/src/ripple/protocol/impl/b58_utils.h b/src/ripple/protocol/impl/b58_utils.h index c3bb0c03750..52ee171187a 100644 --- a/src/ripple/protocol/impl/b58_utils.h +++ b/src/ripple/protocol/impl/b58_utils.h @@ -21,11 +21,11 @@ #define RIPPLE_PROTOCOL_B58_UTILS_H_INCLUDED #include +#include #include #include -#include #include #include #include @@ -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. - assert(0); + XRPL_ASSERT(0); 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); - assert(d >> 64 == 0); - assert(r >> 64 == 0); + XRPL_ASSERT(d >> 64 == 0); + XRPL_ASSERT(r >> 64 == 0); return {static_cast(d), static_cast(r)}; }; diff --git a/src/ripple/protocol/impl/tokens.cpp b/src/ripple/protocol/impl/tokens.cpp index 8445eec38ca..7a88372e72d 100644 --- a/src/ripple/protocol/impl/tokens.cpp +++ b/src/ripple/protocol/impl/tokens.cpp @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include -#include #include #include #include @@ -248,7 +248,7 @@ encodeBase58( iter[-1] = carry % 58; carry /= 58; } - assert(carry == 0); + XRPL_ASSERT(carry == 0); pbegin++; } @@ -298,7 +298,7 @@ decodeBase58(std::string const& s) *iter = carry % 256; carry /= 256; } - assert(carry == 0); + XRPL_ASSERT(carry == 0); ++psz; --remain; } @@ -530,7 +530,7 @@ b58_to_b256_be(std::string_view input, std::span out) ripple::b58_fast::detail::div_rem(input.size(), 10); auto const num_partial_coeffs = partial_coeff_len ? 1 : 0; auto const num_b_58_10_coeffs = num_full_coeffs + num_partial_coeffs; - assert(num_b_58_10_coeffs <= b_58_10_coeff.size()); + XRPL_ASSERT(num_b_58_10_coeffs <= b_58_10_coeff.size()); for (auto c : input.substr(0, partial_coeff_len)) { auto cur_val = ::ripple::alphabetReverse[c]; diff --git a/src/ripple/resource/impl/Consumer.cpp b/src/ripple/resource/impl/Consumer.cpp index 34edbbfcc71..78718218ab5 100644 --- a/src/ripple/resource/impl/Consumer.cpp +++ b/src/ripple/resource/impl/Consumer.cpp @@ -17,10 +17,10 @@ */ //============================================================================== +#include #include #include #include -#include namespace ripple { namespace Resource { @@ -109,14 +109,14 @@ Consumer::charge(Charge const& what) bool Consumer::warn() { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); return m_logic->warn(*m_entry); } bool Consumer::disconnect(beast::Journal const& j) { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); bool const d = m_logic->disconnect(*m_entry); if (d) { @@ -128,14 +128,14 @@ Consumer::disconnect(beast::Journal const& j) int Consumer::balance() { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); return m_logic->balance(*m_entry); } Entry& Consumer::entry() { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); return *m_entry; } diff --git a/src/ripple/resource/impl/Entry.h b/src/ripple/resource/impl/Entry.h index 126f2546456..99cbd730ee9 100644 --- a/src/ripple/resource/impl/Entry.h +++ b/src/ripple/resource/impl/Entry.h @@ -21,11 +21,11 @@ #define RIPPLE_RESOURCE_ENTRY_H_INCLUDED #include +#include #include #include #include #include -#include namespace ripple { namespace Resource { diff --git a/src/ripple/resource/impl/Key.h b/src/ripple/resource/impl/Key.h index 929c13eebf6..8a507ee19e1 100644 --- a/src/ripple/resource/impl/Key.h +++ b/src/ripple/resource/impl/Key.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_RESOURCE_KEY_H_INCLUDED #define RIPPLE_RESOURCE_KEY_H_INCLUDED +#include #include #include -#include namespace ripple { namespace Resource { diff --git a/src/ripple/resource/impl/Logic.h b/src/ripple/resource/impl/Logic.h index 07d89403b6a..a6e46896a42 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/src/ripple/resource/impl/Logic.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include namespace ripple { @@ -401,7 +401,7 @@ class Logic { std::lock_guard _(lock_); Entry& entry(iter->second); - assert(entry.refcount == 0); + XRPL_ASSERT(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: - assert(false); + XRPL_UNREACHABLE(); break; } inactive_.push_back(entry); diff --git a/src/ripple/rpc/Status.h b/src/ripple/rpc/Status.h index d930d7ab439..7ac9cef57d7 100644 --- a/src/ripple/rpc/Status.h +++ b/src/ripple/rpc/Status.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_RPC_STATUS_H_INCLUDED #define RIPPLE_RPC_STATUS_H_INCLUDED +#include #include #include -#include namespace ripple { namespace RPC { @@ -95,7 +95,7 @@ struct Status : public std::exception TER toTER() const { - assert(type_ == Type::TER); + XRPL_ASSERT(type_ == Type::TER); return TER::fromInt(code_); } @@ -104,7 +104,7 @@ struct Status : public std::exception error_code_i toErrorCode() const { - assert(type_ == Type::error_code_i); + XRPL_ASSERT(type_ == Type::error_code_i); return error_code_i(code_); } diff --git a/src/ripple/rpc/handlers/AMMInfo.cpp b/src/ripple/rpc/handlers/AMMInfo.cpp index b240c8c2ae6..6e938e3fbe9 100644 --- a/src/ripple/rpc/handlers/AMMInfo.cpp +++ b/src/ripple/rpc/handlers/AMMInfo.cpp @@ -127,7 +127,7 @@ doAMMInfo(RPC::JsonContext& context) ammID = sle->getFieldH256(sfAMMID); } - assert( + XRPL_ASSERT( (issue1.has_value() == issue2.has_value()) && (issue1.has_value() != ammID.has_value())); @@ -141,7 +141,7 @@ doAMMInfo(RPC::JsonContext& context) auto const ammKeylet = [&]() { if (issue1 && issue2) return keylet::amm(*issue1, *issue2); - assert(ammID); + XRPL_ASSERT(ammID); return keylet::amm(*ammID); }(); auto const amm = ledger->read(ammKeylet); @@ -200,7 +200,7 @@ doAMMInfo(RPC::JsonContext& context) } if (voteSlots.size() > 0) ammResult[jss::vote_slots] = std::move(voteSlots); - assert( + XRPL_ASSERT( !ledger->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) diff --git a/src/ripple/rpc/handlers/AccountChannels.cpp b/src/ripple/rpc/handlers/AccountChannels.cpp index ebd89b04418..a89e0d731d0 100644 --- a/src/ripple/rpc/handlers/AccountChannels.cpp +++ b/src/ripple/rpc/handlers/AccountChannels.cpp @@ -166,7 +166,7 @@ doAccountChannels(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/ripple/rpc/handlers/AccountInfo.cpp b/src/ripple/rpc/handlers/AccountInfo.cpp index bd2184f49a3..3d873b377c5 100644 --- a/src/ripple/rpc/handlers/AccountInfo.cpp +++ b/src/ripple/rpc/handlers/AccountInfo.cpp @@ -205,7 +205,7 @@ doAccountInfo(RPC::JsonContext& context) if (tx.seqProxy.isSeq()) { - assert(prevSeqProxy < tx.seqProxy); + XRPL_ASSERT(prevSeqProxy < tx.seqProxy); prevSeqProxy = tx.seqProxy; jvTx[jss::seq] = tx.seqProxy.value(); ++seqCount; @@ -215,7 +215,7 @@ doAccountInfo(RPC::JsonContext& context) } else { - assert(prevSeqProxy < tx.seqProxy); + XRPL_ASSERT(prevSeqProxy < tx.seqProxy); prevSeqProxy = tx.seqProxy; jvTx[jss::ticket] = tx.seqProxy.value(); ++ticketCount; diff --git a/src/ripple/rpc/handlers/AccountLines.cpp b/src/ripple/rpc/handlers/AccountLines.cpp index 3bfcd225b14..f79b4b86a9f 100644 --- a/src/ripple/rpc/handlers/AccountLines.cpp +++ b/src/ripple/rpc/handlers/AccountLines.cpp @@ -186,7 +186,7 @@ doAccountLines(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/ripple/rpc/handlers/AccountOffers.cpp b/src/ripple/rpc/handlers/AccountOffers.cpp index 867f888e241..c469a9d5238 100644 --- a/src/ripple/rpc/handlers/AccountOffers.cpp +++ b/src/ripple/rpc/handlers/AccountOffers.cpp @@ -142,7 +142,7 @@ doAccountOffers(RPC::JsonContext& context) std::shared_ptr const& sle) { if (!sle) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/ripple/rpc/handlers/AccountTx.cpp b/src/ripple/rpc/handlers/AccountTx.cpp index 7fe7472721f..bdb6a656834 100644 --- a/src/ripple/rpc/handlers/AccountTx.cpp +++ b/src/ripple/rpc/handlers/AccountTx.cpp @@ -318,7 +318,7 @@ populateJsonResponse( if (auto txnsData = std::get_if(&result.transactions)) { - assert(!args.binary); + XRPL_ASSERT(!args.binary); for (auto const& [txn, txnMeta] : *txnsData) { @@ -363,13 +363,13 @@ populateJsonResponse( insertNFTSyntheticInJson(jvObj, sttx, *txnMeta); } else - assert(false && "Missing transaction medatata"); + XRPL_ASSERT(false && "Missing transaction medatata"); } } } else { - assert(args.binary); + XRPL_ASSERT(args.binary); for (auto const& binaryData : std::get(result.transactions)) diff --git a/src/ripple/rpc/handlers/Fee1.cpp b/src/ripple/rpc/handlers/Fee1.cpp index 89fa9c6ea07..ceb3865d6ba 100644 --- a/src/ripple/rpc/handlers/Fee1.cpp +++ b/src/ripple/rpc/handlers/Fee1.cpp @@ -32,7 +32,7 @@ doFee(RPC::JsonContext& context) auto result = context.app.getTxQ().doRPC(context.app); if (result.type() == Json::objectValue) return result; - assert(false); + XRPL_UNREACHABLE(); RPC::inject_error(rpcINTERNAL, context.params); return context.params; } diff --git a/src/ripple/rpc/handlers/LedgerClosed.cpp b/src/ripple/rpc/handlers/LedgerClosed.cpp index 66e003e08f5..73e9d44d1af 100644 --- a/src/ripple/rpc/handlers/LedgerClosed.cpp +++ b/src/ripple/rpc/handlers/LedgerClosed.cpp @@ -29,7 +29,7 @@ Json::Value doLedgerClosed(RPC::JsonContext& context) { auto ledger = context.ledgerMaster.getClosedLedger(); - assert(ledger); + XRPL_ASSERT(ledger); Json::Value jvResult; jvResult[jss::ledger_index] = ledger->info().seq; diff --git a/src/ripple/rpc/handlers/LedgerDiff.cpp b/src/ripple/rpc/handlers/LedgerDiff.cpp index 122dcfa31d5..562ef58cc37 100644 --- a/src/ripple/rpc/handlers/LedgerDiff.cpp +++ b/src/ripple/rpc/handlers/LedgerDiff.cpp @@ -73,7 +73,7 @@ doLedgerDiffGrpc( } else { - assert(inDesired->size() > 0); + XRPL_ASSERT(inDesired->size() > 0); diff->set_key(k.data(), k.size()); if (request.include_blobs()) { diff --git a/src/ripple/rpc/handlers/LedgerHandler.cpp b/src/ripple/rpc/handlers/LedgerHandler.cpp index 623cb8d75ac..4e8b4a4ad5a 100644 --- a/src/ripple/rpc/handlers/LedgerHandler.cpp +++ b/src/ripple/rpc/handlers/LedgerHandler.cpp @@ -136,7 +136,7 @@ doLedgerGrpc(RPC::GRPCContext& context) { for (auto& i : ledger->txs) { - assert(i.first); + XRPL_ASSERT(i.first); if (request.expand()) { auto txn = response.mutable_transactions_list() @@ -212,7 +212,7 @@ doLedgerGrpc(RPC::GRPCContext& context) obj->set_key(k.data(), k.size()); if (inDesired) { - assert(inDesired->size() > 0); + XRPL_ASSERT(inDesired->size() > 0); obj->set_data(inDesired->data(), inDesired->size()); } if (inBase && inDesired) diff --git a/src/ripple/rpc/handlers/NodeToShard.cpp b/src/ripple/rpc/handlers/NodeToShard.cpp index 552900d1548..6b4e0615bd7 100644 --- a/src/ripple/rpc/handlers/NodeToShard.cpp +++ b/src/ripple/rpc/handlers/NodeToShard.cpp @@ -78,7 +78,7 @@ doNodeToShard(RPC::JsonContext& context) else { // Shouldn't happen - assert(false); + XRPL_UNREACHABLE(); return rpcError(rpcINTERNAL); } } diff --git a/src/ripple/rpc/handlers/PayChanClaim.cpp b/src/ripple/rpc/handlers/PayChanClaim.cpp index 33561463f21..1ecec64e731 100644 --- a/src/ripple/rpc/handlers/PayChanClaim.cpp +++ b/src/ripple/rpc/handlers/PayChanClaim.cpp @@ -58,7 +58,7 @@ doChannelAuthorize(RPC::JsonContext& context) std::optional> const keyPair = RPC::keypairForSignature(params, result, context.apiVersion); - assert(keyPair || RPC::contains_error(result)); + XRPL_ASSERT(keyPair || RPC::contains_error(result)); if (!keyPair || RPC::contains_error(result)) return result; diff --git a/src/ripple/rpc/handlers/Tx.cpp b/src/ripple/rpc/handlers/Tx.cpp index d4c9c95a341..4da0368aaa4 100644 --- a/src/ripple/rpc/handlers/Tx.cpp +++ b/src/ripple/rpc/handlers/Tx.cpp @@ -75,7 +75,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) { if (!context.app.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Called doTxPostgres yet not in reporting mode"); } @@ -109,13 +109,13 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) SHAMapHash{locator.getNodestoreHash()}); if (!node) { - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Error making SHAMap node"}}; } auto item = (static_cast(node.get()))->peekItem(); if (!item) { - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Error reading SHAMap node"}}; } @@ -124,7 +124,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) if (!sttx || !meta) { - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Error deserializing SHAMap node"}}; } std::string reason; @@ -156,7 +156,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) else { JLOG(context.j.error()) << "Failed to fetch from db"; - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Containing SHAMap node not found"}}; } auto end = std::chrono::system_clock::now(); @@ -184,7 +184,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) return {res, rpcTXN_NOT_FOUND}; } // database didn't return anything. This shouldn't happen - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "unexpected Postgres response"}}; } @@ -370,7 +370,7 @@ populateJsonResponse( // populate binary metadata if (auto blob = std::get_if(&result.meta)) { - assert(args.binary); + XRPL_ASSERT(args.binary); auto json_meta = (context.apiVersion > 1 ? jss::meta_blob : jss::meta); response[json_meta] = strHex(makeSlice(*blob)); diff --git a/src/ripple/rpc/impl/Handler.cpp b/src/ripple/rpc/impl/Handler.cpp index 1fc160dc4db..2f1f451d0a6 100644 --- a/src/ripple/rpc/impl/Handler.cpp +++ b/src/ripple/rpc/impl/Handler.cpp @@ -38,7 +38,7 @@ byRef(Function const& f) result = f(context); if (result.type() != Json::objectValue) { - assert(false); + XRPL_UNREACHABLE(); result = RPC::makeObjectValue(result); } @@ -50,7 +50,7 @@ template Status handle(JsonContext& context, Object& object) { - assert( + XRPL_ASSERT( context.apiVersion >= HandlerImpl::minApiVer && context.apiVersion <= HandlerImpl::maxApiVer); HandlerImpl handler(context); @@ -211,8 +211,8 @@ class HandlerTable unsigned minVer, unsigned maxVer) { - assert(minVer <= maxVer); - assert(maxVer <= RPC::apiMaximumValidVersion); + XRPL_ASSERT(minVer <= maxVer); + XRPL_ASSERT(maxVer <= RPC::apiMaximumValidVersion); return std::any_of( range.first, diff --git a/src/ripple/rpc/impl/RPCHelpers.cpp b/src/ripple/rpc/impl/RPCHelpers.cpp index a6179b04c88..e4f97ccf232 100644 --- a/src/ripple/rpc/impl/RPCHelpers.cpp +++ b/src/ripple/rpc/impl/RPCHelpers.cpp @@ -540,7 +540,7 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) return {rpcNOT_SYNCED, "notSynced"}; } - assert(!ledger->open()); + XRPL_ASSERT(!ledger->open()); } else { @@ -551,7 +551,7 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) rpcLGR_NOT_FOUND, "Reporting does not track current ledger"}; ledger = context.ledgerMaster.getCurrentLedger(); - assert(ledger->open()); + XRPL_ASSERT(ledger->open()); } else if (shortcut == LedgerShortcut::CLOSED) { @@ -559,7 +559,7 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) return { rpcLGR_NOT_FOUND, "Reporting does not track closed ledger"}; ledger = context.ledgerMaster.getClosedLedger(); - assert(!ledger->open()); + XRPL_ASSERT(!ledger->open()); } else { @@ -965,7 +965,7 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{ rpcINVALID_PARAMS, "Invalid field 'type', not string."}; - assert(result.first.type() == RPC::Status::Type::error_code_i); + XRPL_ASSERT(result.first.type() == RPC::Status::Type::error_code_i); return result; } @@ -978,7 +978,7 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{rpcINVALID_PARAMS, "Invalid field 'type'."}; - assert(result.first.type() == RPC::Status::Type::error_code_i); + XRPL_ASSERT(result.first.type() == RPC::Status::Type::error_code_i); return result; } result.second = iter->second; @@ -1071,7 +1071,7 @@ getLedgerByContext(RPC::JsonContext& context) // ledger auto const refIndex = getCandidateLedger(ledgerIndex); auto refHash = hashOfSeq(*ledger, refIndex, j); - assert(refHash); + XRPL_ASSERT(refHash); ledger = ledgerMaster.getLedgerByHash(*refHash); if (!ledger) @@ -1105,7 +1105,7 @@ getLedgerByContext(RPC::JsonContext& context) neededHash = hashOfSeq(*ledger, ledgerIndex, j); } - assert(neededHash); + XRPL_ASSERT(neededHash); ledgerHash = neededHash ? *neededHash : beast::zero; // kludge } diff --git a/src/ripple/rpc/impl/RPCHelpers.h b/src/ripple/rpc/impl/RPCHelpers.h index e003773e50c..77519c23304 100644 --- a/src/ripple/rpc/impl/RPCHelpers.h +++ b/src/ripple/rpc/impl/RPCHelpers.h @@ -213,7 +213,7 @@ template void setVersion(Object& parent, unsigned int apiVersion, bool betaEnabled) { - assert(apiVersion != apiInvalidVersion); + XRPL_ASSERT(apiVersion != apiInvalidVersion); auto&& object = addObject(parent, jss::version); if (apiVersion == apiVersionIfUnspecified) { diff --git a/src/ripple/rpc/impl/Role.cpp b/src/ripple/rpc/impl/Role.cpp index 1807ecc20f6..40d8a3a7ba6 100644 --- a/src/ripple/rpc/impl/Role.cpp +++ b/src/ripple/rpc/impl/Role.cpp @@ -30,7 +30,7 @@ namespace ripple { bool passwordUnrequiredOrSentCorrect(Port const& port, Json::Value const& params) { - assert(!(port.admin_nets_v4.empty() && port.admin_nets_v6.empty())); + XRPL_ASSERT(!(port.admin_nets_v4.empty() && port.admin_nets_v6.empty())); bool const passwordRequired = (!port.admin_user.empty() || !port.admin_password.empty()); diff --git a/src/ripple/rpc/impl/ShardArchiveHandler.cpp b/src/ripple/rpc/impl/ShardArchiveHandler.cpp index d05744f483a..2b5f0d8fa04 100644 --- a/src/ripple/rpc/impl/ShardArchiveHandler.cpp +++ b/src/ripple/rpc/impl/ShardArchiveHandler.cpp @@ -83,7 +83,7 @@ ShardArchiveHandler::ShardArchiveHandler(Application& app) app.config().section(ConfigSection::shardDatabase()), "shard_verification_max_attempts")) { - assert(app_.getShardStore()); + XRPL_ASSERT(app_.getShardStore()); } bool @@ -135,7 +135,7 @@ ShardArchiveHandler::initFromDB(std::lock_guard const& lock) { using namespace boost::filesystem; - assert( + XRPL_ASSERT( exists(downloadDir_ / stateDBName) && is_regular_file(downloadDir_ / stateDBName)); diff --git a/src/ripple/rpc/impl/Status.cpp b/src/ripple/rpc/impl/Status.cpp index e9e64da7ac0..90c375c0cfa 100644 --- a/src/ripple/rpc/impl/Status.cpp +++ b/src/ripple/rpc/impl/Status.cpp @@ -37,7 +37,7 @@ Status::codeString() const std::string s1, s2; auto success = transResultInfo(toTER(), s1, s2); - assert(success); + XRPL_ASSERT(success); (void)success; return s1 + ": " + s2; @@ -51,7 +51,7 @@ Status::codeString() const return sStr.str(); } - assert(false); + XRPL_UNREACHABLE(); return ""; } diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index 3f4407c86e7..b3641c4cb96 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -1034,7 +1034,7 @@ transactionSignFor( if (!preprocResult.second) return preprocResult.first; - assert(signForParams.validMultiSign()); + XRPL_ASSERT(signForParams.validMultiSign()); { std::shared_ptr account_state = diff --git a/src/ripple/server/impl/BaseHTTPPeer.h b/src/ripple/server/impl/BaseHTTPPeer.h index a6bbd18e1aa..d6004237574 100644 --- a/src/ripple/server/impl/BaseHTTPPeer.h +++ b/src/ripple/server/impl/BaseHTTPPeer.h @@ -21,6 +21,7 @@ #define RIPPLE_SERVER_BASEHTTPPEER_H_INCLUDED #include +#include #include #include #include @@ -34,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/server/impl/BasePeer.h b/src/ripple/server/impl/BasePeer.h index bc5375b87f7..0e94df86f81 100644 --- a/src/ripple/server/impl/BasePeer.h +++ b/src/ripple/server/impl/BasePeer.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_SERVER_BASEPEER_H_INCLUDED #define RIPPLE_SERVER_BASEPEER_H_INCLUDED +#include #include #include #include #include #include #include -#include #include #include diff --git a/src/ripple/server/impl/BaseWSPeer.h b/src/ripple/server/impl/BaseWSPeer.h index fd1722df003..e0d61ad5d48 100644 --- a/src/ripple/server/impl/BaseWSPeer.h +++ b/src/ripple/server/impl/BaseWSPeer.h @@ -20,17 +20,18 @@ #ifndef RIPPLE_SERVER_BASEWSPEER_H_INCLUDED #define RIPPLE_SERVER_BASEWSPEER_H_INCLUDED +#include #include #include #include #include #include #include + #include #include #include -#include #include namespace ripple { @@ -508,7 +509,7 @@ template void BaseWSPeer::fail(error_code ec, String const& what) { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); cancel_timer(); if (!ec_ && ec != boost::asio::error::operation_aborted) diff --git a/src/ripple/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h index 2d1aa192fc6..f4fd94b897f 100644 --- a/src/ripple/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -21,6 +21,7 @@ #define RIPPLE_SHAMAP_SHAMAP_H_INCLUDED #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include @@ -599,7 +599,7 @@ SHAMap::setLedgerSeq(std::uint32_t lseq) inline void SHAMap::setImmutable() { - assert(state_ != SHAMapState::Invalid); + XRPL_ASSERT(state_ != SHAMapState::Invalid); state_ = SHAMapState::Immutable; } @@ -680,7 +680,7 @@ class SHAMap::const_iterator inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map) { - assert(map_ != nullptr); + XRPL_ASSERT(map_ != nullptr); if (auto temp = map_->peekFirstItem(stack_)) item_ = temp->peekItem().get(); @@ -732,7 +732,7 @@ SHAMap::const_iterator::operator++(int) inline bool operator==(SHAMap::const_iterator const& x, SHAMap::const_iterator const& y) { - assert(x.map_ == y.map_); + XRPL_ASSERT(x.map_ == y.map_); return x.item_ == y.item_; } diff --git a/src/ripple/shamap/SHAMapItem.h b/src/ripple/shamap/SHAMapItem.h index 160cc3cb49d..132d4770d87 100644 --- a/src/ripple/shamap/SHAMapItem.h +++ b/src/ripple/shamap/SHAMapItem.h @@ -25,8 +25,8 @@ #include #include #include +#include #include -#include namespace ripple { @@ -159,7 +159,7 @@ intrusive_ptr_release(SHAMapItem const* x) inline boost::intrusive_ptr make_shamapitem(uint256 const& tag, Slice data) { - assert(data.size() <= megabytes(16)); + XRPL_ASSERT(data.size() <= megabytes(16)); std::uint8_t* raw = detail::slabber.allocate(data.size()); diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index d6348c86c48..f702e791893 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -101,10 +101,10 @@ SHAMap::dirtyUp( // stack is a path of inner nodes up to, but not including, child // child can be an inner node or a leaf - assert( + XRPL_ASSERT( (state_ != SHAMapState::Synching) && (state_ != SHAMapState::Immutable)); - assert(child && (child->cowid() == cowid_)); + XRPL_ASSERT(child && (child->cowid() == cowid_)); while (!stack.empty()) { @@ -112,10 +112,10 @@ SHAMap::dirtyUp( std::dynamic_pointer_cast(stack.top().first); SHAMapNodeID nodeID = stack.top().second; stack.pop(); - assert(node != nullptr); + XRPL_ASSERT(node != nullptr); int branch = selectBranch(nodeID, target); - assert(branch >= 0); + XRPL_ASSERT(branch >= 0); node = unshareNode(std::move(node), nodeID); node->setChild(branch, std::move(child)); @@ -127,7 +127,7 @@ SHAMap::dirtyUp( SHAMapLeafNode* SHAMap::walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack) const { - assert(stack == nullptr || stack->empty()); + XRPL_ASSERT(stack == nullptr || stack->empty()); auto inNode = root_; SHAMapNodeID nodeID; @@ -162,7 +162,7 @@ SHAMap::findKey(uint256 const& id) const std::shared_ptr SHAMap::fetchNodeFromDB(SHAMapHash const& hash) const { - assert(backed_); + XRPL_ASSERT(backed_); auto obj = f_.db().fetchNodeObject(hash.as_uint256(), ledgerSeq_); return finishFetch(hash, obj); } @@ -172,7 +172,7 @@ SHAMap::finishFetch( SHAMapHash const& hash, std::shared_ptr const& object) const { - assert(backed_); + XRPL_ASSERT(backed_); try { @@ -360,9 +360,9 @@ SHAMap::descend( int branch, SHAMapSyncFilter* filter) const { - assert(parent->isInner()); - assert((branch >= 0) && (branch < branchFactor)); - assert(!parent->isEmptyBranch(branch)); + XRPL_ASSERT(parent->isInner()); + XRPL_ASSERT((branch >= 0) && (branch < branchFactor)); + XRPL_ASSERT(!parent->isEmptyBranch(branch)); SHAMapTreeNode* child = parent->getChildPointer(branch); @@ -430,11 +430,11 @@ std::shared_ptr SHAMap::unshareNode(std::shared_ptr node, SHAMapNodeID const& nodeID) { // make sure the node is suitable for the intended operation (copy on write) - assert(node->cowid() <= cowid_); + XRPL_ASSERT(node->cowid() <= cowid_); if (node->cowid() != cowid_) { // have a CoW - assert(state_ != SHAMapState::Immutable); + XRPL_ASSERT(state_ != SHAMapState::Immutable); node = std::static_pointer_cast(node->clone(cowid_)); if (nodeID.isRoot()) root_ = node; @@ -467,7 +467,7 @@ SHAMap::belowHelper( if (!inner->isEmptyBranch(i)) { node = descendThrow(inner, i); - assert(!stack.empty()); + XRPL_ASSERT(!stack.empty()); if (node->isLeaf()) { auto n = std::static_pointer_cast(node); @@ -531,7 +531,7 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const if (!nextNode) { - assert(false); + XRPL_UNREACHABLE(); return no_item; } @@ -541,14 +541,14 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const // An inner node must have at least one leaf // below it, unless it's the root_ auto const leaf = static_cast(node); - assert(leaf->peekItem() || (leaf == root_.get())); + XRPL_ASSERT(leaf->peekItem() || (leaf == root_.get())); return leaf->peekItem(); } SHAMapLeafNode const* SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const { - assert(stack.empty()); + XRPL_ASSERT(stack.empty()); SHAMapLeafNode* node = firstBelow(root_, stack); if (!node) { @@ -562,13 +562,13 @@ SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const SHAMapLeafNode const* SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const { - assert(!stack.empty()); - assert(stack.top().first->isLeaf()); + XRPL_ASSERT(!stack.empty()); + XRPL_ASSERT(stack.top().first->isLeaf()); stack.pop(); while (!stack.empty()) { auto [node, nodeID] = stack.top(); - assert(!node->isLeaf()); + XRPL_ASSERT(!node->isLeaf()); auto inner = std::static_pointer_cast(node); for (auto i = selectBranch(nodeID, id) + 1; i < branchFactor; ++i) { @@ -578,7 +578,7 @@ SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const auto leaf = firstBelow(node, stack, i); if (!leaf) Throw(type_, id); - assert(leaf->isLeaf()); + XRPL_ASSERT(leaf->isLeaf()); return leaf; } } @@ -696,7 +696,7 @@ bool SHAMap::delItem(uint256 const& id) { // delete the item with this ID - assert(state_ != SHAMapState::Immutable); + XRPL_ASSERT(state_ != SHAMapState::Immutable); SharedPtrNodeStack stack; walkTowardsKey(id, &stack); @@ -775,8 +775,8 @@ SHAMap::addGiveItem( SHAMapNodeType type, boost::intrusive_ptr item) { - assert(state_ != SHAMapState::Immutable); - assert(type != SHAMapNodeType::tnINNER); + XRPL_ASSERT(state_ != SHAMapState::Immutable); + XRPL_ASSERT(type != SHAMapNodeType::tnINNER); // add the specified item, does not update uint256 tag = item->key(); @@ -802,7 +802,7 @@ SHAMap::addGiveItem( // easy case, we end on an inner node auto inner = std::static_pointer_cast(node); int branch = selectBranch(nodeID, tag); - assert(inner->isEmptyBranch(branch)); + XRPL_ASSERT(inner->isEmptyBranch(branch)); inner->setChild(branch, makeTypedLeaf(type, std::move(item), cowid_)); } else @@ -811,7 +811,7 @@ SHAMap::addGiveItem( // items auto leaf = std::static_pointer_cast(node); auto otherItem = leaf->peekItem(); - assert(otherItem && (tag != otherItem->key())); + XRPL_ASSERT(otherItem && (tag != otherItem->key())); node = std::make_shared(node->cowid()); @@ -829,7 +829,7 @@ SHAMap::addGiveItem( } // we can add the two leaf nodes here - assert(node->isInner()); + XRPL_ASSERT(node->isInner()); auto inner = static_cast(node.get()); inner->setChild(b1, makeTypedLeaf(type, std::move(item), cowid_)); @@ -868,7 +868,7 @@ SHAMap::updateGiveItem( // can't change the tag but can change the hash uint256 tag = item->key(); - assert(state_ != SHAMapState::Immutable); + XRPL_ASSERT(state_ != SHAMapState::Immutable); SharedPtrNodeStack stack; walkTowardsKey(tag, &stack); @@ -882,7 +882,7 @@ SHAMap::updateGiveItem( if (!node || (node->peekItem()->key() != tag)) { - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -927,7 +927,7 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) if (newRoot) { root_ = newRoot; - assert(root_->getHash() == hash); + XRPL_ASSERT(root_->getHash() == hash); return true; } @@ -949,8 +949,8 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) std::shared_ptr SHAMap::writeNode(NodeObjectType t, std::shared_ptr node) const { - assert(node->cowid() == 0); - assert(backed_); + XRPL_ASSERT(node->cowid() == 0); + XRPL_ASSERT(backed_); canonicalize(node->getHash(), node); @@ -970,7 +970,7 @@ SHAMap::preFlushNode(std::shared_ptr node) const { // A shared node should never need to be flushed // because that would imply someone modified it - assert(node->cowid() != 0); + XRPL_ASSERT(node->cowid() != 0); if (node->cowid() != cowid_) { @@ -998,7 +998,7 @@ SHAMap::flushDirty(NodeObjectType t) int SHAMap::walkSubTree(bool doWrite, NodeObjectType t) { - assert(!doWrite || backed_); + XRPL_ASSERT(!doWrite || backed_); int flushed = 0; @@ -1073,7 +1073,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) // flush this leaf ++flushed; - assert(node->cowid() == cowid_); + XRPL_ASSERT(node->cowid() == cowid_); child->updateHash(); child->unshare(); @@ -1106,7 +1106,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) stack.pop(); // Hook this inner node to its parent - assert(parent->cowid() == cowid_); + XRPL_ASSERT(parent->cowid() == cowid_); parent->shareChild(pos, node); // Continue with parent's next child, if any @@ -1150,7 +1150,7 @@ SHAMap::dump(bool hash) const auto child = inner->getChildPointer(i); if (child) { - assert(child->getHash() == inner->getChildHash(i)); + XRPL_ASSERT(child->getHash() == inner->getChildHash(i)); stack.push({child, nodeID.getChildNodeID(i)}); } } @@ -1167,7 +1167,7 @@ std::shared_ptr SHAMap::cacheLookup(SHAMapHash const& hash) const { auto ret = f_.getTreeNodeCache(ledgerSeq_)->fetch(hash.as_uint256()); - assert(!ret || !ret->cowid()); + XRPL_ASSERT(!ret || !ret->cowid()); return ret; } @@ -1176,9 +1176,9 @@ SHAMap::canonicalize( SHAMapHash const& hash, std::shared_ptr& node) const { - assert(backed_); - assert(node->cowid() == 0); - assert(node->getHash() == hash); + XRPL_ASSERT(backed_); + XRPL_ASSERT(node->cowid() == 0); + XRPL_ASSERT(node->getHash() == hash); f_.getTreeNodeCache(ledgerSeq_) ->canonicalize_replace_client(hash.as_uint256(), node); @@ -1189,8 +1189,8 @@ SHAMap::invariants() const { (void)getHash(); // update node hashes auto node = root_.get(); - assert(node != nullptr); - assert(!node->isLeaf()); + XRPL_ASSERT(node != nullptr); + XRPL_ASSERT(!node->isLeaf()); SharedPtrNodeStack stack; for (auto leaf = peekFirstItem(stack); leaf != nullptr; leaf = peekNextItem(leaf->peekItem()->key(), stack)) diff --git a/src/ripple/shamap/impl/SHAMapDelta.cpp b/src/ripple/shamap/impl/SHAMapDelta.cpp index ab9e329eb30..0daff870bd9 100644 --- a/src/ripple/shamap/impl/SHAMapDelta.cpp +++ b/src/ripple/shamap/impl/SHAMapDelta.cpp @@ -128,7 +128,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const // many differences throws on corrupt tables or missing nodes CAUTION: // otherMap is not locked and must be immutable - assert(isValid() && otherMap.isValid()); + XRPL_ASSERT(isValid() && otherMap.isValid()); if (getHash() == otherMap.getHash()) return true; @@ -145,7 +145,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const if (!ourNode || !otherNode) { - assert(false); + XRPL_UNREACHABLE(); Throw(type_, uint256()); } @@ -226,7 +226,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const } } else - assert(false); + XRPL_UNREACHABLE(); } return true; @@ -323,7 +323,7 @@ SHAMap::walkMapParallel( { std::shared_ptr node = std::move(nodeStack.top()); - assert(node); + XRPL_ASSERT(node); nodeStack.pop(); for (int i = 0; i < 16; ++i) diff --git a/src/ripple/shamap/impl/SHAMapInnerNode.cpp b/src/ripple/shamap/impl/SHAMapInnerNode.cpp index c9884955914..b7effce5f4c 100644 --- a/src/ripple/shamap/impl/SHAMapInnerNode.cpp +++ b/src/ripple/shamap/impl/SHAMapInnerNode.cpp @@ -225,7 +225,7 @@ SHAMapInnerNode::updateHashDeep() void SHAMapInnerNode::serializeForWire(Serializer& s) const { - assert(!isEmpty()); + XRPL_ASSERT(!isEmpty()); // If the node is sparse, then only send non-empty branches: if (getBranchCount() < 12) @@ -249,7 +249,7 @@ SHAMapInnerNode::serializeForWire(Serializer& s) const void SHAMapInnerNode::serializeWithPrefix(Serializer& s) const { - assert(!isEmpty()); + XRPL_ASSERT(!isEmpty()); s.add32(HashPrefix::innerNode); iterChildren( @@ -274,9 +274,9 @@ SHAMapInnerNode::getString(const SHAMapNodeID& id) const void SHAMapInnerNode::setChild(int m, std::shared_ptr child) { - assert((m >= 0) && (m < branchFactor)); - assert(cowid_ != 0); - assert(child.get() != this); + XRPL_ASSERT((m >= 0) && (m < branchFactor)); + XRPL_ASSERT(cowid_ != 0); + XRPL_ASSERT(child.get() != this); auto const dstIsBranch = [&] { if (child) @@ -303,27 +303,27 @@ SHAMapInnerNode::setChild(int m, std::shared_ptr child) hash_.zero(); - assert(getBranchCount() <= hashesAndChildren_.capacity()); + XRPL_ASSERT(getBranchCount() <= hashesAndChildren_.capacity()); } // finished modifying, now make shareable void SHAMapInnerNode::shareChild(int m, std::shared_ptr const& child) { - assert((m >= 0) && (m < branchFactor)); - assert(cowid_ != 0); - assert(child); - assert(child.get() != this); + XRPL_ASSERT((m >= 0) && (m < branchFactor)); + XRPL_ASSERT(cowid_ != 0); + XRPL_ASSERT(child); + XRPL_ASSERT(child.get() != this); - assert(!isEmptyBranch(m)); + XRPL_ASSERT(!isEmptyBranch(m)); hashesAndChildren_.getChildren()[*getChildIndex(m)] = child; } SHAMapTreeNode* SHAMapInnerNode::getChildPointer(int branch) { - assert(branch >= 0 && branch < branchFactor); - assert(!isEmptyBranch(branch)); + XRPL_ASSERT(branch >= 0 && branch < branchFactor); + XRPL_ASSERT(!isEmptyBranch(branch)); auto const index = *getChildIndex(branch); @@ -335,8 +335,8 @@ SHAMapInnerNode::getChildPointer(int branch) std::shared_ptr SHAMapInnerNode::getChild(int branch) { - assert(branch >= 0 && branch < branchFactor); - assert(!isEmptyBranch(branch)); + XRPL_ASSERT(branch >= 0 && branch < branchFactor); + XRPL_ASSERT(!isEmptyBranch(branch)); auto const index = *getChildIndex(branch); @@ -348,7 +348,7 @@ SHAMapInnerNode::getChild(int branch) SHAMapHash const& SHAMapInnerNode::getChildHash(int m) const { - assert((m >= 0) && (m < branchFactor)); + XRPL_ASSERT((m >= 0) && (m < branchFactor)); if (auto const i = getChildIndex(m)) return hashesAndChildren_.getHashes()[*i]; @@ -360,12 +360,12 @@ SHAMapInnerNode::canonicalizeChild( int branch, std::shared_ptr node) { - assert(branch >= 0 && branch < branchFactor); - assert(node); - assert(!isEmptyBranch(branch)); + XRPL_ASSERT(branch >= 0 && branch < branchFactor); + XRPL_ASSERT(node); + XRPL_ASSERT(!isEmptyBranch(branch)); auto const childIndex = *getChildIndex(branch); auto [_, hashes, children] = hashesAndChildren_.getHashesAndChildren(); - assert(node->getHash() == hashes[childIndex]); + XRPL_ASSERT(node->getHash() == hashes[childIndex]); packed_spinlock sl(lock_, childIndex); std::lock_guard lock(sl); @@ -395,7 +395,7 @@ SHAMapInnerNode::invariants(bool is_root) const auto const branchCount = getBranchCount(); for (int i = 0; i < branchCount; ++i) { - assert(hashes[i].isNonZero()); + XRPL_ASSERT(hashes[i].isNonZero()); if (children[i] != nullptr) children[i]->invariants(); ++count; @@ -407,24 +407,24 @@ SHAMapInnerNode::invariants(bool is_root) const { if (hashes[i].isNonZero()) { - assert((isBranch_ & (1 << i)) != 0); + XRPL_ASSERT((isBranch_ & (1 << i)) != 0); if (children[i] != nullptr) children[i]->invariants(); ++count; } else { - assert((isBranch_ & (1 << i)) == 0); + XRPL_ASSERT((isBranch_ & (1 << i)) == 0); } } } if (!is_root) { - assert(hash_.isNonZero()); - assert(count >= 1); + XRPL_ASSERT(hash_.isNonZero()); + XRPL_ASSERT(count >= 1); } - assert((count == 0) ? hash_.isZero() : hash_.isNonZero()); + XRPL_ASSERT((count == 0) ? hash_.isZero() : hash_.isNonZero()); } } // namespace ripple diff --git a/src/ripple/shamap/impl/SHAMapLeafNode.cpp b/src/ripple/shamap/impl/SHAMapLeafNode.cpp index 8f634cfad88..058440c63d7 100644 --- a/src/ripple/shamap/impl/SHAMapLeafNode.cpp +++ b/src/ripple/shamap/impl/SHAMapLeafNode.cpp @@ -28,7 +28,7 @@ SHAMapLeafNode::SHAMapLeafNode( std::uint32_t cowid) : SHAMapTreeNode(cowid), item_(std::move(item)) { - assert(item_->size() >= 12); + XRPL_ASSERT(item_->size() >= 12); } SHAMapLeafNode::SHAMapLeafNode( @@ -37,7 +37,7 @@ SHAMapLeafNode::SHAMapLeafNode( SHAMapHash const& hash) : SHAMapTreeNode(cowid, hash), item_(std::move(item)) { - assert(item_->size() >= 12); + XRPL_ASSERT(item_->size() >= 12); } boost::intrusive_ptr const& @@ -49,7 +49,7 @@ SHAMapLeafNode::peekItem() const bool SHAMapLeafNode::setItem(boost::intrusive_ptr item) { - assert(cowid_ != 0); + XRPL_ASSERT(cowid_ != 0); item_ = std::move(item); auto const oldHash = hash_; @@ -87,8 +87,8 @@ SHAMapLeafNode::getString(const SHAMapNodeID& id) const void SHAMapLeafNode::invariants(bool) const { - assert(hash_.isNonZero()); - assert(item_ != nullptr); + XRPL_ASSERT(hash_.isNonZero()); + XRPL_ASSERT(item_ != nullptr); } } // namespace ripple diff --git a/src/ripple/shamap/impl/SHAMapNodeID.cpp b/src/ripple/shamap/impl/SHAMapNodeID.cpp index bcbdb7f3311..48cb6dca883 100644 --- a/src/ripple/shamap/impl/SHAMapNodeID.cpp +++ b/src/ripple/shamap/impl/SHAMapNodeID.cpp @@ -17,12 +17,12 @@ */ //============================================================================== +#include #include #include #include #include #include -#include namespace ripple { @@ -57,8 +57,8 @@ depthMask(unsigned int depth) SHAMapNodeID::SHAMapNodeID(unsigned int depth, uint256 const& hash) : id_(hash), depth_(depth) { - assert(depth <= SHAMap::leafDepth); - assert(id_ == (id_ & depthMask(depth))); + XRPL_ASSERT(depth <= SHAMap::leafDepth); + XRPL_ASSERT(id_ == (id_ & depthMask(depth))); } std::string @@ -73,7 +73,7 @@ SHAMapNodeID::getRawString() const SHAMapNodeID SHAMapNodeID::getChildNodeID(unsigned int m) const { - assert(m < SHAMap::branchFactor); + XRPL_ASSERT(m < SHAMap::branchFactor); // A SHAMap has exactly 65 levels, so nodes must not exceed that // depth; if they do, this breaks the invariant of never allowing @@ -83,7 +83,7 @@ SHAMapNodeID::getChildNodeID(unsigned int m) const // We throw (but never assert) if the node is at level 64, since // entries at that depth are leaf nodes and have no children and even // constructing a child node from them would break the above invariant. - assert(depth_ <= SHAMap::leafDepth); + XRPL_ASSERT(depth_ <= SHAMap::leafDepth); if (depth_ >= SHAMap::leafDepth) Throw( @@ -128,14 +128,14 @@ selectBranch(SHAMapNodeID const& id, uint256 const& hash) else branch >>= 4; - assert(branch < SHAMap::branchFactor); + XRPL_ASSERT(branch < SHAMap::branchFactor); return branch; } SHAMapNodeID SHAMapNodeID::createID(int depth, uint256 const& key) { - assert((depth >= 0) && (depth < 65)); + XRPL_ASSERT((depth >= 0) && (depth < 65)); return SHAMapNodeID(depth, key & depthMask(depth)); } diff --git a/src/ripple/shamap/impl/SHAMapSync.cpp b/src/ripple/shamap/impl/SHAMapSync.cpp index 3f24047eb7a..1ede95c8fbb 100644 --- a/src/ripple/shamap/impl/SHAMapSync.cpp +++ b/src/ripple/shamap/impl/SHAMapSync.cpp @@ -316,8 +316,8 @@ SHAMap::gmn_ProcessDeferredReads(MissingNodes& mn) std::vector> SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) { - assert(root_->getHash().isNonZero()); - assert(max > 0); + XRPL_ASSERT(root_->getHash().isNonZero()); + XRPL_ASSERT(max > 0); MissingNodes mn( max, @@ -376,7 +376,7 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // This is a node we are continuing to process fullBelow = fullBelow && was; // was and still is } - assert(node); + XRPL_ASSERT(node); } } @@ -407,7 +407,7 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // Resume at the top of the stack pos = mn.stack_.top(); mn.stack_.pop(); - assert(node != nullptr); + XRPL_ASSERT(node != nullptr); } } @@ -534,11 +534,11 @@ SHAMap::addRootNode( if (root_->getHash().isNonZero()) { JLOG(journal_.trace()) << "got root node, already have one"; - assert(root_->getHash() == hash); + XRPL_ASSERT(root_->getHash() == hash); return SHAMapAddNode::duplicate(); } - assert(cowid_ >= 1); + XRPL_ASSERT(cowid_ >= 1); auto node = SHAMapTreeNode::makeFromWire(rootNode); if (!node || node->getHash() != hash) return SHAMapAddNode::invalid(); @@ -572,7 +572,7 @@ SHAMap::addKnownNode( Slice const& rawNode, SHAMapSyncFilter* filter) { - assert(!node.isRoot()); + XRPL_ASSERT(!node.isRoot()); if (!isSynching()) { @@ -589,7 +589,7 @@ SHAMap::addKnownNode( (iNodeID.getDepth() < node.getDepth())) { int branch = selectBranch(iNodeID, node.getNodeID()); - assert(branch >= 0); + XRPL_ASSERT(branch >= 0); auto inner = static_cast(iNode); if (inner->isEmptyBranch(branch)) { diff --git a/src/ripple/shamap/impl/ShardFamily.cpp b/src/ripple/shamap/impl/ShardFamily.cpp index f22d4152e2b..ad47c44ce12 100644 --- a/src/ripple/shamap/impl/ShardFamily.cpp +++ b/src/ripple/shamap/impl/ShardFamily.cpp @@ -30,7 +30,7 @@ static NodeStore::Database& getShardStore(Application& app) { auto const dbPtr = app.getShardStore(); - assert(dbPtr); + XRPL_ASSERT(dbPtr); return *dbPtr; } diff --git a/src/ripple/shamap/impl/TaggedPointer.ipp b/src/ripple/shamap/impl/TaggedPointer.ipp index 7cdff6b4944..6d82cae4a6a 100644 --- a/src/ripple/shamap/impl/TaggedPointer.ipp +++ b/src/ripple/shamap/impl/TaggedPointer.ipp @@ -79,14 +79,14 @@ constexpr auto chunksPerBlock = [[nodiscard]] inline std::uint8_t numAllocatedChildren(std::uint8_t n) { - assert(n <= SHAMapInnerNode::branchFactor); + XRPL_ASSERT(n <= SHAMapInnerNode::branchFactor); return *std::lower_bound(boundaries.begin(), boundaries.end(), n); } [[nodiscard]] inline std::size_t boundariesIndex(std::uint8_t numChildren) { - assert(numChildren <= SHAMapInnerNode::branchFactor); + XRPL_ASSERT(numChildren <= SHAMapInnerNode::branchFactor); return std::distance( boundaries.begin(), std::lower_bound(boundaries.begin(), boundaries.end(), numChildren)); @@ -156,7 +156,7 @@ allocateArrays(std::uint8_t numChildren) inline void deallocateArrays(std::uint8_t boundaryIndex, void* p) { - assert(isFromArrayFuns[boundaryIndex](p)); + XRPL_ASSERT(isFromArrayFuns[boundaryIndex](p)); freeArrayFuns[boundaryIndex](p); } @@ -270,8 +270,8 @@ TaggedPointer::getChildIndex(std::uint16_t isBranch, int i) const inline TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t numChildren) { auto [tag, p] = allocateArrays(numChildren); - assert(tag < boundaries.size()); - assert( + XRPL_ASSERT(tag < boundaries.size()); + XRPL_ASSERT( (reinterpret_cast(p) & ptrMask) == reinterpret_cast(p)); tp_ = reinterpret_cast(p) + tag; @@ -283,7 +283,7 @@ inline TaggedPointer::TaggedPointer( std::uint16_t dstBranches, std::uint8_t toAllocate) { - assert(toAllocate >= popcnt16(dstBranches)); + XRPL_ASSERT(toAllocate >= popcnt16(dstBranches)); if (other.capacity() == numAllocatedChildren(toAllocate)) { @@ -428,7 +428,7 @@ inline TaggedPointer::TaggedPointer( } } // If sparse, may need to run additional constructors - assert(!dstIsDense || dstIndex == dstNumAllocated); + XRPL_ASSERT(!dstIsDense || dstIndex == dstNumAllocated); for (int i = dstIndex; i < dstNumAllocated; ++i) { new (&dstHashes[i]) SHAMapHash{}; diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index a3c4ae9800c..c77b9fc4feb 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -6086,7 +6086,7 @@ struct AMM_test : public jtx::AMMTest boost::regex_search(std::get<0>(t), match, rx); auto const poolOutIsXRP = boost::regex_search(std::get<1>(t), match, rx); - assert(!(poolInIsXRP && poolOutIsXRP)); + XRPL_ASSERT(!(poolInIsXRP && poolOutIsXRP)); auto const poolIn = getPool(std::get<0>(t), poolInIsXRP); auto const poolOut = getPool(std::get<1>(t), poolOutIsXRP); try diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 238e05ba523..248028672d3 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -142,7 +142,7 @@ class AmendmentTable_test final : public beast::unit_test::suite std::vector const& src, Args const&... args) { - assert(dest.capacity() >= dest.size() + src.size()); + XRPL_ASSERT(dest.capacity() >= dest.size() + src.size()); std::copy(src.begin(), src.end(), std::back_inserter(dest)); if constexpr (sizeof...(args) > 0) combine_arg(dest, args...); diff --git a/src/test/app/Check_test.cpp b/src/test/app/Check_test.cpp index 8f0c0ec46b8..ac03f5553cd 100644 --- a/src/test/app/Check_test.cpp +++ b/src/test/app/Check_test.cpp @@ -2016,7 +2016,7 @@ class Check_test : public beast::unit_test::suite // This capability is enabled by the featureCheckCashMakesTrustLine // amendment. So this test executes only when that amendment is // active. - assert(features[featureCheckCashMakesTrustLine]); + XRPL_ASSERT(features[featureCheckCashMakesTrustLine]); testcase("Trust Line Creation"); diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index f10633c5e46..00c54955ae4 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -294,7 +294,7 @@ struct DepositAuth_test : public beast::unit_test::suite bool noRipplePrev, bool noRippleNext, bool withDepositAuth) { - assert(!withDepositAuth || features[featureDepositAuth]); + XRPL_ASSERT(!withDepositAuth || features[featureDepositAuth]); Env env(*this, features); @@ -317,7 +317,7 @@ struct DepositAuth_test : public beast::unit_test::suite bool noRipplePrev, bool noRippleNext, bool withDepositAuth) { - assert(!withDepositAuth || features[featureDepositAuth]); + XRPL_ASSERT(!withDepositAuth || features[featureDepositAuth]); Env env(*this, features); diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index 880cbea5980..e83ca4df84c 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -52,7 +52,7 @@ class LedgerHistory_test : public beast::unit_test::suite { if (!prev) { - assert(!stx); + XRPL_ASSERT(!stx); return std::make_shared( create_genesis, env.app().config(), diff --git a/src/test/app/LedgerLoad_test.cpp b/src/test/app/LedgerLoad_test.cpp index 599215c2435..94a8784c3c1 100644 --- a/src/test/app/LedgerLoad_test.cpp +++ b/src/test/app/LedgerLoad_test.cpp @@ -44,7 +44,7 @@ class LedgerLoad_test : public beast::unit_test::suite cfg->START_LEDGER = ledger; cfg->START_UP = type; cfg->TRAP_TX_HASH = trapTxHash; - assert(!dbPath.empty()); + XRPL_ASSERT(!dbPath.empty()); cfg->legacy("database_path", dbPath); return cfg; } diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index aee24cd7d57..ff48e33f368 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -470,7 +470,7 @@ struct LedgerServer , msgHandler(env.app(), env.app().getLedgerReplayer()) , param(p) { - assert(param.initLedgers > 0); + XRPL_ASSERT(param.initLedgers > 0); createAccounts(param.initAccounts); createLedgerHistory(); app.logs().threshold(beast::severities::kWarning); @@ -499,7 +499,7 @@ struct LedgerServer sendPayments(int newTxes) { int fundedAccounts = accounts.size(); - assert(fundedAccounts >= newTxes); + XRPL_ASSERT(fundedAccounts >= newTxes); std::unordered_set senders; // somewhat random but reproducible @@ -507,7 +507,7 @@ struct LedgerServer int fromIdx = 0; int toIdx = 0; auto updateIdx = [&]() { - assert(fundedAccounts > senders.size()); + XRPL_ASSERT(fundedAccounts > senders.size()); fromIdx = (fromIdx + r) % fundedAccounts; while (senders.count(fromIdx) != 0) fromIdx = (fromIdx + 1) % fundedAccounts; diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index b72623309e9..792fb40ab8c 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -253,7 +253,7 @@ class Manifest_test : public beast::unit_test::suite jtx::Env env(*this); DatabaseCon::Setup setup; setup.dataDir = getDatabasePath(); - assert(!setup.useGlobalPragma); + XRPL_ASSERT(!setup.useGlobalPragma); auto dbCon = makeTestWalletDB(setup, dbName); diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index a479e43b170..6a7ebfe4dcd 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -152,7 +152,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(-100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt), ter(temBAD_AMOUNT)); } { @@ -161,7 +161,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt)); BEAST_EXPECT(channelBalance(*env.current(), chan) == reqBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); @@ -174,7 +174,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -197,7 +197,7 @@ struct PayChan_test : public beast::unit_test::suite auto const preBob = env.balance(bob); STAmount const authAmt = chanBal + XRP(500); STAmount const reqAmt = authAmt + STAmount{1}; - assert(reqAmt <= chanAmt); + XRPL_ASSERT(reqAmt <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqAmt, authAmt, Slice(sig), alice.pk()), @@ -248,7 +248,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - assert(delta > beast::zero); + XRPL_ASSERT(delta > beast::zero); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } @@ -369,7 +369,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -499,7 +499,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -518,7 +518,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -590,7 +590,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); @@ -607,7 +607,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); @@ -1736,7 +1736,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(50); auto reqBal = chanBal + delta; auto authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); // claim should fail if the dst was removed if (withOwnerDirFix) @@ -1822,7 +1822,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(50); auto reqBal = chanBal + delta; auto authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); { // claim should fail, since bob doesn't exist @@ -1959,7 +1959,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt), ticket::use(aliceTicketSeq++)); @@ -1977,7 +1977,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()), @@ -2011,7 +2011,7 @@ struct PayChan_test : public beast::unit_test::suite auto const preBob = env.balance(bob); STAmount const authAmt = chanBal + XRP(500); STAmount const reqAmt = authAmt + drops(1); - assert(reqAmt <= chanAmt); + XRPL_ASSERT(reqAmt <= chanAmt); // Note that since claim() returns a tem (neither tec nor tes), // the ticket is not consumed. So we don't increment bobTicket. auto const sig = @@ -2053,7 +2053,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - assert(delta > beast::zero); + XRPL_ASSERT(delta > beast::zero); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index ae17b8e0d43..58e13c7cfd2 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -271,7 +271,7 @@ class ElementComboIter std::optional const& existingCur, std::optional const& existingIss) { - assert(!has(SB::last)); + XRPL_ASSERT(!has(SB::last)); auto const acc = [&]() -> std::optional { if (!has(SB::acc)) @@ -322,14 +322,14 @@ struct ExistingElementPool jtx::Account getAccount(size_t id) { - assert(id < accounts.size()); + XRPL_ASSERT(id < accounts.size()); return accounts[id]; } ripple::Currency getCurrency(size_t id) { - assert(id < currencies.size()); + XRPL_ASSERT(id < currencies.size()); return currencies[id]; } @@ -380,7 +380,7 @@ struct ExistingElementPool { using namespace jtx; - assert(!offererIndex || offererIndex < numAct); + XRPL_ASSERT(!offererIndex || offererIndex < numAct); accounts.clear(); accounts.reserve(numAct); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index f743a30f079..f03fc395214 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -145,7 +145,7 @@ struct Regression_test : public beast::unit_test::suite // Set the same key in the STTx. auto secp256r1Sig = std::make_unique(*(jt.stx)); auto pubKeyBlob = strUnHex(secp256r1PubKey); - assert(pubKeyBlob); // Hex for public key must be valid + XRPL_ASSERT(pubKeyBlob); // Hex for public key must be valid secp256r1Sig->setFieldVL(sfSigningPubKey, *pubKeyBlob); jt.stx.reset(secp256r1Sig.release()); diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index ae537a45657..f6f2796b4bf 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -64,7 +64,7 @@ struct RippleCalcTestParams { if (pe.isMember(jss::account)) { - assert( + XRPL_ASSERT( !pe.isMember(jss::currency) && !pe.isMember(jss::issuer)); p.emplace_back( @@ -83,13 +83,13 @@ struct RippleCalcTestParams issuer = *parseBase58( pe[jss::issuer].asString()); else - assert(isXRP(*parseBase58( + XRPL_ASSERT(isXRP(*parseBase58( pe[jss::issuer].asString()))); p.emplace_back(std::nullopt, currency, issuer); } else { - assert(0); + XRPL_ASSERT(0); } } paths.emplace_back(std::move(p)); diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index a0837782a9c..8d62e8b67d7 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -4426,7 +4426,8 @@ struct XChainSim_test : public beast::unit_test::suite, c.num_create_attn_sent += sendCreateAttestations( i, bridge, create_claims); } - assert(claims.create_claims[c.claim_count].empty()); + XRPL_ASSERT( + claims.create_claims[c.claim_count].empty()); } } for (auto& [bridge, c] : counters) @@ -4705,11 +4706,11 @@ struct XChainSim_test : public beast::unit_test::suite, auto complete_cb = [&](std::vector const& signers) { auto num_attestors = signers.size(); st.env.close(); - assert( + XRPL_ASSERT( num_attestors <= std::count(cr.attested.begin(), cr.attested.end(), true)); - assert(num_attestors >= bridge_.quorum); - assert(cr.claim_id - 1 == counters.claim_count); + XRPL_ASSERT(num_attestors >= bridge_.quorum); + XRPL_ASSERT(cr.claim_id - 1 == counters.claim_count); auto r = cr.reward; auto reward = divide(r, STAmount(num_attestors), r.issue()); @@ -4741,7 +4742,7 @@ struct XChainSim_test : public beast::unit_test::suite, break; default: - assert(0); + XRPL_ASSERT(0); break; case st_completed: @@ -4905,14 +4906,14 @@ struct XChainSim_test : public beast::unit_test::suite, break; case st_attested: - assert(xfer.with_claim == WithClaim::yes); + XRPL_ASSERT(xfer.with_claim == WithClaim::yes); claim(); sm_state = st_completed; break; default: case st_completed: - assert(0); // should have been removed + XRPL_ASSERT(0); // should have been removed break; } return sm_state; diff --git a/src/test/basics/base58_test.cpp b/src/test/basics/base58_test.cpp index 6f3d495d7a9..0c86ab39f35 100644 --- a/src/test/basics/base58_test.cpp +++ b/src/test/basics/base58_test.cpp @@ -51,7 +51,7 @@ constexpr int numTokenTypeIndexes = 9; [[nodiscard]] inline auto tokenTypeAndSize(int i) -> std::tuple { - assert(i < numTokenTypeIndexes); + XRPL_ASSERT(i < numTokenTypeIndexes); switch (i) { diff --git a/src/test/basics/base_uint_test.cpp b/src/test/basics/base_uint_test.cpp index 9b1f7696dd5..bd309456c83 100644 --- a/src/test/basics/base_uint_test.cpp +++ b/src/test/basics/base_uint_test.cpp @@ -44,7 +44,7 @@ struct nonhash void operator()(void const* key, std::size_t len) noexcept { - assert(len == WIDTH); + XRPL_ASSERT(len == WIDTH); memcpy(data_.data(), key, len); } diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index 8cbb57444bd..7ff3346b447 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -594,7 +594,7 @@ struct NetworkHistory void createNodes() { - assert(param.numNodes <= 256); + XRPL_ASSERT(param.numNodes <= 256); UNLKeys = createPublicKeys(param.numNodes); for (int i = 0; i < param.numNodes; ++i) { diff --git a/src/test/csf/BasicNetwork.h b/src/test/csf/BasicNetwork.h index 3ce159a2333..e48948d4edd 100644 --- a/src/test/csf/BasicNetwork.h +++ b/src/test/csf/BasicNetwork.h @@ -215,7 +215,7 @@ BasicNetwork::connect( return false; auto const result = links_.connect(to, from, link_type{true, delay, now}); (void)result; - assert(result); + XRPL_ASSERT(result); return true; } @@ -227,7 +227,7 @@ BasicNetwork::disconnect(Peer const& peer1, Peer const& peer2) return false; bool r = links_.disconnect(peer2, peer1); (void)r; - assert(r); + XRPL_ASSERT(r); return true; } diff --git a/src/test/csf/Histogram.h b/src/test/csf/Histogram.h index 2df1844a21d..af2ce4909d9 100644 --- a/src/test/csf/Histogram.h +++ b/src/test/csf/Histogram.h @@ -19,8 +19,8 @@ #ifndef RIPPLE_TEST_CSF_HISTOGRAM_H_INCLUDED #define RIPPLE_TEST_CSF_HISTOGRAM_H_INCLUDED +#include #include -#include #include #include #include @@ -110,7 +110,7 @@ class Histogram T percentile(float p) const { - assert(p >= 0 && p <= 1); + XRPL_ASSERT(p >= 0 && p <= 1); std::size_t pos = std::round(p * samples); if (counts_.empty()) diff --git a/src/test/csf/PeerGroup.h b/src/test/csf/PeerGroup.h index 1f3421a4adb..5051dbad0de 100644 --- a/src/test/csf/PeerGroup.h +++ b/src/test/csf/PeerGroup.h @@ -303,7 +303,7 @@ randomRankedGroups( RandomNumberDistribution sizeDist, Generator& g) { - assert(peers.size() == ranks.size()); + XRPL_ASSERT(peers.size() == ranks.size()); std::vector groups; groups.reserve(numGroups); diff --git a/src/test/csf/README.md b/src/test/csf/README.md index ff6bdc5dfac..801e514b76f 100644 --- a/src/test/csf/README.md +++ b/src/test/csf/README.md @@ -81,7 +81,7 @@ for (Peer * p : validators) sim.run(1); std::cout << (simDur.stop - simDur.start).count() << std::endl; -assert(sim.synchronized()); +XRPL_ASSERT(sim.synchronized()); ``` ### `Sim` and `PeerGroup` diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 352aa4cb8c2..b91d473b700 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -239,7 +239,7 @@ struct TxCollector { Tracker& tracker = it->second; // Should only validated a previously accepted Tx - assert(tracker.accepted); + XRPL_ASSERT(tracker.accepted); tracker.validated = when; validated++; @@ -501,7 +501,7 @@ struct LedgerCollector if (e.prior.id() == e.ledger.parentID()) { auto const it = ledgers_.find(e.ledger.id()); - assert(it != ledgers_.end()); + XRPL_ASSERT(it != ledgers_.end()); auto& tracker = it->second; // first time fully validated if (!tracker.fullyValidated) diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index 987c5e706c6..eca7b27427a 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -345,7 +345,7 @@ struct LedgerHistoryHelper return it->second; // enforce that the new suffix has never been seen - assert(seen.emplace(s.back()).second); + XRPL_ASSERT(seen.emplace(s.back()).second); Ledger const& parent = (*this)[s.substr(0, s.size() - 1)]; return ledgers.emplace(s, oracle.accept(parent, Tx{++nextTx})) diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index 38cdb201854..afd231e4045 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -432,7 +432,7 @@ AMM::deposit( std::optional const& flags, std::optional const& ter) { - assert(!(asset2In && maxEP)); + XRPL_ASSERT(!(asset2In && maxEP)); return deposit( account, std::nullopt, @@ -556,7 +556,7 @@ AMM::withdraw( std::optional const& maxEP, std::optional const& ter) { - assert(!(asset2Out && maxEP)); + XRPL_ASSERT(!(asset2Out && maxEP)); return withdraw( account, std::nullopt, @@ -661,7 +661,7 @@ AMM::bid(BidArg const& arg) if (auto const amm = env_.current()->read(keylet::amm(asset1_.issue(), asset2_.issue()))) { - assert( + XRPL_ASSERT( !env_.current()->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) @@ -756,7 +756,7 @@ AMM::expectAuctionSlot(auto&& cb) const if (auto const amm = env_.current()->read(keylet::amm(asset1_.issue(), asset2_.issue()))) { - assert( + XRPL_ASSERT( !env_.current()->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) diff --git a/src/test/jtx/impl/Account.cpp b/src/test/jtx/impl/Account.cpp index a17186d4ffb..eaaef1d595d 100644 --- a/src/test/jtx/impl/Account.cpp +++ b/src/test/jtx/impl/Account.cpp @@ -89,7 +89,7 @@ IOU Account::operator[](std::string const& s) const { auto const currency = to_currency(s); - assert(currency != noCurrency()); + XRPL_ASSERT(currency != noCurrency()); return IOU(*this, currency); } diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 884caf9162e..300cac32c11 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -357,7 +357,7 @@ Env::sign_and_submit(JTx const& jt, Json::Value params) { // Use the provided parameters, and go straight // to the (RPC) client. - assert(params.isObject()); + XRPL_ASSERT(params.isObject()); if (!params.isMember(jss::secret) && !params.isMember(jss::key_type) && !params.isMember(jss::seed) && !params.isMember(jss::seed_hex) && !params.isMember(jss::passphrase)) diff --git a/src/test/jtx/impl/Oracle.cpp b/src/test/jtx/impl/Oracle.cpp index 34249a61228..a28630d1fa0 100644 --- a/src/test/jtx/impl/Oracle.cpp +++ b/src/test/jtx/impl/Oracle.cpp @@ -100,7 +100,7 @@ Oracle::submit( bool Oracle::exists(Env& env, AccountID const& account, std::uint32_t documentID) { - assert(account.isNonZero()); + XRPL_ASSERT(account.isNonZero()); return env.le(keylet::oracle(account, documentID)) != nullptr; } @@ -243,7 +243,7 @@ Oracle::set(UpdateArg const& arg) // assume standard currency if (s.size() == 3) return s; - assert(s.size() <= 20); + XRPL_ASSERT(s.size() <= 20); // anything else must be 160-bit hex string std::string h = strHex(s); return strHex(s).append(40 - s.size() * 2, '0'); diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 86f51d135d7..5b94c1f1464 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include #include #include #include @@ -56,7 +56,7 @@ template static std::string to_places(const T d, std::uint8_t places) { - assert(places <= std::numeric_limits::digits10); + XRPL_ASSERT(places <= std::numeric_limits::digits10); std::ostringstream oss; oss << std::setprecision(places) << std::fixed << d; diff --git a/src/test/jtx/impl/quality2.cpp b/src/test/jtx/impl/quality2.cpp index e1837035e2d..9855ce39467 100644 --- a/src/test/jtx/impl/quality2.cpp +++ b/src/test/jtx/impl/quality2.cpp @@ -28,13 +28,13 @@ namespace jtx { qualityInPercent::qualityInPercent(double percent) : qIn_(static_cast((percent / 100) * QUALITY_ONE)) { - assert(percent <= 400 && percent >= 0); + XRPL_ASSERT(percent <= 400 && percent >= 0); } qualityOutPercent::qualityOutPercent(double percent) : qOut_(static_cast((percent / 100) * QUALITY_ONE)) { - assert(percent <= 400 && percent >= 0); + XRPL_ASSERT(percent <= 400 && percent >= 0); } static void diff --git a/src/test/jtx/impl/xchain_bridge.cpp b/src/test/jtx/impl/xchain_bridge.cpp index 0b81ccdcd91..aa03311d9fd 100644 --- a/src/test/jtx/impl/xchain_bridge.cpp +++ b/src/test/jtx/impl/xchain_bridge.cpp @@ -316,8 +316,8 @@ claim_attestations( std::size_t const numAtts, std::size_t const fromIdx) { - assert(fromIdx + numAtts <= rewardAccounts.size()); - assert(fromIdx + numAtts <= signers.size()); + XRPL_ASSERT(fromIdx + numAtts <= rewardAccounts.size()); + XRPL_ASSERT(fromIdx + numAtts <= signers.size()); JValueVec vec; vec.reserve(numAtts); for (auto i = fromIdx; i < fromIdx + numAtts; ++i) @@ -349,8 +349,8 @@ create_account_attestations( std::size_t const numAtts, std::size_t const fromIdx) { - assert(fromIdx + numAtts <= rewardAccounts.size()); - assert(fromIdx + numAtts <= signers.size()); + XRPL_ASSERT(fromIdx + numAtts <= rewardAccounts.size()); + XRPL_ASSERT(fromIdx + numAtts <= signers.size()); JValueVec vec; vec.reserve(numAtts); for (auto i = fromIdx; i < fromIdx + numAtts; ++i) diff --git a/src/test/nodestore/DatabaseShard_test.cpp b/src/test/nodestore/DatabaseShard_test.cpp index 5c074b14938..7db7061c88d 100644 --- a/src/test/nodestore/DatabaseShard_test.cpp +++ b/src/test/nodestore/DatabaseShard_test.cpp @@ -134,7 +134,7 @@ struct uniformIntDistribution static_assert( Generator::min() == 0, "If non-zero we have handle the offset"); const resultType range = b - a + 1; - assert(Generator::max() >= range); // Just for safety + XRPL_ASSERT(Generator::max() >= range); // Just for safety const resultType rejectLim = g.max() % range; resultType n; do @@ -148,7 +148,7 @@ template Integral randInt(Engine& engine, Integral min, Integral max) { - assert(max > min); + XRPL_ASSERT(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/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 025e3295f2a..f9c4080b88a 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -266,7 +266,7 @@ class Link : validator_(validator), peer_(peer), latency_(latency), up_(true) { auto sp = peer_.lock(); - assert(sp); + XRPL_ASSERT(sp); } ~Link() = default; void @@ -275,7 +275,7 @@ class Link if (!up_) return; auto sp = peer_.lock(); - assert(sp); + XRPL_ASSERT(sp); auto peer = std::dynamic_pointer_cast(sp); peer->onMessage(m, f); } @@ -293,14 +293,14 @@ class Link peerId() { auto p = peer_.lock(); - assert(p); + XRPL_ASSERT(p); return p->id(); } PeerSPtr getPeer() { auto p = peer_.lock(); - assert(p); + XRPL_ASSERT(p); return p; } @@ -376,7 +376,7 @@ class Validator { for (auto id : peers) { - assert(links_.find(id) != links_.end()); + XRPL_ASSERT(links_.find(id) != links_.end()); f(*links_[id], message_); } } @@ -429,7 +429,7 @@ class Validator linkUp(Peer::id_t id) { auto it = links_.find(id); - assert(it != links_.end()); + XRPL_ASSERT(it != links_.end()); it->second->up(true); } @@ -437,7 +437,7 @@ class Validator linkDown(Peer::id_t id) { auto it = links_.find(id); - assert(it != links_.end()); + XRPL_ASSERT(it != links_.end()); it->second->up(false); } @@ -478,7 +478,7 @@ class PeerSim : public PeerPartial, public std::enable_shared_from_this onMessage(MessageSPtr const& m, SquelchCB f) override { auto validator = m->getValidatorKey(); - assert(validator); + XRPL_ASSERT(validator); if (!squelch_.expireSquelch(*validator)) return; @@ -584,7 +584,7 @@ class OverlaySim : public Overlay, public reduce_relay::SquelchHandler deletePeer(Peer::id_t id, bool useCache = true) { auto it = peers_.find(id); - assert(it != peers_.end()); + XRPL_ASSERT(it != peers_.end()); deletePeer(id, [&](PublicKey const&, PeerWPtr) {}); if (useCache) peersCache_.emplace(std::make_pair(id, it->second)); @@ -643,7 +643,7 @@ class OverlaySim : public Overlay, public reduce_relay::SquelchHandler getSelectedPeer(PublicKey const& validator) { auto selected = slots_.getSelected(validator); - assert(selected.size()); + XRPL_ASSERT(selected.size()); return *selected.begin(); } @@ -752,7 +752,7 @@ class Network Validator& validator(std::uint16_t v) { - assert(v < validators_.size()); + XRPL_ASSERT(v < validators_.size()); return validators_[v]; } @@ -769,7 +769,7 @@ class Network std::find_if(validators_.begin(), validators_.end(), [&](auto& v) { return v.id() == validatorId; }); - assert(it != validators_.end()); + XRPL_ASSERT(it != validators_.end()); if (enable) it->linkUp(peer); else @@ -911,7 +911,7 @@ class reduce_relay_test : public beast::unit_test::suite if (res) squelch.set_squelchduration(*duration); auto sp = peerPtr.lock(); - assert(sp); + XRPL_ASSERT(sp); std::dynamic_pointer_cast(sp)->send(squelch); return sp->id(); } @@ -958,7 +958,7 @@ class reduce_relay_test : public beast::unit_test::suite [&](PublicKey const& key, PeerWPtr const& peerPtr, std::uint32_t duration) { - assert(key == validator); + XRPL_ASSERT(key == validator); auto p = sendSquelch(key, peerPtr, duration); squelched = true; str << p << " "; @@ -1295,7 +1295,7 @@ class reduce_relay_test : public beast::unit_test::suite return std::get(it.second) == reduce_relay::PeerState::Squelched; }); - assert(it != peers.end()); + XRPL_ASSERT(it != peers.end()); std::uint16_t unsquelched = 0; network_.overlay().deletePeer( it->first, [&](PublicKey const& key, PeerWPtr const& peer) { diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index 434b4100852..79f3de56d68 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -26,7 +27,6 @@ #include #include -#include #include #include #include @@ -112,7 +112,7 @@ class short_read_test : public beast::unit_test::suite ~Base() { // Derived class must call wait() in the destructor - assert(list_.empty()); + XRPL_ASSERT(list_.empty()); } void diff --git a/src/test/overlay/tx_reduce_relay_test.cpp b/src/test/overlay/tx_reduce_relay_test.cpp index 7b26ad0962f..8d30087ce88 100644 --- a/src/test/overlay/tx_reduce_relay_test.cpp +++ b/src/test/overlay/tx_reduce_relay_test.cpp @@ -193,7 +193,7 @@ class tx_reduce_relay_test : public beast::unit_test::suite peers.emplace_back(peer); // overlay stores week ptr to PeerImp lid_ += 2; rid_ += 2; - assert(lid_ <= 254); + XRPL_ASSERT(lid_ <= 254); } void diff --git a/src/test/rpc/Handler_test.cpp b/src/test/rpc/Handler_test.cpp index 5160a68aac2..3da5f38cbd4 100644 --- a/src/test/rpc/Handler_test.cpp +++ b/src/test/rpc/Handler_test.cpp @@ -51,7 +51,7 @@ class Handler_test : public beast::unit_test::suite time(std::size_t n, auto f, auto prng) -> auto { using clock = std::chrono::steady_clock; - assert(n > 0); + XRPL_ASSERT(n > 0); double sum = 0; double sum_squared = 0; std::size_t j = 0; diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index 8fd453ee9f6..6b64fcb8bac 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -2586,7 +2586,7 @@ class JSONRPC_test : public beast::unit_test::suite auto const signFn = get<0>(testFunc); if (signFn != nullptr) { - assert(get<1>(testFunc) == nullptr); + XRPL_ASSERT(get<1>(testFunc) == nullptr); result = signFn( req, 1, @@ -2598,7 +2598,7 @@ class JSONRPC_test : public beast::unit_test::suite else { auto const submitFn = get<1>(testFunc); - assert(submitFn != nullptr); + XRPL_ASSERT(submitFn != nullptr); result = submitFn( req, 1, diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp index f15f3163e55..5e49bc4e223 100644 --- a/src/test/shamap/FetchPack_test.cpp +++ b/src/test/shamap/FetchPack_test.cpp @@ -101,7 +101,7 @@ class FetchPack_test : public beast::unit_test::suite { auto const result(t.addItem( SHAMapNodeType::tnACCOUNT_STATE, make_random_item(r))); - assert(result); + XRPL_ASSERT(result); (void)result; } } diff --git a/src/test/unit_test/multi_runner.cpp b/src/test/unit_test/multi_runner.cpp index cd84c3c999f..67950f9a468 100644 --- a/src/test/unit_test/multi_runner.cpp +++ b/src/test/unit_test/multi_runner.cpp @@ -19,6 +19,7 @@ #include +#include #include #include @@ -419,7 +420,7 @@ multi_runner_parent::multi_runner_parent() : os_(std::cout) buf.data(), buf.size(), recvd_size, priority); if (!recvd_size) continue; - assert(recvd_size == 1); + XRPL_ASSERT(recvd_size == 1); MessageType mt{*reinterpret_cast(buf.data())}; this->message_queue_->receive( @@ -440,7 +441,7 @@ multi_runner_parent::multi_runner_parent() : os_(std::cout) running_suites_.erase(s); break; default: - assert(0); // unknown message type + XRPL_ASSERT(0); // unknown message type } } }