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

feat: tx sign and new signer #1590

Merged
merged 26 commits into from
Sep 24, 2024
Merged

feat: tx sign and new signer #1590

merged 26 commits into from
Sep 24, 2024

Conversation

willemneal
Copy link
Member

@willemneal willemneal commented Sep 10, 2024

The new sign subcommand allows for signing a passed transaction envelope.

Additionally, signer::{Transaction, TransactionHash} traits which simplifies the interface. Transaction has just a single method which returns a DecoratedSignature. TransactionHash breaks this up into two methods to get a Signature and a SignatureHint.

The new `sign` subcommand allows for signing a passed transaction envelope. And can choose a different source_account than the signing key's corresponding public key.

Additionally, `signer::{Transaction, TransactionHash, Blob}` traits which simplifies the interface. Using blanket implementations, any type that implements `Blob`, will implement, `TransactionHash` and any type that implements `TransactionHash` implements `Transaction`, which uses the hash. This will allow for types to opt in to how they want to sign the transaction.
This was referenced Sep 13, 2024
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

A few issues with this command, elaborated inline:

  • Signing shouldn't require specifying a source account.
  • Signing shouldn't be able to alter the source account.
  • Signing shouldn't require additional user confirmation, given the command's only purpose is to sign.
  • Trait mechanics. See inline. I think @Ifropc might have commented on this in the past too.

cmd/crates/soroban-test/tests/it/integration/tx.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/Cargo.toml Outdated Show resolved Hide resolved
cmd/soroban-cli/src/config/sign_with.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/config/sign_with.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/config/sign_with.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/signer/types.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/signer/types.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/signer/types.rs Outdated Show resolved Hide resolved
willemneal and others added 5 commits September 16, 2024 09:36
Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
Remove Blob trait. Add to TransactionHash trait to include hint. Move print to top level signer and fix test. Also remove the prompt for this PR since the sign command is already approval for signing.
@leighmcculloch
Copy link
Member

leighmcculloch commented Sep 23, 2024

I've been pushing some tweaks directly to this PR to try something out, but I had to step away midway through. Will return, but maybe don't look too hard at the moment. Happy to also revert or force push the commits away.

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

I've pushed a series of changes that I think simplify the type system around the new logic being added. The new logic is largely unchanged, just moved out of the trait system.

I was going to leave a comment with the suggestion, but wanted to try it out before suggesting, and then discovered some things along the way.

The changes involved in brief:

  • Removing traits Stellar, TransactionHash, Transaction. Part of the design of the StellarSigner that was already in this PR was an enum containing the different keys, and it then called each function on its key type anyway. So we actually don't need the implementations of different keys to sit behind a common trait, at least not yet with what's presented in this PR. Also the traits were implemented at two layers (both StellarSigner and LocalKey), which was confusing. I think we can bring back traits when they add value, but it seems like the design of StellarSigner already satisfies.
  • Removing terms like "accounts" in any of the signing logic, since these aren't accounts, just keys.
  • Updated the signing code used by other fns to call through to the StellarSigner. Doing this only required ~4 lines of code because of how the StellarSigner was already designed, and it means after this PR merges we still only have one signing implementation for txs.

I'm approving this PR, but now that I've contributed changes, it would be ideal if @fnando you could 👀 the PR as a whole and sign off before we merge.

cmd/soroban-cli/src/config/sign_with.rs Outdated Show resolved Hide resolved
cmd/crates/soroban-test/tests/it/integration/tx.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/config/sign_with.rs Show resolved Hide resolved
cmd/soroban-cli/src/config/sign_with.rs Outdated Show resolved Hide resolved
@willemneal
Copy link
Member Author

@leighmcculloch Thanks for the clean up. I do think it's ready to be merged and we can iterate when the demands change.

@willemneal willemneal changed the title feat: tx sign and new traits for signing feat: tx sign and new signer Sep 23, 2024
Copy link
Contributor

@Ifropc Ifropc left a comment

Choose a reason for hiding this comment

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

Like the new PR, very compact and simple!

cmd/soroban-cli/src/signer.rs Outdated Show resolved Hide resolved
@leighmcculloch leighmcculloch enabled auto-merge (squash) September 24, 2024 02:34
@leighmcculloch leighmcculloch merged commit ff57159 into main Sep 24, 2024
25 checks passed
@leighmcculloch leighmcculloch deleted the feat/tx_sign branch September 24, 2024 02:37
elizabethengelman pushed a commit that referenced this pull request Sep 24, 2024
Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
@willemneal willemneal linked an issue Oct 2, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add a tx sign command
5 participants