mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-03 08:46:46 +00:00
feat: Add --definitions flag and artifact (#6858)
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
This commit is contained in:
16
.github/workflows/reusable-build-test-config.yml
vendored
16
.github/workflows/reusable-build-test-config.yml
vendored
@@ -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 }}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
10
src/xrpld/rpc/handlers/server_info/ServerDefinitions.h
Normal file
10
src/xrpld/rpc/handlers/server_info/ServerDefinitions.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
Json::Value const&
|
||||
getServerDefinitionsJson();
|
||||
|
||||
} // namespace xrpl
|
||||
Reference in New Issue
Block a user