-
Notifications
You must be signed in to change notification settings - Fork 8
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
Create a dedicated ssv_types
crate.
#58
base: unstable
Are you sure you want to change the base?
Conversation
types
module. types
crate.
types
crate. ssv_types
crate.
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.
Nice! I had a few comments
pub type OperatorID = u64; | ||
|
||
/// Operator RSA public key | ||
pub type OperatorPublicKey = [u8; 459]; |
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.
If we are using RSA, we probably should use a specific library and its associated public key type.
Each library will have an RSAPublicKey struct. This object will have been verified when created or deserialized. If we use this type, then there is no chance that we are carrying around invalid/malicious bytes in other types.
I think we want to deserialize any public key we get from the network instantly or reject the message, then we carry around only verified and valid keys throughout our types.
i.e our types shouldn't really be bytes anywhere, unless we have to have them.
@@ -0,0 +1,14 @@ | |||
/// Unique identifier for an Operator | |||
pub type OperatorID = u64; |
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.
For things that we will be using a lot, we should use the new type idiom: https://doc.rust-lang.org/rust-by-example/generics/new_types.html
This enforces the type at compile time, so we can't get confused by accidentally putting another type that is a u64 in place of this.
For the operator-id, I have already done this. See here - I used usize, (I didn't check the specs :p, if the specs say u64, then we should change it to that).
#[derive(Debug, Clone)] | ||
pub struct SSVShare { | ||
pub share: Share, | ||
pub metadata: Metadata, |
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.
You've been awesome with comments on all the fields, might as well be consistent here
use types::Domain; | ||
|
||
/// Unique identifier for a committee. | ||
pub type CommitteeID = u64; |
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.
Same here as operator id.
Its a bit cumbersome, but it does pay dividends in the future
Issue Addressed
N/A
Proposed Changes
This PR starts a
ssv_types
crate withinanchor/common
. It contains core SSV types in accordance with the spec. It does not contain related methods as we still need to determine what is needed, but just having these types defined helps. Validator related types are imported via thetypes
crate in lighthouse.Additional Info
This is just an initial draft to get the ball rolling. It will change as we see fit. Also waiting on re-export of
ValidatorIndex
in lighthouse into unstable.