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

compile xmtp_id and xmtp_mls to wasm32 #1026

Merged
merged 26 commits into from
Sep 5, 2024

Conversation

insipx
Copy link
Contributor

@insipx insipx commented Sep 3, 2024

  • feature flag/Send bounds

  • slightly changes streams. All streams except for _with_callback are stack-based/no more Box<Stream>. This makes it easier to modify the Send bound for wasm32.

  • general dependency pruning where possible.

    • Remove the smart-default crate since it was used in only one place.
    • replace flume with tokio::sync::mpsc
  • blocked on some missing trait implementations for WasmSqlite backend which require a patched diesel.

  • remove InboxOwner in xmtp_mls and use the one in xmtp_id

    • this allows us to remove xmtp_mls dependency on ethers. xmtp_id depends on ethers anyway
  • remove ethers_core and use the ethers::core re-export

90% of this PR is adding cfg/cfg_attr to tests/items + hoisting individual types like Box<dyn Signature> into type alias to make it possible to vary Send/Sync bounds based on wasm/not wasm

closes #951 closes #939 closes #940

this PR makes tests compile in WebAssembly, but not necessarily pass. Rel: #941

@insipx insipx mentioned this pull request Sep 3, 2024
5 tasks
@insipx insipx changed the base branch from main to wasm-backend September 4, 2024 23:09
@insipx insipx changed the base branch from wasm-backend to main September 4, 2024 23:12
@insipx insipx changed the base branch from main to wasm-backend September 4, 2024 23:12
@@ -1,3 +1,11 @@
pub mod time;
use wasm_timer::{SystemTime, UNIX_EPOCH};
Copy link
Contributor Author

@insipx insipx Sep 5, 2024

Choose a reason for hiding this comment

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

wasm_timer uses normal std SystemTime libraries if on native, and the JS web_sys/js_sys shim if on web


use crate::InboxOwner;

impl InboxOwner for LocalWallet {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I preferred the implementation in xmtp_id, enabling us to remove the ethers dependency in xmtp_mls

let mut stream = client.stream_conversations().await?;
let handle = crate::spawn(async move {
let stream = client.stream_conversations().await?;
futures::pin_mut!(stream);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be a minor performance improvement, streams are entirely stack-based, even in the with_callback methods.

@insipx insipx marked this pull request as ready for review September 5, 2024 17:58
@insipx insipx requested a review from a team as a code owner September 5, 2024 17:58
@insipx insipx merged commit acbe841 into wasm-backend Sep 5, 2024
10 checks passed
@insipx insipx deleted the insipx/compile-xmtp-id-wasm-2 branch September 5, 2024 18:59
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.

Fix tokio for wasm32-unknown-unknown target
1 participant