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/protocol/Feature.h>
27 #include <ripple/protocol/Indexes.h>
28 #include <ripple/protocol/TxFlags.h>
40 if (account != beast::zero)
42 JLOG(ctx.
j.
warn()) <<
"Change: Bad source id";
48 if (!fee.native() || fee != beast::zero)
50 JLOG(ctx.
j.
warn()) <<
"Change: invalid fee";
57 JLOG(ctx.
j.
warn()) <<
"Change: Bad signature";
64 JLOG(ctx.
j.
warn()) <<
"Change: Bad sequence";
71 JLOG(ctx.
j.
warn()) <<
"Change: NegativeUNL not enabled";
85 JLOG(ctx.
j.
warn()) <<
"Change transaction against open ledger";
132 if (!amendmentObject)
134 amendmentObject = std::make_shared<SLE>(k);
140 if (
std::find(amendments.begin(), amendments.end(), amendment) !=
149 if (gotMajority && lostMajority)
159 for (
auto const& majority : oldMajorities)
161 if (majority.getFieldH256(
sfAmendment) == amendment)
175 if (!found && lostMajority)
182 auto& entry = newMajorities.
back();
189 JLOG(
j_.
warn()) <<
"Unsupported amendment " << amendment
190 <<
" received a majority.";
193 else if (!lostMajority)
196 amendments.push_back(amendment);
197 amendmentObject->setFieldV256(
sfAmendments, amendments);
203 JLOG(
j_.
error()) <<
"Unsupported amendment " << amendment
204 <<
" activated: server blocked.";
209 if (newMajorities.
empty())
212 amendmentObject->setFieldArray(
sfMajorities, newMajorities);
228 feeObject = std::make_shared<SLE>(k);
233 feeObject->setFieldU32(
236 feeObject->setFieldU32(
241 JLOG(
j_.
warn()) <<
"Fees have been changed";
250 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, not a flag ledger, seq="
260 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, wrong Tx format.";
266 if (seq !=
view().seq())
268 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, wrong ledger seq=" << seq;
275 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, bad validator key";
279 JLOG(
j_.
info()) <<
"N-UNL: applyUNLModify, "
280 << (disabling ?
"ToDisable" :
"ToReEnable")
282 <<
" validator data:" <<
strHex(validator);
288 negUnlObject = std::make_shared<SLE>(k);
292 bool const found = [&] {
297 for (
auto const& v : negUnl)
312 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, already has ToDisable";
322 <<
"N-UNL: applyUNLModify, ToDisable is same as ToReEnable";
331 <<
"N-UNL: applyUNLModify, ToDisable already in negative UNL";
342 JLOG(
j_.
warn()) <<
"N-UNL: applyUNLModify, already has ToReEnable";
352 <<
"N-UNL: applyUNLModify, ToReEnable is same as ToDisable";
361 <<
"N-UNL: applyUNLModify, ToReEnable is not in negative UNL";
TxType getTxnType() const
const SF_HASH256 sfPreviousTxnID
bool isFlagLedger(LedgerIndex seq)
Returns true if the given ledgerIndex is a flag ledgerIndex.
const SF_VL sfUNLModifyValidator
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
Keylet const & amendments() noexcept
The index of the amendment table.
boost::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
const SF_UINT32 sfLedgerSequence
std::uint64_t getFieldU64(SField const &field) const
const SF_UINT32 sfSequence
virtual AmendmentTable & getAmendmentTable()=0
STInteger< std::uint32_t > STUInt32
unsigned char getFieldU8(SField const &field) const
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
const SF_HASH256 sfAmendment
Blob getFieldVL(SField const &field) const
const std::uint32_t tfLostMajority
const std::uint32_t tfGotMajority
virtual NetworkOPs & getOPs()=0
NotTEC preflight0(PreflightContext const &ctx)
Performs early sanity checks on the txid.
AccountID getAccountID(SField const &field) const
const SF_UINT32 sfReserveIncrement
const SF_VL sfValidatorToDisable
std::uint32_t getFlags() const
Blob getSigningPubKey() const
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
virtual bool enable(uint256 const &amendment)=0
STBitString< 256 > STHash256
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
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
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
std::string strHex(FwdIt begin, FwdIt end)
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 SField sfMajorities
virtual bool open() const =0
Returns true if this reflects an open ledger.
const SField sfDisabledValidators
STAmount const & getFieldAmount(SField const &field) const
const SF_VECTOR256 sfAmendments
const SF_VL sfValidatorToReEnable
TERSubset< CanCvtToNotTEC > NotTEC
uint256 getFieldH256(SField const &field) const