Skip to content

Commit

Permalink
Do not attempt to acquire missing data from peer network in
Browse files Browse the repository at this point in the history
reporting mode.
  • Loading branch information
mtrippled committed Mar 9, 2023
1 parent 8687b5c commit 2b5f18d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ripple/shamap/Family.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/shamap/NodeFamily.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/ripple/shamap/SHAMapMissingNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<std::underlying_type_t<SHAMapType>>(t));
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/shamap/ShardFamily.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/ripple/shamap/impl/NodeFamily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/main/Application.h>
#include <ripple/app/main/Tuning.h>
#include <ripple/basics/contract.h>
#include <ripple/shamap/NodeFamily.h>
#include <ripple/shamap/SHAMapMissingNode.h>

namespace ripple {

Expand Down Expand Up @@ -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<SHAMapMissingNode>(nodeHash);

std::unique_lock<std::mutex> lock(maxSeqMutex_);
if (maxSeq_ == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/shamap/impl/SHAMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ SHAMap::finishFetch(
if (full_)
{
full_ = false;
f_.missingNode(ledgerSeq_);
f_.missingNode(ledgerSeq_, hash.as_uint256());
}
return {};
}
Expand Down
4 changes: 3 additions & 1 deletion src/ripple/shamap/impl/ShardFamily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <ripple/app/main/Tuning.h>
#include <ripple/nodestore/DatabaseShard.h>
#include <ripple/shamap/ShardFamily.h>
#include <tuple>

namespace ripple {

Expand Down Expand Up @@ -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<std::mutex> lock(maxSeqMutex_);
Expand Down
2 changes: 1 addition & 1 deletion src/test/shamap/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::runtime_error>("missing node");
}
Expand Down

0 comments on commit 2b5f18d

Please sign in to comment.