-
Notifications
You must be signed in to change notification settings - Fork 64
feat: Update containers for Vote and Attestation #855
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
feat: Update containers for Vote and Attestation #855
Conversation
|
Do we want to wait until the spec PR is merged? |
yes |
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.
Hopefully they fix the upstream spec
cb70798 to
61082d7
Compare
| pub async fn on_attestation_from_block( | ||
| &mut self, | ||
| signed_votes: impl IntoIterator<Item = SignedVote>, | ||
| signed_votes: impl IntoIterator<Item = SignedAttestation>, |
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.
| signed_votes: impl IntoIterator<Item = SignedAttestation>, | |
| signed_attestations: impl IntoIterator<Item = SignedAttestation>, |
We're gonna drop all vote jargons, so I'd suggest to fix the parameter name as well.
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.
Fixed; I've tried to remove most if not all vote jargons from the lean flow
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.
Do you want to open a PR to the Lean spec to change gossip topic from vote to attestation? @syjn99
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 can do it as well
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.
@varun-doshi
Yes, I think this PR can change the gossip topic as well, along with a PR on leanSpec.
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 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 some variables that named after vote in lean_block.rs and state.rs. It's just name changes so having it in this PR would be simpler imo
| /// for detailed protocol information. | ||
| #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash)] | ||
| pub struct Attestation { | ||
| pub struct AggregatedAttestation { |
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 AggregatedAttestations similar to AggregatedSignatures. I've left a comment in the spec PR, let's see.
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.
Overall good, I couldn't find any issues on this PR. Just some renaming stuffs are remaining.
| if !self | ||
| .justified_slots | ||
| .get(vote.source.slot as usize) | ||
| .get(vote.source().slot as usize) |
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.
| .get(vote.source().slot as usize) | |
| .get(attestation.source().slot as usize) |
Can we rename this as well?
| pub async fn on_attestation_from_block( | ||
| &mut self, | ||
| signed_votes: impl IntoIterator<Item = SignedVote>, | ||
| signed_votes: impl IntoIterator<Item = SignedAttestation>, |
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.
@varun-doshi
Yes, I think this PR can change the gossip topic as well, along with a PR on leanSpec.
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.
LGTM, just a small renaming left.
| for signed_attestations in attestations { | ||
| let attestations = &signed_attestations.message; |
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 signed_attestations in attestations { | |
| let attestations = &signed_attestations.message; | |
| for signed_attestation in attestations { | |
| let attestation = &signed_attestation.message; |
Minor plural issues
| let root2 = B256::repeat_byte(2); | ||
|
|
||
| // root0 is voted by validator 0 | ||
| // root0 is attestationsd by validator 0 |
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 like this part is also changed by using IDE features
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.
It's not critical but some comments are outdated (they're using vote). Other than that, looks good!
|
I will review this when I wake up |
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.
Here is some feedback
| /// TODO: Add link from spec once finalized. | ||
| #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash)] | ||
| pub struct AttestationData { | ||
| pub slot: u64, | ||
| pub head: Checkpoint, | ||
| pub target: Checkpoint, | ||
| pub source: Checkpoint, | ||
| } | ||
|
|
||
| /// Validator specific attestation wrapping shared attestation data. | ||
| /// | ||
| /// TODO: Add link from spec once finalized. | ||
| #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash)] | ||
| pub struct Attestation { | ||
| pub validator_id: u64, | ||
| pub data: AttestationData, | ||
| } | ||
|
|
||
| impl Attestation { | ||
| // Return the attested slot. | ||
| pub fn slot(&self) -> u64 { | ||
| self.data.slot | ||
| } | ||
|
|
||
| // Return the attested head checkpoint. | ||
| pub fn head(&self) -> Checkpoint { | ||
| self.data.head | ||
| } | ||
|
|
||
| // Return the attested target checkpoint. | ||
| pub fn target(&self) -> Checkpoint { | ||
| self.data.target | ||
| } | ||
|
|
||
| // Return the attested source checkpoint. | ||
| pub fn source(&self) -> Checkpoint { | ||
| self.data.source | ||
| } | ||
| } | ||
|
|
||
| /// Validator attestation bundled with its signature. | ||
| /// | ||
| /// TODO: Add link from spec once finalized. |
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 don't see the value in linking the spec here, this isn't a niche complex example, so I think this is an anti pattern
| // Return the attested slot. | ||
| pub fn slot(&self) -> u64 { | ||
| self.data.slot | ||
| } | ||
|
|
||
| // Return the attested head checkpoint. | ||
| pub fn head(&self) -> Checkpoint { | ||
| self.data.head | ||
| } | ||
|
|
||
| // Return the attested target checkpoint. | ||
| pub fn target(&self) -> Checkpoint { | ||
| self.data.target | ||
| } | ||
|
|
||
| // Return the attested source checkpoint. |
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 should be doc comments ///
| #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash)] | ||
| pub struct SignedAttestation { | ||
| pub message: Attestation, | ||
| // signature over attestaion message only as it would be aggregated later in attestation |
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 should be a doc comment
| // Diverged from current ongoing spec change. This should be | ||
| // `VariableList<ValidatorAttestation, U4096>` but since we are yet to implement | ||
| // `SignedBlockAndVote`(these are still being reviewed). |
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 should be a doc comment, and should have a todo tag and link to the PR in question
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.
or issue etc, this is a todo which isn't clearly marked
0d2235b to
1e662d6
Compare
What was wrong?
Fixes #840
Changes:
AttestationDataAggregatedAttestation,SignedAggregatedAttestationSignedVote-> Rename toSignedAttestationand fix message type asAttestationattestation.rsHow was it fixed?
Implement some changes fromm ongoing spec PR: leanEthereum/leanSpec#67
To-Do
VariableList<SignedAttestation, U4096>but since we are yet to implementSignedBlockAndVote(these are still being reviewed). This will be done in a follow PR once the spec change has stabalized a bit. For context if we useAttestationthe code wont compile because our db savesSignedAttestation