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

MLS CLI #338

Merged
merged 10 commits into from
Nov 17, 2023
Merged

MLS CLI #338

merged 10 commits into from
Nov 17, 2023

Conversation

neekolas
Copy link
Contributor

@neekolas neekolas commented Nov 16, 2023

Summary

Updates the existing CLI example to work with MLS. Supported actions are:

  1. Register
  2. Create Group
  3. List Groups
  4. Send
  5. List Group Messages
  6. Add Group Member
  7. Info
  8. Clear

In order to support the Add Group Member command, I also added the ability to add members by wallet address to the MlsGroup struct.

TODO

  • I haven't added support for removing group members yet

@@ -1,10 +1,6 @@
FROM ghcr.io/xmtp/rust:latest
USER xmtp

RUN ~xmtp/.cargo/bin/rustup toolchain install stable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These components are already in the base image, so we don't need to install them again. For some reason the re-install is failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems related to this issue (same error). Dockerignoring the rust-toolchain.toml file does avoid the issue, at the cost of forcing us to use the rust toolchain from the base docker file instead of the one specified in the rust-toolchain.toml

Copy link
Contributor

Choose a reason for hiding this comment

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

@jac18281828 might be able to help, maybe because of some updates?

@neekolas neekolas marked this pull request as ready for review November 17, 2023 01:29
@neekolas neekolas requested review from a team, richardhuaaa and insipx November 17, 2023 01:29
@insipx
Copy link
Contributor

insipx commented Nov 17, 2023

Looks good!

It works, but i'm not able to list-group-messages until after running list-groups with the user that was just added to a group:

/xli.sh --local --db user2.db list-group-messages $GROUP_ID
warning: use of deprecated method `tokio_rustls::rustls::RootCertStore::add_server_trust_anchors`: Please use `add_trust_anchors` instead
  --> xmtp_api_grpc/src/grpc_api_helper.rs:32:11
   |
32 |     roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
   |           ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: `xmtp_api_grpc` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `/Users/insipx/Projects/xmtp/workspace-libxmtp/nm/mls-cli/target/debug/cli-client --local --db user2.db list-group-messages d48c0c94a532f1e2f1ccdfc80f7ebefc`
[2023-11-17T16:50:44Z INFO  cli_client] Starting CLI Client....
[2023-11-17T16:50:44Z INFO  cli_client] Recv
[2023-11-17T16:50:44Z INFO  cli_client] Using persistent storage: user2.db 
thread 'main' panicked at examples/cli/cli-client.rs:197:18:
failed to find group: Generic("group not found")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


/xli.sh --local --db user2.db list-groups
warning: use of deprecated method `tokio_rustls::rustls::RootCertStore::add_server_trust_anchors`: Please use `add_trust_anchors` instead
  --> xmtp_api_grpc/src/grpc_api_helper.rs:32:11
   |
32 |     roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
   |           ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: `xmtp_api_grpc` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.31s
     Running `/Users/insipx/Projects/xmtp/workspace-libxmtp/nm/mls-cli/target/debug/cli-client --local --db user2.db list-groups`
[2023-11-17T16:50:54Z INFO  cli_client] Starting CLI Client....
[2023-11-17T16:50:54Z INFO  cli_client] List Conversations
[2023-11-17T16:50:54Z INFO  cli_client] Using persistent storage: user2.db 
[2023-11-17T16:50:54Z INFO  cli_client] ====== [0] Group d48c0c94a532f1e2f1ccdfc80f7ebefc ======

./xli.sh --local --db user2.db list-group-messages $GROUP_ID
warning: use of deprecated method `tokio_rustls::rustls::RootCertStore::add_server_trust_anchors`: Please use `add_trust_anchors` instead
  --> xmtp_api_grpc/src/grpc_api_helper.rs:32:11
   |
32 |     roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
   |           ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: `xmtp_api_grpc` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.30s
     Running `/Users/insipx/Projects/xmtp/workspace-libxmtp/nm/mls-cli/target/debug/cli-

client --local --db user2.db list-group-messages d48c0c94a532f1e2f1ccdfc80f7ebefc`
[2023-11-17T16:51:03Z INFO  cli_client] Starting CLI Client....
[2023-11-17T16:51:03Z INFO  cli_client] Recv
[2023-11-17T16:51:03Z INFO  cli_client] Using persistent storage: user2.db 
[2023-11-17T16:51:03Z ERROR openmls::group::public_group::validation] Wrong Epoch: message.epoch() 0 != 1 self.group_context().epoch()
[2023-11-17T16:51:03Z WARN  xmtp_mls::groups] receive error ReceiveError([OpenMlsProcessMessage(ValidationError(WrongEpoch))])
[2023-11-17T16:51:03Z INFO  cli_client] ====== Group d48c0c94a532f1e2f1ccdfc80f7ebefc ======
    [ 17 seconds ago ] 0xa2cf2c5b8ae341012e3426b73576ca6b9732a71e:   helloooooo

@neekolas
Copy link
Contributor Author

@insipx I'm going to merge a few changes from the demo branch into this one (including adding a bunch more syncing before doing operations) to avoid situations like the one you ran into.

@neekolas
Copy link
Contributor Author

@insipx try now. The issue above should be fixed. The logs will be pretty noisy until the topic syncing PR goes in, since it still tries to reprocess all old messages every time.

@neekolas neekolas merged commit 945205f into main Nov 17, 2023
4 checks passed
@neekolas neekolas deleted the nm/mls-cli branch November 17, 2023 20:15
@boneyard93501
Copy link

hello, i'm at commit 6c05ffa9338648c3e36be89bd47f72d349ab265a (HEAD -> main, origin/main, origin/HEAD) and get the same error just running docker build . -t libxmtp:1, which was easily fixed by updating

roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {

that left me with some lifetime errors for
impl TextCodec {
, which are easily fixed with &'static ...
finally, i'm down to privacy errors in cli-client.rs, e.g.,
client.sync_welcomes().await?;
, stemming from
pub(crate) async fn sync_welcomes(&self) -> Result<Vec<MlsGroup<ApiClient>>, ClientError> {
. the naive fix pub(crate) upgrade to pub of course did the trick.
last trip-up was a clippy error in
let mut roots = RootCertStore::empty();

i can push a PR if you want.

@neekolas
Copy link
Contributor Author

Thanks for pointing those out @boneyard93501. I have a PR up that restores a missing Github workflow, which should have brought them to our attention sooner. It also should fix the issues listed above.

#342

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants