mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-18 01:55:50 +00:00
Compare commits
9 Commits
vlntb/mall
...
bthomee/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
690dced2c8 | ||
|
|
13a12c6402 | ||
|
|
362ecbd1cb | ||
|
|
3faff9f7a6 | ||
|
|
7141781db4 | ||
|
|
802ac5629f | ||
|
|
2f15909ffa | ||
|
|
9184b7274c | ||
|
|
54a19a0e8d |
4
.github/scripts/rename/README.md
vendored
4
.github/scripts/rename/README.md
vendored
@@ -26,6 +26,9 @@ run from the repository root.
|
|||||||
references to `ripple` and `rippled` (with or without capital letters) to
|
references to `ripple` and `rippled` (with or without capital letters) to
|
||||||
`xrpl` and `xrpld`, respectively. The name of the binary will remain as-is,
|
`xrpl` and `xrpld`, respectively. The name of the binary will remain as-is,
|
||||||
and will only be renamed to `xrpld` by a later script.
|
and will only be renamed to `xrpld` by a later script.
|
||||||
|
4. `.github/scripts/rename/binary.sh`: This script will rename the binary from
|
||||||
|
`rippled` to `xrpld`, and reverses the symlink so that `rippled` points to
|
||||||
|
the `xrpld` binary.
|
||||||
|
|
||||||
You can run all these scripts from the repository root as follows:
|
You can run all these scripts from the repository root as follows:
|
||||||
|
|
||||||
@@ -33,4 +36,5 @@ You can run all these scripts from the repository root as follows:
|
|||||||
./.github/scripts/rename/definitions.sh .
|
./.github/scripts/rename/definitions.sh .
|
||||||
./.github/scripts/rename/copyright.sh .
|
./.github/scripts/rename/copyright.sh .
|
||||||
./.github/scripts/rename/cmake.sh .
|
./.github/scripts/rename/cmake.sh .
|
||||||
|
./.github/scripts/rename/binary.sh .
|
||||||
```
|
```
|
||||||
|
|||||||
42
.github/scripts/rename/binary.sh
vendored
Executable file
42
.github/scripts/rename/binary.sh
vendored
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit the script as soon as an error occurs.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||||
|
SED_COMMAND=sed
|
||||||
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
|
if ! command -v gsed &> /dev/null; then
|
||||||
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
SED_COMMAND=gsed
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This script changes the binary name from `rippled` to `xrpld`, and reverses
|
||||||
|
# the symlink that currently points from `xrpld` to `rippled` so that it points
|
||||||
|
# from `rippled` to `xrpld` instead.
|
||||||
|
# Usage: .github/scripts/rename/binary.sh <repository directory>
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <repository directory>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DIRECTORY=$1
|
||||||
|
echo "Processing directory: ${DIRECTORY}"
|
||||||
|
if [ ! -d "${DIRECTORY}" ]; then
|
||||||
|
echo "Error: Directory '${DIRECTORY}' does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
pushd ${DIRECTORY}
|
||||||
|
|
||||||
|
# Remove the binary name override added by the cmake.sh script.
|
||||||
|
${SED_COMMAND} -z -i -E 's@\s+# For the time being.+"rippled"\)@@' cmake/XrplCore.cmake
|
||||||
|
|
||||||
|
# Reverse the symlink.
|
||||||
|
${SED_COMMAND} -i -E 's@create_symbolic_link\(rippled@create_symbolic_link(xrpld@' cmake/XrplInstall.cmake
|
||||||
|
${SED_COMMAND} -i -E 's@/xrpld\$\{suffix\}@/rippled${suffix}@' cmake/XrplInstall.cmake
|
||||||
|
|
||||||
|
popd
|
||||||
|
echo "Processing complete."
|
||||||
14
.github/workflows/reusable-build-test-config.yml
vendored
14
.github/workflows/reusable-build-test-config.yml
vendored
@@ -129,14 +129,14 @@ jobs:
|
|||||||
--parallel "${BUILD_NPROC}" \
|
--parallel "${BUILD_NPROC}" \
|
||||||
--target "${CMAKE_TARGET}"
|
--target "${CMAKE_TARGET}"
|
||||||
|
|
||||||
- name: Upload rippled artifact (Linux)
|
- name: Upload the binary (Linux)
|
||||||
if: ${{ runner.os == 'Linux' }}
|
if: ${{ runner.os == 'Linux' }}
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
env:
|
env:
|
||||||
BUILD_DIR: ${{ inputs.build_dir }}
|
BUILD_DIR: ${{ inputs.build_dir }}
|
||||||
with:
|
with:
|
||||||
name: rippled-${{ inputs.config_name }}
|
name: xrpld-${{ inputs.config_name }}
|
||||||
path: ${{ env.BUILD_DIR }}/rippled
|
path: ${{ env.BUILD_DIR }}/xrpld
|
||||||
retention-days: 3
|
retention-days: 3
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
@@ -144,8 +144,8 @@ jobs:
|
|||||||
if: ${{ runner.os == 'Linux' }}
|
if: ${{ runner.os == 'Linux' }}
|
||||||
working-directory: ${{ inputs.build_dir }}
|
working-directory: ${{ inputs.build_dir }}
|
||||||
run: |
|
run: |
|
||||||
ldd ./rippled
|
ldd ./xrpld
|
||||||
if [ "$(ldd ./rippled | grep -E '(libstdc\+\+|libgcc)' | wc -l)" -eq 0 ]; then
|
if [ "$(ldd ./xrpld | grep -E '(libstdc\+\+|libgcc)' | wc -l)" -eq 0 ]; then
|
||||||
echo 'The binary is statically linked.'
|
echo 'The binary is statically linked.'
|
||||||
else
|
else
|
||||||
echo 'The binary is dynamically linked.'
|
echo 'The binary is dynamically linked.'
|
||||||
@@ -156,7 +156,7 @@ jobs:
|
|||||||
if: ${{ runner.os == 'Linux' && env.ENABLED_VOIDSTAR == 'true' }}
|
if: ${{ runner.os == 'Linux' && env.ENABLED_VOIDSTAR == 'true' }}
|
||||||
working-directory: ${{ inputs.build_dir }}
|
working-directory: ${{ inputs.build_dir }}
|
||||||
run: |
|
run: |
|
||||||
./rippled --version | grep libvoidstar
|
./xrpld --version | grep libvoidstar
|
||||||
|
|
||||||
- name: Run the separate tests
|
- name: Run the separate tests
|
||||||
if: ${{ !inputs.build_only }}
|
if: ${{ !inputs.build_only }}
|
||||||
@@ -177,7 +177,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
BUILD_NPROC: ${{ steps.nproc.outputs.nproc }}
|
BUILD_NPROC: ${{ steps.nproc.outputs.nproc }}
|
||||||
run: |
|
run: |
|
||||||
./rippled --unittest --unittest-jobs "${BUILD_NPROC}"
|
./xrpld --unittest --unittest-jobs "${BUILD_NPROC}"
|
||||||
|
|
||||||
- name: Debug failure (Linux)
|
- name: Debug failure (Linux)
|
||||||
if: ${{ failure() && runner.os == 'Linux' && !inputs.build_only }}
|
if: ${{ failure() && runner.os == 'Linux' && !inputs.build_only }}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
MESSAGE: |
|
MESSAGE: |
|
||||||
|
|
||||||
The dependency relationships between the modules in rippled have
|
The dependency relationships between the modules in xrpld have
|
||||||
changed, which may be an improvement or a regression.
|
changed, which may be an improvement or a regression.
|
||||||
|
|
||||||
A rule of thumb is that if your changes caused something to be
|
A rule of thumb is that if your changes caused something to be
|
||||||
|
|||||||
2
.github/workflows/reusable-check-rename.yml
vendored
2
.github/workflows/reusable-check-rename.yml
vendored
@@ -25,6 +25,8 @@ jobs:
|
|||||||
run: .github/scripts/rename/copyright.sh .
|
run: .github/scripts/rename/copyright.sh .
|
||||||
- name: Check CMake configs
|
- name: Check CMake configs
|
||||||
run: .github/scripts/rename/cmake.sh .
|
run: .github/scripts/rename/cmake.sh .
|
||||||
|
- name: Check binary name
|
||||||
|
run: .github/scripts/rename/binary.sh .
|
||||||
- name: Check for differences
|
- name: Check for differences
|
||||||
env:
|
env:
|
||||||
MESSAGE: |
|
MESSAGE: |
|
||||||
|
|||||||
@@ -223,6 +223,4 @@ if(xrpld)
|
|||||||
src/test/ledger/Invariants_test.cpp
|
src/test/ledger/Invariants_test.cpp
|
||||||
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
|
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
|
||||||
endif()
|
endif()
|
||||||
# For the time being, we will keep the name of the binary as it was.
|
|
||||||
set_target_properties(xrpld PROPERTIES OUTPUT_NAME "rippled")
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ if (is_root_project AND TARGET xrpld)
|
|||||||
install(CODE "
|
install(CODE "
|
||||||
set(CMAKE_MODULE_PATH \"${CMAKE_MODULE_PATH}\")
|
set(CMAKE_MODULE_PATH \"${CMAKE_MODULE_PATH}\")
|
||||||
include(create_symbolic_link)
|
include(create_symbolic_link)
|
||||||
create_symbolic_link(rippled${suffix} \
|
create_symbolic_link(xrpld${suffix} \
|
||||||
\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/xrpld${suffix})
|
\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/rippled${suffix})
|
||||||
")
|
")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,18 @@
|
|||||||
"sqlite3/3.49.1#8631739a4c9b93bd3d6b753bac548a63%1756234266.869",
|
"sqlite3/3.49.1#8631739a4c9b93bd3d6b753bac548a63%1756234266.869",
|
||||||
"soci/4.0.3#a9f8d773cd33e356b5879a4b0564f287%1756234262.318",
|
"soci/4.0.3#a9f8d773cd33e356b5879a4b0564f287%1756234262.318",
|
||||||
"snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1756234314.246",
|
"snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1756234314.246",
|
||||||
"rocksdb/10.5.1#4a197eca381a3e5ae8adf8cffa5aacd0%1759820024.194",
|
"rocksdb/10.5.1#4a197eca381a3e5ae8adf8cffa5aacd0%1762797952.535",
|
||||||
"re2/20230301#dfd6e2bf050eb90ddd8729cfb4c844a4%1756234257.976",
|
"re2/20230301#dfd6e2bf050eb90ddd8729cfb4c844a4%1756234257.976",
|
||||||
"protobuf/3.21.12#d927114e28de9f4691a6bbcdd9a529d1%1756234251.614",
|
"protobuf/3.21.12#d927114e28de9f4691a6bbcdd9a529d1%1756234251.614",
|
||||||
"openssl/3.5.4#a1d5835cc6ed5c5b8f3cd5b9b5d24205%1760106486.594",
|
"openssl/3.5.4#a1d5835cc6ed5c5b8f3cd5b9b5d24205%1760106486.594",
|
||||||
"nudb/2.0.9#c62cfd501e57055a7e0d8ee3d5e5427d%1756234237.107",
|
"nudb/2.0.9#fb8dfd1a5557f5e0528114c2da17721e%1763150366.909",
|
||||||
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1756234228.999",
|
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1756234228.999",
|
||||||
"libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1756223727.64",
|
"libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1756223727.64",
|
||||||
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1756230911.03",
|
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1756230911.03",
|
||||||
"libarchive/3.8.1#5cf685686322e906cb42706ab7e099a8%1756234256.696",
|
"libarchive/3.8.1#5cf685686322e906cb42706ab7e099a8%1756234256.696",
|
||||||
"jemalloc/5.3.0#e951da9cf599e956cebc117880d2d9f8%1729241615.244",
|
"jemalloc/5.3.0#e951da9cf599e956cebc117880d2d9f8%1729241615.244",
|
||||||
"grpc/1.50.1#02291451d1e17200293a409410d1c4e1%1756234248.958",
|
"grpc/1.50.1#02291451d1e17200293a409410d1c4e1%1756234248.958",
|
||||||
"doctest/2.4.12#eb9fb352fb2fdfc8abb17ec270945165%1749889324.069",
|
"doctest/2.4.12#eb9fb352fb2fdfc8abb17ec270945165%1762797941.757",
|
||||||
"date/3.0.4#f74bbba5a08fa388256688743136cb6f%1756234217.493",
|
"date/3.0.4#f74bbba5a08fa388256688743136cb6f%1756234217.493",
|
||||||
"c-ares/1.34.5#b78b91e7cfb1f11ce777a285bbf169c6%1756234217.915",
|
"c-ares/1.34.5#b78b91e7cfb1f11ce777a285bbf169c6%1756234217.915",
|
||||||
"bzip2/1.0.8#00b4a4658791c1f06914e087f0e792f5%1756234261.716",
|
"bzip2/1.0.8#00b4a4658791c1f06914e087f0e792f5%1756234261.716",
|
||||||
@@ -53,6 +53,9 @@
|
|||||||
],
|
],
|
||||||
"lz4/[>=1.9.4 <2]": [
|
"lz4/[>=1.9.4 <2]": [
|
||||||
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504"
|
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504"
|
||||||
|
],
|
||||||
|
"sqlite3/3.44.2": [
|
||||||
|
"sqlite3/3.49.1"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"config_requires": []
|
"config_requires": []
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
#ifndef XRPL_BASICS_MALLOCTRIM_H_INCLUDED
|
|
||||||
#define XRPL_BASICS_MALLOCTRIM_H_INCLUDED
|
|
||||||
|
|
||||||
#include <xrpl/beast/utility/Journal.h>
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace ripple {
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Allocator interaction note:
|
|
||||||
// - This facility invokes glibc's malloc_trim(0) on Linux/glibc to request that
|
|
||||||
// ptmalloc return free heap pages to the OS.
|
|
||||||
// - If an alternative allocator (e.g. jemalloc or tcmalloc) is linked or
|
|
||||||
// preloaded (LD_PRELOAD), calling glibc's malloc_trim typically has no effect
|
|
||||||
// on the *active* heap. The call is harmless but may not reclaim memory
|
|
||||||
// because those allocators manage their own arenas.
|
|
||||||
// - Only glibc sbrk/arena space is eligible for trimming; large mmap-backed
|
|
||||||
// allocations are usually returned to the OS on free regardless of trimming.
|
|
||||||
// - Call at known reclamation points (e.g., after cache sweeps / online delete)
|
|
||||||
// and consider rate limiting to avoid churn.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
struct MallocTrimReport
|
|
||||||
{
|
|
||||||
bool supported{false};
|
|
||||||
int trimResult{-1};
|
|
||||||
long rssBeforeKB{-1};
|
|
||||||
long rssAfterKB{-1};
|
|
||||||
|
|
||||||
[[nodiscard]] long
|
|
||||||
deltaKB() const noexcept
|
|
||||||
{
|
|
||||||
if (rssBeforeKB < 0 || rssAfterKB < 0)
|
|
||||||
return 0;
|
|
||||||
return rssAfterKB - rssBeforeKB;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Attempt to return freed memory to the operating system.
|
|
||||||
*
|
|
||||||
* On Linux with glibc malloc, this issues ::malloc_trim(0), which may release
|
|
||||||
* free space from ptmalloc arenas back to the kernel. On other platforms, or if
|
|
||||||
* a different allocator is in use, this function is a no-op and the report will
|
|
||||||
* indicate that trimming is unsupported or had no effect.
|
|
||||||
*
|
|
||||||
* @param tag Optional identifier for logging/debugging purposes.
|
|
||||||
* @param journal Journal for diagnostic logging.
|
|
||||||
* @return Report containing before/after metrics and the trim result.
|
|
||||||
*
|
|
||||||
* @note If an alternative allocator (jemalloc/tcmalloc) is linked or preloaded,
|
|
||||||
* calling glibc's malloc_trim may have no effect on the active heap. The
|
|
||||||
* call is harmless but typically does not reclaim memory under those
|
|
||||||
* allocators.
|
|
||||||
*
|
|
||||||
* @note Only memory served from glibc's sbrk/arena heaps is eligible for trim.
|
|
||||||
* Large allocations satisfied via mmap are usually returned on free
|
|
||||||
* independently of trimming.
|
|
||||||
*
|
|
||||||
* @note Intended for use after operations that free significant memory (e.g.,
|
|
||||||
* cache sweeps, ledger cleanup, online delete). Consider rate limiting.
|
|
||||||
*/
|
|
||||||
MallocTrimReport
|
|
||||||
mallocTrim(std::optional<std::string> const& tag, beast::Journal journal);
|
|
||||||
|
|
||||||
} // namespace ripple
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
#include <xrpl/basics/Log.h>
|
|
||||||
#include <xrpl/basics/MallocTrim.h>
|
|
||||||
|
|
||||||
#include <boost/predef.h>
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
pid_t const cachedPid = ::getpid();
|
|
||||||
} // namespace
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace ripple {
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
|
|
||||||
long
|
|
||||||
parseVmRSSkB(std::string const& status)
|
|
||||||
{
|
|
||||||
std::istringstream iss(status);
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
while (std::getline(iss, line))
|
|
||||||
{
|
|
||||||
// Allow leading spaces/tabs before the key.
|
|
||||||
auto const firstNonWs = line.find_first_not_of(" \t");
|
|
||||||
if (firstNonWs == std::string::npos)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
constexpr char key[] = "VmRSS:";
|
|
||||||
constexpr auto keyLen = sizeof(key) - 1;
|
|
||||||
|
|
||||||
// Require the line (after leading whitespace) to start with "VmRSS:".
|
|
||||||
// Check if we have enough characters and the substring matches.
|
|
||||||
if (firstNonWs + keyLen > line.size() ||
|
|
||||||
line.substr(firstNonWs, keyLen) != key)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Move past "VmRSS:" and any following whitespace.
|
|
||||||
auto pos = firstNonWs + keyLen;
|
|
||||||
while (pos < line.size() &&
|
|
||||||
std::isspace(static_cast<unsigned char>(line[pos])))
|
|
||||||
{
|
|
||||||
++pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
long value = -1;
|
|
||||||
if (std::sscanf(line.c_str() + pos, "%ld", &value) == 1)
|
|
||||||
return value;
|
|
||||||
|
|
||||||
// Found the key but couldn't parse a number.
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No VmRSS line found.
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __GLIBC__ && BOOST_OS_LINUX
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
MallocTrimReport
|
|
||||||
mallocTrim(
|
|
||||||
[[maybe_unused]] std::optional<std::string> const& tag,
|
|
||||||
beast::Journal journal)
|
|
||||||
{
|
|
||||||
MallocTrimReport report;
|
|
||||||
|
|
||||||
#if !(defined(__GLIBC__) && BOOST_OS_LINUX)
|
|
||||||
JLOG(journal.debug()) << "malloc_trim not supported on this platform";
|
|
||||||
#else
|
|
||||||
|
|
||||||
report.supported = true;
|
|
||||||
|
|
||||||
if (journal.debug())
|
|
||||||
{
|
|
||||||
auto readFile = [](std::string const& path) -> std::string {
|
|
||||||
std::ifstream ifs(path);
|
|
||||||
if (!ifs.is_open())
|
|
||||||
return {};
|
|
||||||
return std::string(
|
|
||||||
std::istreambuf_iterator<char>(ifs),
|
|
||||||
std::istreambuf_iterator<char>());
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string const tagStr = tag.value_or("default");
|
|
||||||
std::string const statusPath =
|
|
||||||
"/proc/" + std::to_string(cachedPid) + "/status";
|
|
||||||
|
|
||||||
auto const statusBefore = readFile(statusPath);
|
|
||||||
report.rssBeforeKB = detail::parseVmRSSkB(statusBefore);
|
|
||||||
|
|
||||||
report.trimResult = ::malloc_trim(0);
|
|
||||||
|
|
||||||
auto const statusAfter = readFile(statusPath);
|
|
||||||
report.rssAfterKB = detail::parseVmRSSkB(statusAfter);
|
|
||||||
|
|
||||||
JLOG(journal.debug())
|
|
||||||
<< "malloc_trim tag=" << tagStr << " result=" << report.trimResult
|
|
||||||
<< " rss_before=" << report.rssBeforeKB << "kB"
|
|
||||||
<< " rss_after=" << report.rssAfterKB << "kB"
|
|
||||||
<< " delta=" << report.deltaKB() << "kB";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
report.trimResult = ::malloc_trim(0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return report;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ripple
|
|
||||||
@@ -1329,7 +1329,7 @@ class Vault_test : public beast::unit_test::suite
|
|||||||
Vault& vault) {
|
Vault& vault) {
|
||||||
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
|
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
|
||||||
testcase("insufficient fee");
|
testcase("insufficient fee");
|
||||||
env(tx, fee(env.current()->fees().base), ter(telINSUF_FEE_P));
|
env(tx, fee(env.current()->fees().base - 1), ter(telINSUF_FEE_P));
|
||||||
});
|
});
|
||||||
|
|
||||||
testCase([this](
|
testCase([this](
|
||||||
@@ -2074,6 +2074,10 @@ class Vault_test : public beast::unit_test::suite
|
|||||||
auto const sleMPT = env.le(mptoken);
|
auto const sleMPT = env.le(mptoken);
|
||||||
BEAST_EXPECT(sleMPT == nullptr);
|
BEAST_EXPECT(sleMPT == nullptr);
|
||||||
|
|
||||||
|
// Use one reserve so the next transaction fails
|
||||||
|
env(ticket::create(owner, 1));
|
||||||
|
env.close();
|
||||||
|
|
||||||
// No reserve to create MPToken for asset in VaultWithdraw
|
// No reserve to create MPToken for asset in VaultWithdraw
|
||||||
tx = vault.withdraw(
|
tx = vault.withdraw(
|
||||||
{.depositor = owner,
|
{.depositor = owner,
|
||||||
@@ -2091,7 +2095,7 @@ class Vault_test : public beast::unit_test::suite
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{.requireAuth = false,
|
{.requireAuth = false,
|
||||||
.initialXRP = acctReserve + incReserve * 4 - 1});
|
.initialXRP = acctReserve + incReserve * 4 + 1});
|
||||||
|
|
||||||
testCase([this](
|
testCase([this](
|
||||||
Env& env,
|
Env& env,
|
||||||
@@ -2980,6 +2984,9 @@ class Vault_test : public beast::unit_test::suite
|
|||||||
env.le(keylet::line(owner, asset.raw().get<Issue>()));
|
env.le(keylet::line(owner, asset.raw().get<Issue>()));
|
||||||
BEAST_EXPECT(trustline == nullptr);
|
BEAST_EXPECT(trustline == nullptr);
|
||||||
|
|
||||||
|
env(ticket::create(owner, 1));
|
||||||
|
env.close();
|
||||||
|
|
||||||
// Fail because not enough reserve to create trust line
|
// Fail because not enough reserve to create trust line
|
||||||
tx = vault.withdraw(
|
tx = vault.withdraw(
|
||||||
{.depositor = owner,
|
{.depositor = owner,
|
||||||
@@ -2995,7 +3002,7 @@ class Vault_test : public beast::unit_test::suite
|
|||||||
env(tx);
|
env(tx);
|
||||||
env.close();
|
env.close();
|
||||||
},
|
},
|
||||||
CaseArgs{.initialXRP = acctReserve + incReserve * 4 - 1});
|
CaseArgs{.initialXRP = acctReserve + incReserve * 4 + 1});
|
||||||
|
|
||||||
testCase(
|
testCase(
|
||||||
[&, this](
|
[&, this](
|
||||||
@@ -3016,8 +3023,7 @@ class Vault_test : public beast::unit_test::suite
|
|||||||
env(pay(owner, charlie, asset(100)));
|
env(pay(owner, charlie, asset(100)));
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// Use up some reserve on tickets
|
env(ticket::create(charlie, 3));
|
||||||
env(ticket::create(charlie, 2));
|
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// Fail because not enough reserve to create MPToken for shares
|
// Fail because not enough reserve to create MPToken for shares
|
||||||
@@ -3035,7 +3041,7 @@ class Vault_test : public beast::unit_test::suite
|
|||||||
env(tx);
|
env(tx);
|
||||||
env.close();
|
env.close();
|
||||||
},
|
},
|
||||||
CaseArgs{.initialXRP = acctReserve + incReserve * 4 - 1});
|
CaseArgs{.initialXRP = acctReserve + incReserve * 4 + 1});
|
||||||
|
|
||||||
testCase([&, this](
|
testCase([&, this](
|
||||||
Env& env,
|
Env& env,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ Vault::create(CreateArgs const& args)
|
|||||||
jv[jss::TransactionType] = jss::VaultCreate;
|
jv[jss::TransactionType] = jss::VaultCreate;
|
||||||
jv[jss::Account] = args.owner.human();
|
jv[jss::Account] = args.owner.human();
|
||||||
jv[jss::Asset] = to_json(args.asset);
|
jv[jss::Asset] = to_json(args.asset);
|
||||||
jv[jss::Fee] = STAmount(env.current()->fees().increment).getJson();
|
|
||||||
if (args.flags)
|
if (args.flags)
|
||||||
jv[jss::Flags] = *args.flags;
|
jv[jss::Flags] = *args.flags;
|
||||||
return {jv, keylet};
|
return {jv, keylet};
|
||||||
|
|||||||
@@ -1,207 +0,0 @@
|
|||||||
#include <xrpl/basics/MallocTrim.h>
|
|
||||||
|
|
||||||
#include <boost/predef.h>
|
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
|
||||||
|
|
||||||
using namespace ripple;
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
namespace ripple::detail {
|
|
||||||
long
|
|
||||||
parseVmRSSkB(std::string const& status);
|
|
||||||
} // namespace ripple::detail
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST_CASE("MallocTrimReport structure")
|
|
||||||
{
|
|
||||||
// Test default construction
|
|
||||||
MallocTrimReport report;
|
|
||||||
CHECK(report.supported == false);
|
|
||||||
CHECK(report.trimResult == -1);
|
|
||||||
CHECK(report.rssBeforeKB == -1);
|
|
||||||
CHECK(report.rssAfterKB == -1);
|
|
||||||
CHECK(report.deltaKB() == 0);
|
|
||||||
|
|
||||||
// Test deltaKB calculation - memory freed
|
|
||||||
report.rssBeforeKB = 1000;
|
|
||||||
report.rssAfterKB = 800;
|
|
||||||
CHECK(report.deltaKB() == -200);
|
|
||||||
|
|
||||||
// Test deltaKB calculation - memory increased
|
|
||||||
report.rssBeforeKB = 500;
|
|
||||||
report.rssAfterKB = 600;
|
|
||||||
CHECK(report.deltaKB() == 100);
|
|
||||||
|
|
||||||
// Test deltaKB calculation - no change
|
|
||||||
report.rssBeforeKB = 1234;
|
|
||||||
report.rssAfterKB = 1234;
|
|
||||||
CHECK(report.deltaKB() == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
TEST_CASE("parseVmRSSkB")
|
|
||||||
{
|
|
||||||
using ripple::detail::parseVmRSSkB;
|
|
||||||
|
|
||||||
// Test standard format
|
|
||||||
{
|
|
||||||
std::string status = "VmRSS: 123456 kB\n";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == 123456);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test with multiple lines
|
|
||||||
{
|
|
||||||
std::string status =
|
|
||||||
"Name: rippled\n"
|
|
||||||
"VmPeak: 1234567 kB\n"
|
|
||||||
"VmSize: 1234567 kB\n"
|
|
||||||
"VmRSS: 987654 kB\n"
|
|
||||||
"VmData: 123456 kB\n";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == 987654);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test with minimal whitespace
|
|
||||||
{
|
|
||||||
std::string status = "VmRSS: 42 kB";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == 42);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test with extra whitespace
|
|
||||||
{
|
|
||||||
std::string status = "VmRSS: 999999 kB";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == 999999);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test with tabs
|
|
||||||
{
|
|
||||||
std::string status = "VmRSS:\t\t12345 kB";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
// Note: tabs are not explicitly handled as spaces, this documents
|
|
||||||
// current behavior
|
|
||||||
CHECK(result == 12345);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test zero value
|
|
||||||
{
|
|
||||||
std::string status = "VmRSS: 0 kB\n";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test missing VmRSS
|
|
||||||
{
|
|
||||||
std::string status =
|
|
||||||
"Name: rippled\n"
|
|
||||||
"VmPeak: 1234567 kB\n"
|
|
||||||
"VmSize: 1234567 kB\n";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test empty string
|
|
||||||
{
|
|
||||||
std::string status = "";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test malformed data (VmRSS but no number)
|
|
||||||
{
|
|
||||||
std::string status = "VmRSS: \n";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
// sscanf should fail to parse and return -1 unchanged
|
|
||||||
CHECK(result == -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test malformed data (VmRSS but invalid number)
|
|
||||||
{
|
|
||||||
std::string status = "VmRSS: abc kB\n";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
// sscanf should fail and return -1 unchanged
|
|
||||||
CHECK(result == -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test partial match (should not match "NotVmRSS:")
|
|
||||||
{
|
|
||||||
std::string status = "NotVmRSS: 123456 kB\n";
|
|
||||||
long result = parseVmRSSkB(status);
|
|
||||||
CHECK(result == -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST_CASE("mallocTrim basic functionality")
|
|
||||||
{
|
|
||||||
beast::Journal journal{beast::Journal::getNullSink()};
|
|
||||||
|
|
||||||
// Test with no tag
|
|
||||||
{
|
|
||||||
MallocTrimReport report = mallocTrim(std::nullopt, journal);
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
// On Linux with glibc, should be supported
|
|
||||||
CHECK(report.supported == true);
|
|
||||||
// trimResult should be 0 or 1 (success indicators)
|
|
||||||
CHECK(report.trimResult >= 0);
|
|
||||||
#else
|
|
||||||
// On other platforms, should be unsupported
|
|
||||||
CHECK(report.supported == false);
|
|
||||||
CHECK(report.trimResult == -1);
|
|
||||||
CHECK(report.rssBeforeKB == -1);
|
|
||||||
CHECK(report.rssAfterKB == -1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test with tag
|
|
||||||
{
|
|
||||||
MallocTrimReport report =
|
|
||||||
mallocTrim(std::optional<std::string>("test_tag"), journal);
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
CHECK(report.supported == true);
|
|
||||||
CHECK(report.trimResult >= 0);
|
|
||||||
#else
|
|
||||||
CHECK(report.supported == false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("mallocTrim with debug logging")
|
|
||||||
{
|
|
||||||
beast::Journal journal{beast::Journal::getNullSink()};
|
|
||||||
|
|
||||||
MallocTrimReport report =
|
|
||||||
mallocTrim(std::optional<std::string>("debug_test"), journal);
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
CHECK(report.supported == true);
|
|
||||||
// The function should complete without crashing
|
|
||||||
#else
|
|
||||||
CHECK(report.supported == false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("mallocTrim repeated calls")
|
|
||||||
{
|
|
||||||
beast::Journal journal{beast::Journal::getNullSink()};
|
|
||||||
|
|
||||||
// Call malloc_trim multiple times to ensure it's safe
|
|
||||||
for (int i = 0; i < 5; ++i)
|
|
||||||
{
|
|
||||||
MallocTrimReport report = mallocTrim(
|
|
||||||
std::optional<std::string>("iteration_" + std::to_string(i)),
|
|
||||||
journal);
|
|
||||||
|
|
||||||
#if defined(__GLIBC__) && BOOST_OS_LINUX
|
|
||||||
CHECK(report.supported == true);
|
|
||||||
CHECK(report.trimResult >= 0);
|
|
||||||
#else
|
|
||||||
CHECK(report.supported == false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <xrpld/core/JobQueue.h>
|
#include <xrpld/core/JobQueue.h>
|
||||||
|
|
||||||
#include <xrpl/basics/Log.h>
|
#include <xrpl/basics/Log.h>
|
||||||
#include <xrpl/basics/MallocTrim.h>
|
|
||||||
#include <xrpl/protocol/Indexes.h>
|
#include <xrpl/protocol/Indexes.h>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
@@ -155,8 +154,6 @@ OrderBookDB::update(std::shared_ptr<ReadView const> const& ledger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
app_.getLedgerMaster().newOrderBookDB();
|
app_.getLedgerMaster().newOrderBookDB();
|
||||||
|
|
||||||
mallocTrim(std::optional<std::string>("OrderBookUpdate"), j_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include <xrpld/shamap/NodeFamily.h>
|
#include <xrpld/shamap/NodeFamily.h>
|
||||||
|
|
||||||
#include <xrpl/basics/ByteUtilities.h>
|
#include <xrpl/basics/ByteUtilities.h>
|
||||||
#include <xrpl/basics/MallocTrim.h>
|
|
||||||
#include <xrpl/basics/ResolverAsio.h>
|
#include <xrpl/basics/ResolverAsio.h>
|
||||||
#include <xrpl/basics/random.h>
|
#include <xrpl/basics/random.h>
|
||||||
#include <xrpl/beast/asio/io_latency_probe.h>
|
#include <xrpl/beast/asio/io_latency_probe.h>
|
||||||
@@ -1107,8 +1106,6 @@ public:
|
|||||||
<< "; size after: " << cachedSLEs_.size();
|
<< "; size after: " << cachedSLEs_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
mallocTrim(std::optional<std::string>("doSweep"), m_journal);
|
|
||||||
|
|
||||||
// Set timer to do another sweep later.
|
// Set timer to do another sweep later.
|
||||||
setSweepTimer();
|
setSweepTimer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#include <xrpld/rpc/MPTokenIssuanceID.h>
|
#include <xrpld/rpc/MPTokenIssuanceID.h>
|
||||||
#include <xrpld/rpc/ServerHandler.h>
|
#include <xrpld/rpc/ServerHandler.h>
|
||||||
|
|
||||||
#include <xrpl/basics/MallocTrim.h>
|
|
||||||
#include <xrpl/basics/UptimeClock.h>
|
#include <xrpl/basics/UptimeClock.h>
|
||||||
#include <xrpl/basics/mulDiv.h>
|
#include <xrpl/basics/mulDiv.h>
|
||||||
#include <xrpl/basics/safe_cast.h>
|
#include <xrpl/basics/safe_cast.h>
|
||||||
@@ -2548,14 +2547,10 @@ NetworkOPsImp::setMode(OperatingMode om)
|
|||||||
if (mMode == om)
|
if (mMode == om)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto const oldMode = mMode.load(std::memory_order_relaxed);
|
|
||||||
mMode = om;
|
mMode = om;
|
||||||
|
|
||||||
accounting_.mode(om);
|
accounting_.mode(om);
|
||||||
|
|
||||||
if (oldMode != OperatingMode::FULL && om == OperatingMode::FULL)
|
|
||||||
mallocTrim(std::optional<std::string>("SyncComplete"), m_journal);
|
|
||||||
|
|
||||||
JLOG(m_journal.info()) << "STATE->" << strOperatingMode();
|
JLOG(m_journal.info()) << "STATE->" << strOperatingMode();
|
||||||
pubServer();
|
pubServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
|
#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
|
||||||
#include <xrpld/core/ConfigSections.h>
|
#include <xrpld/core/ConfigSections.h>
|
||||||
|
|
||||||
#include <xrpl/basics/MallocTrim.h>
|
|
||||||
#include <xrpl/beast/core/CurrentThreadName.h>
|
#include <xrpl/beast/core/CurrentThreadName.h>
|
||||||
#include <xrpl/nodestore/Scheduler.h>
|
#include <xrpl/nodestore/Scheduler.h>
|
||||||
#include <xrpl/nodestore/detail/DatabaseRotatingImp.h>
|
#include <xrpl/nodestore/detail/DatabaseRotatingImp.h>
|
||||||
@@ -546,8 +545,6 @@ SHAMapStoreImp::clearCaches(LedgerIndex validatedSeq)
|
|||||||
{
|
{
|
||||||
ledgerMaster_->clearLedgerCachePrior(validatedSeq);
|
ledgerMaster_->clearLedgerCachePrior(validatedSeq);
|
||||||
fullBelowCache_->clear();
|
fullBelowCache_->clear();
|
||||||
|
|
||||||
mallocTrim(std::optional<std::string>("clearCaches"), journal_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -613,8 +610,6 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated)
|
|||||||
});
|
});
|
||||||
if (healthWait() == stopping)
|
if (healthWait() == stopping)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mallocTrim(std::optional<std::string>("clearPrior"), journal_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SHAMapStoreImp::HealthResult
|
SHAMapStoreImp::HealthResult
|
||||||
|
|||||||
@@ -79,13 +79,6 @@ VaultCreate::preflight(PreflightContext const& ctx)
|
|||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
XRPAmount
|
|
||||||
VaultCreate::calculateBaseFee(ReadView const& view, STTx const& tx)
|
|
||||||
{
|
|
||||||
// One reserve increment is typically much greater than one base fee.
|
|
||||||
return calculateOwnerReserveFee(view, tx);
|
|
||||||
}
|
|
||||||
|
|
||||||
TER
|
TER
|
||||||
VaultCreate::preclaim(PreclaimContext const& ctx)
|
VaultCreate::preclaim(PreclaimContext const& ctx)
|
||||||
{
|
{
|
||||||
@@ -142,8 +135,9 @@ VaultCreate::doApply()
|
|||||||
|
|
||||||
if (auto ter = dirLink(view(), account_, vault))
|
if (auto ter = dirLink(view(), account_, vault))
|
||||||
return ter;
|
return ter;
|
||||||
adjustOwnerCount(view(), owner, 1, j_);
|
// We will create Vault and PseudoAccount, hence increase OwnerCount by 2
|
||||||
auto ownerCount = owner->at(sfOwnerCount);
|
adjustOwnerCount(view(), owner, 2, j_);
|
||||||
|
auto const ownerCount = owner->at(sfOwnerCount);
|
||||||
if (mPriorBalance < view().fees().accountReserve(ownerCount))
|
if (mPriorBalance < view().fees().accountReserve(ownerCount))
|
||||||
return tecINSUFFICIENT_RESERVE;
|
return tecINSUFFICIENT_RESERVE;
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ public:
|
|||||||
static NotTEC
|
static NotTEC
|
||||||
preflight(PreflightContext const& ctx);
|
preflight(PreflightContext const& ctx);
|
||||||
|
|
||||||
static XRPAmount
|
|
||||||
calculateBaseFee(ReadView const& view, STTx const& tx);
|
|
||||||
|
|
||||||
static TER
|
static TER
|
||||||
preclaim(PreclaimContext const& ctx);
|
preclaim(PreclaimContext const& ctx);
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,35 @@ VaultDelete::doApply()
|
|||||||
return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
|
return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
|
||||||
|
|
||||||
// Destroy the pseudo-account.
|
// Destroy the pseudo-account.
|
||||||
view().erase(view().peek(keylet::account(pseudoID)));
|
auto vaultPseudoSLE = view().peek(keylet::account(pseudoID));
|
||||||
|
if (!vaultPseudoSLE || vaultPseudoSLE->at(~sfVaultID) != vault->key())
|
||||||
|
return tefBAD_LEDGER; // LCOV_EXCL_LINE
|
||||||
|
|
||||||
|
// Making the payment and removing the empty holding should have deleted any
|
||||||
|
// obligations associated with the vault or vault pseudo-account.
|
||||||
|
if (*vaultPseudoSLE->at(sfBalance))
|
||||||
|
{
|
||||||
|
// LCOV_EXCL_START
|
||||||
|
JLOG(j_.error()) << "VaultDelete: pseudo-account has a balance";
|
||||||
|
return tecHAS_OBLIGATIONS;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
if (vaultPseudoSLE->at(sfOwnerCount) != 0)
|
||||||
|
{
|
||||||
|
// LCOV_EXCL_START
|
||||||
|
JLOG(j_.error()) << "VaultDelete: pseudo-account still owns objects";
|
||||||
|
return tecHAS_OBLIGATIONS;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
if (view().exists(keylet::ownerDir(pseudoID)))
|
||||||
|
{
|
||||||
|
// LCOV_EXCL_START
|
||||||
|
JLOG(j_.error()) << "VaultDelete: pseudo-account has a directory";
|
||||||
|
return tecHAS_OBLIGATIONS;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
|
||||||
|
view().erase(vaultPseudoSLE);
|
||||||
|
|
||||||
// Remove the vault from its owner's directory.
|
// Remove the vault from its owner's directory.
|
||||||
auto const ownerID = vault->at(sfOwner);
|
auto const ownerID = vault->at(sfOwner);
|
||||||
@@ -170,7 +198,9 @@ VaultDelete::doApply()
|
|||||||
return tefBAD_LEDGER;
|
return tefBAD_LEDGER;
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
adjustOwnerCount(view(), owner, -1, j_);
|
|
||||||
|
// We are destroying Vault and PseudoAccount, hence decrease by 2
|
||||||
|
adjustOwnerCount(view(), owner, -2, j_);
|
||||||
|
|
||||||
// Destroy the vault.
|
// Destroy the vault.
|
||||||
view().erase(vault);
|
view().erase(vault);
|
||||||
|
|||||||
Reference in New Issue
Block a user