20#include <xrpld/app/tx/detail/SetSignerList.h>
22#include <xrpld/app/ledger/Ledger.h>
23#include <xrpld/ledger/ApplyView.h>
24#include <xrpl/basics/Log.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>
52 auto const quorum = tx[sfSignerQuorum];
57 if (quorum && hasSignerEntries)
64 std::sort(signers->begin(), signers->end());
67 sign = std::move(*signers);
70 else if ((quorum == 0) && !hasSignerEntries)
87 return std::get<0>(result);
89 if (std::get<3>(result) ==
unknown)
93 <<
"Malformed transaction: Invalid signer set list format.";
97 if (std::get<3>(result) ==
set)
131 UNREACHABLE(
"ripple::SetSignerList::doApply : invalid operation");
142 "ripple::SetSignerList::preCompute : result is tesSUCCESS");
144 std::get<3>(result) !=
unknown,
145 "ripple::SetSignerList::preCompute : result is known operation");
149 do_ = std::get<3>(result);
180 "ripple::signerCountBasedOwnerCountDelta : minimum signers");
183 "ripple::signerCountBasedOwnerCountDelta : maximum signers");
184 return 2 +
static_cast<int>(entryCount);
191 Keylet const& accountKeylet,
192 Keylet const& ownerDirKeylet,
193 Keylet const& signerListKeylet,
207 int removeFromOwnerCount = -1;
210 STArray const& actualList = signers->getFieldArray(sfSignerEntries);
211 removeFromOwnerCount =
217 auto const hint = (*signers)[sfOwnerNode];
219 if (!view.
dirRemove(ownerDirKeylet, hint, signerListKeylet.
key,
false))
221 JLOG(j.
fatal()) <<
"Unable to delete SignerList from owner.";
227 view.
peek(accountKeylet),
228 removeFromOwnerCount,
248 app,
view, accountKeylet, ownerDirKeylet, signerListKeylet, j);
265 JLOG(j.
trace()) <<
"Too many or too few signers in signer list.";
273 "ripple::SetSignerList::validateQuorumAndSignerEntries : sorted "
277 JLOG(j.
trace()) <<
"Duplicate signers in signer list";
282 bool const expandedSignerList = rules.
enabled(featureExpandedSignerList);
287 for (
auto const& signer : signers)
292 JLOG(j.
trace()) <<
"Every signer must have a positive weight.";
296 allSignersWeight += signer.weight;
298 if (signer.account == account)
300 JLOG(j.
trace()) <<
"A signer may not self reference account.";
304 if (signer.tag && !expandedSignerList)
306 JLOG(j.
trace()) <<
"Malformed transaction: sfWalletLocator "
307 "specified in SignerEntry "
308 <<
"but featureExpandedSignerList is not enabled.";
315 if ((quorum <= 0) || (allSignersWeight < quorum))
317 JLOG(j.
trace()) <<
"Quorum is unreachable";
342 auto const sle =
view().
peek(accountKeylet);
350 int addedOwnerCount{1};
369 auto signerList = std::make_shared<SLE>(signerListKeylet);
379 <<
": " << (page ?
"success" :
"failure");
384 signerList->setFieldU64(sfOwnerNode, *page);
403 (!ledgerEntry->isFieldPresent(sfRegularKey)))
409 ctx_.
app,
view(), accountKeylet, ownerDirKeylet, signerListKeylet,
j_);
418 ledgerEntry->setFieldU32(sfSignerQuorum,
quorum_);
421 ledgerEntry->setFieldU32(sfFlags, flags);
423 bool const expandedSignerList =
433 obj[sfAccount] = entry.account;
434 obj[sfSignerWeight] = entry.weight;
438 if (expandedSignerList && entry.tag)
443 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 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)
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
Buffer sign(PublicKey const &pk, SecretKey const &sk, Slice const &message)
Generate a signature for a message.
static bool adjustOwnerCount(ApplyContext &ctx, int count)
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
@ tecINSUFFICIENT_RESERVE
TERSubset< CanCvtToTER > TER
static std::uint32_t const defaultSignerListID_
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.