mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
add IL type, gossip kind, and pubsub message
This commit is contained in:
@@ -211,6 +211,7 @@ impl GossipCache {
|
||||
GossipKind::BlsToExecutionChange => self.bls_to_execution_change,
|
||||
GossipKind::LightClientFinalityUpdate => self.light_client_finality_update,
|
||||
GossipKind::LightClientOptimisticUpdate => self.light_client_optimistic_update,
|
||||
GossipKind::InclusionList => None,
|
||||
};
|
||||
let Some(expire_timeout) = expire_timeout else {
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::sync::Arc;
|
||||
use types::{
|
||||
Attestation, AttestationBase, AttestationElectra, AttesterSlashing, AttesterSlashingBase,
|
||||
AttesterSlashingElectra, BlobSidecar, DataColumnSidecar, DataColumnSubnetId, EthSpec,
|
||||
ForkContext, ForkName, LightClientFinalityUpdate, LightClientOptimisticUpdate,
|
||||
ForkContext, ForkName, InclusionList, LightClientFinalityUpdate, LightClientOptimisticUpdate,
|
||||
ProposerSlashing, SignedAggregateAndProof, SignedAggregateAndProofBase,
|
||||
SignedAggregateAndProofElectra, SignedBeaconBlock, SignedBeaconBlockAltair,
|
||||
SignedBeaconBlockBase, SignedBeaconBlockBellatrix, SignedBeaconBlockCapella,
|
||||
@@ -45,6 +45,8 @@ pub enum PubsubMessage<E: EthSpec> {
|
||||
LightClientFinalityUpdate(Box<LightClientFinalityUpdate<E>>),
|
||||
/// Gossipsub message providing notification of a light client optimistic update.
|
||||
LightClientOptimisticUpdate(Box<LightClientOptimisticUpdate<E>>),
|
||||
/// Gossipsub message providing notification of an inclusion list.
|
||||
InclusionList(Box<InclusionList<E>>),
|
||||
}
|
||||
|
||||
// Implements the `DataTransform` trait of gossipsub to employ snappy compression
|
||||
@@ -138,6 +140,7 @@ impl<E: EthSpec> PubsubMessage<E> {
|
||||
PubsubMessage::LightClientOptimisticUpdate(_) => {
|
||||
GossipKind::LightClientOptimisticUpdate
|
||||
}
|
||||
PubsubMessage::InclusionList(_) => GossipKind::InclusionList,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,6 +393,11 @@ impl<E: EthSpec> PubsubMessage<E> {
|
||||
light_client_optimistic_update,
|
||||
)))
|
||||
}
|
||||
GossipKind::InclusionList => {
|
||||
let il =
|
||||
InclusionList::from_ssz_bytes(data).map_err(|e| format!("{:?}", e))?;
|
||||
Ok(PubsubMessage::InclusionList(Box::new(il)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,6 +424,7 @@ impl<E: EthSpec> PubsubMessage<E> {
|
||||
PubsubMessage::BlsToExecutionChange(data) => data.as_ssz_bytes(),
|
||||
PubsubMessage::LightClientFinalityUpdate(data) => data.as_ssz_bytes(),
|
||||
PubsubMessage::LightClientOptimisticUpdate(data) => data.as_ssz_bytes(),
|
||||
PubsubMessage::InclusionList(data) => data.as_ssz_bytes(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -477,6 +486,9 @@ impl<E: EthSpec> std::fmt::Display for PubsubMessage<E> {
|
||||
PubsubMessage::LightClientOptimisticUpdate(_data) => {
|
||||
write!(f, "Light CLient Optimistic Update")
|
||||
}
|
||||
PubsubMessage::InclusionList(_data) => {
|
||||
write!(f, "Inclusion List")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ pub const SYNC_COMMITTEE_PREFIX_TOPIC: &str = "sync_committee_";
|
||||
pub const BLS_TO_EXECUTION_CHANGE_TOPIC: &str = "bls_to_execution_change";
|
||||
pub const LIGHT_CLIENT_FINALITY_UPDATE: &str = "light_client_finality_update";
|
||||
pub const LIGHT_CLIENT_OPTIMISTIC_UPDATE: &str = "light_client_optimistic_update";
|
||||
pub const INCLUSION_LIST_TOPIC: &str = "inclusion_list";
|
||||
|
||||
pub const BASE_CORE_TOPICS: [GossipKind; 5] = [
|
||||
GossipKind::BeaconBlock,
|
||||
@@ -43,6 +44,8 @@ pub const LIGHT_CLIENT_GOSSIP_TOPICS: [GossipKind; 2] = [
|
||||
|
||||
pub const DENEB_CORE_TOPICS: [GossipKind; 0] = [];
|
||||
|
||||
pub const ELECTRA_CORE_TOPICS: [GossipKind; 1] = [GossipKind::InclusionList];
|
||||
|
||||
/// Returns the core topics associated with each fork that are new to the previous fork
|
||||
pub fn fork_core_topics<E: EthSpec>(fork_name: &ForkName, spec: &ChainSpec) -> Vec<GossipKind> {
|
||||
match fork_name {
|
||||
@@ -60,7 +63,7 @@ pub fn fork_core_topics<E: EthSpec>(fork_name: &ForkName, spec: &ChainSpec) -> V
|
||||
deneb_topics.append(&mut deneb_blob_topics);
|
||||
deneb_topics
|
||||
}
|
||||
ForkName::Electra => vec![],
|
||||
ForkName::Electra => ELECTRA_CORE_TOPICS.to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +138,8 @@ pub enum GossipKind {
|
||||
LightClientFinalityUpdate,
|
||||
/// Topic for publishing optimistic updates for light clients.
|
||||
LightClientOptimisticUpdate,
|
||||
/// Topic for publishing inclusion lists.
|
||||
InclusionList,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for GossipKind {
|
||||
@@ -217,6 +222,7 @@ impl GossipTopic {
|
||||
BLS_TO_EXECUTION_CHANGE_TOPIC => GossipKind::BlsToExecutionChange,
|
||||
LIGHT_CLIENT_FINALITY_UPDATE => GossipKind::LightClientFinalityUpdate,
|
||||
LIGHT_CLIENT_OPTIMISTIC_UPDATE => GossipKind::LightClientOptimisticUpdate,
|
||||
INCLUSION_LIST_TOPIC => GossipKind::InclusionList,
|
||||
topic => match subnet_topic_index(topic) {
|
||||
Some(kind) => kind,
|
||||
None => return Err(format!("Unknown topic: {}", topic)),
|
||||
@@ -282,6 +288,7 @@ impl std::fmt::Display for GossipTopic {
|
||||
GossipKind::BlsToExecutionChange => BLS_TO_EXECUTION_CHANGE_TOPIC.into(),
|
||||
GossipKind::LightClientFinalityUpdate => LIGHT_CLIENT_FINALITY_UPDATE.into(),
|
||||
GossipKind::LightClientOptimisticUpdate => LIGHT_CLIENT_OPTIMISTIC_UPDATE.into(),
|
||||
GossipKind::InclusionList => INCLUSION_LIST_TOPIC.into(),
|
||||
};
|
||||
write!(
|
||||
f,
|
||||
|
||||
@@ -542,6 +542,9 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
bls_to_execution_change,
|
||||
),
|
||||
),
|
||||
PubsubMessage::InclusionList(il) => {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +160,11 @@ pub trait EthSpec:
|
||||
type MaxAttestationsElectra: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
type MaxWithdrawalRequestsPerPayload: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
|
||||
/*
|
||||
* FOCIL
|
||||
*/
|
||||
type MaxTransactionsPerInclusionList: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
|
||||
fn default_spec() -> ChainSpec;
|
||||
|
||||
fn spec_name() -> EthSpecId;
|
||||
@@ -374,6 +379,11 @@ pub trait EthSpec:
|
||||
fn kzg_commitments_inclusion_proof_depth() -> usize {
|
||||
Self::KzgCommitmentsInclusionProofDepth::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `MAX_TRANSACTIONS_PER_INCLUSION_LIST` constant for this specification.
|
||||
fn max_transactions_per_inclusion_list() -> usize {
|
||||
Self::MaxTransactionsPerInclusionList::to_usize()
|
||||
}
|
||||
}
|
||||
|
||||
/// Macro to inherit some type values from another EthSpec.
|
||||
@@ -438,6 +448,7 @@ impl EthSpec for MainnetEthSpec {
|
||||
type MaxAttesterSlashingsElectra = U1;
|
||||
type MaxAttestationsElectra = U8;
|
||||
type MaxWithdrawalRequestsPerPayload = U16;
|
||||
type MaxTransactionsPerInclusionList = U16;
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
ChainSpec::mainnet()
|
||||
@@ -503,7 +514,8 @@ impl EthSpec for MinimalEthSpec {
|
||||
PendingBalanceDepositsLimit,
|
||||
MaxConsolidationRequestsPerPayload,
|
||||
MaxAttesterSlashingsElectra,
|
||||
MaxAttestationsElectra
|
||||
MaxAttestationsElectra,
|
||||
MaxTransactionsPerInclusionList
|
||||
});
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
@@ -569,6 +581,7 @@ impl EthSpec for GnosisEthSpec {
|
||||
type FieldElementsPerExtBlob = U8192;
|
||||
type BytesPerCell = U2048;
|
||||
type KzgCommitmentsInclusionProofDepth = U4;
|
||||
type MaxTransactionsPerInclusionList = U16;
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
ChainSpec::gnosis()
|
||||
|
||||
53
consensus/types/src/inclusion_list.rs
Normal file
53
consensus/types/src/inclusion_list.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::{EthSpec, Hash256, Signature, Slot, Transaction};
|
||||
|
||||
use derivative::Derivative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use ssz_types::VariableList;
|
||||
use test_random_derive::TestRandom;
|
||||
use tree_hash::TreeHash;
|
||||
use tree_hash_derive::TreeHash;
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Encode,
|
||||
Decode,
|
||||
TreeHash,
|
||||
TestRandom,
|
||||
Derivative,
|
||||
arbitrary::Arbitrary,
|
||||
)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
#[arbitrary(bound = "E: EthSpec")]
|
||||
#[derivative(PartialEq, Eq, Hash(bound = "E: EthSpec"))]
|
||||
pub struct InclusionList<E: EthSpec> {
|
||||
pub slot: Slot,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub validator_index: u64,
|
||||
pub inclusion_list_committee_root: Hash256,
|
||||
pub transactions:
|
||||
VariableList<Transaction<E::MaxBytesPerTransaction>, E::MaxTransactionsPerInclusionList>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, Derivative, arbitrary::Arbitrary,
|
||||
)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
#[arbitrary(bound = "E: EthSpec")]
|
||||
#[derivative(PartialEq, Eq, Hash(bound = "E: EthSpec"))]
|
||||
pub struct SignedInclusionList<E: EthSpec> {
|
||||
pub message: InclusionList<E>,
|
||||
pub signature: Signature,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
ssz_and_tree_hash_tests!(InclusionList<MainnetEthSpec>);
|
||||
}
|
||||
@@ -48,6 +48,7 @@ pub mod fork_versioned_response;
|
||||
pub mod graffiti;
|
||||
pub mod historical_batch;
|
||||
pub mod historical_summary;
|
||||
pub mod inclusion_list;
|
||||
pub mod indexed_attestation;
|
||||
pub mod light_client_bootstrap;
|
||||
pub mod light_client_finality_update;
|
||||
@@ -178,6 +179,7 @@ pub use crate::fork_name::{ForkName, InconsistentFork};
|
||||
pub use crate::fork_versioned_response::{ForkVersionDeserialize, ForkVersionedResponse};
|
||||
pub use crate::graffiti::{Graffiti, GRAFFITI_BYTES_LEN};
|
||||
pub use crate::historical_batch::HistoricalBatch;
|
||||
pub use crate::inclusion_list::{InclusionList, SignedInclusionList};
|
||||
pub use crate::indexed_attestation::{
|
||||
IndexedAttestation, IndexedAttestationBase, IndexedAttestationElectra, IndexedAttestationRef,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user