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

Wasm target #7

Open
852Kerfunkle opened this issue Dec 29, 2022 · 8 comments
Open

Wasm target #7

852Kerfunkle opened this issue Dec 29, 2022 · 8 comments

Comments

@852Kerfunkle
Copy link

First of all, this is great, thank you!

Compiling with --target wasm32-unknown-unknown yields a bunch of future cannot be sent between threads safely errors.

Is this on the roadmap?

@RomarQ
Copy link
Collaborator

RomarQ commented Dec 29, 2022

Hi @852Kerfunkle,

Currently, this is not on the roadmap.

The error above comes from the RPC crate. The remaining crates should compile fine for target wasm32-unknown-unknown.

We may have a look at it next year if we find some time.

@852Kerfunkle
Copy link
Author

Thank you @RomarQ.

It is the rpc crate, indeed. It would be the one that is most interesting to me - I probably only need bigmap queries for now :)

I can probably get by otherwise and should I really need it, maybe I can try to make a PR.

Thanks!

@m-kus
Copy link
Contributor

m-kus commented Jan 8, 2023

Hey @852Kerfunkle !
I was able to compile by making these two changes:
baking-bad#1
baking-bad#3

Hope that will help.

@852Kerfunkle
Copy link
Author

Amazing @m-kus, thank you!

I didn't even get to figuring out what was causing the issue.

I will give it a try soon 🙇

@852Kerfunkle
Copy link
Author

Right, so, I got it to compile (with tezos-contracts) removing the Send trait from a few things (ContractFetcher, Http, FeeEstimator).

@m-kus as far as I can tell, your changes made no difference for me (rustc 1.66).

No idea if it works, didn't try to use it yet.

@852Kerfunkle
Copy link
Author

image

Sure seems to work.

Not sure this is useful to anyone else, but basically:

diff --git a/tezos-contract/src/contract.rs b/tezos-contract/src/contract.rs
index 6d35ed1..8e7498f 100644
--- a/tezos-contract/src/contract.rs
+++ b/tezos-contract/src/contract.rs
@@ -469,7 +469,7 @@ impl CompatibleWith<Type> for DataSome {
     }
 }
 
-#[async_trait]
+#[async_trait(?Send)]
 pub trait ContractFetcher<'a, HttpClient: Http + Sync> {
     async fn contract_at(
         &'a self,
@@ -478,7 +478,7 @@ pub trait ContractFetcher<'a, HttpClient: Http + Sync> {
     ) -> Result<Contract<'a, HttpClient>>;
 }
 
-#[async_trait]
+#[async_trait(?Send)]
 impl<'a, HttpClient: Http + Sync> ContractFetcher<'a, HttpClient> for TezosRpc<HttpClient> {
     async fn contract_at(
         &'a self,
diff --git a/tezos-rpc/src/http.rs b/tezos-rpc/src/http.rs
index 8bfb59e..c2f08ae 100644
--- a/tezos-rpc/src/http.rs
+++ b/tezos-rpc/src/http.rs
@@ -4,7 +4,7 @@ use {
     serde::{de::DeserializeOwned, Serialize},
 };
 
-#[async_trait]
+#[async_trait(?Send)]
 pub trait Http {
     fn new(rpc_endpoint: String) -> Self;
 
@@ -76,7 +76,7 @@ pub mod default {
     }
 
     #[cfg(feature = "http")]
-    #[async_trait]
+    #[async_trait(?Send)]
     impl Http for HttpClient {
         /// Creates an Http client that will be used to send requests to the specified node.
         fn new(rpc_endpoint: String) -> Self {
diff --git a/tezos-rpc/src/internal/estimator.rs b/tezos-rpc/src/internal/estimator.rs
index b214457..6cd844b 100644
--- a/tezos-rpc/src/internal/estimator.rs
+++ b/tezos-rpc/src/internal/estimator.rs
@@ -27,7 +27,7 @@ use crate::{
     Error, Result,
 };
 
-#[async_trait]
+#[async_trait(?Send)]
 pub trait FeeEstimator {
     async fn min_fee<'a>(
         &self,
@@ -48,7 +48,7 @@ impl<'a, HttpClient: Http> OperationFeeEstimator<'a, HttpClient> {
 
 const PLACEHOLDER_SIGNATURE: &'static str = "edsigtXomBKi5CTRf5cjATJWSyaRvhfYNHqSUGrn4SdbYRcGwQrUGjzEfQDTuqHhuA8b2d8NarZjz8TRf65WkpQmo423BtomS8Q";
 
-#[async_trait]
+#[async_trait(?Send)]
 impl<'a, HttpClient: Http + Send + Sync> FeeEstimator for OperationFeeEstimator<'a, HttpClient> {
     async fn min_fee<'b>(
         &self,

@RomarQ
Copy link
Collaborator

RomarQ commented Jan 16, 2023

@852Kerfunkle feel free to submit a PR with your changes. We will have a look when possible.

@852Kerfunkle
Copy link
Author

@RomarQ Will do, once I figured out if there's maybe a better way to achieve it. Cheers.

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

No branches or pull requests

3 participants