mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
bug fixes, but levelisation issues
This commit is contained in:
@@ -456,6 +456,7 @@ target_sources (rippled PRIVATE
|
|||||||
src/ripple/app/tx/impl/Import.cpp
|
src/ripple/app/tx/impl/Import.cpp
|
||||||
src/ripple/app/tx/impl/Invoke.cpp
|
src/ripple/app/tx/impl/Invoke.cpp
|
||||||
src/ripple/app/tx/impl/Remit.cpp
|
src/ripple/app/tx/impl/Remit.cpp
|
||||||
|
src/ripple/app/tx/impl/SetRemarks.cpp
|
||||||
src/ripple/app/tx/impl/SetSignerList.cpp
|
src/ripple/app/tx/impl/SetSignerList.cpp
|
||||||
src/ripple/app/tx/impl/SetTrust.cpp
|
src/ripple/app/tx/impl/SetTrust.cpp
|
||||||
src/ripple/app/tx/impl/SignerEntries.cpp
|
src/ripple/app/tx/impl/SignerEntries.cpp
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wasmedge/wasmedge.h>
|
#include <wasmedge/wasmedge.h>
|
||||||
|
#include <ripple/protocol/STAccount.h>
|
||||||
|
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
|
||||||
|
#include <ripple/protocol/TxFlags.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace ripple;
|
using namespace ripple;
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,18 @@ SetRemarks::preflight(PreflightContext const& ctx)
|
|||||||
return temMALFORMED;
|
return temMALFORMED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (auto const& remark : remarks)
|
for (auto const& remark : remarks)
|
||||||
{
|
{
|
||||||
|
if (remark.getFName() != sfRemark)
|
||||||
|
{
|
||||||
|
JLOG(j.warn()) << "Remarks: contained non-sfRemark field.";
|
||||||
|
return temMALFORMED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// will be checked by template system, extra check for security
|
||||||
|
if (!remark.isFieldPresent(sfRemarkName))
|
||||||
|
return temMALFORMED;
|
||||||
|
|
||||||
Blob const& name = remark.getFieldVL(sfRemarkName);
|
Blob const& name = remark.getFieldVL(sfRemarkName);
|
||||||
if (already_seen.find(name) != already_seen.end())
|
if (already_seen.find(name) != already_seen.end())
|
||||||
{
|
{
|
||||||
@@ -204,14 +213,14 @@ SetRemarks::preclaim(PreclaimContext const& ctx)
|
|||||||
if (!sleO)
|
if (!sleO)
|
||||||
return tecNO_TARGET;
|
return tecNO_TARGET;
|
||||||
|
|
||||||
std::optional<Account> issuer = getRemarksIssuer(sleO);
|
std::optional<AccountID> issuer = getRemarksIssuer(sleO);
|
||||||
|
|
||||||
if (!issuer || *issuer != id)
|
if (!issuer || *issuer != id)
|
||||||
return tecNO_PERMISSION;
|
return tecNO_PERMISSION;
|
||||||
|
|
||||||
// sanity check the remarks merge between txn and obj
|
// sanity check the remarks merge between txn and obj
|
||||||
|
|
||||||
auto const& remarksTxn = tx.getFieldArray(sfRemarks);
|
auto const& remarksTxn = ctx.tx.getFieldArray(sfRemarks);
|
||||||
|
|
||||||
std::map<Blob, std::pair<Blob, bool>> keys;
|
std::map<Blob, std::pair<Blob, bool>> keys;
|
||||||
if (sleO->isFieldPresent(sfRemarks))
|
if (sleO->isFieldPresent(sfRemarks))
|
||||||
@@ -220,9 +229,10 @@ SetRemarks::preclaim(PreclaimContext const& ctx)
|
|||||||
|
|
||||||
// map the remark name to its value and whether it's immutable
|
// map the remark name to its value and whether it's immutable
|
||||||
for (auto const& remark : remarksObj)
|
for (auto const& remark : remarksObj)
|
||||||
keys.emplace_back(remark.getFieldVL(sfRemarkName),
|
keys.emplace(
|
||||||
{remark.getFieldVL(sfRemarkValue),
|
std::make_pair(remark.getFieldVL(sfRemarkName),
|
||||||
remark.isFieldPresent(sfFlags) && remark.getFieldU32(sfFlags) & tfImmutable});
|
std::make_pair(remark.getFieldVL(sfRemarkValue),
|
||||||
|
remark.isFieldPresent(sfFlags) && remark.getFieldU32(sfFlags) & tfImmutable)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t count = keys.size();
|
int64_t count = keys.size();
|
||||||
@@ -258,7 +268,7 @@ SetRemarks::preclaim(PreclaimContext const& ctx)
|
|||||||
|
|
||||||
if (immutable)
|
if (immutable)
|
||||||
{
|
{
|
||||||
JLOG(j.warn())
|
JLOG(ctx.j.warn())
|
||||||
<< "Remarks: attempt to mutate an immutable remark.";
|
<< "Remarks: attempt to mutate an immutable remark.";
|
||||||
return tecIMMUTABLE;
|
return tecIMMUTABLE;
|
||||||
}
|
}
|
||||||
@@ -267,7 +277,7 @@ SetRemarks::preclaim(PreclaimContext const& ctx)
|
|||||||
{
|
{
|
||||||
if (--count < 0)
|
if (--count < 0)
|
||||||
{
|
{
|
||||||
JLOG(j.warn())
|
JLOG(ctx.j.warn())
|
||||||
<< "Remarks: insane remarks accounting.";
|
<< "Remarks: insane remarks accounting.";
|
||||||
return tecCLAIM;
|
return tecCLAIM;
|
||||||
}
|
}
|
||||||
@@ -276,7 +286,7 @@ SetRemarks::preclaim(PreclaimContext const& ctx)
|
|||||||
|
|
||||||
if (count > 32)
|
if (count > 32)
|
||||||
{
|
{
|
||||||
JLOG(j.warn())
|
JLOG(ctx.j.warn())
|
||||||
<< "Remarks: an object may have at most 32 remarks.";
|
<< "Remarks: an object may have at most 32 remarks.";
|
||||||
return tecTOO_MANY_REMARKS;
|
return tecTOO_MANY_REMARKS;
|
||||||
}
|
}
|
||||||
@@ -287,6 +297,8 @@ SetRemarks::preclaim(PreclaimContext const& ctx)
|
|||||||
TER
|
TER
|
||||||
SetRemarks::doApply()
|
SetRemarks::doApply()
|
||||||
{
|
{
|
||||||
|
auto j = ctx_.journal;
|
||||||
|
|
||||||
auto const sle = view().peek(keylet::account(account_));
|
auto const sle = view().peek(keylet::account(account_));
|
||||||
if (!sle)
|
if (!sle)
|
||||||
return tefINTERNAL;
|
return tefINTERNAL;
|
||||||
@@ -296,9 +308,9 @@ SetRemarks::doApply()
|
|||||||
if (!sleO)
|
if (!sleO)
|
||||||
return tecNO_TARGET;
|
return tecNO_TARGET;
|
||||||
|
|
||||||
std::optional<Account> issuer = getRemarksIssuer(sleO);
|
std::optional<AccountID> issuer = getRemarksIssuer(sleO);
|
||||||
|
|
||||||
if (!issuer || *issuer != id)
|
if (!issuer || *issuer != account_)
|
||||||
return tecNO_PERMISSION;
|
return tecNO_PERMISSION;
|
||||||
|
|
||||||
auto const& remarksTxn = ctx_.tx.getFieldArray(sfRemarks);
|
auto const& remarksTxn = ctx_.tx.getFieldArray(sfRemarks);
|
||||||
@@ -338,7 +350,7 @@ SetRemarks::doApply()
|
|||||||
|
|
||||||
if (remarksMap.find(name) == remarksMap.end())
|
if (remarksMap.find(name) == remarksMap.end())
|
||||||
{
|
{
|
||||||
remarksMap[name] = {name, {*val, setImmutable}};
|
remarksMap[name] = std::make_pair(*val, setImmutable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,22 +376,30 @@ SetRemarks::doApply()
|
|||||||
if (remarksMap[k].second & tfImmutable)
|
if (remarksMap[k].second & tfImmutable)
|
||||||
remark.setFieldU32(sfFlags, lsfImmutable);
|
remark.setFieldU32(sfFlags, lsfImmutable);
|
||||||
|
|
||||||
newRemarks.push_back(std::map(remark));
|
newRemarks.push_back(std::move(remark));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newRemarks.size() > 32)
|
if (newRemarks.size() > 32)
|
||||||
return tecINTERNAL;
|
return tecINTERNAL;
|
||||||
|
|
||||||
if (newRemarks.empty() && sleO->isFieldPresent(sfRemarks))
|
if (newRemarks.empty() && sleO->isFieldPresent(sfRemarks))
|
||||||
sleO.makeFieldAbsent(sfRemarks);
|
sleO->makeFieldAbsent(sfRemarks);
|
||||||
else
|
else
|
||||||
sleO.setFieldArray(sfRemarks, std::move(newRemarks));
|
sleO->setFieldArray(sfRemarks, std::move(newRemarks));
|
||||||
|
|
||||||
view.update(sleO);
|
view().update(sleO);
|
||||||
|
|
||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RH TODO: transaction fee needs to charge for remarks, in particular because they are not ownercounted.
|
XRPAmount
|
||||||
|
calculateBaseFee(ReadView const& view, STTx const& tx)
|
||||||
|
{
|
||||||
|
// RH TODO: transaction fee needs to charge for remarks, in particular because they are not ownercounted.
|
||||||
|
auto fee = Transactor::calculateBaseFee(view, tx);
|
||||||
|
return fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace ripple
|
} // namespace ripple
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ invoke_preflight(PreflightContext const& ctx)
|
|||||||
case ttREMIT:
|
case ttREMIT:
|
||||||
return invoke_preflight_helper<Remit>(ctx);
|
return invoke_preflight_helper<Remit>(ctx);
|
||||||
case ttREMARKS_SET:
|
case ttREMARKS_SET:
|
||||||
return invoke_preflight_helper<Remarks>(ctx);
|
return invoke_preflight_helper<SetRemarks>(ctx);
|
||||||
case ttURITOKEN_MINT:
|
case ttURITOKEN_MINT:
|
||||||
case ttURITOKEN_BURN:
|
case ttURITOKEN_BURN:
|
||||||
case ttURITOKEN_BUY:
|
case ttURITOKEN_BUY:
|
||||||
@@ -291,7 +291,7 @@ invoke_preclaim(PreclaimContext const& ctx)
|
|||||||
case ttREMIT:
|
case ttREMIT:
|
||||||
return invoke_preclaim<Remit>(ctx);
|
return invoke_preclaim<Remit>(ctx);
|
||||||
case ttREMARKS_SET:
|
case ttREMARKS_SET:
|
||||||
return invoke_preclaim<Remarks>(ctx);
|
return invoke_preclaim<SetRemarks>(ctx);
|
||||||
case ttURITOKEN_MINT:
|
case ttURITOKEN_MINT:
|
||||||
case ttURITOKEN_BURN:
|
case ttURITOKEN_BURN:
|
||||||
case ttURITOKEN_BUY:
|
case ttURITOKEN_BUY:
|
||||||
@@ -376,7 +376,7 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx)
|
|||||||
case ttREMIT:
|
case ttREMIT:
|
||||||
return Remit::calculateBaseFee(view, tx);
|
return Remit::calculateBaseFee(view, tx);
|
||||||
case ttREMARKS_SET:
|
case ttREMARKS_SET:
|
||||||
return Remarks::calculateBaseFee(view, tx);
|
return SetRemarks::calculateBaseFee(view, tx);
|
||||||
case ttURITOKEN_MINT:
|
case ttURITOKEN_MINT:
|
||||||
case ttURITOKEN_BURN:
|
case ttURITOKEN_BURN:
|
||||||
case ttURITOKEN_BUY:
|
case ttURITOKEN_BUY:
|
||||||
@@ -561,7 +561,7 @@ invoke_apply(ApplyContext& ctx)
|
|||||||
return p();
|
return p();
|
||||||
}
|
}
|
||||||
case ttREMARKS_SET: {
|
case ttREMARKS_SET: {
|
||||||
Remarks p(ctx);
|
SetRemarks p(ctx);
|
||||||
return p();
|
return p();
|
||||||
}
|
}
|
||||||
case ttURITOKEN_MINT:
|
case ttURITOKEN_MINT:
|
||||||
|
|||||||
@@ -315,6 +315,9 @@ enum LedgerSpecificFlags {
|
|||||||
|
|
||||||
// ltURI_TOKEN
|
// ltURI_TOKEN
|
||||||
lsfBurnable = 0x00000001, // True, issuer can burn the token
|
lsfBurnable = 0x00000001, // True, issuer can burn the token
|
||||||
|
|
||||||
|
// remarks
|
||||||
|
lsfImmutable = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -538,6 +538,8 @@ extern SF_VL const sfHookReturnString;
|
|||||||
extern SF_VL const sfHookParameterName;
|
extern SF_VL const sfHookParameterName;
|
||||||
extern SF_VL const sfHookParameterValue;
|
extern SF_VL const sfHookParameterValue;
|
||||||
extern SF_VL const sfBlob;
|
extern SF_VL const sfBlob;
|
||||||
|
extern SF_VL const sfRemarkName;
|
||||||
|
extern SF_VL const sfRemarkValue;
|
||||||
|
|
||||||
// account
|
// account
|
||||||
extern SF_ACCOUNT const sfAccount;
|
extern SF_ACCOUNT const sfAccount;
|
||||||
@@ -595,6 +597,7 @@ extern SField const sfImportVLKey;
|
|||||||
extern SField const sfHookEmission;
|
extern SField const sfHookEmission;
|
||||||
extern SField const sfMintURIToken;
|
extern SField const sfMintURIToken;
|
||||||
extern SField const sfAmountEntry;
|
extern SField const sfAmountEntry;
|
||||||
|
extern SField const sfRemark;
|
||||||
|
|
||||||
// array of objects (common)
|
// array of objects (common)
|
||||||
// ARRAY/1 is reserved for end of array
|
// ARRAY/1 is reserved for end of array
|
||||||
@@ -623,6 +626,7 @@ extern SField const sfActiveValidators;
|
|||||||
extern SField const sfImportVLKeys;
|
extern SField const sfImportVLKeys;
|
||||||
extern SField const sfHookEmissions;
|
extern SField const sfHookEmissions;
|
||||||
extern SField const sfAmounts;
|
extern SField const sfAmounts;
|
||||||
|
extern SField const sfRemarks;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ JSS(Remit); // transaction type.
|
|||||||
JSS(RippleState); // ledger type.
|
JSS(RippleState); // ledger type.
|
||||||
JSS(SLE_hit_rate); // out: GetCounts.
|
JSS(SLE_hit_rate); // out: GetCounts.
|
||||||
JSS(SetFee); // transaction type.
|
JSS(SetFee); // transaction type.
|
||||||
|
JSS(SetRemarks); // transaction type
|
||||||
JSS(UNLModify); // transaction type.
|
JSS(UNLModify); // transaction type.
|
||||||
JSS(UNLReport); // transaction type.
|
JSS(UNLReport); // transaction type.
|
||||||
JSS(SettleDelay); // in: TransactionSign
|
JSS(SettleDelay); // in: TransactionSign
|
||||||
|
|||||||
Reference in New Issue
Block a user