Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove unused code in subsystem message implementations #6525

Merged
merged 1 commit into from
Jan 9, 2023
Merged
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
113 changes: 0 additions & 113 deletions node/subsystem-types/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ use std::{
pub mod network_bridge_event;
pub use network_bridge_event::NetworkBridgeEvent;

/// Subsystem messages where each message is always bound to a relay parent.
pub trait BoundToRelayParent {
/// Returns the relay parent this message is bound to.
fn relay_parent(&self) -> Hash;
}

/// Messages received by the Candidate Backing subsystem.
#[derive(Debug)]
pub enum CandidateBackingMessage {
Expand All @@ -78,16 +72,6 @@ pub enum CandidateBackingMessage {
Statement(Hash, SignedFullStatement),
}

impl BoundToRelayParent for CandidateBackingMessage {
fn relay_parent(&self) -> Hash {
match self {
Self::GetBackedCandidates(hash, _, _) => *hash,
Self::Second(hash, _, _) => *hash,
Self::Statement(hash, _) => *hash,
}
}
}

/// Blanket error for validation failing for internal reasons.
#[derive(Debug, Error)]
#[error("Validation failed with {0:?}")]
Expand Down Expand Up @@ -170,17 +154,6 @@ pub enum CandidateValidationMessage {
),
}

impl CandidateValidationMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
match self {
Self::ValidateFromChainState(_, _, _, _) => None,
Self::ValidateFromExhaustive(_, _, _, _, _, _) => None,
Self::PreCheck(relay_parent, _, _) => Some(*relay_parent),
}
}
}

/// Messages received by the Collator Protocol subsystem.
#[derive(Debug, derive_more::From)]
pub enum CollatorProtocolMessage {
Expand Down Expand Up @@ -218,12 +191,6 @@ impl Default for CollatorProtocolMessage {
}
}

impl BoundToRelayParent for CollatorProtocolMessage {
fn relay_parent(&self) -> Hash {
Default::default()
}
}

/// Messages received by the dispute coordinator subsystem.
///
/// NOTE: Any response oneshots might get cancelled if the `DisputeCoordinator` was not yet
Expand Down Expand Up @@ -397,23 +364,6 @@ pub enum NetworkBridgeTxMessage {
},
}

impl NetworkBridgeTxMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
match self {
Self::ReportPeer(_, _) => None,
Self::DisconnectPeer(_, _) => None,
Self::SendValidationMessage(_, _) => None,
Self::SendCollationMessage(_, _) => None,
Self::SendValidationMessages(_) => None,
Self::SendCollationMessages(_) => None,
Self::ConnectToValidators { .. } => None,
Self::ConnectToResolvedValidators { .. } => None,
Self::SendRequests { .. } => None,
}
}
}

/// Availability Distribution Message.
#[derive(Debug)]
pub enum AvailabilityDistributionMessage {
Expand Down Expand Up @@ -463,16 +413,6 @@ pub enum BitfieldDistributionMessage {
NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::BitfieldDistributionMessage>),
}

impl BitfieldDistributionMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
match self {
Self::DistributeBitfield(hash, _) => Some(*hash),
Self::NetworkBridgeUpdate(_) => None,
}
}
}

/// Availability store subsystem message.
#[derive(Debug)]
pub enum AvailabilityStoreMessage {
Expand Down Expand Up @@ -526,13 +466,6 @@ pub enum AvailabilityStoreMessage {
},
}

impl AvailabilityStoreMessage {
/// In fact, none of the `AvailabilityStore` messages assume a particular relay parent.
pub fn relay_parent(&self) -> Option<Hash> {
None
}
}

/// A response channel for the result of a chain API request.
pub type ChainApiResponseChannel<T> = oneshot::Sender<Result<T, crate::errors::ChainApiError>>;

Expand Down Expand Up @@ -575,13 +508,6 @@ pub enum ChainApiMessage {
},
}

impl ChainApiMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
None
}
}

/// Chain selection subsystem messages
#[derive(Debug)]
pub enum ChainSelectionMessage {
Expand All @@ -594,20 +520,6 @@ pub enum ChainSelectionMessage {
BestLeafContaining(Hash, oneshot::Sender<Option<Hash>>),
}

impl ChainSelectionMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
// None of the messages, even the ones containing specific
// block hashes, can be considered to have those blocks as
// a relay parent.
match *self {
ChainSelectionMessage::Approved(_) => None,
ChainSelectionMessage::Leaves(_) => None,
ChainSelectionMessage::BestLeafContaining(..) => None,
}
}
}

/// A sender for the result of a runtime API request.
pub type RuntimeApiSender<T> = oneshot::Sender<Result<T, crate::errors::RuntimeApiError>>;

Expand Down Expand Up @@ -702,15 +614,6 @@ pub enum RuntimeApiMessage {
Request(Hash, RuntimeApiRequest),
}

impl RuntimeApiMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
match self {
Self::Request(hash, _) => Some(*hash),
}
}
}

/// Statement distribution message.
#[derive(Debug, derive_more::From)]
pub enum StatementDistributionMessage {
Expand Down Expand Up @@ -762,29 +665,13 @@ pub enum ProvisionerMessage {
ProvisionableData(Hash, ProvisionableData),
}

impl BoundToRelayParent for ProvisionerMessage {
fn relay_parent(&self) -> Hash {
match self {
Self::RequestInherentData(hash, _) => *hash,
Self::ProvisionableData(hash, _) => *hash,
}
}
}

/// Message to the Collation Generation subsystem.
#[derive(Debug)]
pub enum CollationGenerationMessage {
/// Initialize the collation generation subsystem
Initialize(CollationGenerationConfig),
}

impl CollationGenerationMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
None
}
}

/// The result type of [`ApprovalVotingMessage::CheckAndImportAssignment`] request.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AssignmentCheckResult {
Expand Down