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

Add RemoveProposal to the Removed case of CommitEffect #176

Merged
merged 3 commits into from
Jul 19, 2024
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
2 changes: 1 addition & 1 deletion mls-rs-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -227,7 +227,7 @@ impl From<mls_rs::group::CommitEffect> for CommitEffect {
.map(|p| Arc::new(p.proposal.into()))
.collect(),
},
group::CommitEffect::Removed => CommitEffect::Removed,
group::CommitEffect::Removed(_) => CommitEffect::Removed,
group::CommitEffect::ReInit(_) => CommitEffect::ReInit,
}
}
2 changes: 1 addition & 1 deletion mls-rs/src/client.rs
Original file line number Diff line number Diff line change
@@ -968,7 +968,7 @@ mod tests {
assert_matches!(
message,
ReceivedMessage::Commit(CommitMessageDescription {
effect: CommitEffect::Removed,
effect: CommitEffect::Removed(_),
..
})
);
11 changes: 8 additions & 3 deletions mls-rs/src/external_client/group.rs
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ use crate::{
ApplicationMessageDescription, CommitMessageDescription, EventOrContent,
MessageProcessor, ProposalMessageDescription, ProvisionalState,
},
proposal::RemoveProposal,
proposal_filter::ProposalInfo,
snapshot::RawGroupState,
state::GroupState,
transcript_hash::InterimTranscriptHash,
@@ -56,7 +58,7 @@ use mls_rs_core::{crypto::CipherSuiteProvider, psk::ExternalPskId};
#[cfg(feature = "by_ref_proposal")]
use crate::{
extension::ExternalSendersExt,
group::proposal::{AddProposal, ReInitProposal, RemoveProposal},
group::proposal::{AddProposal, ReInitProposal},
};

#[cfg(all(feature = "by_ref_proposal", feature = "psk"))]
@@ -638,8 +640,11 @@ where
&mut self.state
}

fn can_continue_processing(&self, _provisional_state: &ProvisionalState) -> bool {
true
fn removal_proposal(
&self,
_provisional_state: &ProvisionalState,
) -> Option<ProposalInfo<RemoveProposal>> {
None
}

#[cfg(feature = "private_message")]
14 changes: 9 additions & 5 deletions mls-rs/src/group/message_processor.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ use super::{
state::GroupState,
transcript_hash::InterimTranscriptHash,
transcript_hashes, validate_group_info_member, GroupContext, GroupInfo, ReInitProposal,
Welcome,
RemoveProposal, Welcome,
};
use crate::{
client::MlsError,
@@ -121,7 +121,7 @@ impl NewEpoch {
#[derive(Clone, Debug, PartialEq)]
pub enum CommitEffect {
NewEpoch(Box<NewEpoch>),
Removed,
Removed(ProposalInfo<RemoveProposal>),
ReInit(ProposalInfo<ReInitProposal>),
}

@@ -636,12 +636,12 @@ pub(crate) trait MessageProcessor: Send + Sync {
return Err(MlsError::CommitMissingPath);
}

if !self.can_continue_processing(&provisional_state) {
if let Some(removal) = self.removal_proposal(&provisional_state) {
return Ok(CommitMessageDescription {
is_external: matches!(auth_content.content.sender, Sender::NewMemberCommit),
authenticated_data: auth_content.content.authenticated_data,
committer: *sender,
effect: CommitEffect::Removed,
effect: CommitEffect::Removed(removal),
});
}

@@ -727,7 +727,11 @@ pub(crate) trait MessageProcessor: Send + Sync {
fn identity_provider(&self) -> Self::IdentityProvider;
fn cipher_suite_provider(&self) -> &Self::CipherSuiteProvider;
fn psk_storage(&self) -> Self::PreSharedKeyStorage;
fn can_continue_processing(&self, provisional_state: &ProvisionalState) -> bool;

fn removal_proposal(
&self,
provisional_state: &ProvisionalState,
) -> Option<ProposalInfo<RemoveProposal>>;

#[cfg(feature = "private_message")]
fn min_epoch_available(&self) -> Option<u64>;
21 changes: 13 additions & 8 deletions mls-rs/src/group/mod.rs
Original file line number Diff line number Diff line change
@@ -73,7 +73,6 @@ pub(crate) use self::commit::test_utils::CommitModifiers;
#[cfg(all(test, feature = "private_message"))]
pub use self::framing::PrivateMessage;

#[cfg(feature = "psk")]
use self::proposal_filter::ProposalInfo;

#[cfg(any(feature = "secret_tree_access", feature = "private_message"))]
@@ -1827,13 +1826,19 @@ where
&mut self.state
}

fn can_continue_processing(&self, provisional_state: &ProvisionalState) -> bool {
!(provisional_state
.applied_proposals
.removals
.iter()
.any(|p| p.proposal.to_remove == self.private_tree.self_index)
&& self.pending_commit.is_none())
fn removal_proposal(
&self,
provisional_state: &ProvisionalState,
) -> Option<ProposalInfo<RemoveProposal>> {
match self.pending_commit {
Some(_) => None,
None => provisional_state
.applied_proposals
.removals
.iter()
.find(|p| p.proposal.to_remove == self.private_tree.self_index)
.cloned(),
}
}

#[cfg(feature = "private_message")]
7 changes: 5 additions & 2 deletions mls-rs/src/group/test_utils.rs
Original file line number Diff line number Diff line change
@@ -461,8 +461,11 @@ impl MessageProcessor for GroupWithoutKeySchedule {
self.inner.psk_storage()
}

fn can_continue_processing(&self, provisional_state: &ProvisionalState) -> bool {
self.inner.can_continue_processing(provisional_state)
fn removal_proposal(
&self,
provisional_state: &ProvisionalState,
) -> Option<ProposalInfo<RemoveProposal>> {
self.inner.removal_proposal(provisional_state)
}

#[cfg(feature = "private_message")]