diff --git a/.vscode/settings.json.sample b/.vscode/settings.json.sample index fd07c1e34..720d10b49 100644 --- a/.vscode/settings.json.sample +++ b/.vscode/settings.json.sample @@ -22,8 +22,9 @@ "editor.formatOnSave": true, "editor.formatOnSaveMode": "file", }, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true, }, "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"] } diff --git a/CMakeLists.txt b/CMakeLists.txt index b64680e14..fa6048859 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.16.3) cmake_policy(VERSION 3.16.3...3.25.1) project(psibase) +enable_testing() include(ExternalProject) if(CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) @@ -200,6 +201,22 @@ add_custom_command( add_custom_target(psibase.1 ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc/psidk/psibase.1) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/doc/psidk/psibase.1 TYPE MAN COMPONENT Client) +# Cargo psibase +ExternalProject_Add( + cargo-psibase + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rust + CONFIGURE_COMMAND "" + BUILD_COMMAND cargo build -r --bin cargo-psibase --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/rust/Cargo.toml --target-dir ${CMAKE_CURRENT_BINARY_DIR}/rust + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/rust/release/cargo-psibase + BUILD_ALWAYS 1 + INSTALL_COMMAND "" +) +add_test( + NAME CargoTestCargoPsibase + COMMAND cargo test --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/rust/cargo-psibase/Cargo.toml + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rust/cargo-psibase/ +) + # Run yarn to build service UIs set(JS_DIRS services/system/AccountSys/ui:AccountSys_js diff --git a/README.md b/README.md index aeb714f77..dccca93a6 100644 --- a/README.md +++ b/README.md @@ -48,27 +48,27 @@ Some of our developers have very strong success with Ubuntu on WSL2, and also wi The following is a list of dependencies you are required to install: -| Package | Minimum Version | Description | -| -------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| autoconf | 2.69 | A tool for producing configure scripts for building, installing, and packaging software | -| binaryen | 113 | A compiler and toolchain infrastructure library for WebAssembly | -| boost | 1.78 | A collection of C++ libraries | -| clang + llvm | 16 | The LLVM compiler and toolchain for C/C++ and the libraries to interface with it | -| cmake | 3.16.3 | A build system generator that creates makefiles used for compilation | -| g++ | 11 | A GNU compiler for C++ | -| libssl-dev | 1.1.1 | Development package for OpenSSL, enabling various cryptography and secure network communication | -| libtool | 2.4.6 | Script that simplifies the process of creating and using shared libraries | -| make | 4.3 | Reads makefiles generated by cmake to build executables from source code | -| node | 16.17.0 | A JavaScript runtime | -| pkg-config | 0.29.1 | A helper tool used during compilation to provide correct compiler flags, and to locate and manage library dependencies | -| Rust toolchain | 1.63 | Develop programs in Rust. Use `cargo` to install `mdbook`, `mdbook-linkcheck`, `mdbook-mermaid`, `mdbook-pagetoc`, and `sccache` | -| Wasi SDK | 20.0 | A development toolchain for building WebAssembly programs that target the WebAssembly System Interface (WASI) | -| zstd | 1.4.4 | Command-line utility that implements the Zstandard file compression algorithm | +| Package | Minimum Version | Description | +| -------------------------- | --------------- | -----------------------------------------------------------------------------------------------------------------------------------------------------------------| +| autoconf | 2.69 | A tool for producing configure scripts for building, installing, and packaging software | +| binaryen | 113 | A compiler and toolchain infrastructure library for WebAssembly | +| boost | 1.78 | A collection of C++ libraries | +| clang + llvm | 16 | The LLVM compiler and toolchain for C/C++ and the libraries to interface with it | +| cmake | 3.16.3 | A build system generator that creates makefiles used for compilation | +| g++ | 11 | A GNU compiler for C++ | +| libssl-dev | 1.1.1 | Development package for OpenSSL, enabling various cryptography and secure network communication | +| libtool | 2.4.6 | Script that simplifies the process of creating and using shared libraries | +| make | 4.3 | Reads makefiles generated by cmake to build executables from source code | +| node | 16.17.0 | A JavaScript runtime | +| pkg-config | 0.29.1 | A helper tool used during compilation to provide correct compiler flags, and to locate and manage library dependencies | +| Rust toolchain | 1.73 | Develop programs in Rust. Use `cargo` to install `cargo-component`, `mdbook`, `mdbook-linkcheck`, `mdbook-mermaid`, `mdbook-pagetoc`, `sccache`, and `wasm-pack` | +| Wasi SDK | 20.0 | A development toolchain for building WebAssembly programs that target the WebAssembly System Interface (WASI) | +| zstd | 1.4.4 | Command-line utility that implements the Zstandard file compression algorithm | Other notes: * Add the paths to `node`, `npm`, `yarn`, `cargo`, and `wasm-opt` into your PATH environment variable. * Set the `WASI_SDK_PREFIX` environment variable before building to the root of your llvm installation (e.g. `/usr/lib/llvm-16`). Alternatively, set this variable during the build using the CMake flag `-DWASI_SDK_PREFIX=....`. -* Add the wasm32-wasi target to rust. +* Add the following targets to rust: `wasm32-wasi`, `wasm32-unknown-unknown` > 🔍 You can reference either the [Ubuntu 20.04 dockerfile](https://github.com/gofractally/image-builders/blob/main/docker/ubuntu-2004-builder.Dockerfile) or the [Ubuntu 22.04 dockerfile](https://github.com/gofractally/image-builders/blob/main/docker/ubuntu-2204-builder.Dockerfile) for an example on how an environment could be set up. diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 39a74b8b2..fda66da25 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -28,7 +28,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli", + "gimli 0.28.1", ] [[package]] @@ -39,9 +39,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ "anstyle", "anstyle-parse", @@ -90,43 +90,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.2" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "approx" @@ -240,7 +240,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -251,7 +251,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -300,9 +300,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64ct" @@ -310,27 +310,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "binaryen" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "783bea139d75b6a565b13fab54d12ec4d58724a9458598ad7283d578f4f8777a" -dependencies = [ - "binaryen-sys", -] - -[[package]] -name = "binaryen-sys" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e9636d01b92f2df45dce29c35a9e3724687c1055bb4472fb4b829cc4a5a561" -dependencies = [ - "cc", - "cmake", - "heck 0.3.3", - "regex", -] - [[package]] name = "bitcoin-private" version = "0.1.0" @@ -354,9 +333,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -369,9 +348,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", "regex-automata", @@ -380,9 +359,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "burst-transfer" @@ -403,21 +382,21 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" dependencies = [ "serde", ] @@ -433,9 +412,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -445,23 +424,27 @@ name = "cargo-psibase" version = "0.7.0" dependencies = [ "anyhow", - "binaryen", "cargo_metadata", - "clap 3.2.25", + "clap 4.5.1", "console", - "parity-wasm", "psibase", "regex", "serde_json", + "tempfile", "tokio", "url", + "walrus", + "wasm-opt", + "wasmparser 0.201.0", + "wasmprinter", + "wat", ] [[package]] name = "cargo_metadata" -version = "0.15.4" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -473,9 +456,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" dependencies = [ "libc", ] @@ -494,17 +477,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "time", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets 0.52.4", ] [[package]] @@ -519,9 +501,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" dependencies = [ "glob", "libc", @@ -535,44 +517,45 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags 1.3.2", - "clap_derive", + "clap_derive 3.2.25", "clap_lex 0.2.4", "indexmap 1.9.3", "once_cell", - "strsim", + "strsim 0.10.0", "termcolor", "textwrap", ] [[package]] name = "clap" -version = "4.4.2" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", + "clap_derive 4.5.0", ] [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstream", "anstyle", - "clap_lex 0.5.1", - "strsim", + "clap_lex 0.7.0", + "strsim 0.11.0", "terminal_size", ] [[package]] name = "clap_complete" -version = "4.4.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" +checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c" dependencies = [ - "clap 4.4.2", + "clap 4.5.1", ] [[package]] @@ -588,6 +571,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "clap_lex" version = "0.2.4" @@ -599,18 +594,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" - -[[package]] -name = "cmake" -version = "0.1.50" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "codespan-reporting" @@ -630,22 +616,22 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] name = "const-oid" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const_format" @@ -667,49 +653,74 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" dependencies = [ - "cfg-if 1.0.0", "crossbeam-utils", ] [[package]] -name = "crossbeam-utils" -version = "0.8.16" +name = "crossbeam-deque" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", ] +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + [[package]] name = "crypto-common" version = "0.1.6" @@ -751,9 +762,9 @@ checksum = "4f8a51dd197fa6ba5b4dc98a990a43cc13693c23eb0089ebb0fcc1f04152bca6" [[package]] name = "cxx" -version = "1.0.107" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe98ba1789d56fb3db3bee5e032774d4f421b685de7ba703643584ba24effbe" +checksum = "2673ca5ae28334544ec2a6b18ebe666c42a2650abfb48abbd532ed409a44be2b" dependencies = [ "cc", "cxxbridge-flags", @@ -763,9 +774,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.107" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ce20f6b8433da4841b1dadfb9468709868022d829d5ca1f2ffbda928455ea3" +checksum = "9df46fe0eb43066a332586114174c449a62c25689f85a08f28fdcc8e12c380b9" dependencies = [ "cc", "codespan-reporting", @@ -773,24 +784,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "cxxbridge-flags" -version = "1.0.107" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20888d9e1d2298e2ff473cee30efe7d5036e437857ab68bbfea84c74dba91da2" +checksum = "886acf875df67811c11cd015506b3392b9e1820b1627af1a6f4e93ccdfc74d11" [[package]] name = "cxxbridge-macro" -version = "1.0.107" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84" +checksum = "1d151cc139c3080e07f448f93a1284577ab2283d2a44acd902c6fba9ec20b6de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -813,7 +824,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -828,6 +839,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + [[package]] name = "der" version = "0.7.8" @@ -864,9 +881,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elasticlunr-rs" @@ -904,17 +921,27 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" dependencies = [ + "anstream", + "anstyle", + "env_filter", "humantime", - "is-terminal", "log", - "regex", - "termcolor", ] [[package]] @@ -925,25 +952,30 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +name = "example" +version = "0.7.0" dependencies = [ - "cc", - "libc", + "async-graphql", + "psibase", + "psibase_macros", + "serde", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fast_chemail" version = "0.9.6" @@ -955,20 +987,20 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "filetime" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -989,16 +1021,16 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "fracpack" -version = "0.7.0" +version = "0.6.0" dependencies = [ "custom_error", "psibase_macros", @@ -1025,9 +1057,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -1040,9 +1072,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -1050,15 +1082,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -1067,38 +1099,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -1120,7 +1152,7 @@ dependencies = [ "clang", "clap 3.2.25", "mdbook", - "pulldown-cmark", + "pulldown-cmark 0.9.6", "regex", "serde_json", "svgbob", @@ -1147,22 +1179,33 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if 1.0.0", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] [[package]] name = "gimli" -version = "0.28.0" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "indexmap 1.9.3", + "stable_deref_trait", +] + +[[package]] +name = "gimli" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glob" @@ -1172,22 +1215,22 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata", + "regex-syntax", ] [[package]] name = "h2" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -1195,7 +1238,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.2.3", "slab", "tokio", "tokio-util", @@ -1204,9 +1247,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.3.7" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" +checksum = "ab283476b99e66691dee3f1640fea91487a8d81f50fb5ecc75538f8f8879a1e4" dependencies = [ "log", "pest", @@ -1224,9 +1267,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "headers" @@ -1234,7 +1277,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.3", + "base64 0.21.7", "bytes", "headers-core", "http", @@ -1278,9 +1321,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -1313,20 +1356,20 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", - "itoa 1.0.9", + "itoa 1.0.10", ] [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1353,9 +1396,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -1366,9 +1409,9 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.9", + "itoa 1.0.10", "pin-project-lite", - "socket2 0.4.9", + "socket2", "tokio", "tower-service", "tracing", @@ -1377,9 +1420,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -1391,16 +1434,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1412,6 +1455,12 @@ dependencies = [ "cc", ] +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "ident_case" version = "1.0.1" @@ -1420,9 +1469,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1430,17 +1479,16 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata", "same-file", - "thread_local", "walkdir", "winapi-util", ] @@ -1477,19 +1525,19 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.3", ] [[package]] name = "indicatif" -version = "0.17.6" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b297dc40733f23a0e52728a58fa9489a5b7638a324932de16b41adc3ef80730" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" dependencies = [ "console", "instant", @@ -1527,33 +1575,11 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.2", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.10", - "windows-sys 0.48.0", -] +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itertools" @@ -1572,15 +1598,15 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -1652,9 +1678,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" @@ -1668,9 +1694,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "link-cplusplus" @@ -1683,21 +1709,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1705,9 +1725,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "mac" @@ -1737,9 +1757,9 @@ dependencies = [ [[package]] name = "matrixmultiply" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" dependencies = [ "autocfg", "rawpointer", @@ -1750,19 +1770,19 @@ name = "md2man" version = "0.7.0" dependencies = [ "clap 3.2.25", - "pulldown-cmark", + "pulldown-cmark 0.9.6", ] [[package]] name = "mdbook" -version = "0.4.34" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55eb7c4dad20cc5bc15181c2aaf43d5689d5c3e0b80b50cc4cf0b7fe72a26d9" +checksum = "0c33564061c3c640bed5ace7d6a2a1b65f2c64257d1ac930c15e94ed0fb561d3" dependencies = [ "ammonia", "anyhow", "chrono", - "clap 4.4.2", + "clap 4.5.1", "clap_complete", "elasticlunr-rs", "env_logger", @@ -1775,7 +1795,8 @@ dependencies = [ "notify-debouncer-mini", "once_cell", "opener", - "pulldown-cmark", + "pathdiff", + "pulldown-cmark 0.10.0", "regex", "serde", "serde_json", @@ -1789,9 +1810,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.2" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mime" @@ -1811,22 +1832,22 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -1853,7 +1874,7 @@ dependencies = [ "log", "memchr", "mime", - "spin 0.9.8", + "spin", "version_check", ] @@ -1892,11 +1913,11 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "normpath" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec60c60a693226186f5d6edf073232bfb6464ed97eb22cf3b01c1e8198fd97f5" +checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1905,7 +1926,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.2", "crossbeam-channel", "filetime", "fsevent-sys", @@ -1920,19 +1941,20 @@ dependencies = [ [[package]] name = "notify-debouncer-mini" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55ee272914f4563a2f8b8553eb6811f3c0caea81c756346bad15b7e3ef969f0" +checksum = "5d40b221972a1fc5ef4d858a2f671fb34c75983eb385463dff3780eeff6a9d43" dependencies = [ "crossbeam-channel", + "log", "notify", ] [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] @@ -1950,11 +1972,10 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] @@ -1971,9 +1992,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -1985,7 +2006,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.9", "libc", ] @@ -1997,18 +2018,18 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.32.0" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opener" @@ -2032,15 +2053,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" - -[[package]] -name = "parity-wasm" -version = "0.45.0" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "parking_lot" @@ -2054,9 +2069,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if 1.0.0", "libc", @@ -2111,6 +2126,12 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -2122,15 +2143,15 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.3" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", @@ -2139,9 +2160,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.3" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" +checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" dependencies = [ "pest", "pest_generator", @@ -2149,22 +2170,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.3" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" +checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "pest_meta" -version = "2.7.3" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" +checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" dependencies = [ "once_cell", "pest", @@ -2227,22 +2248,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -2278,9 +2299,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "ppv-lite86" @@ -2345,7 +2366,7 @@ dependencies = [ [[package]] name = "psibase" -version = "0.7.0" +version = "0.6.0" dependencies = [ "anyhow", "async-graphql", @@ -2393,7 +2414,7 @@ dependencies = [ [[package]] name = "psibase_macros" -version = "0.7.0" +version = "0.6.0" dependencies = [ "darling", "proc-macro-error", @@ -2405,7 +2426,7 @@ dependencies = [ [[package]] name = "psibase_names" -version = "0.7.0" +version = "0.6.0" dependencies = [ "seahash", ] @@ -2423,16 +2444,34 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.3" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "getopts", "memchr", "unicase", ] +[[package]] +name = "pulldown-cmark" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce76ce678ffc8e5675b22aa1405de0b7037e2fdf8913fea40d1926c6fe1e6e7" +dependencies = [ + "bitflags 2.4.2", + "memchr", + "pulldown-cmark-escape", + "unicase", +] + +[[package]] +name = "pulldown-cmark-escape" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d8f9aa0e3cbcfaf8bf00300004ee3b72f74770f9cbac93f6928771f613276b" + [[package]] name = "quote" version = "1.0.35" @@ -2480,18 +2519,18 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.9.4" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -2501,9 +2540,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -2512,17 +2551,17 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ - "base64 0.21.3", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -2544,6 +2583,8 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", + "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -2557,17 +2598,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.20" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if 1.0.0", + "getrandom", "libc", - "once_cell", - "spin 0.5.2", + "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -2581,23 +2622,23 @@ dependencies = [ [[package]] name = "rpassword" -version = "7.2.0" +version = "7.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +checksum = "80472be3c897911d0137b2d2b9055faf6eeac5b14e324073d83bc17b191d7e3f" dependencies = [ "libc", "rtoolbox", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "rtoolbox" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +checksum = "c247d24e63230cdb56463ae328478bd5eac8b8faa8c69461a77e8e323afac90e" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -2614,36 +2655,22 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.10" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6248e1caa625eb708e266e06159f135e8c26f2bb7ceb72dc4b2766d0340964" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.2", "errno", "libc", - "linux-raw-sys 0.4.5", - "windows-sys 0.48.0", + "linux-raw-sys", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", @@ -2653,28 +2680,34 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.3", + "base64 0.21.7", ] [[package]] name = "rustls-webpki" -version = "0.101.4" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ "ring", "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safe_arch" @@ -2752,9 +2785,9 @@ checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -2808,27 +2841,27 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.188" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde-aux" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a86348501c129f3ad50c2f4635a01971f76974cd8a3f335988a0f1581c082765" +checksum = "0d2e8bfba469d06512e11e3311d4d051a4a387a5b42d010404fecf3200321c95" dependencies = [ "chrono", "serde", @@ -2837,9 +2870,9 @@ dependencies = [ [[package]] name = "serde-wasm-bindgen" -version = "0.6.0" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c9933e5689bd420dc6c87b7a1835701810cbc10cd86a26e4da45b73e6b1d78" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" dependencies = [ "js-sys", "serde", @@ -2848,31 +2881,31 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.12" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ - "itoa 1.0.9", + "itoa 1.0.10", "ryu", "serde", ] @@ -2884,16 +2917,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.9", + "itoa 1.0.10", "ryu", "serde", ] [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -2902,9 +2935,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -2913,9 +2946,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" @@ -2956,36 +2989,20 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - -[[package]] -name = "socket2" -version = "0.4.9" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -2994,14 +3011,20 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", ] +[[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" @@ -3040,6 +3063,31 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + [[package]] name = "subprocess" version = "0.2.9" @@ -3085,15 +3133,21 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "synstructure" version = "0.12.6" @@ -3106,17 +3160,37 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" -version = "3.8.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if 1.0.0", "fastrand", - "redox_syscall", - "rustix 0.38.10", - "windows-sys 0.48.0", + "rustix", + "windows-sys 0.52.0", ] [[package]] @@ -3132,20 +3206,20 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.37.23", + "rustix", "windows-sys 0.48.0", ] @@ -3171,49 +3245,28 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if 1.0.0", - "once_cell", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", + "syn 2.0.52", ] [[package]] @@ -3233,9 +3286,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -3245,20 +3298,20 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -3284,9 +3337,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.18.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", @@ -3296,9 +3349,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -3319,17 +3372,17 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.2.3", "toml_datetime", "winnow", ] @@ -3348,11 +3401,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if 1.0.0", "log", "pin-project-lite", "tracing-core", @@ -3360,28 +3412,28 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.18.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ - "base64 0.13.1", "byteorder", "bytes", + "data-encoding", "http", "httparse", "log", @@ -3394,9 +3446,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" @@ -3415,36 +3467,36 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -3454,15 +3506,15 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -3576,14 +3628,42 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", ] +[[package]] +name = "walrus" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c03529cd0c4400a2449f640d2f27cd1b48c3065226d15e26d98e4429ab0adb7" +dependencies = [ + "anyhow", + "gimli 0.26.2", + "id-arena", + "leb128", + "log", + "walrus-macro", + "wasm-encoder 0.29.0", + "wasmparser 0.80.2", +] + +[[package]] +name = "walrus-macro" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e5bd22c71e77d60140b0bd5be56155a37e5bd14e24f5f87298040d0cc40d7" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "want" version = "0.3.1" @@ -3595,9 +3675,9 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69" +checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" dependencies = [ "bytes", "futures-channel", @@ -3623,12 +3703,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3637,9 +3711,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -3647,24 +3721,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3674,9 +3748,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3684,28 +3758,135 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" + +[[package]] +name = "wasm-encoder" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18c41dbd92eaebf3612a39be316540b8377c871cb9bde6b064af962984912881" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-opt" +version = "0.116.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "fc942673e7684671f0c5708fc18993569d184265fd5223bb51fc8e5b9b6cfd52" +dependencies = [ + "anyhow", + "libc", + "strum", + "strum_macros", + "tempfile", + "thiserror", + "wasm-opt-cxx-sys", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-cxx-sys" +version = "0.116.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c57b28207aa724318fcec6575fe74803c23f6f266fce10cbc9f3f116762f12e" +dependencies = [ + "anyhow", + "cxx", + "cxx-build", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-sys" +version = "0.116.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a1cce564dc768dacbdb718fc29df2dba80bd21cb47d8f77ae7e3d95ceb98cbe" +dependencies = [ + "anyhow", + "cc", + "cxx", + "cxx-build", +] + +[[package]] +name = "wasmparser" +version = "0.80.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449167e2832691a1bff24cde28d2804e90e09586a448c8e76984792c44334a6b" + +[[package]] +name = "wasmparser" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" +dependencies = [ + "bitflags 2.4.2", + "indexmap 2.2.3", + "semver", +] + +[[package]] +name = "wasmprinter" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a67e66da702706ba08729a78e3c0079085f6bfcb1a62e4799e97bbf728c2c265" +dependencies = [ + "anyhow", + "wasmparser 0.201.0", +] + +[[package]] +name = "wast" +version = "201.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ef6e1ef34d7da3e2b374fd2b1a9c0227aff6cad596e1b24df9b58d0f6222faa" +dependencies = [ + "bumpalo", + "leb128", + "memchr", + "unicode-width", + "wasm-encoder 0.201.0", +] + +[[package]] +name = "wat" +version = "1.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453d5b37a45b98dee4f4cb68015fc73634d7883bbef1c65e6e9c78d454cf3f32" +dependencies = [ + "wast", +] [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -3713,15 +3894,15 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "wide" -version = "0.7.11" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" +checksum = "89beec544f246e679fc25490e3f8e08003bc4bf612068f325120dad4cea02c1c" dependencies = [ "bytemuck", "safe_arch", @@ -3745,9 +3926,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -3759,21 +3940,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.52.4", ] [[package]] @@ -3786,18 +3958,12 @@ dependencies = [ ] [[package]] -name = "windows-targets" -version = "0.42.2" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.52.4", ] [[package]] @@ -3816,10 +3982,19 @@ dependencies = [ ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" +name = "windows-targets" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", +] [[package]] name = "windows_aarch64_gnullvm" @@ -3828,10 +4003,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" +name = "windows_aarch64_gnullvm" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -3840,10 +4015,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] -name = "windows_i686_gnu" -version = "0.42.2" +name = "windows_aarch64_msvc" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -3852,10 +4027,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] -name = "windows_i686_msvc" -version = "0.42.2" +name = "windows_i686_gnu" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -3864,10 +4039,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" +name = "windows_i686_msvc" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -3876,10 +4051,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" +name = "windows_x86_64_gnu" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -3888,10 +4063,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" +name = "windows_x86_64_gnullvm" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -3899,11 +4074,17 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -3920,9 +4101,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" [[package]] name = "zip" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 629900223..500530bbe 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -10,6 +10,7 @@ members = [ "psibase_macros", "psibase", "test_contract", + "test_contract_2", "test_service_elections", "test_service_psispace", "test_fracpack", diff --git a/rust/account_sys/Cargo.toml b/rust/account_sys/Cargo.toml index 5e17eac2d..5f1e4c542 100644 --- a/rust/account_sys/Cargo.toml +++ b/rust/account_sys/Cargo.toml @@ -11,7 +11,7 @@ publish = false crate-type = ["cdylib", "staticlib"] [dependencies] -fracpack = { path = "../fracpack" } -psibase = { path = "../psibase" } +fracpack = { version = "0.6.0", path = "../fracpack" } +psibase = { version = "0.6.0", path = "../psibase" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/rust/burst-transfer/Cargo.toml b/rust/burst-transfer/Cargo.toml index 3a1ea119c..76bead030 100644 --- a/rust/burst-transfer/Cargo.toml +++ b/rust/burst-transfer/Cargo.toml @@ -14,7 +14,7 @@ anyhow = "1.0" chrono = "0.4" clap = {version = "3.1", features = ["derive"]} futures = "0.3" -psibase = { path = "../psibase" } +psibase = { version = "0.6.0", path = "../psibase" } rand = "0.8.5" reqwest = { version = "0.11", default-features = false, features = ["json","rustls-tls"] } serde = { version = "1.0", features = ["derive"] } diff --git a/rust/cargo-psibase/Cargo.toml b/rust/cargo-psibase/Cargo.toml index 89c4308dc..709ae781f 100644 --- a/rust/cargo-psibase/Cargo.toml +++ b/rust/cargo-psibase/Cargo.toml @@ -10,16 +10,22 @@ license = "MIT" [dependencies] anyhow = "1.0" -binaryen = "0.12" -cargo_metadata = "0.15.0" -clap = {version = "3.1", features = ["derive"]} +wasm-opt = "0.116.0" +cargo_metadata = "0.18.1" +clap = { version = "4.4", features = ["derive"]} console = "0.15.2" -parity-wasm = "0.45" -psibase = { path = "../psibase" } +psibase = { version = "0.6.0", path = "../psibase" } regex = "1" serde_json = "1.0" tokio = { version = "1", features = ["full"] } url = "2.3" +walrus = "0.20.3" +wasmparser = { version = "0.201.0"} +tempfile = { version = "3.10" } + +[dev-dependencies] +wasmprinter = { version = "0.201.0"} +wat = { version = "1.201.0" } [build-dependencies] -binaryen = "0.12" +wasm-opt = "0.116.0" \ No newline at end of file diff --git a/rust/cargo-psibase/build.rs b/rust/cargo-psibase/build.rs index 9fe77a08e..063d831d1 100644 --- a/rust/cargo-psibase/build.rs +++ b/rust/cargo-psibase/build.rs @@ -1,9 +1,10 @@ -use binaryen::{CodegenConfig, Module}; +use std::path::PathBuf; use std::{ env, - fs::{create_dir_all, hard_link, read, remove_dir_all, write}, + fs::{create_dir_all, hard_link, remove_dir_all}, process::{exit, Command}, }; +use wasm_opt::OptimizationOptions; fn main() { let cargo = env::var("CARGO").unwrap(); @@ -33,12 +34,13 @@ fn main() { let target_dir = out_dir.clone() + "/" + name + "-target"; if !Command::new(&cargo) - .args(["build"]) + .args(["rustc"]) .args(["--color", "always"]) .args(["--target", "wasm32-wasi"]) .args(["--target-dir", &target_dir]) .args(["--manifest-path", &(package_dir + "/Cargo.toml")]) .args(["--release"]) + .args(["--", "-C", "target-feature=+simd128,+bulk-memory,+sign-ext"]) .status() .unwrap() .success() @@ -46,14 +48,17 @@ fn main() { exit(1); } - let code = read(target_dir + "/wasm32-wasi/release/" + name + ".wasm").unwrap(); - let mut module = Module::read(&code).unwrap(); - module.optimize(&CodegenConfig { - shrink_level: 1, - optimization_level: 2, - debug_info: false, - }); - write(out_dir.clone() + "/" + name + ".wasm", module.write()).unwrap(); + let infile = PathBuf::from(target_dir + "/wasm32-wasi/release/" + name + ".wasm"); + let outfile = PathBuf::from(out_dir.clone() + "/" + name + ".wasm"); + let debug_build = false; + OptimizationOptions::new_opt_level_2() + .shrink_level(wasm_opt::ShrinkLevel::Level1) + .enable_feature(wasm_opt::Feature::BulkMemory) + .enable_feature(wasm_opt::Feature::SignExt) + .enable_feature(wasm_opt::Feature::Simd) + .debug_info(debug_build) + .run(&infile, &outfile) + .unwrap(); }; build("service_wasi_polyfill"); diff --git a/rust/cargo-psibase/src/link.rs b/rust/cargo-psibase/src/link.rs index f1c71d9b7..680a008f2 100644 --- a/rust/cargo-psibase/src/link.rs +++ b/rust/cargo-psibase/src/link.rs @@ -1,463 +1,931 @@ -use anyhow::anyhow; -use parity_wasm::deserialize_buffer; -use parity_wasm::elements::{ - External, Func, FuncBody, ImportEntry, Instruction, Internal, Section, TableElementType, Type, -}; use std::collections::HashMap; -use std::path::Path; -#[derive(Clone, Hash, PartialEq, Eq, Debug)] -struct ImportFunction { - module: String, - field: String, - ty: Type, +use anyhow::anyhow; +use walrus::ir::{Instr, InstrSeqId}; +use walrus::FunctionKind::{Import, Local, Uninitialized}; +use walrus::{FunctionId, FunctionKind, InstrSeqBuilder, LocalFunction, LocalId, Module, ValType}; +use wasmparser::Validator; + +// Helper traits +trait TypeFromFid { + fn func_type(&self, id: FunctionId) -> &walrus::Type; +} + +impl TypeFromFid for walrus::Module { + fn func_type(&self, id: FunctionId) -> &walrus::Type { + &self.types.get(self.funcs.get(id).ty()) + } +} + +/// The polyfill module must not have the following sections, since they require +/// relocatable wasms to merge: +/// * Tables +/// * Start +/// * Elements +/// * Data +/// +/// The polyfill must include the following sections: +/// * Types +/// * Imports +/// * Functions +/// * Exports +/// +/// Any local functions in the polyfill must have >0 instructions +fn validate_polyfill(polyfill: &walrus::Module) -> Result<(), anyhow::Error> { + if polyfill.tables.iter().next().is_some() + || polyfill.start.is_some() + || polyfill.elements.iter().next().is_some() + || polyfill.data.iter().next().is_some() + { + // Rust uses lld, which currently errors out when attempting to + // produce relocatable wasms. If it could produce relocatable wasms, + // there is an alternative solution to writing this custom + // linker: feed lld's output, along with the polyfill, back + // into lld, after repairing names which unfortunately vary + // over time, e.g. + // "$_ZN4wasi13lib_generated22wasi_snapshot_preview18fd_write17haadc9440e6dddc5cE" + // + // Another option that we may try in the future: rustc doesn't + // give us enough control over library link order to insert + // polyfills into the right spot. We could create a linker wrapper + // which invokes lld after doing the name translation, giving + // us that control. We'd still have to remove unused functions + // after link, since neither lld nor binaryen currently do that. + // wasm-gc does it, but its repo is archived. + return Err(anyhow!("Polyfill has unexpected section")); + } + if polyfill.types.iter().next().is_none() + || polyfill.imports.iter().next().is_none() + || polyfill.funcs.iter().next().is_none() + || polyfill + .funcs + .iter_local() + .any(|(_, local_function)| local_function.size() == 0) + || polyfill.exports.iter().next().is_none() + { + return Err(anyhow!("Polyfill has missing section")); + } + + Ok(()) } -#[derive(Clone, Debug)] -enum OldToNewFn { - Fn { - ty: Type, - body: FuncBody, - new_index: usize, - }, - Import(ImportFunction), - ResolvedImport(usize), +/// The module is not a supported target for polyfilling if it has the following: +/// * A start function +fn validate_fill_target(module: &walrus::Module) -> Result<(), anyhow::Error> { + if module.start.is_some() { + return Err(anyhow!("Target module has unsupported section: start"))?; + } + Ok(()) } -fn get_imported_functions( - module: &parity_wasm::elements::Module, - types: &[Type], -) -> Vec { - module - .import_section() - .unwrap() - .entries() +/// A module is not a candidate for polyfilling if it has any of the following: +/// * No types +/// * No imports +/// * No functions +/// * No exports +/// * No function exports +fn should_polyfill(module: &walrus::Module) -> bool { + if module.types.iter().next().is_none() + || module.imports.iter().next().is_none() + || module.funcs.iter().next().is_none() + || module.exports.iter().next().is_none() + || !module + .funcs + .iter() + .any(|f| module.exports.get_exported_func(f.id()).is_some()) + { + return false; + } + true +} + +/// Maps imported function IDs in a destination module to their corresponding exported +/// function IDs from a source module +struct PolyfillTarget { + source_fid: FunctionId, + dest_fid: FunctionId, +} + +/// Returns a list of `PolyfillTarget` objects. +/// +/// Only functions that are actually imported in the `dest` module will be considered +/// for polyfilling. +fn get_polyfill_targets( + source: &walrus::Module, + dest: &walrus::Module, +) -> Result>, anyhow::Error> { + let mut error: Option = None; + let targets: Vec = dest + .imports .iter() - .filter_map(|entry| { - if let External::Function(ty) = entry.external() { - Some(ImportFunction { - module: entry.module().to_owned(), - field: entry.field().to_owned(), - ty: types[*ty as usize].clone(), - }) - } else { - None + .filter_map(|import| { + let name = &import.name; + + // Only consider imported functions + let dest_func = match import.kind { + walrus::ImportKind::Function(import_fid) => dest.funcs.get(import_fid), + _ => return None, + }; + + // Check if there's a corresponding export in the `source` module + let source_func = match source.exports.get_func(name) { + Ok(exp_fid) => source.funcs.get(exp_fid), + _ => return None, + }; + + // Check function types match + if source.func_type(source_func.id()) != dest.func_type(dest_func.id()) { + error = Some(anyhow!( + "Destination import {} matches source export by name but not by type.", + name + )); } + + Some(PolyfillTarget { + source_fid: source_func.id(), + dest_fid: dest_func.id(), + }) }) - .collect() -} + .collect(); -fn mark_type(new_types: &mut Vec, type_map: &mut HashMap, ty: &Type) { - if !type_map.contains_key(ty) { - type_map.insert(ty.clone(), new_types.len()); - new_types.push(ty.clone()); + if error.is_some() { + return Err(error.unwrap()); } + + return Ok(Some(targets)); } -#[allow(clippy::too_many_arguments)] -fn mark_function( - module: &parity_wasm::elements::Module, - imported_fns: &[ImportFunction], - num_new_functions: &mut usize, - old_to_new_fn: &mut Vec>, - old_types: &Vec, - new_types: &mut Vec, - type_map: &mut HashMap, - index: usize, -) -> Result<(), anyhow::Error> { - if old_to_new_fn[index].is_some() { - return Ok(()); - } - if index < imported_fns.len() { - old_to_new_fn[index] = Some(OldToNewFn::Import(imported_fns[index].clone())); - mark_type(new_types, type_map, &imported_fns[index].ty); - } else { - let adj_index = index - imported_fns.len(); - let functions = module.function_section().unwrap().entries(); - let code = module.code_section().unwrap().bodies(); - if adj_index >= functions.len() || adj_index >= code.len() { - return Err(anyhow!("Function index out of bounds")); +/// Gets the FunctionID if it exists for a function in a `wasm_module` based on a +/// `function_module` and `name`. +fn get_import_fid( + function_module: &str, + name: &str, + wasm_module: &Module, +) -> Result, anyhow::Error> { + wasm_module + .imports + .iter() + .find(|&i| &i.name == name && &i.module == function_module) + .map_or(Ok(None), |i| match i.kind { + walrus::ImportKind::Function(fid) => Ok(Some(fid)), + _ => Err(anyhow!("Import kind mismatch")), + }) +} + +/// Get the corresponding FunctionID in the `dest` module for a given FunctionID from the `source` +/// module. If the function does not exist in the `dest` module, it will be added. +fn to_dest_func( + source_fid: FunctionId, + source: &Module, + dest: &mut Module, + id_maps: &mut IdMaps, +) -> Result { + let f = source.funcs.get(source_fid); + let (source_func_kind, source_func_ty) = (&f.kind, f.ty()); + + let new_fid = match &source_func_kind { + Import(_) => { + let s = source.imports.get_imported_func(source_fid).unwrap(); + let (module, name) = (&s.module, &s.name); + + let dest_fid_opt = get_import_fid(module, name, &dest)?; + + if let Some(dest_fid) = dest_fid_opt { + // The import already exists in the dest + if dest.func_type(dest_fid) != source.func_type(source_fid) { + return Err(anyhow!("Type mismatch between imports")); + } + dest_fid + } else { + // The import needs to be added to the dest. Update the called fid. + let ty = source.types.get(source_func_ty); + let dest_type = dest.types.add(ty.params(), ty.results()); + dest.add_import_func(module, name, dest_type).0 + } } - let ty = &old_types[functions[adj_index].type_ref() as usize]; - let body = &code[adj_index]; - - old_to_new_fn[index] = Some(OldToNewFn::Fn { - ty: ty.clone(), - body: body.clone(), - new_index: *num_new_functions, - }); - *num_new_functions += 1; - - mark_type(new_types, type_map, ty); - for instruction in body.code().elements() { - if let Instruction::Call(index) = instruction { - mark_function( - module, - imported_fns, - num_new_functions, - old_to_new_fn, - old_types, - new_types, - type_map, - *index as usize, - )? + Local(loc) => { + if let Some(local_fid) = id_maps.loc_fid_map.get(&source_fid) { + *local_fid + } else { + let new_local_func = copy_func(loc, &f.name, source, dest, id_maps)?; + let new_local_fid = dest.funcs.add_local(new_local_func); + id_maps.loc_fid_map.insert(source_fid, new_local_fid); + new_local_fid + } + } + Uninitialized(_) => { + return Err(anyhow!("Error: Source function uninitialized.")); + } + }; + Ok(new_fid) +} + +/// Copies one instruction sequence from a function in a `source` module to a sequence +/// in a `dest` module. +/// +/// Returns the id of the new sequence +fn to_dest_seq( + source_block_id: InstrSeqId, + source_function: &LocalFunction, + source: &Module, + dest_seq: &mut InstrSeqBuilder, + dest: &mut Module, + id_maps: &mut IdMaps, +) -> Result { + // Update the id map with the id of this new sequence. Needed to correctly identify + // the corresponding target sequence id for a given source sequence id in a br instruction + id_maps.seq_id_map.insert(source_block_id, dest_seq.id()); + + // Get the instructions from the specified source block + let instrs = source_function + .block(source_block_id) + .instrs + .iter() + .map(|(instr, _)| instr); + + let dest_mem_id = dest.get_memory_id()?; + + // Map each source instruction to an instruction injected into the new target sequence + for instr in instrs { + match instr { + // Function reference updates + Instr::RefFunc(func_ref) => { + let mut i = func_ref.clone(); + i.func = to_dest_func(i.func, source, dest, id_maps)?; + dest_seq.instr(i); + } + Instr::Call(func_ref) => { + let mut i = func_ref.clone(); + i.func = to_dest_func(i.func, source, dest, id_maps)?; + dest_seq.instr(i); + } + + // Sequence reference updates + Instr::Block(seq_ref) => { + let mut i = seq_ref.clone(); + let mut new_dest_sequence = + dest_seq.dangling_instr_seq(source_function.block(i.seq).ty); + i.seq = to_dest_seq( + i.seq, + source_function, + source, + &mut new_dest_sequence, + dest, + id_maps, + )?; + dest_seq.instr(i); + } + Instr::Loop(seq_ref) => { + let mut i = seq_ref.clone(); + let mut new_dest_sequence = + dest_seq.dangling_instr_seq(source_function.block(i.seq).ty); + i.seq = to_dest_seq( + i.seq, + source_function, + source, + &mut new_dest_sequence, + dest, + id_maps, + )?; + dest_seq.instr(i); + } + Instr::IfElse(if_else) => { + let mut i = if_else.clone(); + + let mut new_dest_seq_1 = + dest_seq.dangling_instr_seq(source_function.block(i.consequent).ty); + i.consequent = to_dest_seq( + i.consequent, + source_function, + source, + &mut new_dest_seq_1, + dest, + id_maps, + )?; + + let mut new_dest_seq_2 = + dest_seq.dangling_instr_seq(source_function.block(i.alternative).ty); + i.alternative = to_dest_seq( + i.alternative, + source_function, + source, + &mut new_dest_seq_2, + dest, + id_maps, + )?; + + dest_seq.instr(i); + } + + // Memory reference updates + Instr::MemorySize(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::MemoryGrow(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::MemoryInit(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::MemoryFill(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::Load(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::Store(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::AtomicRmw(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::Cmpxchg(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::AtomicNotify(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::AtomicWait(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + Instr::LoadSimd(mem_ref) => { + let mut i = mem_ref.clone(); + i.memory = dest_mem_id; + dest_seq.instr(i); + } + + // Local reference updates + Instr::LocalGet(local_ref) => { + let mut i = local_ref.clone(); + i.local = + id_maps.to_dest_loc_id(&local_ref.local, source.locals.get(i.local).ty(), dest); + dest_seq.instr(i); + } + Instr::LocalSet(local_ref) => { + let mut i = local_ref.clone(); + i.local = + id_maps.to_dest_loc_id(&local_ref.local, source.locals.get(i.local).ty(), dest); + dest_seq.instr(i); + } + Instr::LocalTee(local_ref) => { + let mut i = local_ref.clone(); + i.local = + id_maps.to_dest_loc_id(&local_ref.local, source.locals.get(i.local).ty(), dest); + dest_seq.instr(i); + } + + // Branch sequence id updates + // "Labels are targets for branch instructions that reference them with label indices. + // Unlike with other index spaces, indexing of labels is relative by nesting depth..." + // https://webassembly.github.io/spec/core/syntax/instructions.html#control-instructions + Instr::Br(block_ref) => { + let mut i = block_ref.clone(); + i.block = id_maps.get_mapped_seq( + &block_ref.block, + "`br` instruction references untracked sequence ID", + )?; + dest_seq.instr(i); + } + Instr::BrIf(block_ref) => { + let mut i = block_ref.clone(); + i.block = id_maps.get_mapped_seq( + &block_ref.block, + "`br_if` instruction references untracked sequence ID", + )?; + dest_seq.instr(i); + } + Instr::BrTable(block_table_ref) => { + let mut i = block_table_ref.clone(); + let mut blocks: Vec = vec![]; + for b in i.blocks.into_vec().iter() { + blocks.push(id_maps.get_mapped_seq( + &b, + "`br_table` instruction references untracked sequence ID", + )?); + } + i.blocks = blocks.into(); + i.default = id_maps.get_mapped_seq( + &i.default, + "`br_table` instruction references untracked sequence ID", + )?; + dest_seq.instr(i); + } + + // Invalid instructions + Instr::CallIndirect(_) => { + // Polyfill shouldn't be using indirect calls + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `call_indirect`" + )); + } + Instr::GlobalGet(_) => { + // Polyfill shouldn't be referencing globals + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `global.get`" + )); + } + Instr::GlobalSet(_) => { + // Polyfill shouldn't be referencing globals + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `global.set`" + )); + } + Instr::MemoryCopy(_) => { + // Unsure how to handle copying memory + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `memory.copy`" + )); + } + Instr::TableGet(_) => { + // Polyfill not allowed to have a tables section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `table.get`" + )); + } + Instr::TableSet(_) => { + // Polyfill not allowed to have a tables section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `table.set`" + )); + } + Instr::TableGrow(_) => { + // Polyfill not allowed to have a tables section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `table.grow`" + )); + } + Instr::TableSize(_) => { + // Polyfill not allowed to have a tables section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `table.size`" + )); + } + Instr::TableFill(_) => { + // Polyfill not allowed to have a tables section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `table.fill`" + )); + } + Instr::TableInit(_) => { + // Polyfill not allowed to have a tables section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `table.init`" + )); + } + Instr::TableCopy(_) => { + // Polyfill not allowed to have a tables section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `table.copy`" + )); + } + Instr::ElemDrop(_) => { + // Polyfill not allowed to have an elements section + return Err(anyhow!( + "Error: Polyfill module has unsupported instruction: `elem.drop`" + )); + } + + // List every other instruction type, to enforce that new types are properly handled + Instr::Const(i) => { + dest_seq.instr(i.clone()); + } + Instr::Binop(i) => { + dest_seq.instr(i.clone()); + } + Instr::Unop(i) => { + dest_seq.instr(i.clone()); + } + Instr::Select(i) => { + dest_seq.instr(i.clone()); + } + Instr::Unreachable(i) => { + dest_seq.instr(i.clone()); + } + Instr::Drop(i) => { + dest_seq.instr(i.clone()); + } + Instr::Return(i) => { + dest_seq.instr(i.clone()); + } + Instr::DataDrop(i) => { + dest_seq.instr(i.clone()); + } + Instr::AtomicFence(i) => { + dest_seq.instr(i.clone()); + } + Instr::RefNull(i) => { + dest_seq.instr(i.clone()); + } + Instr::RefIsNull(i) => { + dest_seq.instr(i.clone()); + } + Instr::V128Bitselect(i) => { + dest_seq.instr(i.clone()); + } + Instr::I8x16Swizzle(i) => { + dest_seq.instr(i.clone()); + } + Instr::I8x16Shuffle(i) => { + dest_seq.instr(i.clone()); } } } - Ok(()) + + Ok(dest_seq.id()) +} + +/// Tracks the ids from a source wasm and their corresponding new id +/// created in the destination wasm. +/// +/// Needed to ensure that various instructions in the destination are +/// consistently referencing the correct ids. +struct IdMaps { + seq_id_map: HashMap, + loc_id_map: HashMap, + loc_fid_map: HashMap, } -fn mark_functions( - module: &parity_wasm::elements::Module, - imported_fns: &[ImportFunction], - num_new_functions: &mut usize, - old_to_new_fn: &mut Vec>, - old_types: &Vec, - new_types: &mut Vec, - type_map: &mut HashMap, -) -> Result<(), anyhow::Error> { - for entry in module.export_section().unwrap().entries() { - if let Internal::Function(index) = entry.internal() { - mark_function( - module, - imported_fns, - num_new_functions, - old_to_new_fn, - old_types, - new_types, - type_map, - *index as usize, - )?; +impl IdMaps { + fn get_mapped_seq(&self, seq_id: &InstrSeqId, err: &str) -> Result { + if let Some(id) = self.seq_id_map.get(seq_id) { + return Ok(*id); + } else { + return Err(anyhow!(err.to_owned())); } } - if let Some(element) = module.elements_section() { - if let Some(table) = module.table_section() { - for entry in element.entries() { - if entry.index() as usize >= table.entries().len() { - return Err(anyhow!("Element references missing table")); - } - if table.entries()[entry.index() as usize].elem_type() != TableElementType::AnyFunc - { - return Err(anyhow!("Unsupported table type")); - } - for member in entry.members() { - mark_function( - module, - imported_fns, - num_new_functions, - old_to_new_fn, - old_types, - new_types, - type_map, - *member as usize, - )?; - } - } + // Creates a new local in the dest module if this is the first time + // we have seen the specified local from the source module `loc_id`. + // If we have already seen a reference to this source local, then we + // replace the reference to the corresponding (already created) target local. + fn to_dest_loc_id( + &mut self, + loc_id: &LocalId, + local_type: ValType, + dest: &mut Module, + ) -> LocalId { + if let Some(local_id) = self.loc_id_map.get(loc_id) { + return *local_id; } else { - return Err(anyhow!("Element references missing table")); + let new_local = dest.locals.add(local_type); + self.loc_id_map.insert(*loc_id, new_local); + return new_local; } } - Ok(()) } -fn fill_functions( - is_poly: bool, - old_types: &[Type], - type_map: &HashMap, - old_to_new_fn: &[Option], - new_imports: &[ImportEntry], - new_functions: &mut [Option], - new_bodies: &mut [Option], -) -> Result<(), anyhow::Error> { - for item in old_to_new_fn.iter().flatten() { - if let OldToNewFn::Fn { - ty, - body, - new_index, - } = item - { - new_functions[*new_index] = Some(Func::new(*type_map.get(ty).unwrap() as u32)); - let mut body = body.clone(); - for instr in body.code_mut().elements_mut() { - match instr { - Instruction::Call(f) => match old_to_new_fn[*f as usize].as_ref().unwrap() { - OldToNewFn::Fn { - ty: _, - body: _, - new_index, - } => *f = (new_imports.len() + new_index) as u32, - OldToNewFn::Import(_) => panic!("unresolved import"), - OldToNewFn::ResolvedImport(i) => *f = *i as u32, - }, - Instruction::CallIndirect(ty, _) => { - if is_poly { - return Err(anyhow!("polyfill has an indirect call")); - } - *ty = *type_map.get(&old_types[*ty as usize]).unwrap() as u32; - } - Instruction::GetGlobal(_) => { - if is_poly { - return Err(anyhow!("polyfill uses a global")); - } +impl Default for IdMaps { + fn default() -> Self { + IdMaps { + seq_id_map: HashMap::new(), + loc_id_map: HashMap::new(), + loc_fid_map: HashMap::new(), + } + } +} + +/// Copy all instructions from a function in a `source` module to a new function +/// in a `dest` module. +fn copy_func( + source_local_func: &LocalFunction, + source_local_func_name: &Option, + source: &Module, + dest: &mut Module, + id_maps: &mut IdMaps, +) -> Result { + // Build the new local function in `dest` with the correct signature + let tid = source_local_func.ty(); + let ty = source.types.get(tid); + let (params, results) = (ty.params().to_vec(), ty.results().to_vec()); + + let mut builder = walrus::FunctionBuilder::new(&mut dest.types, ¶ms, &results); + + if source_local_func_name.is_some() { + builder.name(source_local_func_name.to_owned().unwrap()); + } + + // Make the new local function + let args = params + .iter() + .map(|val_type| dest.locals.add(*val_type)) + .collect::>(); + + // Copy the sequence of instructions in a function from a `source` module into + // the new `dest` instruction sequence. + let instr_seq_id = source_local_func.entry_block(); + let dest_instr_builder = &mut builder.func_body(); + + // Map parameters to locals + for (index, source_loc_id) in source_local_func.args.iter().enumerate() { + // Verify the arg type is the same + let dest_loc_id = args[index]; + if source.locals.get(*source_loc_id).ty() != dest.locals.get(dest_loc_id).ty() { + return Err(anyhow!("Error mapping locals")); + } + + id_maps.loc_id_map.insert(*source_loc_id, dest_loc_id); + } + + to_dest_seq( + instr_seq_id, + &source_local_func, + source, + dest_instr_builder, + dest, + id_maps, + )?; + + Ok(builder.local_func(args)) +} + +fn new_validator() -> Validator { + let validator = wasmparser::Validator::new_with_features(wasmparser::WasmFeatures { + sign_extension: true, + bulk_memory: true, + simd: true, + ..wasmparser::WasmFeatures::default() + }); + return validator; +} + +/// Produce a module that links exported functions in the `source` module to +/// their corresponding imported functions in a `dest` module. +/// +/// This also strips out unused functions from the final module. +pub fn link_module(source: &Module, dest: &mut Module) -> Result<(), anyhow::Error> { + validate_polyfill(&source)?; + validate_fill_target(dest)?; + + let mut id_maps: IdMaps = Default::default(); + if should_polyfill(dest) { + if let Some(targets) = get_polyfill_targets(&source, &dest)? { + for target in targets { + let PolyfillTarget { + source_fid, + dest_fid, + } = target; + + // Get import ID + let import_id = dest + .imports + .get_imported_func(dest_fid) + .map(|i| i.id()) + .unwrap(); + + // Get source local function + let source_func = source.funcs.get(source_fid); + match &source_func.kind { + walrus::FunctionKind::Local(loc) => { + // Copy the function into a new local function in the `dest` + let new_func = + copy_func(loc, &source_func.name, &source, dest, &mut id_maps)?; + + // Replace the old imported function with the new local function and delete the old import. + let dest_func = dest.funcs.get_mut(dest_fid); + dest_func.kind = FunctionKind::Local(new_func); + dest.imports.delete(import_id); } - Instruction::SetGlobal(_) => { - if is_poly { - return Err(anyhow!("polyfill uses a global")); - } + walrus::FunctionKind::Import(_) => { + // Rewrite the dest import to the source import + let source_import = source.imports.get_imported_func(source_fid).unwrap(); + let dest_import = dest.imports.get_mut(import_id); + dest_import.module = source_import.module.to_owned(); + dest_import.name = source_import.name.to_owned(); } - _ => (), + _ => return Err(anyhow!("Requested local function not found")), } } - new_bodies[*new_index] = Some(body); } } + + walrus::passes::gc::run(dest); + + // To be safe, run the validator on every wasm produced by this linker + new_validator() + .validate_all(&dest.emit_wasm()) + .map_err(|e| anyhow!("[Wasm linker error] {}", e))?; + + // TODO: enable debug builds + // Prior version of this linker removed all custom sections because it was annoying to + // keep them updated while reordering and modifying functions. But now that we are using + // walrus, dwarf data already in the dest module should be left intact. + // To support debugging, don't delete the custom sections, might also need to skip wasm-opt. + Ok(()) } -// Link polyfill to code and strip out unused functions -pub fn link(filename: &Path, code: &[u8], polyfill: &[u8]) -> Result, anyhow::Error> { - let poly: parity_wasm::elements::Module = deserialize_buffer(polyfill) - .map_err(|_| anyhow!("Parity-wasm failed to parse polyfill"))?; - if poly.table_section().is_some() - || poly.start_section().is_some() - || poly.elements_section().is_some() - || poly.data_section().is_some() - { - // These sections are unsupported in the polyfill since they - // would require relocatable wasms to merge. Rust uses lld, - // which currently errors out when attempting to produce - // relocatable wasms. If it could produce relocatable wasms, - // there is an alternative solution to writing this custom - // linker: feed lld's output, along with the polyfill, back - // into lld, after repairing names which unfortunately vary - // over time, e.g. - // "$_ZN4wasi13lib_generated22wasi_snapshot_preview18fd_write17haadc9440e6dddc5cE" - // - // Another option that we may try in the future: rustc doesn't - // give us enough control over library link order to insert - // polyfills into the right spot. We could create a linker wrapper - // which invokes lld after doing the name translation, giving - // us that control. We'd still have to remove unused functions - // after link, since neither lld nor binaryen currently do that. - // wasm-gc does it, but its repo is archived. - return Err(anyhow!("Polyfill has unexpected section")); +#[cfg(test)] +mod tests { + use anyhow::Error; + use core::fmt; + use std::{ + fs::File, + io::Write, + path::{Path, PathBuf}, + }; + + use super::*; + + const SERVICE_POLYFILL: &str = concat!(env!("OUT_DIR"), "/service_wasi_polyfill.wasm"); + const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); + + // Config params + const GEN_NAME_SECTION: bool = false; + const GEN_PRODUCERS_SECTION: bool = false; + const PRINT_OFFSETS: bool = false; + + fn rel_to_manifest(filepath: &str) -> String { + format!("{}{}", CARGO_MANIFEST_DIR, filepath) } - if poly.type_section().is_none() - || poly.import_section().is_none() - || poly.function_section().is_none() - || poly.code_section().is_none() - || poly.export_section().is_none() - { - return Err(anyhow!("Polyfill has missing section")); + + fn walrus_config() -> walrus::ModuleConfig { + let mut config = walrus::ModuleConfig::new(); + config.generate_name_section(GEN_NAME_SECTION); + config.generate_producers_section(GEN_PRODUCERS_SECTION); + config } - let poly_old_types = poly.type_section().unwrap().types().to_owned(); - let poly_imported_fns = get_imported_functions(&poly, &poly_old_types); - let poly_functions = poly.function_section().unwrap().entries(); - let poly_exports = poly.export_section().unwrap().entries(); - let poly_num_functions = poly_imported_fns.len() + poly_functions.len(); - - let mut module: parity_wasm::elements::Module = deserialize_buffer(code) - .map_err(|_| anyhow!("Parity-wasm failed to parse {}", filename.to_string_lossy()))?; - if module.start_section().is_some() { - return Err(anyhow!( - "{} has unsupported start section", - filename.to_string_lossy() - ))?; + fn wasm(filepath: &str) -> Result { + walrus_config().parse_file(filepath) } - if module.type_section().is_none() - || module.import_section().is_none() - || module.function_section().is_none() - || module.code_section().is_none() - || module.export_section().is_none() - || !module - .export_section() - .unwrap() - .entries() - .iter() - .any(|e| matches!(e.internal(), Internal::Function(_))) - { - return Ok(code.to_owned()); + + fn wat(filepath: &str) -> Result { + walrus_config().parse(&wat::parse_file(filepath)?) } - let old_types = module.type_section().unwrap().types().to_owned(); - let imported_fns = get_imported_functions(&module, &old_types); - let num_functions = imported_fns.len() + module.function_section().unwrap().entries().len(); - - let mut num_new_functions = 0; - let mut new_types = Vec::new(); - let mut old_to_new_fn = vec![None; num_functions]; - let mut type_map = HashMap::new(); - mark_functions( - &module, - &imported_fns, - &mut num_new_functions, - &mut old_to_new_fn, - &old_types, - &mut new_types, - &mut type_map, - )?; + fn wat_path(file_path: &str) -> PathBuf { + let mut p = Path::new(file_path).to_path_buf(); + p.set_extension("wat"); + p + } - let mut poly_old_to_new_fn = vec![None; poly_num_functions]; - for item in old_to_new_fn.iter_mut().flatten() { - if let OldToNewFn::Import(import) = item { - if import.module == "wasi_snapshot_preview1" { - for export in poly_exports.iter() { - if export.field() == import.field { - if let Internal::Function(export_fn) = export.internal() { - mark_function( - &poly, - &poly_imported_fns, - &mut num_new_functions, - &mut poly_old_to_new_fn, - &poly_old_types, - &mut new_types, - &mut type_map, - *export_fn as usize, - )?; - let new_item = poly_old_to_new_fn[*export_fn as usize].clone().unwrap(); - let new_ty = match &new_item { - OldToNewFn::Fn { - ty, - body: _, - new_index: _, - } => ty, - OldToNewFn::Import(f) => &f.ty, - OldToNewFn::ResolvedImport(_) => unimplemented!(), - }; - if new_ty != &import.ty { - return Err(anyhow!( - "mismatched polyfill type; {} {:?} {:?}", - import.field, - import.ty, - new_ty - )); - } - *item = new_item; - break; - } - } - } - } - } + fn suffix_pb(file_path: &PathBuf, suffix: &str) -> PathBuf { + let stem = file_path + .file_stem() + .unwrap_or_default() + .to_str() + .unwrap_or(""); + let extension = file_path + .extension() + .map_or_else(|| "", |e| e.to_str().unwrap_or("")); + let new_stem = format!("{}{}", stem, suffix); + + file_path.with_file_name(new_stem).with_extension(extension) } - let mut new_imports = Vec::new(); - let mut import_map = HashMap::new(); - for item in old_to_new_fn - .iter_mut() - .chain(poly_old_to_new_fn.iter_mut()) - .flatten() - { - if let OldToNewFn::Import(import) = item { - if let Some(index) = import_map.get(import) { - *item = OldToNewFn::ResolvedImport(*index); - } else { - import_map.insert(import.clone(), new_imports.len()); - new_imports.push(ImportEntry::new( - import.module.clone(), - import.field.clone(), - External::Function(*type_map.get(&import.ty).unwrap() as u32), - )); - *item = OldToNewFn::ResolvedImport(new_imports.len() - 1); - } - } + fn suffix(filepath: &str, suffix: &str) -> String { + let filepath_pb = &Path::new(filepath).to_path_buf(); + suffix_pb(filepath_pb, suffix).to_str().unwrap().to_string() } - let mut new_functions = vec![None; num_new_functions]; - let mut new_bodies = vec![None; num_new_functions]; - fill_functions( - false, - &old_types, - &type_map, - &old_to_new_fn, - &new_imports, - &mut new_functions, - &mut new_bodies, - )?; - fill_functions( - true, - &poly_old_types, - &type_map, - &poly_old_to_new_fn, - &new_imports, - &mut new_functions, - &mut new_bodies, - )?; + fn print_wat(wasm_path: &str, wasm_data: &Vec) -> Result<(), Error> { + let wat_path = wat_path(wasm_path); + let skele_path = suffix_pb(&wat_path, "-skeleton"); - // for (i, item) in old_to_new_fn.iter().enumerate() { - // if let Some(item) = item { - // match item { - // OldToNewFn::Fn { - // ty: _, - // body: _, - // new_index, - // } => println!("func {} -> {}", i, new_imports.len() + new_index), - // OldToNewFn::Import(_) => todo!(), - // OldToNewFn::ResolvedImport(f) => println!("imp {} -> {}", i, f), - // } - // } - // } - - // Remove all custom sections; psibase doesn't need them - // and this is easier than translating them. - // - // TODO: need an option to to support debugging. - // * Don't trim out or reorder functions, since - // editing DWARF is a PITA - // * Leave custom sections as-is - // * Might also need to skip binaryen - let sections = module.sections_mut(); - *sections = sections - .drain(..) - .filter(|s| !matches!(s, Section::Custom(_))) - .collect(); + let mut printer = wasmprinter::Printer::new(); + printer.print_offsets(PRINT_OFFSETS); + let wat_data = printer.print(wasm_data)?; + printer.print_skeleton(true); + let wat_skele = printer.print(wasm_data)?; - for entry in module.export_section_mut().unwrap().entries_mut() { - if let Internal::Function(f) = entry.internal_mut() { - *f = match old_to_new_fn[*f as usize].as_ref().unwrap() { - OldToNewFn::Fn { - ty: _, - body: _, - new_index, - } => (new_imports.len() + new_index) as u32, - OldToNewFn::Import(_) => panic!("unresolved import"), - OldToNewFn::ResolvedImport(i) => *i as u32, - }; - } + File::create(&wat_path)?.write_all((&wat_data).as_bytes())?; + File::create(&skele_path)?.write_all((&wat_skele).as_bytes())?; + Ok(()) } - for entry in module.elements_section_mut().unwrap().entries_mut() { - for member in entry.members_mut() { - *member = match old_to_new_fn[*member as usize].as_ref().unwrap() { - OldToNewFn::Fn { - ty: _, - body: _, - new_index, - } => (new_imports.len() + new_index) as u32, - OldToNewFn::Import(_) => panic!("unresolved import"), - OldToNewFn::ResolvedImport(i) => *i as u32, - }; + struct ImportFunction { + _id: FunctionId, + name: String, + module: String, + } + impl fmt::Display for ImportFunction { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}::{}", self.module, self.name) } } - new_imports.extend( + fn get_import_funcs(module: &Module) -> Vec { module - .import_section() - .unwrap() - .entries() + .imports .iter() - .filter(|e| !matches!(e.external(), External::Function(_))) - .cloned(), - ); - - *module.type_section_mut().unwrap().types_mut() = new_types; - *module.import_section_mut().unwrap().entries_mut() = new_imports; - *module.function_section_mut().unwrap().entries_mut() = - new_functions.into_iter().map(|f| f.unwrap()).collect(); - *module.code_section_mut().unwrap().bodies_mut() = - new_bodies.into_iter().map(|f| f.unwrap()).collect(); - - Ok(module.into_bytes()?) + .filter_map(|import| { + let dest_func = match import.kind { + walrus::ImportKind::Function(import_fid) => module.funcs.get(import_fid), + _ => return None, + }; + + let import = module.imports.get_imported_func(dest_func.id()).unwrap(); + + Some(ImportFunction { + _id: dest_func.id(), + name: import.name.to_owned(), + module: import.module.to_owned(), + }) + }) + .collect() + } + + #[test] + fn imports_removed() -> Result<(), Error> { + let simple_wasm = &rel_to_manifest("/test-data/simple.wasm"); + let mut original = wasm(simple_wasm)?; + let mut destination = wasm(simple_wasm)?; + let polyfill = wasm(SERVICE_POLYFILL)?; + + link_module(&polyfill, &mut destination)?; + + print_wat(simple_wasm, &original.emit_wasm())?; + print_wat(&suffix(simple_wasm, "-filled"), &destination.emit_wasm())?; + + let targets_before_fill: Option> = + get_polyfill_targets(&polyfill, &original)?; + let _import_fids: Vec = if let Some(targets) = targets_before_fill { + assert_eq!( + targets.len(), + 4, + "Before fill, polyfill targets should be 4." + ); + targets.into_iter().map(|t| t.dest_fid).collect() + } else { + vec![] + }; + + let targets_after_fill: Option> = + get_polyfill_targets(&polyfill, &destination)?; + if let Some(targets) = targets_after_fill { + assert_eq!( + targets.len(), + 0, + "After fill, polyfill targets should be 0." + ); + } + + let import_funcs = get_import_funcs(&destination); + for f in import_funcs { + println!("{}", f); + } + + Ok(()) + } + + #[test] + fn fill_reexport() -> Result<(), Error> { + let import_path = &rel_to_manifest("/test-data/import.wat"); + let mut destination = wat(import_path)?; + let mut polyfill = wat(&rel_to_manifest("/test-data/reexport.wat"))?; + + new_validator() + .validate_all(&destination.emit_wasm()) + .map_err(|e| anyhow!("[import.wat not valid] {}", e))?; + new_validator() + .validate_all(&polyfill.emit_wasm()) + .map_err(|e| anyhow!("[reexport.wat not valid] {}", e))?; + + let imports = get_import_funcs(&destination); + assert!(imports.len() == 1, "Unexpected import"); + assert!( + imports[0].module == "wasi_snapshot_preview1", + "Prefill import module incorrect" + ); + assert!( + imports[0].name == "fd_close", + "Prefill import name incorrect" + ); + + link_module(&polyfill, &mut destination)?; + print_wat(&suffix(import_path, "-filled"), &destination.emit_wasm())?; + + let post_imports = get_import_funcs(&destination); + assert!(post_imports.len() == 1, "Unexpected import"); + assert!( + post_imports[0].module == "env", + "Postfill import module incorrect" + ); + assert!( + post_imports[0].name == "testerClose", + "Postfill import name incorrect" + ); + + Ok(()) + } } diff --git a/rust/cargo-psibase/src/main.rs b/rust/cargo-psibase/src/main.rs index d49e777da..c9eb616d4 100644 --- a/rust/cargo-psibase/src/main.rs +++ b/rust/cargo-psibase/src/main.rs @@ -1,8 +1,5 @@ -mod link; - use anyhow::Error; use anyhow::{anyhow, Context}; -use binaryen::{CodegenConfig, Module}; use cargo_metadata::Message; use cargo_metadata::Metadata; use clap::{Parser, Subcommand}; @@ -17,8 +14,14 @@ use std::process::{exit, Stdio}; use std::{env, fs}; use tokio::io::AsyncBufReadExt; use url::Url; +use walrus::Module; +use wasm_opt::OptimizationOptions; + +mod link; +use link::link_module; const SERVICE_ARGS: &[&str] = &["--lib", "--crate-type=cdylib"]; +const SERVICE_ARGS_RUSTC: &[&str] = &["--", "-C", "target-feature=+simd128,+bulk-memory,+sign-ext"]; const SERVICE_POLYFILL: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/service_wasi_polyfill.wasm")); @@ -111,16 +114,25 @@ fn pretty_path(label: &str, filename: &Path) { pretty(label, &filename.file_name().unwrap().to_string_lossy()); } -fn optimize(filename: &Path, code: &[u8]) -> Result, Error> { - pretty_path("Reoptimizing", filename); - let mut module = Module::read(code) - .map_err(|_| anyhow!("Binaryen failed to parse {}", filename.to_string_lossy()))?; - module.optimize(&CodegenConfig { - shrink_level: 1, - optimization_level: 2, - debug_info: false, - }); - Ok(module.write()) +fn optimize(code: &mut Module) -> Result<(), Error> { + let file = tempfile::NamedTempFile::new()?; + code.emit_wasm_file(file.path())?; + + let debug_build = false; + OptimizationOptions::new_opt_level_2() + .shrink_level(wasm_opt::ShrinkLevel::Level1) + .enable_feature(wasm_opt::Feature::BulkMemory) + .enable_feature(wasm_opt::Feature::SignExt) + .enable_feature(wasm_opt::Feature::Simd) + .debug_info(debug_build) + .run(file.path(), file.path())?; + + let mut config = walrus::ModuleConfig::new(); + config.generate_name_section(false); + config.generate_producers_section(false); + *code = config.parse_file(file.path().to_path_buf())?; + + Ok(()) } fn process(filename: &PathBuf, polyfill: &[u8]) -> Result<(), Error> { @@ -135,16 +147,29 @@ fn process(filename: &PathBuf, polyfill: &[u8]) -> Result<(), Error> { let code = &read(filename) .with_context(|| format!("Failed to read {}", filename.to_string_lossy()))?; + + let debug_build = false; + let mut config = walrus::ModuleConfig::new(); + config.generate_name_section(debug_build); + config.generate_producers_section(false); + let source_module = config.parse(polyfill)?; + let mut dest_module = config.parse(code)?; + pretty_path("Polyfilling", filename); - let code = link::link(filename, code, polyfill)?; - let code = optimize(filename, &code)?; - write(filename, code) + link_module(&source_module, &mut dest_module)?; + + pretty_path("Reoptimizing", filename); + optimize(&mut dest_module)?; + + write(filename, dest_module.emit_wasm()) .with_context(|| format!("Failed to write {}", filename.to_string_lossy()))?; + OpenOptions::new() .create(true) .truncate(true) .write(true) .open(timestamp_file)?; + Ok(()) } @@ -215,6 +240,7 @@ async fn build( .arg("--target=wasm32-wasi") .arg("--message-format=json-diagnostic-rendered-ansi") .arg("--color=always") + .args(SERVICE_ARGS_RUSTC) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn()?; @@ -239,7 +265,7 @@ async fn build( } async fn get_test_services() -> Result, Error> { - let mut command = tokio::process::Command::new(get_cargo()) + let mut command: tokio::process::Child = tokio::process::Command::new(get_cargo()) .arg("test") .arg("--color=always") .arg("--") diff --git a/rust/cargo-psibase/test-data/.gitignore b/rust/cargo-psibase/test-data/.gitignore new file mode 100644 index 000000000..0ba9e92ed --- /dev/null +++ b/rust/cargo-psibase/test-data/.gitignore @@ -0,0 +1,3 @@ +!*.wasm +!import.wat +!reexport.wat \ No newline at end of file diff --git a/rust/cargo-psibase/test-data/README.md b/rust/cargo-psibase/test-data/README.md new file mode 100644 index 000000000..f97c2b897 --- /dev/null +++ b/rust/cargo-psibase/test-data/README.md @@ -0,0 +1,32 @@ +# Test data + +The code used to generate the sample wasm is found below. + +The command used to build these wasms is the same as what is used in the first step of `cargo psibase`: +``` +cargo rustc --lib --crate-type=cdylib -p example --release --target=wasm32-wasi --message-format=json-diagnostic-rendered-ansi --color=always -- -C target-feature=+simd128,+bulk-memory,+sign-ext +``` + +## `simple.wasm` +```rust +#[psibase::service] +#[allow(non_snake_case)] +mod service { + use psibase::*; + #[action] + pub fn add(a: i32, b: i32) -> i32 { + a + b + } + + #[action] + pub fn multiply(a: i32, b: i32) -> i32 { + a * b + } + + #[action] + #[allow(non_snake_case)] + fn serveSys(request: HttpRequest) -> Option { + serve_simple_ui::(&request) + } +} +``` diff --git a/rust/cargo-psibase/test-data/import.wat b/rust/cargo-psibase/test-data/import.wat new file mode 100644 index 000000000..e01031453 --- /dev/null +++ b/rust/cargo-psibase/test-data/import.wat @@ -0,0 +1,9 @@ +(module + (type (;0;) (func (param i32))) + (import "wasi_snapshot_preview1" "fd_close" (func (;0;) (type 0))) + (func (;1;) (type 0) (param i32) + local.get 0 + call 0 + ) + (export "internal_fd_close" (func 1)) +) diff --git a/rust/cargo-psibase/test-data/reexport.wat b/rust/cargo-psibase/test-data/reexport.wat new file mode 100644 index 000000000..7e2fba3fe --- /dev/null +++ b/rust/cargo-psibase/test-data/reexport.wat @@ -0,0 +1,3 @@ +(module + (func (export "fd_close") (import "env" "testerClose") (param i32)) +) \ No newline at end of file diff --git a/rust/cargo-psibase/test-data/simple.wasm b/rust/cargo-psibase/test-data/simple.wasm new file mode 100755 index 000000000..aa7c13b54 Binary files /dev/null and b/rust/cargo-psibase/test-data/simple.wasm differ diff --git a/rust/fracpack/Cargo.toml b/rust/fracpack/Cargo.toml index 12183aefb..64972fca6 100644 --- a/rust/fracpack/Cargo.toml +++ b/rust/fracpack/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fracpack" -version.workspace = true +version = "0.6.0" rust-version.workspace = true repository.workspace = true homepage.workspace = true @@ -13,4 +13,4 @@ path = "src/fracpack.rs" [dependencies] custom_error = "1.9.2" -psibase_macros = { path = "../psibase_macros" } +psibase_macros = { version = "0.6.0", path = "../psibase_macros" } diff --git a/rust/psibase/Cargo.toml b/rust/psibase/Cargo.toml index a7586c716..ed739b3bc 100644 --- a/rust/psibase/Cargo.toml +++ b/rust/psibase/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "psibase" -version.workspace = true +version = "0.6.0" rust-version.workspace = true repository.workspace = true homepage.workspace = true edition = "2021" description = "Library and command-line tool for interacting with psibase blockchains" license = "MIT" +include = ["src/**/*", "boot-image/**/*", "Cargo.toml"] [lib] crate-type = ["cdylib", "rlib"] @@ -18,15 +19,15 @@ async-trait = "0.1.77" chrono = "0.4" const_format = "0.2" custom_error = "1.9" -fracpack = { path = "../fracpack" } +fracpack = { version = "0.6.0", path = "../fracpack" } futures = "0.3" getrandom = { version = "0.2", features = ["js"] } include_dir = "0.7.3" sha2 = "0.10" mime_guess = "2.0" percent-encoding = "2.3" -psibase_macros = { path = "../psibase_macros" } -psibase_names = { path = "../psibase_names" } +psibase_macros = { version = "0.6.0", path = "../psibase_macros" } +psibase_names = { version = "0.6.0", path = "../psibase_names" } regex = "1" ripemd = "0.1" serde = { version = "1.0", features = ["derive", "rc"] } diff --git a/rust/psibase_macros/Cargo.toml b/rust/psibase_macros/Cargo.toml index 08d7d8cfe..7bae48eba 100644 --- a/rust/psibase_macros/Cargo.toml +++ b/rust/psibase_macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "psibase_macros" -version.workspace = true +version = "0.6.0" rust-version.workspace = true repository.workspace = true homepage.workspace = true @@ -15,6 +15,6 @@ proc-macro = true darling = "0.14" proc-macro-error = "1.0.4" proc-macro2 = "1.0.36" -psibase_names = { path = "../psibase_names" } +psibase_names = { version = "0.6.0", path = "../psibase_names" } quote = "1.0.15" syn = {version = "1.0.86", features = ["full", "visit-mut"] } diff --git a/rust/psibase_names/Cargo.toml b/rust/psibase_names/Cargo.toml index 5bcf5c2c3..beee0ca73 100644 --- a/rust/psibase_names/Cargo.toml +++ b/rust/psibase_names/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "psibase_names" -version.workspace = true +version = "0.6.0" rust-version.workspace = true repository.workspace = true homepage.workspace = true diff --git a/rust/scripts/publish.sh b/rust/scripts/publish.sh new file mode 100755 index 000000000..626aa1f60 --- /dev/null +++ b/rust/scripts/publish.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Run with +# `./scripts/publish.sh` +# Can also dry-run with: +# `./scripts/publish.sh --dry-run` + +###### +# ~ Dependencies ~ +# +# ,---> fracpack -->--, +# cargo-psibase --> psibase --| | +# |--->---------------'--> psibase-macros -->--, +# | | +# '--->-----------------------------------------'--> psibase-names +###### + +# Dependencies above imply the following publish order: +dirs=(psibase_names psibase_macros fracpack psibase cargo-psibase) + +cd "$(dirname "$0")/../" + +# Ensure each crate builds +for dir in "${dirs[@]}"; do + cd "$dir" || exit + echo "Building $dir..." + cargo build || exit + cd .. +done + +# Now publish each crate +for dir in "${dirs[@]}"; do + cd "$dir" + echo "Publishing $dir..." + cargo publish $1 + cd .. +done diff --git a/rust/scripts/set-version.sh b/rust/scripts/set-version.sh new file mode 100755 index 000000000..60c549a53 --- /dev/null +++ b/rust/scripts/set-version.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Run with +# `./scripts/set-version.sh x.y.z` +# Can also dry-run with: +# `./scripts/set-version.sh x.y.z --dry-run` + +cargo set-version "$@" --workspace \ No newline at end of file diff --git a/rust/test_contract/Cargo.toml b/rust/test_contract/Cargo.toml index 23af7f533..4154925ad 100644 --- a/rust/test_contract/Cargo.toml +++ b/rust/test_contract/Cargo.toml @@ -11,6 +11,6 @@ publish = false crate-type = ["cdylib"] [dependencies] -psibase = { path = "../psibase" } +psibase = { version = "0.6.0", path = "../psibase" } serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/rust/test_contract_2/Cargo.toml b/rust/test_contract_2/Cargo.toml new file mode 100644 index 000000000..7b6dedbfc --- /dev/null +++ b/rust/test_contract_2/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "example" +version.workspace = true +rust-version.workspace = true +repository.workspace = true +homepage.workspace = true +edition = "2021" +publish = false + +[lib] +path = "src/lib.rs" +crate-type = ["cdylib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies] +psibase_macros = { version = "0.6.0", path = "../psibase_macros" } +psibase = { version = "0.6.0", path = "../psibase" } +serde = { version = "1", features = ["derive"] } +async-graphql = "4.0" diff --git a/rust/test_contract_2/src/lib.rs b/rust/test_contract_2/src/lib.rs new file mode 100644 index 000000000..3dfd2f432 --- /dev/null +++ b/rust/test_contract_2/src/lib.rs @@ -0,0 +1,80 @@ + +/// This is another example service that adds and multiplies `i32` +/// numbers, similar to test_contract. This service has additional +/// features such as writing tables, and providing a graphiql +/// query interface. +#[psibase::service] +#[allow(non_snake_case)] +mod service { + use psibase::*; + use serde::{Serialize, Deserialize}; + use async_graphql::*; + + /// Holds an answer to a calculation done by an account `id` + #[table(name="AnswerTable", index=0)] + #[derive(Fracpack, Reflect, Serialize, Deserialize, SimpleObject)] + pub struct Answer { + + /// The account responsible for the calculation + #[primary_key] + id: AccountNumber, + + /// The result of the calculation + result: i32, + } + + #[action] + pub fn add(a: i32, b: i32) -> i32 { + let res = a + b; + + let answer_table = AnswerTable::new(); + answer_table.put(&Answer{ + id : get_sender(), + result : res, + }).unwrap(); + + res + + } + + #[action] + pub fn multiply(a: i32, b: i32) -> i32 { + let res = a * b; + + let answer_table = AnswerTable::new(); + answer_table.put(&Answer{ + id : get_sender(), + result : res, + }).unwrap(); + + res + } + + struct Query; + + #[Object] + impl Query { + /// Get the answer to `account`'s most recent calculation + async fn answer(&self, account : AccountNumber) -> Option { + AnswerTable::new().get_index_pk().get(&account) + } + } + + #[action] + #[allow(non_snake_case)] + fn serveSys(request: HttpRequest) -> Option { + None.or_else(|| serve_simple_ui::(&request)) + .or_else(|| serve_graphql(&request, Query)) + .or_else(|| serve_graphiql(&request)) + } +} + +// TODO: testing not working +// #[psibase::test_case(services("example"))] +// fn test_arith(chain: psibase::Chain) -> Result<(), psibase::Error> { +// let result = Wrapper::push(&chain).add(3, 4); +// assert_eq!(result.get()?, 7); +// println!("\n\nTrace:\n{}", result.trace); + +// Ok(()) +// } diff --git a/rust/test_fracpack/Cargo.toml b/rust/test_fracpack/Cargo.toml index d8d50be6f..b292a74bd 100644 --- a/rust/test_fracpack/Cargo.toml +++ b/rust/test_fracpack/Cargo.toml @@ -9,9 +9,9 @@ publish = false [dependencies] cxx = "1.0" -fracpack = { path = "../fracpack" } +fracpack = { version = "0.6.0", path = "../fracpack" } hex = "0.3.1" -psibase_macros = { path = "../psibase_macros" } +psibase_macros = { version = "0.6.0", path = "../psibase_macros" } [build-dependencies] cxx-build = "1.0" diff --git a/rust/test_service_elections/Cargo.toml b/rust/test_service_elections/Cargo.toml index b7c3f48ad..5b064870e 100644 --- a/rust/test_service_elections/Cargo.toml +++ b/rust/test_service_elections/Cargo.toml @@ -11,6 +11,6 @@ publish = false crate-type = ["cdylib"] [dependencies] -fracpack = { path = "../fracpack" } -psibase = { path = "../psibase" } +fracpack = { version = "0.6.0", path = "../fracpack" } +psibase = { version = "0.6.0", path = "../psibase" } serde = { version = "1.0.145", features = ["derive"] } diff --git a/rust/test_service_psispace/Cargo.toml b/rust/test_service_psispace/Cargo.toml index b4297a440..aed9b011c 100644 --- a/rust/test_service_psispace/Cargo.toml +++ b/rust/test_service_psispace/Cargo.toml @@ -12,7 +12,7 @@ crate-type = ["cdylib"] [dependencies] async-graphql = "4.0" -fracpack = { path = "../fracpack" } -psibase = { path = "../psibase" } +fracpack = { version = "0.6.0", path = "../fracpack" } +psibase = { version = "0.6.0", path = "../psibase" } serde = { version = "1.0.145", features = ["derive"] } serde_json = "1.0" diff --git a/services/user/NftSys/src/NftSys.cpp b/services/user/NftSys/src/NftSys.cpp index 260444415..8f36b29f7 100644 --- a/services/user/NftSys/src/NftSys.cpp +++ b/services/user/NftSys/src/NftSys.cpp @@ -5,6 +5,8 @@ #include #include +#include + using namespace psibase; using namespace UserService; using namespace Errors; @@ -307,7 +309,7 @@ PSIO_REFLECT(NftQuery, std::optional NftSys::serveSys(psibase::HttpRequest request) { - if (auto result = servePackAction(request)) + if (auto result = serveSimpleUI(request)) return result; if (auto result = serveGraphQL(request, NftQuery{})) return result; diff --git a/services/user/SymbolSys/src/SymbolSys.cpp b/services/user/SymbolSys/src/SymbolSys.cpp index 6a8c11897..0b255bc73 100644 --- a/services/user/SymbolSys/src/SymbolSys.cpp +++ b/services/user/SymbolSys/src/SymbolSys.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "services/user/NftSys.hpp" #include "services/user/TokenSys.hpp" @@ -325,7 +326,7 @@ PSIO_REFLECT(SymbolQuery, optional SymbolSys::serveSys(HttpRequest request) { - if (auto result = servePackAction(request)) + if (auto result = serveSimpleUI(request)) return result; if (auto result = serveGraphQL(request, SymbolQuery{})) return result;