Skip to content

Commit

Permalink
Eliminate proposal "filtering" in favor of throwing hard errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomleavy committed Jan 23, 2025
1 parent c198d38 commit 92feb7e
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 2,197 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ members = [
"mls-rs-provider-sqlite",
"mls-rs-codec",
"mls-rs-codec-derive",
]

exclude = [
"mls-rs-uniffi",
"mls-rs-uniffi/uniffi-bindgen",
]

Expand Down
15 changes: 2 additions & 13 deletions mls-rs-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ impl From<mls_rs::group::proposal::Proposal> for Proposal {
pub enum CommitEffect {
NewEpoch {
applied_proposals: Vec<Arc<Proposal>>,
unused_proposals: Vec<Arc<Proposal>>,
},
ReInit,
Removed,
Expand All @@ -221,12 +220,7 @@ impl From<mls_rs::group::CommitEffect> for CommitEffect {
.into_iter()
.map(|p| Arc::new(p.proposal.into()))
.collect(),
unused_proposals: new_epoch
.unused_proposals
.into_iter()
.map(|p| Arc::new(p.proposal.into()))
.collect(),
},
},
group::CommitEffect::Removed {
new_epoch: _,
remover: _,
Expand Down Expand Up @@ -382,10 +376,7 @@ impl Client {
/// See [`mls_rs::Client::generate_key_package_message`] for
/// details.
pub async fn generate_key_package_message(&self) -> Result<Message, Error> {
let message = self
.inner
.generate_key_package()
.await?;
let message = self.inner.generate_key_package().await?;
Ok(message.into())
}

Expand Down Expand Up @@ -499,8 +490,6 @@ pub struct CommitOutput {
/// A group info that can be provided to new members in order to
/// enable external commit functionality.
pub group_info: Option<Arc<Message>>,
// TODO(mgeisler): decide if we should expose unused_proposals()
// as well.
}

impl TryFrom<mls_rs::group::CommitOutput> for CommitOutput {
Expand Down
8 changes: 5 additions & 3 deletions mls-rs/src/external_client/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ impl<C: ExternalClientConfig + Clone> ExternalGroup<C> {
/// Issue an external proposal.
///
/// This function is useful for reissuing external proposals that
/// are returned in [crate::group::NewEpoch::unused_proposals]
/// after a commit is processed.
/// were not consumed by a commit.
#[cfg(feature = "by_ref_proposal")]
#[cfg_attr(not(mls_build_async), maybe_async::must_be_sync)]
pub async fn propose(
Expand Down Expand Up @@ -1405,7 +1404,10 @@ mod tests {
)
.await;

let proposal = alice.propose_update().await.unwrap();
let proposal = alice
.propose_group_context_extensions(Default::default())
.await
.unwrap();

let commit_output = alice.commit(vec![]).await.unwrap();

Expand Down
26 changes: 2 additions & 24 deletions mls-rs/src/group/commit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use itertools::Itertools;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
use mls_rs_core::crypto::SignatureSecretKey;

#[cfg(feature = "by_ref_proposal")]
use crate::group::proposal_filter::ProposalInfo;
use crate::group::proposal_filter::{ProposalBundle, ProposalSource};
use crate::group::{EncryptionMode, RemoveProposal};
use crate::{
Expand Down Expand Up @@ -57,9 +55,6 @@ use crate::group::{
PendingCommitSnapshot, Welcome,
};

#[cfg(feature = "by_ref_proposal")]
use crate::group::proposal_filter::CommitDirection;

#[cfg(feature = "custom_proposal")]
use crate::group::proposal::CustomProposal;

Expand Down Expand Up @@ -122,9 +117,6 @@ pub struct CommitOutput {
/// functionality. This value is set if [`MlsRules::commit_options`] returns
/// `allow_external_commit` set to true.
pub external_commit_group_info: Option<MlsMessage>,
/// Proposals that were received in the prior epoch but not included in the following commit.
#[cfg(feature = "by_ref_proposal")]
pub unused_proposals: Vec<ProposalInfo<Proposal>>,
/// Indicator that the commit contains a path update
pub contains_update_path: bool,
}
Expand Down Expand Up @@ -158,12 +150,6 @@ impl CommitOutput {
pub fn external_commit_group_info(&self) -> Option<&MlsMessage> {
self.external_commit_group_info.as_ref()
}

/// Proposals that were received in the prior epoch but not included in the following commit.
#[cfg(all(feature = "ffi", feature = "by_ref_proposal"))]
pub fn unused_proposals(&self) -> &[ProposalInfo<Proposal>] {
&self.unused_proposals
}
}

/// Options controlling commit generation
Expand Down Expand Up @@ -369,16 +355,12 @@ where
self.with_proposal(Proposal::Custom(proposal))
}

/// Insert a proposal that was previously constructed such as when a
/// proposal is returned from
/// [`NewEpoch::unused_proposals`](super::NewEpoch::unused_proposals).
/// Insert a proposal that was previously not consumed by a commit
pub fn raw_proposal(self, proposal: Proposal) -> Self {
self.with_proposal(proposal)
}

/// Insert proposals that were previously constructed such as when a
/// proposal is returned from
/// [`NewEpoch::unused_proposals`](super::NewEpoch::unused_proposals).
/// Insert proposals that were previously not consumed by a commit
pub fn raw_proposals(self, proposals: Vec<Proposal>) -> Self {
proposals.into_iter().fold(self, |b, p| b.with_proposal(p))
}
Expand Down Expand Up @@ -684,8 +666,6 @@ where
&self.config.identity_provider(),
&self.cipher_suite_provider,
time,
#[cfg(feature = "by_ref_proposal")]
CommitDirection::Send,
#[cfg(feature = "psk")]
&psks
.iter()
Expand Down Expand Up @@ -1025,8 +1005,6 @@ where
ratchet_tree,
external_commit_group_info,
contains_update_path: perform_path_update,
#[cfg(feature = "by_ref_proposal")]
unused_proposals: provisional_state.unused_proposals,
};

Ok((output, pending_commit))
Expand Down
5 changes: 0 additions & 5 deletions mls-rs/src/group/commit/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ use crate::{
Group,
};

#[cfg(feature = "by_ref_proposal")]
use crate::group::proposal_filter::CommitDirection;

#[cfg(feature = "psk")]
use mls_rs_core::psk::{ExternalPskId, PreSharedKey};

Expand Down Expand Up @@ -136,8 +133,6 @@ pub(crate) async fn process_commit<'a, P: MessageProcessor<'a>>(
&id_provider,
&cs_provider,
commit_processor.time_sent,
#[cfg(feature = "by_ref_proposal")]
CommitDirection::Receive,
#[cfg(feature = "psk")]
&commit_processor
.psks
Expand Down
3 changes: 1 addition & 2 deletions mls-rs/src/group/framing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,7 @@ impl MlsMessage {
kp.to_reference(cipher_suite).await.map(Some)
}

/// If this is a plaintext proposal, return the proposal reference that can be matched e.g. with
/// [`NewEpoch::unused_proposals`](super::NewEpoch::unused_proposals).
/// If this is a plaintext proposal, return the proposal reference
#[cfg(feature = "by_ref_proposal")]
#[cfg_attr(not(mls_build_async), maybe_async::must_be_sync)]
pub async fn into_proposal_reference<C: CipherSuiteProvider>(
Expand Down
8 changes: 0 additions & 8 deletions mls-rs/src/group/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub(crate) struct ProvisionalState {
pub(crate) group_context: GroupContext,
pub(crate) external_init_index: Option<LeafIndex>,
pub(crate) indexes_of_added_kpkgs: Vec<LeafIndex>,
pub(crate) unused_proposals: Vec<ProposalInfo<Proposal>>,
}

//By default, the path field of a Commit MUST be populated. The path field MAY be omitted if
Expand Down Expand Up @@ -92,15 +91,13 @@ pub struct NewEpoch {
pub epoch: u64,
pub prior_state: GroupState,
pub applied_proposals: Vec<ProposalInfo<Proposal>>,
pub unused_proposals: Vec<ProposalInfo<Proposal>>,
}

impl NewEpoch {
pub(crate) fn new(prior_state: GroupState, provisional_state: &ProvisionalState) -> NewEpoch {
NewEpoch {
epoch: provisional_state.group_context.epoch,
prior_state,
unused_proposals: provisional_state.unused_proposals.clone(),
applied_proposals: provisional_state
.applied_proposals
.clone()
Expand All @@ -124,10 +121,6 @@ impl NewEpoch {
pub fn applied_proposals(&self) -> &[ProposalInfo<Proposal>] {
&self.applied_proposals
}

pub fn unused_proposals(&self) -> &[ProposalInfo<Proposal>] {
&self.unused_proposals
}
}

#[cfg_attr(
Expand Down Expand Up @@ -878,7 +871,6 @@ mod tests {
confirmation_tag: Default::default(),
},
applied_proposals: vec![],
unused_proposals: vec![],
};

let effects = vec![
Expand Down
Loading

0 comments on commit 92feb7e

Please sign in to comment.