mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-14 02:30:20 +00:00
Compare commits
29 Commits
ximinez/on
...
copilot/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b1e9f2a8a | ||
|
|
4b7a21bdfe | ||
|
|
f956135e29 | ||
|
|
3e4422df28 | ||
|
|
9f5bf51b31 | ||
|
|
9ccb7742ca | ||
|
|
336b9c101e | ||
|
|
5fdbedf6ac | ||
|
|
ce4490d793 | ||
|
|
ba2ff93d6e | ||
|
|
4714160052 | ||
|
|
5147825d61 | ||
|
|
719368ae25 | ||
|
|
3e372656d3 | ||
|
|
81964068a1 | ||
|
|
2e0ea38d7d | ||
|
|
aa1f84e226 | ||
|
|
ae7076c054 | ||
|
|
9a221d1291 | ||
|
|
5e6d8a4692 | ||
|
|
11c7d912f6 | ||
|
|
b7d6cdf713 | ||
|
|
193ddcbfac | ||
|
|
3a70d9dfba | ||
|
|
03e8a68670 | ||
|
|
28143d74af | ||
|
|
ff4c538a9f | ||
|
|
9fe94c47c3 | ||
|
|
3f307f8128 |
5
BUILD.md
5
BUILD.md
@@ -41,10 +41,7 @@ Our Linux CI tooling is distro-independent and uses a Nix-based environment, so
|
||||
|
||||
### macOS
|
||||
|
||||
Many `xrpld` engineers use macOS for development. The minimum supported version
|
||||
is macOS 26, which is also what our CI builds and tests against. The build
|
||||
defaults `CMAKE_OSX_DEPLOYMENT_TARGET` accordingly, so you do not need to pass it
|
||||
yourself.
|
||||
Many `xrpld` engineers use macOS for development.
|
||||
|
||||
### Windows
|
||||
|
||||
|
||||
@@ -13,21 +13,6 @@ if(DEFINED CMAKE_MODULE_PATH)
|
||||
endif()
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Default the macOS deployment target so it does not have to be passed on the
|
||||
# command line. Must be set before project() because project() consumes it when
|
||||
# configuring the compiler and SDK. A user-provided -DCMAKE_OSX_DEPLOYMENT_TARGET
|
||||
# still takes precedence.
|
||||
if(
|
||||
CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin"
|
||||
AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
"26.0"
|
||||
CACHE STRING
|
||||
"Minimum macOS deployment version"
|
||||
)
|
||||
endif()
|
||||
|
||||
project(xrpl)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
@@ -1059,11 +1059,10 @@
|
||||
# The online delete process checks periodically
|
||||
# that xrpld is still in sync with the network,
|
||||
# and that the validated ledger is less than
|
||||
# 'age_threshold_seconds' old, and that all
|
||||
# recent ledgers are available. If not, then continue
|
||||
# 'age_threshold_seconds' old. If not, then continue
|
||||
# sleeping for this number of seconds and
|
||||
# checking until healthy.
|
||||
# Default is 2.
|
||||
# Default is 5.
|
||||
#
|
||||
# Notes:
|
||||
# The 'node_db' entry configures the primary, persistent storage.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -13,6 +13,6 @@ namespace xrpl {
|
||||
* @throws runtime_error
|
||||
*/
|
||||
void
|
||||
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst);
|
||||
extractTarLz4(std::filesystem::path const& src, std::filesystem::path const& dst);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
std::string
|
||||
getFileContents(
|
||||
boost::system::error_code& ec,
|
||||
boost::filesystem::path const& sourcePath,
|
||||
std::error_code& ec,
|
||||
std::filesystem::path const& sourcePath,
|
||||
std::optional<std::size_t> maxSize = std::nullopt);
|
||||
|
||||
void
|
||||
writeFileContents(
|
||||
boost::system::error_code& ec,
|
||||
boost::filesystem::path const& destPath,
|
||||
std::error_code& ec,
|
||||
std::filesystem::path const& destPath,
|
||||
std::string const& contents);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
* @return `true` if the file was opened.
|
||||
*/
|
||||
bool
|
||||
open(boost::filesystem::path const& path);
|
||||
open(std::filesystem::path const& path);
|
||||
|
||||
/**
|
||||
* Close and re-open the system file associated with the log
|
||||
@@ -133,7 +133,7 @@ private:
|
||||
|
||||
private:
|
||||
std::unique_ptr<std::ofstream> stream_;
|
||||
boost::filesystem::path path_;
|
||||
std::filesystem::path path_;
|
||||
};
|
||||
|
||||
std::mutex mutable mutex_;
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
virtual ~Logs() = default;
|
||||
|
||||
bool
|
||||
open(boost::filesystem::path const& pathToLogFile);
|
||||
open(std::filesystem::path const& pathToLogFile);
|
||||
|
||||
beast::Journal::Sink&
|
||||
get(std::string const& name);
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/runner.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
@@ -27,7 +27,7 @@ makeReason(String const& reason, char const* file, int line)
|
||||
std::string s(reason);
|
||||
if (!s.empty())
|
||||
s.append(": ");
|
||||
namespace fs = boost::filesystem;
|
||||
namespace fs = std::filesystem;
|
||||
s.append(fs::path{file}.filename().string());
|
||||
s.append("(");
|
||||
s.append(boost::lexical_cast<std::string>(line));
|
||||
|
||||
@@ -1,20 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <iomanip>
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace beast {
|
||||
|
||||
/**
|
||||
* Generate a unique, non-existing path under @p base with an optional @p prefix
|
||||
* and a random hex suffix.
|
||||
*
|
||||
* Attempts up to @p maxAttempts paths. Throws `std::runtime_error` if a
|
||||
* unique path cannot be found or if the filesystem returns an error while
|
||||
* checking for existence.
|
||||
*/
|
||||
inline std::filesystem::path
|
||||
uniqueRandomPath(
|
||||
std::filesystem::path const& base,
|
||||
std::size_t maxAttempts = 100,
|
||||
std::string const& prefix = "")
|
||||
{
|
||||
std::random_device rd;
|
||||
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << prefix << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8)
|
||||
<< rd();
|
||||
auto candidate = base / oss.str();
|
||||
std::error_code ec;
|
||||
bool const exists = std::filesystem::exists(candidate, ec);
|
||||
if (ec)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Unable to check path '" + candidate.string() + "': " + ec.message());
|
||||
}
|
||||
if (!exists)
|
||||
return candidate;
|
||||
}
|
||||
throw std::runtime_error("Unable to generate a unique path under '" + base.string() + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* RAII temporary directory.
|
||||
*
|
||||
* The directory and all its contents are deleted when
|
||||
* the instance of `temp_dir` is destroyed.
|
||||
* the instance of `TempDir` is destroyed.
|
||||
*/
|
||||
class TempDir
|
||||
{
|
||||
boost::filesystem::path path_;
|
||||
std::filesystem::path path_;
|
||||
|
||||
public:
|
||||
#if !GENERATING_DOCS
|
||||
@@ -28,12 +66,8 @@ public:
|
||||
*/
|
||||
TempDir()
|
||||
{
|
||||
auto const dir = boost::filesystem::temp_directory_path();
|
||||
do
|
||||
{
|
||||
path_ = dir / boost::filesystem::unique_path();
|
||||
} while (boost::filesystem::exists(path_));
|
||||
boost::filesystem::create_directory(path_);
|
||||
path_ = uniqueRandomPath(std::filesystem::temp_directory_path());
|
||||
std::filesystem::create_directory(path_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,8 +76,8 @@ public:
|
||||
~TempDir()
|
||||
{
|
||||
// use non-throwing calls in the destructor
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::remove_all(path_, ec);
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(path_, ec);
|
||||
// TODO: warn/notify if ec set ?
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
#include <xrpl/core/Job.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -44,7 +43,7 @@ public:
|
||||
*/
|
||||
struct Setup
|
||||
{
|
||||
boost::filesystem::path perfLog;
|
||||
std::filesystem::path perfLog;
|
||||
// log_interval is in milliseconds to support faster testing.
|
||||
milliseconds logInterval{seconds(1)};
|
||||
};
|
||||
@@ -149,7 +148,7 @@ public:
|
||||
};
|
||||
|
||||
PerfLog::Setup
|
||||
setupPerfLog(Section const& section, boost::filesystem::path const& configDir);
|
||||
setupPerfLog(Section const& section, std::filesystem::path const& configDir);
|
||||
|
||||
std::unique_ptr<PerfLog>
|
||||
makePerfLog(
|
||||
|
||||
@@ -41,18 +41,6 @@ public:
|
||||
std::unique_ptr<NodeStore::Backend>&& newBackend,
|
||||
std::function<void(std::string const& writableName, std::string const& archiveName)> const&
|
||||
f) = 0;
|
||||
|
||||
/** Marks an online-delete rotation as in progress (or completed).
|
||||
|
||||
While in flight, a read served by the archive backend is copied
|
||||
forward into the writable backend even for ordinary
|
||||
(duplicate == false) fetches: the archive is about to be deleted,
|
||||
and a node body canonicalized into caches during the rotation
|
||||
window would otherwise survive only in RAM once the archive is
|
||||
dropped.
|
||||
*/
|
||||
virtual void
|
||||
setRotationInFlight(bool inFlight) = 0;
|
||||
};
|
||||
|
||||
} // namespace xrpl::NodeStore
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <xrpl/nodestore/NodeObject.h>
|
||||
#include <xrpl/nodestore/Scheduler.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -70,22 +69,11 @@ public:
|
||||
void
|
||||
sweep() override;
|
||||
|
||||
void
|
||||
setRotationInFlight(bool inFlight) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Backend> writableBackend_;
|
||||
std::shared_ptr<Backend> archiveBackend_;
|
||||
mutable std::mutex mutex_;
|
||||
|
||||
// True between SHAMapStore starting the cache-freshen phase and the
|
||||
// completion of rotate(). While true, archive hits on ordinary
|
||||
// (duplicate == false) fetches are copied forward into the writable
|
||||
// backend; copyForwardCount_ tallies them per rotation for the
|
||||
// summary line logged at swap.
|
||||
std::atomic<bool> rotationInFlight_{false};
|
||||
std::atomic<std::uint64_t> copyForwardCount_{0};
|
||||
|
||||
std::shared_ptr<NodeObject>
|
||||
fetchNodeObject(uint256 const& hash, std::uint32_t, FetchReport& fetchReport, bool duplicate)
|
||||
override;
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
#include <xrpl/core/StartUpType.h>
|
||||
#include <xrpl/rdb/SociDB.h>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <soci/statement.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -80,7 +79,7 @@ public:
|
||||
|
||||
StartUpType startUp = StartUpType::Normal;
|
||||
bool standAlone = false;
|
||||
boost::filesystem::path dataDir;
|
||||
std::filesystem::path dataDir;
|
||||
// Indicates whether or not to return the `globalPragma`
|
||||
// from commonPragma()
|
||||
bool useGlobalPragma = false;
|
||||
@@ -143,7 +142,7 @@ public:
|
||||
|
||||
template <std::size_t N, std::size_t M>
|
||||
DatabaseCon(
|
||||
boost::filesystem::path const& dataDir,
|
||||
std::filesystem::path const& dataDir,
|
||||
std::string const& dbName,
|
||||
std::array<std::string, N> const& pragma,
|
||||
std::array<char const*, M> const& initSQL,
|
||||
@@ -155,7 +154,7 @@ public:
|
||||
// Use this constructor to setup checkpointing
|
||||
template <std::size_t N, std::size_t M>
|
||||
DatabaseCon(
|
||||
boost::filesystem::path const& dataDir,
|
||||
std::filesystem::path const& dataDir,
|
||||
std::string const& dbName,
|
||||
std::array<std::string, N> const& pragma,
|
||||
std::array<char const*, M> const& initSQL,
|
||||
@@ -190,7 +189,7 @@ private:
|
||||
|
||||
template <std::size_t N, std::size_t M>
|
||||
DatabaseCon(
|
||||
boost::filesystem::path const& pPath,
|
||||
std::filesystem::path const& pPath,
|
||||
std::vector<std::string> const* commonPragma,
|
||||
std::array<std::string, N> const& pragma,
|
||||
std::array<char const*, M> const& initSQL,
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <xrpl/protocol/TxMeta.h>
|
||||
#include <xrpl/protocol/TxSearched.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <concepts>
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
#include <xrpl/rdb/DatabaseCon.h>
|
||||
#include <xrpl/rdb/SociDB.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
struct SavedState
|
||||
|
||||
@@ -35,15 +35,13 @@ to_string(SHAMapType t)
|
||||
class SHAMapMissingNode : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
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, SHAMapHash const& hash)
|
||||
: std::runtime_error("Missing Node: " + to_string(t) + ": hash " + to_string(hash))
|
||||
{
|
||||
}
|
||||
|
||||
SHAMapMissingNode(SHAMapType t, uint256 const& id, std::string const& location)
|
||||
: std::runtime_error(
|
||||
"Missing Node: " + to_string(t) + ": id " + to_string(id) + " in: " + location)
|
||||
SHAMapMissingNode(SHAMapType t, uint256 const& id)
|
||||
: std::runtime_error("Missing Node: " + to_string(t) + ": id " + to_string(id))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,22 +2,20 @@
|
||||
|
||||
#include <xrpl/basics/contract.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
void
|
||||
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst)
|
||||
extractTarLz4(std::filesystem::path const& src, std::filesystem::path const& dst)
|
||||
{
|
||||
if (!is_regular_file(src))
|
||||
if (!std::filesystem::is_regular_file(src))
|
||||
Throw<std::runtime_error>("Invalid source file");
|
||||
|
||||
using archive_ptr = std::unique_ptr<struct archive, void (*)(struct archive*)>;
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
#include <xrpl/basics/FileUtilities.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/errc.hpp>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <iterator>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
std::string
|
||||
getFileContents(
|
||||
boost::system::error_code& ec,
|
||||
boost::filesystem::path const& sourcePath,
|
||||
std::error_code& ec,
|
||||
std::filesystem::path const& sourcePath,
|
||||
std::optional<std::size_t> maxSize)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace boost::system::errc;
|
||||
using namespace std::filesystem;
|
||||
|
||||
path const fullPath{canonical(sourcePath, ec)};
|
||||
if (ec)
|
||||
@@ -32,15 +27,15 @@ getFileContents(
|
||||
if (maxSize && (file_size(fullPath, ec) > *maxSize || ec))
|
||||
{
|
||||
if (!ec)
|
||||
ec = make_error_code(file_too_large);
|
||||
ec = make_error_code(std::errc::file_too_large);
|
||||
return {};
|
||||
}
|
||||
|
||||
std::ifstream fileStream(fullPath.string(), std::ios::in);
|
||||
std::ifstream fileStream(fullPath, std::ios::in);
|
||||
|
||||
if (!fileStream)
|
||||
{
|
||||
ec = make_error_code(static_cast<errc_t>(errno));
|
||||
ec.assign(errno, std::generic_category());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -49,7 +44,7 @@ getFileContents(
|
||||
|
||||
if (fileStream.bad())
|
||||
{
|
||||
ec = make_error_code(static_cast<errc_t>(errno));
|
||||
ec.assign(errno, std::generic_category());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -58,18 +53,15 @@ getFileContents(
|
||||
|
||||
void
|
||||
writeFileContents(
|
||||
boost::system::error_code& ec,
|
||||
boost::filesystem::path const& destPath,
|
||||
std::error_code& ec,
|
||||
std::filesystem::path const& destPath,
|
||||
std::string const& contents)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace boost::system::errc;
|
||||
|
||||
std::ofstream fileStream(destPath.string(), std::ios::out | std::ios::trunc);
|
||||
std::ofstream fileStream(destPath, std::ios::out | std::ios::trunc);
|
||||
|
||||
if (!fileStream)
|
||||
{
|
||||
ec = make_error_code(static_cast<errc_t>(errno));
|
||||
ec.assign(errno, std::generic_category());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,7 +69,7 @@ writeFileContents(
|
||||
|
||||
if (fileStream.bad())
|
||||
{
|
||||
ec = make_error_code(static_cast<errc_t>(errno));
|
||||
ec.assign(errno, std::generic_category());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -54,7 +54,7 @@ Logs::File::isOpen() const noexcept
|
||||
}
|
||||
|
||||
bool
|
||||
Logs::File::open(boost::filesystem::path const& path)
|
||||
Logs::File::open(std::filesystem::path const& path)
|
||||
{
|
||||
close();
|
||||
|
||||
@@ -114,7 +114,7 @@ Logs::Logs(beast::Severity thresh) : thresh_(thresh) // default severity
|
||||
}
|
||||
|
||||
bool
|
||||
Logs::open(boost::filesystem::path const& pathToLogFile)
|
||||
Logs::open(std::filesystem::path const& pathToLogFile)
|
||||
{
|
||||
return file_.open(pathToLogFile);
|
||||
}
|
||||
|
||||
@@ -746,8 +746,7 @@ 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}, "Ledger::walkLedger");
|
||||
missingNodes1.emplace_back(SHAMapType::STATE, SHAMapHash{header_.accountHash});
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -771,8 +770,7 @@ 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}, "Ledger::walkLedger");
|
||||
missingNodes2.emplace_back(SHAMapType::TRANSACTION, SHAMapHash{header_.txHash});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -52,7 +52,6 @@ DatabaseRotatingImp::rotate(
|
||||
// callback finishes. Only then will the archive directory be
|
||||
// deleted.
|
||||
std::shared_ptr<NodeStore::Backend> oldArchiveBackend;
|
||||
std::uint64_t copyForwards = 0;
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
@@ -63,28 +62,11 @@ DatabaseRotatingImp::rotate(
|
||||
newArchiveBackendName = archiveBackend_->getName();
|
||||
|
||||
writableBackend_ = std::move(newBackend);
|
||||
|
||||
copyForwards = copyForwardCount_.exchange(0, std::memory_order_acq_rel);
|
||||
}
|
||||
|
||||
if (copyForwards > 0)
|
||||
{
|
||||
JLOG(j_.warn()) << "Rotating: copied forward " << copyForwards
|
||||
<< " archive-served reads into the writable backend "
|
||||
"during the rotation window";
|
||||
}
|
||||
|
||||
f(newWritableBackendName, newArchiveBackendName);
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseRotatingImp::setRotationInFlight(bool inFlight)
|
||||
{
|
||||
rotationInFlight_.store(inFlight, std::memory_order_release);
|
||||
JLOG(j_.debug()) << "Rotating: copy-forward on archive reads "
|
||||
<< (inFlight ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
std::string
|
||||
DatabaseRotatingImp::getName() const
|
||||
{
|
||||
@@ -195,18 +177,9 @@ DatabaseRotatingImp::fetchNodeObject(
|
||||
writable = writableBackend_;
|
||||
}
|
||||
|
||||
// Update writable backend with data from the archive backend.
|
||||
// While a rotation is in flight, ordinary (duplicate == false)
|
||||
// reads served by the archive are copied forward too: the
|
||||
// archive is about to be deleted, and a body canonicalized
|
||||
// into the cache after the freshen getKeys() snapshot would
|
||||
// otherwise survive only in RAM once the archive is dropped.
|
||||
if (duplicate || rotationInFlight_.load(std::memory_order_acquire))
|
||||
{
|
||||
if (!duplicate)
|
||||
++copyForwardCount_;
|
||||
// Update writable backend with data from the archive backend
|
||||
if (duplicate)
|
||||
writable->store(nodeObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include <xrpl/nodestore/detail/EncodedBlob.h>
|
||||
#include <xrpl/nodestore/detail/codec.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
|
||||
#include <nudb/context.hpp>
|
||||
@@ -36,12 +34,14 @@
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
void
|
||||
open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt) override
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
if (db.is_open())
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
@@ -194,11 +194,12 @@ public:
|
||||
|
||||
if (deletePath)
|
||||
{
|
||||
boost::filesystem::remove_all(name, ec);
|
||||
if (ec)
|
||||
std::error_code fsec;
|
||||
std::filesystem::remove_all(name, fsec);
|
||||
if (fsec)
|
||||
{
|
||||
JLOG(j.fatal())
|
||||
<< "Filesystem remove_all of " << name << " failed with: " << ec.message();
|
||||
JLOG(j.fatal()) << "Filesystem remove_all of " << name
|
||||
<< " failed with: " << fsec.message();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,7 +353,7 @@ private:
|
||||
static std::size_t
|
||||
parseBlockSize(std::string const& name, Section const& keyValues, beast::Journal journal)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
auto const folder = path(name);
|
||||
auto const kp = (folder / "nudb.key").string();
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
#include <xrpl/nodestore/detail/DecodedBlob.h>
|
||||
#include <xrpl/nodestore/detail/EncodedBlob.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <rocksdb/advanced_options.h>
|
||||
#include <rocksdb/cache.h>
|
||||
#include <rocksdb/compression_type.h>
|
||||
@@ -37,6 +34,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
@@ -262,8 +260,8 @@ public:
|
||||
db.reset();
|
||||
if (deletePath_)
|
||||
{
|
||||
boost::filesystem::path const dir = name;
|
||||
boost::filesystem::remove_all(dir);
|
||||
std::filesystem::path const dir = name;
|
||||
std::filesystem::remove_all(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,11 @@
|
||||
#include <xrpl/core/JobQueue.h>
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <soci/blob.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@@ -45,8 +43,8 @@ getSociSqliteInit(std::string const& name, std::string const& dir, std::string c
|
||||
Throw<std::runtime_error>(
|
||||
"Sqlite databases must specify a dir and a name. Name: " + name + " Dir: " + dir);
|
||||
}
|
||||
boost::filesystem::path file(dir);
|
||||
if (is_directory(file))
|
||||
std::filesystem::path file(dir);
|
||||
if (std::filesystem::is_directory(file))
|
||||
file /= name + ext;
|
||||
return file.string();
|
||||
}
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
#include <xrpl/rdb/DBInit.h>
|
||||
#include <xrpl/rdb/DatabaseCon.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/format.hpp> // IWYU pragma: keep
|
||||
|
||||
#include <soci/into.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
@@ -20,12 +19,12 @@ namespace xrpl {
|
||||
bool
|
||||
doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j)
|
||||
{
|
||||
boost::filesystem::path const dbPath = setup.dataDir / kTxDbName;
|
||||
std::filesystem::path const dbPath = setup.dataDir / kTxDbName;
|
||||
|
||||
uintmax_t const dbSize = file_size(dbPath);
|
||||
uintmax_t const dbSize = std::filesystem::file_size(dbPath);
|
||||
XRPL_ASSERT(dbSize != static_cast<uintmax_t>(-1), "xrpl::doVacuumDB : file_size succeeded");
|
||||
|
||||
if (auto available = space(dbPath.parent_path()).available; available < dbSize)
|
||||
if (auto available = std::filesystem::space(dbPath.parent_path()).available; available < dbSize)
|
||||
{
|
||||
std::cerr << "The database filesystem must have at least as "
|
||||
"much free space as the size of "
|
||||
|
||||
@@ -272,7 +272,7 @@ SHAMap::fetchNode(SHAMapHash const& hash) const
|
||||
auto node = fetchNodeNT(hash);
|
||||
|
||||
if (!node)
|
||||
Throw<SHAMapMissingNode>(type_, hash, "fetchNode");
|
||||
Throw<SHAMapMissingNode>(type_, hash);
|
||||
|
||||
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<SHAMapMissingNode>(type_, parent->getChildHash(branch), "descendThrow");
|
||||
Throw<SHAMapMissingNode>(type_, parent->getChildHash(branch));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ SHAMap::descendThrow(SHAMapInnerNode& parent, int branch) const
|
||||
SHAMapTreeNodePtr ret = descend(parent, branch);
|
||||
|
||||
if (!ret && !parent.isEmptyBranch(branch))
|
||||
Throw<SHAMapMissingNode>(type_, parent.getChildHash(branch), "descendThrow");
|
||||
Throw<SHAMapMissingNode>(type_, parent.getChildHash(branch));
|
||||
|
||||
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<SHAMapMissingNode>(type_, id, "peekNextItem");
|
||||
Throw<SHAMapMissingNode>(type_, id);
|
||||
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<SHAMapMissingNode>(type_, id, "upperBound");
|
||||
Throw<SHAMapMissingNode>(type_, id);
|
||||
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<SHAMapMissingNode>(type_, id, "lowerBound");
|
||||
Throw<SHAMapMissingNode>(type_, id);
|
||||
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<SHAMapMissingNode>(type_, id, "delItem");
|
||||
Throw<SHAMapMissingNode>(type_, id);
|
||||
|
||||
auto leaf = intr_ptr::dynamicPointerCast<SHAMapLeafNode>(stack.top().first);
|
||||
stack.pop();
|
||||
@@ -770,7 +770,7 @@ SHAMap::addGiveItem(SHAMapNodeType type, boost::intrusive_ptr<SHAMapItem const>
|
||||
walkTowardsKey(tag, &stack);
|
||||
|
||||
if (stack.empty())
|
||||
Throw<SHAMapMissingNode>(type_, tag, "addGiveItem");
|
||||
Throw<SHAMapMissingNode>(type_, tag);
|
||||
|
||||
auto [node, nodeID] = stack.top();
|
||||
stack.pop();
|
||||
@@ -857,7 +857,7 @@ SHAMap::updateGiveItem(SHAMapNodeType type, boost::intrusive_ptr<SHAMapItem cons
|
||||
walkTowardsKey(tag, &stack);
|
||||
|
||||
if (stack.empty())
|
||||
Throw<SHAMapMissingNode>(type_, tag, "updateGiveItem");
|
||||
Throw<SHAMapMissingNode>(type_, tag);
|
||||
|
||||
auto node = intr_ptr::dynamicPointerCast<SHAMapLeafNode>(stack.top().first);
|
||||
auto nodeID = stack.top().second;
|
||||
|
||||
@@ -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<SHAMapMissingNode>(type_, uint256(), "compare");
|
||||
Throw<SHAMapMissingNode>(type_, uint256());
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ SHAMap::walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing) co
|
||||
}
|
||||
else
|
||||
{
|
||||
missingNodes.emplace_back(type_, node->getChildHash(i), "walkMap");
|
||||
missingNodes.emplace_back(type_, node->getChildHash(i));
|
||||
if (--maxMissing <= 0)
|
||||
return;
|
||||
}
|
||||
@@ -344,8 +344,7 @@ SHAMap::walkMapParallel(std::vector<SHAMapMissingNode>& missingNodes, int maxMis
|
||||
else
|
||||
{
|
||||
std::scoped_lock const l{m};
|
||||
missingNodes.emplace_back(
|
||||
type_, node->getChildHash(i), "walkMapParallel");
|
||||
missingNodes.emplace_back(type_, node->getChildHash(i));
|
||||
if (--maxMissing <= 0)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
#include <test/jtx/envconfig.h>
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/beast/utility/temp_dir.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
|
||||
#include <xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
#include <grpcpp/client_context.h>
|
||||
#include <grpcpp/create_channel.h>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
@@ -17,6 +16,7 @@
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@@ -254,10 +254,8 @@ public:
|
||||
|
||||
TemporaryTLSCertificates()
|
||||
{
|
||||
auto tmpDir = std::filesystem::temp_directory_path();
|
||||
auto uniqueDirName =
|
||||
boost::filesystem::unique_path(std::string(kCertsDirPrefix) + "%%%%%%%%");
|
||||
tempDir_ = tmpDir / uniqueDirName.string();
|
||||
tempDir_ = beast::uniqueRandomPath(
|
||||
std::filesystem::temp_directory_path(), 100, std::string(kCertsDirPrefix));
|
||||
std::filesystem::create_directories(tempDir_);
|
||||
|
||||
writeFile(tempDir_ / kCaCertFilename, kCaCertContent);
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <boost/algorithm/string/erase.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -139,7 +139,7 @@ class LedgerLoad_test : public beast::unit_test::Suite
|
||||
{
|
||||
testcase("Load ledger: Bad Files");
|
||||
using namespace test::jtx;
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
// empty path
|
||||
except([&] {
|
||||
@@ -161,8 +161,8 @@ class LedgerLoad_test : public beast::unit_test::Suite
|
||||
});
|
||||
|
||||
// make a corrupted version of the ledger file (last 10 bytes removed).
|
||||
boost::system::error_code ec;
|
||||
auto ledgerFileCorrupt = boost::filesystem::path{sd.dbPath} / "ledgerdata_bad.json";
|
||||
std::error_code ec;
|
||||
auto ledgerFileCorrupt = std::filesystem::path{sd.dbPath} / "ledgerdata_bad.json";
|
||||
copy_file(sd.ledgerFile, ledgerFileCorrupt, copy_options::overwrite_existing, ec);
|
||||
if (!BEAST_EXPECTS(!ec, ec.message()))
|
||||
return;
|
||||
|
||||
@@ -5,21 +5,17 @@
|
||||
#include <test/jtx/noop.h>
|
||||
|
||||
#include <xrpld/app/ledger/LedgerMaster.h>
|
||||
#include <xrpld/app/misc/SHAMapStore.h>
|
||||
#include <xrpld/core/Config.h>
|
||||
|
||||
#include <xrpl/basics/ToString.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl::test {
|
||||
@@ -115,73 +111,6 @@ class LedgerMaster_test : public beast::unit_test::Suite
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testCompleteLedgerRange(FeatureBitset features)
|
||||
{
|
||||
// Note that this test is intentionally very similar to
|
||||
// SHAMapStore_test::testLedgerGaps, but has a different
|
||||
// focus.
|
||||
|
||||
testcase("Complete Ledger operations");
|
||||
|
||||
using namespace test::jtx;
|
||||
|
||||
auto const deleteInterval = 8;
|
||||
|
||||
Env env{*this, envconfig([](auto cfg) {
|
||||
return onlineDelete(std::move(cfg), deleteInterval);
|
||||
})};
|
||||
|
||||
auto const alice = Account("alice");
|
||||
env.fund(XRP(1000), alice);
|
||||
env.close();
|
||||
|
||||
auto& lm = env.app().getLedgerMaster();
|
||||
LedgerIndex minSeq = 2;
|
||||
LedgerIndex maxSeq = env.closed()->header().seq;
|
||||
auto& store = env.app().getSHAMapStore();
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
LedgerIndex lastRotated = store.getLastRotated();
|
||||
BEAST_EXPECTS(maxSeq == 3, to_string(maxSeq));
|
||||
BEAST_EXPECTS(lm.getCompleteLedgers() == "2-3", lm.getCompleteLedgers());
|
||||
BEAST_EXPECTS(lastRotated == 3, to_string(lastRotated));
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq, maxSeq) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 1, maxSeq - 1) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 1, maxSeq + 1) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 2, maxSeq - 2) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 2, maxSeq + 2) == 2);
|
||||
|
||||
// Close enough ledgers to rotate a few times
|
||||
for (int i = 0; i < 24; ++i)
|
||||
{
|
||||
for (int t = 0; t < 3; ++t)
|
||||
{
|
||||
env(noop(alice));
|
||||
}
|
||||
env.close();
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
|
||||
++maxSeq;
|
||||
|
||||
if (maxSeq == lastRotated + deleteInterval)
|
||||
{
|
||||
minSeq = lastRotated;
|
||||
lastRotated = maxSeq;
|
||||
}
|
||||
BEAST_EXPECTS(
|
||||
env.closed()->header().seq == maxSeq, to_string(env.closed()->header().seq));
|
||||
BEAST_EXPECTS(store.getLastRotated() == lastRotated, to_string(store.getLastRotated()));
|
||||
std::stringstream expectedRange;
|
||||
expectedRange << minSeq << "-" << maxSeq;
|
||||
BEAST_EXPECTS(lm.getCompleteLedgers() == expectedRange.str(), lm.getCompleteLedgers());
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq, maxSeq) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 1, maxSeq - 1) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 1, maxSeq + 1) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 2, maxSeq - 2) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 2, maxSeq + 2) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
void
|
||||
run() override
|
||||
@@ -195,7 +124,6 @@ public:
|
||||
testWithFeats(FeatureBitset features)
|
||||
{
|
||||
testTxnIdFromIndex(features);
|
||||
testCompleteLedgerRange(features);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -22,14 +22,12 @@
|
||||
#include <xrpl/server/Manifest.h>
|
||||
#include <xrpl/server/Wallet.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -56,18 +54,18 @@ private:
|
||||
}
|
||||
|
||||
static void
|
||||
cleanupDatabaseDir(boost::filesystem::path const& dbPath)
|
||||
cleanupDatabaseDir(std::filesystem::path const& dbPath)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
|
||||
return;
|
||||
remove(dbPath);
|
||||
}
|
||||
|
||||
static void
|
||||
setupDatabaseDir(boost::filesystem::path const& dbPath)
|
||||
setupDatabaseDir(std::filesystem::path const& dbPath)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
if (!exists(dbPath))
|
||||
{
|
||||
create_directory(dbPath);
|
||||
@@ -80,10 +78,10 @@ private:
|
||||
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
|
||||
}
|
||||
}
|
||||
static boost::filesystem::path
|
||||
static std::filesystem::path
|
||||
getDatabasePath()
|
||||
{
|
||||
return boost::filesystem::current_path() / "manifest_test_databases";
|
||||
return std::filesystem::current_path() / "manifest_test_databases";
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -351,7 +349,7 @@ public:
|
||||
BEAST_EXPECT(loaded.revoked(pk));
|
||||
}
|
||||
}
|
||||
boost::filesystem::remove(getDatabasePath() / boost::filesystem::path(dbName));
|
||||
std::filesystem::remove(getDatabasePath() / std::filesystem::path(dbName));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/envconfig.h>
|
||||
#include <test/jtx/noop.h>
|
||||
|
||||
#include <xrpld/app/ledger/LedgerMaster.h>
|
||||
#include <xrpld/app/main/Application.h>
|
||||
#include <xrpld/app/main/NodeStoreScheduler.h>
|
||||
#include <xrpld/app/misc/SHAMapStore.h>
|
||||
@@ -11,7 +9,6 @@
|
||||
#include <xrpld/core/Config.h>
|
||||
|
||||
#include <xrpl/basics/ByteUtilities.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
@@ -26,18 +23,14 @@
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl::test {
|
||||
@@ -49,7 +42,10 @@ class SHAMapStore_test : public beast::unit_test::Suite
|
||||
static auto
|
||||
onlineDelete(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
return jtx::onlineDelete(std::move(cfg), kDeleteInterval);
|
||||
cfg->ledgerHistory = kDeleteInterval;
|
||||
auto& section = cfg->section(Sections::kNodeDatabase);
|
||||
section.set(Keys::kOnlineDelete, std::to_string(kDeleteInterval));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
static auto
|
||||
@@ -147,11 +143,11 @@ class SHAMapStore_test : public beast::unit_test::Suite
|
||||
auto& store = env.app().getSHAMapStore();
|
||||
|
||||
int ledgerSeq = 3;
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
BEAST_EXPECT(!store.getLastRotated());
|
||||
|
||||
env.close();
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
auto ledger = env.rpc("ledger", "validated");
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++)));
|
||||
@@ -231,7 +227,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(kDeleteInterval + 4)));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
BEAST_EXPECT(store.getLastRotated() == kDeleteInterval + 3);
|
||||
lastRotated = store.getLastRotated();
|
||||
@@ -258,7 +254,7 @@ public:
|
||||
!getHash(ledgers[i]).empty());
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
BEAST_EXPECT(store.getLastRotated() == kDeleteInterval + lastRotated);
|
||||
|
||||
@@ -296,7 +292,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
// The database will always have back to ledger 2,
|
||||
// regardless of lastRotated.
|
||||
@@ -311,7 +307,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, ledgerSeq - lastRotated, lastRotated);
|
||||
BEAST_EXPECT(lastRotated != store.getLastRotated());
|
||||
@@ -327,7 +323,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, kDeleteInterval + 1, lastRotated);
|
||||
BEAST_EXPECT(lastRotated != store.getLastRotated());
|
||||
@@ -366,7 +362,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, ledgerSeq - 2, 2);
|
||||
BEAST_EXPECT(lastRotated == store.getLastRotated());
|
||||
@@ -376,7 +372,7 @@ public:
|
||||
BEAST_EXPECT(!RPC::containsError(canDelete[jss::result]));
|
||||
BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq + (kDeleteInterval / 2));
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, ledgerSeq - 2, 2);
|
||||
BEAST_EXPECT(store.getLastRotated() == lastRotated);
|
||||
@@ -389,7 +385,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, ledgerSeq - lastRotated, lastRotated);
|
||||
|
||||
@@ -405,7 +401,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
BEAST_EXPECT(store.getLastRotated() == lastRotated);
|
||||
|
||||
@@ -417,7 +413,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, ledgerSeq - firstBatch, firstBatch);
|
||||
|
||||
@@ -439,7 +435,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
BEAST_EXPECT(store.getLastRotated() == lastRotated);
|
||||
|
||||
@@ -451,7 +447,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, ledgerSeq - lastRotated, lastRotated);
|
||||
|
||||
@@ -472,7 +468,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
BEAST_EXPECT(store.getLastRotated() == lastRotated);
|
||||
|
||||
@@ -484,7 +480,7 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledger, std::to_string(ledgerSeq++), true));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
store.rendezvous();
|
||||
|
||||
ledgerCheck(env, ledgerSeq - lastRotated, lastRotated);
|
||||
|
||||
@@ -496,7 +492,7 @@ public:
|
||||
makeBackendRotating(jtx::Env& env, NodeStoreScheduler& scheduler, std::string path)
|
||||
{
|
||||
Section section{env.app().config().section(Sections::kNodeDatabase)};
|
||||
boost::filesystem::path newPath;
|
||||
std::filesystem::path newPath;
|
||||
|
||||
if (!BEAST_EXPECT(path.size()))
|
||||
return {};
|
||||
@@ -607,173 +603,6 @@ public:
|
||||
BEAST_EXPECT(dbr->getName() == "3");
|
||||
}
|
||||
|
||||
void
|
||||
testLedgerGaps()
|
||||
{
|
||||
// Note that this test is intentionally very similar to
|
||||
// LedgerMaster_test::testCompleteLedgerRange, but has a different
|
||||
// focus.
|
||||
|
||||
testcase("Wait for ledger gaps to fill in");
|
||||
|
||||
using namespace test::jtx;
|
||||
|
||||
Env env{*this, envconfig(onlineDelete)};
|
||||
|
||||
auto failureMessage = [&](char const* label, auto expected, auto actual) {
|
||||
std::stringstream ss;
|
||||
ss << label << ": Expected: " << expected << ", Got: " << actual;
|
||||
return ss.str();
|
||||
};
|
||||
|
||||
auto const alice = Account("alice");
|
||||
env.fund(XRP(1000), alice);
|
||||
env.close();
|
||||
|
||||
auto& lm = env.app().getLedgerMaster();
|
||||
LedgerIndex minSeq = 2;
|
||||
LedgerIndex maxSeq = env.closed()->header().seq;
|
||||
auto& store = env.app().getSHAMapStore();
|
||||
LedgerIndex lastRotated = store.getLastRotated();
|
||||
while (lastRotated != 3)
|
||||
{
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
lastRotated = store.getLastRotated();
|
||||
}
|
||||
BEAST_EXPECTS(maxSeq == 3, std::to_string(maxSeq));
|
||||
BEAST_EXPECTS(lm.getCompleteLedgers() == "2-3", lm.getCompleteLedgers());
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq, maxSeq) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 1, maxSeq - 1) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 1, maxSeq + 1) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 2, maxSeq - 2) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 2, maxSeq + 2) == 2);
|
||||
|
||||
// Close enough ledgers to rotate a few times
|
||||
while (maxSeq < 20)
|
||||
{
|
||||
for (int t = 0; t < 3; ++t)
|
||||
{
|
||||
env(noop(alice));
|
||||
}
|
||||
env.close();
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
|
||||
++maxSeq;
|
||||
|
||||
if (maxSeq + 1 == lastRotated + kDeleteInterval)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
// The next ledger will trigger a rotation. Delete the
|
||||
// current ledger from LedgerMaster.
|
||||
std::this_thread::sleep_for(100ms);
|
||||
LedgerIndex const deleteSeq = maxSeq;
|
||||
{
|
||||
std::size_t iterations = 30;
|
||||
while (!lm.haveLedger(deleteSeq) && --iterations > 0)
|
||||
{
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
// Even the slowest machines should be able to finalize deleteSeq within 4
|
||||
// loops (400ms). If this test ever actually fails feel free to lower this
|
||||
// cutoff.
|
||||
BEAST_EXPECTS(iterations > 25, to_string(iterations));
|
||||
}
|
||||
lm.clearLedger(deleteSeq);
|
||||
|
||||
auto expectedRange = [](auto minSeq, auto deleteSeq, auto maxSeq) {
|
||||
std::stringstream expectedRange;
|
||||
expectedRange << minSeq << "-" << (deleteSeq - 1);
|
||||
if (deleteSeq + 1 == maxSeq)
|
||||
{
|
||||
expectedRange << "," << maxSeq;
|
||||
}
|
||||
else if (deleteSeq < maxSeq)
|
||||
{
|
||||
expectedRange << "," << (deleteSeq + 1) << "-" << maxSeq;
|
||||
}
|
||||
return expectedRange.str();
|
||||
};
|
||||
BEAST_EXPECTS(
|
||||
lm.getCompleteLedgers() == expectedRange(minSeq, deleteSeq, maxSeq),
|
||||
failureMessage(
|
||||
"Complete ledgers",
|
||||
expectedRange(minSeq, deleteSeq, maxSeq),
|
||||
lm.getCompleteLedgers()));
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq, maxSeq) == 1);
|
||||
|
||||
// Close another ledger, which will trigger a rotation, but the
|
||||
// rotation will be stuck until the missing ledger is filled in.
|
||||
env.close();
|
||||
// Do not call rendezvous() here without a timeout; it will block until the missing
|
||||
// ledger is backfilled. That will not happen automatically. It's a manual step that
|
||||
// is done later in this test.
|
||||
++maxSeq;
|
||||
|
||||
// Nothing has changed
|
||||
BEAST_EXPECTS(
|
||||
store.getLastRotated() == lastRotated,
|
||||
failureMessage("lastRotated", lastRotated, store.getLastRotated()));
|
||||
BEAST_EXPECTS(
|
||||
lm.getCompleteLedgers() == expectedRange(minSeq, deleteSeq, maxSeq),
|
||||
failureMessage(
|
||||
"Complete ledgers",
|
||||
expectedRange(minSeq, deleteSeq, maxSeq),
|
||||
lm.getCompleteLedgers()));
|
||||
|
||||
// Close 5 more ledgers, waiting a little bit in between to
|
||||
// simulate the ledger making progress while online delete waits
|
||||
// for the missing ledger to be filled in.
|
||||
// This ensures the healthWait check has time to run and
|
||||
// detect the gap.
|
||||
for (int l = 0; l < 5; ++l)
|
||||
{
|
||||
env.close();
|
||||
++maxSeq;
|
||||
// Nothing has changed
|
||||
BEAST_EXPECTS(
|
||||
store.getLastRotated() == lastRotated,
|
||||
failureMessage("lastRotated", lastRotated, store.getLastRotated()));
|
||||
BEAST_EXPECTS(
|
||||
lm.getCompleteLedgers() == expectedRange(minSeq, deleteSeq, maxSeq),
|
||||
failureMessage(
|
||||
"Complete Ledgers",
|
||||
expectedRange(minSeq, deleteSeq, maxSeq),
|
||||
lm.getCompleteLedgers()));
|
||||
// The Store is "stuck" in healthWait() and won't finish the run() loop until
|
||||
// it's backfilled
|
||||
BEAST_EXPECT(!store.rendezvous(100ms));
|
||||
}
|
||||
|
||||
// Put the missing ledger back in LedgerMaster
|
||||
lm.setLedgerRangePresent(deleteSeq, deleteSeq);
|
||||
|
||||
// Wait for the rotation to finish
|
||||
BEAST_EXPECT(store.rendezvous());
|
||||
|
||||
minSeq = lastRotated;
|
||||
lastRotated = deleteSeq + 1;
|
||||
}
|
||||
BEAST_EXPECT(maxSeq != lastRotated + kDeleteInterval);
|
||||
BEAST_EXPECTS(
|
||||
env.closed()->header().seq == maxSeq,
|
||||
failureMessage("maxSeq", maxSeq, env.closed()->header().seq));
|
||||
BEAST_EXPECTS(
|
||||
store.getLastRotated() == lastRotated,
|
||||
failureMessage("lastRotated", lastRotated, store.getLastRotated()));
|
||||
std::stringstream expectedRange;
|
||||
expectedRange << minSeq << "-" << maxSeq;
|
||||
BEAST_EXPECTS(
|
||||
lm.getCompleteLedgers() == expectedRange.str(),
|
||||
failureMessage("CompleteLedgers", expectedRange.str(), lm.getCompleteLedgers()));
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq, maxSeq) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 1, maxSeq - 1) == 0);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 1, maxSeq + 1) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq - 2, maxSeq - 2) == 2);
|
||||
BEAST_EXPECT(lm.missingFromCompleteLedgerRange(minSeq + 2, maxSeq + 2) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@@ -781,7 +610,6 @@ public:
|
||||
testAutomatic();
|
||||
testCanDelete();
|
||||
testRotate();
|
||||
testLedgerGaps();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/filesystem/directory.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
|
||||
#include <date/date.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
@@ -704,7 +703,7 @@ public:
|
||||
.effectiveOverlap = detail::kDefaultEffectiveOverlap,
|
||||
.expectedRefreshMin = 60 * 24}}); // max of 24 hours
|
||||
}
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
for (auto const& file : directory_iterator(good.subdir()))
|
||||
{
|
||||
remove_all(file);
|
||||
|
||||
@@ -15,14 +15,10 @@
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <boost/filesystem/file_status.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <iterator>
|
||||
@@ -31,6 +27,7 @@
|
||||
#include <ostream>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -43,7 +40,7 @@ class PerfLog_test : public beast::unit_test::Suite
|
||||
{
|
||||
enum class WithFile : bool { No = false, Yes = true };
|
||||
|
||||
using path = boost::filesystem::path;
|
||||
using path = std::filesystem::path;
|
||||
|
||||
// We're only using Env for its Journal. That Journal gives better
|
||||
// coverage in unit tests.
|
||||
@@ -66,14 +63,14 @@ class PerfLog_test : public beast::unit_test::Suite
|
||||
// The error code is intentionally ignored: if the path doesn't
|
||||
// exist (the common case on a clean runner) remove_all returns
|
||||
// an error, and that's fine — there's nothing to clean up.
|
||||
using namespace boost::filesystem;
|
||||
boost::system::error_code ec;
|
||||
using namespace std::filesystem;
|
||||
std::error_code ec;
|
||||
remove_all(logDir(), ec);
|
||||
}
|
||||
|
||||
~Fixture()
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
auto const dir{logDir()};
|
||||
auto const file{logFile()};
|
||||
@@ -96,7 +93,7 @@ class PerfLog_test : public beast::unit_test::Suite
|
||||
static path
|
||||
logDir()
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
return temp_directory_path() / "perf_log_test_dir";
|
||||
}
|
||||
|
||||
@@ -129,7 +126,7 @@ class PerfLog_test : public beast::unit_test::Suite
|
||||
static void
|
||||
wait()
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
auto const path = logFile();
|
||||
if (!exists(path))
|
||||
@@ -201,7 +198,7 @@ public:
|
||||
void
|
||||
testFileCreation()
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
{
|
||||
// Verify a PerfLog creates its file when constructed.
|
||||
@@ -256,22 +253,23 @@ public:
|
||||
|
||||
// Construct and write protect a file to prevent PerfLog
|
||||
// from creating its file.
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::create_directories(fixture.logDir(), ec);
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(fixture.logDir(), ec);
|
||||
if (!BEAST_EXPECT(!ec))
|
||||
return;
|
||||
|
||||
auto fileWriteable = [](boost::filesystem::path const& p) -> bool {
|
||||
return std::ofstream{p.c_str(), std::ios::out | std::ios::app}.is_open();
|
||||
auto fileWriteable = [](std::filesystem::path const& p) -> bool {
|
||||
return std::ofstream{p, std::ios::out | std::ios::app}.is_open();
|
||||
};
|
||||
|
||||
if (!BEAST_EXPECT(fileWriteable(fixture.logFile())))
|
||||
return;
|
||||
|
||||
boost::filesystem::permissions(
|
||||
std::filesystem::permissions(
|
||||
fixture.logFile(),
|
||||
perms::remove_perms | perms::owner_write | perms::others_write |
|
||||
perms::group_write);
|
||||
std::filesystem::perms::owner_write | std::filesystem::perms::others_write |
|
||||
std::filesystem::perms::group_write,
|
||||
std::filesystem::perm_options::remove);
|
||||
|
||||
// If the test is running as root, then the write protect may have
|
||||
// no effect. Make sure write protect worked before proceeding.
|
||||
@@ -295,9 +293,11 @@ public:
|
||||
perfLog->stop();
|
||||
|
||||
// Fix file permissions so the file can be cleaned up.
|
||||
boost::filesystem::permissions(
|
||||
std::filesystem::permissions(
|
||||
fixture.logFile(),
|
||||
perms::add_perms | perms::owner_write | perms::others_write | perms::group_write);
|
||||
std::filesystem::perms::owner_write | std::filesystem::perms::others_write |
|
||||
std::filesystem::perms::group_write,
|
||||
std::filesystem::perm_options::add);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -962,7 +962,7 @@ public:
|
||||
// We can't fully test rotate because unit tests must run on Windows,
|
||||
// and Windows doesn't (may not?) support rotate. But at least call
|
||||
// the interface and see that it doesn't crash.
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
Fixture fixture{env_.app(), j_};
|
||||
BEAST_EXPECT(!exists(fixture.logDir()));
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <xrpl/protocol/SystemParameters.h> // IWYU pragma: keep
|
||||
#include <xrpl/server/Port.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/format.hpp> // IWYU pragma: keep
|
||||
#include <boost/format/free_funcs.hpp>
|
||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||
@@ -20,6 +19,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
[[nodiscard]] bool
|
||||
dataDirExists() const
|
||||
{
|
||||
return boost::filesystem::is_directory(dataDir_);
|
||||
return std::filesystem::is_directory(dataDir_);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
if (rmDataDir_)
|
||||
rmDir(dataDir_);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ public:
|
||||
class Config_test final : public TestSuite
|
||||
{
|
||||
private:
|
||||
using path = boost::filesystem::path;
|
||||
using path = std::filesystem::path;
|
||||
|
||||
public:
|
||||
void
|
||||
@@ -309,7 +309,7 @@ port_wss_admin
|
||||
{
|
||||
testcase("config_file");
|
||||
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
auto const cwd = current_path();
|
||||
|
||||
// Test both config file names.
|
||||
@@ -425,7 +425,7 @@ port_wss_admin
|
||||
{
|
||||
testcase("database_path");
|
||||
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
{
|
||||
boost::format cc("[database_path]\n%1%\n");
|
||||
|
||||
@@ -601,7 +601,7 @@ main
|
||||
{
|
||||
testcase("validators_file");
|
||||
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
{
|
||||
// load should throw for missing specified validators file
|
||||
boost::format cc("[validators_file]\n%1%\n");
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <xrpl/rdb/SociDB.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/optional/optional.hpp> // IWYU pragma: keep
|
||||
|
||||
#include <soci/boost-optional.h> // IWYU pragma: keep
|
||||
@@ -20,6 +18,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
@@ -32,7 +31,7 @@ class SociDB_test final : public TestSuite
|
||||
{
|
||||
private:
|
||||
static void
|
||||
setupSQLiteConfig(BasicConfig& config, boost::filesystem::path const& dbPath)
|
||||
setupSQLiteConfig(BasicConfig& config, std::filesystem::path const& dbPath)
|
||||
{
|
||||
config.overwrite(Sections::kSqdb, Keys::kBackend, "sqlite");
|
||||
auto value = dbPath.string();
|
||||
@@ -41,18 +40,18 @@ private:
|
||||
}
|
||||
|
||||
static void
|
||||
cleanupDatabaseDir(boost::filesystem::path const& dbPath)
|
||||
cleanupDatabaseDir(std::filesystem::path const& dbPath)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
|
||||
return;
|
||||
remove(dbPath);
|
||||
}
|
||||
|
||||
static void
|
||||
setupDatabaseDir(boost::filesystem::path const& dbPath)
|
||||
setupDatabaseDir(std::filesystem::path const& dbPath)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
if (!exists(dbPath))
|
||||
{
|
||||
create_directory(dbPath);
|
||||
@@ -65,10 +64,10 @@ private:
|
||||
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
|
||||
}
|
||||
}
|
||||
static boost::filesystem::path
|
||||
static std::filesystem::path
|
||||
getDatabasePath()
|
||||
{
|
||||
return boost::filesystem::current_path() / "socidb_test_databases";
|
||||
return std::filesystem::current_path() / "socidb_test_databases";
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -158,7 +157,7 @@ public:
|
||||
checkValues(s);
|
||||
}
|
||||
{
|
||||
namespace bfs = boost::filesystem;
|
||||
namespace bfs = std::filesystem;
|
||||
// Remove the database
|
||||
bfs::path const dbPath(sc.connectionString());
|
||||
if (bfs::is_regular_file(dbPath))
|
||||
@@ -288,7 +287,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
{
|
||||
namespace bfs = boost::filesystem;
|
||||
namespace bfs = std::filesystem;
|
||||
// Remove the database
|
||||
bfs::path const dbPath(sc.connectionString());
|
||||
if (bfs::is_regular_file(dbPath))
|
||||
@@ -340,7 +339,7 @@ public:
|
||||
s << "SELECT LedgerSeq FROM Ledgers;", soci::into(ledgersLS);
|
||||
BEAST_EXPECT(ledgersLS.size() == numRows);
|
||||
}
|
||||
namespace bfs = boost::filesystem;
|
||||
namespace bfs = std::filesystem;
|
||||
// Remove the database
|
||||
bfs::path const dbPath(sc.connectionString());
|
||||
if (bfs::is_regular_file(dbPath))
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <xrpld/core/Config.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -63,19 +62,6 @@ envconfig(F&& modfunc, Args&&... args)
|
||||
return modfunc(envconfig(), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief adjust config to enable online_delete
|
||||
*
|
||||
* @param cfg config instance to be modified
|
||||
*
|
||||
* @param deleteInterval how many new ledgers should be available before
|
||||
* rotating. Defaults to 8, because the standalone minimum is 8.
|
||||
*
|
||||
* @return unique_ptr to Config instance
|
||||
*/
|
||||
std::unique_ptr<Config>
|
||||
onlineDelete(std::unique_ptr<Config> cfg, std::uint32_t deleteInterval = 8);
|
||||
|
||||
/**
|
||||
* @brief adjust config so no admin ports are enabled
|
||||
*
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
#include <xrpl/config/Constants.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl::test {
|
||||
@@ -62,15 +60,6 @@ setupConfigForUnitTests(Config& cfg)
|
||||
|
||||
namespace jtx {
|
||||
|
||||
std::unique_ptr<Config>
|
||||
onlineDelete(std::unique_ptr<Config> cfg, std::uint32_t deleteInterval)
|
||||
{
|
||||
cfg->ledgerHistory = deleteInterval;
|
||||
auto& section = cfg->section(Sections::kNodeDatabase);
|
||||
section.set(Keys::kOnlineDelete, std::to_string(deleteInterval));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
std::unique_ptr<Config>
|
||||
noAdmin(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
@@ -20,7 +19,7 @@ namespace xrpl::detail {
|
||||
class DirGuard
|
||||
{
|
||||
protected:
|
||||
using path = boost::filesystem::path;
|
||||
using path = std::filesystem::path;
|
||||
|
||||
private:
|
||||
path subDir_;
|
||||
@@ -47,7 +46,7 @@ public:
|
||||
DirGuard(beast::unit_test::Suite& test, path subDir, bool useCounter = true)
|
||||
: subDir_(std::move(subDir)), test_(test)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
static auto kSubDirCounter = 0;
|
||||
if (useCounter)
|
||||
@@ -73,7 +72,7 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
if (rmSubDir_)
|
||||
rmDir(subDir_);
|
||||
@@ -130,7 +129,7 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
if (exists(file_))
|
||||
{
|
||||
remove(file_);
|
||||
@@ -160,7 +159,7 @@ public:
|
||||
[[nodiscard]] bool
|
||||
fileExists() const
|
||||
{
|
||||
return boost::filesystem::exists(file_);
|
||||
return std::filesystem::exists(file_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
#include <xrpl/basics/FileUtilities.h>
|
||||
|
||||
#include <xrpl/basics/ByteUtilities.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <xrpl/beast/utility/temp_dir.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -20,15 +19,16 @@ namespace {
|
||||
class TempFile
|
||||
{
|
||||
public:
|
||||
explicit TempFile(boost::filesystem::path file, std::string const& contents)
|
||||
: dir_(
|
||||
boost::filesystem::temp_directory_path() /
|
||||
boost::filesystem::unique_path("xrpl-file-utilities-%%%%-%%%%-%%%%"))
|
||||
explicit TempFile(std::filesystem::path file, std::string const& contents)
|
||||
: dir_(beast::uniqueRandomPath(
|
||||
std::filesystem::temp_directory_path(),
|
||||
100,
|
||||
"xrpl-file-utilities-"))
|
||||
, file_(dir_ / file)
|
||||
{
|
||||
boost::filesystem::create_directory(dir_);
|
||||
std::filesystem::create_directory(dir_);
|
||||
|
||||
std::ofstream output(file_.string());
|
||||
std::ofstream output(file_);
|
||||
if (!output)
|
||||
throw std::runtime_error("Unable to create temporary test file");
|
||||
|
||||
@@ -37,33 +37,31 @@ public:
|
||||
|
||||
~TempFile()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::remove(file_, ec);
|
||||
boost::filesystem::remove(dir_, ec);
|
||||
std::error_code ec;
|
||||
std::filesystem::remove(file_, ec);
|
||||
std::filesystem::remove(dir_, ec);
|
||||
}
|
||||
|
||||
[[nodiscard]] boost::filesystem::path const&
|
||||
[[nodiscard]] std::filesystem::path const&
|
||||
file() const
|
||||
{
|
||||
return file_;
|
||||
}
|
||||
|
||||
private:
|
||||
boost::filesystem::path dir_;
|
||||
boost::filesystem::path file_;
|
||||
std::filesystem::path dir_;
|
||||
std::filesystem::path file_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(FileUtilitiesTest, get_file_contents)
|
||||
{
|
||||
using namespace boost::system;
|
||||
|
||||
constexpr char const* kExpectedContents = "This file is very short. That's all we need.";
|
||||
|
||||
TempFile const file("test_file", "This is temporary text that should get overwritten");
|
||||
|
||||
error_code ec;
|
||||
std::error_code ec;
|
||||
auto const path = file.file();
|
||||
|
||||
writeFileContents(ec, path, kExpectedContents);
|
||||
@@ -86,7 +84,7 @@ TEST(FileUtilitiesTest, get_file_contents)
|
||||
{
|
||||
// Test with small max
|
||||
auto const bad = getFileContents(ec, path, 16);
|
||||
EXPECT_TRUE(ec && ec.value() == boost::system::errc::file_too_large);
|
||||
EXPECT_TRUE(ec && ec.value() == static_cast<int>(std::errc::file_too_large));
|
||||
EXPECT_TRUE(bad.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +123,7 @@ public:
|
||||
failedSave(std::uint32_t seq, uint256 const& hash);
|
||||
|
||||
std::string
|
||||
getCompleteLedgers() const;
|
||||
|
||||
std::size_t
|
||||
missingFromCompleteLedgerRange(LedgerIndex first, LedgerIndex last) const;
|
||||
getCompleteLedgers();
|
||||
|
||||
/**
|
||||
* Apply held transactions to the open ledger
|
||||
@@ -351,7 +348,7 @@ private:
|
||||
// A set of transactions to replay during the next close
|
||||
std::unique_ptr<LedgerReplay> replayData_;
|
||||
|
||||
std::recursive_mutex mutable completeLock_;
|
||||
std::recursive_mutex completeLock_;
|
||||
RangeSet<std::uint32_t> completeLedgers_;
|
||||
|
||||
// Publish thread is running.
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
#include <xrpl/shamap/SHAMapMissingNode.h>
|
||||
#include <xrpl/shamap/SHAMapTreeNode.h>
|
||||
|
||||
#include <boost/icl/concept/interval_associator.hpp>
|
||||
#include <boost/icl/concept/interval_set.hpp>
|
||||
|
||||
#include <xrpl.pb.h>
|
||||
@@ -1577,25 +1576,12 @@ LedgerMaster::getPublishedLedger()
|
||||
}
|
||||
|
||||
std::string
|
||||
LedgerMaster::getCompleteLedgers() const
|
||||
LedgerMaster::getCompleteLedgers()
|
||||
{
|
||||
std::scoped_lock const sl(completeLock_);
|
||||
return to_string(completeLedgers_);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
LedgerMaster::missingFromCompleteLedgerRange(LedgerIndex first, LedgerIndex last) const
|
||||
{
|
||||
RangeSet<LedgerIndex> const target{range(first, last)};
|
||||
|
||||
auto const missing = [&target, this] {
|
||||
std::scoped_lock const sl(completeLock_);
|
||||
return target - completeLedgers_;
|
||||
}();
|
||||
|
||||
return boost::icl::size(missing);
|
||||
}
|
||||
|
||||
std::optional<NetClock::time_point>
|
||||
LedgerMaster::getCloseTimeBySeq(LedgerIndex ledgerIndex)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -615,7 +616,7 @@ GRPCServerImpl::createServerCredentials()
|
||||
|
||||
try
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::error_code ec;
|
||||
grpc::SslServerCredentialsOptions sslOpts;
|
||||
grpc::SslServerCredentialsOptions::PemKeyCertPair keyCertPair;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <xrpl/nodestore/Scheduler.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -35,8 +34,8 @@ public:
|
||||
virtual void
|
||||
start() = 0;
|
||||
|
||||
[[nodiscard]] virtual bool
|
||||
rendezvous(std::optional<std::chrono::milliseconds> const& timeout = {}) const = 0;
|
||||
virtual void
|
||||
rendezvous() const = 0;
|
||||
|
||||
virtual void
|
||||
stop() = 0;
|
||||
|
||||
@@ -8,35 +8,30 @@
|
||||
#include <xrpl/basics/ByteUtilities.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/basics/scope.h>
|
||||
#include <xrpl/beast/core/CurrentThreadName.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/beast/utility/temp_dir.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/ledger/Ledger.h>
|
||||
#include <xrpl/nodestore/Database.h>
|
||||
#include <xrpl/nodestore/Manager.h>
|
||||
#include <xrpl/nodestore/NodeObject.h>
|
||||
#include <xrpl/nodestore/Scheduler.h>
|
||||
#include <xrpl/nodestore/detail/DatabaseRotatingImp.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
#include <xrpl/server/NetworkOPs.h>
|
||||
#include <xrpl/server/State.h>
|
||||
#include <xrpl/shamap/SHAMapMissingNode.h>
|
||||
#include <xrpl/shamap/SHAMapTreeNode.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem/directory.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -239,21 +234,14 @@ SHAMapStoreImp::onLedgerClosed(std::shared_ptr<Ledger const> const& ledger)
|
||||
cond_.notify_one();
|
||||
}
|
||||
|
||||
bool
|
||||
SHAMapStoreImp::rendezvous(std::optional<std::chrono::milliseconds> const& timeout) const
|
||||
void
|
||||
SHAMapStoreImp::rendezvous() const
|
||||
{
|
||||
if (!working_)
|
||||
return true;
|
||||
|
||||
auto notWorking = [&] { return !working_; };
|
||||
return;
|
||||
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
if (timeout)
|
||||
{
|
||||
return rendezvous_.wait_for(lock, *timeout, notWorking);
|
||||
}
|
||||
rendezvous_.wait(lock, notWorking);
|
||||
return true;
|
||||
rendezvous_.wait(lock, [&] { return !working_; });
|
||||
}
|
||||
|
||||
int
|
||||
@@ -266,28 +254,8 @@ bool
|
||||
SHAMapStoreImp::copyNode(std::uint64_t& nodeCount, SHAMapTreeNode const& node)
|
||||
{
|
||||
// Copy a single record from node to dbRotating_
|
||||
auto obj = dbRotating_->fetchNodeObject(
|
||||
dbRotating_->fetchNodeObject(
|
||||
node.getHash().asUInt256(), 0, NodeStore::FetchType::Synchronous, true);
|
||||
if (!obj)
|
||||
{
|
||||
// Reachable from the validated state map in memory, but present in
|
||||
// neither backend: its only on-disk copy lived in a backend removed by
|
||||
// an earlier rotation, and it was never rewritten because it is clean
|
||||
// (cowid == 0, so flushDirty skips it). Persist the in-memory body
|
||||
// directly into the writable backend so it survives this rotation
|
||||
// instead of later surfacing as an unresolvable SHAMapMissingNode.
|
||||
auto const hash = node.getHash().asUInt256();
|
||||
Serializer s;
|
||||
node.serializeWithPrefix(s);
|
||||
dbRotating_->store(NodeObjectType::AccountNode, std::move(s.modData()), hash, 0);
|
||||
{
|
||||
auto const& cached = treeNodeCache_->fetch(hash);
|
||||
JLOG(journal_.warn()) << "copyNode: re-stored node missing from both backends, hash="
|
||||
<< hash << " type=" << static_cast<int>(node.getType())
|
||||
<< ". Node is " << (cached ? "" : "not ")
|
||||
<< "in the tree node cache";
|
||||
}
|
||||
}
|
||||
if ((++nodeCount % checkHealthInterval_) == 0u)
|
||||
{
|
||||
if (healthWait() == HealthResult::Stopping)
|
||||
@@ -344,26 +312,14 @@ SHAMapStoreImp::run()
|
||||
bool const readyToRotate = validatedSeq >= lastRotated + deleteInterval_ &&
|
||||
canDelete_ >= lastRotated - 1 && healthWait() == HealthResult::KeepGoing;
|
||||
|
||||
{
|
||||
JLOG(journal_.trace()) << "run: Setting lastGoodValidatedLedger_ to " << validatedSeq;
|
||||
// Note that this is set after the healthWait() check, so that we
|
||||
// don't start the rotation until the validated ledger is fully
|
||||
// processed. It is not guaranteed to be done at this point. It also
|
||||
// allows the testLedgerGaps unit test to work.
|
||||
std::unique_lock<std::mutex> const lock(mutex_);
|
||||
lastGoodValidatedLedger_ = validatedSeq;
|
||||
}
|
||||
|
||||
// will delete up to (not including) lastRotated
|
||||
if (readyToRotate)
|
||||
{
|
||||
auto const diff = validatedSeq - lastRotated;
|
||||
JLOG(journal_.warn()) << "rotating validatedSeq " << validatedSeq << " lastRotated "
|
||||
<< lastRotated << " diff " << diff << " deleteInterval "
|
||||
<< deleteInterval_ << " canDelete_ " << canDelete_ << " state "
|
||||
<< lastRotated << " deleteInterval " << deleteInterval_
|
||||
<< " canDelete_ " << canDelete_ << " state "
|
||||
<< app_.getOPs().strOperatingMode(false) << " age "
|
||||
<< ledgerMaster_->getValidatedLedgerAge().count()
|
||||
<< "s. Complete ledgers: " << ledgerMaster_->getCompleteLedgers();
|
||||
<< ledgerMaster_->getValidatedLedgerAge().count() << 's';
|
||||
|
||||
clearPrior(lastRotated);
|
||||
if (healthWait() == HealthResult::Stopping)
|
||||
@@ -392,23 +348,6 @@ SHAMapStoreImp::run()
|
||||
JLOG(journal_.debug())
|
||||
<< "copied ledger " << validatedSeq << " nodecount " << nodeCount;
|
||||
|
||||
// Close the getKeys()->swap exposure window: from here until
|
||||
// rotate() completes, an ordinary read served by the archive is
|
||||
// copied forward into the writable backend, so a node fetched
|
||||
// from the doomed archive cannot be left RAM-only when the
|
||||
// archive is deleted. RAII so the early returns below (and any
|
||||
// exception) also clear the flag.
|
||||
struct RotationExposureGuard
|
||||
{
|
||||
NodeStore::DatabaseRotating& db;
|
||||
~RotationExposureGuard()
|
||||
{
|
||||
db.setRotationInFlight(false);
|
||||
}
|
||||
};
|
||||
RotationExposureGuard const rotationExposureGuard{*dbRotating_};
|
||||
dbRotating_->setRotationInFlight(true);
|
||||
|
||||
JLOG(journal_.debug()) << "freshening caches";
|
||||
freshenCaches();
|
||||
if (healthWait() == HealthResult::Stopping)
|
||||
@@ -438,14 +377,7 @@ SHAMapStoreImp::run()
|
||||
clearCaches(validatedSeq);
|
||||
});
|
||||
|
||||
auto const currentValidatedSeq = ledgerMaster_->getValidLedgerIndex();
|
||||
auto const processingDiff = currentValidatedSeq - validatedSeq;
|
||||
JLOG(journal_.warn())
|
||||
<< "finished rotation. validatedSeq: " << validatedSeq
|
||||
<< ", lastRotated: " << lastRotated << " diff " << diff
|
||||
<< ". Updated validated seq is " << currentValidatedSeq << ", " << processingDiff
|
||||
<< " ledgers were validated during the rotation processs. Complete ledgers: "
|
||||
<< ledgerMaster_->getCompleteLedgers();
|
||||
JLOG(journal_.warn()) << "finished rotation " << validatedSeq;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,10 +391,10 @@ SHAMapStoreImp::dbPaths()
|
||||
if (boost::iequals(get(section, Keys::kType), "memory"))
|
||||
return;
|
||||
|
||||
boost::filesystem::path dbPath = get(section, Keys::kPath);
|
||||
if (boost::filesystem::exists(dbPath))
|
||||
std::filesystem::path dbPath = get(section, Keys::kPath);
|
||||
if (std::filesystem::exists(dbPath))
|
||||
{
|
||||
if (!boost::filesystem::is_directory(dbPath))
|
||||
if (!std::filesystem::is_directory(dbPath))
|
||||
{
|
||||
journal_.error() << "node db path must be a directory. " << dbPath.string();
|
||||
Throw<std::runtime_error>("node db path must be a directory.");
|
||||
@@ -470,7 +402,7 @@ SHAMapStoreImp::dbPaths()
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::filesystem::create_directories(dbPath);
|
||||
std::filesystem::create_directories(dbPath);
|
||||
}
|
||||
|
||||
SavedState state = stateDb_.getState();
|
||||
@@ -481,8 +413,8 @@ SHAMapStoreImp::dbPaths()
|
||||
return false;
|
||||
|
||||
// Check if configured "path" matches stored directory path
|
||||
using namespace boost::filesystem;
|
||||
auto const stored{path(sPath)};
|
||||
using namespace std::filesystem;
|
||||
auto const stored{std::filesystem::path(sPath)};
|
||||
if (stored.parent_path() == dbPath)
|
||||
return false;
|
||||
|
||||
@@ -500,9 +432,9 @@ SHAMapStoreImp::dbPaths()
|
||||
bool writableDbExists = false;
|
||||
bool archiveDbExists = false;
|
||||
|
||||
std::vector<boost::filesystem::path> pathsToDelete;
|
||||
for (boost::filesystem::directory_iterator it(dbPath);
|
||||
it != boost::filesystem::directory_iterator();
|
||||
std::vector<std::filesystem::path> pathsToDelete;
|
||||
for (std::filesystem::directory_iterator it(dbPath);
|
||||
it != std::filesystem::directory_iterator();
|
||||
++it)
|
||||
{
|
||||
if (state.writableDb.compare(it->path().string()) == 0)
|
||||
@@ -523,7 +455,7 @@ SHAMapStoreImp::dbPaths()
|
||||
(!archiveDbExists && !state.archiveDb.empty()) || (writableDbExists != archiveDbExists) ||
|
||||
state.writableDb.empty() != state.archiveDb.empty())
|
||||
{
|
||||
boost::filesystem::path stateDbPathName = app_.config().legacy(Sections::kDatabasePath);
|
||||
std::filesystem::path stateDbPathName = app_.config().legacy(Sections::kDatabasePath);
|
||||
stateDbPathName /= dbName_;
|
||||
stateDbPathName += "*";
|
||||
|
||||
@@ -545,15 +477,15 @@ SHAMapStoreImp::dbPaths()
|
||||
}
|
||||
|
||||
// The necessary directories exist. Now, remove any others.
|
||||
for (boost::filesystem::path const& p : pathsToDelete)
|
||||
boost::filesystem::remove_all(p);
|
||||
for (std::filesystem::path const& p : pathsToDelete)
|
||||
std::filesystem::remove_all(p);
|
||||
}
|
||||
|
||||
std::unique_ptr<NodeStore::Backend>
|
||||
SHAMapStoreImp::makeBackendRotating(std::string path)
|
||||
{
|
||||
Section section{app_.config().section(Sections::kNodeDatabase)};
|
||||
boost::filesystem::path newPath;
|
||||
std::filesystem::path newPath;
|
||||
|
||||
if (!path.empty())
|
||||
{
|
||||
@@ -561,10 +493,7 @@ SHAMapStoreImp::makeBackendRotating(std::string path)
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::filesystem::path p = get(section, Keys::kPath);
|
||||
p /= dbPrefix_;
|
||||
p += ".%%%%";
|
||||
newPath = boost::filesystem::unique_path(p);
|
||||
newPath = beast::uniqueRandomPath(get(section, Keys::kPath), 100, dbPrefix_ + ".");
|
||||
}
|
||||
section.set(Keys::kPath, newPath.string());
|
||||
|
||||
@@ -689,86 +618,20 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated)
|
||||
SHAMapStoreImp::HealthResult
|
||||
SHAMapStoreImp::healthWait()
|
||||
{
|
||||
// Gets the current status of the server from ledgerMaster_ and netOPs_. Must be called
|
||||
// while mutex_ is unlocked to avoid unlikely, but possible, deadlock with ledgerMaster_'s
|
||||
// completeLock_.
|
||||
// Releasing the lock may mean that status will be slightly out of date when the lock is
|
||||
// reacquired, but it's close enough. In a normal rotation, healthWait() is called frequently,
|
||||
// so a false positive will be detected on the next call, and a false negative will be detected
|
||||
// in the next loop iteration. Database rotation is important, but not timely, so an extra
|
||||
// delay is fine.
|
||||
auto readServerStatus = [this](
|
||||
LedgerIndex& index,
|
||||
std::chrono::seconds& age,
|
||||
OperatingMode& mode,
|
||||
std::size_t& numMissing,
|
||||
LedgerIndex const lowerBound,
|
||||
ScopeUnlock<decltype(mutex_)> const&) {
|
||||
index = ledgerMaster_->getValidLedgerIndex();
|
||||
auto age = ledgerMaster_->getValidatedLedgerAge();
|
||||
OperatingMode mode = netOPs_->getOperatingMode();
|
||||
std::unique_lock lock(mutex_);
|
||||
while (!stop_ && (mode != OperatingMode::FULL || age > ageThreshold_))
|
||||
{
|
||||
lock.unlock();
|
||||
JLOG(journal_.warn()) << "Waiting " << recoveryWaitTime_.count()
|
||||
<< "s for node to stabilize. state: "
|
||||
<< app_.getOPs().strOperatingMode(mode, false) << ". age "
|
||||
<< age.count() << 's';
|
||||
std::this_thread::sleep_for(recoveryWaitTime_);
|
||||
age = ledgerMaster_->getValidatedLedgerAge();
|
||||
mode = netOPs_->getOperatingMode();
|
||||
|
||||
numMissing =
|
||||
lowerBound == 0 ? 0 : ledgerMaster_->missingFromCompleteLedgerRange(lowerBound, index);
|
||||
};
|
||||
// Tracked server status properties
|
||||
LedgerIndex index = 0;
|
||||
std::chrono::seconds age;
|
||||
OperatingMode mode = OperatingMode::DISCONNECTED;
|
||||
std::size_t numMissing = 0;
|
||||
LedgerIndex lastLedger = 0;
|
||||
|
||||
std::unique_lock lock(mutex_);
|
||||
|
||||
auto const waitTime = recoveryWaitTime_;
|
||||
auto const ageThreshold = ageThreshold_;
|
||||
{
|
||||
auto const lowerBound = lastGoodValidatedLedger_;
|
||||
|
||||
ScopeUnlock const unlock(lock);
|
||||
|
||||
readServerStatus(index, age, mode, numMissing, lowerBound, unlock);
|
||||
}
|
||||
|
||||
auto healthy = [&]() {
|
||||
// Special case: If the server is disconnected, it's not doing any ledger I/O, because
|
||||
// it's focused on trying to get peers. A disconnected state is should never be caused by
|
||||
// the activity of the server. It's usually limited to hardware or connectivity issues. Take
|
||||
// advantage of that to run as much rotation I/O as possible before it comes back online.
|
||||
if (mode == OperatingMode::DISCONNECTED)
|
||||
return true;
|
||||
if (age > ageThreshold)
|
||||
return false;
|
||||
if (numMissing > 0)
|
||||
return false;
|
||||
if (mode != OperatingMode::FULL)
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
while (!stop_ && !healthy())
|
||||
{
|
||||
// this value shouldn't change, so grab it while we have the
|
||||
// lock
|
||||
auto const lowerBound = lastGoodValidatedLedger_;
|
||||
|
||||
ScopeUnlock const unlock(lock);
|
||||
|
||||
auto const stream = std::invoke([mode, age, ageThreshold, index, lastLedger, this]() {
|
||||
if (mode != OperatingMode::FULL || age > ageThreshold)
|
||||
return journal_.warn();
|
||||
if (index != lastLedger)
|
||||
return journal_.trace();
|
||||
return journal_.info();
|
||||
});
|
||||
JLOG(stream) << "Waiting " << waitTime.count() << "s for node to stabilize. state: "
|
||||
<< app_.getOPs().strOperatingMode(mode, false) << ". age " << age.count()
|
||||
<< "s. Missing ledgers: " << numMissing << ". Expect: " << lowerBound << "-"
|
||||
<< index << ". Complete ledgers: " << ledgerMaster_->getCompleteLedgers();
|
||||
std::this_thread::sleep_for(waitTime);
|
||||
|
||||
readServerStatus(index, age, mode, numMissing, lowerBound, unlock);
|
||||
lastLedger = index;
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
return stop_ ? HealthResult::Stopping : HealthResult::KeepGoing;
|
||||
|
||||
@@ -88,11 +88,6 @@ private:
|
||||
std::thread thread_;
|
||||
bool stop_ = false;
|
||||
bool healthy_ = true;
|
||||
// Used to prevent ledger gaps from forming during online deletion. Keeps
|
||||
// track of the last validated ledger that was processed without gaps. There
|
||||
// are no guarantees about gaps while online delete is not running. For
|
||||
// that, use advisory_delete and check for gaps externally.
|
||||
LedgerIndex lastGoodValidatedLedger_ = 0;
|
||||
mutable std::condition_variable cond_;
|
||||
mutable std::condition_variable rendezvous_;
|
||||
mutable std::mutex mutex_;
|
||||
@@ -107,12 +102,12 @@ private:
|
||||
std::chrono::milliseconds backOff_{100};
|
||||
std::chrono::seconds ageThreshold_{60};
|
||||
/**
|
||||
* If the node is out of sync, or any recent ledgers are not
|
||||
* available during an online_delete healthWait() call, sleep
|
||||
* the thread for this time, and continue checking until recovery.
|
||||
* If the node is out of sync during an online_delete healthWait()
|
||||
* call, sleep the thread for this time, and continue checking until
|
||||
* recovery.
|
||||
* See also: "recovery_wait_seconds" in xrpld-example.cfg
|
||||
*/
|
||||
std::chrono::seconds recoveryWaitTime_{2};
|
||||
std::chrono::seconds recoveryWaitTime_{5};
|
||||
|
||||
// these do not exist upon SHAMapStore creation, but do exist
|
||||
// as of run() or before
|
||||
@@ -168,8 +163,8 @@ public:
|
||||
void
|
||||
onLedgerClosed(std::shared_ptr<Ledger const> const& ledger) override;
|
||||
|
||||
bool
|
||||
rendezvous(std::optional<std::chrono::milliseconds> const& timeout = {}) const override;
|
||||
void
|
||||
rendezvous() const override;
|
||||
int
|
||||
fdRequired() const override;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -238,7 +239,7 @@ class ValidatorList
|
||||
ManifestCache& validatorManifests_;
|
||||
ManifestCache& publisherManifests_;
|
||||
TimeKeeper& timeKeeper_;
|
||||
boost::filesystem::path const dataPath_;
|
||||
std::filesystem::path const dataPath_;
|
||||
beast::Journal const j_;
|
||||
std::shared_mutex mutable mutex_;
|
||||
using scoped_lock = std::scoped_lock<decltype(mutex_)>;
|
||||
@@ -866,7 +867,7 @@ private:
|
||||
/**
|
||||
* Get the filename used for caching UNLs
|
||||
*/
|
||||
boost::filesystem::path
|
||||
std::filesystem::path
|
||||
getCacheFileName(scoped_lock const&, PublicKey const& pubKey) const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,12 +29,8 @@
|
||||
#include <xrpl/server/Manifest.h>
|
||||
#include <xrpl/server/NetworkOPs.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/regex/v5/regex.hpp>
|
||||
#include <boost/regex/v5/regex_match.hpp>
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/errc.hpp>
|
||||
|
||||
#include <xrpl.pb.h>
|
||||
|
||||
@@ -43,6 +39,7 @@
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
@@ -54,6 +51,7 @@
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -288,7 +286,7 @@ ValidatorList::load(
|
||||
return true;
|
||||
}
|
||||
|
||||
boost::filesystem::path
|
||||
std::filesystem::path
|
||||
ValidatorList::getCacheFileName(ValidatorList::scoped_lock const&, PublicKey const& pubKey) const
|
||||
{
|
||||
return dataPath_ / (kFilePrefix + strHex(pubKey));
|
||||
@@ -372,9 +370,9 @@ ValidatorList::cacheValidatorFile(ValidatorList::scoped_lock const& lock, Public
|
||||
if (dataPath_.empty())
|
||||
return;
|
||||
|
||||
boost::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
||||
std::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
||||
|
||||
boost::system::error_code ec;
|
||||
std::error_code ec;
|
||||
|
||||
json::Value value = buildFileData(strHex(pubKey), publisherLists_.at(pubKey), j_);
|
||||
// xrpld should be the only process writing to this file, so
|
||||
@@ -1283,8 +1281,7 @@ std::vector<std::string>
|
||||
ValidatorList::loadLists()
|
||||
{
|
||||
using namespace std::string_literals;
|
||||
using namespace boost::filesystem;
|
||||
using namespace boost::system::errc;
|
||||
using namespace std::filesystem;
|
||||
|
||||
std::scoped_lock const lock{mutex_};
|
||||
|
||||
@@ -1292,12 +1289,12 @@ ValidatorList::loadLists()
|
||||
sites.reserve(publisherLists_.size());
|
||||
for (auto const& [pubKey, publisherCollection] : publisherLists_)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::error_code ec;
|
||||
|
||||
if (publisherCollection.status == PublisherStatus::Available)
|
||||
continue;
|
||||
|
||||
boost::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
||||
std::filesystem::path const filename = getCacheFileName(lock, pubKey);
|
||||
|
||||
auto const fullPath{canonical(filename, ec)};
|
||||
if (ec)
|
||||
@@ -1308,7 +1305,7 @@ ValidatorList::loadLists()
|
||||
{
|
||||
// Treat an empty file as a missing file, because
|
||||
// nobody else is going to write it.
|
||||
ec = make_error_code(no_such_file_or_directory);
|
||||
ec = make_error_code(std::errc::no_such_file_or_directory);
|
||||
}
|
||||
if (ec)
|
||||
continue;
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <xrpl/rdb/RelationalDatabase.h>
|
||||
#include <xrpl/rdb/SociDB.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/format/free_funcs.hpp>
|
||||
#include <boost/optional/optional.hpp> // IWYU pragma: keep
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
@@ -56,6 +55,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
@@ -64,6 +64,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
@@ -1293,8 +1294,8 @@ getTransaction(
|
||||
bool
|
||||
dbHasSpace(soci::session& session, Config const& config, beast::Journal j)
|
||||
{
|
||||
boost::filesystem::space_info const space =
|
||||
boost::filesystem::space(config.legacy(Sections::kDatabasePath));
|
||||
std::filesystem::space_info const space =
|
||||
std::filesystem::space(config.legacy(Sections::kDatabasePath));
|
||||
|
||||
if (space.available < megabytes(512))
|
||||
{
|
||||
@@ -1305,9 +1306,9 @@ dbHasSpace(soci::session& session, Config const& config, beast::Journal j)
|
||||
if (config.useTxTables())
|
||||
{
|
||||
DatabaseCon::Setup const dbSetup = setupDatabaseCon(config);
|
||||
boost::filesystem::path const dbPath = dbSetup.dataDir / kTxDbName;
|
||||
boost::system::error_code ec;
|
||||
std::optional<std::uint64_t> dbSize = boost::filesystem::file_size(dbPath, ec);
|
||||
std::filesystem::path const dbPath = dbSetup.dataDir / kTxDbName;
|
||||
std::error_code ec;
|
||||
std::optional<std::uint64_t> dbSize = std::filesystem::file_size(dbPath, ec);
|
||||
if (ec)
|
||||
{
|
||||
JLOG(j.error()) << "Error checking transaction db file size: " << ec.message();
|
||||
|
||||
@@ -11,11 +11,10 @@
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/rdb/DatabaseCon.h>
|
||||
|
||||
#include <boost/filesystem.hpp> // VFALCO FIX: This include should not be here
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
@@ -97,17 +96,17 @@ public:
|
||||
/**
|
||||
* Returns the full path and filename of the debug log file.
|
||||
*/
|
||||
[[nodiscard]] boost::filesystem::path
|
||||
[[nodiscard]] std::filesystem::path
|
||||
getDebugLogFile() const;
|
||||
|
||||
private:
|
||||
boost::filesystem::path configFile_;
|
||||
std::filesystem::path configFile_;
|
||||
|
||||
public:
|
||||
boost::filesystem::path configDir;
|
||||
std::filesystem::path configDir;
|
||||
|
||||
private:
|
||||
boost::filesystem::path debugLogfile_;
|
||||
std::filesystem::path debugLogfile_;
|
||||
|
||||
void
|
||||
load();
|
||||
|
||||
@@ -21,21 +21,19 @@
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/format/free_funcs.hpp>
|
||||
#include <boost/multiprecision/detail/endian.hpp>
|
||||
#include <boost/predef.h>
|
||||
#include <boost/regex.hpp> // IWYU pragma: keep
|
||||
#include <boost/regex/v5/regex.hpp>
|
||||
#include <boost/regex/v5/regex_match.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
@@ -45,6 +43,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
@@ -313,13 +312,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
||||
// directory, use the current working directory as the
|
||||
// config directory and that with "db" as the data
|
||||
// directory.
|
||||
boost::filesystem::path dataDir;
|
||||
std::filesystem::path dataDir;
|
||||
|
||||
if (!strConf.empty())
|
||||
{
|
||||
// --conf=<path> : everything is relative that file.
|
||||
configFile_ = strConf;
|
||||
configDir = boost::filesystem::absolute(configFile_);
|
||||
configDir = std::filesystem::absolute(configFile_);
|
||||
configDir.remove_filename();
|
||||
dataDir = configDir / kDatabaseDirName;
|
||||
}
|
||||
@@ -330,13 +329,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
||||
// Check if either of the config files exist in the current working
|
||||
// directory, in which case the databases will be stored in a
|
||||
// subdirectory.
|
||||
configDir = boost::filesystem::current_path();
|
||||
configDir = std::filesystem::current_path();
|
||||
dataDir = configDir / kDatabaseDirName;
|
||||
configFile_ = configDir / kConfigFileName;
|
||||
if (boost::filesystem::exists(configFile_))
|
||||
if (std::filesystem::exists(configFile_))
|
||||
break;
|
||||
configFile_ = configDir / kConfigLegacyName;
|
||||
if (boost::filesystem::exists(configFile_))
|
||||
if (std::filesystem::exists(configFile_))
|
||||
break;
|
||||
|
||||
// Check if the home directory is set, and optionally the XDG config
|
||||
@@ -363,10 +362,10 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
||||
dataDir = strXdgDataHome + "/" + systemName();
|
||||
configDir = strXdgConfigHome + "/" + systemName();
|
||||
configFile_ = configDir / kConfigFileName;
|
||||
if (boost::filesystem::exists(configFile_))
|
||||
if (std::filesystem::exists(configFile_))
|
||||
break;
|
||||
configFile_ = configDir / kConfigLegacyName;
|
||||
if (boost::filesystem::exists(configFile_))
|
||||
if (std::filesystem::exists(configFile_))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -374,7 +373,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
||||
dataDir = "/var/lib/" + systemName();
|
||||
configDir = "/etc/" + systemName();
|
||||
configFile_ = configDir / kConfigFileName;
|
||||
if (boost::filesystem::exists(configFile_))
|
||||
if (std::filesystem::exists(configFile_))
|
||||
break;
|
||||
configFile_ = configDir / kConfigLegacyName;
|
||||
} while (false);
|
||||
@@ -387,7 +386,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
||||
std::string const dbPath(legacy(Sections::kDatabasePath));
|
||||
if (!dbPath.empty())
|
||||
{
|
||||
dataDir = boost::filesystem::path(dbPath);
|
||||
dataDir = std::filesystem::path(dbPath);
|
||||
}
|
||||
else if (runStandalone_)
|
||||
{
|
||||
@@ -397,13 +396,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
|
||||
|
||||
if (!dataDir.empty())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::create_directories(dataDir, ec);
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(dataDir, ec);
|
||||
|
||||
if (ec)
|
||||
Throw<std::runtime_error>(boost::str(boost::format("Can not create %s") % dataDir));
|
||||
|
||||
legacy(Sections::kDatabasePath, boost::filesystem::absolute(dataDir).string());
|
||||
legacy(Sections::kDatabasePath, std::filesystem::absolute(dataDir).string());
|
||||
}
|
||||
|
||||
HTTPClient::initializeSSLContext(this->sslVerifyDir, this->sslVerifyFile, this->sslVerify, j_);
|
||||
@@ -455,7 +454,7 @@ Config::load()
|
||||
if (!quiet_)
|
||||
std::cerr << "Loading: " << configFile_ << "\n";
|
||||
|
||||
boost::system::error_code ec;
|
||||
std::error_code ec;
|
||||
auto const fileContents = getFileContents(ec, configFile_);
|
||||
|
||||
if (ec)
|
||||
@@ -508,8 +507,8 @@ Config::loadFromString(std::string const& fileContents)
|
||||
std::string dbPath;
|
||||
if (getSingleSection(secConfig, Sections::kDatabasePath, dbPath, j_))
|
||||
{
|
||||
boost::filesystem::path const p(dbPath);
|
||||
legacy(Sections::kDatabasePath, boost::filesystem::absolute(p).string());
|
||||
std::filesystem::path const p(dbPath);
|
||||
legacy(Sections::kDatabasePath, std::filesystem::absolute(p).string());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -976,7 +975,7 @@ Config::loadFromString(std::string const& fileContents)
|
||||
// If no path was specified, then look for validators.txt
|
||||
// in the same directory as the config file, but don't complain
|
||||
// if we can't find it.
|
||||
boost::filesystem::path validatorsFile;
|
||||
std::filesystem::path validatorsFile;
|
||||
|
||||
if (getSingleSection(secConfig, Sections::kValidatorsFile, strTemp, j_))
|
||||
{
|
||||
@@ -991,7 +990,7 @@ Config::loadFromString(std::string const& fileContents)
|
||||
if (!validatorsFile.is_absolute() && !configDir.empty())
|
||||
validatorsFile = configDir / validatorsFile;
|
||||
|
||||
if (!boost::filesystem::exists(validatorsFile))
|
||||
if (!std::filesystem::exists(validatorsFile))
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
std::string("The file specified in [") + Sections::kValidatorsFile +
|
||||
@@ -1000,8 +999,8 @@ Config::loadFromString(std::string const& fileContents)
|
||||
validatorsFile.string());
|
||||
}
|
||||
else if (
|
||||
!boost::filesystem::is_regular_file(validatorsFile) &&
|
||||
!boost::filesystem::is_symlink(validatorsFile))
|
||||
!std::filesystem::is_regular_file(validatorsFile) &&
|
||||
!std::filesystem::is_symlink(validatorsFile))
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
std::string("Invalid file specified in [") + Sections::kValidatorsFile +
|
||||
@@ -1014,20 +1013,20 @@ Config::loadFromString(std::string const& fileContents)
|
||||
|
||||
if (!validatorsFile.empty())
|
||||
{
|
||||
if (!boost::filesystem::exists(validatorsFile) ||
|
||||
(!boost::filesystem::is_regular_file(validatorsFile) &&
|
||||
!boost::filesystem::is_symlink(validatorsFile)))
|
||||
if (!std::filesystem::exists(validatorsFile) ||
|
||||
(!std::filesystem::is_regular_file(validatorsFile) &&
|
||||
!std::filesystem::is_symlink(validatorsFile)))
|
||||
{
|
||||
validatorsFile.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!validatorsFile.empty() && boost::filesystem::exists(validatorsFile) &&
|
||||
(boost::filesystem::is_regular_file(validatorsFile) ||
|
||||
boost::filesystem::is_symlink(validatorsFile)))
|
||||
if (!validatorsFile.empty() && std::filesystem::exists(validatorsFile) &&
|
||||
(std::filesystem::is_regular_file(validatorsFile) ||
|
||||
std::filesystem::is_symlink(validatorsFile)))
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::error_code ec;
|
||||
auto const data = getFileContents(ec, validatorsFile);
|
||||
if (ec)
|
||||
{
|
||||
@@ -1160,7 +1159,7 @@ Config::loadFromString(std::string const& fileContents)
|
||||
}
|
||||
}
|
||||
|
||||
boost::filesystem::path
|
||||
std::filesystem::path
|
||||
Config::getDebugLogFile() const
|
||||
{
|
||||
auto logFile = debugLogfile_;
|
||||
@@ -1169,17 +1168,17 @@ Config::getDebugLogFile() const
|
||||
{
|
||||
// Unless an absolute path for the log file is specified, the
|
||||
// path is relative to the config file directory.
|
||||
logFile = boost::filesystem::absolute(logFile, configDir);
|
||||
logFile = std::filesystem::absolute(configDir / logFile);
|
||||
}
|
||||
|
||||
if (!logFile.empty())
|
||||
{
|
||||
auto logDir = logFile.parent_path();
|
||||
|
||||
if (!boost::filesystem::is_directory(logDir))
|
||||
if (!std::filesystem::is_directory(logDir))
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::create_directories(logDir, ec);
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(logDir, ec);
|
||||
|
||||
// If we fail, we warn but continue so that the calling code can
|
||||
// decide how to handle this situation.
|
||||
|
||||
@@ -17,11 +17,9 @@
|
||||
#include <xrpl/nodestore/Database.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
@@ -29,6 +27,7 @@
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -220,10 +219,10 @@ PerfLogImp::openLog()
|
||||
logFile_.close();
|
||||
|
||||
auto logDir = setup_.perfLog.parent_path();
|
||||
if (!boost::filesystem::is_directory(logDir))
|
||||
if (!std::filesystem::is_directory(logDir))
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::create_directories(logDir, ec);
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(logDir, ec);
|
||||
if (ec)
|
||||
{
|
||||
JLOG(j_.fatal()) << "Unable to create performance log "
|
||||
@@ -478,17 +477,17 @@ PerfLogImp::stop()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PerfLog::Setup
|
||||
setupPerfLog(Section const& section, boost::filesystem::path const& configDir)
|
||||
setupPerfLog(Section const& section, std::filesystem::path const& configDir)
|
||||
{
|
||||
PerfLog::Setup setup;
|
||||
std::string perfLog;
|
||||
set(perfLog, "perf_log", section);
|
||||
if (!perfLog.empty())
|
||||
{
|
||||
setup.perfLog = boost::filesystem::path(perfLog);
|
||||
setup.perfLog = std::filesystem::path(perfLog);
|
||||
if (setup.perfLog.is_relative())
|
||||
{
|
||||
setup.perfLog = boost::filesystem::absolute(setup.perfLog, configDir);
|
||||
setup.perfLog = std::filesystem::absolute(configDir / setup.perfLog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user