Compare commits

..

4 Commits

Author SHA1 Message Date
RichardAH
833df20fce Fix240819 (#350)
fix240918
---------

Co-authored-by: Denis Angell <dangell@transia.co>
2024-08-20 09:40:31 +10:00
Wietse Wind
5737c2b6e8 Workaround CentOS7 EOL 2024-08-18 01:50:44 +02:00
Richard Holland
a15d0b2ecc set huge mode nudb cache to 64mib 2024-08-14 16:40:07 +10:00
Denis Angell
18d76d3082 fix delivered amount (#310)
* fix delivered amount
2024-07-16 08:56:30 +10:00
26 changed files with 247 additions and 341 deletions

View File

@@ -588,7 +588,6 @@ target_sources (rippled PRIVATE
src/ripple/resource/impl/Consumer.cpp
src/ripple/resource/impl/Fees.cpp
src/ripple/resource/impl/ResourceManager.cpp
src/ripple/resource/impl/Tuning.cpp
#[===============================[
main sources:
subdir: rpc

View File

@@ -9,6 +9,15 @@ echo "-- GITHUB_RUN_NUMBER: $4"
umask 0000;
echo "Fixing CentOS 7 EOL"
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum clean all
yum-config-manager --disable centos-sclo-sclo
####
cd /io;
mkdir src/certs;
curl --silent -k https://raw.githubusercontent.com/RichardAH/rippled-release-builder/main/ca-bundle/certbundle.h -o src/certs/certbundle.h;

View File

@@ -23,9 +23,7 @@
#
# 9. Misc Settings
#
# 10. Resource Settings
#
# 11. Example Settings
# 10. Example Settings
#
#-------------------------------------------------------------------------------
#
@@ -1567,41 +1565,7 @@
#
#-------------------------------------------------------------------------------
#
# 10. Resource Settings
#
#--------------------
# [resource]
#
# A set of key/value pair parameters to tune the performance of the
# transaction queue.
#
# warning_threshold = <number>
#
# Lorem Epsium....
#
# drop_threshold = <number>
#
# Lorem Epsium....
#
# decay_window_seconds = <number>
#
# Lorem Epsium....
#
# minimum_gossip_balance = <number>
#
# Lorem Epsium....
#
# seconds_until_expiration = <number>
#
# Lorem Epsium....
#
# gossip_expiration_seconds = <number>
#
# Lorem Epsium....
#
#
#
# 11. Example Settings
# 10. Example Settings
#
#--------------------
#

View File

@@ -352,7 +352,6 @@ public:
, validatorKeys_(*config_, m_journal)
, m_resourceManager(Resource::make_Manager(
config_->section("resource"),
m_collectorManager->collector(),
logs_->journal("Resource")))

View File

@@ -1142,8 +1142,12 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
// Enforce Network bar for emitted txn
if (view->rules().enabled(featureHooks) && hook::isEmittedTxn(*iTrans))
{
JLOG(m_journal.warn())
<< "Submitted transaction invalid: EmitDetails present.";
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.
// JLOG(m_journal.warn())
// << "Submitted transaction invalid: EmitDetails present.";
return;
}
@@ -1155,7 +1159,11 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
if ((flags & SF_BAD) != 0)
{
JLOG(m_journal.warn()) << "Submitted transaction cached bad";
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.
// JLOG(m_journal.warn()) << "Submitted transaction cached bad";
return;
}

View File

@@ -173,6 +173,11 @@ updateLedgerDBs(
auto const sParentHash{to_string(ledger->info().parentHash)};
auto const sDrops{to_string(ledger->info().drops)};
auto const closingTime{
ledger->info().closeTime.time_since_epoch().count()};
auto const prevClosingTime{
ledger->info().parentCloseTime.time_since_epoch().count()};
auto const closeTimeRes{ledger->info().closeTimeResolution.count()};
auto const sAccountHash{to_string(ledger->info().accountHash)};
auto const sTxHash{to_string(ledger->info().txHash)};
@@ -188,11 +193,8 @@ updateLedgerDBs(
":closingTime, :prevClosingTime, :closeTimeRes,"
":closeFlags, :accountSetHash, :transSetHash);",
soci::use(sHash), soci::use(ledgerSeq), soci::use(sParentHash),
soci::use(sDrops),
soci::use(ledger->info().closeTime.time_since_epoch().count()),
soci::use(
ledger->info().parentCloseTime.time_since_epoch().count()),
soci::use(ledger->info().closeTimeResolution.count()),
soci::use(sDrops), soci::use(closingTime),
soci::use(prevClosingTime), soci::use(closeTimeRes),
soci::use(ledger->info().closeFlags), soci::use(sAccountHash),
soci::use(sTxHash);

View File

@@ -205,19 +205,20 @@ insertPeerReservation(
PublicKey const& nodeId,
std::string const& description)
{
auto const sNodeId = toBase58(TokenType::NodePublic, nodeId);
session << "INSERT INTO PeerReservations (PublicKey, Description) "
"VALUES (:nodeId, :desc) "
"ON CONFLICT (PublicKey) DO UPDATE SET "
"Description=excluded.Description",
soci::use(toBase58(TokenType::NodePublic, nodeId)),
soci::use(description);
soci::use(sNodeId), soci::use(description);
}
void
deletePeerReservation(soci::session& session, PublicKey const& nodeId)
{
auto const sNodeId = toBase58(TokenType::NodePublic, nodeId);
session << "DELETE FROM PeerReservations WHERE PublicKey = :nodeId",
soci::use(toBase58(TokenType::NodePublic, nodeId));
soci::use(sNodeId);
}
bool

View File

@@ -1921,6 +1921,12 @@ Transactor::operator()()
STObject const meta = metaRaw.getAsObject();
uint32_t lgrCur = view().seq();
bool const has240819 = view().rules().enabled(fix240819);
auto const& sfRewardFields =
*(ripple::SField::knownCodeToField.at(917511 - has240819));
// iterate all affected balances
for (auto const& node : meta.getFieldArray(sfAffectedNodes))
{
@@ -1932,7 +1938,7 @@ Transactor::operator()()
if (nodeType != ltACCOUNT_ROOT || metaType == sfDeletedNode)
continue;
if (!node.isFieldPresent(sfFinalFields) ||
if (!node.isFieldPresent(sfRewardFields) ||
!node.isFieldPresent(sfLedgerIndex))
continue;
@@ -1948,7 +1954,7 @@ Transactor::operator()()
continue;
STObject& finalFields = (const_cast<STObject&>(node))
.getField(sfFinalFields)
.getField(sfRewardFields)
.downcast<STObject>();
if (!finalFields.isFieldPresent(sfBalance))

View File

@@ -101,7 +101,6 @@ struct ConfigSection
#define SECTION_SWEEP_INTERVAL "sweep_interval"
#define SECTION_NETWORK_ID "network_id"
#define SECTION_IMPORT_VL_KEYS "import_vl_keys"
#define SECTION_RESOURCE "resource"
} // namespace ripple

View File

@@ -127,7 +127,7 @@ sizedItems
{SizedItem::txnDBCache, {{ 4, 12, 24, 64, 128 }}},
{SizedItem::lgrDBCache, {{ 4, 8, 16, 32, 128 }}},
{SizedItem::openFinalLimit, {{ 8, 16, 32, 64, 128 }}},
{SizedItem::burstSize, {{ 4, 8, 16, 32, 48 }}},
{SizedItem::burstSize, {{ 4, 8, 16, 32, 64*1024*1024 }}},
{SizedItem::ramSizeGB, {{ 8, 12, 16, 24, 32 }}},
{SizedItem::accountIdCacheSize, {{ 20047, 50053, 77081, 150061, 300007 }}}
}};

View File

@@ -74,7 +74,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 70;
static constexpr std::size_t numFeatures = 71;
/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
@@ -358,6 +358,7 @@ extern uint256 const fixXahauV2;
extern uint256 const featureRemit;
extern uint256 const featureZeroB2M;
extern uint256 const fixNSDelete;
extern uint256 const fix240819;
} // namespace ripple

View File

@@ -464,6 +464,7 @@ REGISTER_FIX (fixXahauV2, Supported::yes, VoteBehavior::De
REGISTER_FEATURE(Remit, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(ZeroB2M, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixNSDelete, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fix240819, Supported::yes, VoteBehavior::DefaultYes);
// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.

View File

@@ -80,7 +80,6 @@ public:
std::unique_ptr<Manager>
make_Manager(
Section const& section,
beast::insight::Collector::ptr const& collector,
beast::Journal journal);

View File

@@ -89,7 +89,7 @@ struct Entry : public beast::List<Entry>::Node
int refcount;
// Exponentially decaying balance of resource consumption
DecayingSample<Tuning::getDecayWindowSeconds(), clock_type> local_balance;
DecayingSample<decayWindowSeconds, clock_type> local_balance;
// Normalized balance contribution from imports
int remote_balance;

View File

@@ -31,7 +31,6 @@
#include <ripple/resource/Fees.h>
#include <ripple/resource/Gossip.h>
#include <ripple/resource/impl/Import.h>
#include <ripple/resource/impl/Tuning.h>
#include <cassert>
#include <mutex>
@@ -89,27 +88,11 @@ private:
//--------------------------------------------------------------------------
public:
Logic(
Section const& section,
beast::insight::Collector::ptr const& collector,
clock_type& clock,
beast::Journal journal)
: m_stats(collector), m_clock(clock), m_journal(journal)
{
std::uint32_t warningThreshold;
if (get_if_exists(section, "warning_threshold", warningThreshold))
Tuning::warningThreshold = warningThreshold;
std::uint32_t dropThreshold;
if (get_if_exists(section, "drop_threshold", dropThreshold))
Tuning::dropThreshold = dropThreshold;
// std::uint32_t decayWindowSeconds;
// if (get_if_exists(section, "decay_window_seconds", decayWindowSeconds))
// Tuning::decayWindowSeconds = decayWindowSeconds;
std::uint32_t minimumGossipBalance;
if (get_if_exists(section, "minimum_gossip_balance", minimumGossipBalance))
Tuning::minimumGossipBalance = minimumGossipBalance;
}
~Logic()
@@ -217,7 +200,7 @@ public:
Json::Value
getJson()
{
return getJson(Tuning::warningThreshold);
return getJson(warningThreshold);
}
/** Returns a Json::objectValue. */
@@ -283,7 +266,7 @@ public:
{
Gossip::Item item;
item.balance = inboundEntry.local_balance.value(now);
if (item.balance >= Tuning::minimumGossipBalance)
if (item.balance >= minimumGossipBalance)
{
item.address = inboundEntry.key->address;
gossip.items.push_back(item);
@@ -311,7 +294,7 @@ public:
{
// This is a new import
Import& next(resultIt->second);
next.whenExpires = elapsed + Tuning::gossipExpirationSeconds;
next.whenExpires = elapsed + gossipExpirationSeconds;
next.items.reserve(gossip.items.size());
for (auto const& gossipItem : gossip.items)
@@ -329,7 +312,7 @@ public:
// balances and then deduct the old remote balances.
Import next;
next.whenExpires = elapsed + Tuning::gossipExpirationSeconds;
next.whenExpires = elapsed + gossipExpirationSeconds;
next.items.reserve(gossip.items.size());
for (auto const& gossipItem : gossip.items)
{
@@ -404,10 +387,10 @@ public:
static Disposition
disposition(int balance)
{
if (balance >= Tuning::dropThreshold)
if (balance >= dropThreshold)
return Disposition::drop;
if (balance >= Tuning::warningThreshold)
if (balance >= warningThreshold)
return Disposition::warn;
return Disposition::ok;
@@ -454,7 +437,7 @@ public:
break;
}
inactive_.push_back(entry);
entry.whenExpires = m_clock.now() + Tuning::secondsUntilExpiration;
entry.whenExpires = m_clock.now() + secondsUntilExpiration;
}
}
@@ -477,7 +460,7 @@ public:
std::lock_guard _(lock_);
bool notify(false);
auto const elapsed = m_clock.now();
if (entry.balance(m_clock.now()) >= Tuning::warningThreshold &&
if (entry.balance(m_clock.now()) >= warningThreshold &&
elapsed != entry.lastWarningTime)
{
charge(entry, feeWarning);
@@ -502,11 +485,11 @@ public:
bool drop(false);
clock_type::time_point const now(m_clock.now());
int const balance(entry.balance(now));
if (balance >= Tuning::dropThreshold)
if (balance >= dropThreshold)
{
JLOG(m_journal.warn())
<< "Consumer entry " << entry << " dropped with balance "
<< balance << " at or above drop threshold " << Tuning::dropThreshold;
<< balance << " at or above drop threshold " << dropThreshold;
// Adding feeDrop at this point keeps the dropped connection
// from re-connecting for at least a little while after it is

View File

@@ -45,10 +45,9 @@ private:
public:
ManagerImp(
Section const& section,
beast::insight::Collector::ptr const& collector,
beast::Journal journal)
: journal_(journal), logic_(section, collector, stopwatch(), journal)
: journal_(journal), logic_(collector, stopwatch(), journal)
{
thread_ = std::thread{&ManagerImp::run, this};
}
@@ -174,11 +173,10 @@ Manager::~Manager() = default;
std::unique_ptr<Manager>
make_Manager(
Section const& section,
beast::insight::Collector::ptr const& collector,
beast::Journal journal)
{
return std::make_unique<ManagerImp>(section, collector, journal);
return std::make_unique<ManagerImp>(collector, journal);
}
} // namespace Resource

View File

@@ -1,34 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include "Tuning.h"
namespace ripple {
namespace Resource {
uint32_t Tuning::warningThreshold = 5000;
uint32_t Tuning::dropThreshold = 15000;
// uint32_t Tuning::decayWindowSeconds = 32;
uint32_t Tuning::minimumGossipBalance = 1000;
std::chrono::seconds constexpr Tuning::secondsUntilExpiration{300};
std::chrono::seconds constexpr Tuning::gossipExpirationSeconds{30};
} // namespace Resource
} // namespace ripple

View File

@@ -17,7 +17,6 @@
*/
//==============================================================================
// Tuning.h
#ifndef RIPPLE_RESOURCE_TUNING_H_INCLUDED
#define RIPPLE_RESOURCE_TUNING_H_INCLUDED
@@ -26,23 +25,31 @@
namespace ripple {
namespace Resource {
class Tuning
{
public:
static std::uint32_t warningThreshold;
static std::uint32_t dropThreshold;
// static std::uint32_t decayWindowSeconds;
static std::uint32_t minimumGossipBalance;
/** Tunable constants. */
enum {
// Balance at which a warning is issued
warningThreshold = 5000
static std::chrono::seconds const secondsUntilExpiration;
static std::chrono::seconds const gossipExpirationSeconds;
// Balance at which the consumer is disconnected
,
dropThreshold = 15000
static constexpr std::uint32_t getDecayWindowSeconds()
{
return 32;
}
// The number of seconds in the exponential decay window
// (This should be a power of two)
,
decayWindowSeconds = 32
// The minimum balance required in order to include a load source in gossip
,
minimumGossipBalance = 1000
};
// The number of seconds until an inactive table item is removed
std::chrono::seconds constexpr secondsUntilExpiration{300};
// Number of seconds until imported gossip expires
std::chrono::seconds constexpr gossipExpirationSeconds{30};
} // namespace Resource
} // namespace ripple

View File

@@ -61,22 +61,7 @@ getDeliveredAmount(
if (serializedTx->isFieldPresent(sfAmount))
{
using namespace std::chrono_literals;
// Ledger 4594095 is the first ledger in which the DeliveredAmount field
// was present when a partial payment was made and its absence indicates
// that the amount delivered is listed in the Amount field.
//
// If the ledger closed long after the DeliveredAmount code was deployed
// then its absence indicates that the amount delivered is listed in the
// Amount field. DeliveredAmount went live January 24, 2014.
// 446000000 is in Feb 2014, well after DeliveredAmount went live
if (getLedgerIndex() >= 4594095 ||
getCloseTime() > NetClock::time_point{446000000s} ||
(serializedTx && serializedTx->isFieldPresent(sfNetworkID)))
{
return serializedTx->getFieldAmount(sfAmount);
}
return serializedTx->getFieldAmount(sfAmount);
}
return {};

View File

@@ -256,6 +256,8 @@ BaseWSPeer<Handler, Impl>::close(
return post(strand_, [self = impl().shared_from_this(), reason] {
self->close(reason);
});
if (do_close_)
return;
do_close_ = true;
if (wq_.empty())
{

View File

@@ -5466,6 +5466,7 @@ private:
params[jss::transaction] = txIds[i];
auto const jrr = env.rpc("json", "tx", to_string(params));
auto const meta = jrr[jss::result][jss::meta];
BEAST_EXPECT(meta[jss::delivered_amount] == "1000000");
for (auto const& node : meta[sfAffectedNodes.jsonName])
{
auto const nodeType = node[sfLedgerEntryType.jsonName];

View File

@@ -3968,8 +3968,8 @@ struct XahauGenesis_test : public beast::unit_test::suite
using namespace std::chrono_literals;
testcase("test claim reward valid without unl report");
Env env{
*this, envconfig(), supported_amendments() - featureXahauGenesis};
Env env{*this, envconfig(), features - featureXahauGenesis};
bool const has240819 = env.current()->rules().enabled(fix240819);
double const rateDrops = 0.00333333333 * 1'000'000;
STAmount const feesXRP = XRP(1);
@@ -4050,7 +4050,12 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postUser = preUser + netReward;
BEAST_EXPECT(expectAccountFields(
env, user, preLedger, preLedger + 1, postUser, preTime));
env,
user,
preLedger,
preLedger + 1,
has240819 ? (preUser - feesXRP) : postUser,
preTime));
env(claimReward(user, env.master), fee(feesXRP), ter(tecHOOK_REJECTED));
env.close();
@@ -4095,7 +4100,12 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postUser1 = preUser1 + netReward1;
BEAST_EXPECT(expectAccountFields(
env, user, preLedger1, preLedger1 + 1, postUser1, preTime1));
env,
user,
preLedger1,
preLedger1 + 1,
has240819 ? (preUser1 - feesXRP) : postUser1,
preTime1));
}
void
@@ -4219,8 +4229,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postUser = preUser + netReward;
bool const has240819 = env.current()->rules().enabled(fix240819);
BEAST_EXPECT(expectAccountFields(
env, user, preLedger, preLedger + 1, postUser, preTime));
env,
user,
preLedger,
preLedger + 1,
has240819 ? (preUser - feesXRP) : postUser,
preTime));
}
void
@@ -4352,10 +4368,15 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postAlice = preAlice + netReward + l1Reward;
bool const boolResult = withXahauV1 ? true : false;
bool const has240819 = env.current()->rules().enabled(fix240819);
BEAST_EXPECT(
expectAccountFields(
env, alice, preLedger, preLedger + 1, postAlice, preTime) ==
boolResult);
env,
alice,
preLedger,
preLedger + 1,
has240819 ? (preAlice - feesXRP) : postAlice,
preTime) == boolResult);
}
}
@@ -4367,6 +4388,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
testcase("test claim reward optin optout");
Env env{*this, envconfig(), features - featureXahauGenesis};
bool const has240819 = env.current()->rules().enabled(fix240819);
double const rateDrops = 0.00333333333 * 1'000'000;
STAmount const feesXRP = XRP(1);
@@ -4436,7 +4458,12 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postUser = preUser + netReward;
BEAST_EXPECT(expectAccountFields(
env, user, preLedger, preLedger + 1, postUser, preTime));
env,
user,
preLedger,
preLedger + 1,
has240819 ? (preUser - feesXRP) : postUser,
preTime));
// opt out of claim rewards
env(claimReward(user, std::nullopt, 1), fee(feesXRP), ter(tesSUCCESS));
@@ -4461,7 +4488,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
user,
preLedger1,
preLedger1 + 1,
env.balance(user),
has240819 ? (env.balance(user) + feesXRP) : env.balance(user),
preTime1));
}
@@ -4543,8 +4570,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postUser = preUser + netReward;
bool const has240819 = env.current()->rules().enabled(fix240819);
BEAST_EXPECT(expectAccountFields(
env, user, preLedger, preLedger + 1, postUser, preTime));
env,
user,
preLedger,
has240819 ? preLedger : preLedger + 1,
has240819 ? (preUser - feesXRP) : postUser,
preTime));
}
void
@@ -4618,8 +4651,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postUser = preUser + netReward;
bool const has240819 = env.current()->rules().enabled(fix240819);
BEAST_EXPECT(expectAccountFields(
env, user, preLedger, preLedger + 1, postUser, preTime));
env,
user,
preLedger,
preLedger + 1,
has240819 ? (preUser - feesXRP) : postUser,
preTime));
}
void
@@ -4824,13 +4863,13 @@ struct XahauGenesis_test : public beast::unit_test::suite
Env env{
*this,
makeGenesisConfig(
supported_amendments() - featureXahauGenesis,
features - featureXahauGenesis,
21337,
"10",
"1000000",
"200000",
0),
supported_amendments() - featureXahauGenesis};
features - featureXahauGenesis};
STAmount const feesXRP = XRP(1);
@@ -4890,8 +4929,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
using namespace std::chrono_literals;
testcase("test compound interest over 12 claims");
Env env{
*this, envconfig(), supported_amendments() - featureXahauGenesis};
Env env{*this, envconfig(), features - featureXahauGenesis};
double const rateDrops = 0.00333333333 * 1'000'000;
STAmount const feesXRP = XRP(1);
@@ -4965,8 +5003,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
// validate account fields
STAmount const postUser = preUser + netReward;
bool const has240819 = env.current()->rules().enabled(fix240819);
BEAST_EXPECT(expectAccountFields(
env, user, preLedger, preLedger + 1, postUser, preTime));
env,
user,
preLedger,
preLedger + 1,
has240819 ? (preUser - feesXRP) : postUser,
preTime));
}
STAmount const endBal = env.balance(user);
@@ -5012,6 +5056,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
using namespace test::jtx;
auto const sa = supported_amendments();
testGovernHookWithFeats(sa);
testRewardHookWithFeats(sa - fix240819);
testRewardHookWithFeats(sa);
}
};

View File

@@ -23,7 +23,6 @@
#include <ripple/resource/Consumer.h>
#include <ripple/resource/impl/Entry.h>
#include <ripple/resource/impl/Logic.h>
#include <ripple/resource/impl/Tuning.h>
#include <test/unit_test/SuiteJournal.h>
#include <boost/utility/base_from_member.hpp>
@@ -43,8 +42,8 @@ public:
using clock_type = boost::base_from_member<TestStopwatch>;
public:
explicit TestLogic(Section const& section, beast::Journal journal)
: Logic(section, beast::insight::NullCollector::New(), member, journal)
explicit TestLogic(beast::Journal journal)
: Logic(beast::insight::NullCollector::New(), member, journal)
{
}
@@ -90,13 +89,9 @@ public:
else
testcase("Unlimited warn/drop");
auto const config = test::jtx::envconfig([](std::unique_ptr<Config> cfg) {
return cfg;
});
TestLogic logic(j);
TestLogic logic(config->section("resource"), j);
Charge const fee(Tuning::dropThreshold + 1);
Charge const fee(dropThreshold + 1);
beast::IP::Endpoint const addr(
beast::IP::Endpoint::from_string("192.0.2.2"));
@@ -178,7 +173,7 @@ public:
using namespace std::chrono_literals;
// Give Consumer time to become readmitted. Should never
// exceed expiration time.
auto n = Tuning::secondsUntilExpiration + 1s;
auto n = secondsUntilExpiration + 1s;
while (--n > 0s)
{
++logic.clock();
@@ -204,11 +199,7 @@ public:
{
testcase("Imports");
auto const config = test::jtx::envconfig([](std::unique_ptr<Config> cfg) {
return cfg;
});
TestLogic logic(config->section("resource"), j);
TestLogic logic(j);
Gossip g[5];
@@ -226,11 +217,7 @@ public:
{
testcase("Import");
auto const config = test::jtx::envconfig([](std::unique_ptr<Config> cfg) {
return cfg;
});
TestLogic logic(config->section("resource"), j);
TestLogic logic(j);
Gossip g;
Gossip::Item item;
@@ -249,11 +236,7 @@ public:
{
testcase("Charge");
auto const config = test::jtx::envconfig([](std::unique_ptr<Config> cfg) {
return cfg;
});
TestLogic logic(config->section("resource"), j);
TestLogic logic(j);
{
beast::IP::Endpoint address(
@@ -292,41 +275,6 @@ public:
pass();
}
void
testConfig(beast::Journal j)
{
std::cout << "warningThreshold: " << Tuning::warningThreshold << "\n";
std::cout << "dropThreshold: " << Tuning::dropThreshold << "\n";
std::cout << "getDecayWindowSeconds: " << Tuning::getDecayWindowSeconds() << "\n";
std::cout << "minimumGossipBalance: " << Tuning::minimumGossipBalance << "\n";
BEAST_EXPECT(Tuning::warningThreshold == 5000);
BEAST_EXPECT(Tuning::dropThreshold == 15000);
BEAST_EXPECT(Tuning::getDecayWindowSeconds() == 32);
BEAST_EXPECT(Tuning::minimumGossipBalance == 1000);
BEAST_EXPECT(Tuning::secondsUntilExpiration == std::chrono::seconds{300});
BEAST_EXPECT(Tuning::gossipExpirationSeconds == std::chrono::seconds{30});
auto const config = test::jtx::envconfig([](std::unique_ptr<Config> cfg) {
cfg->section("resource").set("warning_threshold", "15000");
cfg->section("resource").set("drop_threshold", "25000");
cfg->section("resource").set("minimum_gossip_balance", "2000");
cfg->section("resource").set("seconds_until_expiration", "600");
cfg->section("resource").set("gossip_expiration_seconds", "60");
return cfg;
});
TestLogic logic(config->section("resource"), j);
BEAST_EXPECT(Tuning::warningThreshold == 15000);
BEAST_EXPECT(Tuning::dropThreshold == 25000);
BEAST_EXPECT(Tuning::getDecayWindowSeconds() == 32);
BEAST_EXPECT(Tuning::minimumGossipBalance == 2000);
// BEAST_EXPECT(Tuning::secondsUntilExpiration == 600);
// BEAST_EXPECT(Tuning::gossipExpirationSeconds == 60);
}
void
run() override
{
@@ -338,7 +286,6 @@ public:
testCharges(journal);
testImports(journal);
testImport(journal);
testConfig(journal);
}
};

View File

@@ -191,80 +191,73 @@ class DeliveredAmount_test : public beast::unit_test::suite
auto const gw = Account("gateway");
auto const USD = gw["USD"];
for (bool const afterSwitchTime : {true, false})
Env env{*this, features};
env.fund(XRP(10000), alice, bob, carol, gw);
env.trust(USD(1000), alice, bob, carol);
env.close();
CheckDeliveredAmount checkDeliveredAmount{true};
{
Env env{*this, features};
env.fund(XRP(10000), alice, bob, carol, gw);
env.trust(USD(1000), alice, bob, carol);
if (afterSwitchTime)
env.close(NetClock::time_point{446000000s});
else
env.close();
// add payments, but do no close until subscribed
CheckDeliveredAmount checkDeliveredAmount{afterSwitchTime};
{
// add payments, but do no close until subscribed
// normal payments
env(pay(gw, alice, USD(50)));
checkDeliveredAmount.adjCountersSuccess();
env(pay(gw, alice, XRP(50)));
checkDeliveredAmount.adjCountersSuccess();
// normal payments
env(pay(gw, alice, USD(50)));
checkDeliveredAmount.adjCountersSuccess();
env(pay(gw, alice, XRP(50)));
checkDeliveredAmount.adjCountersSuccess();
// partial payment
env(pay(gw, bob, USD(9999999)), txflags(tfPartialPayment));
checkDeliveredAmount.adjCountersPartialPayment();
env.require(balance(bob, USD(1000)));
// partial payment
env(pay(gw, bob, USD(9999999)), txflags(tfPartialPayment));
checkDeliveredAmount.adjCountersPartialPayment();
env.require(balance(bob, USD(1000)));
// failed payment
env(pay(bob, carol, USD(9999999)), ter(tecPATH_PARTIAL));
checkDeliveredAmount.adjCountersFail();
env.require(balance(carol, USD(0)));
}
auto wsc = makeWSClient(env.app().config());
{
Json::Value stream;
// RPC subscribe to ledger stream
stream[jss::streams] = Json::arrayValue;
stream[jss::streams].append("ledger");
stream[jss::accounts] = Json::arrayValue;
stream[jss::accounts].append(toBase58(alice.id()));
stream[jss::accounts].append(toBase58(bob.id()));
stream[jss::accounts].append(toBase58(carol.id()));
auto jv = wsc->invoke("subscribe", stream);
if (wsc->version() == 2)
{
BEAST_EXPECT(
jv.isMember(jss::jsonrpc) && jv[jss::jsonrpc] == "2.0");
BEAST_EXPECT(
jv.isMember(jss::ripplerpc) &&
jv[jss::ripplerpc] == "2.0");
BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5);
}
BEAST_EXPECT(jv[jss::result][jss::ledger_index] == 3);
}
{
env.close();
// Check stream update
while (true)
{
auto const r = wsc->findMsg(1s, [&](auto const& jv) {
return jv[jss::ledger_index] == 4;
});
if (!r)
break;
if (!r->isMember(jss::transaction))
continue;
BEAST_EXPECT(checkDeliveredAmount.checkTxn(
(*r)[jss::transaction], (*r)[jss::meta]));
}
}
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
// failed payment
env(pay(bob, carol, USD(9999999)), ter(tecPATH_PARTIAL));
checkDeliveredAmount.adjCountersFail();
env.require(balance(carol, USD(0)));
}
auto wsc = makeWSClient(env.app().config());
{
Json::Value stream;
// RPC subscribe to ledger stream
stream[jss::streams] = Json::arrayValue;
stream[jss::streams].append("ledger");
stream[jss::accounts] = Json::arrayValue;
stream[jss::accounts].append(toBase58(alice.id()));
stream[jss::accounts].append(toBase58(bob.id()));
stream[jss::accounts].append(toBase58(carol.id()));
auto jv = wsc->invoke("subscribe", stream);
if (wsc->version() == 2)
{
BEAST_EXPECT(
jv.isMember(jss::jsonrpc) && jv[jss::jsonrpc] == "2.0");
BEAST_EXPECT(
jv.isMember(jss::ripplerpc) && jv[jss::ripplerpc] == "2.0");
BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5);
}
BEAST_EXPECT(jv[jss::result][jss::ledger_index] == 3);
}
{
env.close();
// Check stream update
while (true)
{
auto const r = wsc->findMsg(1s, [&](auto const& jv) {
return jv[jss::ledger_index] == 4;
});
if (!r)
break;
if (!r->isMember(jss::transaction))
continue;
BEAST_EXPECT(checkDeliveredAmount.checkTxn(
(*r)[jss::transaction], (*r)[jss::meta]));
}
}
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
}
void
testTxDeliveredAmountRPC(FeatureBitset features)
@@ -280,49 +273,41 @@ class DeliveredAmount_test : public beast::unit_test::suite
auto const gw = Account("gateway");
auto const USD = gw["USD"];
for (bool const afterSwitchTime : {true, false})
{
Env env{*this, features};
env.fund(XRP(10000), alice, bob, carol, gw);
env.trust(USD(1000), alice, bob, carol);
if (afterSwitchTime)
env.close(NetClock::time_point{446000000s});
else
env.close();
Env env{*this, features};
env.fund(XRP(10000), alice, bob, carol, gw);
env.trust(USD(1000), alice, bob, carol);
env.close();
CheckDeliveredAmount checkDeliveredAmount{afterSwitchTime};
// normal payments
env(pay(gw, alice, USD(50)));
checkDeliveredAmount.adjCountersSuccess();
env(pay(gw, alice, XRP(50)));
checkDeliveredAmount.adjCountersSuccess();
CheckDeliveredAmount checkDeliveredAmount{true};
// normal payments
env(pay(gw, alice, USD(50)));
checkDeliveredAmount.adjCountersSuccess();
env(pay(gw, alice, XRP(50)));
checkDeliveredAmount.adjCountersSuccess();
// partial payment
env(pay(gw, bob, USD(9999999)), txflags(tfPartialPayment));
checkDeliveredAmount.adjCountersPartialPayment();
env.require(balance(bob, USD(1000)));
// partial payment
env(pay(gw, bob, USD(9999999)), txflags(tfPartialPayment));
checkDeliveredAmount.adjCountersPartialPayment();
env.require(balance(bob, USD(1000)));
// failed payment
env(pay(gw, carol, USD(9999999)), ter(tecPATH_PARTIAL));
checkDeliveredAmount.adjCountersFail();
env.require(balance(carol, USD(0)));
// failed payment
env(pay(gw, carol, USD(9999999)), ter(tecPATH_PARTIAL));
checkDeliveredAmount.adjCountersFail();
env.require(balance(carol, USD(0)));
env.close();
std::string index;
Json::Value jvParams;
jvParams[jss::ledger_index] = 4u;
jvParams[jss::transactions] = true;
jvParams[jss::expand] = true;
auto const jtxn = env.rpc(
"json",
"ledger",
to_string(
jvParams))[jss::result][jss::ledger][jss::transactions];
for (auto const& t : jtxn)
BEAST_EXPECT(
checkDeliveredAmount.checkTxn(t, t[jss::metaData]));
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
}
env.close();
std::string index;
Json::Value jvParams;
jvParams[jss::ledger_index] = 4u;
jvParams[jss::transactions] = true;
jvParams[jss::expand] = true;
auto const jtxn = env.rpc(
"json",
"ledger",
to_string(jvParams))[jss::result][jss::ledger][jss::transactions];
for (auto const& t : jtxn)
BEAST_EXPECT(checkDeliveredAmount.checkTxn(t, t[jss::metaData]));
BEAST_EXPECT(checkDeliveredAmount.checkExpectedCounters());
}
public:

View File

@@ -276,11 +276,11 @@ class NoRippleCheckLimits_test : public beast::unit_test::suite
Endpoint::from_string(test::getEnvLocalhostAddr()));
// if we go above the warning threshold, reset
if (c.balance() > Tuning::warningThreshold)
if (c.balance() > warningThreshold)
{
using ct = beast::abstract_clock<steady_clock>;
c.entry().local_balance =
DecayingSample<Tuning::getDecayWindowSeconds(), ct>{steady_clock::now()};
DecayingSample<decayWindowSeconds, ct>{steady_clock::now()};
}
};

View File

@@ -57,7 +57,6 @@ public:
{
Env env(*this);
auto const result = env.rpc("server_definitions");
std::cout << "RESULT: " << result << "\n";
BEAST_EXPECT(!result[jss::result].isMember(jss::error));
BEAST_EXPECT(result[jss::result].isMember(jss::FIELDS));
BEAST_EXPECT(result[jss::result].isMember(jss::LEDGER_ENTRY_TYPES));