Skip to content

Commit

Permalink
Fix unused proposals when receiving commit (#69)
Browse files Browse the repository at this point in the history
* Test that rejected proposals are proposals in cache and not in commit when receiving commit

The test currently fails and the implementation will be fixed in the
next commit.

* Fix unused proposals when receiving commit

Unused proposals were previously made of the proposals in the received
commit that would cause the commit to be invalid and thus were excluded.
But given that invalid proposals when receiving a commit cause the
entire commit to be rejected, it means that unused proposals were always
empty when receiving a commit.

Unused proposals are now made of the proposals in the receiver's cache
that are not in the received commit.

* Rename rejected_proposals to unused_proposals

The previous term was confusing in the context of receiving a commit.

This also removes outdated comments in tests from back when only unused
proposals from the committer were returned.
  • Loading branch information
stefunctional authored Jan 25, 2024
1 parent d9d9e2e commit 3c57e91
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 104 deletions.
2 changes: 1 addition & 1 deletion mls-rs/src/group/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ where
ratchet_tree,
external_commit_group_info,
#[cfg(feature = "by_ref_proposal")]
unused_proposals: provisional_state.rejected_proposals,
unused_proposals: provisional_state.unused_proposals,
})
}

Expand Down
4 changes: 2 additions & 2 deletions mls-rs/src/group/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(crate) struct ProvisionalState {
pub(crate) external_init_index: Option<LeafIndex>,
pub(crate) indexes_of_added_kpkgs: Vec<LeafIndex>,
#[cfg(feature = "by_ref_proposal")]
pub(crate) rejected_proposals: Vec<crate::mls_rules::ProposalInfo<Proposal>>,
pub(crate) unused_proposals: Vec<crate::mls_rules::ProposalInfo<Proposal>>,
}

//By default, the path field of a Commit MUST be populated. The path field MAY be omitted if
Expand Down Expand Up @@ -607,7 +607,7 @@ pub(crate) trait MessageProcessor: Send + Sync {
#[cfg(feature = "custom_proposal")]
custom_proposals: provisional.applied_proposals.custom_proposals.clone(),
#[cfg(feature = "by_ref_proposal")]
unused_proposals: provisional.rejected_proposals.clone(),
unused_proposals: provisional.unused_proposals.clone(),
};

Ok(update)
Expand Down
Loading

0 comments on commit 3c57e91

Please sign in to comment.