From 0e5c9e6f37600112308f34d92e25c8550cfd4935 Mon Sep 17 00:00:00 2001 From: Siddharth Suresh Date: Mon, 11 Apr 2022 13:51:25 -0700 Subject: [PATCH] scale ed25519 signers in extraSigners --- .../simulation/TxSimApplyTransactionsWork.cpp | 36 ++++++++++++++++--- src/transactions/simulation/TxSimUtils.h | 2 ++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/catchup/simulation/TxSimApplyTransactionsWork.cpp b/src/catchup/simulation/TxSimApplyTransactionsWork.cpp index 097d226de8..543a0a8fc1 100644 --- a/src/catchup/simulation/TxSimApplyTransactionsWork.cpp +++ b/src/catchup/simulation/TxSimApplyTransactionsWork.cpp @@ -291,16 +291,31 @@ TxSimApplyTransactionsWork::addSignerKeys( return; } - for (auto const& signer : account.current().data.account().signers) - { - if (signer.key.type() == SIGNER_KEY_TYPE_ED25519) + auto maybeAddKey = [&](SignerKey const& signer) { + if (signer.type() == SIGNER_KEY_TYPE_ED25519) { - auto pubKey = KeyUtils::convertKey(signer.key); + auto pubKey = KeyUtils::convertKey(signer); if (hasSig(pubKey, sigs, txHash)) { keys.emplace(generateScaledSecret(pubKey, partition)); } } + }; + + for (auto const& signer : account.current().data.account().signers) + { + maybeAddKey(signer.key); + } + + auto const& env = mUpgradeProtocol + ? txbridge::convertForV13(*mTransactionIter) + : *mTransactionIter; + if (env.type() == ENVELOPE_TYPE_TX && env.v1().tx.cond.type() == PRECOND_V2) + { + for (auto const& signerKey : env.v1().tx.cond.v2().extraSigners) + { + maybeAddKey(signerKey); + } } } @@ -469,6 +484,19 @@ TxSimApplyTransactionsWork::scaleLedger( mutateScaledAccountID(newEnv.feeBump().tx.feeSource, partition); newTxHash = simulateSigs(outerSigs, outerTxKeys, false); } + else if (env.type() == ENVELOPE_TYPE_TX && + env.v1().tx.cond.type() == PRECOND_V2) + { + newEnv.v1().tx.cond.v2().extraSigners.clear(); + for (auto const& signerKey : env.v1().tx.cond.v2().extraSigners) + { + if (signerKey.type() == SIGNER_KEY_TYPE_ED25519) + { + newEnv.v1().tx.cond.v2().extraSigners.emplace_back( + generateScaledEd25519Signer(signerKey, partition)); + } + } + } // These are not exactly accurate, but sufficient to check result codes auto newRes = *mResultIter; diff --git a/src/transactions/simulation/TxSimUtils.h b/src/transactions/simulation/TxSimUtils.h index b85141e49c..6ab8853000 100644 --- a/src/transactions/simulation/TxSimUtils.h +++ b/src/transactions/simulation/TxSimUtils.h @@ -38,6 +38,8 @@ void generateScaledDeadEntries( poolIDToParam, uint32_t partition); +SignerKey generateScaledEd25519Signer(SignerKey const& signer, + uint32_t partition); SignerKey generateScaledEd25519Signer(Signer const& signer, uint32_t partition); SecretKey mutateScaledAccountID(AccountID& acc, uint32_t partition);