diff --git a/include/xrpl/shamap/SHAMapMissingNode.h b/include/xrpl/shamap/SHAMapMissingNode.h index 3168d0eff1..95253ec6d3 100644 --- a/include/xrpl/shamap/SHAMapMissingNode.h +++ b/include/xrpl/shamap/SHAMapMissingNode.h @@ -35,13 +35,15 @@ to_string(SHAMapType t) class SHAMapMissingNode : public std::runtime_error { public: - SHAMapMissingNode(SHAMapType t, SHAMapHash const& hash) - : std::runtime_error("Missing Node: " + to_string(t) + ": hash " + to_string(hash)) + SHAMapMissingNode(SHAMapType t, SHAMapHash const& hash, std::string const& location) + : std::runtime_error( + "Missing Node: " + to_string(t) + ": hash " + to_string(hash) + " in: " + location) { } - SHAMapMissingNode(SHAMapType t, uint256 const& id) - : std::runtime_error("Missing Node: " + to_string(t) + ": id " + to_string(id)) + SHAMapMissingNode(SHAMapType t, uint256 const& id, std::string const& location) + : std::runtime_error( + "Missing Node: " + to_string(t) + ": id " + to_string(id) + " in: " + location) { } }; diff --git a/src/libxrpl/ledger/Ledger.cpp b/src/libxrpl/ledger/Ledger.cpp index 188fb3cd2c..0ed9f643c8 100644 --- a/src/libxrpl/ledger/Ledger.cpp +++ b/src/libxrpl/ledger/Ledger.cpp @@ -746,7 +746,8 @@ Ledger::walkLedger(beast::Journal j, bool parallel) const if (stateMap_.getHash().isZero() && !header_.accountHash.isZero() && !stateMap_.fetchRoot(SHAMapHash{header_.accountHash}, nullptr)) { - missingNodes1.emplace_back(SHAMapType::STATE, SHAMapHash{header_.accountHash}); + missingNodes1.emplace_back( + SHAMapType::STATE, SHAMapHash{header_.accountHash}, "Ledger::walkLedger"); } else { @@ -770,7 +771,8 @@ Ledger::walkLedger(beast::Journal j, bool parallel) const if (txMap_.getHash().isZero() && header_.txHash.isNonZero() && !txMap_.fetchRoot(SHAMapHash{header_.txHash}, nullptr)) { - missingNodes2.emplace_back(SHAMapType::TRANSACTION, SHAMapHash{header_.txHash}); + missingNodes2.emplace_back( + SHAMapType::TRANSACTION, SHAMapHash{header_.txHash}, "Ledger::walkLedger"); } else { diff --git a/src/libxrpl/shamap/SHAMap.cpp b/src/libxrpl/shamap/SHAMap.cpp index 0df0430a5f..bd782fe2d4 100644 --- a/src/libxrpl/shamap/SHAMap.cpp +++ b/src/libxrpl/shamap/SHAMap.cpp @@ -272,7 +272,7 @@ SHAMap::fetchNode(SHAMapHash const& hash) const auto node = fetchNodeNT(hash); if (!node) - Throw(type_, hash); + Throw(type_, hash, "fetchNode"); return node; } @@ -283,7 +283,7 @@ SHAMap::descendThrow(SHAMapInnerNode* parent, int branch) const SHAMapTreeNode* ret = descend(parent, branch); // NOLINT(misc-const-correctness) if ((ret == nullptr) && !parent->isEmptyBranch(branch)) - Throw(type_, parent->getChildHash(branch)); + Throw(type_, parent->getChildHash(branch), "descendThrow"); return ret; } @@ -294,7 +294,7 @@ SHAMap::descendThrow(SHAMapInnerNode& parent, int branch) const SHAMapTreeNodePtr ret = descend(parent, branch); if (!ret && !parent.isEmptyBranch(branch)) - Throw(type_, parent.getChildHash(branch)); + Throw(type_, parent.getChildHash(branch), "descendThrow"); return ret; } @@ -566,7 +566,7 @@ SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const node = descendThrow(*inner, i); auto leaf = firstBelow(node, stack, i); if (leaf == nullptr) - Throw(type_, id); + Throw(type_, id, "peekNextItem"); XRPL_ASSERT(leaf->isLeaf(), "xrpl::SHAMap::peekNextItem : leaf is valid"); return leaf; } @@ -624,7 +624,7 @@ SHAMap::upperBound(uint256 const& id) const node = descendThrow(*inner, branch); auto leaf = firstBelow(node, stack, branch); if (leaf == nullptr) - Throw(type_, id); + Throw(type_, id, "upperBound"); return ConstIterator(this, leaf->peekItem().get(), std::move(stack)); } } @@ -657,7 +657,7 @@ SHAMap::lowerBound(uint256 const& id) const node = descendThrow(*inner, branch); auto leaf = lastBelow(node, stack, branch); if (leaf == nullptr) - Throw(type_, id); + Throw(type_, id, "lowerBound"); return ConstIterator(this, leaf->peekItem().get(), std::move(stack)); } } @@ -684,7 +684,7 @@ SHAMap::delItem(uint256 const& id) walkTowardsKey(id, &stack); if (stack.empty()) - Throw(type_, id); + Throw(type_, id, "delItem"); auto leaf = intr_ptr::dynamicPointerCast(stack.top().first); stack.pop(); @@ -770,7 +770,7 @@ SHAMap::addGiveItem(SHAMapNodeType type, boost::intrusive_ptr walkTowardsKey(tag, &stack); if (stack.empty()) - Throw(type_, tag); + Throw(type_, tag, "addGiveItem"); auto [node, nodeID] = stack.top(); stack.pop(); @@ -857,7 +857,7 @@ SHAMap::updateGiveItem(SHAMapNodeType type, boost::intrusive_ptr(type_, tag); + Throw(type_, tag, "updateGiveItem"); auto node = intr_ptr::dynamicPointerCast(stack.top().first); auto nodeID = stack.top().second; diff --git a/src/libxrpl/shamap/SHAMapDelta.cpp b/src/libxrpl/shamap/SHAMapDelta.cpp index 8336ce5481..1d985e71a1 100644 --- a/src/libxrpl/shamap/SHAMapDelta.cpp +++ b/src/libxrpl/shamap/SHAMapDelta.cpp @@ -153,7 +153,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const { // LCOV_EXCL_START UNREACHABLE("xrpl::SHAMap::compare : missing a node"); - Throw(type_, uint256()); + Throw(type_, uint256(), "compare"); // LCOV_EXCL_STOP } @@ -270,7 +270,7 @@ SHAMap::walkMap(std::vector& missingNodes, int maxMissing) co } else { - missingNodes.emplace_back(type_, node->getChildHash(i)); + missingNodes.emplace_back(type_, node->getChildHash(i), "walkMap"); if (--maxMissing <= 0) return; } @@ -344,7 +344,8 @@ SHAMap::walkMapParallel(std::vector& missingNodes, int maxMis else { std::scoped_lock const l{m}; - missingNodes.emplace_back(type_, node->getChildHash(i)); + missingNodes.emplace_back( + type_, node->getChildHash(i), "walkMapParallel"); if (--maxMissing <= 0) return; }