Giter Club home page Giter Club logo

libxmtp's Introduction

xmtp

libxmtp's People

Contributors

bwcdvorak avatar daria-github avatar dmccartney avatar insipx avatar jac18281828 avatar jazzz avatar jhaaaa avatar michaelx11 avatar mkobetic avatar nakajima avatar neekolas avatar nplasterer avatar richardhuaaa avatar snormore avatar xiaolou86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libxmtp's Issues

WASM support

  • Setup API Client
  • Setup Index DB
  • Integrate with SDK

Custom JS error classes/enum

wasm_bindgen expects a JsValue to be returned from any function that can throw.

Currently, we handle this by returning JsError from all of our wasm bindings. This has the effect of auto-converting from Rust std::err::Error to JsError automatically via JsError::from, and then into JsValue via JsError::into.

The implementation of JsError::from is the JS equivalent of calling new Error(...) with the string generated from calling to_string() on the Rust error, which doesn't give consumers the opportunity to differentiate between different types of errors in code.

A workaround would be to define custom JS Error subclasses and import them into Rust, or define a special JS XMTPError type with an enum field and mappings from all known errors to this enum.

More info at rustwasm/wasm-bindgen#1742 (comment)

Ramp-up task: Detect DB errors

Is your feature request related to a problem?

This ramp-up task will get you familiar with the database, with Rust error handling, and with writing unit tests.

We are using Diesel ORM with a sqlite database. Most of the DB operations are in mod.rs for encrypted store. We are using Diesel::insert_or_ignore in a few places, for example:

diesel::insert_or_ignore_into(schema::sessions::table)
.

Originally, the reason for this was to ignore duplicate insertion errors, so that the operation is idempotent if it is called twice and the row already exists. However, a problem with Diesel::insert_or_ignore is it will ignore all errors, including foreign key constraint violations, for example - which results in the row silently not being inserted at all. This makes debugging difficult.

Describe the solution to the problem

My rough idea is to just use the normal Diesel::insert, and then add code specifically to detect when a duplicate primary key error happens and just return Ok(), while surfacing the rest of the errors normally. This could be put in a helper method that is used everywhere insert_or_ignore was used. I also thought about using upsert, but we don't want to update any columns (e.g. state) if a row already exists. It's up to you what the best way of doing this is.

Ideally we add a unit test for this as well.

Describe the uses cases for the feature

No response

Additional details

No response

Generate and persist account keys

We can generate/store the vmac keys as-is.
If there are already keys on disk, we should read those into memory as part of initialization.

Wallet signing the identity key and possibly the fallback key is left as a separate task for simplicity.

Building for x86_64-linux-android fails with sqlite3-related linker errors

Example: https://github.com/xmtp/libxmtp/actions/runs/5166007186/jobs/9305846305

ld: error: undefined symbol: __extenddftf2
          >>> referenced by sqlite3.c
          >>>               sqlite3.o:(sqlite3_str_vappendf) in archive /target/x86_64-linux-android/release/deps/liblibsqlite3_sys-a59c0c668a489339.rlib
          >>> referenced by sqlite3.c
          >>>               sqlite3.o:(sqlite3_str_vappendf) in archive /target/x86_64-linux-android/release/deps/liblibsqlite3_sys-a59c0c668a489339.rlib
          >>> referenced by sqlite3.c
          >>>               sqlite3.o:(sqlite3_str_vappendf) in archive /target/x86_64-linux-android/release/deps/liblibsqlite3_sys-a59c0c668a489339.rlib
          >>> referenced 6 more times

This seems to happen both in CI and locally.

Related errors reports:

Contact bundle refactoring + prekeys API

Publish fallback prekeys via prekeys API instead of in the contact bundle. This makes rotating prekeys cleaner in the future. When initiating conversations, use whatever prekey is available in the prekey topic (which automatically supports one-time prekeys when they become available in future versions).

iOS SDK support

An iOS SDK backed by V3 but still able to run V2 messages.

Bug: InvalidMac on self-fanout

Describe the bug

$ ./xli.sh --db a2.db3 list-conversations                                       
    Finished dev [unoptimized + debuginfo] target(s) in 0.26s
     Running `/Users/jazz/dev/libxmtp/target/debug/cli-client --db a1.db3 list-conversations`
[2023-08-16T02:09:59Z INFO  cli_client] Starting CLI Client....
[2023-08-16T02:09:59Z INFO  cli_client] List Conversations
[2023-08-16T02:09:59Z INFO  cli_client] Using persistent storage: a1.db3 
[2023-08-16T02:09:59Z WARN  xmtp::conversations] 0
[2023-08-16T02:10:00Z INFO  xmtp::conversations] Messages Downloaded:1
[2023-08-16T02:10:00Z ERROR xmtp::conversations] Error processing msg: Session(Decrypt(InvalidMAC(MacError)))
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: MessageStore(Unknown("Session: decrypt error"))', examples/cli/cli-client.rs:163:33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior

Messages sent from A1 need to be replicated to A2

Steps to reproduce the bug

A1:Register
A2:Register
B1:Register
A1: Send B
A2: list-conversations -> InvalidMAC

Ramp-up task: Rename SecretConversation->Conversation

Is your feature request related to a problem?

No response

Describe the solution to the problem

We have a struct called SecretConversation that is used in multiple places, we should rename it to Conversation.

This should get you set up in our environment, running tests, and understanding what different crates do. Feel free to ask questions about anything as that is the fastest way to learn

Describe the uses cases for the feature

No response

Additional details

No response

Feature request: Reminder: check rng generation for wasm

Is your feature request related to a problem?

As we productionize, it's worth taking some time to go back through and verify any randomness generation changes we had to make for WASM compatibility.

Describe the solution to the problem

No response

Describe the uses cases for the feature

No response

Additional details

No response

Tracking: Sprint #1

Encapsulates:

Any infrastructure setup work that needs to happen
Any derisking work that needs to happen
All of the initialization logic that happens on startup (client.create())
Demo output:

New account flow/signatures
New account exists on the network
Private keys exist in local storage

Tasks

  1. neekolas
  2. jazzz
  3. jazzz
  4. richardhuaaa
  5. michaelx11
  6. neekolas
  7. jazzz
  8. richardhuaaa
  9. jazzz
  10. richardhuaaa
  11. 23 of 23
    jazzz michaelx11
    neekolas richardhuaaa

Encapsulates:

The steps required to initiate a conversation, loosely corresponding to conversations.newConversation() and conversation.send() in the JS API
Demo output:

Dual SDK logic - receiving

Dedupe by message ID. Do we need to make code changes to support consistent message ID’s? Should we write v2 messages into the v3 database? What would an eventual migration look like?

Prod builds should merge messages from both protocols, dev builds should allow us to flip back and forth between v2 and v3 views.

Bug: sometimes xmtp_proto build hangs

Describe the bug

I've only seen it when I'm developing locally, but during cargo build of for example bindings_swift it'll get stuck at: (253/255) xmtp_proto.

I wonder if buf is hanging?

Expected behavior

No response

Steps to reproduce the bug

No response

Tracking: Conversation initiation

Encapsulates:

  • The steps required to initiate a conversation, loosely corresponding to conversations.newConversation() and conversation.send() in the JS API

Demo output:

Feature request: Improve bindings_swift

Right now swift-bridge supports returning Result<_, Enum> from sync/async functions, like so:

// Rust
#[swift_bridge::bridge]
mod ffi {
    enum NetworkError {
        Authentication{
            description: String
        },
        Unknown
    }

    extern "Rust" {
        async fn post_data(data: usize) -> Result<(), NetworkError>;
    }
}

async fn post_data(data: usize) -> Result<(), ffi::NetworkError> {
    Err(ffi::NetworkError::Authentication { description: "error".to_string() })
}
// Swift
do {
    let result = try await post_data(123)
} catch let error as NetworkError {
    switch error {
        case .Authentication(let description):
            print(description.toString())
        case .Unknown:
            print("Unknown")
    }
} catch let error {
    //..
}

I think we can improve error handling by introducing this feature.

End-to-end example app

Somewhere for us to test the changes, as well as note any breaking interface changes in the future. Ideally we use an existing app and only have to bump the SDK version.

Probably should be in React Native.

Secure enclave support

Assuming we can handle the storing/fetching in the platform-specific SDK layer and just pass the encryption key down, so no changes in Rust.

Changes to vodozemac

It’s beneficial to get changes to vmac in before we have older versions to support. Changes might include switching to ChaPoly, adding support for X3DH, etc.

Tracking: Account setup and infrastructure

Consent/PPP plan

Work out a plan for this and any overlap with portable inbox work. Most likely path is via building Portable Private Preferences

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.