Compare commits

...

1 Commits

Author SHA1 Message Date
tequ
8845f4672e fix: keep ledger_history in standalone mode for rwdb null node store
Since #728, [node_db] type=rwdb is the null node store. SHAMapStoreImp
sizes LedgerMaster's in-memory retained-ledger window from ledger_history
and throws when it is 0 or "full". Config::setup, however, unconditionally
forced LEDGER_HISTORY to 0 in standalone mode, so any standalone node
using rwdb (including the shipped cfg/rippled.cfg, and tools such as
xrpld-lab) aborted at startup with:

    RWDB null mode requires a finite ledger_history > 0

jtx builds its Config without Config::setup, so the unit test suite never
exercised this path.

Gate the standalone reset on !nullBackend() instead of removing it: for
persistent backends standalone behaviour is unchanged, and for rwdb the
configured value (default 256) is kept, matching what jtx already runs
with. cfg/rippled.cfg needs no change.

Add a Config_test case that goes through Config::setup in standalone mode
and checks ledger_history is kept for type=rwdb and still zeroed for a
persistent backend.
2026-10-14 10:18:36 +09:00
2 changed files with 36 additions and 1 deletions

View File

@@ -1122,6 +1122,36 @@ trustthesevalidators.gov
}
}
// Standalone forces ledger_history to zero, but [node_db] type=rwdb
// (the null node store) sizes its retained-ledger window from it and
// SHAMapStoreImp throws on zero. cfg/rippled.cfg ships exactly this
// configuration, and jtx never calls Config::setup, so pin it here.
void
testSetupStandaloneRwdb()
{
testcase("setup standalone rwdb keeps ledger_history");
for (std::string const type : {"rwdb", "NuDB"})
{
detail::RippledCfgGuard const cfg(
*this,
"testSetupStandaloneRwdb_" + type,
"",
"",
true,
"[node_db]\ntype=" + type + "\npath=main\n");
Config config;
config.setup(
cfg.configFile(),
/*bQuiet*/ true,
/* bSilent */ true,
/* bStandalone */ true);
BEAST_EXPECT(config.standalone());
BEAST_EXPECT(config.nullBackend() == (type == "rwdb"));
BEAST_EXPECT(config.LEDGER_HISTORY == (type == "rwdb" ? 256 : 0));
}
}
void
testPort()
{
@@ -1813,6 +1843,7 @@ r.ripple.com:51235
testValidatorsFile();
testSetup(false);
testSetup(true);
testSetupStandaloneRwdb();
testPort();
testZeroPort();
testWhitespace();

View File

@@ -405,7 +405,11 @@ Config::setup(
HTTPClient::initializeSSLContext(*this, j_);
if (RUN_STANDALONE)
// Standalone never fetches history, so ledger_history is normally
// meaningless there. The rwdb null node store (nullBackend) uses it
// to size the in-memory retained-ledger window, and SHAMapStoreImp
// rejects zero for it, so keep the configured value in that case.
if (RUN_STANDALONE && !nullBackend())
LEDGER_HISTORY = 0;
std::string ledgerTxDbType;