diff --git a/src/ripple/shamap/Family.h b/src/ripple/shamap/Family.h index 72c9a6cb07a..cd3f9cdd001 100644 --- a/src/ripple/shamap/Family.h +++ b/src/ripple/shamap/Family.h @@ -76,7 +76,7 @@ class Family isShardBacked() const = 0; virtual void - missingNode(std::uint32_t refNum) = 0; + missingNode(std::uint32_t refNum, uint256 const& nodeHash) = 0; virtual void missingNode(uint256 const& refHash, std::uint32_t refNum) = 0; diff --git a/src/ripple/shamap/NodeFamily.h b/src/ripple/shamap/NodeFamily.h index 2d8236705b5..2c67622b33a 100644 --- a/src/ripple/shamap/NodeFamily.h +++ b/src/ripple/shamap/NodeFamily.h @@ -83,7 +83,7 @@ class NodeFamily : public Family reset() override; void - missingNode(std::uint32_t seq) override; + missingNode(std::uint32_t seq, uint256 const& hash) override; void missingNode(uint256 const& hash, std::uint32_t seq) override diff --git a/src/ripple/shamap/SHAMapMissingNode.h b/src/ripple/shamap/SHAMapMissingNode.h index 811fe5f9615..07a521cd049 100644 --- a/src/ripple/shamap/SHAMapMissingNode.h +++ b/src/ripple/shamap/SHAMapMissingNode.h @@ -33,6 +33,7 @@ enum class SHAMapType { TRANSACTION = 1, // A tree of transactions STATE = 2, // A tree of state nodes FREE = 3, // A tree not part of a ledger + UNKNOWN = 4 // Could be any type, but it's not there nonetheless }; inline std::string @@ -46,6 +47,8 @@ to_string(SHAMapType t) return "State Tree"; case SHAMapType::FREE: return "Free Tree"; + case SHAMapType::UNKNOWN: + return "Unknown Tree"; default: return std::to_string( safe_cast>(t)); @@ -66,6 +69,13 @@ class SHAMapMissingNode : public std::runtime_error "Missing Node: " + to_string(t) + ": id " + to_string(id)) { } + + SHAMapMissingNode(uint256 const& id) + : std::runtime_error( + "Missing Node: " + to_string(SHAMapType::UNKNOWN) + ": hash " + + to_string(id)) + { + } }; } // namespace ripple diff --git a/src/ripple/shamap/ShardFamily.h b/src/ripple/shamap/ShardFamily.h index 550efeb5b81..c7cbb8d3d00 100644 --- a/src/ripple/shamap/ShardFamily.h +++ b/src/ripple/shamap/ShardFamily.h @@ -89,7 +89,7 @@ class ShardFamily : public Family reset() override; void - missingNode(std::uint32_t seq) override; + missingNode(std::uint32_t seq, uint256 const& nodeHash) override; void missingNode(uint256 const& hash, std::uint32_t seq) override diff --git a/src/ripple/shamap/impl/NodeFamily.cpp b/src/ripple/shamap/impl/NodeFamily.cpp index f9c6dedb265..0f851606e4a 100644 --- a/src/ripple/shamap/impl/NodeFamily.cpp +++ b/src/ripple/shamap/impl/NodeFamily.cpp @@ -20,7 +20,9 @@ #include #include #include +#include #include +#include namespace ripple { @@ -65,9 +67,11 @@ NodeFamily::reset() } void -NodeFamily::missingNode(std::uint32_t seq) +NodeFamily::missingNode(std::uint32_t seq, uint256 const& nodeHash) { JLOG(j_.error()) << "Missing node in " << seq; + if (app_.config().reporting()) + Throw(nodeHash); std::unique_lock lock(maxSeqMutex_); if (maxSeq_ == 0) diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index 1a5a283dd3c..cd9ba05736e 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -178,7 +178,7 @@ SHAMap::finishFetch( if (full_) { full_ = false; - f_.missingNode(ledgerSeq_); + f_.missingNode(ledgerSeq_, hash.as_uint256()); } return {}; } diff --git a/src/ripple/shamap/impl/ShardFamily.cpp b/src/ripple/shamap/impl/ShardFamily.cpp index eadfc42aa27..16423a65b7c 100644 --- a/src/ripple/shamap/impl/ShardFamily.cpp +++ b/src/ripple/shamap/impl/ShardFamily.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace ripple { @@ -152,8 +153,9 @@ ShardFamily::reset() } void -ShardFamily::missingNode(std::uint32_t seq) +ShardFamily::missingNode(std::uint32_t seq, uint256 const& nodeHash) { + std::ignore = nodeHash; JLOG(j_.error()) << "Missing node in ledger sequence " << seq; std::unique_lock lock(maxSeqMutex_); diff --git a/src/test/shamap/common.h b/src/test/shamap/common.h index c4238b2a65f..fd9da468348 100644 --- a/src/test/shamap/common.h +++ b/src/test/shamap/common.h @@ -105,7 +105,7 @@ class TestNodeFamily : public Family } void - missingNode(std::uint32_t refNum) override + missingNode(std::uint32_t refNum, uint256 const& nodeHash) override { Throw("missing node"); }