Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion include/xrpl/protocol/Indexes.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ signers(AccountID const& account) noexcept;

/** A Sponsorship */
Keylet
sponsor(AccountID const& sponsor, AccountID const& sponsee) noexcept;
sponsorship(AccountID const& sponsor, AccountID const& sponsee) noexcept;
Comment thread
mvadari marked this conversation as resolved.

/** A Check */
/** @{ */
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/protocol/detail/ledger_entries.macro
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ LEDGER_ENTRY(ltSPONSORSHIP, 0x0090, Sponsorship, sponsorship, ({
{sfSponsee, SoeRequired},
{sfFeeAmount, SoeOptional},
{sfMaxFee, SoeOptional},
{sfReserveCount, SoeDefault},
{sfRemainingOwnerCount, SoeDefault},
{sfOwnerNode, SoeRequired},
{sfSponseeNode, SoeRequired},
}))
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/protocol/detail/sfields.macro
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ TYPED_SFIELD(sfOverpaymentInterestRate, UINT32, 68) // 1/10 basis points (bi
TYPED_SFIELD(sfSponsoredOwnerCount, UINT32, 69)
TYPED_SFIELD(sfSponsoringOwnerCount, UINT32, 70)
TYPED_SFIELD(sfSponsoringAccountCount, UINT32, 71)
TYPED_SFIELD(sfReserveCount, UINT32, 72)
TYPED_SFIELD(sfRemainingOwnerCount, UINT32, 72)
TYPED_SFIELD(sfSponsorFlags, UINT32, 73)
Comment thread
mvadari marked this conversation as resolved.

// 64-bit integers (common)
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/protocol/detail/transactions.macro
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ TRANSACTION(ttSPONSORSHIP_SET, 86, SponsorshipSet,
{sfSponsee, SoeOptional},
{sfFeeAmount, SoeOptional},
{sfMaxFee, SoeOptional},
{sfReserveCount, SoeOptional},
{sfRemainingOwnerCount, SoeOptional},
}))

/** This system-generated transaction type is used to update the status of the various amendments.
Expand Down
12 changes: 6 additions & 6 deletions include/xrpl/protocol_autogen/ledger_entries/Sponsorship.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,27 @@ class Sponsorship : public LedgerEntryBase
}

/**
* @brief Get sfReserveCount (SoeDefault)
* @brief Get sfRemainingOwnerCount (SoeDefault)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getReserveCount() const
{
if (hasReserveCount())
return this->sle_->at(sfReserveCount);
return this->sle_->at(sfRemainingOwnerCount);
return std::nullopt;
}

/**
* @brief Check if sfReserveCount is present.
* @brief Check if sfRemainingOwnerCount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasReserveCount() const
{
return this->sle_->isFieldPresent(sfReserveCount);
return this->sle_->isFieldPresent(sfRemainingOwnerCount);
}

/**
Expand Down Expand Up @@ -297,13 +297,13 @@ class SponsorshipBuilder : public LedgerEntryBuilderBase<SponsorshipBuilder>
}

/**
* @brief Set sfReserveCount (SoeDefault)
* @brief Set sfRemainingOwnerCount (SoeDefault)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setReserveCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfReserveCount] = value;
object_[sfRemainingOwnerCount] = value;
return *this;
}

Expand Down
12 changes: 6 additions & 6 deletions include/xrpl/protocol_autogen/transactions/SponsorshipSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class SponsorshipSet : public TransactionBase
}

/**
* @brief Get sfReserveCount (SoeOptional)
* @brief Get sfRemainingOwnerCount (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
Expand All @@ -161,20 +161,20 @@ class SponsorshipSet : public TransactionBase
{
if (hasReserveCount())
{
return this->tx_->at(sfReserveCount);
return this->tx_->at(sfRemainingOwnerCount);
}
return std::nullopt;
}

/**
* @brief Check if sfReserveCount is present.
* @brief Check if sfRemainingOwnerCount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasReserveCount() const
{
return this->tx_->isFieldPresent(sfReserveCount);
return this->tx_->isFieldPresent(sfRemainingOwnerCount);
}
};

Expand Down Expand Up @@ -263,13 +263,13 @@ class SponsorshipSetBuilder : public TransactionBuilderBase<SponsorshipSetBuilde
}

/**
* @brief Set sfReserveCount (SoeOptional)
* @brief Set sfRemainingOwnerCount (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipSetBuilder&
setReserveCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfReserveCount] = value;
object_[sfRemainingOwnerCount] = value;
return *this;
}

Expand Down
9 changes: 5 additions & 4 deletions src/libxrpl/ledger/helpers/AccountRootHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ adjustOwnerCount(
adjustOwnerCountHlp(view, accountSle, sfSponsoredOwnerCount, accountID, adjustment, j);
adjustOwnerCountHlp(view, sponsorSle, sfSponsoringOwnerCount, sponsorID, adjustment, j);

auto sponsorObjSle = view.peek(keylet::sponsor(sponsorID, accountID));
auto sponsorObjSle = view.peek(keylet::sponsorship(sponsorID, accountID));
if (sponsorObjSle && adjustment > 0)
{
// update the pre-funded ReserveCount on Sponsorship ledger object
// Reserve count moves opposite to adjustment: +adjustment => consume reserve (-),
adjustOwnerCountHlp(
Comment thread
Copilot marked this conversation as resolved.
Outdated
view, sponsorObjSle, sfReserveCount, sponsorID, -adjustment, j, false);
view, sponsorObjSle, sfRemainingOwnerCount, sponsorID, -adjustment, j, false);
Comment thread
mvadari marked this conversation as resolved.
}
}
adjustOwnerCountHlp(view, accountSle, sfOwnerCount, accountID, adjustment, j);
Expand Down Expand Up @@ -345,15 +345,16 @@ checkInsufficientReserve(
auto const isCoSigning = isSponsorReserveCoSigning(tx);

auto const sle = view.read(
keylet::sponsor(sponsorSle->getAccountID(sfAccount), accSle->getAccountID(sfAccount)));
keylet::sponsorship(
sponsorSle->getAccountID(sfAccount), accSle->getAccountID(sfAccount)));

// prefunded sponsor should have a sponsorship entry
if (!isCoSigning && !sle)
return tecINTERNAL; // LCOV_EXCL_LINE

if (sle)
{
auto const ownerCountAllowed = sle->getFieldU32(sfReserveCount);
auto const ownerCountAllowed = sle->getFieldU32(sfRemainingOwnerCount);
if (ownerCountAllowed < ownerCountDelta)
return tecINSUFFICIENT_RESERVE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/protocol/Indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ signers(AccountID const& account) noexcept
}

Keylet
sponsor(AccountID const& sponsor, AccountID const& sponsee) noexcept
sponsorship(AccountID const& sponsor, AccountID const& sponsee) noexcept
{
return {ltSPONSORSHIP, indexHash(LedgerNameSpace::Sponsorship, sponsor, sponsee)};
}
Comment thread
mvadari marked this conversation as resolved.
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/tx/Transactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ Transactor::checkSponsor(ReadView const& view, STTx const& tx)
return tesSUCCESS;

auto const sponsorshipSle =
view.read(keylet::sponsor(tx.getAccountID(sfSponsor), tx.getAccountID(sfAccount)));
view.read(keylet::sponsorship(tx.getAccountID(sfSponsor), tx.getAccountID(sfAccount)));

// sponsorship object missing for pre-funded tx
if (!sponsorshipSle)
Expand Down Expand Up @@ -1322,7 +1322,7 @@ Transactor::getFeePayer(ReadView const& view, STTx const& tx)
auto const sponsorAccountID = tx.getAccountID(sfSponsor);
auto const sponseeAccountID = tx.getAccountID(sfAccount);
auto const hasSponsorSignature = tx.isFieldPresent(sfSponsorSignature);
auto const sponsorshipKeylet = keylet::sponsor(sponsorAccountID, sponseeAccountID);
auto const sponsorshipKeylet = keylet::sponsorship(sponsorAccountID, sponseeAccountID);

// if pre-funded sponsorship exists, prefer it
if (hasSponsorSignature && !view.exists(sponsorshipKeylet))
Expand Down
15 changes: 8 additions & 7 deletions src/libxrpl/tx/transactors/Sponsor/SponsorshipSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SponsorshipSet::preflight(PreflightContext const& ctx)
return temINVALID_FLAG;

// can not include these fields when deleting
if (ctx.tx.isFieldPresent(sfFeeAmount) || ctx.tx.isFieldPresent(sfReserveCount) ||
if (ctx.tx.isFieldPresent(sfFeeAmount) || ctx.tx.isFieldPresent(sfRemainingOwnerCount) ||
ctx.tx.isFieldPresent(sfMaxFee))
return temMALFORMED;
}
Expand Down Expand Up @@ -133,7 +133,7 @@ SponsorshipSet::checkPermission(ReadView const& view, STTx const& tx)
auto const sponsoringFee = tx.isFieldPresent(sfFeeAmount) || tx.isFieldPresent(sfMaxFee) ||
((txFlags & (tfSponsorshipSetRequireSignForFee | tfSponsorshipClearRequireSignForFee)) !=
0u);
auto const sponsoringReserve = tx.isFieldPresent(sfReserveCount) ||
auto const sponsoringReserve = tx.isFieldPresent(sfRemainingOwnerCount) ||
((txFlags &
(tfSponsorshipSetRequireSignForReserve | tfSponsorshipClearRequireSignForReserve)) != 0u);

Expand Down Expand Up @@ -170,7 +170,8 @@ SponsorshipSet::preclaim(PreclaimContext const& ctx)
return tecNO_PERMISSION;

// check if object exists
auto const sponsorObjSle = ctx.view.read(keylet::sponsor(sponsorAccountID, sponseeAccountID));
auto const sponsorObjSle =
ctx.view.read(keylet::sponsorship(sponsorAccountID, sponseeAccountID));

if (ctx.tx.isFlag(tfDeleteObject) && !sponsorObjSle)
return tecNO_ENTRY;
Expand Down Expand Up @@ -235,7 +236,7 @@ SponsorshipSet::doApply()
if (!ctx_.view().exists(keylet::account(sponseeAccountID)))
return tecINTERNAL; // LCOV_EXCL_LINE

auto const sponsorKeylet = keylet::sponsor(sponsorAccountID, sponseeAccountID);
auto const sponsorKeylet = keylet::sponsorship(sponsorAccountID, sponseeAccountID);
auto const sponsorObjSle = ctx_.view().peek(sponsorKeylet);

if (ctx_.tx.isFlag(tfDeleteObject))
Expand All @@ -249,7 +250,7 @@ SponsorshipSet::doApply()

auto const feeAmount = ctx_.tx[~sfFeeAmount];
auto const maxFee = ctx_.tx[~sfMaxFee];
auto const reserveCount = ctx_.tx[~sfReserveCount];
auto const reserveCount = ctx_.tx[~sfRemainingOwnerCount];

auto reserveSponsorAccSle = getTxReserveSponsor(view(), ctx_.tx);
if (!reserveSponsorAccSle)
Expand Down Expand Up @@ -286,7 +287,7 @@ SponsorshipSet::doApply()
if (maxFee && *maxFee > XRPAmount(0))
(*newSle)[sfMaxFee] = *maxFee;
if (reserveCount && *reserveCount > 0)
(*newSle)[sfReserveCount] = *reserveCount;
(*newSle)[sfRemainingOwnerCount] = *reserveCount;

auto flags = 0;
if (ctx_.tx.isFlag(tfSponsorshipSetRequireSignForFee))
Expand Down Expand Up @@ -367,7 +368,7 @@ SponsorshipSet::doApply()
}

if (reserveCount)
sponsorObjSle->at(sfReserveCount) = *reserveCount;
sponsorObjSle->at(sfRemainingOwnerCount) = *reserveCount;

// update Flags
auto flags = sponsorObjSle->getFieldU32(sfFlags);
Expand Down
7 changes: 4 additions & 3 deletions src/libxrpl/tx/transactors/Sponsor/SponsorshipTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,21 @@ reduceReserveCount(
if (delta > 0)
return tefINTERNAL; // LCOV_EXCL_LINE

auto const sponsorKeylet = keylet::sponsor(sponsor, account);
auto const sponsorKeylet = keylet::sponsorship(sponsor, account);
auto const sponsorSle = view.peek(sponsorKeylet);
if (!sponsorSle)
return tefINTERNAL; // LCOV_EXCL_LINE

auto const afterReserveCount = applyCountDelta(sponsorSle->getFieldU32(sfReserveCount), delta);
auto const afterReserveCount =
applyCountDelta(sponsorSle->getFieldU32(sfRemainingOwnerCount), delta);
if (!afterReserveCount)
{
// already checked in preclaim()
UNREACHABLE("xrpl::reduceReserveCount : invalid reserve count");
return tefINTERNAL; // LCOV_EXCL_LINE
}

sponsorSle->at(sfReserveCount) = *afterReserveCount;
sponsorSle->at(sfRemainingOwnerCount) = *afterReserveCount;
view.update(sponsorSle);
return tesSUCCESS;
}
Expand Down
Loading
Loading