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

Improve signature collection UX #6174

Closed

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented May 8, 2020

addresses the concerns raised in #6111 (comment)

Note that this does not address multisig public keys, public key encoding or reserved field ranges. I intend to address those separately.

@auto-comment
Copy link

auto-comment bot commented May 8, 2020

👋 Thanks for creating a PR!

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

Thank you for your contribution to the Cosmos-SDK! 🚀

@aaronc aaronc mentioned this pull request May 8, 2020
11 tasks
@aaronc aaronc changed the title Address signature collection UX Improve signature gatherings UX May 8, 2020
@aaronc aaronc changed the title Improve signature gatherings UX Improve signature collection UX May 8, 2020
@@ -54,33 +54,57 @@ package cosmos_sdk.v1;

message Tx {
TxBody body = 1;
repeated bytes signatures = 2;
AuthInfo auth_info = 2;
repeated bytes signatures = 3;
Copy link
Member

Choose a reason for hiding this comment

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

How do you map signatures to the signers' pubkeys when AuthInfo.signer_infos is not sorted?

Copy link
Member Author

Choose a reason for hiding this comment

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

SignerInfo should be in the same order as signatures. This just proposes that the order of signers does not need to match the SDK's existing requirement about signature ordering which you pointed out could be hard for a client to compute.

PublicKey public_key = 1;
// address can be used for accounts that already have a public key in state
bytes address = 2;
}
Copy link
Member

Choose a reason for hiding this comment

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

Since this is not part of the TxBody anymore, this is only needed suring signing, right? So we can just use pubkey here (to reduce complexity) like we do right now in the StdSignature type.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed for both signing (by the primary signer) and tx broadcasting. Allowing the option to use address can reduce the tx size which could be significant if using a multisig pubkey.

// message handlers that examine the full list of signers on the transaction
// context
repeated SignerInfo signer_infos = 1;
uint64 gas = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Is this a gas_limit? A little doc comment what this field means would help, just a one-liner.

// Each signer can specify a fee that they are paying separately. In the case
// that the chain supports refunds for unused gas, refunds will be distributed
// to the last signer first.
Fee fee = 4;
Copy link
Member

Choose a reason for hiding this comment

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

This moves the fee and fee payer out of the signed content, right? Interesting. I'm not sure about all the consequences this has.

How can the signers coordinate such that enough fee is payed? Or is the first signer still the primary fee payer?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this model there could be more than one fee payer and the first signer would be the primary. But maybe it's not needed to have multiple fee payers?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think multiple fee payers are needed.

In the typical multisig case that I am aware of, a few employees sign a transaction and the company pays (the group's shared account) pays the fee. I don't know if that is possible right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove the multiple payers then and I think that will make this a lot easier to understand

}
```
* **No Malleability**: given a `TxBody` and an `AuthInfo` there is one and only
one valid `Tx` that can be generated
Copy link
Member

Choose a reason for hiding this comment

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

This is impossible to get, as described in https://medium.com/@simonwarta/signature-determinism-for-blockchain-developers-dbd84865a93e. Most likely it is not needed as well.

2. Sign the encoded `SignDocAux` bytes
3. Send their signature and `SignerInfo` to the tx composer(s) who will then
sign and broadcast the final transaction (with `SIGN_MODE_DIRECT` and fees and
gas added) once enough signatures have been collected
Copy link
Member

Choose a reason for hiding this comment

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

Why would the tx composer be a signer? It can be a moderator/secretary/notary/bot that is just responsible for composing a transaction, collection the signatures, putting everything together and broadcasting it.

Copy link
Member Author

Choose a reason for hiding this comment

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

So maybe this can be the primary signer who is the fee payer. The composer can be anyone. And anyone who had collected enough auxiliary signatures could sign the message with a fee.

* **No Malleability**: given a `TxBody` and an `AuthInfo` there is one and only
one valid `Tx` that can be generated
* **Predictable Gas**: if I am signing a transaction where I am paying a fee,
the final gas is fully dependent on what I am signing
Copy link
Member

Choose a reason for hiding this comment

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

Can you help me understand this point better: do we (right now and in the future) support an undefined number of signatures?

If not, the only purpose of this added complexity is to set different gas prices for different verification modes?

Copy link
Member Author

Choose a reason for hiding this comment

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

As I understand it, with multisigs currently it could be unpredictable because the signatures are nested. Also, I am noting this in contrast to weave where my reading is that it's generally unpredictable.

@aaronc
Copy link
Member Author

aaronc commented May 11, 2020

Since some of you have mentioned this was hard to understand, here is my attempt at explaining this PR more simply is:

  • SignerInfos and Fee moved from TxBody to a new type AuthInfo
  • the primary signer and fee payer signs over TxBody and AuthInfo
  • additional signers only need to sign TxBody and not AuthInfo

@aaronc aaronc mentioned this pull request May 13, 2020
4 tasks
@aaronc aaronc closed this May 13, 2020
@clevinson clevinson added this to the v0.39 milestone Jun 11, 2020
@alessio alessio deleted the aaronc/6030-update-adr-020-2 branch March 14, 2021 01:45
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.

3 participants