Skip to content

[FS-721] Forward All Default Proposals#2628

Merged
mdimjasevic merged 11 commits intodevelopfrom
fs-721/fwd-all-default-proposals
Aug 25, 2022
Merged

[FS-721] Forward All Default Proposals#2628
mdimjasevic merged 11 commits intodevelopfrom
fs-721/fwd-all-default-proposals

Conversation

@mdimjasevic
Copy link
Contributor

@mdimjasevic mdimjasevic commented Aug 18, 2022

The PR adapts the Wire server such that it simply forwards all MLS default proposal types, including those that it currently does not support.

Tracked by https://wearezeta.atlassian.net/browse/FS-721.

Checklist

  • The PR Title explains the impact of the change.
  • The PR description provides context as to why the change should occur and what the code contributes to that effect. This could also be a link to a JIRA ticket or a Github issue, if there is one.
  • changelog.d contains the following bits of information (details):
    • A file with the changelog entry in one or more suitable sub-sections. The sub-sections are marked by directories inside changelog.d.

@mdimjasevic mdimjasevic temporarily deployed to cachix August 18, 2022 08:27 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 18, 2022 08:27 Inactive
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Aug 18, 2022
@pcapriotti pcapriotti force-pushed the pcapriotti/mls-serialisation branch 2 times, most recently from c7b25b7 to 3d3265e Compare August 22, 2022 06:48
Base automatically changed from pcapriotti/mls-serialisation to develop August 22, 2022 08:43
@mdimjasevic mdimjasevic temporarily deployed to cachix August 23, 2022 12:18 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 23, 2022 12:18 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-721/fwd-all-default-proposals branch from aed3c11 to 734c569 Compare August 23, 2022 12:49
@mdimjasevic mdimjasevic temporarily deployed to cachix August 23, 2022 12:49 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 23, 2022 12:49 Inactive
- This was introduced accidentally
@mdimjasevic mdimjasevic temporarily deployed to cachix August 23, 2022 12:52 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 23, 2022 12:52 Inactive
let sig = BA.convert $ sign priv pub (rmRaw tbs)
pure (Message tbs (MessageExtraFields sig Nothing Nothing))

mkAppAckProposalMessage ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't used, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I removed it in 39d7c31.

mkAppAckProposalMessage priv pub gid epoch ref mrs =
maybeCryptoError $ mkAppAckProposalMessageFailable priv pub gid epoch ref mrs

mkAppAckProposalMessageFailable ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used for testing, couldn't it just be moved to the tests?

Copy link
Contributor

@smatting smatting Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this function and mkRemoveProposalMessage can be factored to use a common function that signs a MessageTBS to (Message 'MLSPlainText)?

Also I noted that both functions use maybeCryptoError together with a pure which is just CryptoPassed. I think because of that in both functions nothing is acutally checked. Can we remove this indirection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, only in testing. I simplified and moved it to the test code in 39d7c31.

[a] ->
Put
serialiseMLSVector p as = do
put @w . fromIntegral . length $ as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. Vectors begin with the whole size of their binary representation, not the number of items. See https://www.rfc-editor.org/rfc/rfc5246#section-4.3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting! Fixed in cc6548a.

)
@?= [Ed25519]

propUnsupported :: TestM ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a somewhat unconventional test. Maybe add a couple of lines of comment explaining what it is we're doing here, like the fact that we are manually reading mls-test-cli's store and extracting the private key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a description in 39d7c31.

@smatting smatting self-requested a review August 24, 2022 07:52
@mdimjasevic mdimjasevic temporarily deployed to cachix August 24, 2022 13:59 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 24, 2022 13:59 Inactive
@mdimjasevic mdimjasevic requested a review from pcapriotti August 24, 2022 14:03
Copy link
Contributor

@pcapriotti pcapriotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the vector serialisation. See comment below.

Comment on lines +94 to +96
let elLen = maybe 0 (LBS.length . runPut . p) . listToMaybe $ as
put @w . fromIntegral $ elLen * fromIntegral (length as)
traverse_ p as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me. Why is every element the same length?

To be fair, it's not easy to do this efficiently. As a compromise, we can do the following:

  • serialise the whole vector ignoring the size
  • convert to lazy bytestring
  • put count
  • put bytestring

To get good performance we need imperative access to the buffer, which is probably possible, but requires the unsafe API. Maybe the above is good enough.

Copy link
Contributor Author

@mdimjasevic mdimjasevic Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points! I obviously overlooked this.

I changed the implementation and round-trip tests for serialiseMLSVector pass. I am not too familiar with how efficient the conversion from a lazy bytestring to a strict bytestring is, but that's what I did.

Copy link
Contributor

@pcapriotti pcapriotti Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lazy bytestrings are essentially lists of strict bytestrings (representing their concatenation). Converting from lazy to strict amounts to actually performing the concatenation (i.e. basically allocating a big buffer, copying, and likely leaving the original bytestrings to the GC). So it's basically a bunch of extra copies and allocations, good to avoid if possible.

Marko Dimjašević added 2 commits August 25, 2022 10:16
- This change makes the round-trip test for the serialiseMLSVector
pass (via the ExtensionVector test type)
@mdimjasevic mdimjasevic temporarily deployed to cachix August 25, 2022 08:39 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 25, 2022 08:39 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 25, 2022 08:45 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 25, 2022 08:45 Inactive
Comment on lines +93 to +95
serialiseMLSBytes @w . LBS.toStrict . toLazyByteString
. execPut
. traverse_ p
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct, but we can avoid the bytestring conversion if we create a version of serialiseMLSBytes that takes a lazy bytestring and uses putLazyByteString.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again! I've implemented that in 8ce0da0.

@mdimjasevic mdimjasevic temporarily deployed to cachix August 25, 2022 09:28 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix August 25, 2022 09:28 Inactive
@mdimjasevic mdimjasevic merged commit 33d8889 into develop Aug 25, 2022
@mdimjasevic mdimjasevic deleted the fs-721/fwd-all-default-proposals branch August 25, 2022 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants