Skip to content

Commit

Permalink
scale ed25519 signers in extraSigners
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Apr 13, 2022
1 parent 0da09fe commit 0e5c9e6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/catchup/simulation/TxSimApplyTransactionsWork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PublicKey>(signer.key);
auto pubKey = KeyUtils::convertKey<PublicKey>(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);
}
}
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/transactions/simulation/TxSimUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

5 comments on commit 0e5c9e6

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from MonsieurNicolas
at sisuresh@0e5c9e6

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sisuresh/stellar-core/cap21-40-2 = 0e5c9e6 into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sisuresh/stellar-core/cap21-40-2 = 0e5c9e6 merged ok, testing candidate = 27c798e

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 27c798e

Please sign in to comment.