Skip to content
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

CDN <> Epoch changes #3885

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions crates/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ path = "push-cdn/broker.rs"
name = "cdn-marshal"
path = "push-cdn/marshal.rs"

[[example]]
name = "whitelist-push-cdn"
path = "push-cdn/whitelist-adapter.rs"

[dependencies]
async-trait = { workspace = true }
clap = { workspace = true, optional = true }
Expand Down
86 changes: 0 additions & 86 deletions crates/examples/push-cdn/whitelist-adapter.rs

This file was deleted.

9 changes: 1 addition & 8 deletions crates/hotshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,7 @@ pub struct MarketplaceConfig<TYPES: NodeType, I: NodeImplementation<TYPES>> {
pub fallback_builder_url: Url,
}

/// Bundle of all the memberships a consensus instance uses
#[derive(Clone)]
pub struct Memberships<TYPES: NodeType> {
/// The entire quorum
pub quorum_membership: TYPES::Membership,
/// The DA nodes
pub da_membership: TYPES::Membership,
}
pub use hotshot_types::stake_table::Memberships;

/// Holds the state needed to participate in `HotShot` consensus
pub struct SystemContext<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ use hotshot_types::{
PeerConfig,
};
use rand::{rngs::StdRng, Rng};
use serde::{Deserialize, Serialize};
use utils::anytrace::Result;

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]

/// The static committee election

Expand Down
3 changes: 2 additions & 1 deletion crates/hotshot/src/traits/election/static_committee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use hotshot_types::{
},
PeerConfig,
};
use serde::{Deserialize, Serialize};
use utils::anytrace::Result;

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]

/// The static committee election
pub struct StaticCommittee<T: NodeType> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use hotshot_types::{
},
PeerConfig,
};
use serde::{Deserialize, Serialize};
use utils::anytrace::Result;

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]

/// The static committee election
pub struct StaticCommitteeLeaderForTwoViews<T: NodeType> {
Expand Down
25 changes: 25 additions & 0 deletions crates/types/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::{
error::HotShotError,
message::Proposal,
simple_certificate::QuorumCertificate,
stake_table::Memberships,
traits::{node_implementation::NodeType, ValidatedState},
};
/// A status event emitted by a `HotShot` instance
Expand Down Expand Up @@ -178,7 +179,31 @@ pub enum EventType<TYPES: NodeType> {
/// Serialized data of the message
data: Vec<u8>,
},

/// An epoch transition was started
EpochTransitionStarted {
/// The new epoch number
epoch: TYPES::Epoch,

/// The initial stake table before the epoch transition
pre_update_stake_table: Memberships<TYPES>,

/// The final stake table after the epoch transition
/// completes
post_update_stake_table: Memberships<TYPES>,
},

/// An epoch transition was completed
EpochTransitionFinished {
/// The new epoch number
epoch: TYPES::Epoch,

/// The final stake table after the epoch transition
/// completes
post_update_stake_table: Memberships<TYPES>,
},
}

#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
/// A list of actions that we track for nodes
pub enum HotShotAction {
Expand Down
14 changes: 13 additions & 1 deletion crates/types/src/stake_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
use ethereum_types::U256;
use serde::{Deserialize, Serialize};

use crate::traits::signature_key::{SignatureKey, StakeTableEntryType};
use crate::traits::{
node_implementation::NodeType,
signature_key::{SignatureKey, StakeTableEntryType},
};

/// Bundle of all the memberships a consensus instance uses
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Memberships<TYPES: NodeType> {
/// The entire quorum
pub quorum_membership: TYPES::Membership,
/// The DA nodes
pub da_membership: TYPES::Membership,
}

/// Stake table entry
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Hash, Eq)]
Expand Down
5 changes: 4 additions & 1 deletion crates/types/src/traits/election.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
//! The election trait, used to decide which node is the leader and determine if a vote is valid.
use std::{collections::BTreeSet, fmt::Debug, num::NonZeroU64};

use serde::{de::DeserializeOwned, Serialize};
use utils::anytrace::Result;

use super::{network::Topic, node_implementation::NodeType};
use crate::{traits::signature_key::SignatureKey, PeerConfig};

/// A protocol for determining membership in and participating in a committee.
pub trait Membership<TYPES: NodeType>: Clone + Debug + Send + Sync {
pub trait Membership<TYPES: NodeType>:
Clone + Debug + Send + Sync + Serialize + DeserializeOwned
{
/// The error type returned by methods like `lookup_leader`.
type Error: std::fmt::Display;

Expand Down
2 changes: 1 addition & 1 deletion crates/types/src/traits/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ impl NetworkReliability for ChaosNetwork {
}

/// Used when broadcasting messages
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Topic {
/// The `Global` topic goes out to all nodes
Global,
Expand Down