From a7a8684b7a3b1f5c5032a4e3a3b83f082626a898 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Mon, 24 Oct 2022 23:54:36 +0200 Subject: [PATCH 1/8] run wasm_executor from js --- .gitignore | 2 + README.md | 6 +- executor/Cargo.lock | 1354 ++---------------------------------- executor/Cargo.toml | 23 +- executor/src/lib.rs | 32 + executor/src/main.rs | 35 - executor/src/runner_api.rs | 16 +- executor/src/task.rs | 25 +- package.json | 3 +- src/index.ts | 14 +- src/task.ts | 20 +- tsconfig.json | 1 + yarn.lock | 136 ++-- 13 files changed, 223 insertions(+), 1444 deletions(-) create mode 100644 executor/src/lib.rs delete mode 100644 executor/src/main.rs diff --git a/.gitignore b/.gitignore index b960a8f7..5ad30835 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,5 @@ dist !.yarn/plugins !.yarn/sdks !.yarn/versions + +.idea diff --git a/README.md b/README.md index 379d6836..49eee9a8 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Create parallel reality of your Substrate network. - Install deps - `yarn` +- Build wasm + - `yarn build-wasm` - Run nodejs runner - - `yarn dev` -- Run rust executor - - `cargo run --manifest-path executor/Cargo.toml` + - `yarn start run-block --endpoint=wss://acala-rpc-2.aca-api.network/ws` Currently it defaults to execute the latest block of Acala parachain. More options will be added later. diff --git a/executor/Cargo.lock b/executor/Cargo.lock index 7880f029..1b7acd22 100644 --- a/executor/Cargo.lock +++ b/executor/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli", -] - [[package]] name = "aead" version = "0.4.3" @@ -46,17 +37,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.7", - "once_cell", - "version_check", -] - [[package]] name = "anyhow" version = "1.0.65" @@ -84,66 +64,6 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" -[[package]] -name = "async-channel" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "once_cell", - "slab", -] - -[[package]] -name = "async-global-executor" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da5b41ee986eed3f524c380e6d64965aea573882a8907682ad100f7859305ca" -dependencies = [ - "async-channel", - "async-executor", - "async-io", - "async-lock", - "blocking", - "futures-lite", - "once_cell", -] - -[[package]] -name = "async-io" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7" -dependencies = [ - "autocfg", - "concurrent-queue", - "futures-lite", - "libc", - "log", - "once_cell", - "parking", - "polling", - "slab", - "socket2", - "waker-fn", - "winapi", -] - [[package]] name = "async-lock" version = "2.5.0" @@ -153,38 +73,6 @@ dependencies = [ "event-listener", ] -[[package]] -name = "async-std" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" -dependencies = [ - "async-channel", - "async-global-executor", - "async-io", - "async-lock", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "once_cell", - "pin-project-lite", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-task" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" - [[package]] name = "async-trait" version = "0.1.57" @@ -205,23 +93,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "atomic-waker" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -243,15 +114,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bip39" version = "1.0.1" @@ -268,12 +130,6 @@ version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ce18265ec2324ad075345d5814fbeed4f41f0a660055dc78840b74d19b874b1" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "blake2" version = "0.10.4" @@ -311,20 +167,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "blocking" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" -dependencies = [ - "async-channel", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "once_cell", -] - [[package]] name = "bs58" version = "0.4.0" @@ -349,24 +191,6 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" - -[[package]] -name = "cache-padded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" - -[[package]] -name = "cc" -version = "1.0.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - [[package]] name = "cfg-if" version = "1.0.0" @@ -408,49 +232,23 @@ dependencies = [ ] [[package]] -name = "clap" -version = "4.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f" -dependencies = [ - "atty", - "bitflags", - "clap_derive", - "clap_lex", - "once_cell", - "strsim", - "termcolor", -] - -[[package]] -name = "clap_derive" -version = "4.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.3.0" +name = "console_error_panic_hook" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "os_str_bytes", + "cfg-if", + "wasm-bindgen", ] [[package]] -name = "concurrent-queue" -version = "1.2.4" +name = "console_log" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +checksum = "501a375961cef1a0d44767200e66e4a559283097e91d0730b1d75dfb2f8a1494" dependencies = [ - "cache-padded", + "log", + "web-sys", ] [[package]] @@ -465,31 +263,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "cpp_demangle" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" -dependencies = [ - "cfg-if", -] - [[package]] name = "cpufeatures" version = "0.2.5" @@ -499,113 +272,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cranelift-bforest" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44409ccf2d0f663920cab563d2b79fcd6b2e9a2bcc6e929fef76c8f82ad6c17a" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de2018ad96eb97f621f7d6b900a0cc661aec8d02ea4a50e56ecb48e5a2fcaf" -dependencies = [ - "arrayvec 0.7.2", - "bumpalo", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "cranelift-isle", - "gimli", - "log", - "regalloc2", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5287ce36e6c4758fbaf298bd1a8697ad97a4f2375a3d1b61142ea538db4877e5" -dependencies = [ - "cranelift-codegen-shared", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2855c24219e2f08827f3f4ffb2da92e134ae8d8ecc185b11ec8f9878cf5f588e" - -[[package]] -name = "cranelift-entity" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b65673279d75d34bf11af9660ae2dbd1c22e6d28f163f5c72f4e1dc56d56103" -dependencies = [ - "serde", -] - -[[package]] -name = "cranelift-frontend" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed2b3d7a4751163f6c4a349205ab1b7d9c00eecf19dcea48592ef1f7688eefc" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-isle" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be64cecea9d90105fc6a2ba2d003e98c867c1d6c4c86cc878f97ad9fb916293" - -[[package]] -name = "cranelift-native" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a03a6ac1b063e416ca4b93f6247978c991475e8271465340caa6f92f3c16a4" -dependencies = [ - "cranelift-codegen", - "libc", - "target-lexicon", -] - -[[package]] -name = "cranelift-wasm" -version = "0.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c699873f7b30bc5f20dd03a796b4183e073a46616c91704792ec35e45d13f913" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "itertools", - "log", - "smallvec", - "wasmparser", - "wasmtime-types", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - [[package]] name = "crossbeam-queue" version = "0.3.6" @@ -651,16 +317,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctor" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdffe87e1d521a10f9696f833fe502293ea446d7f256c06128293a4119bdf4cb" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "ctr" version = "0.8.0" @@ -768,27 +424,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "event-listener" version = "2.5.3" @@ -799,29 +434,19 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" name = "executor" version = "0.1.0" dependencies = [ - "clap", + "console_error_panic_hook", + "console_log", + "futures", + "getrandom 0.2.7", "hex", "hex-literal", "jsonrpsee", + "log", "serde", "serde_json", "smoldot", - "tokio", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fastrand" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", + "wasm-bindgen", + "wasm-bindgen-futures", ] [[package]] @@ -870,7 +495,6 @@ dependencies = [ "futures-core", "futures-task", "futures-util", - "num_cpus", ] [[package]] @@ -879,21 +503,6 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.24" @@ -922,6 +531,10 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +dependencies = [ + "gloo-timers", + "send_wrapper", +] [[package]] name = "futures-util" @@ -941,15 +554,6 @@ dependencies = [ "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.6" @@ -978,8 +582,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -993,15 +599,24 @@ dependencies = [ ] [[package]] -name = "gimli" -version = "0.26.2" +name = "gloo-net" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "ec897194fb9ac576c708f63d35604bc58f2a262b8cec0fabfed26f3991255f21" dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] [[package]] name = "gloo-timers" @@ -1016,28 +631,25 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.12.3" +name = "gloo-utils" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "40913a05c8297adca04392f707b1e73b12ba7b8eab7244a4961580b1fd34063c" dependencies = [ - "ahash", + "js-sys", "serde", + "serde_json", + "wasm-bindgen", + "web-sys", ] [[package]] -name = "heck" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" - -[[package]] -name = "hermit-abi" -version = "0.1.19" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "libc", + "serde", ] [[package]] @@ -1082,23 +694,6 @@ dependencies = [ "hmac 0.8.1", ] -[[package]] -name = "http" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -1110,32 +705,6 @@ dependencies = [ "syn", ] -[[package]] -name = "indexmap" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" -dependencies = [ - "autocfg", - "hashbrown", - "serde", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" - [[package]] name = "itertools" version = "0.10.5" @@ -1169,7 +738,7 @@ dependencies = [ "jsonrpsee-core", "jsonrpsee-proc-macros", "jsonrpsee-types", - "jsonrpsee-ws-client", + "jsonrpsee-wasm-client", "tracing", ] @@ -1179,19 +748,14 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8752740ecd374bcbf8b69f3e80b0327942df76f793f8d4e60d3355650c31fb74" dependencies = [ + "anyhow", + "futures-channel", + "futures-timer", "futures-util", - "http", + "gloo-net", "jsonrpsee-core", - "jsonrpsee-types", - "pin-project", - "rustls-native-certs", - "soketto", "thiserror", - "tokio", - "tokio-rustls", - "tokio-util", "tracing", - "webpki-roots", ] [[package]] @@ -1212,9 +776,9 @@ dependencies = [ "serde", "serde_json", "thiserror", - "tokio", "tracing", "tracing-futures", + "wasm-bindgen-futures", ] [[package]] @@ -1244,12 +808,11 @@ dependencies = [ ] [[package]] -name = "jsonrpsee-ws-client" +name = "jsonrpsee-wasm-client" version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee5feddd5188e62ac08fcf0e56478138e581509d4730f3f7be9b57dd402a4ff" +checksum = "597b4eb94730e7695d0a2a429bc37a12e6e84d12680fdafb9b8f5f53652aab57" dependencies = [ - "http", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", @@ -1261,21 +824,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.135" @@ -1336,22 +884,6 @@ dependencies = [ "libsecp256k1-core", ] -[[package]] -name = "linux-raw-sys" -version = "0.0.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.17" @@ -1359,16 +891,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", - "value-bag", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", ] [[package]] @@ -1377,15 +899,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "memory_units" version = "0.3.0" @@ -1410,18 +923,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "mio" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" -dependencies = [ - "libc", - "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", -] - [[package]] name = "no-std-net" version = "0.6.0" @@ -1497,28 +998,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" -dependencies = [ - "crc32fast", - "hashbrown", - "indexmap", - "memchr", -] - [[package]] name = "once_cell" version = "1.15.0" @@ -1531,18 +1010,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "os_str_bytes" -version = "6.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" - [[package]] name = "parity-scale-codec" version = "3.2.1" @@ -1573,41 +1040,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - -[[package]] -name = "paste" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" - [[package]] name = "pbkdf2" version = "0.11.0" @@ -1649,26 +1081,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" - -[[package]] -name = "polling" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011" -dependencies = [ - "autocfg", - "cfg-if", - "libc", - "log", - "wepoll-ffi", - "winapi", -] - [[package]] name = "poly1305" version = "0.7.2" @@ -1709,30 +1121,6 @@ dependencies = [ "toml", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.47" @@ -1742,15 +1130,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "psm" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" -dependencies = [ - "cc", -] - [[package]] name = "quote" version = "1.0.21" @@ -1805,48 +1184,6 @@ dependencies = [ "getrandom 0.2.7", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regalloc2" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d43a209257d978ef079f3d446331d0f1794f5e0fc19b306a199983857833a779" -dependencies = [ - "fxhash", - "log", - "slice-group-by", - "smallvec", -] - -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin", - "untrusted", - "web-sys", - "winapi", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -1862,53 +1199,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.35.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb2fda4666def1433b1b05431ab402e42a1084285477222b72d6c564c417cef" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "rustls" -version = "0.20.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033" -dependencies = [ - "log", - "ring", - "sct", - "webpki", -] - -[[package]] -name = "rustls-native-certs" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" -dependencies = [ - "base64", -] - [[package]] name = "ruzstd" version = "0.3.0" @@ -1926,16 +1216,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" -[[package]] -name = "schannel" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" -dependencies = [ - "lazy_static", - "windows-sys", -] - [[package]] name = "schnorrkel" version = "0.10.2" @@ -1952,51 +1232,18 @@ dependencies = [ "zeroize", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "sct" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "security-framework" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + [[package]] name = "serde" version = "1.0.145" @@ -2028,19 +1275,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.9.9" @@ -2065,15 +1299,6 @@ dependencies = [ "digest 0.10.5", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" -dependencies = [ - "libc", -] - [[package]] name = "siphasher" version = "0.3.10" @@ -2089,12 +1314,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slice-group-by" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" - [[package]] name = "smallvec" version = "1.10.0" @@ -2106,7 +1325,6 @@ name = "smoldot" version = "0.4.0" dependencies = [ "arrayvec 0.7.2", - "async-std", "atomic", "base64", "bip39", @@ -2131,9 +1349,7 @@ dependencies = [ "num-rational 0.4.1", "num-traits", "parity-scale-codec", - "parking_lot", "pbkdf2", - "pin-project", "rand", "rand_chacha", "ruzstd", @@ -2145,12 +1361,9 @@ dependencies = [ "slab", "smallvec", "snow", - "soketto", - "sqlite", "tiny-keccak", "twox-hash", "wasmi", - "wasmtime", ] [[package]] @@ -2169,85 +1382,12 @@ dependencies = [ "subtle", ] -[[package]] -name = "socket2" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "soketto" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" -dependencies = [ - "base64", - "bytes", - "futures", - "httparse", - "log", - "rand", - "sha-1", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "sqlite" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2df8edd55685048550daaaf2be9024182f3523086cc86f7d50c136e55173e8c" -dependencies = [ - "libc", - "sqlite3-sys", -] - -[[package]] -name = "sqlite3-src" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1815a7a02c996eb8e5c64f61fcb6fd9b12e593ce265c512c5853b2513635691" -dependencies = [ - "cc", - "pkg-config", -] - -[[package]] -name = "sqlite3-sys" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d47c99824fc55360ba00caf28de0b8a0458369b832e016a64c13af0ad9fbb9ee" -dependencies = [ - "libc", - "sqlite3-src", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "subtle" version = "2.4.1" @@ -2283,21 +1423,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "target-lexicon" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" - -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.37" @@ -2327,62 +1452,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tokio" -version = "1.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" -dependencies = [ - "autocfg", - "bytes", - "libc", - "memchr", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "winapi", -] - -[[package]] -name = "tokio-macros" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls", - "tokio", - "webpki", -] - -[[package]] -name = "tokio-util" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" -dependencies = [ - "bytes", - "futures-core", - "futures-io", - "futures-sink", - "pin-project-lite", - "tokio", -] - [[package]] name = "toml" version = "0.5.9" @@ -2472,34 +1541,12 @@ dependencies = [ "subtle", ] -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] -name = "value-bag" -version = "1.0.0-alpha.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" -dependencies = [ - "ctor", - "version_check", -] - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2519,6 +1566,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if", + "serde", + "serde_json", "wasm-bindgen-macro", ] @@ -2602,175 +1651,6 @@ dependencies = [ "parity-wasm", ] -[[package]] -name = "wasmparser" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5d3e08b13876f96dd55608d03cd4883a0545884932d5adf11925876c96daef" -dependencies = [ - "indexmap", -] - -[[package]] -name = "wasmtime" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f511c4917c83d04da68333921107db75747c4e11a2f654a8e909cc5e0520dc" -dependencies = [ - "anyhow", - "async-trait", - "bincode", - "cfg-if", - "indexmap", - "libc", - "log", - "object", - "once_cell", - "paste", - "psm", - "serde", - "target-lexicon", - "wasmparser", - "wasmtime-cranelift", - "wasmtime-environ", - "wasmtime-fiber", - "wasmtime-jit", - "wasmtime-runtime", - "windows-sys", -] - -[[package]] -name = "wasmtime-asm-macros" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39bf3debfe744bf19dd3732990ce6f8c0ced7439e2370ba4e1d8f5a3660a3178" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "wasmtime-cranelift" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058217e28644b012bdcdf0e445f58d496d78c2e0b6a6dd93558e701591dad705" -dependencies = [ - "anyhow", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "cranelift-native", - "cranelift-wasm", - "gimli", - "log", - "object", - "target-lexicon", - "thiserror", - "wasmparser", - "wasmtime-environ", -] - -[[package]] -name = "wasmtime-environ" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7af06848df28b7661471d9a80d30a973e0f401f2e3ed5396ad7e225ed217047" -dependencies = [ - "anyhow", - "cranelift-entity", - "gimli", - "indexmap", - "log", - "object", - "serde", - "target-lexicon", - "thiserror", - "wasmparser", - "wasmtime-types", -] - -[[package]] -name = "wasmtime-fiber" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fc45a6497f557382fc19b8782ad5d47ce3fced469bdaf303ec6b5b2e83c1a6" -dependencies = [ - "cc", - "cfg-if", - "rustix", - "wasmtime-asm-macros", - "windows-sys", -] - -[[package]] -name = "wasmtime-jit" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9028fb63a54185b3c192b7500ef8039c7bb8d7f62bfc9e7c258483a33a3d13bb" -dependencies = [ - "addr2line", - "anyhow", - "bincode", - "cfg-if", - "cpp_demangle", - "gimli", - "log", - "object", - "rustc-demangle", - "rustix", - "serde", - "target-lexicon", - "thiserror", - "wasmtime-environ", - "wasmtime-runtime", - "windows-sys", -] - -[[package]] -name = "wasmtime-jit-debug" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25e82d4ef93296785de7efca92f7679dc67fe68a13b625a5ecc8d7503b377a37" -dependencies = [ - "once_cell", -] - -[[package]] -name = "wasmtime-runtime" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f0e9bea7d517d114fe66b930b2124ee086516ee93eeebfd97f75f366c5b0553" -dependencies = [ - "anyhow", - "cc", - "cfg-if", - "indexmap", - "libc", - "log", - "mach", - "memoffset", - "paste", - "rand", - "rustix", - "thiserror", - "wasmtime-asm-macros", - "wasmtime-environ", - "wasmtime-fiber", - "wasmtime-jit-debug", - "windows-sys", -] - -[[package]] -name = "wasmtime-types" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b83e93ed41b8fdc936244cfd5e455480cf1eca1fd60c78a0040038b4ce5075" -dependencies = [ - "cranelift-entity", - "serde", - "thiserror", - "wasmparser", -] - [[package]] name = "web-sys" version = "0.3.60" @@ -2781,108 +1661,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" -dependencies = [ - "webpki", -] - -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "zeroize" version = "1.5.7" diff --git a/executor/Cargo.toml b/executor/Cargo.toml index 6d5740a6..ae671ac0 100644 --- a/executor/Cargo.toml +++ b/executor/Cargo.toml @@ -5,13 +5,22 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +crate-type = ["cdylib"] + [dependencies] -clap = { version = "4.0.15", features = ["derive"] } +getrandom = { version = "0.2", default-features = false, features = ["js"] } +jsonrpsee = { version = "0.15.1", default-features = false, features = ["wasm-client", "macros"] } +serde = { version = "1.0.136", default-features = false } +serde_json = { version = "1.0", default-features = false } +hex = { version = "0.4.3", default-features = false } hex-literal = "0.3.4" -jsonrpsee = { version = "0.15.1", features = ["ws-client", "macros"] } -serde = "1.0.136" -serde_json = "1.0" -tokio = { version = "1.21.2", features = ["full"] } -hex = "0.4.3" +wasm-bindgen = "0.2.83" +wasm-bindgen-futures = "0.4.33" +futures = "0.3.24" +log = { version = "0.4.17", features = ["std"] } +console_error_panic_hook = "0.1.7" +console_log = "0.2.0" + +smoldot = { path = '../vendor/smoldot', default-features = false } -smoldot = { path = '../vendor/smoldot' } diff --git a/executor/src/lib.rs b/executor/src/lib.rs new file mode 100644 index 00000000..4c3239ed --- /dev/null +++ b/executor/src/lib.rs @@ -0,0 +1,32 @@ +extern crate console_error_panic_hook; + +use futures::prelude::*; +use jsonrpsee::core::client::Client; +use wasm_bindgen::prelude::*; + +mod runner_api; +mod task; + +use crate::runner_api::RpcApiClient; + +#[wasm_bindgen] +pub async fn start(task_id: u32, ws_url: &str) -> Result<(), JsValue> { + std::panic::set_hook(Box::new(console_error_panic_hook::hook)); + console_log::init_with_level(log::Level::Debug).expect("error initializing logger"); + + let client = runner_api::client(ws_url) + .await + .map_err(|e| e.to_string())?; + run_task(&client, task_id) + .map_err(|x| x.to_string()) + .await?; + + Closure::::new(move || drop(&client)).forget(); + + Ok(()) +} + +async fn run_task(client: &Client, task_id: u32) -> Result<(), jsonrpsee::core::Error> { + let task = client.get_task(task_id).await?; + task.run(task_id, &client).await +} diff --git a/executor/src/main.rs b/executor/src/main.rs deleted file mode 100644 index feb8c4f6..00000000 --- a/executor/src/main.rs +++ /dev/null @@ -1,35 +0,0 @@ -use runner_api::RpcApiClient; - -mod runner_api; -mod task; - -#[derive(Debug, Clone, clap::Parser)] -pub struct Command { - #[clap(long, default_value = "ws://localhost:8000")] - runner_url: String, - - #[clap(long, default_value = "0")] - task_id: u32, -} - -#[tokio::main] -async fn main() -> Result<(), jsonrpsee::core::Error> { - real_main().await -} - -async fn real_main() -> Result<(), jsonrpsee::core::Error> { - let config = ::parse(); - let task_id = config.task_id; - - println!("Starting {}", task_id); - - let client = runner_api::client(&config.runner_url).await?; - - let task = client.get_task(task_id).await?; - - task.run(task_id, &client).await?; - - println!("Done"); - - Ok(()) -} diff --git a/executor/src/runner_api.rs b/executor/src/runner_api.rs index 6adff97d..413b3ba7 100644 --- a/executor/src/runner_api.rs +++ b/executor/src/runner_api.rs @@ -1,12 +1,12 @@ use std::time::Duration; +use crate::task::{Task, TaskResponse}; use jsonrpsee::{ - core::Error as RpcError, + core::{client::Client, Error as RpcError}, proc_macros::rpc, - ws_client::{WsClient, WsClientBuilder}, + wasm_client::WasmClientBuilder, }; use smoldot::json_rpc::methods::HexString; -use crate::task::{Task, TaskResponse}; #[rpc(client)] pub trait RpcApi { @@ -38,15 +38,11 @@ pub trait RpcApi { fn get_task(&self, task_id: u32) -> Result; #[method(name = "exec_taskResult")] - fn task_result( - &self, - task_id: u32, - resp: TaskResponse, - ) -> Result<(), RpcError>; + fn task_result(&self, task_id: u32, resp: TaskResponse) -> Result<(), RpcError>; } -pub async fn client(url: &str) -> Result { - let client = WsClientBuilder::default() +pub async fn client(url: &str) -> Result { + let client = WasmClientBuilder::default() .request_timeout(Duration::from_secs(120)) .build(url) .await?; diff --git a/executor/src/task.rs b/executor/src/task.rs index 6949ed0e..160d725c 100644 --- a/executor/src/task.rs +++ b/executor/src/task.rs @@ -1,5 +1,5 @@ use core::iter; -use jsonrpsee::ws_client::WsClient; +use jsonrpsee::core::client::Client; use serde::{Deserialize, Serialize}; use smoldot::{ executor::{ @@ -30,8 +30,8 @@ pub struct Task { #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct CallResponse { - result: HexString, - storage_diff: Vec<(HexString, Option)> + result: HexString, + storage_diff: Vec<(HexString, Option)>, } #[derive(Serialize, Deserialize, Debug)] @@ -41,7 +41,7 @@ pub enum TaskResponse { } impl Task { - pub async fn run(&self, task_id: u32, client: &WsClient) -> Result<(), jsonrpsee::core::Error> { + pub async fn run(&self, task_id: u32, client: &Client) -> Result<(), jsonrpsee::core::Error> { let resp = match self.kind { TaskKind::Call => self.call(task_id, client).await, TaskKind::RuntimeVersion => self.runtime_version(task_id, client).await, @@ -55,7 +55,7 @@ impl Task { async fn call( &self, task_id: u32, - client: &WsClient, + client: &Client, ) -> Result { let mut storage_top_trie_changes = storage_diff::StorageDiff::empty(); let mut offchain_storage_changes = storage_diff::StorageDiff::empty(); @@ -68,7 +68,7 @@ impl Task { }) .unwrap(); - let mut ret: Vec = vec![]; + let mut ret: Vec = vec![]; for (call, params) in self.calls.as_ref().unwrap() { let mut vm = runtime_host::run(runtime_host::Config { @@ -129,7 +129,7 @@ impl Task { let res = res.unwrap(); - ret = res.virtual_machine.value().as_ref().to_vec(); + ret = res.virtual_machine.value().as_ref().to_vec(); storage_top_trie_changes = res.storage_top_trie_changes; offchain_storage_changes = res.offchain_storage_changes; @@ -140,13 +140,16 @@ impl Task { .map(|(k, v)| (HexString(k), v.map(HexString))) .collect(); - Ok(TaskResponse::Call(CallResponse { result: HexString(ret), storage_diff: diff })) + Ok(TaskResponse::Call(CallResponse { + result: HexString(ret), + storage_diff: diff, + })) } async fn runtime_version( &self, _task_id: u32, - _client: &WsClient, + _client: &Client, ) -> Result { let vm_proto = HostVmPrototype::new(Config { module: &self.wasm, @@ -158,6 +161,8 @@ impl Task { let resp = vm_proto.runtime_version(); - Ok(TaskResponse::RuntimeVersion(HexString(resp.as_ref().to_vec()))) + Ok(TaskResponse::RuntimeVersion(HexString( + resp.as_ref().to_vec(), + ))) } } diff --git a/package.json b/package.json index 520f5ebc..36621656 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "lint": "tsc --noEmit --project tsconfig.json && eslint . --ext .js,.ts && prettier --check .", "fix": "eslint . --ext .js,.ts --fix && prettier -w .", "prepare": "husky install", + "build-wasm": "cd executor && wasm-pack --log-level=info build --target nodejs", "start": "ts-node src/index.ts", - "dev": "LOG_LEVEL=trace node-dev --notify=false src/index.ts -- dev --endpoint=wss://acala-rpc-2.aca-api.network/ws --head=0xecd7db7a9959ef8a3632789aed9e94cfdcd9790f64f310e0393c58295658e3a3 --executor-cmd='cargo run --manifest-path executor/Cargo.toml --' | pino-pretty" + "dev": "LOG_LEVEL=trace node-dev --notify=false src/index.ts -- dev --endpoint=wss://acala-rpc-2.aca-api.network/ws --head=0xecd7db7a9959ef8a3632789aed9e94cfdcd9790f64f310e0393c58295658e3a3 | pino-pretty" }, "dependencies": { "@polkadot/api": "^9.5.2", diff --git a/src/index.ts b/src/index.ts index 28b82854..4cb28e9c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,7 +27,7 @@ const setup = async (argv: any) => { defaultLogger.info({ endpoint: argv.endpoint, blockHash }, 'Args') const header = await api.rpc.chain.getHeader(blockHash) - const tasks = new TaskManager(argv['executor-cmd'], port) + const tasks = new TaskManager(port) const chain = new Blockchain(api, tasks, { hash: blockHash, number: header.number.toNumber() }) const context = { chain, api, ws: wsProvider, tasks } @@ -60,7 +60,7 @@ const runBlock = async (argv: any) => { blockHash: parent, wasm, calls, - }) + }, console.log) setTimeout(() => process.exit(0), 50) } @@ -84,11 +84,6 @@ yargs(hideBin(process.argv)) desc: 'Block hash or block number. Default to latest block', string: true, }, - 'executor-cmd': { - desc: 'Command to execute the executor', - string: true, - require: true, - }, }), (argv) => { runBlock(argv).catch((err) => { @@ -115,11 +110,6 @@ yargs(hideBin(process.argv)) desc: 'Block hash or block number. Default to latest block', string: true, }, - 'executor-cmd': { - desc: 'Command to execute the executor', - string: true, - require: true, - }, }), (argv) => { setup(argv).catch((err) => { diff --git a/src/task.ts b/src/task.ts index 19a2f987..348a28b4 100644 --- a/src/task.ts +++ b/src/task.ts @@ -1,6 +1,9 @@ -import { spawn } from 'child_process' +import { WebSocket } from 'ws' +// @ts-ignore +global.WebSocket = WebSocket; import { defaultLogger } from './logger' +import { start } from '../executor/pkg' const logger = defaultLogger.child({ name: 'task' }) @@ -13,11 +16,9 @@ interface Task { export class TaskManager { #tasks: { task: Task; callback: (res: any) => any }[] = [] - #executorCmd: string #listeningPort: number - constructor(executorCmd: string, listeningPort: number) { - this.#executorCmd = executorCmd + constructor(listeningPort: number) { this.#listeningPort = listeningPort } @@ -42,16 +43,7 @@ export class TaskManager { } runTask(taskId: number): Promise { - const cmd = `${this.#executorCmd} --runner-url=ws://localhost:${this.#listeningPort} --task-id=${taskId}` - logger.info({ taskId, cmd }, 'RunTask') - const p = spawn(cmd, { shell: true, stdio: 'inherit' }) - - return new Promise((resolve) => { - p.once('exit', (code) => { - logger.debug({ taskId, code }, 'RunTask done') - resolve() - }) - }) + return start(taskId, `ws://localhost:${this.#listeningPort}`) } async addAndRunTask(task: Task, callback: (res: any) => any = () => {}) { diff --git a/tsconfig.json b/tsconfig.json index c4657c14..3fcfc124 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "moduleResolution": "node", "noUnusedLocals": true, "noUnusedParameters": true, + "noImplicitAny": false, "outDir": "lib", "sourceMap": true, "target": "esnext", diff --git a/yarn.lock b/yarn.lock index 4ce0f9b2..d7bb6d13 100644 --- a/yarn.lock +++ b/yarn.lock @@ -673,9 +673,16 @@ __metadata: linkType: hard "@types/node@npm:*, @types/node@npm:^18.11.0": - version: 18.11.0 - resolution: "@types/node@npm:18.11.0" - checksum: f27f899ab428e5732f04fadadc9203f44bdf3abf56474540ee27da90e4f2ba133faf87263cada4d2271955f92ee6a142bd50683c86290fe5070c19aac44fd654 + version: 18.11.2 + resolution: "@types/node@npm:18.11.2" + checksum: 0ff5c90fb9ab653e018b858479aea4d2f763b07b31f9502383d408936f525ca37cac82ea27774a0dd0356ff9badba2792a6a3fff94f79fd7c82ee2a892c43ed5 + languageName: node + linkType: hard + +"@types/semver@npm:^7.3.12": + version: 7.3.12 + resolution: "@types/semver@npm:7.3.12" + checksum: 35536b2fc5602904f21cae681f6c9498e177dab3f54ae37c92f9a1b7e43c35f18bcd81e1c98c1cf0d33ee046bb06c771e9928c1c00a401d56a03f56549252a15 languageName: node linkType: hard @@ -714,12 +721,12 @@ __metadata: linkType: hard "@typescript-eslint/eslint-plugin@npm:^5.23.0": - version: 5.40.0 - resolution: "@typescript-eslint/eslint-plugin@npm:5.40.0" + version: 5.40.1 + resolution: "@typescript-eslint/eslint-plugin@npm:5.40.1" dependencies: - "@typescript-eslint/scope-manager": 5.40.0 - "@typescript-eslint/type-utils": 5.40.0 - "@typescript-eslint/utils": 5.40.0 + "@typescript-eslint/scope-manager": 5.40.1 + "@typescript-eslint/type-utils": 5.40.1 + "@typescript-eslint/utils": 5.40.1 debug: ^4.3.4 ignore: ^5.2.0 regexpp: ^3.2.0 @@ -731,43 +738,43 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: ac9e8fcea3545eb33353373c5094fd0a7b79647b37066adbcbd8edcb6fc17c6a601fd0e1b8db0a39200e8238acb33d4b1b036bfe09ebb9899cfb43f6c271a8fd + checksum: 61f19bde0f1206beb20aeb28d18c1ef26a98cf4d2ead9f1d2f204cb91af31582eb5ee9422fe5f92d6aa10cebf85cd50f1b41e8cf8ce65808e2208664c3b1d66a languageName: node linkType: hard "@typescript-eslint/parser@npm:^5.23.0": - version: 5.40.0 - resolution: "@typescript-eslint/parser@npm:5.40.0" + version: 5.40.1 + resolution: "@typescript-eslint/parser@npm:5.40.1" dependencies: - "@typescript-eslint/scope-manager": 5.40.0 - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/typescript-estree": 5.40.0 + "@typescript-eslint/scope-manager": 5.40.1 + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/typescript-estree": 5.40.1 debug: ^4.3.4 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: a8d02950dd12fcb1d19ad5f24cbfd186ca88d8a099160f93f99767896a45198a9f9bfbdd1a57c1ae50d452e6c895ae5b4d7e4623dfc87bca55a45c5ba16491f8 + checksum: 9fe410c1b14934803bb7c26de9b8de5d46ef9b6fe5dcbee1d7e111f0259659c214549b60dacdc729a3e23da835e6a44f08a9aa6bcb73ffff3c4fd5b9142358ed languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/scope-manager@npm:5.40.0" +"@typescript-eslint/scope-manager@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/scope-manager@npm:5.40.1" dependencies: - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/visitor-keys": 5.40.0 - checksum: 48dfb2f1a71bda5b782263e97608f1e1a2e8a89a603344af5072208be7936140af9d41483be439405c5ee379d0263555d6cc94405b187707f9ecfd7dd9821b5f + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/visitor-keys": 5.40.1 + checksum: 5f25b86bfd09fbf8cdfdf932eaf0b41a7594c9b4539d3c8321f882bf7b4bf486454256fdb9a5a8c4eae305419d377fa93d382f80004711d759ff77b3d565c1dc languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/type-utils@npm:5.40.0" +"@typescript-eslint/type-utils@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/type-utils@npm:5.40.1" dependencies: - "@typescript-eslint/typescript-estree": 5.40.0 - "@typescript-eslint/utils": 5.40.0 + "@typescript-eslint/typescript-estree": 5.40.1 + "@typescript-eslint/utils": 5.40.1 debug: ^4.3.4 tsutils: ^3.21.0 peerDependencies: @@ -775,23 +782,23 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: eabe86de93b0bd4bcbfb13cace097ff7addbd992c91b80c73bbaa677ce26f1c2abd1c63fe585f2fd9c80df07d3d54bd6e4a46aebc908cef0f870f1d6955d6b8a + checksum: 6771196b8f16f4893bae70aa1371ff004b0058e8edef9b935143e2f1272e471049e9c34beb1d625fb6423db95dd377e01e938b70dd4506fbf071566e2bfb574d languageName: node linkType: hard -"@typescript-eslint/types@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/types@npm:5.40.0" - checksum: 892ff162176a3e292b5b55090421c6d318187255f3f91be46bd5c0b38e3c25a49d9320ffb646d5709f3a2cdf350217a79e557886fdfdbdb322caec27f2b3d116 +"@typescript-eslint/types@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/types@npm:5.40.1" + checksum: 2430c799667c820903df7ef39bc4c2762cb7654dbb8525d56f37e73f8cefb82186b80654dbbe0294c5b55affe929c641cdb90232e2749dcd7838f9e500a41549 languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/typescript-estree@npm:5.40.0" +"@typescript-eslint/typescript-estree@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/typescript-estree@npm:5.40.1" dependencies: - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/visitor-keys": 5.40.0 + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/visitor-keys": 5.40.1 debug: ^4.3.4 globby: ^11.1.0 is-glob: ^4.0.3 @@ -800,34 +807,35 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 8b67b8c4278f6bbd16ec521c847920c6f0ba57ec4bf148505c057aa160363852f50f9db73f42ee71ac3906940e8554e9c27686194a57f6554efcd82a8b0fa3e8 + checksum: d0426a55d24b76a3f042816dd8baaaa7a8da0158870bb08fff5a5524821c13ca196117dc269f098b8887ef75e01da1a498637153ab3c29c370ca356bfe4a1716 languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/utils@npm:5.40.0" +"@typescript-eslint/utils@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/utils@npm:5.40.1" dependencies: "@types/json-schema": ^7.0.9 - "@typescript-eslint/scope-manager": 5.40.0 - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/typescript-estree": 5.40.0 + "@types/semver": ^7.3.12 + "@typescript-eslint/scope-manager": 5.40.1 + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/typescript-estree": 5.40.1 eslint-scope: ^5.1.1 eslint-utils: ^3.0.0 semver: ^7.3.7 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: 608e16ad510c1543de37e168ab42e9d11fdd7d38faf19fe5d60255ea8e43b9a8cebeea11bd9776eed55fe0e453c5d222bb708b930b431c5b113269c6b44788c1 + checksum: a971101bb2f4c742a1734a87e17997addb7ffa6639d472097fe098f6c5f09567b858949b97f05892aabb20f38479abecdfdd69cf740046aa601dd3fc39a44090 languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/visitor-keys@npm:5.40.0" +"@typescript-eslint/visitor-keys@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/visitor-keys@npm:5.40.1" dependencies: - "@typescript-eslint/types": 5.40.0 + "@typescript-eslint/types": 5.40.1 eslint-visitor-keys: ^3.3.0 - checksum: a11787f7e6ac7018b22848028c9116d028f89782b0ee120517f0384e9db260e3001ad897512d9c3cf15ce16073ae4c1dc7f81f29d6d40dec78b5e8c8e79f344f + checksum: b5dbf1e484ba2832ca1883ee9cf7da5967f70aa5624f3fb67f13c3be90a3770b0bb96e64ccfb0c31b5d8f80794b5727e14b6c0d8c5184634a686f0ea6e798772 languageName: node linkType: hard @@ -1097,12 +1105,12 @@ __metadata: linkType: hard "bufferutil@npm:^4.0.1": - version: 4.0.6 - resolution: "bufferutil@npm:4.0.6" + version: 4.0.7 + resolution: "bufferutil@npm:4.0.7" dependencies: node-gyp: latest node-gyp-build: ^4.3.0 - checksum: dd107560947445280af7820c3d0534127b911577d85d537e1d7e0aa30fd634853cef8a994d6e8aed3d81388ab1a20257de776164afe6a6af8e78f5f17968ebd6 + checksum: f75aa87e3d1b99b87a95f60a855e63f70af07b57fb8443e75a2ddfef2e47788d130fdd46e3a78fd7e0c10176082b26dfbed970c5b8632e1cc299cafa0e93ce45 languageName: node linkType: hard @@ -2457,11 +2465,11 @@ __metadata: linkType: hard "is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": - version: 2.10.0 - resolution: "is-core-module@npm:2.10.0" + version: 2.11.0 + resolution: "is-core-module@npm:2.11.0" dependencies: has: ^1.0.3 - checksum: 0f3f77811f430af3256fa7bbc806f9639534b140f8ee69476f632c3e1eb4e28a38be0b9d1b8ecf596179c841b53576129279df95e7051d694dac4ceb6f967593 + checksum: f96fd490c6b48eb4f6d10ba815c6ef13f410b0ba6f7eb8577af51697de523e5f2cd9de1c441b51d27251bf0e4aebc936545e33a5d26d5d51f28d25698d4a8bab languageName: node linkType: hard @@ -3386,8 +3394,8 @@ __metadata: linkType: hard "pino@npm:^8.6.1": - version: 8.6.1 - resolution: "pino@npm:8.6.1" + version: 8.7.0 + resolution: "pino@npm:8.7.0" dependencies: atomic-sleep: ^1.0.0 fast-redact: ^3.1.1 @@ -3402,7 +3410,7 @@ __metadata: thread-stream: ^2.0.0 bin: pino: bin.js - checksum: 1201cf2b47c8860b8e5811c20ddf6db000158d98dd04da2f09d59e797c3d7c391819d6279a526699b3fd8c13c357e86e0bb32ded15d2815ca8d97a407de47c9f + checksum: 4aa2e320aa88f4a90fd25884ee4e3b9ef7963b3c59c514f3693b5a5c987b112cf3ab4e39a8c51efe32c861f5c058d7cfa7fcda59d964ed878f842fdbc6ab2876 languageName: node linkType: hard @@ -3665,9 +3673,9 @@ __metadata: linkType: hard "safe-stable-stringify@npm:^2.3.1": - version: 2.4.0 - resolution: "safe-stable-stringify@npm:2.4.0" - checksum: 5c9e4b2b2423470becafe232244948e7ce9545baaa65d67965e8c36536c93d2f7b4c1ddeb4bba8a912d0325e02c7691f24dd4de6935a9c1221402c17582ae1c1 + version: 2.4.1 + resolution: "safe-stable-stringify@npm:2.4.1" + checksum: d8e505c462031301040605a4836ca25b52a1744eff01b0939b4d43136638fb8e88e0cec3d3ab6ab8e26f501086e6ba6bf34b228f57bf2ac56cb8d4061355d723 languageName: node linkType: hard @@ -4185,12 +4193,12 @@ __metadata: linkType: hard "utf-8-validate@npm:^5.0.2": - version: 5.0.9 - resolution: "utf-8-validate@npm:5.0.9" + version: 5.0.10 + resolution: "utf-8-validate@npm:5.0.10" dependencies: node-gyp: latest node-gyp-build: ^4.3.0 - checksum: 90117f1b65e0a1256c83dfad529983617263b622f2379745311d0438c7ea31db0d134ebd0dca84c3f5847a3560a3d249644e478a9109c616f63c7ea19cac53dc + checksum: 5579350a023c66a2326752b6c8804cc7b39dcd251bb088241da38db994b8d78352e388dcc24ad398ab98385ba3c5ffcadb6b5b14b2637e43f767869055e46ba6 languageName: node linkType: hard From 8947b9e19a6a908ae3fe1844def8ab2c1dccbb79 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 25 Oct 2022 00:05:43 +0200 Subject: [PATCH 2/8] fmt --- executor/src/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/src/task.rs b/executor/src/task.rs index c82d8890..d6f76876 100644 --- a/executor/src/task.rs +++ b/executor/src/task.rs @@ -136,7 +136,7 @@ impl Task { } Err(err) => { ret = Err(err.to_string()); - storage_top_trie_changes = StorageDiff::empty(); + storage_top_trie_changes = StorageDiff::empty(); break; } } From 3a98a82455e33714c32f1188deeb5a3c4315f908 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Tue, 25 Oct 2022 11:49:37 +1300 Subject: [PATCH 3/8] install wasmpack locally --- package.json | 3 ++- yarn.lock | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 23100e00..196384a9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "prettier": "^2.7.1", "ts-node": "^10.9.1", "typescript": "^4.8.4", - "vitest": "^0.24.3" + "vitest": "^0.24.3", + "wasm-pack": "^0.10.3" }, "prettier": { "tabWidth": 2, diff --git a/yarn.lock b/yarn.lock index 631c5242..58f95aab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1089,6 +1089,15 @@ __metadata: languageName: node linkType: hard +"axios@npm:^0.21.1": + version: 0.21.4 + resolution: "axios@npm:0.21.4" + dependencies: + follow-redirects: ^1.14.0 + checksum: 44245f24ac971e7458f3120c92f9d66d1fc695e8b97019139de5b0cc65d9b8104647db01e5f46917728edfc0cfd88eb30fc4c55e6053eef4ace76768ce95ff3c + languageName: node + linkType: hard + "balanced-match@npm:^1.0.0": version: 1.0.2 resolution: "balanced-match@npm:1.0.2" @@ -1103,6 +1112,17 @@ __metadata: languageName: node linkType: hard +"binary-install@npm:^0.1.0": + version: 0.1.1 + resolution: "binary-install@npm:0.1.1" + dependencies: + axios: ^0.21.1 + rimraf: ^3.0.2 + tar: ^6.1.0 + checksum: a3df9c07a3ab81533cff610527263181c4c34a44efb115555be910b6011ac047bf875ad57469cc2259dfaba58e971c7ba2958038e9d222c546eef7b58b826ecc + languageName: node + linkType: hard + "bn.js@npm:^5.2.1": version: 5.2.1 resolution: "bn.js@npm:5.2.1" @@ -1260,6 +1280,7 @@ __metadata: ts-node: ^10.9.1 typescript: ^4.8.4 vitest: ^0.24.3 + wasm-pack: ^0.10.3 ws: ^8.9.0 yargs: ^17.6.0 languageName: unknown @@ -2317,6 +2338,16 @@ __metadata: languageName: node linkType: hard +"follow-redirects@npm:^1.14.0": + version: 1.15.2 + resolution: "follow-redirects@npm:1.15.2" + peerDependenciesMeta: + debug: + optional: true + checksum: faa66059b66358ba65c234c2f2a37fcec029dc22775f35d9ad6abac56003268baf41e55f9ee645957b32c7d9f62baf1f0b906e68267276f54ec4b4c597c2b190 + languageName: node + linkType: hard + "form-data@npm:^3.0.0": version: 3.0.1 resolution: "form-data@npm:3.0.1" @@ -4360,7 +4391,7 @@ __metadata: languageName: node linkType: hard -"tar@npm:^6.1.11, tar@npm:^6.1.2": +"tar@npm:^6.1.0, tar@npm:^6.1.11, tar@npm:^6.1.2": version: 6.1.11 resolution: "tar@npm:6.1.11" dependencies: @@ -4724,6 +4755,17 @@ __metadata: languageName: node linkType: hard +"wasm-pack@npm:^0.10.3": + version: 0.10.3 + resolution: "wasm-pack@npm:0.10.3" + dependencies: + binary-install: ^0.1.0 + bin: + wasm-pack: run.js + checksum: b980b33fc8adcd208556a1f5c4656b02d1ae584792259874f09ab5647dd52d0cdd3179d970ba99eed72ac1a422445c3c81122a3e9d7c05ebb2a3ff83bd7ec7db + languageName: node + linkType: hard + "web-streams-polyfill@npm:^3.0.3": version: 3.2.1 resolution: "web-streams-polyfill@npm:3.2.1" From 45afec1e1a0ad797a8826f17023f44f08da9c039 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 25 Oct 2022 09:42:36 +0200 Subject: [PATCH 4/8] fix --- .eslintrc.js | 1 + e2e/helper.ts | 5 +---- executor/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index af31a3d9..3f804620 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,6 +14,7 @@ module.exports = { '@typescript-eslint/explicit-module-boundary-types': 'off', 'sort-imports-es6-autofix/sort-imports-es6': 'error', '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-unused-vars': [ 'warn', { diff --git a/e2e/helper.ts b/e2e/helper.ts index 294d028b..4a668546 100644 --- a/e2e/helper.ts +++ b/e2e/helper.ts @@ -8,9 +8,6 @@ import { handler } from '../src/rpc' const setupAll = async () => { const endpoint = 'wss://mandala-rpc.aca-staging.network/ws' - const executorCmd = process.env.CI - ? './executor/target/debug/executor' - : 'cargo run --manifest-path executor/Cargo.toml --' const blockHash = '0x68cff8682eda3e5e63b375253bdb3a01f0dce1879fe7ade97c9697406c56b55a' const wsProvider = new WsProvider(endpoint) @@ -22,7 +19,7 @@ const setupAll = async () => { return { async setup() { - const tasks = new TaskManager(executorCmd, 8000) + const tasks = new TaskManager(8000) const chain = new Blockchain(api, tasks, { hash: blockHash, number: header.number.toNumber() }) diff --git a/executor/src/lib.rs b/executor/src/lib.rs index 4c3239ed..50e766c6 100644 --- a/executor/src/lib.rs +++ b/executor/src/lib.rs @@ -12,7 +12,7 @@ use crate::runner_api::RpcApiClient; #[wasm_bindgen] pub async fn start(task_id: u32, ws_url: &str) -> Result<(), JsValue> { std::panic::set_hook(Box::new(console_error_panic_hook::hook)); - console_log::init_with_level(log::Level::Debug).expect("error initializing logger"); + _ = console_log::init_with_level(log::Level::Debug); let client = runner_api::client(ws_url) .await From ba12ec366cfcd03db95bfaacff52e48b7f49b2b4 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 25 Oct 2022 10:58:40 +0200 Subject: [PATCH 5/8] run executor as bin or wasm --- e2e/helper.ts | 5 +- executor/Cargo.lock | 622 +++++++++++++++++++++++++++++++++++++ executor/Cargo.toml | 10 + executor/src/main.rs | 35 +++ executor/src/runner_api.rs | 15 +- package.json | 3 +- src/index.ts | 10 +- src/task.ts | 20 +- 8 files changed, 713 insertions(+), 7 deletions(-) create mode 100644 executor/src/main.rs diff --git a/e2e/helper.ts b/e2e/helper.ts index f7a8a37c..21c97405 100644 --- a/e2e/helper.ts +++ b/e2e/helper.ts @@ -9,6 +9,9 @@ import { handler } from '../src/rpc' const setupAll = async () => { const endpoint = 'wss://mandala-rpc.aca-staging.network/ws' + const executorCmd = process.env.CI + ? './executor/target/debug/executor' + : 'cargo run --manifest-path executor/Cargo.toml --' const blockHash = '0x68cff8682eda3e5e63b375253bdb3a01f0dce1879fe7ade97c9697406c56b55a' const wsProvider = new WsProvider(endpoint) @@ -20,7 +23,7 @@ const setupAll = async () => { return { async setup() { - const tasks = new TaskManager(8000) + const tasks = new TaskManager(process.env.WASM_EXECUTOR === 'true' ? '' : executorCmd, 8000) const chain = new Blockchain(api, tasks, { hash: blockHash, number: header.number.toNumber() }) diff --git a/executor/Cargo.lock b/executor/Cargo.lock index 1b7acd22..c70be4bf 100644 --- a/executor/Cargo.lock +++ b/executor/Cargo.lock @@ -93,6 +93,17 @@ dependencies = [ "autocfg", ] +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -130,6 +141,12 @@ version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ce18265ec2324ad075345d5814fbeed4f41f0a660055dc78840b74d19b874b1" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "blake2" version = "0.10.4" @@ -191,6 +208,18 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + [[package]] name = "cfg-if" version = "1.0.0" @@ -231,6 +260,43 @@ dependencies = [ "generic-array", ] +[[package]] +name = "clap" +version = "4.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -263,6 +329,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpufeatures" version = "0.2.5" @@ -434,6 +516,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" name = "executor" version = "0.1.0" dependencies = [ + "clap", "console_error_panic_hook", "console_log", "futures", @@ -445,6 +528,7 @@ dependencies = [ "serde", "serde_json", "smoldot", + "tokio", "wasm-bindgen", "wasm-bindgen-futures", ] @@ -652,6 +736,21 @@ dependencies = [ "serde", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -694,6 +793,23 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -739,6 +855,7 @@ dependencies = [ "jsonrpsee-proc-macros", "jsonrpsee-types", "jsonrpsee-wasm-client", + "jsonrpsee-ws-client", "tracing", ] @@ -753,9 +870,18 @@ dependencies = [ "futures-timer", "futures-util", "gloo-net", + "http", "jsonrpsee-core", + "jsonrpsee-types", + "pin-project", + "rustls-native-certs", + "soketto", "thiserror", + "tokio", + "tokio-rustls", + "tokio-util", "tracing", + "webpki-roots", ] [[package]] @@ -776,6 +902,7 @@ dependencies = [ "serde", "serde_json", "thiserror", + "tokio", "tracing", "tracing-futures", "wasm-bindgen-futures", @@ -818,12 +945,30 @@ dependencies = [ "jsonrpsee-types", ] +[[package]] +name = "jsonrpsee-ws-client" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee5feddd5188e62ac08fcf0e56478138e581509d4730f3f7be9b57dd402a4ff" +dependencies = [ + "http", + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", +] + [[package]] name = "keccak" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.135" @@ -884,6 +1029,16 @@ dependencies = [ "libsecp256k1-core", ] +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -923,6 +1078,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.42.0", +] + [[package]] name = "no-std-net" version = "0.6.0" @@ -998,6 +1165,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "once_cell" version = "1.15.0" @@ -1010,6 +1187,18 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "os_str_bytes" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" + [[package]] name = "parity-scale-codec" version = "3.2.1" @@ -1040,6 +1229,29 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.42.0", +] + [[package]] name = "pbkdf2" version = "0.11.0" @@ -1121,6 +1333,30 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.47" @@ -1184,6 +1420,30 @@ dependencies = [ "getrandom 0.2.7", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1199,6 +1459,39 @@ dependencies = [ "semver", ] +[[package]] +name = "rustls" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +dependencies = [ + "base64", +] + [[package]] name = "ruzstd" version = "0.3.0" @@ -1216,6 +1509,16 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys 0.36.1", +] + [[package]] name = "schnorrkel" version = "0.10.2" @@ -1232,6 +1535,45 @@ dependencies = [ "zeroize", ] +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.14" @@ -1275,6 +1617,19 @@ dependencies = [ "serde", ] +[[package]] +name = "sha-1" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.9.9" @@ -1299,6 +1654,15 @@ dependencies = [ "digest 0.10.5", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + [[package]] name = "siphasher" version = "0.3.10" @@ -1382,12 +1746,49 @@ dependencies = [ "subtle", ] +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "soketto" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" +dependencies = [ + "base64", + "bytes", + "futures", + "httparse", + "log", + "rand", + "sha-1", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "subtle" version = "2.4.1" @@ -1423,6 +1824,15 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.37" @@ -1452,6 +1862,62 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tokio" +version = "1.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-io", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.9" @@ -1541,6 +2007,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "version_check" version = "0.9.4" @@ -1661,6 +2133,156 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" +dependencies = [ + "webpki", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + [[package]] name = "zeroize" version = "1.5.7" diff --git a/executor/Cargo.toml b/executor/Cargo.toml index ae671ac0..70b51242 100644 --- a/executor/Cargo.toml +++ b/executor/Cargo.toml @@ -22,5 +22,15 @@ log = { version = "0.4.17", features = ["std"] } console_error_panic_hook = "0.1.7" console_log = "0.2.0" +clap = { version = "4.0.15", features = ["derive"], optional = true } +tokio = { version = "1.21.2", features = ["full"], optional = true } + smoldot = { path = '../vendor/smoldot', default-features = false } +[features] +default = ["std"] +std = [ + "clap", + "tokio", + "jsonrpsee/ws-client" +] \ No newline at end of file diff --git a/executor/src/main.rs b/executor/src/main.rs new file mode 100644 index 00000000..685856b2 --- /dev/null +++ b/executor/src/main.rs @@ -0,0 +1,35 @@ +use runner_api::RpcApiClient; + +mod runner_api; +mod task; + +#[derive(Debug, Clone, clap::Parser)] +pub struct Command { + #[clap(long, default_value = "ws://localhost:8000")] + runner_url: String, + + #[clap(long, default_value = "0")] + task_id: u32, +} + +#[tokio::main] +async fn main() -> Result<(), jsonrpsee::core::Error> { + real_main().await +} + +async fn real_main() -> Result<(), jsonrpsee::core::Error> { + let config = ::parse(); + let task_id = config.task_id; + + println!("Starting {}", task_id); + + let client = runner_api::client(&config.runner_url).await?; + + let task = client.get_task(task_id).await?; + + task.run(task_id, &client).await?; + + println!("Done"); + + Ok(()) +} diff --git a/executor/src/runner_api.rs b/executor/src/runner_api.rs index 413b3ba7..353f54a6 100644 --- a/executor/src/runner_api.rs +++ b/executor/src/runner_api.rs @@ -4,8 +4,14 @@ use crate::task::{Task, TaskResponse}; use jsonrpsee::{ core::{client::Client, Error as RpcError}, proc_macros::rpc, - wasm_client::WasmClientBuilder, }; + +#[cfg(target_arch = "wasm32")] +use jsonrpsee::wasm_client::WasmClientBuilder; + +#[cfg(feature = "std")] +use jsonrpsee::ws_client::WsClientBuilder; + use smoldot::json_rpc::methods::HexString; #[rpc(client)] @@ -42,7 +48,12 @@ pub trait RpcApi { } pub async fn client(url: &str) -> Result { - let client = WasmClientBuilder::default() + #[cfg(target_arch = "wasm32")] + let builder = WasmClientBuilder::default(); + #[cfg(feature = "std")] + let builder = WsClientBuilder::default(); + + let client = builder .request_timeout(Duration::from_secs(120)) .build(url) .await?; diff --git a/package.json b/package.json index ab4ccb43..db50013b 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,11 @@ "lint": "tsc --noEmit --project tsconfig.json && eslint . --ext .js,.ts && prettier --check .", "fix": "eslint . --ext .js,.ts --fix && prettier -w .", "prepare": "husky install", - "build-wasm": "cd executor && wasm-pack --log-level=info build --target nodejs", + "build-wasm": "cd executor && wasm-pack --log-level=info build --target nodejs --no-default-features", "start": "ts-node src/index.ts", "build": "cd executor && cargo build --locked", "test": "vitest", + "test:wasm": "WASM_EXECUTOR=true vitest", "dev": "LOG_LEVEL=trace node-dev --notify=false src/index.ts -- dev --endpoint=wss://karura-rococo-rpc.aca-staging.network/ws | pino-pretty" }, "dependencies": { diff --git a/src/index.ts b/src/index.ts index b88d57bc..393390f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,7 @@ const setup = async (argv: any) => { defaultLogger.info({ endpoint: argv.endpoint, blockHash }, 'Args') const header = await api.rpc.chain.getHeader(blockHash) - const tasks = new TaskManager(port) + const tasks = new TaskManager(argv['executor-cmd'], port) const chain = new Blockchain(api, tasks, { hash: blockHash, number: header.number.toNumber() }) const context = { chain, api, ws: wsProvider, tasks } @@ -83,6 +83,10 @@ yargs(hideBin(process.argv)) desc: 'Block hash or block number. Default to latest block', string: true, }, + 'executor-cmd': { + desc: 'Command to execute the executor', + string: true, + }, }), (argv) => { runBlock(argv).catch((err) => { @@ -109,6 +113,10 @@ yargs(hideBin(process.argv)) desc: 'Block hash or block number. Default to latest block', string: true, }, + 'executor-cmd': { + desc: 'Command to execute the executor', + string: true, + }, }), (argv) => { setup(argv).catch((err) => { diff --git a/src/task.ts b/src/task.ts index be6fca46..c6aca49f 100644 --- a/src/task.ts +++ b/src/task.ts @@ -1,3 +1,4 @@ +import { spawn } from 'child_process' import { WebSocket } from 'ws' // @ts-ignore global.WebSocket = WebSocket; @@ -33,9 +34,11 @@ interface Task { export class TaskManager { #tasks: { task: Task; callback: (res: TaskResponse) => any }[] = [] + #executorCmd: string #listeningPort: number - constructor(listeningPort: number) { + constructor(executorCmd: string, listeningPort: number) { + this.#executorCmd = executorCmd this.#listeningPort = listeningPort } @@ -60,7 +63,20 @@ export class TaskManager { } runTask(taskId: number): Promise { - return start(taskId, `ws://localhost:${this.#listeningPort}`) + if (this.#executorCmd && this.#executorCmd.length > 0) { + const cmd = `${this.#executorCmd} --runner-url=ws://localhost:${this.#listeningPort} --task-id=${taskId}` + logger.info({ taskId, cmd }, 'RunTask') + const p = spawn(cmd, { shell: true, stdio: 'inherit' }) + + return new Promise((resolve) => { + p.once('exit', (code) => { + logger.debug({ taskId, code }, 'RunTask done') + resolve() + }) + }) + } else { + return start(taskId, `ws://localhost:${this.#listeningPort}`) + } } async addAndRunTask(task: Task, callback: (res: TaskResponse) => any = () => {}) { From aeb1076c0080106694cca82fbdac9696a5ce9500 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 25 Oct 2022 11:04:19 +0200 Subject: [PATCH 6/8] fix lint --- .github/workflows/ci.yml | 1 + src/task.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf54d3fd..585f2a76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,7 @@ jobs: node-version: 18.x cache: 'yarn' - run: yarn --immutable + - run: yarn build-wasm - run: yarn lint - run: yarn build - run: yarn test diff --git a/src/task.ts b/src/task.ts index c6aca49f..f6e38b29 100644 --- a/src/task.ts +++ b/src/task.ts @@ -1,11 +1,12 @@ import { spawn } from 'child_process' -import { WebSocket } from 'ws' -// @ts-ignore -global.WebSocket = WebSocket; import { defaultLogger } from './logger' import { start } from '../executor/pkg' +import { WebSocket } from 'ws' +// @ts-ignore +global.WebSocket = WebSocket; + const logger = defaultLogger.child({ name: 'task' }) export interface TaskResponseCall { From 44012d1839ffe109c25f83da497442c4c9908809 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 25 Oct 2022 11:13:34 +0200 Subject: [PATCH 7/8] prettier --- src/index.ts | 15 +++++++++------ src/task.ts | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 393390f1..4c5ba8d5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,12 +54,15 @@ const runBlock = async (argv: any) => { calls.push(['BlockBuilder_finalize_block', '0x']) - await context.tasks.addAndRunTask({ - kind: 'Call', - blockHash: parent, - wasm, - calls, - }, console.log) + await context.tasks.addAndRunTask( + { + kind: 'Call', + blockHash: parent, + wasm, + calls, + }, + console.log + ) setTimeout(() => process.exit(0), 50) } diff --git a/src/task.ts b/src/task.ts index f6e38b29..59b4fe54 100644 --- a/src/task.ts +++ b/src/task.ts @@ -5,7 +5,7 @@ import { start } from '../executor/pkg' import { WebSocket } from 'ws' // @ts-ignore -global.WebSocket = WebSocket; +global.WebSocket = WebSocket const logger = defaultLogger.child({ name: 'task' }) From ef23aa18760649d7fc52ee76ef495feef2147805 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 25 Oct 2022 11:49:57 +0200 Subject: [PATCH 8/8] close sockets before wss.close --- src/server.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server.ts b/src/server.ts index 55ede77e..f4a3e27c 100644 --- a/src/server.ts +++ b/src/server.ts @@ -129,6 +129,7 @@ export const createServer = (port: number, handler: Handler) => { port: promise, close: () => new Promise((resolve, reject) => { + wss.clients.forEach((socket) => socket.close()) wss.close((err) => { if (err) { reject(err)