Compare commits

..

1 Commits

Author SHA1 Message Date
Pratik Mankawde
7def28c8ef switch to ucontext and coroutine2
Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

updated conan profiles

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

removed no-pie

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

minor change

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

fixes for boost flags

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

minor fix

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

added boost flags to cxx_flags

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

added boost context to conanfile

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

added dependency to coroutine2

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

now building coroutine2

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

using without_coroutine2=false as well

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>

fix build

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>
2025-11-21 12:11:13 +00:00
28 changed files with 389 additions and 112 deletions

View File

@@ -70,6 +70,9 @@ 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

View File

@@ -156,15 +156,107 @@ 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.
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,
})
# 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
})
return configurations

View File

@@ -17,7 +17,7 @@ find_dependency (Boost
chrono
container
context
coroutine
coroutine2
date_time
filesystem
program_options

View File

@@ -2,7 +2,7 @@ find_package(Boost 1.82 REQUIRED
COMPONENTS
chrono
container
coroutine
context
date_time
filesystem
json
@@ -20,7 +20,7 @@ target_link_libraries(xrpl_boost
Boost::headers
Boost::chrono
Boost::container
Boost::coroutine
Boost::context
Boost::date_time
Boost::filesystem
Boost::json

1
conan/profiles/ci Normal file
View File

@@ -0,0 +1 @@
include(sanitizers)

69
conan/profiles/sanitizers Normal file
View File

@@ -0,0 +1,69 @@
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 %}

View File

@@ -102,6 +102,7 @@ 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
@@ -172,7 +173,8 @@ class Xrpl(ConanFile):
'boost::headers',
'boost::chrono',
'boost::container',
'boost::coroutine',
'boost::context',
'boost::coroutine2',
'boost::date_time',
'boost::filesystem',
'boost::json',

View File

@@ -63,10 +63,12 @@ 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
@@ -114,12 +116,10 @@ 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)

View File

@@ -226,7 +226,7 @@ TRANSACTION(ttPAYCHAN_CLAIM, 15, PaymentChannelClaim,
#endif
TRANSACTION(ttCHECK_CREATE, 16, CheckCreate,
Delegation::delegatable,
uint256{},
featureChecks,
noPriv,
({
{sfDestination, soeREQUIRED},
@@ -242,7 +242,7 @@ TRANSACTION(ttCHECK_CREATE, 16, CheckCreate,
#endif
TRANSACTION(ttCHECK_CASH, 17, CheckCash,
Delegation::delegatable,
uint256{},
featureChecks,
noPriv,
({
{sfCheckID, soeREQUIRED},
@@ -256,7 +256,7 @@ TRANSACTION(ttCHECK_CASH, 17, CheckCash,
#endif
TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel,
Delegation::delegatable,
uint256{},
featureChecks,
noPriv,
({
{sfCheckID, soeREQUIRED},

View File

@@ -67,6 +67,8 @@ public:
class Check_test : public beast::unit_test::suite
{
FeatureBitset const disallowIncoming{featureDisallowIncoming};
static uint256
getCheckIndex(AccountID const& account, std::uint32_t uSequence)
{
@@ -123,6 +125,25 @@ 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.
@@ -256,12 +277,24 @@ 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};
Env env{*this, features | disallowIncoming};
STAmount const startBalance{XRP(1000).value()};
env.fund(startBalance, gw, alice, bob);
@@ -2580,6 +2613,7 @@ public:
{
using namespace test::jtx;
auto const sa = testable_amendments();
testWithFeats(sa - disallowIncoming);
testWithFeats(sa);
testTrustLineCreation(sa);
}

View File

@@ -1703,6 +1703,9 @@ 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},

View File

@@ -12,6 +12,8 @@ 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)
@@ -2958,7 +2960,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite
using namespace test::jtx;
Env env{*this, features};
// 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};
Account const issuer{"issuer"};
Account const minter{"minter"};
@@ -7610,8 +7624,8 @@ class NFTokenDisallowIncoming_test : public NFTokenBaseUtil_test
run() override
{
testWithFeats(
allFeatures - fixNFTokenReserve - featureNFTokenMintOffer -
featureDynamicNFT);
allFeatures - featureDisallowIncoming - fixNFTokenReserve -
featureNFTokenMintOffer - featureDynamicNFT);
}
};

View File

@@ -1,3 +1,5 @@
// Copyright (c) 2020 Dev Null Productions
#include <test/jtx.h>
#include <test/jtx/CaptureLogs.h>
#include <test/jtx/Env.h>

View File

@@ -14,6 +14,8 @@ 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,
@@ -240,8 +242,20 @@ 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};
Env env{*this, features | disallowIncoming};
auto const alice = Account("alice");
auto const bob = Account("bob");
auto const cho = Account("cho");
@@ -2113,6 +2127,7 @@ public:
{
using namespace test::jtx;
FeatureBitset const all{testable_amendments()};
testWithFeats(all - disallowIncoming);
testWithFeats(all);
testDepositAuthCreds();
testMetaAndOwnership(all - fixIncludeKeyletFields);

View File

@@ -9,6 +9,8 @@ namespace test {
class SetTrust_test : public beast::unit_test::suite
{
FeatureBitset const disallowIncoming{featureDisallowIncoming};
public:
void
testTrustLineDelete()
@@ -476,12 +478,25 @@ 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 : features - fixDisallowIncomingV1;
auto const amend = withFix
? features | disallowIncoming
: (features | disallowIncoming) - fixDisallowIncomingV1;
Env env{*this, amend};
auto const dist = Account("dist");
@@ -517,7 +532,7 @@ public:
}
}
Env env{*this, features};
Env env{*this, features | disallowIncoming};
auto const gw = Account{"gateway"};
auto const alice = Account{"alice"};
@@ -615,6 +630,7 @@ public:
{
using namespace test::jtx;
auto const sa = testable_amendments();
testWithFeats(sa - disallowIncoming);
testWithFeats(sa);
}
};

View File

@@ -615,23 +615,33 @@ public:
{"disallowIncomingTrustline",
asfDisallowIncomingTrustline}}};
for (auto& asf : disallowIncomingFlags)
if (features[featureDisallowIncoming])
{
// 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());
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());
// 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());
// 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));
}
}
static constexpr std::pair<std::string_view, std::uint32_t>
@@ -696,8 +706,12 @@ public:
FeatureBitset const allFeatures{
ripple::test::jtx::testable_amendments()};
testAccountFlags(allFeatures);
testAccountFlags(allFeatures - featureClawback);
testAccountFlags(allFeatures - featureClawback - featureTokenEscrow);
testAccountFlags(allFeatures - featureDisallowIncoming);
testAccountFlags(
allFeatures - featureDisallowIncoming - featureClawback);
testAccountFlags(
allFeatures - featureDisallowIncoming - featureClawback -
featureTokenEscrow);
}
};

View File

@@ -171,7 +171,7 @@ getRowsMinMax(soci::session& session, TableType type)
bool
saveValidatedLedger(
DatabaseCon& ldgDB,
std::unique_ptr<DatabaseCon> const& txnDB,
DatabaseCon& txnDB,
Application& app,
std::shared_ptr<Ledger const> const& ledger,
bool current)
@@ -254,15 +254,7 @@ saveValidatedLedger(
if (app.config().useTxTables())
{
if (!txnDB)
{
// LCOV_EXCL_START
JLOG(j.fatal()) << "TxTables db isn't available";
Throw<std::runtime_error>("TxTables db isn't available");
// LCOV_EXCL_STOP
}
auto db = txnDB->checkoutDb();
auto db = txnDB.checkoutDb();
soci::transaction tr(*db);

View File

@@ -111,7 +111,7 @@ getRowsMinMax(soci::session& session, TableType type);
bool
saveValidatedLedger(
DatabaseCon& ldgDB,
std::unique_ptr<DatabaseCon> const& txnDB,
DatabaseCon& txnDB,
Application& app,
std::shared_ptr<Ledger const> const& ledger,
bool current);

View File

@@ -392,7 +392,8 @@ SQLiteDatabaseImp::saveValidatedLedger(
{
if (existsLedger())
{
if (!detail::saveValidatedLedger(*lgrdb_, txdb_, app_, ledger, current))
if (!detail::saveValidatedLedger(
*lgrdb_, *txdb_, app_, ledger, current))
return false;
}

View File

@@ -61,7 +61,8 @@ CreateCheck::preclaim(PreclaimContext const& ctx)
auto const flags = sleDst->getFlags();
// Check if the destination has disallowed incoming checks
if (flags & lsfDisallowIncomingCheck)
if (ctx.view.rules().enabled(featureDisallowIncoming) &&
(flags & lsfDisallowIncomingCheck))
return tecNO_PERMISSION;
// Pseudo-accounts cannot cash checks. Note, this is not amendment-gated

View File

@@ -919,21 +919,31 @@ tokenOfferCreatePreclaim(
return tecNO_DST;
// check if the destination has disallowed incoming offers
if (sleDst->getFlags() & lsfDisallowIncomingNFTokenOffer)
return tecNO_PERMISSION;
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 (owner)
{
auto const sleOwner = view.read(keylet::account(*owner));
// Check if the owner (buy offer) has disallowed incoming offers
if (view.rules().enabled(featureDisallowIncoming))
{
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())

View File

@@ -202,7 +202,8 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
auto const flags = sled->getFlags();
// Check if they have disallowed incoming payment channels
if (flags & lsfDisallowIncomingPayChan)
if (ctx.view.rules().enabled(featureDisallowIncoming) &&
(flags & lsfDisallowIncomingPayChan))
return tecNO_PERMISSION;
if ((flags & lsfRequireDestTag) && !ctx.tx[~sfDestinationTag])

View File

@@ -595,25 +595,29 @@ SetAccount::doApply()
sle->isFieldPresent(sfNFTokenMinter))
sle->makeFieldAbsent(sfNFTokenMinter);
if (uSetFlag == asfDisallowIncomingNFTokenOffer)
uFlagsOut |= lsfDisallowIncomingNFTokenOffer;
else if (uClearFlag == asfDisallowIncomingNFTokenOffer)
uFlagsOut &= ~lsfDisallowIncomingNFTokenOffer;
// 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 == 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))

View File

@@ -200,27 +200,31 @@ SetTrust::preclaim(PreclaimContext const& ctx)
// This might be nullptr
auto const sleDst = ctx.view.read(keylet::account(uDstAccountID));
if ((ammEnabled(ctx.view.rules()) ||
if ((ctx.view.rules().enabled(featureDisallowIncoming) ||
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 (sleDst->getFlags() & lsfDisallowIncomingTrustline)
if (ctx.view.rules().enabled(featureDisallowIncoming))
{
// 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)))
if (sleDst->getFlags() & lsfDisallowIncomingTrustline)
{
// pass
// 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;
}
else
return tecNO_PERMISSION;
}
// In general, trust lines to pseudo accounts are not permitted, unless

View File

@@ -121,8 +121,6 @@ VaultWithdraw::preclaim(PreclaimContext const& ctx)
if (auto const ret = checkFrozen(ctx.view, dstAcct, vaultAsset))
return ret;
// Cannot return shares to the vault, if the underlying asset was frozen for
// the submitter
if (auto const ret = checkFrozen(ctx.view, account, vaultShare))
return ret;

View File

@@ -16,18 +16,16 @@ JobQueue::Coro::Coro(
, type_(type)
, name_(name)
, running_(false)
, coro_(
[this, fn = std::forward<F>(f)](
boost::coroutines::asymmetric_coroutine<void>::push_type&
do_yield) {
yield_ = &do_yield;
yield();
fn(shared_from_this());
, coro_([this, fn = std::forward<F>(f)](
boost::coroutines2::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)))
})
{
}

View File

@@ -9,7 +9,7 @@
#include <xrpl/basics/LocalValue.h>
#include <xrpl/json/json_value.h>
#include <boost/coroutine/all.hpp>
#include <boost/coroutine2/all.hpp>
#include <set>
@@ -50,8 +50,8 @@ public:
std::mutex mutex_;
std::mutex mutex_run_;
std::condition_variable cv_;
boost::coroutines::asymmetric_coroutine<void>::pull_type coro_;
boost::coroutines::asymmetric_coroutine<void>::push_type* yield_;
boost::coroutines2::asymmetric_coroutine<void>::pull_type coro_;
boost::coroutines2::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::coroutines::pull_type), execution
coro_ member is initialized (a boost::coroutines2::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

View File

@@ -116,8 +116,11 @@ doAccountInfo(RPC::JsonContext& context)
for (auto const& lsf : lsFlags)
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(featureDisallowIncoming))
{
for (auto const& lsf : disallowIncomingFlags)
acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
}
if (ledger->rules().enabled(featureClawback))
acctFlags[allowTrustLineClawbackFlag.first.data()] =