mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-01 07:55:49 +00:00
Adjust pathfinding configuration defaults:
The pathfinding engine built into the code has several configurable parameters to adjust the depth of the paths indexed and explored. These parameters can dramatically impact the performance and memory consumption of a server; higher values can result in resource usage increasing exponentially. These default values were decided early and somewhat arbitrarily at a time when the network and the size of the network state were much smaller. This commit adjusts the default values to reduce the depth of paths to more reasonable levels; unless explicitly overriden, the changes mean that pathfinding operations will return fewer, shallower paths than previous versions of the software.
This commit is contained in:
committed by
Richard Holland
parent
1e414ca96e
commit
a394641037
@@ -174,10 +174,10 @@ public:
|
|||||||
// Servers operating as validators disable path finding by
|
// Servers operating as validators disable path finding by
|
||||||
// default by setting the `PATH_SEARCH_MAX` option to 0
|
// default by setting the `PATH_SEARCH_MAX` option to 0
|
||||||
// unless it is explicitly set in the configuration file.
|
// unless it is explicitly set in the configuration file.
|
||||||
int PATH_SEARCH_OLD = 7;
|
int PATH_SEARCH_OLD = 2;
|
||||||
int PATH_SEARCH = 7;
|
int PATH_SEARCH = 2;
|
||||||
int PATH_SEARCH_FAST = 2;
|
int PATH_SEARCH_FAST = 2;
|
||||||
int PATH_SEARCH_MAX = 10;
|
int PATH_SEARCH_MAX = 3;
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
std::optional<std::size_t>
|
std::optional<std::size_t>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <test/jtx.h>
|
#include <test/jtx.h>
|
||||||
|
#include <test/jtx/envconfig.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
@@ -171,6 +172,21 @@ IPE(Issue const& iss)
|
|||||||
|
|
||||||
class Path_test : public beast::unit_test::suite
|
class Path_test : public beast::unit_test::suite
|
||||||
{
|
{
|
||||||
|
jtx::Env
|
||||||
|
pathTestEnv()
|
||||||
|
{
|
||||||
|
// These tests were originally written with search parameters that are
|
||||||
|
// different from the current defaults. This function creates an env
|
||||||
|
// with the search parameters that the tests were written for.
|
||||||
|
using namespace jtx;
|
||||||
|
return Env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||||
|
cfg->PATH_SEARCH_OLD = 7;
|
||||||
|
cfg->PATH_SEARCH = 7;
|
||||||
|
cfg->PATH_SEARCH_MAX = 10;
|
||||||
|
return cfg;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class gate
|
class gate
|
||||||
{
|
{
|
||||||
@@ -314,7 +330,7 @@ public:
|
|||||||
testcase("source currency limits");
|
testcase("source currency limits");
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
env.fund(XRP(10000), "alice", "bob", gw);
|
env.fund(XRP(10000), "alice", "bob", gw);
|
||||||
env.trust(gw["USD"](100), "alice", "bob");
|
env.trust(gw["USD"](100), "alice", "bob");
|
||||||
@@ -396,7 +412,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("no direct path no intermediary no alternatives");
|
testcase("no direct path no intermediary no alternatives");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob");
|
env.fund(XRP(10000), "alice", "bob");
|
||||||
|
|
||||||
auto const result =
|
auto const result =
|
||||||
@@ -409,7 +425,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("direct path no intermediary");
|
testcase("direct path no intermediary");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob");
|
env.fund(XRP(10000), "alice", "bob");
|
||||||
env.trust(Account("alice")["USD"](700), "bob");
|
env.trust(Account("alice")["USD"](700), "bob");
|
||||||
|
|
||||||
@@ -426,7 +442,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("payment auto path find");
|
testcase("payment auto path find");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
env.fund(XRP(10000), "alice", "bob", gw);
|
env.fund(XRP(10000), "alice", "bob", gw);
|
||||||
@@ -445,7 +461,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("path find");
|
testcase("path find");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
env.fund(XRP(10000), "alice", "bob", gw);
|
env.fund(XRP(10000), "alice", "bob", gw);
|
||||||
@@ -467,7 +483,7 @@ public:
|
|||||||
{
|
{
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
testcase("XRP to XRP");
|
testcase("XRP to XRP");
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob");
|
env.fund(XRP(10000), "alice", "bob");
|
||||||
|
|
||||||
auto const result = find_paths(env, "alice", "bob", XRP(5));
|
auto const result = find_paths(env, "alice", "bob", XRP(5));
|
||||||
@@ -481,7 +497,7 @@ public:
|
|||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
|
|
||||||
{
|
{
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward");
|
env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward");
|
||||||
env.trust(Account("alice")["USD"](10), "bob");
|
env.trust(Account("alice")["USD"](10), "bob");
|
||||||
env.trust(Account("bob")["USD"](10), "carol");
|
env.trust(Account("bob")["USD"](10), "carol");
|
||||||
@@ -500,7 +516,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
env.fund(XRP(10000), "alice", "bob", "carol", gw);
|
env.fund(XRP(10000), "alice", "bob", "carol", gw);
|
||||||
@@ -534,7 +550,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("alternative path consume both");
|
testcase("alternative path consume both");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
auto const gw2 = Account("gateway2");
|
auto const gw2 = Account("gateway2");
|
||||||
@@ -563,7 +579,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("alternative paths consume best transfer");
|
testcase("alternative paths consume best transfer");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
auto const gw2 = Account("gateway2");
|
auto const gw2 = Account("gateway2");
|
||||||
@@ -592,7 +608,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("alternative paths - consume best transfer first");
|
testcase("alternative paths - consume best transfer first");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
auto const gw2 = Account("gateway2");
|
auto const gw2 = Account("gateway2");
|
||||||
@@ -623,7 +639,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("alternative paths - limit returned paths to best quality");
|
testcase("alternative paths - limit returned paths to best quality");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
auto const gw2 = Account("gateway2");
|
auto const gw2 = Account("gateway2");
|
||||||
@@ -658,7 +674,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("path negative: Issue #5");
|
testcase("path negative: Issue #5");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan");
|
env.fund(XRP(10000), "alice", "bob", "carol", "dan");
|
||||||
env.trust(Account("bob")["USD"](100), "alice", "carol", "dan");
|
env.trust(Account("bob")["USD"](100), "alice", "carol", "dan");
|
||||||
env.trust(Account("alice")["USD"](100), "dan");
|
env.trust(Account("alice")["USD"](100), "dan");
|
||||||
@@ -696,7 +712,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("path negative: ripple-client issue #23: smaller");
|
testcase("path negative: ripple-client issue #23: smaller");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan");
|
env.fund(XRP(10000), "alice", "bob", "carol", "dan");
|
||||||
env.trust(Account("alice")["USD"](40), "bob");
|
env.trust(Account("alice")["USD"](40), "bob");
|
||||||
env.trust(Account("dan")["USD"](20), "bob");
|
env.trust(Account("dan")["USD"](20), "bob");
|
||||||
@@ -715,7 +731,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("path negative: ripple-client issue #23: larger");
|
testcase("path negative: ripple-client issue #23: larger");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward");
|
env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward");
|
||||||
env.trust(Account("alice")["USD"](120), "edward");
|
env.trust(Account("alice")["USD"](120), "edward");
|
||||||
env.trust(Account("edward")["USD"](25), "bob");
|
env.trust(Account("edward")["USD"](25), "bob");
|
||||||
@@ -742,7 +758,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("via gateway");
|
testcase("via gateway");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
auto const gw = Account("gateway");
|
auto const gw = Account("gateway");
|
||||||
auto const AUD = gw["AUD"];
|
auto const AUD = gw["AUD"];
|
||||||
env.fund(XRP(10000), "alice", "bob", "carol", gw);
|
env.fund(XRP(10000), "alice", "bob", "carol", gw);
|
||||||
@@ -764,7 +780,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("path find");
|
testcase("path find");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob", "carol");
|
env.fund(XRP(10000), "alice", "bob", "carol");
|
||||||
env.trust(Account("alice")["USD"](1000), "bob");
|
env.trust(Account("alice")["USD"](1000), "bob");
|
||||||
env.trust(Account("bob")["USD"](1000), "carol");
|
env.trust(Account("bob")["USD"](1000), "carol");
|
||||||
@@ -782,7 +798,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("quality set and test");
|
testcase("quality set and test");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob");
|
env.fund(XRP(10000), "alice", "bob");
|
||||||
env(trust("bob", Account("alice")["USD"](1000)),
|
env(trust("bob", Account("alice")["USD"](1000)),
|
||||||
json("{\"" + sfQualityIn.fieldName + "\": 2000}"),
|
json("{\"" + sfQualityIn.fieldName + "\": 2000}"),
|
||||||
@@ -828,7 +844,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("trust normal clear");
|
testcase("trust normal clear");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob");
|
env.fund(XRP(10000), "alice", "bob");
|
||||||
env.trust(Account("bob")["USD"](1000), "alice");
|
env.trust(Account("bob")["USD"](1000), "alice");
|
||||||
env.trust(Account("alice")["USD"](1000), "bob");
|
env.trust(Account("alice")["USD"](1000), "bob");
|
||||||
@@ -878,7 +894,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("trust auto clear");
|
testcase("trust auto clear");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), "alice", "bob");
|
env.fund(XRP(10000), "alice", "bob");
|
||||||
env.trust(Account("bob")["USD"](1000), "alice");
|
env.trust(Account("bob")["USD"](1000), "alice");
|
||||||
env(pay("bob", "alice", Account("bob")["USD"](50)));
|
env(pay("bob", "alice", Account("bob")["USD"](50)));
|
||||||
@@ -931,7 +947,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("Path Find: XRP -> XRP and XRP -> IOU");
|
testcase("Path Find: XRP -> XRP and XRP -> IOU");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
Account A1{"A1"};
|
Account A1{"A1"};
|
||||||
Account A2{"A2"};
|
Account A2{"A2"};
|
||||||
Account A3{"A3"};
|
Account A3{"A3"};
|
||||||
@@ -1018,7 +1034,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("Path Find: non-XRP -> XRP");
|
testcase("Path Find: non-XRP -> XRP");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
Account A1{"A1"};
|
Account A1{"A1"};
|
||||||
Account A2{"A2"};
|
Account A2{"A2"};
|
||||||
Account G3{"G3"};
|
Account G3{"G3"};
|
||||||
@@ -1055,7 +1071,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("Path Find: Bitstamp and SnapSwap, liquidity with no offers");
|
testcase("Path Find: Bitstamp and SnapSwap, liquidity with no offers");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
Account A1{"A1"};
|
Account A1{"A1"};
|
||||||
Account A2{"A2"};
|
Account A2{"A2"};
|
||||||
Account G1BS{"G1BS"};
|
Account G1BS{"G1BS"};
|
||||||
@@ -1135,7 +1151,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("Path Find: non-XRP -> non-XRP, same currency");
|
testcase("Path Find: non-XRP -> non-XRP, same currency");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
Account A1{"A1"};
|
Account A1{"A1"};
|
||||||
Account A2{"A2"};
|
Account A2{"A2"};
|
||||||
Account A3{"A3"};
|
Account A3{"A3"};
|
||||||
@@ -1264,7 +1280,7 @@ public:
|
|||||||
{
|
{
|
||||||
testcase("Path Find: non-XRP -> non-XRP, same currency)");
|
testcase("Path Find: non-XRP -> non-XRP, same currency)");
|
||||||
using namespace jtx;
|
using namespace jtx;
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
Account A1{"A1"};
|
Account A1{"A1"};
|
||||||
Account A2{"A2"};
|
Account A2{"A2"};
|
||||||
Account A3{"A3"};
|
Account A3{"A3"};
|
||||||
@@ -1315,7 +1331,7 @@ public:
|
|||||||
auto const USD = gw["USD"];
|
auto const USD = gw["USD"];
|
||||||
{
|
{
|
||||||
// XRP -> IOU receive max
|
// XRP -> IOU receive max
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), alice, bob, charlie, gw);
|
env.fund(XRP(10000), alice, bob, charlie, gw);
|
||||||
env.close();
|
env.close();
|
||||||
env.trust(USD(100), alice, bob, charlie);
|
env.trust(USD(100), alice, bob, charlie);
|
||||||
@@ -1338,7 +1354,7 @@ public:
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
// IOU -> XRP receive max
|
// IOU -> XRP receive max
|
||||||
Env env(*this);
|
Env env = pathTestEnv();
|
||||||
env.fund(XRP(10000), alice, bob, charlie, gw);
|
env.fund(XRP(10000), alice, bob, charlie, gw);
|
||||||
env.close();
|
env.close();
|
||||||
env.trust(USD(100), alice, bob, charlie);
|
env.trust(USD(100), alice, bob, charlie);
|
||||||
|
|||||||
Reference in New Issue
Block a user