-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
…Proof->::QC, partial_sign->sign, active_keys->signers
src/qc.rs
Outdated
| message: &GenericArray<A::MessageUnit, Self::MessageLength>, | ||
| qc: &Self::QC, | ||
| ) -> Result<Self::CheckedType, PrimitivesError>; | ||
| ) -> Result<(), PrimitivesError>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I remember why this is here now. It's not the Checked<T>. And it is needed.
I'm even the person who requested it, I just forgot.
And I think the entire discussion motivating this was on github.
... 90 minutes of searching later...
Short version: we absolutely, non-negotiably, need the CheckedType if we want to be able to use this from HotShot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for digging this comment for us! could you clarify what would the number CheckedType = U256 signify?
the number of votes inside the qc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of HotShot, the total number of voted shares, I think...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Another question I had is if we should turn cc @philippecamacho @nyospe @mrain Will continue this work #65. |
|
cc @dailinsubjam as this might also affect the QC integration work. |
|
It should probably be a trait that can be applied to the actual stake table, yes... |
|
After rerunning the build, it failed. I also have an error on my machine. |
This is likely due to caching of cargo build in CI and failed to point to the right jellyfish version. The best way to solve it is version controlling Cargo.lock. |
nyospe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to post this comment on Friday morning... oops.
| type QC; | ||
|
|
||
| /// Type of the quorum size (e.g. number of votes or accumulated weight of signatures) | ||
| type QuorumSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to decide how I feel about this. There's one use case for it as-is, but that's not the only way we would use it in HotShot, and this creates an implied, but unenforced, property restriction on the associated type.
I'd prefer a name that more clearly says "A precise statement about how this Certificate meets (or exceeds) the condition for validity, specific to the usage of this specific Certificate type."
Originally, I had requested some updates to QCParams. This is not strictly required, but would allow a convenient improvement. Let me illustrate.
We have the following certificates in HotShot (this is not a comprehensive list, these are the specific ones that are involved in this use case)
QuorumCertificate (certificate that a quorum of replicas has committed to accepting a sequence with a given hash/commitment, parent, and view number, contingent on eventual evidence of full availability; e.g. voted 'Yes' on the proposal)
RejectCertificate (certificate that a superminority (e.g. F+1) of replicas has seen and rejected the same proposal seen above)
ViewFailedNextViewCertificate (certificate that the previous view was proposed, but failed, and control should now progress to the appropriate proposer for the subsequent view sequence)
Now, we actually have an enumeration NextViewCertificate, which may be a few things, including a token that says "check the QuorumCertificate", because a valid QC is also sufficient evidence to allow view progress, but let's just look at this one.
ViewFailedNextViewCertificate can be implemented as follows:
struct ViewFailedNextViewQC;
impl<A> hsp::QuorumCertificate<A> for ViewFailedNextViewQC<A>
where A:... {
type QuorumSize = (U256, U256);
type QC = (hsp::BitVectorQC<A>::QC, hsp::BitVectorQC<A>::QC);
// shared QCParams, except for overrides for the thresholds for Yes and No thresholds.
// There's also a max threshold for this case, but it is derivable. It would be really nice if QCParams was composable, so that we could supply the same stake_entries/agg_sig_pp and switch in different threshold values.
type QCVerifierParams = (hsp::BitVectorQC<A>::QCVerifierParams, hsp::BitVectorQC<A>::QCVerifierParams);
// ..
fn check(
qc_vp: &Self::QCVerifierParams,
message: &GenericArray<A::MessageUnit, Self::MessageLength>,
qc: &Self::QC,
) -> Result<Self::QuorumSize, PrimitivesError> {
let totals = (hsp::BitVectorQC<A>::check(qc_vp.0, message, qc.0)?, hsp::BitVectorQC<A>::check(qc_vp.1, message, qc.1)?);
if totals.0 > 2 * (qc_vp.1 - 1) {
// Yes votes over 2F threshold. Should be impossible.
return Err(ParameterError(...));
}
if totals.0 + totals.1 < 2 * qc_vp.1 - 1 {
// Total votes under 2F+1 threshold
return Err(ParameterError(...));
}
Ok(totals)
}
}As you can see, this is not completely copacetic with the QuorumSize naming...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the detailed clarification @nyospe! this is super helpful.
when I read your snippet above, I still think QuorumSize is not a bad name.
the semantic meaning of QC::check() is to check the validity of a certificate, and as you illustrated in the ViewFailedNextViewQC example, such a certificate can be a composite (tuple in this case) of several other vanilla aggregated-signature style QCs; and the validity condition depends on the status (i.e. composite quorum size) of its constituents.
Else, what about QuorumStatus or QuorumProgress, neither is clearly better than QuorumSize.
maybe a second opinion here? @dailinsubjam @philippecamacho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QuorumSize also seems natural to me and we should have a type anyways to capture this concept. I am not sure how to express the possible multidimensions aspect like in ViewFailedNextViewQC yet still in the end we are comparing numbers (size) against some threshold.
|
The type of message inputted to signing function is &GenericArray<A::MessageUnit, Self::MessageLength>, where |
cc @philippecamacho for this question. |
We decided to only allow fixed length for the input of the signing function, meaning we expect the message to be some kind of commitment on the data. @nyospe What is the the canonical way to compute a commitment over QC data in Hotshot? |
After today's discussion we plan to change the code in |
nyospe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still a few things about this that aren't very ergonomic, but it's better than it was before, and we have hacks/workarounds for use within HotShot, and maybe those can be revisited once this part has been moved to hotshot.
Changes include:
trait QuorumCertificateValidation->trait QuorumCertificatestruct BitvectorQuorumCertificate->struct BitVectorQC::parti_sign()->::sign()(consistent with hotshot spec)active_keys->signersCheckedTypeas @nyospe pointed out that we don't need this.Proof, and replace withQCassemble()andcheck()to deal withSelf::QCdirectly (consistent with Hotshot spec)trace()API and tests