Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes baseFee, reserveBase, reserveIncrement to XRPAmount #3546

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ripple/app/ledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,16 @@ Ledger::setup(Config const& config)
// VFALCO NOTE Why getFieldIndex and not isFieldPresent?

if (sle->getFieldIndex(sfBaseFee) != -1)
fees_.base = sle->getFieldU64(sfBaseFee);
fees_.base = sle->getFieldAmount(sfBaseFee).xrp();

if (sle->getFieldIndex(sfReferenceFeeUnits) != -1)
fees_.units = sle->getFieldU32(sfReferenceFeeUnits);

if (sle->getFieldIndex(sfReserveBase) != -1)
fees_.reserve = sle->getFieldU32(sfReserveBase);
fees_.reserve = sle->getFieldAmount(sfReserveBase).xrp();

if (sle->getFieldIndex(sfReserveIncrement) != -1)
fees_.increment = sle->getFieldU32(sfReserveIncrement);
fees_.increment = sle->getFieldAmount(sfReserveIncrement).xrp();
}
}
catch (SHAMapMissingNode const&)
Expand Down
25 changes: 12 additions & 13 deletions src/ripple/app/misc/FeeVoteImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ FeeVoteImpl::doValidation(Fees const& lastFees, STValidation& v)
<< "Voting for base fee of " << target_.reference_fee;

if (auto const f = target_.reference_fee.dropsAs<std::uint64_t>())
v.setFieldU64(sfBaseFee, *f);
v.setFieldAmount(sfBaseFee, XRPAmount(*f));
}

if (lastFees.accountReserve(0) != target_.account_reserve)
Expand All @@ -131,7 +131,7 @@ FeeVoteImpl::doValidation(Fees const& lastFees, STValidation& v)
<< "Voting for base reserve of " << target_.account_reserve;

if (auto const f = target_.account_reserve.dropsAs<std::uint32_t>())
v.setFieldU32(sfReserveBase, *f);
v.setFieldAmount(sfReserveBase, XRPAmount(*f));
}

if (lastFees.increment != target_.owner_reserve)
Expand All @@ -140,7 +140,7 @@ FeeVoteImpl::doValidation(Fees const& lastFees, STValidation& v)
<< "Voting for reserve increment of " << target_.owner_reserve;

if (auto const f = target_.owner_reserve.dropsAs<std::uint32_t>())
v.setFieldU32(sfReserveIncrement, *f);
v.setFieldAmount(sfReserveIncrement, XRPAmount(*f));
}
}

Expand Down Expand Up @@ -169,11 +169,10 @@ FeeVoteImpl::doVoting(
if (val->isFieldPresent(sfBaseFee))
{
using xrptype = XRPAmount::value_type;
auto const vote = val->getFieldU64(sfBaseFee);
if (vote <= std::numeric_limits<xrptype>::max() &&
isLegalAmount(XRPAmount{unsafe_cast<xrptype>(vote)}))
baseFeeVote.addVote(
XRPAmount{unsafe_cast<XRPAmount::value_type>(vote)});
auto const vote = val->getFieldAmount(sfBaseFee).xrp();
if (vote.drops() <= std::numeric_limits<xrptype>::max() &&
isLegalAmount(vote))
baseFeeVote.addVote(vote);
else
// Invalid amounts will be treated as if they're
// not provided. Don't throw because this value is
Expand All @@ -188,7 +187,7 @@ FeeVoteImpl::doVoting(
if (val->isFieldPresent(sfReserveBase))
{
baseReserveVote.addVote(
XRPAmount{val->getFieldU32(sfReserveBase)});
val->getFieldAmount(sfReserveBase).xrp());
}
else
{
Expand All @@ -198,7 +197,7 @@ FeeVoteImpl::doVoting(
if (val->isFieldPresent(sfReserveIncrement))
{
incReserveVote.addVote(
XRPAmount{val->getFieldU32(sfReserveIncrement)});
val->getFieldAmount(sfReserveIncrement).xrp());
}
else
{
Expand Down Expand Up @@ -231,9 +230,9 @@ FeeVoteImpl::doVoting(
[seq, baseFee, baseReserve, incReserve, feeUnits](auto& obj) {
obj[sfAccount] = AccountID();
obj[sfLedgerSequence] = seq;
obj[sfBaseFee] = baseFee;
obj[sfReserveBase] = baseReserve;
obj[sfReserveIncrement] = incReserve;
obj[sfBaseFee] = XRPAmount(baseFee);
obj[sfReserveBase] = XRPAmount(baseReserve);
obj[sfReserveIncrement] = XRPAmount(incReserve);
obj[sfReferenceFeeUnits] = feeUnits.fee();
});

Expand Down
6 changes: 3 additions & 3 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2087,13 +2087,13 @@ NetworkOPsImp::pubValidation(std::shared_ptr<STValidation> const& val)
jvObj[jss::load_fee] = *loadFee;

if (auto const baseFee = (*val)[~sfBaseFee])
jvObj[jss::base_fee] = static_cast<double>(*baseFee);
jvObj[jss::base_fee] = (*baseFee).getJson(JsonOptions::none);

if (auto const reserveBase = (*val)[~sfReserveBase])
jvObj[jss::reserve_base] = *reserveBase;
jvObj[jss::reserve_base] = (*reserveBase).getJson(JsonOptions::none);

if (auto const reserveInc = (*val)[~sfReserveIncrement])
jvObj[jss::reserve_inc] = *reserveInc;
jvObj[jss::reserve_inc] = (*reserveInc).getJson(JsonOptions::none);

for (auto i = mStreamMaps[sValidations].begin();
i != mStreamMaps[sValidations].end();)
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/app/tx/impl/Change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ Change::applyFee()
view().insert(feeObject);
}

feeObject->setFieldU64(sfBaseFee, ctx_.tx.getFieldU64(sfBaseFee));
feeObject->setFieldAmount(sfBaseFee, ctx_.tx.getFieldAmount(sfBaseFee));
feeObject->setFieldU32(
sfReferenceFeeUnits, ctx_.tx.getFieldU32(sfReferenceFeeUnits));
feeObject->setFieldU32(sfReserveBase, ctx_.tx.getFieldU32(sfReserveBase));
feeObject->setFieldU32(
sfReserveIncrement, ctx_.tx.getFieldU32(sfReserveIncrement));
feeObject->setFieldAmount(sfReserveBase, ctx_.tx.getFieldAmount(sfReserveBase));
feeObject->setFieldAmount(
sfReserveIncrement, ctx_.tx.getFieldAmount(sfReserveIncrement));

view().update(feeObject);

Expand Down
6 changes: 3 additions & 3 deletions src/ripple/proto/org/xrpl/rpc/v1/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ message ReferenceFeeUnits
message ReserveBase
{
// in drops
uint32 value = 1;
CurrencyAmount value = 1;
}

message ReserveIncrement
{
// in drops
uint32 value = 1;
CurrencyAmount value = 1;
}

message Sequence
Expand Down Expand Up @@ -185,7 +185,7 @@ message TransferRate
message BaseFee
{
// in drops
uint64 value = 1 [jstype=JS_STRING];
CurrencyAmount value = 1;
}

message BookNode
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,6 @@ extern SF_U32 const sfLastLedgerSequence;
extern SF_U32 const sfTransactionIndex;
extern SF_U32 const sfOperationLimit;
extern SF_U32 const sfReferenceFeeUnits;
extern SF_U32 const sfReserveBase;
extern SF_U32 const sfReserveIncrement;
extern SF_U32 const sfSetFlag;
extern SF_U32 const sfClearFlag;
extern SF_U32 const sfSignerQuorum;
Expand All @@ -396,7 +394,6 @@ extern SF_U64 const sfIndexNext;
extern SF_U64 const sfIndexPrevious;
extern SF_U64 const sfBookNode;
extern SF_U64 const sfOwnerNode;
extern SF_U64 const sfBaseFee;
extern SF_U64 const sfExchangeRate;
extern SF_U64 const sfLowNode;
extern SF_U64 const sfHighNode;
Expand Down Expand Up @@ -447,6 +444,9 @@ extern SF_Amount const sfHighLimit;
extern SF_Amount const sfFee;
extern SF_Amount const sfSendMax;
extern SF_Amount const sfDeliverMin;
extern SF_Amount const sfBaseFee;
extern SF_Amount const sfReserveBase;
extern SF_Amount const sfReserveIncrement;

// currency amount (uncommon)
extern SF_Amount const sfMinimumOffer;
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/protocol/impl/SField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ SF_U32 const sfLastLedgerSequence(access, STI_UINT32, 27, "LastLedgerSequence");
SF_U32 const sfTransactionIndex(access, STI_UINT32, 28, "TransactionIndex");
SF_U32 const sfOperationLimit(access, STI_UINT32, 29, "OperationLimit");
SF_U32 const sfReferenceFeeUnits(access, STI_UINT32, 30, "ReferenceFeeUnits");
SF_U32 const sfReserveBase(access, STI_UINT32, 31, "ReserveBase");
SF_U32 const sfReserveIncrement(access, STI_UINT32, 32, "ReserveIncrement");
SF_U32 const sfSetFlag(access, STI_UINT32, 33, "SetFlag");
SF_U32 const sfClearFlag(access, STI_UINT32, 34, "ClearFlag");
SF_U32 const sfSignerQuorum(access, STI_UINT32, 35, "SignerQuorum");
Expand All @@ -123,7 +121,6 @@ SF_U64 const sfIndexNext(access, STI_UINT64, 1, "IndexNext");
SF_U64 const sfIndexPrevious(access, STI_UINT64, 2, "IndexPrevious");
SF_U64 const sfBookNode(access, STI_UINT64, 3, "BookNode");
SF_U64 const sfOwnerNode(access, STI_UINT64, 4, "OwnerNode");
SF_U64 const sfBaseFee(access, STI_UINT64, 5, "BaseFee");
SF_U64 const sfExchangeRate(access, STI_UINT64, 6, "ExchangeRate");
SF_U64 const sfLowNode(access, STI_UINT64, 7, "LowNode");
SF_U64 const sfHighNode(access, STI_UINT64, 8, "HighNode");
Expand Down Expand Up @@ -180,6 +177,9 @@ SF_Amount const sfHighLimit(access, STI_AMOUNT, 7, "HighLimit");
SF_Amount const sfFee(access, STI_AMOUNT, 8, "Fee");
SF_Amount const sfSendMax(access, STI_AMOUNT, 9, "SendMax");
SF_Amount const sfDeliverMin(access, STI_AMOUNT, 10, "DeliverMin");
SF_Amount const sfBaseFee(access, STI_AMOUNT, 11, "BaseFee");
SF_Amount const sfReserveBase(access, STI_AMOUNT, 12, "ReserveBase");
SF_Amount const sfReserveIncrement(access, STI_AMOUNT, 13, "ReserveIncrement");

// currency amount (uncommon)
SF_Amount const sfMinimumOffer(access, STI_AMOUNT, 16, "MinimumOffer");
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/rpc/impl/GRPCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ template <class T>
void
populateBaseFee(T& to, STObject const& from)
{
populateProtoPrimitive(
populateProtoAmount(
[&to]() { return to.mutable_base_fee(); }, from, sfBaseFee);
}

Expand All @@ -847,15 +847,15 @@ template <class T>
void
populateReserveBase(T& to, STObject const& from)
{
populateProtoPrimitive(
populateProtoAmount(
[&to]() { return to.mutable_reserve_base(); }, from, sfReserveBase);
}

template <class T>
void
populateReserveIncrement(T& to, STObject const& from)
{
populateProtoPrimitive(
populateProtoAmount(
[&to]() { return to.mutable_reserve_increment(); },
from,
sfReserveIncrement);
Expand Down
6 changes: 3 additions & 3 deletions src/test/app/PseudoTx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ struct PseudoTx_test : public beast::unit_test::suite
res.emplace_back(STTx(ttFEE, [&](auto& obj) {
obj[sfAccount] = AccountID();
obj[sfLedgerSequence] = seq;
obj[sfBaseFee] = 0;
obj[sfReserveBase] = 0;
obj[sfReserveIncrement] = 0;
obj[sfBaseFee] = STAmount();
obj[sfReserveBase] = STAmount();
obj[sfReserveIncrement] = STAmount();
obj[sfReferenceFeeUnits] = 0;
}));

Expand Down
2 changes: 1 addition & 1 deletion src/test/jtx/impl/Env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Env::close(
if (resp["result"]["status"] != std::string("success"))
{
JLOG(journal.error())
<< "Env::close() failed: " << resp["result"]["status"]
<< "Env::close() failed: " << resp
<< std::endl;
res = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/nodestore/DatabaseShard_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,8 @@ class DatabaseShard_test : public TestBase
{
using namespace test::jtx;

std::string ripemd160Key("4CFA8985836B549EC99D2E9705707F488DC91E4E"),
ripemd160Dat("8CC61F503C36339803F8C2FC652C1102DDB889F1");
std::string ripemd160Key("633EA054C1D6619B6B67B3BE4149829C0D49AC2A"),
ripemd160Dat("5CC8725822A017FDD62F7AAFD5052F4ADE7D8167");

for (int i = 0; i < 2; i++)
{
Expand Down