-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use ValidatorPublicKey instead of ValidatorName #3372
Conversation
2061f04
to
c858a43
Compare
c858a43
to
7471c40
Compare
1c45355
to
7bcec3b
Compare
7bcec3b
to
b3e6534
Compare
07d9ca9
to
3c76e1e
Compare
3c76e1e
to
9293417
Compare
@@ -330,7 +330,7 @@ impl Ed25519Signature { | |||
pub fn verify_batch<'a, 'de, T, I>(value: &'a T, votes: I) -> Result<(), CryptoError> | |||
where | |||
T: BcsSignable<'de>, | |||
I: IntoIterator<Item = (&'a Ed25519PublicKey, &'a Ed25519Signature)>, |
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.
Inside the ed25519
module I wouldn't use the alias.
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.
Yes, found that in the next PR. Will push here.
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.
Actually, I'm gonna do that in the follow-up PRs to avoid waiting for the CI again.
@@ -916,7 +916,7 @@ pub(crate) fn check_signatures( | |||
); | |||
// All that is left is checking signatures! | |||
let hash_and_round = VoteValue(value_hash, round, certificate_kind); | |||
ValidatorSignature::verify_batch(&hash_and_round, signatures.iter().map(|(v, s)| (&v.0, s)))?; | |||
ValidatorSignature::verify_batch(&hash_and_round, signatures.iter().map(|(v, s)| (v, s)))?; |
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.
ValidatorSignature::verify_batch(&hash_and_round, signatures.iter().map(|(v, s)| (v, s)))?; | |
ValidatorSignature::verify_batch(&hash_and_round, &signatures)?; |
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.
This won't work. The argument type is an iterator over references - not a reference to something that can be turned into an iterator.
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.
Maybe verify_batch
should actually accept an IntoIterator
.
And even if not, wouldn't signatures.iter()
suffice? Is the .map(|(v, s)| (v, s))
really necessary?
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.
verify_batch
already accepts IntoIterator
.
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.
Actually - it works 🤔 IDK why it didn't compile earlier.
|
||
let committee = Committee::make_simple(vec![name1, name2]); | ||
let committee = Committee::make_simple(vec![validator1_pk, validator2_pk]); |
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.
No need to introduce those two, since below you use v1.public_key
anyway instead of validator1_pk
.
let committee = Committee::make_simple(vec![validator1_pk, validator2_pk]); | |
let committee = Committee::make_simple(vec![key1.public(), key2.public()]); |
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.
(No blockers from my side.)
Motivation
Currently we're using
ValidatorName
(a newtype wrapper aroundValidatorPublicKey
) in many places where it's not making any quality improvements. I'd argue that it's:ValidatorName
and, next to it,ValidatorSignature
that we verify withvalidator_name.public_key
)Proposal
Replace usage of
ValidatorName
withValidatorPublicKey
. Also rename field names fromname
topublic_key
- this affects the RPC format and CLI.Test Plan
CI should catch any regressions.
Release Plan
Links