Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIT-3995 - (wrapped-keys) - Add signTransaction functionality to supported actions for batchGeneratePrivateKeys #702

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

MaximusHaximus
Copy link
Contributor

@MaximusHaximus MaximusHaximus commented Oct 22, 2024

Description

  • Allows consumers to provide a transaction to be signed by each key they request be generated, in the same LIT action execution as the key is generated in. Basically matches the sign message capability, but for transactions.
  • I'm not sure how useful this is with our Solana integration; the existing sign transaction test logic fails with 'unknown signer' -- I think that's because the serialized TX expects the fromPubkey and feePayer in the serialized TX to match the pubKey of the generated key that is doing the signer -- but obviously that can't happen since we generate the key in the LIT action runtime. 🤔

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Ran all existing wrapped-keys local-tests
  • Updated local-tests/tests/wrapped-keys/testBatchGeneratePrivateKeys.ts to sign an ethereum tx and verify the signature returned is hex (same logic as our existing signTransactionEthereum test)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@MaximusHaximus MaximusHaximus changed the base branch from master to feat/convert-wrapped-keys-lit-actions-to-ts October 22, 2024 21:55
@MaximusHaximus MaximusHaximus marked this pull request as draft October 22, 2024 21:55
@MaximusHaximus MaximusHaximus changed the title LIT-3995 - (wrapped-keys) - Add signTransaction functionality to supported actions for batchGeneratePrivateKeys [WiP] - LIT-3995 - (wrapped-keys) - Add signTransaction functionality to supported actions for batchGeneratePrivateKeys Oct 22, 2024
@MaximusHaximus MaximusHaximus force-pushed the LIT-3995-batchGenKeysAddSignTx branch from 250aff5 to 2c075d6 Compare October 22, 2024 22:30
…h batchGeneratePrivateKeys

- This doesn't work for Solana yet, because our test requires the keyPair from the generated key to serialize the TX
@MaximusHaximus MaximusHaximus marked this pull request as ready for review October 22, 2024 23:28
@MaximusHaximus MaximusHaximus changed the title [WiP] - LIT-3995 - (wrapped-keys) - Add signTransaction functionality to supported actions for batchGeneratePrivateKeys LIT-3995 - (wrapped-keys) - Add signTransaction functionality to supported actions for batchGeneratePrivateKeys Oct 22, 2024
Base automatically changed from feat/convert-wrapped-keys-lit-actions-to-ts to master October 23, 2024 18:16
@MaximusHaximus MaximusHaximus requested review from DashKash54 and removed request for joshLong145 October 24, 2024 18:43
Copy link
Collaborator

@DashKash54 DashKash54 left a comment

Choose a reason for hiding this comment

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

The reason it works for Ethereum tx is because internally in the signTransactionEthereumKey() we add the from address:


We always need to provide the from address (and feePayer as well in Solana tx). Since we're generating the wallet and signing right after that the user can just provide the params that we can use to craft a tx object inside the LA itself.
Note: The user should always provide the gas and anything else that currently requires an RPC call as we should no longer support making RPC calls from within the LA as it causes arbitrary delay due to the blockchain. Therefore, we shouldn't even support tx broadcast or at least not in the batchGenerate(). Since we're just creating the wallet the nonce will be 0. @MaximusHaximus lemme know if you have any questions

Comment on lines +153 to +155
if (!ethers.utils.isHexString(signedEthTx)) {
throw new Error(`signedTx isn't hex: ${signedEthTx}`);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we verify that the signed tx is from the the generated wallet?

unsignedTransaction
? signTransactionEthereumKey({
unsignedTransaction,
broadcast: action.signTransactionParams?.broadcast || false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't allow broadcast in the batchGenerate function as it uses RPC which can take arbitrary amounts of time?

: Promise.resolve(),
unsignedTransaction
? signTransactionSolanaKey({
broadcast: action.signTransactionParams?.broadcast || false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't allow broadcast?

network: Extract<Network, 'solana'>;
signTransactionParams?: {
unsignedTransaction: SerializedTransaction;
broadcast?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not include the broadcast field it should always be false?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@MaximusHaximus we don't wanna allow fetching nonce, gas, etc or anything from the RPC. It should all be provided by the user either as a serialized tx or as params and we could construct the transaction inside the LA but we should not fetch anything from the RPC we can remove this fetching altogether

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants