Merge branch 'develop' into ximinez/acquireAsyncDispatch

This commit is contained in:
Ed Hennis
2026-04-22 23:40:40 -04:00
committed by GitHub
7 changed files with 145 additions and 16 deletions

View File

@@ -210,6 +210,22 @@ jobs:
retention-days: 3
if-no-files-found: error
- name: Export server definitions
if: ${{ runner.os != 'Windows' && !inputs.build_only && env.VOIDSTAR_ENABLED != 'true' }}
working-directory: ${{ env.BUILD_DIR }}
run: |
set -o pipefail
./xrpld --definitions | python3 -m json.tool > server_definitions.json
- name: Upload server definitions
if: ${{ github.event.repository.visibility == 'public' && inputs.config_name == 'debian-bookworm-gcc-13-amd64-release' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: server-definitions
path: ${{ env.BUILD_DIR }}/server_definitions.json
retention-days: 3
if-no-files-found: error
- name: Check linking (Linux)
if: ${{ runner.os == 'Linux' && env.SANITIZERS_ENABLED == 'false' }}
working-directory: ${{ env.BUILD_DIR }}

View File

@@ -20,6 +20,22 @@ repos:
- id: check-merge-conflict
args: [--assume-in-merge]
- repo: local
hooks:
- id: clang-tidy
name: "clang-tidy (enable with: TIDY=1)"
entry: ./bin/pre-commit/clang_tidy_check.py
language: python
types_or: [c++, c]
exclude: ^include/xrpl/protocol_autogen
pass_filenames: false # script determines the staged files itself
- id: fix-include-style
name: fix include style
entry: ./bin/pre-commit/fix_include_style.py
language: python
types_or: [c++, c]
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: cd481d7b0bfb5c7b3090c21846317f9a8262e891 # frozen: v22.1.0
hooks:
@@ -67,14 +83,6 @@ repos:
- repo: local
hooks:
- id: clang-tidy
name: "clang-tidy (enable with: TIDY=1)"
entry: ./bin/pre-commit/clang_tidy_check.py
language: python
types_or: [c++, c]
exclude: ^include/xrpl/protocol_autogen
pass_filenames: false # script determines the staged files itself
- id: nix-fmt
name: Format Nix files
entry: |

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
"""
Converts quoted includes (#include "...") to angle-bracket includes
(#include <...>), which is the required style in this project.
Usage: ./bin/pre-commit/fix_include_style.py <file1> <file2> ...
"""
import re
import sys
from pathlib import Path
PATTERN = re.compile(r'^(\s*#include\s*)"([^"]+)"', re.MULTILINE)
def fix_includes(path: Path) -> bool:
original = path.read_text(encoding="utf-8")
fixed = PATTERN.sub(r"\1<\2>", original)
if fixed != original:
path.write_text(fixed, encoding="utf-8")
return False
return True
def main() -> int:
files = [Path(f) for f in sys.argv[1:]]
success = True
for path in files:
success &= fix_includes(path)
return 0 if success else 1
if __name__ == "__main__":
sys.exit(main())

View File

@@ -1,6 +1,7 @@
#include <test/jtx/Env.h>
#include <xrpld/rpc/handlers/server_info/ServerDefinitions.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/SOTemplate.h>
@@ -451,10 +452,40 @@ public:
}
}
void
testGetServerDefinitionsJson()
{
testcase("getServerDefinitionsJson");
auto const& defs = getServerDefinitionsJson();
for (auto const& field :
{jss::ACCOUNT_SET_FLAGS,
jss::FIELDS,
jss::LEDGER_ENTRY_FLAGS,
jss::LEDGER_ENTRY_FORMATS,
jss::LEDGER_ENTRY_TYPES,
jss::TRANSACTION_FLAGS,
jss::TRANSACTION_FORMATS,
jss::TRANSACTION_RESULTS,
jss::TRANSACTION_TYPES,
jss::TYPES,
jss::hash})
{
BEAST_EXPECT(defs.isMember(field));
}
// verify it returns the same hash as the RPC handler
using namespace test::jtx;
Env env(*this);
auto const rpcResult = env.rpc("server_definitions");
BEAST_EXPECT(defs[jss::hash] == rpcResult[jss::result][jss::hash]);
}
void
run() override
{
testServerDefinitions();
testGetServerDefinitionsJson();
}
};

View File

@@ -3,6 +3,7 @@
#include <xrpld/core/ConfigSections.h>
#include <xrpld/core/TimeKeeper.h>
#include <xrpld/rpc/RPCCall.h>
#include <xrpld/rpc/handlers/server_info/ServerDefinitions.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/SlabAllocator.h>
@@ -13,6 +14,7 @@
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/core/StartUpType.h>
#include <xrpl/git/Git.h>
#include <xrpl/json/json_writer.h>
#include <xrpl/protocol/BuildInfo.h>
#include <xrpl/protocol/SystemParameters.h>
#include <xrpl/server/Vacuum.h>
@@ -376,12 +378,12 @@ run(int argc, char** argv)
"nodeid", po::value<std::string>(), "Specify the node identity for this server.")(
"quorum", po::value<std::size_t>(), "Override the minimum validation quorum.")(
"silent", "No output to the console after startup.")("standalone,a", "Run with no peers.")(
"verbose,v", "Verbose logging.")
("force_ledger_present_range",
po::value<std::string>(),
"Specify the range of present ledgers for testing purposes. Min and "
"max values are comma separated.")("version", "Display the build version.");
"verbose,v", "Verbose logging.")(
"definitions", "Output server definitions as JSON and exit.")(
"force_ledger_present_range",
po::value<std::string>(),
"Specify the range of present ledgers for testing purposes. Min and "
"max values are comma separated.")("version", "Display the build version.");
po::options_description data("Ledger/Data Options");
data.add_options()("import", importText.c_str())(
@@ -503,10 +505,20 @@ run(int argc, char** argv)
if (vm.contains("version"))
{
// LCOV_EXCL_START
std::cout << "xrpld version " << BuildInfo::getVersionString() << std::endl;
std::cout << "Git commit hash: " << xrpl::git::getCommitHash() << std::endl;
std::cout << "Git build branch: " << xrpl::git::getBuildBranch() << std::endl;
return 0;
// LCOV_EXCL_STOP
}
if (vm.contains("definitions"))
{
// LCOV_EXCL_START
std::cout << Json::FastWriter().write(getServerDefinitionsJson());
return 0;
// LCOV_EXCL_STOP
}
#ifndef ENABLE_TESTS

View File

@@ -1,3 +1,5 @@
#include <xrpld/rpc/handlers/server_info/ServerDefinitions.h>
#include <xrpld/rpc/Context.h>
#include <xrpl/basics/base_uint.h>
@@ -369,8 +371,21 @@ ServerDefinitions::ServerDefinitions() : defs_{Json::objectValue}
}
}
ServerDefinitions const&
getDefinitions()
{
static ServerDefinitions const defs{};
return defs;
}
} // namespace detail
Json::Value const&
getServerDefinitionsJson()
{
return detail::getDefinitions().get();
}
Json::Value
doServerDefinitions(RPC::JsonContext& context)
{
@@ -383,7 +398,7 @@ doServerDefinitions(RPC::JsonContext& context)
return RPC::invalid_field_error(jss::hash);
}
static detail::ServerDefinitions const defs{};
auto const& defs = detail::getDefinitions();
if (defs.hashMatches(hash))
{
Json::Value jv = Json::objectValue;

View File

@@ -0,0 +1,10 @@
#pragma once
#include <xrpl/json/json_value.h>
namespace xrpl {
Json::Value const&
getServerDefinitionsJson();
} // namespace xrpl