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";
63 JLOG(ctx.
j.
warn()) <<
"Change: Bad sequence";
70 JLOG(ctx.
j.
warn()) <<
"Change: NegativeUNL not enabled";
84 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
bool isFlagLedger(LedgerIndex seq)
Returns true if the given ledgerIndex is a flag ledgerIndex.
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)
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 SField sfSigners(access, STI_ARRAY, 3, "Signers", SField::sMD_Default, SField::notSigning)
std::uint64_t getFieldU64(SField const &field) const
virtual AmendmentTable & getAmendmentTable()=0
STInteger< std::uint32_t > STUInt32
unsigned char getFieldU8(SField const &field) const
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
const SField sfMajorities(access, STI_ARRAY, 16, "Majorities")
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_Blob sfUNLModifyValidator(access, STI_VL, 19, "UNLModifyValidator")
const SF_U8 sfUNLModifyDisabling(access, STI_UINT8, 17, "UNLModifyDisabling")
Blob getFieldVL(SField const &field) const
const SField sfDisabledValidators(access, STI_ARRAY, 17, "DisabledValidators")
const std::uint32_t tfLostMajority
const SF_U32 sfReserveBase(access, STI_UINT32, 31, "ReserveBase")
const std::uint32_t tfGotMajority
virtual NetworkOPs & getOPs()=0
const SField sfMajority(access, STI_OBJECT, 18, "Majority")
NotTEC preflight0(PreflightContext const &ctx)
Performs early sanity checks on the txid.
AccountID getAccountID(SField const &field) const
const SF_U256 sfAmendment(access, STI_HASH256, 19, "Amendment")
const SF_U32 sfLedgerSequence(access, STI_UINT32, 6, "LedgerSequence")
const SF_U32 sfReferenceFeeUnits(access, STI_UINT32, 30, "ReferenceFeeUnits")
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_Amount sfFee(access, STI_AMOUNT, 8, "Fee")
std::uint32_t getSequence() const
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_Blob sfValidatorToReEnable(access, STI_VL, 21, "ValidatorToReEnable")
std::size_t emplace_back(Args &&... args)
static NotTEC preflight(PreflightContext const &ctx)
const SF_Blob sfPublicKey(access, STI_VL, 1, "PublicKey")
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.
const SF_U32 sfReserveIncrement(access, STI_UINT32, 32, "ReserveIncrement")
Blob getSignature() const
const uint256 featureNegativeUNL
bool isFieldPresent(SField const &field) const
const SF_U32 sfCloseTime(access, STI_UINT32, 7, "CloseTime")
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
const SF_Blob sfValidatorToDisable(access, STI_VL, 20, "ValidatorToDisable")
std::string strHex(FwdIt begin, FwdIt end)
const SF_Vec256 sfAmendments(access, STI_VECTOR256, 3, "Amendments")
std::uint32_t getFieldU32(SField const &field) const
State information when preflighting a tx.
const SF_U64 sfBaseFee(access, STI_UINT64, 5, "BaseFee")
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
virtual bool open() const =0
Returns true if this reflects an open ledger.
STAmount const & getFieldAmount(SField const &field) const
const SF_U256 sfPreviousTxnID(access, STI_HASH256, 5, "PreviousTxnID", SField::sMD_DeleteFinal)
TERSubset< CanCvtToNotTEC > NotTEC
uint256 getFieldH256(SField const &field) const