Skip to content

Commit ddf7d6c

Browse files
authored
Merge branch 'develop' into ximinez/fix/validator-cache
2 parents fcd2ea2 + 21c0223 commit ddf7d6c

31 files changed

+105
-259
lines changed

include/xrpl/protocol/PublicKey.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,7 @@ verifyDigest(
231231
SHA512-Half, and the resulting digest is signed.
232232
*/
233233
[[nodiscard]] bool
234-
verify(
235-
PublicKey const& publicKey,
236-
Slice const& m,
237-
Slice const& sig,
238-
bool mustBeFullyCanonical = true) noexcept;
234+
verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept;
239235

240236
/** Calculate the 160-bit node ID from a node public key. */
241237
NodeID

include/xrpl/protocol/STTx.h

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,15 @@ class STTx final : public STObject, public CountedObject<STTx>
103103
std::optional<std::reference_wrapper<SField const>> signatureTarget =
104104
{});
105105

106-
enum class RequireFullyCanonicalSig : bool { no, yes };
107-
108106
/** Check the signature.
109-
@param requireCanonicalSig If `true`, check that the signature is fully
110-
canonical. If `false`, only check that the signature is valid.
111107
@param rules The current ledger rules.
112108
@return `true` if valid signature. If invalid, the error message string.
113109
*/
114110
Expected<void, std::string>
115-
checkSign(RequireFullyCanonicalSig requireCanonicalSig, Rules const& rules)
116-
const;
111+
checkSign(Rules const& rules) const;
117112

118113
Expected<void, std::string>
119-
checkBatchSign(
120-
RequireFullyCanonicalSig requireCanonicalSig,
121-
Rules const& rules) const;
114+
checkBatchSign(Rules const& rules) const;
122115

123116
// SQL Functions with metadata.
124117
static std::string const&
@@ -140,40 +133,25 @@ class STTx final : public STObject, public CountedObject<STTx>
140133

141134
private:
142135
/** Check the signature.
143-
@param requireCanonicalSig If `true`, check that the signature is fully
144-
canonical. If `false`, only check that the signature is valid.
145136
@param rules The current ledger rules.
146137
@param sigObject Reference to object that contains the signature fields.
147138
Will be *this more often than not.
148139
@return `true` if valid signature. If invalid, the error message string.
149140
*/
150141
Expected<void, std::string>
151-
checkSign(
152-
RequireFullyCanonicalSig requireCanonicalSig,
153-
Rules const& rules,
154-
STObject const& sigObject) const;
142+
checkSign(Rules const& rules, STObject const& sigObject) const;
155143

156144
Expected<void, std::string>
157-
checkSingleSign(
158-
RequireFullyCanonicalSig requireCanonicalSig,
159-
STObject const& sigObject) const;
145+
checkSingleSign(STObject const& sigObject) const;
160146

161147
Expected<void, std::string>
162-
checkMultiSign(
163-
RequireFullyCanonicalSig requireCanonicalSig,
164-
Rules const& rules,
165-
STObject const& sigObject) const;
148+
checkMultiSign(Rules const& rules, STObject const& sigObject) const;
166149

167150
Expected<void, std::string>
168-
checkBatchSingleSign(
169-
STObject const& batchSigner,
170-
RequireFullyCanonicalSig requireCanonicalSig) const;
151+
checkBatchSingleSign(STObject const& batchSigner) const;
171152

172153
Expected<void, std::string>
173-
checkBatchMultiSign(
174-
STObject const& batchSigner,
175-
RequireFullyCanonicalSig requireCanonicalSig,
176-
Rules const& rules) const;
154+
checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const;
177155

178156
STBase*
179157
copy(std::size_t n, void* buf) const override;

include/xrpl/protocol/detail/features.macro

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo
6565
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
6666
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
6767
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
68-
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
69-
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
7068
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
7169

7270
// The following amendments are obsolete, but must remain supported
@@ -79,9 +77,9 @@ XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYe
7977
// enabled (added to the ledger).
8078
//
8179
// If a feature remains obsolete for long enough that no clients are able
82-
// to vote for it, the feature can be removed (entirely?) from the code.
83-
XRPL_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete)
84-
80+
// to vote for it, the feature can be removed entirely from the code. Until
81+
// then the feature needs to be marked explicitly as obsolete, e.g.
82+
// XRPL_FEATURE(Example, Supported::yes, VoteBehavior::Obsolete)
8583
// The following amendments have been active for at least two years. Their
8684
// pre-amendment code has been removed and the identifiers are deprecated.
8785
// All known amendments and amendments that may appear in a validated ledger
@@ -117,6 +115,8 @@ XRPL_RETIRE_FIX(TrustLinesToSelf)
117115
XRPL_RETIRE_FEATURE(Checks)
118116
XRPL_RETIRE_FEATURE(CheckCashMakesTrustLine)
119117
XRPL_RETIRE_FEATURE(CryptoConditions)
118+
XRPL_RETIRE_FEATURE(CryptoConditionsSuite)
119+
XRPL_RETIRE_FEATURE(DeletableAccounts)
120120
XRPL_RETIRE_FEATURE(DepositAuth)
121121
XRPL_RETIRE_FEATURE(DepositPreauth)
122122
XRPL_RETIRE_FEATURE(DisallowIncoming)
@@ -132,6 +132,7 @@ XRPL_RETIRE_FEATURE(MultiSignReserve)
132132
XRPL_RETIRE_FEATURE(NegativeUNL)
133133
XRPL_RETIRE_FEATURE(NonFungibleTokensV1_1)
134134
XRPL_RETIRE_FEATURE(PayChan)
135+
XRPL_RETIRE_FEATURE(RequireFullyCanonicalSig)
135136
XRPL_RETIRE_FEATURE(SortedDirectories)
136137
XRPL_RETIRE_FEATURE(TicketBatch)
137138
XRPL_RETIRE_FEATURE(TickSize)

include/xrpl/protocol/detail/transactions.macro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ TRANSACTION(ttTRUST_SET, 20, TrustSet,
297297
#endif
298298
TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete,
299299
Delegation::notDelegatable,
300-
featureDeletableAccounts,
300+
uint256{},
301301
mustDeleteAcct,
302302
({
303303
{sfDestination, soeREQUIRED},

src/libxrpl/ledger/View.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ rippleSendIOU(
18631863
// Direct send: redeeming IOUs and/or sending own IOUs.
18641864
auto const ter =
18651865
rippleCreditIOU(view, uSenderID, uReceiverID, saAmount, false, j);
1866-
if (view.rules().enabled(featureDeletableAccounts) && ter != tesSUCCESS)
1866+
if (ter != tesSUCCESS)
18671867
return ter;
18681868
saActual = saAmount;
18691869
return tesSUCCESS;

src/libxrpl/protocol/PublicKey.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,13 @@ verifyDigest(
267267
}
268268

269269
bool
270-
verify(
271-
PublicKey const& publicKey,
272-
Slice const& m,
273-
Slice const& sig,
274-
bool mustBeFullyCanonical) noexcept
270+
verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept
275271
{
276272
if (auto const type = publicKeyType(publicKey))
277273
{
278274
if (*type == KeyType::secp256k1)
279275
{
280-
return verifyDigest(
281-
publicKey, sha512Half(m), sig, mustBeFullyCanonical);
276+
return verifyDigest(publicKey, sha512Half(m), sig);
282277
}
283278
else if (*type == KeyType::ed25519)
284279
{

src/libxrpl/protocol/STTx.cpp

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,7 @@ STTx::sign(
237237
}
238238

239239
Expected<void, std::string>
240-
STTx::checkSign(
241-
RequireFullyCanonicalSig requireCanonicalSig,
242-
Rules const& rules,
243-
STObject const& sigObject) const
240+
STTx::checkSign(Rules const& rules, STObject const& sigObject) const
244241
{
245242
try
246243
{
@@ -249,9 +246,8 @@ STTx::checkSign(
249246
// multi-signing. Otherwise we're single-signing.
250247

251248
Blob const& signingPubKey = sigObject.getFieldVL(sfSigningPubKey);
252-
return signingPubKey.empty()
253-
? checkMultiSign(requireCanonicalSig, rules, sigObject)
254-
: checkSingleSign(requireCanonicalSig, sigObject);
249+
return signingPubKey.empty() ? checkMultiSign(rules, sigObject)
250+
: checkSingleSign(sigObject);
255251
}
256252
catch (std::exception const&)
257253
{
@@ -260,18 +256,16 @@ STTx::checkSign(
260256
}
261257

262258
Expected<void, std::string>
263-
STTx::checkSign(
264-
RequireFullyCanonicalSig requireCanonicalSig,
265-
Rules const& rules) const
259+
STTx::checkSign(Rules const& rules) const
266260
{
267-
if (auto const ret = checkSign(requireCanonicalSig, rules, *this); !ret)
261+
if (auto const ret = checkSign(rules, *this); !ret)
268262
return ret;
269263

270264
/* Placeholder for field that will be added by Lending Protocol
271265
if (isFieldPresent(sfCounterpartySignature))
272266
{
273267
auto const counterSig = getFieldObject(sfCounterpartySignature);
274-
if (auto const ret = checkSign(requireCanonicalSig, rules, counterSig);
268+
if (auto const ret = checkSign(rules, counterSig);
275269
!ret)
276270
return Unexpected("Counterparty: " + ret.error());
277271
}
@@ -280,9 +274,7 @@ STTx::checkSign(
280274
}
281275

282276
Expected<void, std::string>
283-
STTx::checkBatchSign(
284-
RequireFullyCanonicalSig requireCanonicalSig,
285-
Rules const& rules) const
277+
STTx::checkBatchSign(Rules const& rules) const
286278
{
287279
try
288280
{
@@ -299,8 +291,8 @@ STTx::checkBatchSign(
299291
{
300292
Blob const& signingPubKey = signer.getFieldVL(sfSigningPubKey);
301293
auto const result = signingPubKey.empty()
302-
? checkBatchMultiSign(signer, requireCanonicalSig, rules)
303-
: checkBatchSingleSign(signer, requireCanonicalSig);
294+
? checkBatchMultiSign(signer, rules)
295+
: checkBatchSingleSign(signer);
304296

305297
if (!result)
306298
return result;
@@ -395,10 +387,7 @@ STTx::getMetaSQL(
395387
}
396388

397389
static Expected<void, std::string>
398-
singleSignHelper(
399-
STObject const& sigObject,
400-
Slice const& data,
401-
bool const fullyCanonical)
390+
singleSignHelper(STObject const& sigObject, Slice const& data)
402391
{
403392
// We don't allow both a non-empty sfSigningPubKey and an sfSigners.
404393
// That would allow the transaction to be signed two ways. So if both
@@ -413,11 +402,8 @@ singleSignHelper(
413402
if (publicKeyType(makeSlice(spk)))
414403
{
415404
Blob const signature = sigObject.getFieldVL(sfTxnSignature);
416-
validSig = verify(
417-
PublicKey(makeSlice(spk)),
418-
data,
419-
makeSlice(signature),
420-
fullyCanonical);
405+
validSig =
406+
verify(PublicKey(makeSlice(spk)), data, makeSlice(signature));
421407
}
422408
}
423409
catch (std::exception const&)
@@ -432,33 +418,24 @@ singleSignHelper(
432418
}
433419

434420
Expected<void, std::string>
435-
STTx::checkSingleSign(
436-
RequireFullyCanonicalSig requireCanonicalSig,
437-
STObject const& sigObject) const
421+
STTx::checkSingleSign(STObject const& sigObject) const
438422
{
439423
auto const data = getSigningData(*this);
440-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
441-
(requireCanonicalSig == STTx::RequireFullyCanonicalSig::yes);
442-
return singleSignHelper(sigObject, makeSlice(data), fullyCanonical);
424+
return singleSignHelper(sigObject, makeSlice(data));
443425
}
444426

445427
Expected<void, std::string>
446-
STTx::checkBatchSingleSign(
447-
STObject const& batchSigner,
448-
RequireFullyCanonicalSig requireCanonicalSig) const
428+
STTx::checkBatchSingleSign(STObject const& batchSigner) const
449429
{
450430
Serializer msg;
451431
serializeBatch(msg, getFlags(), getBatchTransactionIDs());
452-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
453-
(requireCanonicalSig == STTx::RequireFullyCanonicalSig::yes);
454-
return singleSignHelper(batchSigner, msg.slice(), fullyCanonical);
432+
return singleSignHelper(batchSigner, msg.slice());
455433
}
456434

457435
Expected<void, std::string>
458436
multiSignHelper(
459437
STObject const& sigObject,
460438
std::optional<AccountID> txnAccountID,
461-
bool const fullyCanonical,
462439
std::function<Serializer(AccountID const&)> makeMsg,
463440
Rules const& rules)
464441
{
@@ -515,8 +492,7 @@ multiSignHelper(
515492
validSig = verify(
516493
PublicKey(makeSlice(spk)),
517494
makeMsg(accountID).slice(),
518-
makeSlice(signature),
519-
fullyCanonical);
495+
makeSlice(signature));
520496
}
521497
}
522498
catch (std::exception const& e)
@@ -535,14 +511,8 @@ multiSignHelper(
535511
}
536512

537513
Expected<void, std::string>
538-
STTx::checkBatchMultiSign(
539-
STObject const& batchSigner,
540-
RequireFullyCanonicalSig requireCanonicalSig,
541-
Rules const& rules) const
514+
STTx::checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const
542515
{
543-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
544-
(requireCanonicalSig == RequireFullyCanonicalSig::yes);
545-
546516
// We can ease the computational load inside the loop a bit by
547517
// pre-constructing part of the data that we hash. Fill a Serializer
548518
// with the stuff that stays constant from signature to signature.
@@ -551,7 +521,6 @@ STTx::checkBatchMultiSign(
551521
return multiSignHelper(
552522
batchSigner,
553523
std::nullopt,
554-
fullyCanonical,
555524
[&dataStart](AccountID const& accountID) -> Serializer {
556525
Serializer s = dataStart;
557526
finishMultiSigningData(accountID, s);
@@ -561,14 +530,8 @@ STTx::checkBatchMultiSign(
561530
}
562531

563532
Expected<void, std::string>
564-
STTx::checkMultiSign(
565-
RequireFullyCanonicalSig requireCanonicalSig,
566-
Rules const& rules,
567-
STObject const& sigObject) const
533+
STTx::checkMultiSign(Rules const& rules, STObject const& sigObject) const
568534
{
569-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
570-
(requireCanonicalSig == RequireFullyCanonicalSig::yes);
571-
572535
// Used inside the loop in multiSignHelper to enforce that
573536
// the account owner may not multisign for themselves.
574537
auto const txnAccountID = &sigObject != this
@@ -582,7 +545,6 @@ STTx::checkMultiSign(
582545
return multiSignHelper(
583546
sigObject,
584547
txnAccountID,
585-
fullyCanonical,
586548
[&dataStart](AccountID const& accountID) -> Serializer {
587549
Serializer s = dataStart;
588550
finishMultiSigningData(accountID, s);

0 commit comments

Comments
 (0)