mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-22 03:55:53 +00:00
Compare commits
79 Commits
pratik/use
...
ximinez/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dac87a1b8 | ||
|
|
fb74dc28e1 | ||
|
|
e4dccfd49b | ||
|
|
57f4b4eb7f | ||
|
|
7c933e06a0 | ||
|
|
d94722e4d0 | ||
|
|
059092d773 | ||
|
|
1cb0887436 | ||
|
|
b9e289df55 | ||
|
|
fff08cb2b1 | ||
|
|
d3842b3908 | ||
|
|
759bd4d199 | ||
|
|
4c88dfc384 | ||
|
|
f241378e6e | ||
|
|
c8ff090d8e | ||
|
|
945c362559 | ||
|
|
9546c52013 | ||
|
|
3a099aeb64 | ||
|
|
8567bd0d12 | ||
|
|
3cb1851537 | ||
|
|
55feea308e | ||
|
|
a6692af17a | ||
|
|
1d058a5d78 | ||
|
|
a70821adc5 | ||
|
|
bfeb60d3f5 | ||
|
|
c86bfa32f7 | ||
|
|
0f44d619b6 | ||
|
|
2add6a7917 | ||
|
|
d21c4f3218 | ||
|
|
265a504301 | ||
|
|
b1e576d3d1 | ||
|
|
d2d3039ce6 | ||
|
|
16e85a7b79 | ||
|
|
4ae1c01e13 | ||
|
|
8807afc074 | ||
|
|
a4e13e07d5 | ||
|
|
6067d59336 | ||
|
|
e14aecee66 | ||
|
|
0e4c3e3427 | ||
|
|
da5c563426 | ||
|
|
b9f5d8b1c5 | ||
|
|
5ea7b562a2 | ||
|
|
8450970b80 | ||
|
|
14d4cff530 | ||
|
|
88ac659d86 | ||
|
|
43fdbf27b9 | ||
|
|
1e33f8e868 | ||
|
|
a6e30857df | ||
|
|
563f24edb0 | ||
|
|
a89f6d5da2 | ||
|
|
5b2e91986a | ||
|
|
fbc5056817 | ||
|
|
b7cafed040 | ||
|
|
b6ebd34b30 | ||
|
|
74c2765159 | ||
|
|
62c7fdadba | ||
|
|
372c66e684 | ||
|
|
a2fab5bcaf | ||
|
|
2e4f41571c | ||
|
|
8799a6dbfd | ||
|
|
e655087027 | ||
|
|
46bd2a4090 | ||
|
|
f3b8a8aef3 | ||
|
|
ee0c917e95 | ||
|
|
375aedd340 | ||
|
|
95397a7710 | ||
|
|
7af8a52d27 | ||
|
|
326a8093c9 | ||
|
|
9f0e159205 | ||
|
|
2fda101b44 | ||
|
|
e6e1e4f9dd | ||
|
|
70591265e5 | ||
|
|
ed1d477a45 | ||
|
|
cd58f636d3 | ||
|
|
3152f2233f | ||
|
|
0c147a895c | ||
|
|
cf80710ef1 | ||
|
|
fc929ab984 | ||
|
|
145a8817dc |
3
.github/scripts/rename/copyright.sh
vendored
3
.github/scripts/rename/copyright.sh
vendored
@@ -70,9 +70,6 @@ fi
|
||||
if ! grep -q 'Dev Null' src/test/app/tx/apply_test.cpp; then
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/app/tx/apply_test.cpp)" > src/test/app/tx/apply_test.cpp
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/test/app/NetworkOPs_test.cpp; then
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/app/NetworkOPs_test.cpp)" > src/test/app/NetworkOPs_test.cpp
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/test/rpc/ManifestRPC_test.cpp; then
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/rpc/ManifestRPC_test.cpp)" > src/test/rpc/ManifestRPC_test.cpp
|
||||
fi
|
||||
|
||||
110
.github/scripts/strategy-matrix/generate.py
vendored
110
.github/scripts/strategy-matrix/generate.py
vendored
@@ -156,107 +156,15 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
||||
# Add the configuration to the list, with the most unique fields first,
|
||||
# so that they are easier to identify in the GitHub Actions UI, as long
|
||||
# names get truncated.
|
||||
# Add Address and Thread (both coupled with UB) sanitizers when the distro is bookworm.
|
||||
if os['distro_version'] == 'bookworm' and f'{os["compiler_name"]}-{os["compiler_version"]}' in {'gcc-15', 'clang-20'}:
|
||||
extra_warning_flags = ''
|
||||
linker_relocation_flags = ''
|
||||
linker_flags = ''
|
||||
cxx_flags += ' -DBOOST_USE_TSAN -DBOOST_USE_UBSAN -DBOOST_USE_UCONTEXT'
|
||||
|
||||
# Use large code model to avoid relocation errors with large binaries
|
||||
# Only for x86-64 (amd64) - ARM64 doesn't support -mcmodel=large
|
||||
if architecture['platform'] == 'linux/amd64' and os['compiler_name'] == 'gcc':
|
||||
# Add -mcmodel=large and -fPIC to both compiler AND linker flags
|
||||
# This is needed because sanitizers create very large binaries
|
||||
# -fPIC enables position independent code to avoid relocation range issues
|
||||
# large model removes the 2GB limitation that medium model has
|
||||
cxx_flags += ' -mcmodel=large -fno-PIC'
|
||||
linker_relocation_flags+=' -mcmodel=large -fno-PIC'
|
||||
|
||||
# Create default sanitizer flags
|
||||
sanitizers_flags = 'undefined,float-divide-by-zero'
|
||||
|
||||
if os['compiler_name'] == 'gcc':
|
||||
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow'
|
||||
# Suppress false positive warnings in GCC with stringop-overflow
|
||||
extra_warning_flags += ' -Wno-stringop-overflow'
|
||||
# Disable mold, gold and lld linkers.
|
||||
# Use default linker (bfd/ld) which is more lenient with mixed code models
|
||||
cmake_args += ' -Duse_mold=OFF -Duse_gold=OFF -Duse_lld=OFF'
|
||||
# Add linker flags for Sanitizers
|
||||
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=address,{sanitizers_flags}"'
|
||||
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=address,{sanitizers_flags}"'
|
||||
elif os['compiler_name'] == 'clang':
|
||||
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow,unsigned-integer-overflow'
|
||||
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,{sanitizers_flags}"'
|
||||
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address,{sanitizers_flags}"'
|
||||
|
||||
# Sanitizers recommend minimum of -O1 for reasonable performance
|
||||
if "-O0" in cxx_flags:
|
||||
cxx_flags = cxx_flags.replace("-O0", "-O1")
|
||||
else:
|
||||
cxx_flags += " -O1"
|
||||
|
||||
# First create config for asan
|
||||
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=address,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}" {linker_flags}'
|
||||
|
||||
# Add config with asan
|
||||
configurations.append({
|
||||
'config_name': config_name + "_asan",
|
||||
'cmake_args': cmake_args_flags,
|
||||
'cmake_target': cmake_target,
|
||||
'build_only': build_only,
|
||||
'build_type': build_type,
|
||||
'os': os,
|
||||
'architecture': architecture,
|
||||
'sanitizers': 'Address'
|
||||
})
|
||||
|
||||
linker_flags = ''
|
||||
# Update configs for tsan
|
||||
# gcc doesn't supports atomic_thread_fence with tsan. Suppress warnings.
|
||||
# Also tsan doesn't work well with mcmode=large and bfd linker
|
||||
if os['compiler_name'] == 'gcc':
|
||||
extra_warning_flags += ' -Wno-tsan'
|
||||
cxx_flags = cxx_flags.replace('-mcmodel=large', '-mcmodel=medium')
|
||||
linker_relocation_flags = linker_relocation_flags.replace('-mcmodel=large', '-mcmodel=medium')
|
||||
# Add linker flags for Sanitizers
|
||||
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=thread,{sanitizers_flags}"'
|
||||
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=thread,{sanitizers_flags}"'
|
||||
elif os['compiler_name'] == 'clang':
|
||||
cxx_flags += ' -fsanitize-blacklist=$GITHUB_WORKSPACE/external/sanitizer-blacklist.txt'
|
||||
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread,{sanitizers_flags}"'
|
||||
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=thread,{sanitizers_flags}"'
|
||||
|
||||
# Note: We use $GITHUB_WORKSPACE environment variable which will be expanded by the shell
|
||||
# before CMake processes it. This ensures the compiler receives an absolute path.
|
||||
# CMAKE_SOURCE_DIR won't work here because it's inside CMAKE_CXX_FLAGS string.
|
||||
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=thread,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}" {linker_flags}'
|
||||
|
||||
configurations.append({
|
||||
'config_name': config_name+ "_tsan",
|
||||
'cmake_args': cmake_args_flags,
|
||||
'cmake_target': cmake_target,
|
||||
'build_only': build_only,
|
||||
'build_type': build_type,
|
||||
'os': os,
|
||||
'architecture': architecture,
|
||||
'sanitizers': 'Thread'
|
||||
})
|
||||
else:
|
||||
if cxx_flags:
|
||||
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS={cxx_flags}'
|
||||
else:
|
||||
cmake_args_flags = f'{cmake_args}'
|
||||
configurations.append({
|
||||
'config_name': config_name,
|
||||
'cmake_args': cmake_args_flags,
|
||||
'cmake_target': cmake_target,
|
||||
'build_only': build_only,
|
||||
'build_type': build_type,
|
||||
'os': os,
|
||||
'architecture': architecture
|
||||
})
|
||||
configurations.append({
|
||||
'config_name': config_name,
|
||||
'cmake_args': cmake_args,
|
||||
'cmake_target': cmake_target,
|
||||
'build_only': build_only,
|
||||
'build_type': build_type,
|
||||
'os': os,
|
||||
'architecture': architecture,
|
||||
})
|
||||
|
||||
return configurations
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ find_dependency (Boost
|
||||
chrono
|
||||
container
|
||||
context
|
||||
coroutine2
|
||||
coroutine
|
||||
date_time
|
||||
filesystem
|
||||
program_options
|
||||
|
||||
@@ -2,7 +2,7 @@ find_package(Boost 1.82 REQUIRED
|
||||
COMPONENTS
|
||||
chrono
|
||||
container
|
||||
context
|
||||
coroutine
|
||||
date_time
|
||||
filesystem
|
||||
json
|
||||
@@ -20,7 +20,7 @@ target_link_libraries(xrpl_boost
|
||||
Boost::headers
|
||||
Boost::chrono
|
||||
Boost::container
|
||||
Boost::context
|
||||
Boost::coroutine
|
||||
Boost::date_time
|
||||
Boost::filesystem
|
||||
Boost::json
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
include(sanitizers)
|
||||
@@ -1,69 +0,0 @@
|
||||
include(default)
|
||||
{% set compiler, version, compiler_exe = detect_api.detect_default_compiler() %}
|
||||
{% set default_sanitizer_flags = "undefined,float-divide-by-zero,signed-integer-overflow" %}
|
||||
{% set sanitizers = os.getenv("SANITIZERS") %}
|
||||
|
||||
[settings]
|
||||
|
||||
[conf]
|
||||
|
||||
{% if sanitizers == "Address" or sanitizers == "Thread" %}
|
||||
user.package:sanitizers={{ sanitizers }}
|
||||
tools.info.package_id:confs+=["user.package:sanitizers"]
|
||||
{% endif %}
|
||||
|
||||
{% if compiler == "gcc" %}
|
||||
|
||||
{% set asan_sanitizer_flags = "-fsanitize=address,"~default_sanitizer_flags~" -mcmodel=large -fno-PIC" %}
|
||||
{% set tsan_sanitizer_flags = "-fsanitize=thread,"~default_sanitizer_flags~" -mcmodel=medium -fno-PIC" %}
|
||||
|
||||
{% if sanitizers == "Address" %}
|
||||
tools.build:cxxflags+=['{{asan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -Wno-stringop-overflow -DBOOST_USE_ASAN -DBOOST_USE_UBSAN -DBOOST_USE_UCONTEXT']
|
||||
tools.build:sharedlinkflags+=['{{asan_sanitizer_flags}}']
|
||||
tools.build:exelinkflags+=['{{asan_sanitizer_flags}}']
|
||||
tools.cmake.cmaketoolchain:extra_variables={"use_mold": "OFF", "use_gold": "OFF", "use_lld": "OFF"}
|
||||
tools.build:defines+=["BOOST_USE_ASAN", "BOOST_USE_UBSAN", "BOOST_USE_UCONTEXT"]
|
||||
|
||||
{% elif sanitizers == "Thread" %}
|
||||
tools.build:cxxflags+=['{{tsan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -Wno-stringop-overflow -Wno-tsan -DBOOST_USE_TSAN -DBOOST_USE_UBSAN -DBOOST_USE_UCONTEXT']
|
||||
tools.build:sharedlinkflags+=['{{tsan_sanitizer_flags}}']
|
||||
tools.build:exelinkflags+=['{{tsan_sanitizer_flags}}']
|
||||
tools.build:defines+=["BOOST_USE_TSAN", "BOOST_USE_UBSAN", "BOOST_USE_UCONTEXT"]
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% elif compiler == "apple-clang" or compiler == "clang" %}
|
||||
|
||||
{% set asan_sanitizer_flags = "-fsanitize=address,"~default_sanitizer_flags~",unsigned-integer-overflow" %}
|
||||
{% set tsan_sanitizer_flags = "-fsanitize=thread,"~default_sanitizer_flags~",unsigned-integer-overflow" %}
|
||||
{% if sanitizers == "Address" %}
|
||||
tools.build:cxxflags+=['{{asan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -DBOOST_USE_ASAN -DBOOST_USE_UBSAN -DBOOST_USE_UCONTEXT']
|
||||
tools.build:sharedlinkflags+=['{{asan_sanitizer_flags}}']
|
||||
tools.build:exelinkflags+=['{{asan_sanitizer_flags}}']
|
||||
tools.build:defines+=["BOOST_USE_ASAN", "BOOST_USE_UBSAN", "BOOST_USE_UCONTEXT"]
|
||||
|
||||
{% elif sanitizers == "Thread" %}
|
||||
tools.build:cxxflags+=['{{tsan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -DBOOST_USE_TSAN -DBOOST_USE_UBSAN -DBOOST_USE_UCONTEXT']
|
||||
tools.build:sharedlinkflags+=['{{tsan_sanitizer_flags}}']
|
||||
tools.build:exelinkflags+=['{{tsan_sanitizer_flags}}']
|
||||
tools.build:defines+=["BOOST_USE_TSAN", "BOOST_USE_UBSAN", "BOOST_USE_UCONTEXT"]
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
[options]
|
||||
{% if compiler == "gcc" or compiler == "apple-clang" or compiler == "clang" %}
|
||||
{% if sanitizers == "Address" or sanitizers == "Thread" %}
|
||||
boost/*:without_context=False
|
||||
boost/*:without_stacktrace=True
|
||||
boost/*:without_coroutine2=False
|
||||
|
||||
{% if sanitizers == "Address" %}
|
||||
boost/*:extra_b2_flags="context-impl=ucontext address-sanitizer=norecover undefined-sanitizer=norecover --with-coroutine2"
|
||||
{% elif sanitizers == "Thread" %}
|
||||
boost/*:extra_b2_flags="context-impl=ucontext thread-sanitizer=norecover undefined-sanitizer=norecover --with-coroutine2"
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -102,7 +102,6 @@ class Xrpl(ConanFile):
|
||||
self.options['boost'].visibility = 'global'
|
||||
if self.settings.compiler in ['clang', 'gcc']:
|
||||
self.options['boost'].without_cobalt = True
|
||||
self.options['boost'].without_coroutine2 = False
|
||||
|
||||
def requirements(self):
|
||||
# Conan 2 requires transitive headers to be specified
|
||||
@@ -173,8 +172,7 @@ class Xrpl(ConanFile):
|
||||
'boost::headers',
|
||||
'boost::chrono',
|
||||
'boost::container',
|
||||
'boost::context',
|
||||
'boost::coroutine2',
|
||||
'boost::coroutine',
|
||||
'boost::date_time',
|
||||
'boost::filesystem',
|
||||
'boost::json',
|
||||
|
||||
@@ -63,12 +63,10 @@ XRPL_FEATURE(AMM, Supported::yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(Clawback, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DisallowIncoming, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(Checks, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
|
||||
|
||||
// The following amendments are obsolete, but must remain supported
|
||||
@@ -116,10 +114,12 @@ XRPL_RETIRE_FIX(STAmountCanonicalize)
|
||||
XRPL_RETIRE_FIX(TakerDryOfferRemoval)
|
||||
XRPL_RETIRE_FIX(TrustLinesToSelf)
|
||||
|
||||
XRPL_RETIRE_FEATURE(Checks)
|
||||
XRPL_RETIRE_FEATURE(CheckCashMakesTrustLine)
|
||||
XRPL_RETIRE_FEATURE(CryptoConditions)
|
||||
XRPL_RETIRE_FEATURE(DepositAuth)
|
||||
XRPL_RETIRE_FEATURE(DepositPreauth)
|
||||
XRPL_RETIRE_FEATURE(DisallowIncoming)
|
||||
XRPL_RETIRE_FEATURE(Escrow)
|
||||
XRPL_RETIRE_FEATURE(EnforceInvariants)
|
||||
XRPL_RETIRE_FEATURE(ExpandedSignerList)
|
||||
|
||||
@@ -226,7 +226,7 @@ TRANSACTION(ttPAYCHAN_CLAIM, 15, PaymentChannelClaim,
|
||||
#endif
|
||||
TRANSACTION(ttCHECK_CREATE, 16, CheckCreate,
|
||||
Delegation::delegatable,
|
||||
featureChecks,
|
||||
uint256{},
|
||||
noPriv,
|
||||
({
|
||||
{sfDestination, soeREQUIRED},
|
||||
@@ -242,7 +242,7 @@ TRANSACTION(ttCHECK_CREATE, 16, CheckCreate,
|
||||
#endif
|
||||
TRANSACTION(ttCHECK_CASH, 17, CheckCash,
|
||||
Delegation::delegatable,
|
||||
featureChecks,
|
||||
uint256{},
|
||||
noPriv,
|
||||
({
|
||||
{sfCheckID, soeREQUIRED},
|
||||
@@ -256,7 +256,7 @@ TRANSACTION(ttCHECK_CASH, 17, CheckCash,
|
||||
#endif
|
||||
TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel,
|
||||
Delegation::delegatable,
|
||||
featureChecks,
|
||||
uint256{},
|
||||
noPriv,
|
||||
({
|
||||
{sfCheckID, soeREQUIRED},
|
||||
|
||||
@@ -67,8 +67,6 @@ public:
|
||||
|
||||
class Check_test : public beast::unit_test::suite
|
||||
{
|
||||
FeatureBitset const disallowIncoming{featureDisallowIncoming};
|
||||
|
||||
static uint256
|
||||
getCheckIndex(AccountID const& account, std::uint32_t uSequence)
|
||||
{
|
||||
@@ -125,25 +123,6 @@ class Check_test : public beast::unit_test::suite
|
||||
|
||||
using namespace test::jtx;
|
||||
Account const alice{"alice"};
|
||||
{
|
||||
// If the Checks amendment is not enabled, you should not be able
|
||||
// to create, cash, or cancel checks.
|
||||
Env env{*this, features - featureChecks};
|
||||
|
||||
env.fund(XRP(1000), alice);
|
||||
env.close();
|
||||
|
||||
uint256 const checkId{
|
||||
getCheckIndex(env.master, env.seq(env.master))};
|
||||
env(check::create(env.master, alice, XRP(100)), ter(temDISABLED));
|
||||
env.close();
|
||||
|
||||
env(check::cash(alice, checkId, XRP(100)), ter(temDISABLED));
|
||||
env.close();
|
||||
|
||||
env(check::cancel(alice, checkId), ter(temDISABLED));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// If the Checks amendment is enabled all check-related
|
||||
// facilities should be available.
|
||||
@@ -277,24 +256,12 @@ class Check_test : public beast::unit_test::suite
|
||||
|
||||
using namespace test::jtx;
|
||||
|
||||
// test flag doesn't set unless amendment enabled
|
||||
{
|
||||
Env env{*this, features - disallowIncoming};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
env(fset(alice, asfDisallowIncomingCheck));
|
||||
env.close();
|
||||
auto const sle = env.le(alice);
|
||||
uint32_t flags = sle->getFlags();
|
||||
BEAST_EXPECT(!(flags & lsfDisallowIncomingCheck));
|
||||
}
|
||||
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
IOU const USD{gw["USD"]};
|
||||
|
||||
Env env{*this, features | disallowIncoming};
|
||||
Env env{*this, features};
|
||||
|
||||
STAmount const startBalance{XRP(1000).value()};
|
||||
env.fund(startBalance, gw, alice, bob);
|
||||
@@ -2613,7 +2580,6 @@ public:
|
||||
{
|
||||
using namespace test::jtx;
|
||||
auto const sa = testable_amendments();
|
||||
testWithFeats(sa - disallowIncoming);
|
||||
testWithFeats(sa);
|
||||
testTrustLineCreation(sa);
|
||||
}
|
||||
|
||||
@@ -1703,9 +1703,6 @@ class Delegate_test : public beast::unit_test::suite
|
||||
// NFTokenMint, NFTokenBurn, NFTokenCreateOffer, NFTokenCancelOffer,
|
||||
// NFTokenAcceptOffer are not included, they are tested separately.
|
||||
std::unordered_map<std::string, uint256> txRequiredFeatures{
|
||||
{"CheckCreate", featureChecks},
|
||||
{"CheckCash", featureChecks},
|
||||
{"CheckCancel", featureChecks},
|
||||
{"Clawback", featureClawback},
|
||||
{"AMMClawback", featureAMMClawback},
|
||||
{"AMMCreate", featureAMM},
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace ripple {
|
||||
|
||||
class NFTokenBaseUtil_test : public beast::unit_test::suite
|
||||
{
|
||||
FeatureBitset const disallowIncoming{featureDisallowIncoming};
|
||||
|
||||
// Helper function that returns the number of NFTs minted by an issuer.
|
||||
static std::uint32_t
|
||||
mintedCount(test::jtx::Env const& env, test::jtx::Account const& issuer)
|
||||
@@ -2960,19 +2958,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite
|
||||
|
||||
using namespace test::jtx;
|
||||
|
||||
// test flag doesn't set unless amendment enabled
|
||||
{
|
||||
Env env{*this, features - disallowIncoming};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
env(fset(alice, asfDisallowIncomingNFTokenOffer));
|
||||
env.close();
|
||||
auto const sle = env.le(alice);
|
||||
uint32_t flags = sle->getFlags();
|
||||
BEAST_EXPECT(!(flags & lsfDisallowIncomingNFTokenOffer));
|
||||
}
|
||||
|
||||
Env env{*this, features | disallowIncoming};
|
||||
Env env{*this, features};
|
||||
|
||||
Account const issuer{"issuer"};
|
||||
Account const minter{"minter"};
|
||||
@@ -7624,8 +7610,8 @@ class NFTokenDisallowIncoming_test : public NFTokenBaseUtil_test
|
||||
run() override
|
||||
{
|
||||
testWithFeats(
|
||||
allFeatures - featureDisallowIncoming - fixNFTokenReserve -
|
||||
featureNFTokenMintOffer - featureDynamicNFT);
|
||||
allFeatures - fixNFTokenReserve - featureNFTokenMintOffer -
|
||||
featureDynamicNFT);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// Copyright (c) 2020 Dev Null Productions
|
||||
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/CaptureLogs.h>
|
||||
#include <test/jtx/Env.h>
|
||||
|
||||
@@ -14,8 +14,6 @@ using namespace jtx::paychan;
|
||||
|
||||
struct PayChan_test : public beast::unit_test::suite
|
||||
{
|
||||
FeatureBitset const disallowIncoming{featureDisallowIncoming};
|
||||
|
||||
static std::pair<uint256, std::shared_ptr<SLE const>>
|
||||
channelKeyAndSle(
|
||||
ReadView const& view,
|
||||
@@ -242,20 +240,8 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase("Disallow Incoming Flag");
|
||||
using namespace jtx;
|
||||
|
||||
// test flag doesn't set unless amendment enabled
|
||||
{
|
||||
Env env{*this, features - disallowIncoming};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
env(fset(alice, asfDisallowIncomingPayChan));
|
||||
env.close();
|
||||
auto const sle = env.le(alice);
|
||||
uint32_t flags = sle->getFlags();
|
||||
BEAST_EXPECT(!(flags & lsfDisallowIncomingPayChan));
|
||||
}
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env{*this, features | disallowIncoming};
|
||||
Env env{*this, features};
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
auto const cho = Account("cho");
|
||||
@@ -2127,7 +2113,6 @@ public:
|
||||
{
|
||||
using namespace test::jtx;
|
||||
FeatureBitset const all{testable_amendments()};
|
||||
testWithFeats(all - disallowIncoming);
|
||||
testWithFeats(all);
|
||||
testDepositAuthCreds();
|
||||
testMetaAndOwnership(all - fixIncludeKeyletFields);
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace test {
|
||||
|
||||
class SetTrust_test : public beast::unit_test::suite
|
||||
{
|
||||
FeatureBitset const disallowIncoming{featureDisallowIncoming};
|
||||
|
||||
public:
|
||||
void
|
||||
testTrustLineDelete()
|
||||
@@ -478,25 +476,12 @@ public:
|
||||
|
||||
using namespace test::jtx;
|
||||
|
||||
// test flag doesn't set unless amendment enabled
|
||||
{
|
||||
Env env{*this, features - disallowIncoming};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
env(fset(alice, asfDisallowIncomingTrustline));
|
||||
env.close();
|
||||
auto const sle = env.le(alice);
|
||||
uint32_t flags = sle->getFlags();
|
||||
BEAST_EXPECT(!(flags & lsfDisallowIncomingTrustline));
|
||||
}
|
||||
|
||||
// fixDisallowIncomingV1
|
||||
{
|
||||
for (bool const withFix : {true, false})
|
||||
{
|
||||
auto const amend = withFix
|
||||
? features | disallowIncoming
|
||||
: (features | disallowIncoming) - fixDisallowIncomingV1;
|
||||
auto const amend =
|
||||
withFix ? features : features - fixDisallowIncomingV1;
|
||||
|
||||
Env env{*this, amend};
|
||||
auto const dist = Account("dist");
|
||||
@@ -532,7 +517,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
Env env{*this, features | disallowIncoming};
|
||||
Env env{*this, features};
|
||||
|
||||
auto const gw = Account{"gateway"};
|
||||
auto const alice = Account{"alice"};
|
||||
@@ -630,7 +615,6 @@ public:
|
||||
{
|
||||
using namespace test::jtx;
|
||||
auto const sa = testable_amendments();
|
||||
testWithFeats(sa - disallowIncoming);
|
||||
testWithFeats(sa);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -615,33 +615,23 @@ public:
|
||||
{"disallowIncomingTrustline",
|
||||
asfDisallowIncomingTrustline}}};
|
||||
|
||||
if (features[featureDisallowIncoming])
|
||||
for (auto& asf : disallowIncomingFlags)
|
||||
{
|
||||
for (auto& asf : disallowIncomingFlags)
|
||||
{
|
||||
// Clear a flag and check that account_info returns results
|
||||
// as expected
|
||||
env(fclear(alice, asf.second));
|
||||
env.close();
|
||||
auto const f1 = getAccountFlag(asf.first, alice);
|
||||
BEAST_EXPECT(f1.has_value());
|
||||
BEAST_EXPECT(!f1.value());
|
||||
// Clear a flag and check that account_info returns results
|
||||
// as expected
|
||||
env(fclear(alice, asf.second));
|
||||
env.close();
|
||||
auto const f1 = getAccountFlag(asf.first, alice);
|
||||
BEAST_EXPECT(f1.has_value());
|
||||
BEAST_EXPECT(!f1.value());
|
||||
|
||||
// Set a flag and check that account_info returns results
|
||||
// as expected
|
||||
env(fset(alice, asf.second));
|
||||
env.close();
|
||||
auto const f2 = getAccountFlag(asf.first, alice);
|
||||
BEAST_EXPECT(f2.has_value());
|
||||
BEAST_EXPECT(f2.value());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& asf : disallowIncomingFlags)
|
||||
{
|
||||
BEAST_EXPECT(!getAccountFlag(asf.first, alice));
|
||||
}
|
||||
// Set a flag and check that account_info returns results
|
||||
// as expected
|
||||
env(fset(alice, asf.second));
|
||||
env.close();
|
||||
auto const f2 = getAccountFlag(asf.first, alice);
|
||||
BEAST_EXPECT(f2.has_value());
|
||||
BEAST_EXPECT(f2.value());
|
||||
}
|
||||
|
||||
static constexpr std::pair<std::string_view, std::uint32_t>
|
||||
@@ -706,12 +696,8 @@ public:
|
||||
FeatureBitset const allFeatures{
|
||||
ripple::test::jtx::testable_amendments()};
|
||||
testAccountFlags(allFeatures);
|
||||
testAccountFlags(allFeatures - featureDisallowIncoming);
|
||||
testAccountFlags(
|
||||
allFeatures - featureDisallowIncoming - featureClawback);
|
||||
testAccountFlags(
|
||||
allFeatures - featureDisallowIncoming - featureClawback -
|
||||
featureTokenEscrow);
|
||||
testAccountFlags(allFeatures - featureClawback);
|
||||
testAccountFlags(allFeatures - featureClawback - featureTokenEscrow);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <test/jtx/multisign.h>
|
||||
#include <test/jtx/xchain_bridge.h>
|
||||
|
||||
#include <xrpld/app/tx/apply.h>
|
||||
|
||||
#include <xrpl/beast/unit_test.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
@@ -2008,6 +2010,370 @@ class LedgerEntry_test : public beast::unit_test::suite
|
||||
}
|
||||
}
|
||||
|
||||
/// Test the ledger entry types that don't take parameters
|
||||
void
|
||||
testLedgerEntryFixed()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
|
||||
Env env{*this, envconfig([](auto cfg) {
|
||||
cfg->START_UP = Config::FRESH;
|
||||
return cfg;
|
||||
})};
|
||||
|
||||
env.close();
|
||||
|
||||
/** Verifies that the RPC result has the expected data
|
||||
*
|
||||
* @param good: Indicates that the request should have succeeded
|
||||
* and returned a ledger object of `expectedType` type.
|
||||
* @param jv: The RPC result Json value
|
||||
* @param expectedType: The type that the ledger object should
|
||||
* have if "good".
|
||||
* @param expectedError: Optional. The expected error if not
|
||||
* good. Defaults to "entryNotFound".
|
||||
*/
|
||||
auto checkResult =
|
||||
[&](bool good,
|
||||
Json::Value const& jv,
|
||||
Json::StaticString const& expectedType,
|
||||
std::optional<std::string> const& expectedError = {}) {
|
||||
if (good)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
!jv[jss::result].isMember(jss::error) &&
|
||||
jv[jss::result].isMember(jss::node) &&
|
||||
jv[jss::result][jss::node].isMember(
|
||||
sfLedgerEntryType.jsonName) &&
|
||||
jv[jss::result][jss::node]
|
||||
[sfLedgerEntryType.jsonName] == expectedType,
|
||||
to_string(jv));
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
jv[jss::result].isMember(jss::error) &&
|
||||
!jv[jss::result].isMember(jss::node) &&
|
||||
jv[jss::result][jss::error] ==
|
||||
expectedError.value_or("entryNotFound"),
|
||||
to_string(jv));
|
||||
}
|
||||
};
|
||||
|
||||
/** Runs a series of tests for a given fixed-position ledger
|
||||
* entry.
|
||||
*
|
||||
* @param field: The Json request field to use.
|
||||
* @param expectedType: The type that the ledger object should
|
||||
* have if "good".
|
||||
* @param expectedKey: The keylet of the fixed object.
|
||||
* @param good: Indicates whether the object is expected to
|
||||
* exist.
|
||||
*/
|
||||
auto test = [&](Json::StaticString const& field,
|
||||
Json::StaticString const& expectedType,
|
||||
Keylet const& expectedKey,
|
||||
bool good) {
|
||||
testcase << "ledger_entry " << expectedType.c_str()
|
||||
<< (good ? "" : " not") << " found";
|
||||
|
||||
auto const hexKey = strHex(expectedKey.key);
|
||||
|
||||
// Test bad values
|
||||
// "field":null
|
||||
Json::Value params;
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = Json::nullValue;
|
||||
auto jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "malformedRequest");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// "field":"string"
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = "arbitrary string";
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "malformedRequest");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// "field":false
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = false;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "invalidParams");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
{
|
||||
// "field":[incorrect index hash]
|
||||
auto const badKey = strHex(expectedKey.key + uint256{1});
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = badKey;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "entryNotFound");
|
||||
BEAST_EXPECTS(
|
||||
jv[jss::result][jss::index] == badKey, to_string(jv));
|
||||
}
|
||||
|
||||
// "index":"field" using API 2
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::index] = field;
|
||||
params[jss::api_version] = 2;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "malformedRequest");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// Test good values
|
||||
// Use the "field":true notation
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = true;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
// Index will always be returned for valid parameters.
|
||||
std::string const pdIdx = jv[jss::result][jss::index].asString();
|
||||
BEAST_EXPECTS(hexKey == pdIdx, to_string(jv));
|
||||
checkResult(good, jv, expectedType);
|
||||
|
||||
// "field":"[index hash]"
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = hexKey;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(good, jv, expectedType);
|
||||
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
||||
|
||||
// Use the "index":"field" notation with API 3
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::index] = field;
|
||||
params[jss::api_version] = 3;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
// Index is correct either way
|
||||
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
||||
checkResult(good, jv, expectedType);
|
||||
|
||||
// Use the "index":"[index hash]" notation
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::index] = pdIdx;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
// Index is correct either way
|
||||
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
|
||||
checkResult(good, jv, expectedType);
|
||||
};
|
||||
|
||||
test(jss::amendments, jss::Amendments, keylet::amendments(), true);
|
||||
test(jss::fee, jss::FeeSettings, keylet::fees(), true);
|
||||
// There won't be an nunl
|
||||
test(jss::nunl, jss::NegativeUNL, keylet::negativeUNL(), false);
|
||||
// Can only get the short skip list this way
|
||||
test(jss::hashes, jss::LedgerHashes, keylet::skip(), true);
|
||||
}
|
||||
|
||||
void
|
||||
testLedgerEntryHashes()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
|
||||
Env env{*this, envconfig([](auto cfg) {
|
||||
cfg->START_UP = Config::FRESH;
|
||||
return cfg;
|
||||
})};
|
||||
|
||||
env.close();
|
||||
|
||||
/** Verifies that the RPC result has the expected data
|
||||
*
|
||||
* @param good: Indicates that the request should have succeeded
|
||||
* and returned a ledger object of `expectedType` type.
|
||||
* @param jv: The RPC result Json value
|
||||
* @param expectedCount: The number of Hashes expected in the
|
||||
* object if "good".
|
||||
* @param expectedError: Optional. The expected error if not
|
||||
* good. Defaults to "entryNotFound".
|
||||
*/
|
||||
auto checkResult =
|
||||
[&](bool good,
|
||||
Json::Value const& jv,
|
||||
int expectedCount,
|
||||
std::optional<std::string> const& expectedError = {}) {
|
||||
if (good)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
!jv[jss::result].isMember(jss::error) &&
|
||||
jv[jss::result].isMember(jss::node) &&
|
||||
jv[jss::result][jss::node].isMember(
|
||||
sfLedgerEntryType.jsonName) &&
|
||||
jv[jss::result][jss::node]
|
||||
[sfLedgerEntryType.jsonName] == jss::LedgerHashes,
|
||||
to_string(jv));
|
||||
BEAST_EXPECTS(
|
||||
jv[jss::result].isMember(jss::node) &&
|
||||
jv[jss::result][jss::node].isMember("Hashes") &&
|
||||
jv[jss::result][jss::node]["Hashes"].size() ==
|
||||
expectedCount,
|
||||
to_string(jv[jss::result][jss::node]["Hashes"].size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
jv[jss::result].isMember(jss::error) &&
|
||||
!jv[jss::result].isMember(jss::node) &&
|
||||
jv[jss::result][jss::error] ==
|
||||
expectedError.value_or("entryNotFound"),
|
||||
to_string(jv));
|
||||
}
|
||||
};
|
||||
|
||||
/** Runs a series of tests for a given ledger index.
|
||||
*
|
||||
* @param ledger: The ledger index value of the "hashes" request
|
||||
* parameter. May not necessarily be a number.
|
||||
* @param expectedKey: The expected keylet of the object.
|
||||
* @param good: Indicates whether the object is expected to
|
||||
* exist.
|
||||
* @param expectedCount: The number of Hashes expected in the
|
||||
* object if "good".
|
||||
*/
|
||||
auto test = [&](Json::Value ledger,
|
||||
Keylet const& expectedKey,
|
||||
bool good,
|
||||
int expectedCount = 0) {
|
||||
testcase << "ledger_entry LedgerHashes: seq: "
|
||||
<< env.current()->info().seq
|
||||
<< " \"hashes\":" << to_string(ledger)
|
||||
<< (good ? "" : " not") << " found";
|
||||
|
||||
auto const hexKey = strHex(expectedKey.key);
|
||||
|
||||
// Test bad values
|
||||
// "hashes":null
|
||||
Json::Value params;
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = Json::nullValue;
|
||||
auto jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "malformedRequest");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// "hashes":"non-uint string"
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = "arbitrary string";
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "malformedRequest");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// "hashes":"uint string" is invalid, too
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = "10";
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "malformedRequest");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// "hashes":false
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = false;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "invalidParams");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// "hashes":-1
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = -1;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "internal");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
|
||||
// "hashes":[incorrect index hash]
|
||||
{
|
||||
auto const badKey = strHex(expectedKey.key + uint256{1});
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = badKey;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "entryNotFound");
|
||||
BEAST_EXPECT(jv[jss::result][jss::index] == badKey);
|
||||
}
|
||||
|
||||
// Test good values
|
||||
// Use the "hashes":ledger notation
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = ledger;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(good, jv, expectedCount);
|
||||
// Index will always be returned for valid parameters.
|
||||
std::string const pdIdx = jv[jss::result][jss::index].asString();
|
||||
BEAST_EXPECTS(hexKey == pdIdx, strHex(pdIdx));
|
||||
|
||||
// "hashes":"[index hash]"
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = hexKey;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(good, jv, expectedCount);
|
||||
// Index is correct either way
|
||||
BEAST_EXPECTS(
|
||||
hexKey == jv[jss::result][jss::index].asString(),
|
||||
strHex(jv[jss::result][jss::index].asString()));
|
||||
|
||||
// Use the "index":"[index hash]" notation
|
||||
params.clear();
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::index] = hexKey;
|
||||
jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(good, jv, expectedCount);
|
||||
// Index is correct either way
|
||||
BEAST_EXPECTS(
|
||||
hexKey == jv[jss::result][jss::index].asString(),
|
||||
strHex(jv[jss::result][jss::index].asString()));
|
||||
};
|
||||
|
||||
// short skip list
|
||||
test(true, keylet::skip(), true, 2);
|
||||
// long skip list at index 0
|
||||
test(1, keylet::skip(1), false);
|
||||
// long skip list at index 1
|
||||
test(1 << 17, keylet::skip(1 << 17), false);
|
||||
|
||||
// Close more ledgers, but stop short of the flag ledger
|
||||
for (auto i = env.current()->seq(); i <= 250; ++i)
|
||||
env.close();
|
||||
|
||||
// short skip list
|
||||
test(true, keylet::skip(), true, 249);
|
||||
// long skip list at index 0
|
||||
test(1, keylet::skip(1), false);
|
||||
// long skip list at index 1
|
||||
test(1 << 17, keylet::skip(1 << 17), false);
|
||||
|
||||
// Close a flag ledger so the first "long" skip list is created
|
||||
for (auto i = env.current()->seq(); i <= 260; ++i)
|
||||
env.close();
|
||||
|
||||
// short skip list
|
||||
test(true, keylet::skip(), true, 256);
|
||||
// long skip list at index 0
|
||||
test(1, keylet::skip(1), true, 1);
|
||||
// long skip list at index 1
|
||||
test(1 << 17, keylet::skip(1 << 17), false);
|
||||
}
|
||||
|
||||
void
|
||||
testLedgerEntryCLI()
|
||||
{
|
||||
@@ -2057,6 +2423,8 @@ public:
|
||||
testOracleLedgerEntry();
|
||||
testLedgerEntryMPT();
|
||||
testLedgerEntryPermissionedDomain();
|
||||
testLedgerEntryFixed();
|
||||
testLedgerEntryHashes();
|
||||
testLedgerEntryCLI();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,8 +61,7 @@ CreateCheck::preclaim(PreclaimContext const& ctx)
|
||||
auto const flags = sleDst->getFlags();
|
||||
|
||||
// Check if the destination has disallowed incoming checks
|
||||
if (ctx.view.rules().enabled(featureDisallowIncoming) &&
|
||||
(flags & lsfDisallowIncomingCheck))
|
||||
if (flags & lsfDisallowIncomingCheck)
|
||||
return tecNO_PERMISSION;
|
||||
|
||||
// Pseudo-accounts cannot cash checks. Note, this is not amendment-gated
|
||||
|
||||
@@ -919,31 +919,21 @@ tokenOfferCreatePreclaim(
|
||||
return tecNO_DST;
|
||||
|
||||
// check if the destination has disallowed incoming offers
|
||||
if (view.rules().enabled(featureDisallowIncoming))
|
||||
{
|
||||
// flag cannot be set unless amendment is enabled but
|
||||
// out of an abundance of caution check anyway
|
||||
|
||||
if (sleDst->getFlags() & lsfDisallowIncomingNFTokenOffer)
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
if (sleDst->getFlags() & lsfDisallowIncomingNFTokenOffer)
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
|
||||
if (owner)
|
||||
{
|
||||
// Check if the owner (buy offer) has disallowed incoming offers
|
||||
if (view.rules().enabled(featureDisallowIncoming))
|
||||
{
|
||||
auto const sleOwner = view.read(keylet::account(*owner));
|
||||
auto const sleOwner = view.read(keylet::account(*owner));
|
||||
|
||||
// defensively check
|
||||
// it should not be possible to specify owner that doesn't exist
|
||||
if (!sleOwner)
|
||||
return tecNO_TARGET;
|
||||
// defensively check
|
||||
// it should not be possible to specify owner that doesn't exist
|
||||
if (!sleOwner)
|
||||
return tecNO_TARGET;
|
||||
|
||||
if (sleOwner->getFlags() & lsfDisallowIncomingNFTokenOffer)
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
if (sleOwner->getFlags() & lsfDisallowIncomingNFTokenOffer)
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
|
||||
if (view.rules().enabled(fixEnforceNFTokenTrustlineV2) && !amount.native())
|
||||
|
||||
@@ -202,8 +202,7 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
|
||||
auto const flags = sled->getFlags();
|
||||
|
||||
// Check if they have disallowed incoming payment channels
|
||||
if (ctx.view.rules().enabled(featureDisallowIncoming) &&
|
||||
(flags & lsfDisallowIncomingPayChan))
|
||||
if (flags & lsfDisallowIncomingPayChan)
|
||||
return tecNO_PERMISSION;
|
||||
|
||||
if ((flags & lsfRequireDestTag) && !ctx.tx[~sfDestinationTag])
|
||||
|
||||
@@ -595,29 +595,25 @@ SetAccount::doApply()
|
||||
sle->isFieldPresent(sfNFTokenMinter))
|
||||
sle->makeFieldAbsent(sfNFTokenMinter);
|
||||
|
||||
// Set or clear flags for disallowing various incoming instruments
|
||||
if (ctx_.view().rules().enabled(featureDisallowIncoming))
|
||||
{
|
||||
if (uSetFlag == asfDisallowIncomingNFTokenOffer)
|
||||
uFlagsOut |= lsfDisallowIncomingNFTokenOffer;
|
||||
else if (uClearFlag == asfDisallowIncomingNFTokenOffer)
|
||||
uFlagsOut &= ~lsfDisallowIncomingNFTokenOffer;
|
||||
if (uSetFlag == asfDisallowIncomingNFTokenOffer)
|
||||
uFlagsOut |= lsfDisallowIncomingNFTokenOffer;
|
||||
else if (uClearFlag == asfDisallowIncomingNFTokenOffer)
|
||||
uFlagsOut &= ~lsfDisallowIncomingNFTokenOffer;
|
||||
|
||||
if (uSetFlag == asfDisallowIncomingCheck)
|
||||
uFlagsOut |= lsfDisallowIncomingCheck;
|
||||
else if (uClearFlag == asfDisallowIncomingCheck)
|
||||
uFlagsOut &= ~lsfDisallowIncomingCheck;
|
||||
if (uSetFlag == asfDisallowIncomingCheck)
|
||||
uFlagsOut |= lsfDisallowIncomingCheck;
|
||||
else if (uClearFlag == asfDisallowIncomingCheck)
|
||||
uFlagsOut &= ~lsfDisallowIncomingCheck;
|
||||
|
||||
if (uSetFlag == asfDisallowIncomingPayChan)
|
||||
uFlagsOut |= lsfDisallowIncomingPayChan;
|
||||
else if (uClearFlag == asfDisallowIncomingPayChan)
|
||||
uFlagsOut &= ~lsfDisallowIncomingPayChan;
|
||||
if (uSetFlag == asfDisallowIncomingPayChan)
|
||||
uFlagsOut |= lsfDisallowIncomingPayChan;
|
||||
else if (uClearFlag == asfDisallowIncomingPayChan)
|
||||
uFlagsOut &= ~lsfDisallowIncomingPayChan;
|
||||
|
||||
if (uSetFlag == asfDisallowIncomingTrustline)
|
||||
uFlagsOut |= lsfDisallowIncomingTrustline;
|
||||
else if (uClearFlag == asfDisallowIncomingTrustline)
|
||||
uFlagsOut &= ~lsfDisallowIncomingTrustline;
|
||||
}
|
||||
if (uSetFlag == asfDisallowIncomingTrustline)
|
||||
uFlagsOut |= lsfDisallowIncomingTrustline;
|
||||
else if (uClearFlag == asfDisallowIncomingTrustline)
|
||||
uFlagsOut &= ~lsfDisallowIncomingTrustline;
|
||||
|
||||
// Set or clear flags for disallowing escrow
|
||||
if (ctx_.view().rules().enabled(featureTokenEscrow))
|
||||
|
||||
@@ -200,31 +200,27 @@ SetTrust::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
// This might be nullptr
|
||||
auto const sleDst = ctx.view.read(keylet::account(uDstAccountID));
|
||||
if ((ctx.view.rules().enabled(featureDisallowIncoming) ||
|
||||
ammEnabled(ctx.view.rules()) ||
|
||||
if ((ammEnabled(ctx.view.rules()) ||
|
||||
ctx.view.rules().enabled(featureSingleAssetVault)) &&
|
||||
sleDst == nullptr)
|
||||
return tecNO_DST;
|
||||
|
||||
// If the destination has opted to disallow incoming trustlines
|
||||
// then honour that flag
|
||||
if (ctx.view.rules().enabled(featureDisallowIncoming))
|
||||
if (sleDst->getFlags() & lsfDisallowIncomingTrustline)
|
||||
{
|
||||
if (sleDst->getFlags() & lsfDisallowIncomingTrustline)
|
||||
// The original implementation of featureDisallowIncoming was
|
||||
// too restrictive. If
|
||||
// o fixDisallowIncomingV1 is enabled and
|
||||
// o The trust line already exists
|
||||
// Then allow the TrustSet.
|
||||
if (ctx.view.rules().enabled(fixDisallowIncomingV1) &&
|
||||
ctx.view.exists(keylet::line(id, uDstAccountID, currency)))
|
||||
{
|
||||
// The original implementation of featureDisallowIncoming was
|
||||
// too restrictive. If
|
||||
// o fixDisallowIncomingV1 is enabled and
|
||||
// o The trust line already exists
|
||||
// Then allow the TrustSet.
|
||||
if (ctx.view.rules().enabled(fixDisallowIncomingV1) &&
|
||||
ctx.view.exists(keylet::line(id, uDstAccountID, currency)))
|
||||
{
|
||||
// pass
|
||||
}
|
||||
else
|
||||
return tecNO_PERMISSION;
|
||||
// pass
|
||||
}
|
||||
else
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
|
||||
// In general, trust lines to pseudo accounts are not permitted, unless
|
||||
|
||||
@@ -16,16 +16,18 @@ JobQueue::Coro::Coro(
|
||||
, type_(type)
|
||||
, name_(name)
|
||||
, running_(false)
|
||||
, coro_([this, fn = std::forward<F>(f)](
|
||||
boost::coroutines2::asymmetric_coroutine<void>::push_type&
|
||||
do_yield) {
|
||||
yield_ = &do_yield;
|
||||
yield();
|
||||
fn(shared_from_this());
|
||||
, coro_(
|
||||
[this, fn = std::forward<F>(f)](
|
||||
boost::coroutines::asymmetric_coroutine<void>::push_type&
|
||||
do_yield) {
|
||||
yield_ = &do_yield;
|
||||
yield();
|
||||
fn(shared_from_this());
|
||||
#ifndef NDEBUG
|
||||
finished_ = true;
|
||||
finished_ = true;
|
||||
#endif
|
||||
})
|
||||
},
|
||||
boost::coroutines::attributes(megabytes(1)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <xrpl/basics/LocalValue.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
#include <boost/coroutine2/all.hpp>
|
||||
#include <boost/coroutine/all.hpp>
|
||||
|
||||
#include <set>
|
||||
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
std::mutex mutex_;
|
||||
std::mutex mutex_run_;
|
||||
std::condition_variable cv_;
|
||||
boost::coroutines2::asymmetric_coroutine<void>::pull_type coro_;
|
||||
boost::coroutines2::asymmetric_coroutine<void>::push_type* yield_;
|
||||
boost::coroutines::asymmetric_coroutine<void>::pull_type coro_;
|
||||
boost::coroutines::asymmetric_coroutine<void>::push_type* yield_;
|
||||
#ifndef NDEBUG
|
||||
bool finished_ = false;
|
||||
#endif
|
||||
@@ -334,7 +334,7 @@ private:
|
||||
other requests while the RPC command completes its work asynchronously.
|
||||
|
||||
postCoro() creates a Coro object. When the Coro ctor is called, and its
|
||||
coro_ member is initialized (a boost::coroutines2::pull_type), execution
|
||||
coro_ member is initialized (a boost::coroutines::pull_type), execution
|
||||
automatically passes to the coroutine, which we don't want at this point,
|
||||
since we are still in the handler thread context. It's important to note
|
||||
here that construction of a boost pull_type automatically passes execution to
|
||||
|
||||
@@ -116,11 +116,8 @@ doAccountInfo(RPC::JsonContext& context)
|
||||
for (auto const& lsf : lsFlags)
|
||||
acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
|
||||
|
||||
if (ledger->rules().enabled(featureDisallowIncoming))
|
||||
{
|
||||
for (auto const& lsf : disallowIncomingFlags)
|
||||
acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
|
||||
}
|
||||
for (auto const& lsf : disallowIncomingFlags)
|
||||
acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
|
||||
|
||||
if (ledger->rules().enabled(featureClawback))
|
||||
acctFlags[allowTrustLineClawbackFlag.first.data()] =
|
||||
|
||||
@@ -18,6 +18,32 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
using FunctionType = std::function<Expected<uint256, Json::Value>(
|
||||
Json::Value const&,
|
||||
Json::StaticString const,
|
||||
unsigned apiVersion)>;
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseFixed(
|
||||
Keylet const& keylet,
|
||||
Json::Value const& params,
|
||||
Json::StaticString const& fieldName,
|
||||
unsigned apiVersion);
|
||||
|
||||
// Helper function to return FunctionType for objects that have a fixed
|
||||
// location. That is, they don't take parameters to compute the index.
|
||||
// e.g. amendments, fees, negative UNL, etc.
|
||||
static FunctionType
|
||||
fixed(Keylet const& keylet)
|
||||
{
|
||||
return [&keylet](
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion) -> Expected<uint256, Json::Value> {
|
||||
return parseFixed(keylet, params, fieldName, apiVersion);
|
||||
};
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseObjectID(
|
||||
Json::Value const& params,
|
||||
@@ -33,13 +59,33 @@ parseObjectID(
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseIndex(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseIndex(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (apiVersion > 2u && params.isString())
|
||||
{
|
||||
std::string const index = params.asString();
|
||||
if (index == jss::amendments.c_str())
|
||||
return keylet::amendments().key;
|
||||
if (index == jss::fee.c_str())
|
||||
return keylet::fees().key;
|
||||
if (index == jss::nunl)
|
||||
return keylet::negativeUNL().key;
|
||||
if (index == jss::hashes)
|
||||
// Note this only finds the "short" skip list. Use "hashes":index to
|
||||
// get the long list.
|
||||
return keylet::skip().key;
|
||||
}
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseAccountRoot(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseAccountRoot(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (auto const account = LedgerEntryHelpers::parse<AccountID>(params))
|
||||
{
|
||||
@@ -50,14 +96,13 @@ parseAccountRoot(Json::Value const& params, Json::StaticString const fieldName)
|
||||
"malformedAddress", fieldName, "AccountID");
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseAmendments(Json::Value const& params, Json::StaticString const fieldName)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
auto const parseAmendments = fixed(keylet::amendments());
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseAMM(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseAMM(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -84,7 +129,10 @@ parseAMM(Json::Value const& params, Json::StaticString const fieldName)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseBridge(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseBridge(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isMember(jss::bridge))
|
||||
{
|
||||
@@ -115,13 +163,19 @@ parseBridge(Json::Value const& params, Json::StaticString const fieldName)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseCheck(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseCheck(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseCredential(Json::Value const& cred, Json::StaticString const fieldName)
|
||||
parseCredential(
|
||||
Json::Value const& cred,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!cred.isObject())
|
||||
{
|
||||
@@ -152,7 +206,10 @@ parseCredential(Json::Value const& cred, Json::StaticString const fieldName)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseDelegate(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseDelegate(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -243,7 +300,10 @@ parseAuthorizeCredentials(Json::Value const& jv)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
|
||||
parseDepositPreauth(
|
||||
Json::Value const& dp,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!dp.isObject())
|
||||
{
|
||||
@@ -296,7 +356,10 @@ parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseDID(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseDID(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
auto const account = LedgerEntryHelpers::parse<AccountID>(params);
|
||||
if (!account)
|
||||
@@ -311,7 +374,8 @@ parseDID(Json::Value const& params, Json::StaticString const fieldName)
|
||||
static Expected<uint256, Json::Value>
|
||||
parseDirectoryNode(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName)
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -364,7 +428,10 @@ parseDirectoryNode(
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseEscrow(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseEscrow(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -383,20 +450,53 @@ parseEscrow(Json::Value const& params, Json::StaticString const fieldName)
|
||||
return keylet::escrow(*id, *seq).key;
|
||||
}
|
||||
|
||||
auto const parseFeeSettings = fixed(keylet::fees());
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseFeeSettings(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseFixed(
|
||||
Keylet const& keylet,
|
||||
Json::Value const& params,
|
||||
Json::StaticString const& fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
if (!params.isBool())
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
if (!params.asBool())
|
||||
{
|
||||
return LedgerEntryHelpers::invalidFieldError(
|
||||
"invalidParams", fieldName, "true");
|
||||
}
|
||||
|
||||
return keylet.key;
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseLedgerHashes(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseLedgerHashes(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
if (params.isUInt() || params.isInt())
|
||||
{
|
||||
// If the index doesn't parse as a UInt, throw
|
||||
auto const index = params.asUInt();
|
||||
|
||||
// Return the "long" skip list for the given ledger index.
|
||||
auto const keylet = keylet::skip(index);
|
||||
return keylet.key;
|
||||
}
|
||||
// Return the key in `params` or the "short" skip list, which contains
|
||||
// hashes since the last flag ledger.
|
||||
return parseFixed(keylet::skip(), params, fieldName, apiVersion);
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseMPToken(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseMPToken(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -419,7 +519,8 @@ parseMPToken(Json::Value const& params, Json::StaticString const fieldName)
|
||||
static Expected<uint256, Json::Value>
|
||||
parseMPTokenIssuance(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName)
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
auto const mptIssuanceID = LedgerEntryHelpers::parse<uint192>(params);
|
||||
if (!mptIssuanceID)
|
||||
@@ -430,25 +531,30 @@ parseMPTokenIssuance(
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseNFTokenOffer(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseNFTokenOffer(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseNFTokenPage(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseNFTokenPage(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseNegativeUNL(Json::Value const& params, Json::StaticString const fieldName)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
auto const parseNegativeUNL = fixed(keylet::negativeUNL());
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseOffer(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseOffer(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -469,7 +575,10 @@ parseOffer(Json::Value const& params, Json::StaticString const fieldName)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseOracle(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseOracle(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -490,7 +599,10 @@ parseOracle(Json::Value const& params, Json::StaticString const fieldName)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parsePayChannel(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parsePayChannel(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
@@ -498,7 +610,8 @@ parsePayChannel(Json::Value const& params, Json::StaticString const fieldName)
|
||||
static Expected<uint256, Json::Value>
|
||||
parsePermissionedDomain(
|
||||
Json::Value const& pd,
|
||||
Json::StaticString const fieldName)
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (pd.isString())
|
||||
{
|
||||
@@ -527,7 +640,8 @@ parsePermissionedDomain(
|
||||
static Expected<uint256, Json::Value>
|
||||
parseRippleState(
|
||||
Json::Value const& jvRippleState,
|
||||
Json::StaticString const fieldName)
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
Currency uCurrency;
|
||||
|
||||
@@ -577,13 +691,19 @@ parseRippleState(
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseSignerList(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseSignerList(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
return parseObjectID(params, fieldName, "hex string");
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseTicket(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseTicket(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -604,7 +724,10 @@ parseTicket(Json::Value const& params, Json::StaticString const fieldName)
|
||||
}
|
||||
|
||||
static Expected<uint256, Json::Value>
|
||||
parseVault(Json::Value const& params, Json::StaticString const fieldName)
|
||||
parseVault(
|
||||
Json::Value const& params,
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!params.isObject())
|
||||
{
|
||||
@@ -627,7 +750,8 @@ parseVault(Json::Value const& params, Json::StaticString const fieldName)
|
||||
static Expected<uint256, Json::Value>
|
||||
parseXChainOwnedClaimID(
|
||||
Json::Value const& claim_id,
|
||||
Json::StaticString const fieldName)
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!claim_id.isObject())
|
||||
{
|
||||
@@ -652,7 +776,8 @@ parseXChainOwnedClaimID(
|
||||
static Expected<uint256, Json::Value>
|
||||
parseXChainOwnedCreateAccountClaimID(
|
||||
Json::Value const& claim_id,
|
||||
Json::StaticString const fieldName)
|
||||
Json::StaticString const fieldName,
|
||||
unsigned apiVersion)
|
||||
{
|
||||
if (!claim_id.isObject())
|
||||
{
|
||||
@@ -676,10 +801,6 @@ parseXChainOwnedCreateAccountClaimID(
|
||||
return keylet.key;
|
||||
}
|
||||
|
||||
using FunctionType = Expected<uint256, Json::Value> (*)(
|
||||
Json::Value const&,
|
||||
Json::StaticString const);
|
||||
|
||||
struct LedgerEntry
|
||||
{
|
||||
Json::StaticString fieldName;
|
||||
@@ -712,7 +833,7 @@ doLedgerEntry(RPC::JsonContext& context)
|
||||
{jss::ripple_state, parseRippleState, ltRIPPLE_STATE},
|
||||
});
|
||||
|
||||
auto hasMoreThanOneMember = [&]() {
|
||||
auto const hasMoreThanOneMember = [&]() {
|
||||
int count = 0;
|
||||
|
||||
for (auto const& ledgerEntry : ledgerEntryParsers)
|
||||
@@ -756,8 +877,8 @@ doLedgerEntry(RPC::JsonContext& context)
|
||||
Json::Value const& params = ledgerEntry.fieldName == jss::bridge
|
||||
? context.params
|
||||
: context.params[ledgerEntry.fieldName];
|
||||
auto const result =
|
||||
ledgerEntry.parseFunction(params, ledgerEntry.fieldName);
|
||||
auto const result = ledgerEntry.parseFunction(
|
||||
params, ledgerEntry.fieldName, context.apiVersion);
|
||||
if (!result)
|
||||
return result.error();
|
||||
|
||||
@@ -788,9 +909,13 @@ doLedgerEntry(RPC::JsonContext& context)
|
||||
throw;
|
||||
}
|
||||
|
||||
// Return the computed index regardless of whether the node exists.
|
||||
jvResult[jss::index] = to_string(uNodeIndex);
|
||||
|
||||
if (uNodeIndex.isZero())
|
||||
{
|
||||
return RPC::make_error(rpcENTRY_NOT_FOUND);
|
||||
RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
auto const sleNode = lpLedger->read(keylet::unchecked(uNodeIndex));
|
||||
@@ -802,12 +927,14 @@ doLedgerEntry(RPC::JsonContext& context)
|
||||
if (!sleNode)
|
||||
{
|
||||
// Not found.
|
||||
return RPC::make_error(rpcENTRY_NOT_FOUND);
|
||||
RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
if ((expectedType != ltANY) && (expectedType != sleNode->getType()))
|
||||
{
|
||||
return RPC::make_error(rpcUNEXPECTED_LEDGER_TYPE);
|
||||
RPC::inject_error(rpcUNEXPECTED_LEDGER_TYPE, jvResult);
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
if (bNodeBinary)
|
||||
@@ -817,12 +944,10 @@ doLedgerEntry(RPC::JsonContext& context)
|
||||
sleNode->add(s);
|
||||
|
||||
jvResult[jss::node_binary] = strHex(s.peekData());
|
||||
jvResult[jss::index] = to_string(uNodeIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult[jss::node] = sleNode->getJson(JsonOptions::none);
|
||||
jvResult[jss::index] = to_string(uNodeIndex);
|
||||
}
|
||||
|
||||
return jvResult;
|
||||
|
||||
Reference in New Issue
Block a user