Skip to content

Conversation

@varun-doshi
Copy link
Contributor

@varun-doshi varun-doshi commented Oct 16, 2025

What was wrong?

Fixes #840

Changes:

  • Vote -> Rename AttestationData
  • Add AggregatedAttestation, SignedAggregatedAttestation
  • SignedVote -> Rename to SignedAttestation and fix message type as Attestation
  • Fix existing attestation.rs
  • Remove a few unnecessary clones
  • Other changes to comply with the new types

How was it fixed?

Implement some changes fromm ongoing spec PR: leanEthereum/leanSpec#67

To-Do

  • Our SignedBlock is diverged from current ongoing spec change. This should be VariableList<SignedAttestation, U4096> but since we are yet to implement SignedBlockAndVote(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 use Attestation the code wont compile because our db saves SignedAttestation

@varun-doshi varun-doshi changed the title Varun/lean attestation feat: Update containers for Vote and Attestation Oct 16, 2025
@varun-doshi varun-doshi marked this pull request as ready for review October 16, 2025 09:35
@jihoonsong
Copy link
Contributor

Do we want to wait until the spec PR is merged?

@KolbyML
Copy link
Contributor

KolbyML commented Oct 16, 2025

Do we want to wait until the spec PR is merged?

yes

Copy link
Contributor

@KolbyML KolbyML left a 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

pub async fn on_attestation_from_block(
&mut self,
signed_votes: impl IntoIterator<Item = SignedVote>,
signed_votes: impl IntoIterator<Item = SignedAttestation>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Member

@syjn99 syjn99 Oct 22, 2025

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varun-doshi varun-doshi requested a review from syjn99 October 22, 2025 16:08
Copy link
Contributor

@jihoonsong jihoonsong left a 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 {
Copy link
Contributor

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.

Copy link
Member

@syjn99 syjn99 left a 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.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>,
Copy link
Member

@syjn99 syjn99 Oct 22, 2025

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.

Copy link
Member

@syjn99 syjn99 left a 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.

Comment on lines 316 to 317
for signed_attestations in attestations {
let attestations = &signed_attestations.message;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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

@varun-doshi varun-doshi enabled auto-merge October 23, 2025 03:23
Copy link
Contributor

@jihoonsong jihoonsong left a 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!

@varun-doshi varun-doshi requested a review from KolbyML October 25, 2025 08:07
@KolbyML
Copy link
Contributor

KolbyML commented Oct 25, 2025

I will review this when I wake up

Copy link
Contributor

@KolbyML KolbyML left a 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

Comment on lines 11 to 53
/// 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.
Copy link
Contributor

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

Comment on lines 30 to 45
// 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.
Copy link
Contributor

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
Copy link
Contributor

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

Comment on lines 72 to 74
// 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).
Copy link
Contributor

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

Copy link
Contributor

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

@varun-doshi varun-doshi added this pull request to the merge queue Oct 28, 2025
@KolbyML KolbyML removed this pull request from the merge queue due to a manual request Oct 28, 2025
@varun-doshi varun-doshi force-pushed the varun/lean-attestation branch from 0d2235b to 1e662d6 Compare October 28, 2025 13:39
@varun-doshi varun-doshi added this pull request to the merge queue Oct 28, 2025
Merged via the queue into ReamLabs:master with commit fc63bed Oct 28, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update SSZ containers regarding attestation

4 participants