From 4e90d6fbdac421dc41d6f20e8a92373723a9c7b6 Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Tue, 1 Oct 2024 16:18:04 +0200 Subject: [PATCH 1/3] chore: `autonomi` entry into WASM --- Cargo.lock | 419 ++++++++++++++++++++------------------------ README.md | 33 ++-- autonomi/Cargo.toml | 5 +- evmlib/Cargo.toml | 5 +- 4 files changed, 221 insertions(+), 241 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9110c9bf2f..49c73299c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,7 +130,6 @@ dependencies = [ "alloy-network", "alloy-node-bindings", "alloy-provider", - "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", "alloy-serde", @@ -138,8 +137,6 @@ dependencies = [ "alloy-signer-local", "alloy-transport", "alloy-transport-http", - "alloy-transport-ipc", - "alloy-transport-ws", ] [[package]] @@ -178,7 +175,6 @@ dependencies = [ "alloy-network-primitives", "alloy-primitives", "alloy-provider", - "alloy-pubsub", "alloy-rpc-types-eth", "alloy-sol-types", "alloy-transport", @@ -226,8 +222,6 @@ dependencies = [ "alloy-rlp", "alloy-serde", "c-kzg", - "derive_more", - "k256", "once_cell", "serde", "sha2 0.10.8", @@ -354,15 +348,12 @@ dependencies = [ "alloy-network-primitives", "alloy-node-bindings", "alloy-primitives", - "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types-anvil", "alloy-rpc-types-eth", "alloy-signer-local", "alloy-transport", "alloy-transport-http", - "alloy-transport-ipc", - "alloy-transport-ws", "async-stream", "async-trait", "auto_impl", @@ -379,25 +370,6 @@ dependencies = [ "url", ] -[[package]] -name = "alloy-pubsub" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5da2c55cbaf229bad3c5f8b00b5ab66c74ef093e5f3a753d874cfecf7d2281" -dependencies = [ - "alloy-json-rpc", - "alloy-primitives", - "alloy-transport", - "bimap", - "futures", - "serde", - "serde_json", - "tokio", - "tokio-stream", - "tower", - "tracing", -] - [[package]] name = "alloy-rlp" version = "0.3.8" @@ -427,12 +399,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b38e3ffdb285df5d9f60cb988d336d9b8e3505acb78750c3bc60336a7af41d3" dependencies = [ "alloy-json-rpc", - "alloy-primitives", - "alloy-pubsub", "alloy-transport", "alloy-transport-http", - "alloy-transport-ipc", - "alloy-transport-ws", "futures", "pin-project", "reqwest 0.12.7", @@ -452,7 +420,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c31a3750b8f5a350d17354e46a52b0f2f19ec5f2006d816935af599dedc521" dependencies = [ "alloy-rpc-types-anvil", - "alloy-rpc-types-engine", "alloy-rpc-types-eth", "alloy-serde", "serde", @@ -469,24 +436,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-engine" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff63f51b2fb2f547df5218527fd0653afb1947bf7fead5b3ce58c75d170b30f7" -dependencies = [ - "alloy-consensus", - "alloy-eips", - "alloy-primitives", - "alloy-rlp", - "alloy-rpc-types-eth", - "alloy-serde", - "jsonwebtoken", - "rand 0.8.5", - "serde", - "thiserror", -] - [[package]] name = "alloy-rpc-types-eth" version = "0.2.1" @@ -654,43 +603,6 @@ dependencies = [ "url", ] -[[package]] -name = "alloy-transport-ipc" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804494366e20468776db4e18f9eb5db7db0fe14f1271eb6dbf155d867233405c" -dependencies = [ - "alloy-json-rpc", - "alloy-pubsub", - "alloy-transport", - "bytes", - "futures", - "interprocess", - "pin-project", - "serde_json", - "tokio", - "tokio-util 0.7.12", - "tracing", -] - -[[package]] -name = "alloy-transport-ws" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af855163e7df008799941aa6dd324a43ef2bf264b08ba4b22d44aad6ced65300" -dependencies = [ - "alloy-pubsub", - "alloy-transport", - "futures", - "http 1.1.0", - "rustls 0.23.13", - "serde_json", - "tokio", - "tokio-tungstenite 0.23.1", - "tracing", - "ws_stream_wasm", -] - [[package]] name = "android-tzdata" version = "0.1.1" @@ -1048,17 +960,6 @@ dependencies = [ "syn 2.0.77", ] -[[package]] -name = "async_io_stream" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" -dependencies = [ - "futures", - "pharos", - "rustc_version 0.4.1", -] - [[package]] name = "asynchronous-codec" version = "0.7.0" @@ -1149,6 +1050,7 @@ dependencies = [ "tracing", "tracing-subscriber", "walkdir", + "wasm-bindgen-test", "xor_name", ] @@ -1295,12 +1197,6 @@ dependencies = [ "console", ] -[[package]] -name = "bimap" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" - [[package]] name = "bincode" version = "1.3.3" @@ -1930,6 +1826,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + [[package]] name = "const-hex" version = "1.12.0" @@ -2579,12 +2485,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "doctest-file" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aac81fa3e28d21450aa4d2ac065992ba96a1d7303efbce51a95f4fd175b67562" - [[package]] name = "downcast" version = "0.11.0" @@ -2801,6 +2701,7 @@ name = "evmlib" version = "0.1.0" dependencies = [ "alloy", + "getrandom 0.2.15", "rand 0.8.5", "serde", "thiserror", @@ -2987,6 +2888,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -4214,6 +4130,22 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.4.1", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.8" @@ -4454,21 +4386,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "interprocess" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f4e4a06d42fab3e85ab1b419ad32b09eab58b901d40c57935ff92db3287a13" -dependencies = [ - "doctest-file", - "futures-core", - "libc", - "recvmsg", - "tokio", - "widestring", - "windows-sys 0.52.0", -] - [[package]] name = "ipconfig" version = "0.3.2" @@ -4566,21 +4483,6 @@ dependencies = [ "serde", ] -[[package]] -name = "jsonwebtoken" -version = "9.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" -dependencies = [ - "base64 0.21.7", - "js-sys", - "pem", - "ring 0.17.8", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "k256" version = "0.13.4" @@ -5432,6 +5334,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "minicov" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -5631,6 +5543,23 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -5965,6 +5894,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "opentelemetry" version = "0.20.0" @@ -6298,16 +6271,6 @@ dependencies = [ "indexmap 2.5.0", ] -[[package]] -name = "pharos" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" -dependencies = [ - "futures", - "rustc_version 0.4.1", -] - [[package]] name = "pin-project" version = "1.1.5" @@ -7123,12 +7086,6 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "recvmsg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" - [[package]] name = "redox_syscall" version = "0.5.4" @@ -7249,11 +7206,13 @@ dependencies = [ "http-body-util", "hyper 1.4.1", "hyper-rustls 0.27.3", + "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -7266,6 +7225,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", + "tokio-native-tls", "tokio-rustls 0.26.0", "tower-service", "url", @@ -7632,6 +7592,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -7721,6 +7690,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "self_encryption" version = "0.29.2" @@ -8023,18 +8015,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "simple_asn1" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" -dependencies = [ - "num-bigint 0.4.6", - "num-traits", - "thiserror", - "time", -] - [[package]] name = "slab" version = "0.4.9" @@ -8966,6 +8946,16 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.22.0" @@ -9019,23 +9009,7 @@ dependencies = [ "futures-util", "log", "tokio", - "tungstenite 0.21.0", -] - -[[package]] -name = "tokio-tungstenite" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" -dependencies = [ - "futures-util", - "log", - "rustls 0.23.13", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.26.0", - "tungstenite 0.23.0", - "webpki-roots 0.26.6", + "tungstenite", ] [[package]] @@ -9393,26 +9367,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "tungstenite" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand 0.8.5", - "rustls 0.23.13", - "rustls-pki-types", - "sha1", - "thiserror", - "utf-8", -] - [[package]] name = "typenum" version = "1.17.0" @@ -9602,6 +9556,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vergen" version = "8.3.2" @@ -9700,7 +9660,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "tokio", - "tokio-tungstenite 0.21.0", + "tokio-tungstenite", "tokio-util 0.7.12", "tower-service", "tracing", @@ -9785,6 +9745,32 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "wasm-bindgen-test" +version = "0.3.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "minicov", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "wasmtimer" version = "0.2.0" @@ -10146,25 +10132,6 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" -[[package]] -name = "ws_stream_wasm" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" -dependencies = [ - "async_io_stream", - "futures", - "js-sys", - "log", - "pharos", - "rustc_version 0.4.1", - "send_wrapper 0.6.0", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wyz" version = "0.5.1" diff --git a/README.md b/README.md index 33bbd87661..52a485c16a 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ If you wish to build a version of `safenode` from source, some special considera if you want it to connect to the current beta network. You should build from the `stable` branch, as follows: + ``` git checkout stable export GENESIS_PK=806b5c2eba70354ea92ba142c57587c9c5467ff69f0d43c482cda2313f9351e40c6120d76a2495cb3ca8367eee0a676f @@ -50,6 +51,7 @@ royalties are collected. They are also used as part of the node version string, a connecting node is compatible. For a client to connect to the current beta network, these keys must be set at build time: + ``` GENESIS_PK=8829ca178d6022de16fb8d3498411dd8a674a69c5f12e04d8b794a52ab056f1d419d12f690df1082dfa7efbbb10f62fa FOUNDATION_PK=84418659a8581b510c40b12e57da239787fd0d3b323f102f09fae9daf2ac96907e0045b1653c301de45117d393d92678 @@ -60,11 +62,13 @@ PAYMENT_FORWARD_PK=8c2f406a52d48d48505e1a3fdbb0c19ab42cc7c4807e9ea19c1fff3e5148f ##### Features You should also build `safe` with the `network-contacts` and `distribution` features enabled: + ``` cargo build --release --features="network-contacts,distribution" --bin safe ``` For `safenode`, only the `network-contacts` feature should be required: + ``` cargo build --release --features=network-contacts --bin safenode ``` @@ -135,7 +139,8 @@ YMMV until stabilised. ## Using a Local Network -We can explore the network's features by using multiple node processes to form a local network. +We can explore the network's features by using multiple node processes to form a local network. e also need to run a +local EVM network for our nodes and client to connect to. The latest version of [Rust](https://www.rust-lang.org/learn/get-started) should be installed. If you already have an installation, use `rustup update` to get the latest version. @@ -146,27 +151,31 @@ Run all the commands from the root of this repository. Follow these steps to create a local network: -1. Create the test network:
+1. If you haven't already, install Foundry. We need to have access to Anvil, which is packaged with Foundry, to run an + EVM node: https://book.getfoundry.sh/getting-started/installation
+2. Run a local EVM node:
-```bash -cargo run --bin safenode-manager --features local-discovery -- local run --build +```sh +cargo run --bin evm_testnet ``` -2. Verify node status:
+Take note of the console output for the next step (`RPC URL`, `Payment token address` & `Chunk payments address`). + +3. Create the test network and pass the EVM params:
+ `--rewards-address` _is the address where you will receive your node earnings on._ ```bash -cargo run --bin safenode-manager --features local-discovery -- status +cargo run --bin=safenode-manager --features=local-discovery -- local run --build --clean --rewards-address evm-custom --rpc-url --payment-token-address --chunk-payments-address ``` -3. Build a tokenized wallet:
+4. Verify node status:
```bash -cargo run --bin safe --features local-discovery -- wallet get-faucet 127.0.0.1:8000 +cargo run --bin safenode-manager --features local-discovery -- status ``` -The node manager's `run` command starts the node processes and a faucet process, the latter of -which will dispense tokens for use with the network. The `status` command should show twenty-five -running nodes. The `wallet` command retrieves some tokens, which enables file uploads. +The node manager's `run` command starts the node processes. The `status` command should show twenty-five +running nodes. ### Files @@ -256,7 +265,7 @@ cargo run --bin safe --features local-discovery -- wallet send 2 [address] ``` This will output a transfer as a hex string, which should be sent to the recipient. -This transfer is encrypted to the recipient so only the recipient can read and redeem it. +This transfer is encrypted to the recipient so only the recipient can read and redeem it. To receive a transfer, simply paste it after the wallet receive command: ``` diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index 876936e617..dd99f98fbe 100644 --- a/autonomi/Cargo.toml +++ b/autonomi/Cargo.toml @@ -15,7 +15,7 @@ full = ["data", "registers", "vault"] data = [] vault = ["data"] files = ["fs", "data"] -fs = [] +fs = ["tokio/fs"] local = ["sn_networking/local-discovery"] registers = [] @@ -40,7 +40,7 @@ sn_registers = { path = "../sn_registers", version = "0.3.19" } sn_transfers = { path = "../sn_transfers", version = "0.19.1" } sn_evm = { path = "../sn_evm" } thiserror = "1.0.23" -tokio = { version = "1.35.0", features = ["sync", "fs"] } +tokio = { version = "1.35.0", features = ["sync"] } tracing = { version = "~0.1.26" } walkdir = "2.5.0" xor_name = "5.0.0" @@ -48,6 +48,7 @@ xor_name = "5.0.0" [dev-dependencies] eyre = "0.6.5" tracing-subscriber = { version = "0.3", features = ["env-filter"] } +wasm-bindgen-test = "0.3.43" [lints] workspace = true diff --git a/evmlib/Cargo.toml b/evmlib/Cargo.toml index ea795b69c8..d78ee9e2e3 100644 --- a/evmlib/Cargo.toml +++ b/evmlib/Cargo.toml @@ -9,11 +9,14 @@ repository = "https://github.com/maidsafe/safe_network" version = "0.1.0" [dependencies] -alloy = { version = "0.2", default-features = false, features = ["std", "full", "provider-anvil-node", "reqwest-rustls-tls"] } +alloy = { version = "0.2", features = ["provider-anvil-node", "sol-types", "json", "signers", "contract", "signer-local", "network"] } serde = "1.0" thiserror = "1.0" tokio = "1.38.0" rand = "0.8.5" +[target.'cfg(target_arch = "wasm32")'.dependencies] +getrandom = { version = "0.2.12", features = ["js"] } + [lints] workspace = true From fede77dfefc27eae25adfab1807e2f6e067fef3c Mon Sep 17 00:00:00 2001 From: Mick van Dijke Date: Wed, 2 Oct 2024 09:32:53 +0200 Subject: [PATCH 2/3] chore: update alloy features in evmlib Co-authored-by: Benno --- evmlib/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmlib/Cargo.toml b/evmlib/Cargo.toml index d78ee9e2e3..79c2170270 100644 --- a/evmlib/Cargo.toml +++ b/evmlib/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/maidsafe/safe_network" version = "0.1.0" [dependencies] -alloy = { version = "0.2", features = ["provider-anvil-node", "sol-types", "json", "signers", "contract", "signer-local", "network"] } +alloy = { version = "0.2", default-features = false, features = ["std", "reqwest-rustls-tls", "provider-anvil-node", "sol-types", "json", "signers", "contract", "signer-local", "network"] } serde = "1.0" thiserror = "1.0" tokio = "1.38.0" From be618dc5db6c92dd91dd8174c0b8693a67527f3b Mon Sep 17 00:00:00 2001 From: Warm Beer Date: Wed, 2 Oct 2024 09:49:57 +0200 Subject: [PATCH 3/3] test(autonomi): added wasm put/get test --- Cargo.lock | 143 ----------------------------------------- autonomi/tests/wasm.rs | 37 +++++++++++ 2 files changed, 37 insertions(+), 143 deletions(-) create mode 100644 autonomi/tests/wasm.rs diff --git a/Cargo.lock b/Cargo.lock index 49c73299c9..1de99e6ffe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2888,21 +2888,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -4130,22 +4115,6 @@ dependencies = [ "tokio-io-timeout", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper 1.4.1", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.8" @@ -5543,23 +5512,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "native-tls" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -5894,50 +5846,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "openssl" -version = "0.10.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "opentelemetry" version = "0.20.0" @@ -7206,13 +7114,11 @@ dependencies = [ "http-body-util", "hyper 1.4.1", "hyper-rustls 0.27.3", - "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -7225,7 +7131,6 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", - "tokio-native-tls", "tokio-rustls 0.26.0", "tower-service", "url", @@ -7592,15 +7497,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "scoped-tls" version = "1.0.1" @@ -7690,29 +7586,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "security-framework" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" -dependencies = [ - "bitflags 2.6.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "self_encryption" version = "0.29.2" @@ -8946,16 +8819,6 @@ dependencies = [ "syn 2.0.77", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.22.0" @@ -9556,12 +9419,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "vergen" version = "8.3.2" diff --git a/autonomi/tests/wasm.rs b/autonomi/tests/wasm.rs new file mode 100644 index 0000000000..4814a0c102 --- /dev/null +++ b/autonomi/tests/wasm.rs @@ -0,0 +1,37 @@ +use std::time::Duration; + +use crate::common::{evm_network_from_env, evm_wallet_from_env_or_default}; +use autonomi::Client; +use tokio::time::sleep; +use wasm_bindgen_test::*; + +mod common; + +wasm_bindgen_test_configure!(run_in_browser); + +#[tokio::test] +#[wasm_bindgen_test] +async fn file() -> Result<(), Box> { + common::enable_logging(); + + let peers = vec![ + "/ip4/127.0.0.1/tcp/35499/ws/p2p/12D3KooWGN5RqREZ4RYtsUc3DNCkrNSVXEzTYEbMb1AZx2rNddoW" + .try_into() + .expect("str to be valid multiaddr"), + ]; + + let network = evm_network_from_env(); + let mut client = Client::connect(&peers).await.unwrap(); + let wallet = evm_wallet_from_env_or_default(network); + + let data = common::gen_random_data(1024 * 1024 * 10); + + let addr = client.put(data.clone(), &wallet).await.unwrap(); + + sleep(Duration::from_secs(2)).await; + + let data_fetched = client.get(addr).await.unwrap(); + assert_eq!(data, data_fetched, "data fetched should match data put"); + + Ok(()) +}