Skip to content

Commit

Permalink
Apply inner object templates to more inner objects:
Browse files Browse the repository at this point in the history
Note that Change.cpp is not fixed yet because it causes massive
Unit test failures.
  • Loading branch information
scottschurr committed Feb 7, 2024
1 parent 87a2879 commit d1fa0cf
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/ripple/app/ledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,8 @@ Ledger::updateNegativeUNL()

if (hasToDisable)
{
newNUnl.emplace_back(sfDisabledValidator);
newNUnl.push_back(
STObject::makeInnerObject(sfDisabledValidator, rules()));
newNUnl.back().setFieldVL(
sfPublicKey, sle->getFieldVL(sfValidatorToDisable));
newNUnl.back().setFieldU32(sfFirstLedgerSequence, seq());
Expand Down
1 change: 1 addition & 0 deletions src/ripple/app/tx/impl/Change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ Change::applyAmendment()
if (gotMajority)
{
// This amendment now has a majority
// The following call should use STObject::makeInnerObject
newMajorities.push_back(STObject(sfMajority));
auto& entry = newMajorities.back();
entry.emplace_back(STUInt256(sfAmendment, amendment));
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/tx/impl/SetSignerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,11 @@ SetSignerList::writeSignersToSLE(
ctx_.view().rules().enabled(featureExpandedSignerList);

// Create the SignerListArray one SignerEntry at a time.
Rules const& rules = view().rules();
STArray toLedger(signers_.size());
for (auto const& entry : signers_)
{
toLedger.emplace_back(sfSignerEntry);
toLedger.push_back(STObject::makeInnerObject(sfSignerEntry, rules));
STObject& obj = toLedger.back();
obj.reserve(2);
obj.setAccountID(sfAccount, entry.account);
Expand Down
7 changes: 4 additions & 3 deletions src/ripple/app/tx/impl/XChainBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ applyClaimAttestations(

// update the claim id
sleClaimID->setFieldArray(
sfXChainClaimAttestations, curAtts.toSTArray());
sfXChainClaimAttestations, curAtts.toSTArray(view.rules()));
psb.update(sleClaimID);

return ScopeResult{
Expand Down Expand Up @@ -1097,7 +1097,8 @@ applyCreateAccountAttestations(
if (!sleClaimID)
return Unexpected(tecINTERNAL);
sleClaimID->setFieldArray(
sfXChainCreateAccountAttestations, curAtts.toSTArray());
sfXChainCreateAccountAttestations,
curAtts.toSTArray(view.rules()));
psb.update(sleClaimID);
}
return ScopeResult{newAttResult, createCID, curAtts};
Expand Down Expand Up @@ -1152,7 +1153,7 @@ applyCreateAccountAttestations(
(*createdSleClaimID)[sfXChainAccountCreateCount] =
attBegin->createCount;
createdSleClaimID->setFieldArray(
sfXChainCreateAccountAttestations, curAtts.toSTArray());
sfXChainCreateAccountAttestations, curAtts.toSTArray(view.rules()));

// Add to owner directory of the door account
auto const page = psb.dirInsert(
Expand Down
10 changes: 5 additions & 5 deletions src/ripple/protocol/XChainAttestations.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct AttestationClaim : AttestationBase
explicit AttestationClaim(Json::Value const& v);

[[nodiscard]] STObject
toSTObject() const;
toSTObject(Rules const& rules) const;

// return true if the two attestations attest to the same thing
[[nodiscard]] bool
Expand Down Expand Up @@ -211,7 +211,7 @@ struct AttestationCreateAccount : AttestationBase
AccountID const& toCreate_);

[[nodiscard]] STObject
toSTObject() const;
toSTObject(Rules const& rules) const;

// return true if the two attestations attest to the same thing
[[nodiscard]] bool
Expand Down Expand Up @@ -317,7 +317,7 @@ struct XChainClaimAttestation
match(MatchFields const& rhs) const;

[[nodiscard]] STObject
toSTObject() const;
toSTObject(Rules const& rules) const;

friend bool
operator==(
Expand Down Expand Up @@ -364,7 +364,7 @@ struct XChainCreateAccountAttestation
explicit XChainCreateAccountAttestation(Json::Value const& v);

[[nodiscard]] STObject
toSTObject() const;
toSTObject(Rules const& rules) const;

AttestationMatch
match(MatchFields const& rhs) const;
Expand Down Expand Up @@ -407,7 +407,7 @@ class XChainAttestationsBase
explicit XChainAttestationsBase(STArray const& arr);

[[nodiscard]] STArray
toSTArray() const;
toSTArray(Rules const& rules) const;

typename AttCollection::const_iterator
begin() const;
Expand Down
23 changes: 13 additions & 10 deletions src/ripple/protocol/impl/XChainAttestations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ AttestationClaim::AttestationClaim(Json::Value const& v)
}

STObject
AttestationClaim::toSTObject() const
AttestationClaim::toSTObject(Rules const& rules) const
{
STObject o{sfXChainClaimAttestationCollectionElement};
STObject o = STObject::makeInnerObject(
sfXChainClaimAttestationCollectionElement, rules);
addHelper(o);
o[sfXChainClaimID] = claimID;
if (dst)
Expand Down Expand Up @@ -343,9 +344,10 @@ AttestationCreateAccount::AttestationCreateAccount(
}

STObject
AttestationCreateAccount::toSTObject() const
AttestationCreateAccount::toSTObject(Rules const& rules) const
{
STObject o{sfXChainCreateAccountAttestationCollectionElement};
STObject o = STObject::makeInnerObject(
sfXChainCreateAccountAttestationCollectionElement, rules);
addHelper(o);

o[sfXChainAccountCreateCount] = createCount;
Expand Down Expand Up @@ -495,9 +497,9 @@ XChainClaimAttestation::XChainClaimAttestation(
}

STObject
XChainClaimAttestation::toSTObject() const
XChainClaimAttestation::toSTObject(Rules const& rules) const
{
STObject o{sfXChainClaimProofSig};
STObject o = STObject::makeInnerObject(sfXChainClaimProofSig, rules);
o[sfAttestationSignerAccount] =
STAccount{sfAttestationSignerAccount, keyAccount};
o[sfPublicKey] = publicKey;
Expand Down Expand Up @@ -607,9 +609,10 @@ XChainCreateAccountAttestation::XChainCreateAccountAttestation(
}

STObject
XChainCreateAccountAttestation::toSTObject() const
XChainCreateAccountAttestation::toSTObject(Rules const& rules) const
{
STObject o{sfXChainCreateAccountProofSig};
STObject o =
STObject::makeInnerObject(sfXChainCreateAccountProofSig, rules);

o[sfAttestationSignerAccount] =
STAccount{sfAttestationSignerAccount, keyAccount};
Expand Down Expand Up @@ -745,11 +748,11 @@ XChainAttestationsBase<TAttestation>::XChainAttestationsBase(STArray const& arr)

template <class TAttestation>
STArray
XChainAttestationsBase<TAttestation>::toSTArray() const
XChainAttestationsBase<TAttestation>::toSTArray(Rules const& rules) const
{
STArray r{TAttestation::ArrayFieldName, attestations_.size()};
for (auto const& e : attestations_)
r.emplace_back(e.toSTObject());
r.emplace_back(e.toSTObject(rules));
return r;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/rpc/impl/TransactionSign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ transactionSignFor(
auto& sttx = preprocResult.second;
{
// Make the signer object that we'll inject.
STObject signer(sfSigner);
STObject signer = STObject::makeInnerObject(sfSigner, ledger->rules());
signer[sfAccount] = *signerAccountID;
signer.setFieldVL(sfTxnSignature, multiSignature);
signer.setFieldVL(sfSigningPubKey, multiSignPubKey.slice());
Expand Down

0 comments on commit d1fa0cf

Please sign in to comment.