-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor: align attestation containers with LeanSpec (Issue #26) #41
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
base: devnet-2
Are you sure you want to change the base?
Conversation
ArtiomTr
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.
looks good, although few things need to be fixed
|
|
||
| // Type-level number for 3112 bytes | ||
| pub type U3112 = Sum<U3100, U12>; | ||
| pub type U3112 = Sum<Prod<U31, U100>, U12>; |
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 keep / export this type
| pub fn verify(&self) -> bool { | ||
| true | ||
| } |
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 probably should be replaced with actual implementation
| type Error = String; | ||
| fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> { | ||
| ByteVector::<U3112>::try_from(bytes) | ||
| .map(Signature) | ||
| .map_err(|e| format!("{:?}", e)) | ||
| } |
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.
why changing error type to string? you can just use the error type that ByteVector's try from provides for you
lean_client/containers/src/config.rs
Outdated
| pub genesis_time: u64, | ||
| } | ||
|
|
||
| #[serde(default = "default_seconds_per_slot")] |
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 believe there is no need to define function here, as you can just use constant. Also, because this is declared in one place, you can just directly hardcode value here, without additional functions/constants
lean_client/containers/src/config.rs
Outdated
| use std::path::Path; | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] | ||
| #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, Ssz)] |
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.
Is config should really be ssz-serializable?
lean_client/containers/src/config.rs
Outdated
| pub genesis_validators: Vec<String>, | ||
| #[ssz(skip)] | ||
| #[serde(default)] | ||
| pub genesis_validators: Vec<serde_json::Value>, |
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 this should be more concrete type, not array of any values
lean_client/containers/src/types.rs
Outdated
| pub type Bytes32 = H256; | ||
| pub type Uint64 = 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.
these aren't necessary anymore I think
| _ => return curr, | ||
| }; | ||
|
|
||
| // Choose best child: most attestations, then lexicographically highest hash |
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.
why so many comments removed? I wouldn't say those were unnecessary. Better to have some explanation
| pub fn new() -> Self { | ||
| let justification_lookback_slots: u64 = 3; | ||
| let seconds_per_slot: u64 = 12; | ||
| let seconds_per_slot: u64 = 4; |
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.
shouldn't this be taken from config?
| source_slot = store.latest_justified.slot.0, | ||
| "Created attestation with zero signature" | ||
| ); | ||
| Signature::default() |
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.
don't think this is correct. but anyway - removing this info! is not correct, as it was signalling that something gone wrong. I would change this info! to warn! at least, but not remove it
|
looks like this needs some rebasing |
Overview
This PR completes the refactoring of the configuration system, addressing both #25 and #26. It removes redundancy by eliminating global constants and merging configuration structures into a single source of truth.
Changes
GenesisConfigandConfiginto a singleConfigstruct.SECONDS_PER_SLOT,INTERVALS_PER_SLOT, andSECONDS_PER_INTERVAL. Components now fetch these values fromstore.config.chain/src/lib.rsto exportChainConfigdirectly viapub use.camelCaserenaming and default values toConfigto maintain compatibility with existing JSON test vectors.Related Issues