20#include <xrpld/app/ledger/Ledger.h>
21#include <xrpld/app/tx/detail/SetSignerList.h>
23#include <xrpl/basics/Log.h>
24#include <xrpl/ledger/ApplyView.h>
25#include <xrpl/protocol/Feature.h>
26#include <xrpl/protocol/Indexes.h>
27#include <xrpl/protocol/STArray.h>
28#include <xrpl/protocol/STObject.h>
29#include <xrpl/protocol/STTx.h>
30#include <xrpl/protocol/TxFlags.h>
54 auto const quorum = tx[sfSignerQuorum];
59 if (quorum && hasSignerEntries)
66 std::sort(signers->begin(), signers->end());
69 sign = std::move(*signers);
72 else if ((quorum == 0) && !hasSignerEntries)
99 <<
"Malformed transaction: Invalid signer set list format.";
138 UNREACHABLE(
"ripple::SetSignerList::doApply : invalid operation");
150 "ripple::SetSignerList::preCompute : result is tesSUCCESS");
153 "ripple::SetSignerList::preCompute : result is known operation");
188 "ripple::signerCountBasedOwnerCountDelta : minimum signers");
191 "ripple::signerCountBasedOwnerCountDelta : maximum signers");
192 return 2 +
static_cast<int>(entryCount);
199 Keylet const& accountKeylet,
200 Keylet const& ownerDirKeylet,
201 Keylet const& signerListKeylet,
215 int removeFromOwnerCount = -1;
218 STArray const& actualList = signers->getFieldArray(sfSignerEntries);
219 removeFromOwnerCount =
225 auto const hint = (*signers)[sfOwnerNode];
227 if (!view.
dirRemove(ownerDirKeylet, hint, signerListKeylet.
key,
false))
230 JLOG(j.
fatal()) <<
"Unable to delete SignerList from owner.";
237 view.
peek(accountKeylet),
238 removeFromOwnerCount,
258 app,
view, accountKeylet, ownerDirKeylet, signerListKeylet, j);
275 JLOG(j.
trace()) <<
"Too many or too few signers in signer list.";
283 "ripple::SetSignerList::validateQuorumAndSignerEntries : sorted "
287 JLOG(j.
trace()) <<
"Duplicate signers in signer list";
292 bool const expandedSignerList = rules.
enabled(featureExpandedSignerList);
297 for (
auto const& signer : signers)
302 JLOG(j.
trace()) <<
"Every signer must have a positive weight.";
306 allSignersWeight += signer.weight;
308 if (signer.account == account)
310 JLOG(j.
trace()) <<
"A signer may not self reference account.";
314 if (signer.tag && !expandedSignerList)
316 JLOG(j.
trace()) <<
"Malformed transaction: sfWalletLocator "
317 "specified in SignerEntry "
318 <<
"but featureExpandedSignerList is not enabled.";
325 if ((quorum <= 0) || (allSignersWeight < quorum))
327 JLOG(j.
trace()) <<
"Quorum is unreachable";
352 auto const sle =
view().
peek(accountKeylet);
360 int addedOwnerCount{1};
389 <<
": " << (page ?
"success" :
"failure");
394 signerList->setFieldU64(sfOwnerNode, *page);
413 (!ledgerEntry->isFieldPresent(sfRegularKey)))
419 ctx_.
app,
view(), accountKeylet, ownerDirKeylet, signerListKeylet,
j_);
430 ledgerEntry->setAccountID(sfOwner,
account_);
432 ledgerEntry->setFieldU32(sfSignerQuorum,
quorum_);
435 ledgerEntry->setFieldU32(sfFlags, flags);
437 bool const expandedSignerList =
447 obj[sfAccount] = entry.account;
448 obj[sfSignerWeight] = entry.weight;
452 if (expandedSignerList && entry.tag)
457 ledgerEntry->setFieldArray(sfSignerEntries, toLedger);
T adjacent_find(T... args)
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
virtual beast::Journal journal(std::string const &name)=0
Writeable view to a ledger, for applying a transaction.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe)
Insert an entry to a directory.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual Rules const & rules() const =0
Returns the tx processing rules.
Rules controlling protocol behavior.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
void push_back(STObject const &object)
AccountID getAccountID(SField const &field) const
void setFieldH256(SField const &field, uint256 const &)
bool isFieldPresent(SField const &field) const
static STObject makeInnerObject(SField const &name)
void reserve(std::size_t n)
static std::size_t const minMultiSigners
static std::size_t maxMultiSigners(Rules const *rules=0)
void writeSignersToSLE(SLE::pointer const &ledgerEntry, std::uint32_t flags) const
static NotTEC preflight(PreflightContext const &ctx)
static NotTEC validateQuorumAndSignerEntries(std::uint32_t quorum, std::vector< SignerEntries::SignerEntry > const &signers, AccountID const &account, beast::Journal j, Rules const &)
void preCompute() override
static TER removeFromLedger(Application &app, ApplyView &view, AccountID const &account, beast::Journal j)
std::vector< SignerEntries::SignerEntry > signers_
static std::tuple< NotTEC, std::uint32_t, std::vector< SignerEntries::SignerEntry >, Operation > determineOperation(STTx const &tx, ApplyFlags flags, beast::Journal j)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static Expected< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string_view annotation)
virtual void preCompute()
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet signers(AccountID const &account) noexcept
A SignerList.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
static int signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const &rules)
static TER removeSignersFromLedger(Application &app, ApplyView &view, Keylet const &accountKeylet, Keylet const &ownerDirKeylet, Keylet const &signerListKeylet, beast::Journal j)
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
static std::uint32_t const DEFAULT_SIGNER_LIST_ID
Buffer sign(PublicKey const &pk, SecretKey const &sk, Slice const &message)
Generate a signature for a message.
@ tecINSUFFICIENT_RESERVE
constexpr std::uint32_t tfUniversalMask
TERSubset< CanCvtToTER > TER
TERSubset< CanCvtToNotTEC > NotTEC
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
A pair of SHAMap key and LedgerEntryType.
State information when preflighting a tx.