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

Add QuorumSignInfo and merge CertifiedTransaction with other Transaction types #1686

Merged
merged 4 commits into from
May 1, 2022

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Apr 30, 2022

CertifiedTransaction is also just a Transaction that's signed by authorities, making it very similar to SignedTransaction.
This PR introduces QuorumSignInfo as a new authority signature trait type, and define CertifiedTransaction using it.
This also allows us to unify some of the code, for example, the Transaction type now also has a cached digest field.

@@ -327,6 +372,10 @@ where
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(remote = "TransactionEnvelope")]
pub struct TransactionEnvelope<S> {
// This is a cache of an otherwise expensive to compute value.
// DO NOT serialize or deserialize from the network or disk.
#[serde(skip)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

<3

// in this ser/de context it's relevant to compare signatures
assert_eq!(o1.signatures, o2.signatures);
assert_eq!(o1.auth_sign_info.signatures, o2.auth_sign_info.signatures);
Copy link
Collaborator

@kchalkias kchalkias Apr 30, 2022

Choose a reason for hiding this comment

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

nice, I was originally puzzled re why do we compare signatures as they can be malleable, but this is for serde tests which makes sense.

@@ -485,10 +485,30 @@ impl PartialEq for AuthoritySignInfo {
}
}

#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub struct QuorumSignInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We usually refer to it as auth_sign_info, ideally we should pick a consistent name, either auth or quorum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe AuthQuorumSignInfo? We already have AuthSignInfo to represent a single authority signature

@@ -1081,7 +1081,7 @@ impl CertifiedTransaction {
is_checked: false,
data: transaction.data,
tx_signature: transaction.tx_signature,
auth_sign_info: QuorumSignInfo {
auth_sign_info: AuthorityQuorumSignInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, the readability problem is still remaining (cause while you read this you expect to see an AuthoritySignInfo), what about renaming auth_sign_info to quorum_sign_info and keep your previous QuorumSignInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

auth_sign_info can be one of EmptySignInfo, AuthoritySignInfo and AuthorityQuorumSignInfo.
So I don't think we want to rename it to quorum_sign_info.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm.. ok, let's leave it unchanged for now, we might consider renaming it to the more generic sign_info later, but don't change yet, auth_sign_info works for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same structure also contains transaction signature (tx_signature). So this is named auth_sign_info to emphasize that the signature is from authority side instead of from transaction signer.
But yeah open to better names!

@@ -485,10 +485,30 @@ impl PartialEq for AuthoritySignInfo {
}
}

#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
Copy link
Collaborator

@kchalkias kchalkias Apr 30, 2022

Choose a reason for hiding this comment

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

Also, we should note that certified txs can carry more than quorum sigs (every authority might in theory sign), and wondering if we should put a comment here to clarify it (unless quorum implies quorum+)

@lxfind lxfind force-pushed the crypto-add-quorum-sign-info branch from 037dd9d to aab7077 Compare April 30, 2022 05:50
@lxfind lxfind force-pushed the crypto-add-quorum-sign-info branch from aab7077 to feea7d1 Compare April 30, 2022 06:28
@lxfind lxfind merged commit 8bb5bbf into main May 1, 2022
@lxfind lxfind deleted the crypto-add-quorum-sign-info branch May 1, 2022 02:47
longbowlu pushed a commit that referenced this pull request May 12, 2022
…saction types (#1686)

* Add QuorumSignInfo

* Add cached digest to Tx envelope

* Merge CertifiedTransaction

* Rename QuorumSignInfo
punwai pushed a commit that referenced this pull request Jul 27, 2022
…saction types (#1686)

* Add QuorumSignInfo

* Add cached digest to Tx envelope

* Merge CertifiedTransaction

* Rename QuorumSignInfo
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.

None yet

2 participants