diff --git a/lean_client/containers/src/attestation.rs b/lean_client/containers/src/attestation.rs new file mode 100644 index 0000000..68e2622 --- /dev/null +++ b/lean_client/containers/src/attestation.rs @@ -0,0 +1,87 @@ +use crate::{Checkpoint, Slot, Uint64}; +use ssz::ByteVector; +use ssz_derive::Ssz; +use serde::{Deserialize, Serialize}; +use typenum::{Prod, U100, U31}; + +// Type-level number for 3100 bytes (signature size) = 31 * 100 +pub type U3100 = Prod; + +// Type alias for Signature +pub type Signature = ByteVector; + +// Type-level number for 4096 (validator registry limit) +use typenum::U4096; + +/// List of validator attestations included in a block (without signatures). +/// Limit is VALIDATOR_REGISTRY_LIMIT (4096). +pub type Attestations = ssz::PersistentList; + +/// List of signatures corresponding to attestations in a block. +/// Limit is VALIDATOR_REGISTRY_LIMIT (4096). +pub type BlockSignatures = ssz::PersistentList; + +/// Bitlist representing validator participation in an attestation. +/// Limit is VALIDATOR_REGISTRY_LIMIT (4096). +pub type AggregationBits = ssz::BitList; + +/// Naive list of validator signatures used for aggregation placeholders. +/// Limit is VALIDATOR_REGISTRY_LIMIT (4096). +pub type AggregatedSignatures = ssz::PersistentList; + +/// Attestation content describing the validator's observed chain view. +#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] +pub struct AttestationData { + /// The slot for which the attestation is made. + pub slot: Slot, + /// The checkpoint representing the head block as observed by the validator. + pub head: Checkpoint, + /// The checkpoint representing the target block as observed by the validator. + pub target: Checkpoint, + /// The checkpoint representing the source block as observed by the validator. + pub source: Checkpoint, +} + +/// Validator specific attestation wrapping shared attestation data. +#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] +pub struct Attestation { + /// The index of the validator making the attestation. + pub validator_id: Uint64, + /// The attestation data produced by the validator. + pub data: AttestationData, +} + +/// Validator attestation bundled with its signature. +#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] +pub struct SignedAttestation { + /// The attestation message signed by the validator. + pub message: Attestation, + /// Signature aggregation produced by the leanVM (SNARKs in the future). + pub signature: Signature, +} + +/// Aggregated attestation consisting of participation bits and message. +#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] +pub struct AggregatedAttestations { + /// Bitfield indicating which validators participated in the aggregation. + pub aggregation_bits: AggregationBits, + /// Combined attestation data similar to the beacon chain format. + /// + /// Multiple validator attestations are aggregated here without the complexity of + /// committee assignments. + pub data: AttestationData, +} + +/// Aggregated attestation bundled with aggregated signatures. +#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] +pub struct SignedAggregatedAttestations { + /// Aggregated attestation data. + pub message: AggregatedAttestations, + /// Aggregated attestation plus its combined signature. + /// + /// Stores a naive list of validator signatures that mirrors the attestation + /// order. + /// + /// TODO: this will be replaced by a SNARK in future devnets. + pub signature: AggregatedSignatures, +} diff --git a/lean_client/containers/src/block.rs b/lean_client/containers/src/block.rs index 75f6873..ba4cd3e 100644 --- a/lean_client/containers/src/block.rs +++ b/lean_client/containers/src/block.rs @@ -1,13 +1,15 @@ -use crate::{Bytes32, Slot, SignedVote, ValidatorIndex, U4000}; -use ssz::{ByteVector, PersistentList as List}; +use crate::{Attestation, Attestations, BlockSignatures, Bytes32, Slot, ValidatorIndex, Signature}; use ssz_derive::Ssz; use serde::{Deserialize, Serialize}; -use typenum::U4096; +/// The body of a block, containing payload data. +/// +/// Attestations are stored WITHOUT signatures. Signatures are aggregated +/// separately in BlockSignatures to match the spec architecture. #[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] pub struct BlockBody { #[serde(with = "crate::serde_helpers")] - pub attestations: List, + pub attestations: Attestations, } #[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] @@ -29,10 +31,31 @@ pub struct Block { pub body: BlockBody, } +/// Bundle containing a block and the proposer's attestation. +#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] +pub struct BlockWithAttestation { + /// The proposed block message. + pub block: Block, + /// The proposer's attestation corresponding to this block. + pub proposer_attestation: Attestation, +} + +/// Envelope carrying a block, an attestation from proposer, and aggregated signatures. +#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] +pub struct SignedBlockWithAttestation { + /// The block plus an attestation from proposer being signed. + pub message: BlockWithAttestation, + /// Aggregated signature payload for the block. + /// + /// Signatures remain in attestation order followed by the proposer signature. + pub signature: BlockSignatures, +} + +/// Legacy signed block structure (kept for backwards compatibility). #[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] pub struct SignedBlock { pub message: Block, - pub signature: ByteVector, + pub signature: Signature, } /// Compute the SSZ hash tree root for any type implementing `SszHash`. diff --git a/lean_client/containers/src/lib.rs b/lean_client/containers/src/lib.rs index dbd251a..5dd16a5 100644 --- a/lean_client/containers/src/lib.rs +++ b/lean_client/containers/src/lib.rs @@ -2,17 +2,22 @@ pub mod types; pub mod config; pub mod slot; pub mod checkpoint; -pub mod vote; +pub mod attestation; pub mod block; pub mod state; pub mod validator; pub mod serde_helpers; -pub use block::{Block, BlockBody, BlockHeader, SignedBlock}; +pub use attestation::{ + Attestation, AttestationData, SignedAttestation, + AggregatedAttestations, SignedAggregatedAttestations, + AggregationBits, AggregatedSignatures, Signature, + Attestations, BlockSignatures, +}; +pub use block::{Block, BlockBody, BlockHeader, SignedBlock, BlockWithAttestation, SignedBlockWithAttestation}; pub use checkpoint::Checkpoint; pub use config::Config as ContainerConfig; pub use slot::Slot; pub use state::State; -pub use types::{Bytes32, Uint64, ValidatorIndex, HistoricalBlockHashes, JustificationRoots, JustifiedSlots, JustificationsValidators, U4000}; -pub use vote::{SignedVote, Vote}; +pub use types::{Bytes32, Uint64, ValidatorIndex, HistoricalBlockHashes, JustificationRoots, JustifiedSlots, JustificationsValidators}; pub use ssz; \ No newline at end of file diff --git a/lean_client/containers/src/state.rs b/lean_client/containers/src/state.rs index 04b8246..bb441ef 100644 --- a/lean_client/containers/src/state.rs +++ b/lean_client/containers/src/state.rs @@ -1,4 +1,4 @@ -use crate::{Bytes32, Checkpoint, ContainerConfig, Slot, Uint64, ValidatorIndex, block::{Block, BlockBody, BlockHeader, SignedBlock, hash_tree_root}, SignedVote}; +use crate::{Attestation, Attestations, Bytes32, Checkpoint, ContainerConfig, Slot, Uint64, ValidatorIndex, block::{Block, BlockBody, BlockHeader, SignedBlock, hash_tree_root}}; use crate::{HistoricalBlockHashes, JustificationRoots, JustifiedSlots, JustificationsValidators}; use crate::validator::Validator; use ssz::PersistentList as List; @@ -281,7 +281,7 @@ impl State { self.process_attestations(&body.attestations) } - pub fn process_attestations(&self, attestations: &List) -> Self { + pub fn process_attestations(&self, attestations: &Attestations) -> Self { let mut justifications = self.get_justifications(); let mut latest_justified = self.latest_justified.clone(); let mut latest_finalized = self.latest_finalized.clone(); @@ -289,11 +289,11 @@ impl State { // PersistentList doesn't expose iter; convert to Vec for simple iteration for now // Build a temporary Vec by probing sequentially until index error - let mut votes_vec: Vec = Vec::new(); + let mut attestations_vec: Vec = Vec::new(); let mut i: u64 = 0; loop { match attestations.get(i) { - Ok(v) => votes_vec.push(v.clone()), + Ok(a) => attestations_vec.push(a.clone()), Err(_) => break, } i += 1; @@ -305,12 +305,12 @@ impl State { justified_slots_working.push(justified_slots.get(i).map(|b| *b).unwrap_or(false)); } - for signed_vote in votes_vec.iter() { - let vote = signed_vote.message.clone(); - let target_slot = vote.target.slot; - let source_slot = vote.source.slot; - let target_root = vote.target.root; - let source_root = vote.source.root; + for attestation in attestations_vec.iter() { + let attestation_data = attestation.data.clone(); + let target_slot = attestation_data.target.slot; + let source_slot = attestation_data.source.slot; + let target_root = attestation_data.target.root; + let source_root = attestation_data.source.root; let target_slot_int = target_slot.0 as usize; let source_slot_int = source_slot.0 as usize; @@ -334,24 +334,24 @@ impl State { let target_is_after_source = target_slot > source_slot; let target_is_justifiable = target_slot.is_justifiable_after(latest_finalized.slot); - let is_valid_vote = source_is_justified && + let is_valid_attestation = source_is_justified && !target_already_justified && source_root_matches_history && target_root_is_valid && target_is_after_source && target_is_justifiable; - if !is_valid_vote { continue; } + if !is_valid_attestation { continue; } if !justifications.contains_key(&target_root) { let limit = VALIDATOR_REGISTRY_LIMIT; justifications.insert(target_root, vec![false; limit]); } - let validator_id = signed_vote.validator_id.0 as usize; - if let Some(votes) = justifications.get_mut(&target_root) { - if validator_id < votes.len() && !votes[validator_id] { - votes[validator_id] = true; + let validator_id = attestation.validator_id.0 as usize; + if let Some(attestation_votes) = justifications.get_mut(&target_root) { + if validator_id < attestation_votes.len() && !attestation_votes[validator_id] { + attestation_votes[validator_id] = true; // Count validators let mut num_validators: u64 = 0; @@ -366,9 +366,9 @@ impl State { } } - let count = votes.iter().filter(|&&v| v).count(); + let count = attestation_votes.iter().filter(|&&v| v).count(); if 3 * count >= 2 * num_validators as usize { - latest_justified = vote.target; + latest_justified = attestation_data.target; // Extend justified_slots_working if needed while justified_slots_working.len() <= target_slot_int { @@ -387,7 +387,7 @@ impl State { } if is_finalizable { - latest_finalized = vote.source; + latest_finalized = attestation_data.source; } } } diff --git a/lean_client/containers/src/vote.rs b/lean_client/containers/src/vote.rs deleted file mode 100644 index cf7abfa..0000000 --- a/lean_client/containers/src/vote.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::{Checkpoint, Slot, Uint64, U4000}; -use ssz::ByteVector; -use ssz_derive::Ssz; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] -pub struct Vote { - pub slot: Slot, - pub head: Checkpoint, - pub target: Checkpoint, - pub source: Checkpoint, -} - -// TODO: Rename votes to attestation and add functions from leanspec -#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)] -pub struct SignedVote { - pub validator_id: Uint64, - pub message: Vote, - pub signature: ByteVector, -} \ No newline at end of file diff --git a/lean_client/containers/tests/unit_tests/common.rs b/lean_client/containers/tests/unit_tests/common.rs index 8f11021..59829f9 100644 --- a/lean_client/containers/tests/unit_tests/common.rs +++ b/lean_client/containers/tests/unit_tests/common.rs @@ -1,20 +1,20 @@ use containers::{ + Attestations, block::{Block, BlockBody, BlockHeader, SignedBlock, hash_tree_root}, checkpoint::Checkpoint, ContainerConfig, slot::Slot, state::State, types::{Bytes32, ValidatorIndex}, - vote::SignedVote, }; use ssz::PersistentList as List; use typenum::U4096; pub const DEVNET_CONFIG_VALIDATOR_REGISTRY_LIMIT: usize = 1 << 12; // 4096 -pub fn create_block(slot: u64, parent_header: &mut BlockHeader, votes: Option>) -> SignedBlock { +pub fn create_block(slot: u64, parent_header: &mut BlockHeader, attestations: Option) -> SignedBlock { let body = BlockBody { - attestations: votes.unwrap_or_else(List::default), + attestations: attestations.unwrap_or_else(List::default), }; let block_message = Block { @@ -27,18 +27,18 @@ pub fn create_block(slot: u64, parent_header: &mut BlockHeader, votes: Option
  • Vec { - let mut votes = vec![false; DEVNET_CONFIG_VALIDATOR_REGISTRY_LIMIT]; +pub fn create_attestations(indices: &[usize]) -> Vec { + let mut attestations = vec![false; DEVNET_CONFIG_VALIDATOR_REGISTRY_LIMIT]; for &index in indices { - if index < votes.len() { - votes[index] = true; + if index < attestations.len() { + attestations[index] = true; } } - votes + attestations } pub fn sample_block_header() -> BlockHeader { diff --git a/lean_client/containers/tests/unit_tests/state_justifications.rs b/lean_client/containers/tests/unit_tests/state_justifications.rs index bd76b5b..e5628d7 100644 --- a/lean_client/containers/tests/unit_tests/state_justifications.rs +++ b/lean_client/containers/tests/unit_tests/state_justifications.rs @@ -11,7 +11,7 @@ use ssz::PersistentList as List; #[path = "common.rs"] mod common; use common::{ - base_state, create_votes, sample_config, DEVNET_CONFIG_VALIDATOR_REGISTRY_LIMIT, + base_state, create_attestations, sample_config, DEVNET_CONFIG_VALIDATOR_REGISTRY_LIMIT, }; #[fixture] @@ -173,26 +173,26 @@ fn test_with_justifications_invalid_length() { #[case::empty_justifications(std::collections::BTreeMap::new())] #[case::single_root({ let mut map = std::collections::BTreeMap::new(); - map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_votes(&[0])); + map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_attestations(&[0])); map })] #[case::multiple_roots_sorted({ let mut map = std::collections::BTreeMap::new(); - map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_votes(&[0])); - map.insert(Bytes32(ssz::H256::from_slice(&[2u8; 32])), create_votes(&[1, 2])); + map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_attestations(&[0])); + map.insert(Bytes32(ssz::H256::from_slice(&[2u8; 32])), create_attestations(&[1, 2])); map })] #[case::multiple_roots_unsorted({ let mut map = std::collections::BTreeMap::new(); - map.insert(Bytes32(ssz::H256::from_slice(&[2u8; 32])), create_votes(&[1, 2])); - map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_votes(&[0])); + map.insert(Bytes32(ssz::H256::from_slice(&[2u8; 32])), create_attestations(&[1, 2])); + map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_attestations(&[0])); map })] #[case::complex_unsorted({ let mut map = std::collections::BTreeMap::new(); map.insert(Bytes32(ssz::H256::from_slice(&[3u8; 32])), vec![true; DEVNET_CONFIG_VALIDATOR_REGISTRY_LIMIT]); - map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_votes(&[0])); - map.insert(Bytes32(ssz::H256::from_slice(&[2u8; 32])), create_votes(&[1, 2])); + map.insert(Bytes32(ssz::H256::from_slice(&[1u8; 32])), create_attestations(&[0])); + map.insert(Bytes32(ssz::H256::from_slice(&[2u8; 32])), create_attestations(&[1, 2])); map })] fn test_justifications_roundtrip( diff --git a/lean_client/containers/tests/unit_tests/state_process.rs b/lean_client/containers/tests/unit_tests/state_process.rs index e0a28b7..179108a 100644 --- a/lean_client/containers/tests/unit_tests/state_process.rs +++ b/lean_client/containers/tests/unit_tests/state_process.rs @@ -5,8 +5,7 @@ use containers::{ slot::Slot, state::State, types::{Bytes32, Uint64, ValidatorIndex}, - vote::{SignedVote, Vote}, - ssz::ByteVector, + Attestation, AttestationData, }; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; @@ -136,26 +135,25 @@ fn test_process_attestations_justification_and_finalization() { slot: Slot(4), }; - let votes_for_4: Vec = (0..7) - .map(|i| SignedVote { + let attestations_for_4: Vec = (0..7) + .map(|i| Attestation { validator_id: Uint64(i), - message: Vote { + data: AttestationData { slot: Slot(4), head: checkpoint4.clone(), target: checkpoint4.clone(), source: genesis_checkpoint.clone(), }, - signature: ByteVector::default(), }) .collect(); // Convert Vec to PersistentList - let mut votes_list: List<_, U4096> = List::default(); - for v in votes_for_4 { - votes_list.push(v).unwrap(); + let mut attestations_list: List<_, U4096> = List::default(); + for a in attestations_for_4 { + attestations_list.push(a).unwrap(); } - let new_state = state.process_attestations(&votes_list); + let new_state = state.process_attestations(&attestations_list); assert_eq!(new_state.latest_justified, checkpoint4); let justified_slot_4 = new_state.justified_slots.get(4).map(|b| *b).unwrap_or(false); diff --git a/lean_client/networking/src/gossipsub/message.rs b/lean_client/networking/src/gossipsub/message.rs index ac162cc..871db0f 100644 --- a/lean_client/networking/src/gossipsub/message.rs +++ b/lean_client/networking/src/gossipsub/message.rs @@ -1,12 +1,12 @@ use crate::gossipsub::topic::GossipsubKind; use crate::gossipsub::topic::GossipsubTopic; use containers::ssz::SszReadDefault; -use containers::{SignedBlock, SignedVote}; +use containers::{SignedBlock, SignedAttestation}; use libp2p::gossipsub::TopicHash; pub enum GossipsubMessage { Block(SignedBlock), - Vote(SignedVote), + Attestation(SignedAttestation), } impl GossipsubMessage { @@ -15,8 +15,8 @@ impl GossipsubMessage { GossipsubKind::Block => Ok(Self::Block( SignedBlock::from_ssz_default(data).map_err(|e| format!("{:?}", e))?, )), - GossipsubKind::Vote => Ok(Self::Vote( - SignedVote::from_ssz_default(data).map_err(|e| format!("{:?}", e))?, + GossipsubKind::Attestation => Ok(Self::Attestation( + SignedAttestation::from_ssz_default(data).map_err(|e| format!("{:?}", e))?, )), } } diff --git a/lean_client/networking/src/gossipsub/topic.rs b/lean_client/networking/src/gossipsub/topic.rs index ec9c38b..bb28bc4 100644 --- a/lean_client/networking/src/gossipsub/topic.rs +++ b/lean_client/networking/src/gossipsub/topic.rs @@ -5,7 +5,7 @@ pub const TOPIC_PREFIX: &str = "leanconsensus"; pub const SSZ_SNAPPY_ENCODING_POSTFIX: &str = "ssz_snappy"; pub const BLOCK_TOPIC: &str = "block"; -pub const VOTE_TOPIC: &str = "vote"; +pub const ATTESTATION_TOPIC: &str = "attestation"; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct GossipsubTopic { @@ -16,7 +16,7 @@ pub struct GossipsubTopic { #[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)] pub enum GossipsubKind { Block, - Vote, + Attestation, } pub fn get_topics(fork: String) -> Vec { @@ -27,7 +27,7 @@ pub fn get_topics(fork: String) -> Vec { }, GossipsubTopic { fork: fork.clone(), - kind: GossipsubKind::Vote, + kind: GossipsubKind::Attestation, }, ] } @@ -68,7 +68,7 @@ impl GossipsubTopic { fn extract_kind(parts: &[&str]) -> Result { match parts[2] { BLOCK_TOPIC => Ok(GossipsubKind::Block), - VOTE_TOPIC => Ok(GossipsubKind::Vote), + ATTESTATION_TOPIC => Ok(GossipsubKind::Attestation), other => Err(format!("Invalid topic kind: {other:?}")), } } @@ -103,7 +103,7 @@ impl From for TopicHash { fn from(val: GossipsubTopic) -> Self { let kind_str = match &val.kind { GossipsubKind::Block => BLOCK_TOPIC, - GossipsubKind::Vote => VOTE_TOPIC, + GossipsubKind::Attestation => ATTESTATION_TOPIC, }; TopicHash::from_raw(format!( "/{}/{}/{}/{}", @@ -119,7 +119,7 @@ impl std::fmt::Display for GossipsubKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { GossipsubKind::Block => write!(f, "{BLOCK_TOPIC}"), - GossipsubKind::Vote => write!(f, "{VOTE_TOPIC}"), + GossipsubKind::Attestation => write!(f, "{ATTESTATION_TOPIC}"), } } } diff --git a/lean_client/networking/src/network/service.rs b/lean_client/networking/src/network/service.rs index f89c122..9216031 100644 --- a/lean_client/networking/src/network/service.rs +++ b/lean_client/networking/src/network/service.rs @@ -223,11 +223,11 @@ where Event::Message { message, .. } => { match GossipsubMessage::decode(&message.topic, &message.data) { - Ok(GossipsubMessage::Block(signed_block)) => { + Ok(GossipsubMessage::Block(_signed_block)) => { info!("block"); } - Ok(GossipsubMessage::Vote(signed_vote)) => { - info!("vote"); + Ok(GossipsubMessage::Attestation(_signed_attestation)) => { + info!("attestation"); } Err(err) => warn!(%err, "gossip decode failed"), } @@ -316,18 +316,18 @@ where } } } - OutboundP2pRequest::GossipVote(signed_vote) => { - let slot = signed_vote.message.slot.0; - match signed_vote.to_ssz() { + OutboundP2pRequest::GossipAttestation(signed_attestation) => { + let slot = signed_attestation.message.data.slot.0; + match signed_attestation.to_ssz() { Ok(bytes) => { - if let Err(err) = self.publish_to_topic(GossipsubKind::Vote, bytes) { - warn!(slot = slot, ?err, "Publish vote failed"); + if let Err(err) = self.publish_to_topic(GossipsubKind::Attestation, bytes) { + warn!(slot = slot, ?err, "Publish attestation failed"); } else { - info!(slot = slot, "Broadcasted vote"); + info!(slot = slot, "Broadcasted attestation"); } } Err(err) => { - warn!(slot = slot, ?err, "Serialize vote failed"); + warn!(slot = slot, ?err, "Serialize attestation failed"); } } } diff --git a/lean_client/networking/src/types.rs b/lean_client/networking/src/types.rs index 5474d7d..43dc36b 100644 --- a/lean_client/networking/src/types.rs +++ b/lean_client/networking/src/types.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, fmt::Display}; use anyhow::{Result, anyhow}; use async_trait::async_trait; -use containers::{SignedBlock, SignedVote}; +use containers::{SignedBlock, SignedAttestation}; use serde::Serialize; use tokio::sync::mpsc; @@ -62,8 +62,8 @@ pub enum ChainMessage { is_trusted: bool, should_gossip: bool, }, - ProcessVote { - signed_vote: SignedVote, + ProcessAttestation { + signed_attestation: SignedAttestation, is_trusted: bool, should_gossip: bool, }, @@ -78,9 +78,9 @@ impl ChainMessage { } } - pub fn vote(signed_vote: SignedVote) -> Self { - ChainMessage::ProcessVote { - signed_vote, + pub fn attestation(signed_attestation: SignedAttestation) -> Self { + ChainMessage::ProcessAttestation { + signed_attestation, is_trusted: false, should_gossip: true, } @@ -93,8 +93,8 @@ impl Display for ChainMessage { ChainMessage::ProcessBlock { signed_block, .. } => { write!(f, "ProcessBlock(slot={})", signed_block.message.slot.0) } - ChainMessage::ProcessVote { signed_vote, .. } => { - write!(f, "ProcessVote(slot={})", signed_vote.message.slot.0) + ChainMessage::ProcessAttestation { signed_attestation, .. } => { + write!(f, "ProcessAttestation(slot={})", signed_attestation.message.data.slot.0) } } } @@ -103,7 +103,7 @@ impl Display for ChainMessage { #[derive(Debug, Clone, PartialEq, Eq)] pub enum OutboundP2pRequest { GossipBlock(SignedBlock), - GossipVote(SignedVote), + GossipAttestation(SignedAttestation), } #[async_trait]