20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/app/main/Application.h>
22 #include <ripple/app/misc/AmendmentTable.h>
23 #include <ripple/app/misc/NetworkOPs.h>
24 #include <ripple/app/tx/impl/Change.h>
25 #include <ripple/basics/Log.h>
26 #include <ripple/ledger/Sandbox.h>
27 #include <ripple/protocol/Feature.h>
28 #include <ripple/protocol/Indexes.h>
29 #include <ripple/protocol/TxFlags.h>
42 if (account != beast::zero)
44 JLOG(ctx.
j.
warn()) <<
"Change: Bad source id";
50 if (!fee.native() || fee != beast::zero)
52 JLOG(ctx.
j.
warn()) <<
"Change: invalid fee";
59 JLOG(ctx.
j.
warn()) <<
"Change: Bad signature";
66 JLOG(ctx.
j.
warn()) <<
"Change: Bad sequence";
73 JLOG(ctx.
j.
warn()) <<
"Change: NegativeUNL not enabled";
87 JLOG(ctx.
j.
warn()) <<
"Change transaction against open ledger";
166 JLOG(
j_.
warn()) <<
"fixTrustLinesToSelf amendment activation code starting";
173 JLOG(
j_.
warn()) <<
id <<
": Unable to locate trustline";
179 JLOG(
j_.
warn()) <<
id <<
": Unexpected type "
184 auto const& lo = tl->getFieldAmount(
sfLowLimit);
189 JLOG(
j_.
warn()) <<
id <<
": Trustline doesn't meet requirements";
196 JLOG(
j_.
error()) <<
id <<
": failed to remove low entry from "
197 <<
toBase58(lo.getIssuer()) <<
":" << page
198 <<
" owner directory";
205 JLOG(
j_.
error()) <<
id <<
": failed to remove high entry from "
206 <<
toBase58(hi.getIssuer()) <<
":" << page
207 <<
" owner directory";
221 JLOG(
j_.
warn()) <<
"Successfully deleted trustline " << id;
226 using namespace std::literals;
230 if (removeTrustLineToSelf(
233 "2F8F21EFCAFD7ACFB07D5BB04F0D2E18587820C7611305BB674A64EAB0FA71E1"sv}) &&
234 removeTrustLineToSelf(
237 "326035D5C0560A9DA8636545DD5A1B0DFCFF63E68D491B5522B767BB00564B1A"sv}))
239 JLOG(
j_.
warn()) <<
"fixTrustLinesToSelf amendment activation code "
240 "executed successfully";
254 if (!amendmentObject)
256 amendmentObject = std::make_shared<SLE>(k);
262 if (
std::find(amendments.begin(), amendments.end(), amendment) !=
271 if (gotMajority && lostMajority)
281 for (
auto const& majority : oldMajorities)
283 if (majority.getFieldH256(
sfAmendment) == amendment)
297 if (!found && lostMajority)
304 auto& entry = newMajorities.
back();
311 JLOG(
j_.
warn()) <<
"Unsupported amendment " << amendment
312 <<
" received a majority.";
315 else if (!lostMajority)
318 amendments.push_back(amendment);
319 amendmentObject->setFieldV256(
sfAmendments, amendments);
328 JLOG(
j_.
error()) <<
"Unsupported amendment " << amendment
329 <<
" activated: server blocked.";
334 if (newMajorities.
empty())
337 amendmentObject->setFieldArray(
sfMajorities, newMajorities);
353 feeObject = std::make_shared<SLE>(k);
357 feeObject->at(field) = tx[field];
380 JLOG(
j_.
warn()) <<
"Fees have been changed";
389 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, not a flag ledger, seq="
399 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, wrong Tx format.";
405 if (seq !=
view().seq())
407 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, wrong ledger seq=" << seq;
414 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, bad validator key";
418 JLOG(
j_.
info()) <<
"N-UNL: applyUNLModify, "
419 << (disabling ?
"ToDisable" :
"ToReEnable")
421 <<
" validator data:" <<
strHex(validator);
427 negUnlObject = std::make_shared<SLE>(k);
431 bool const found = [&] {
436 for (
auto const& v : negUnl)
451 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, already has ToDisable";
461 <<
"N-UNL: applyUNLModify, ToDisable is same as ToReEnable";
470 <<
"N-UNL: applyUNLModify, ToDisable already in negative UNL";
481 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, already has ToReEnable";
491 <<
"N-UNL: applyUNLModify, ToReEnable is same as ToDisable";
500 <<
"N-UNL: applyUNLModify, ToReEnable is not in negative UNL";
TxType getTxnType() const
constexpr std::uint32_t tfGotMajority
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
bool isFlagLedger(LedgerIndex seq)
Returns true if the given ledgerIndex is a flag ledgerIndex.
const SF_VL sfUNLModifyValidator
constexpr std::uint32_t tfLostMajority
const SF_AMOUNT sfBaseFeeDrops
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
const SF_UINT32 sfReserveBase
const uint256 featureXRPFees
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Keylet const & amendments() noexcept
The index of the amendment table.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
const SF_UINT32 sfLedgerSequence
const SF_UINT32 sfSequence
virtual AmendmentTable & getAmendmentTable()=0
STInteger< std::uint32_t > STUInt32
unsigned char getFieldU8(SField const &field) const
@ ttFEE
This system-generated transaction type is used to update the network's fee settings.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
void push_back(STObject const &object)
void preCompute() override
virtual void setAmendmentBlocked()=0
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
const SF_UINT32 sfCloseTime
Blob getFieldVL(SField const &field) const
@ ttAMENDMENT
This system-generated transaction type is used to update the status of the various amendments.
virtual NetworkOPs & getOPs()=0
STBitString< 256 > STUInt256
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
const SF_UINT64 sfLowNode
const SF_AMOUNT sfLowLimit
NotTEC preflight0(PreflightContext const &ctx)
Performs early sanity checks on the txid.
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
@ ttUNL_MODIFY
This system-generated transaction type is used to update the network's negative UNL.
Keylet account(AccountID const &id) noexcept
AccountID root.
AccountID getAccountID(SField const &field) const
const SF_UINT32 sfReserveIncrement
Discardable, editable view to a ledger.
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
const SF_VL sfValidatorToDisable
std::uint32_t getFlags() const
Blob getSigningPubKey() const
const SF_UINT256 sfPreviousTxnID
const SF_AMOUNT sfHighLimit
virtual bool enable(uint256 const &amendment)=0
const SF_AMOUNT sfReserveIncrementDrops
const SF_AMOUNT sfReserveBaseDrops
const uint256 fixTrustLinesToSelf
const SF_UINT8 sfUNLModifyDisabling
static TER preclaim(PreclaimContext const &ctx)
virtual bool isSupported(uint256 const &amendment) const =0
State information when determining if a tx is likely to claim a fee.
const SF_UINT64 sfBaseFee
void erase(std::shared_ptr< SLE > const &sle) override
Remove a peeked SLE.
std::size_t emplace_back(Args &&... args)
static NotTEC preflight(PreflightContext const &ctx)
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
Blob getSignature() const
virtual Rules const & rules() const =0
Returns the tx processing rules.
const uint256 featureNegativeUNL
bool isFieldPresent(SField const &field) const
const SF_UINT32 sfReferenceFeeUnits
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
const SF_ACCOUNT sfAccount
@ ltRIPPLE_STATE
A ledger object which describes a bidirectional trust line.
std::shared_ptr< SLE > peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
std::string strHex(FwdIt begin, FwdIt end)
void activateTrustLinesToSelfFix()
std::uint32_t getFieldU32(SField const &field) const
State information when preflighting a tx.
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
const SF_UINT256 sfAmendment
const SField sfMajorities
virtual bool open() const =0
Returns true if this reflects an open ledger.
const SField sfDisabledValidators
const SF_UINT64 sfHighNode
STAmount const & getFieldAmount(SField const &field) const
const SF_VECTOR256 sfAmendments
const SF_VL sfValidatorToReEnable
TERSubset< CanCvtToNotTEC > NotTEC
uint256 getFieldH256(SField const &field) const