From 36d9a0c297331d3dc40c8df5a67422f33532d069 Mon Sep 17 00:00:00 2001 From: Ari Seyhun Date: Tue, 14 Mar 2023 08:39:47 +0000 Subject: [PATCH] Submillisecond control server (#185) * Add lunatic-control crate * Add lunatic-control-submillisecond crate * Add separate test certificate functions * Add control server host functions * Add sqlite persistence to control server * Remove module test insert * Implement bind for nulls * Fix serde_json::Value not working with Bincode in ControlServer abstract process * Use git dependencies in lunatic-control-submillisecond * Add control server readme * Fix formatting in Cargo.toml file --- .gitignore | 1 + Cargo.lock | 365 ++- Cargo.toml | 16 +- crates/lunatic-common-api/src/lib.rs | 26 +- crates/lunatic-control-axum/Cargo.toml | 5 +- crates/lunatic-control-axum/src/routes.rs | 6 +- crates/lunatic-control-axum/src/server.rs | 28 +- .../.cargo/config.toml | 5 + .../lunatic-control-submillisecond/.gitignore | 1 + .../lunatic-control-submillisecond/Cargo.lock | 2750 +++++++++++++++++ .../lunatic-control-submillisecond/Cargo.toml | 25 + .../lunatic-control-submillisecond/README.md | 26 + .../lunatic-control-submillisecond/src/api.rs | 278 ++ .../src/host.rs | 75 + .../src/main.rs | 40 + .../src/routes.rs | 138 + .../src/server.rs | 232 ++ .../src/server/store.rs | 213 ++ crates/lunatic-control/Cargo.toml | 12 + .../control => lunatic-control/src}/api.rs | 3 +- crates/lunatic-control/src/lib.rs | 12 + crates/lunatic-distributed-api/Cargo.toml | 2 + crates/lunatic-distributed-api/src/lib.rs | 148 +- crates/lunatic-distributed/Cargo.toml | 3 +- .../lunatic-distributed/src/control/cert.rs | 38 +- .../lunatic-distributed/src/control/client.rs | 4 +- crates/lunatic-distributed/src/control/mod.rs | 1 - .../src/distributed/client.rs | 2 +- .../src/distributed/server.rs | 16 +- crates/lunatic-distributed/src/lib.rs | 10 +- crates/lunatic-sqlite-api/Cargo.toml | 20 +- .../lunatic-sqlite-api/src/sqlite_bindings.rs | 62 +- .../src/wire_format/bind_values/host_api.rs | 4 +- 33 files changed, 4243 insertions(+), 324 deletions(-) create mode 100644 crates/lunatic-control-submillisecond/.cargo/config.toml create mode 100644 crates/lunatic-control-submillisecond/.gitignore create mode 100644 crates/lunatic-control-submillisecond/Cargo.lock create mode 100644 crates/lunatic-control-submillisecond/Cargo.toml create mode 100644 crates/lunatic-control-submillisecond/README.md create mode 100644 crates/lunatic-control-submillisecond/src/api.rs create mode 100644 crates/lunatic-control-submillisecond/src/host.rs create mode 100644 crates/lunatic-control-submillisecond/src/main.rs create mode 100644 crates/lunatic-control-submillisecond/src/routes.rs create mode 100644 crates/lunatic-control-submillisecond/src/server.rs create mode 100644 crates/lunatic-control-submillisecond/src/server/store.rs create mode 100644 crates/lunatic-control/Cargo.toml rename crates/{lunatic-distributed/src/control => lunatic-control/src}/api.rs (99%) create mode 100644 crates/lunatic-control/src/lib.rs diff --git a/.gitignore b/.gitignore index e0489541a..6017cd968 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ debug.log notes-*.md publish.sh +control_server.db diff --git a/Cargo.lock b/Cargo.lock index d5c5c24b2..0abab3bac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,9 +66,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "asn1-rs" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6690c370453db30743b373a60ba498fc0d6d83b11f4abfd87a84a075db5dd4" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", @@ -114,9 +114,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", @@ -151,9 +151,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6137c6234afb339e75e764c866e3594900f0211e1315d33779f269bbe2ec6967" +checksum = "13d8068b6ccb8b34db9de397c7043f91db8b4c66414952c6db944f238c4d3db3" dependencies = [ "async-trait", "axum-core", @@ -178,16 +178,15 @@ dependencies = [ "sync_wrapper", "tokio", "tower", - "tower-http 0.4.0", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cae3e661676ffbacb30f1a824089a8c9150e71017f7e1e38f2aa32009188d34" +checksum = "b2f958c80c248b34b9a877a643811be8dbca03ca5ba827f2b63baf3a81e5fc4e" dependencies = [ "async-trait", "bytes", @@ -202,9 +201,9 @@ dependencies = [ [[package]] name = "axum-macros" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fbf955307ff8addb48d2399393c9e2740dd491537ec562b66ab364fc4a38841" +checksum = "39bcef27b56d5cad8912d735d5ed1286f073f7bcb88cc31b38a15b514fcf8600" dependencies = [ "heck", "proc-macro2", @@ -250,9 +249,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -362,9 +361,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "num-integer", @@ -503,18 +502,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b18cf92869a6ae85cde3af4bc4beb6154efa8adef03b18db2ad413d5bce3a2" +checksum = "a7379abaacee0f14abf3204a7606118f0465785252169d186337bcb75030815a" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567d9f6e919bac076f39b902a072686eaf9e6d015baa34d10a61b85105b7af59" +checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b" dependencies = [ "arrayvec", "bumpalo", @@ -533,33 +532,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e72b2d5ec8917b2971fe83850187373d0a186db4748a7c23a5f48691b8d92bb" +checksum = "05bbb67da91ec721ed57cef2f7c5ef7728e1cd9bde9ffd3ef8601022e73e3239" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3461c0e0c2ebbeb92533aacb27e219289f60dc84134ef34fbf2d77c9eddf07ef" +checksum = "418ecb2f36032f6665dc1a5e2060a143dbab41d83b784882e97710e890a7a16d" [[package]] name = "cranelift-entity" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af684f7f7b01427b1942c7102673322a51b9d6f261e9663dc5e5595786775531" +checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d361ed0373cf5f086b49c499aa72227b646a64f899f32e34312f97c0fadff75" +checksum = "0b66bf9e916f57fbbd0f7703ec6286f4624866bf45000111627c70d272c8dda1" dependencies = [ "cranelift-codegen", "log", @@ -569,15 +568,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef4f8f3984d772c199a48896d2fb766f96301bf71b371e03a2b99f4f3b7b931" +checksum = "649782a39ce99798dd6b4029e2bb318a2fbeaade1b4fa25330763c10c65bc358" [[package]] name = "cranelift-native" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98e4e99a353703475d5acb402b9c13482d41d8a4008b352559bd560afb90363" +checksum = "937e021e089c51f9749d09e7ad1c4f255c2f8686cb8c3df63a34b3ec9921bc41" dependencies = [ "cranelift-codegen", "libc", @@ -586,9 +585,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e3f4f0779a1b0f286a6ef19835d8665f88326e656a6d7d84fa9a39fa38ca32" +checksum = "d850cf6775477747c9dfda9ae23355dd70512ffebc70cf82b85a5b111ae668b5" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -712,9 +711,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" dependencies = [ "cc", "cxxbridge-flags", @@ -724,9 +723,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" dependencies = [ "cc", "codespan-reporting", @@ -739,15 +738,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" [[package]] name = "cxxbridge-macro" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", "quote", @@ -775,9 +774,9 @@ checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" [[package]] name = "der-parser" -version = "8.1.0" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d4bc9b0db0a0df9ae64634ac5bdefb7afcb534e182275ca0beadbe486701c1" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ "asn1-rs", "displaydoc", @@ -990,9 +989,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" dependencies = [ "futures-channel", "futures-core", @@ -1004,9 +1003,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", "futures-sink", @@ -1014,33 +1013,33 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" [[package]] name = "futures-io" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ "futures-core", "futures-sink", @@ -1206,9 +1205,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.24" +version = "0.14.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" dependencies = [ "bytes", "futures-channel", @@ -1313,9 +1312,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" dependencies = [ "libc", "windows-sys 0.45.0", @@ -1350,9 +1349,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "ittapi" @@ -1406,9 +1405,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "link-cplusplus" @@ -1452,6 +1451,14 @@ dependencies = [ "wasmtime", ] +[[package]] +name = "lunatic-control" +version = "0.12.0" +dependencies = [ + "serde", + "uuid", +] + [[package]] name = "lunatic-control-axum" version = "0.12.0" @@ -1464,12 +1471,13 @@ dependencies = [ "getrandom", "http", "log", + "lunatic-control", "lunatic-distributed", "rcgen", "serde", "serde_json", "tokio", - "tower-http 0.3.5", + "tower-http", "uuid", ] @@ -1482,6 +1490,7 @@ dependencies = [ "bytes", "dashmap", "log", + "lunatic-control", "lunatic-process", "quinn", "rcgen", @@ -1500,12 +1509,14 @@ name = "lunatic-distributed-api" version = "0.12.0" dependencies = [ "anyhow", + "bincode", "log", "lunatic-common-api", "lunatic-distributed", "lunatic-error-api", "lunatic-process", "lunatic-process-api", + "rcgen", "rmp-serde", "tokio", "wasmtime", @@ -1618,6 +1629,7 @@ dependencies = [ "env_logger 0.9.3", "hash-map-id", "log", + "lunatic-control", "lunatic-control-axum", "lunatic-distributed", "lunatic-distributed-api", @@ -2038,9 +2050,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pem" @@ -2161,9 +2173,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] @@ -2256,9 +2268,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -2304,9 +2316,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -2314,9 +2326,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -2483,9 +2495,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.8" +version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ "bitflags", "errno", @@ -2532,15 +2544,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -2568,9 +2580,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -2607,18 +2619,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.152" +version = "1.0.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" dependencies = [ "proc-macro2", "quote", @@ -2627,9 +2639,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" dependencies = [ "itoa", "ryu", @@ -2638,9 +2650,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b04f22b563c91331a10074bda3dd5492e3cc39d56bd557e91c0af42b6c7341" +checksum = "db0969fff533976baadd92e08b1d102c5a3d8a8049eadfd69d4d1e3c5b2ed189" dependencies = [ "serde", ] @@ -2706,9 +2718,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -2849,18 +2861,18 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", @@ -3026,25 +3038,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "tower-http" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" -dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-layer" version = "0.3.2" @@ -3113,15 +3106,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -3218,9 +3211,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f7c5b2a394b5f6affc28f3b6c08010cd03458cdb7509b02a6a70771f6873635" +checksum = "6e90aedcb27963f120aaa7d27216c463f7e8a4f8277434dac88c836a856325dd" dependencies = [ "anyhow", "async-trait", @@ -3242,9 +3235,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "101bb1e5f6cf20b27055006af27f9c6e6a09084469d197ec0cb5884da38968a7" +checksum = "ae6ce6df8b37388a7772aacb9c5d4e9384f97f0abb1984983f892471c952e5be" dependencies = [ "anyhow", "bitflags", @@ -3327,9 +3320,9 @@ checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasm-encoder" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f7d56227d910901ce12dfd19acc40c12687994dfb3f57c90690f80be946ec5" +checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" dependencies = [ "leb128", ] @@ -3346,9 +3339,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9010891d0b8e367c3be94ca35d7bc25c1de3240463bb1d61bcfc8c2233c4e0d0" +checksum = "f6e89f9819523447330ffd70367ef4a18d8c832e24e8150fe054d1d912841632" dependencies = [ "anyhow", "async-trait", @@ -3378,18 +3371,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65805c663eaa8257b910666f6d4b056b5c7329750da754ba5df54f3af7dbf35c" +checksum = "9bd3a5e46c198032da934469f3a6e48649d1f9142438e4fd4617b68a35644b8a" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2049ddfc1b10efc3c5591d0e84b9570ca50478f8818f3bfabb1a467918f53fb4" +checksum = "b389ae9b678b9c3851091a4804f4182d688d27aff7abc9aa37fa7be37d8ecffa" dependencies = [ "anyhow", "base64 0.13.1", @@ -3407,9 +3400,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9086679497e0a0b441d47ebb4781def9fed3d224feee913464a9a9e2950bac89" +checksum = "059ded8e36aa047039093fb3203e719864b219ba706ef83115897208c45c7227" dependencies = [ "anyhow", "proc-macro2", @@ -3422,15 +3415,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a3dd61938af6e06b60b9c5b916b48c9d2b77102e80559fcb4e5afb0c5f5bfdf" +checksum = "925da75e4b2ba3a45671238037f8b496418c092dff287503ca4375824a234024" [[package]] name = "wasmtime-cranelift" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9065cad6a724fa838ec8497567e0b23acc26417bb2449f8d9d2021925c72f2" +checksum = "59b2c92a08c0db6efffd88fdc97d7aa9c7c63b03edb0971dbca745469f820e8c" dependencies = [ "anyhow", "cranelift-codegen", @@ -3449,9 +3442,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f964bb0b91fa021b8d1b488c62cc77b346c1dae6e3ebd010050b57c1f2ca657" +checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" dependencies = [ "anyhow", "cranelift-entity", @@ -3468,9 +3461,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9172517a3331b2a486266f7e16b637b27db6cdf5cddf7d055cd145da14cada46" +checksum = "07739b74248aa609a51061956735e3e394cc9e0fe475e8f821bc837f12d5e547" dependencies = [ "cc", "cfg-if", @@ -3481,9 +3474,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7a1d06f5d109539e0168fc74fa65e3948ac8dac3bb8cdbd08b62b36a0ae27b8" +checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" dependencies = [ "addr2line", "anyhow", @@ -3506,9 +3499,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76ef2e410329aaf8555ac6571d6fe07711be0646dcdf7ff3ab750a42ed2e583" +checksum = "d0245e8a9347017c7185a72e215218a802ff561545c242953c11ba00fccc930f" dependencies = [ "object", "once_cell", @@ -3517,9 +3510,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec1fd0f0dd79e7cc0f55b102e320d7c77ab76cd272008a8fd98e25b5777e2636" +checksum = "67d412e9340ab1c83867051d8d1d7c90aa8c9afc91da086088068e2734e25064" dependencies = [ "cfg-if", "libc", @@ -3528,9 +3521,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271aef9b4ca2e953a866293683f2db33cda46f6933c5e431e68d8373723d4ab6" +checksum = "d594e791b5fdd4dbaf8cf7ae62f2e4ff85018ce90f483ca6f42947688e48827d" dependencies = [ "anyhow", "cc", @@ -3553,9 +3546,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b18144b0e45479a830ac9fcebfc71a16d90dc72d8ebd5679700eb3bfe974d7df" +checksum = "a6688d6f96d4dbc1f89fab626c56c1778936d122b5f4ae7a57c2eb42b8d982e2" dependencies = [ "cranelift-entity", "serde", @@ -3565,9 +3558,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b1bc5cfbbfb4636702aa95d164f8f53bafb9c13e531789edc9e1ce5d4066b29" +checksum = "38e749611f4ea64f19ad4da2324c86043f49ad946e6cc4ce057308d1319b2ba6" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -3578,9 +3571,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92eb1c58cfa115b29e04ff3882ecbd1c8b6db3639b200c72418be5fd43eab3ff" +checksum = "c85c2889e5b4fd2713f02238c7bce6bd4a7e901e1ef251f8b414d5d9449167ea" dependencies = [ "anyhow", "heck", @@ -3598,9 +3591,9 @@ dependencies = [ [[package]] name = "wast" -version = "54.0.1" +version = "55.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d48d9d731d835f4f8dacbb8de7d47be068812cb9877f5c60d408858778d8d2a" +checksum = "4984d3e1406571f4930ba5cf79bd70f75f41d0e87e17506e0bd19b0e5d085f05" dependencies = [ "leb128", "memchr", @@ -3610,11 +3603,11 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1db2e3ed05ea31243761439194bec3af6efbbaf87c4c8667fb879e4f23791a0" +checksum = "af2b53f4da14db05d32e70e9c617abdf6620c575bd5dd972b7400037b4df2091" dependencies = [ - "wast 54.0.1", + "wast 55.0.0", ] [[package]] @@ -3648,9 +3641,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ac5d1216c18d8ee0a6bf37509d2061b17c8c5b11c405b0073108a041438f05" +checksum = "ba2420f80af94fc0e6f54ec45de6f6eb5b06b9b9ad2d1bd1923ed8a1288031b4" dependencies = [ "anyhow", "async-trait", @@ -3664,9 +3657,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebca53f8c1f32e202dfd63f0b18bf01a5a9680e526b626758aa7678af04b2c18" +checksum = "93b0e0ff7e9d9c0b390475c07eedfeddb4e4259baba00032dacfe079616b689a" dependencies = [ "anyhow", "heck", @@ -3679,9 +3672,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3bec97d55f7a62d8d45d76fff91af294196b4aa9d1f45cd6784a964c84c067f" +checksum = "750332a587ddc8372d260ea1792a276b1c908cd93782e2da30c19db075d4d7a8" dependencies = [ "proc-macro2", "quote", @@ -3746,9 +3739,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -3761,45 +3754,45 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winreg" @@ -3823,9 +3816,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b48914ea89d43d7b51fed072143b86b499059a85e27b401e6cdbd0ca1f0c1dc9" +checksum = "f887c3da527a51b321076ebe6a7513026a4757b6d4d144259946552d6fc728b3" dependencies = [ "anyhow", "id-arena", diff --git a/Cargo.toml b/Cargo.toml index 673ad3124..3c0f69ce1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ prometheus = ["dep:metrics-exporter-prometheus", "metrics"] [dependencies] hash-map-id = { workspace = true } +lunatic-control = { workspace = true } lunatic-control-axum = { workspace = true } lunatic-distributed = { workspace = true } lunatic-distributed-api = { workspace = true } @@ -67,7 +68,7 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread", "net"] } toml = "0.5" uuid = { workspace = true } wasmtime = { workspace = true } -wasmtime-wasi = {workspace = true } +wasmtime-wasi = { workspace = true } [dev-dependencies] criterion = { version = "0.4", features = ["async_tokio"] } @@ -82,7 +83,9 @@ name = "benchmark" members = [ "crates/hash-map-id", "crates/lunatic-common-api", + "crates/lunatic-control", "crates/lunatic-control-axum", + # "crates/lunatic-control-submillisecond", "crates/lunatic-distributed-api", "crates/lunatic-distributed", "crates/lunatic-error-api", @@ -101,24 +104,27 @@ members = [ [workspace.dependencies] hash-map-id = { path = "crates/hash-map-id", version = "0.12" } lunatic-common-api = { path = "crates/lunatic-common-api", version = "0.13" } +lunatic-control = { path = "crates/lunatic-control", version = "0.12" } lunatic-control-axum = { path = "crates/lunatic-control-axum", version = "0.12" } +lunatic-control-submillisecond = { path = "crates/lunatic-control-submillisecond", version = "0.12" } lunatic-distributed = { path = "crates/lunatic-distributed", version = "0.12" } lunatic-distributed-api = { path = "crates/lunatic-distributed-api", version = "0.12" } lunatic-error-api = { path = "crates/lunatic-error-api", version = "0.13" } lunatic-messaging-api = { path = "crates/lunatic-messaging-api", version = "0.12" } +lunatic-metrics-api = { path = "crates/lunatic-metrics-api", version = "0.12" } lunatic-networking-api = { path = "crates/lunatic-networking-api", version = "0.13" } lunatic-process = { path = "crates/lunatic-process", version = "0.13" } lunatic-process-api = { path = "crates/lunatic-process-api", version = "0.13" } lunatic-registry-api = { path = "crates/lunatic-registry-api", version = "0.12" } +lunatic-sqlite-api = { path = "crates/lunatic-sqlite-api", version = "0.13" } lunatic-stdout-capture = { path = "crates/lunatic-stdout-capture", version = "0.13" } lunatic-timer-api = { path = "crates/lunatic-timer-api", version = "0.12" } +lunatic-trap-api = { path = "crates/lunatic-trap-api", version = "0.12" } lunatic-version-api = { path = "crates/lunatic-version-api", version = "0.12" } -lunatic-metrics-api = { path = "crates/lunatic-metrics-api", version = "0.12" } lunatic-wasi-api = { path = "crates/lunatic-wasi-api", version = "0.13" } -lunatic-trap-api = { path = "crates/lunatic-trap-api", version = "0.12" } -lunatic-sqlite-api = { path = "crates/lunatic-sqlite-api", version = "0.13" } anyhow = "1.0" +bincode = "1.3" dashmap = "5.4" log = "0.4" metrics = "0.20.1" @@ -126,7 +132,7 @@ reqwest = "0.11" rustls-pemfile = "1.0" serde = "1.0" tokio = "1.20" -uuid = {version = "1.1", features = ["v4"]} +uuid = { version = "1.1", features = ["v4"] } wasi-common = "6" wasmtime = "6" wasmtime-wasi = "6" diff --git a/crates/lunatic-common-api/src/lib.rs b/crates/lunatic-common-api/src/lib.rs index e4cf28d03..277e4791c 100644 --- a/crates/lunatic-common-api/src/lib.rs +++ b/crates/lunatic-common-api/src/lib.rs @@ -1,5 +1,5 @@ -use anyhow::{anyhow, Result}; -use std::{fmt::Display, future::Future, pin::Pin}; +use anyhow::{anyhow, Context, Result}; +use std::{fmt::Display, future::Future, io::Write, pin::Pin}; use wasmtime::{Caller, Memory, Val}; const ALLOCATOR_FUNCTION_NAME: &str = "lunatic_alloc"; @@ -56,6 +56,28 @@ pub fn free_guest_memory<'a, T: Send>( }) } +// Allocates and writes data to guest memory, updating the len_ptr and returning the allocated ptr. +pub async fn write_to_guest_vec( + caller: &mut Caller<'_, T>, + memory: &Memory, + data: &[u8], + len_ptr: u32, +) -> Result { + let alloc_len = data.len(); + let alloc_ptr = allocate_guest_memory(caller, alloc_len as u32).await?; + + let (memory_slice, _) = memory.data_and_store_mut(&mut (*caller)); + let mut alloc_vec = memory_slice + .get_mut(alloc_ptr as usize..(alloc_ptr as usize + alloc_len)) + .context("allocated memory does not exist")?; + + alloc_vec.write_all(data)?; + + memory.write(caller, len_ptr as usize, &alloc_len.to_le_bytes())?; + + Ok(alloc_ptr) +} + pub trait IntoTrap { fn or_trap(self, info: S) -> Result; } diff --git a/crates/lunatic-control-axum/Cargo.toml b/crates/lunatic-control-axum/Cargo.toml index 7d82dab55..369bffe3e 100644 --- a/crates/lunatic-control-axum/Cargo.toml +++ b/crates/lunatic-control-axum/Cargo.toml @@ -8,13 +8,14 @@ repository = "https://github.com/lunatic-solutions/lunatic/tree/main/crates" license = "Apache-2.0/MIT" [dependencies] +lunatic-control = { workspace = true } lunatic-distributed = { workspace = true } anyhow = { workspace = true } -axum = { version = "0.6", features = ["json", "query", "macros" ] } +axum = { version = "0.6", features = ["json", "query", "macros"] } tower-http = { version = "0.3.0", features = ["limit"] } base64-url = "1.4.13" -chrono = { version = "0.4.23", default-features = false, features = ["clock", "std" ]} +chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] } dashmap = { workspace = true } getrandom = "0.2.8" http = "0.2.8" diff --git a/crates/lunatic-control-axum/src/routes.rs b/crates/lunatic-control-axum/src/routes.rs index 943071aac..84ca9db5a 100644 --- a/crates/lunatic-control-axum/src/routes.rs +++ b/crates/lunatic-control-axum/src/routes.rs @@ -6,10 +6,8 @@ use axum::{ routing::{get, post}, Extension, Json, Router, }; -use lunatic_distributed::{ - control::{api::*, cert::TEST_ROOT_CERT}, - NodeInfo, -}; +use lunatic_control::{api::*, NodeInfo}; +use lunatic_distributed::control::cert::TEST_ROOT_CERT; use rcgen::CertificateSigningRequest; use tower_http::limit::RequestBodyLimitLayer; diff --git a/crates/lunatic-control-axum/src/server.rs b/crates/lunatic-control-axum/src/server.rs index 9ba342fb5..156c29e79 100644 --- a/crates/lunatic-control-axum/src/server.rs +++ b/crates/lunatic-control-axum/src/server.rs @@ -10,12 +10,23 @@ use anyhow::Result; use axum::{Extension, Router}; use chrono::{DateTime, Utc}; use dashmap::DashMap; -use lunatic_distributed::control::api::{NodeStart, Register}; +use lunatic_control::api::{NodeStart, Register}; use rcgen::Certificate; use uuid::Uuid; use crate::routes; +pub struct ControlServer { + pub ca_cert: Certificate, + pub quic_client: lunatic_distributed::quic::Client, + pub registrations: DashMap, + pub nodes: DashMap, + pub modules: DashMap>, + next_registration_id: AtomicU64, + next_node_id: AtomicU64, + next_module_id: AtomicU64, +} + #[derive(Clone)] pub struct Registered { pub node_name: Uuid, @@ -33,17 +44,6 @@ pub struct NodeDetails { pub attributes: serde_json::Value, } -pub struct ControlServer { - pub ca_cert: Certificate, - pub quic_client: lunatic_distributed::quic::Client, - pub registrations: DashMap, - pub nodes: DashMap, - pub modules: DashMap>, - next_registration_id: AtomicU64, - next_node_id: AtomicU64, - next_module_id: AtomicU64, -} - impl ControlServer { pub fn new(ca_cert: Certificate, quic_client: lunatic_distributed::quic::Client) -> Self { Self { @@ -100,8 +100,8 @@ impl ControlServer { } fn prepare_app() -> Result { - let ca_cert_str = lunatic_distributed::distributed::server::root_cert(true, None)?; - let ca_cert = lunatic_distributed::control::cert::root_cert(true, None, None).unwrap(); + let ca_cert_str = lunatic_distributed::distributed::server::test_root_cert(); + let ca_cert = lunatic_distributed::control::cert::test_root_cert()?; let (ctrl_cert, ctrl_pk) = lunatic_distributed::control::cert::default_server_certificates(&ca_cert)?; let quic_client = diff --git a/crates/lunatic-control-submillisecond/.cargo/config.toml b/crates/lunatic-control-submillisecond/.cargo/config.toml new file mode 100644 index 000000000..ee70f483b --- /dev/null +++ b/crates/lunatic-control-submillisecond/.cargo/config.toml @@ -0,0 +1,5 @@ +[build] +target = "wasm32-wasi" + +[target.wasm32-wasi] +runner = "lunatic run" diff --git a/crates/lunatic-control-submillisecond/.gitignore b/crates/lunatic-control-submillisecond/.gitignore new file mode 100644 index 000000000..ea8c4bf7f --- /dev/null +++ b/crates/lunatic-control-submillisecond/.gitignore @@ -0,0 +1 @@ +/target diff --git a/crates/lunatic-control-submillisecond/Cargo.lock b/crates/lunatic-control-submillisecond/Cargo.lock new file mode 100644 index 000000000..c21f57af4 --- /dev/null +++ b/crates/lunatic-control-submillisecond/Cargo.lock @@ -0,0 +1,2750 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "ambient-authority" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ad6edb4840b78c5c3d88de606b22252d552b55f3a4699fbb10fc070ec3049" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-trait" +version = "0.1.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64-url" +version = "1.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a99c239d0c7e77c85dddfa9cebce48704b3c49550fcd3b84dd637e4484899f" +dependencies = [ + "base64 0.13.1", +] + +[[package]] +name = "better-bae" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42256f0525b8d9cb8e6573ba850478df93ba34ddd7bf64eeb47ff19a8422bc5" +dependencies = [ + "better-bae-macros", + "proc-macro2", + "syn", +] + +[[package]] +name = "better-bae-macros" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0f3144c211af9910842422e6835938ff01895bca8c143e28dcebdd23eb2dbc" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cap-fs-ext" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff40fd8a96d57a204080e5debd621342612f6d6b60901201a51f518baf72691d" +dependencies = [ + "cap-primitives", + "cap-std", + "io-lifetimes", + "windows-sys 0.45.0", +] + +[[package]] +name = "cap-primitives" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9554a7698c8db4b7777f01b2237de111c5ecea169efb1190004d9069ceb289aa" +dependencies = [ + "ambient-authority", + "fs-set-times", + "io-extras", + "io-lifetimes", + "ipnet", + "maybe-owned", + "rustix", + "windows-sys 0.45.0", + "winx", +] + +[[package]] +name = "cap-rand" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "103e94d97d73504c5fa6ffb47135d5627ce5ff84a4ad37e8219103ddc291de24" +dependencies = [ + "ambient-authority", + "rand", +] + +[[package]] +name = "cap-std" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7b68a8ac703cc7bed0a46666a04b386cca214844897a69f599dcd82ea59422c" +dependencies = [ + "cap-primitives", + "io-extras", + "io-lifetimes", + "ipnet", + "rustix", +] + +[[package]] +name = "cap-time-ext" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "472931750f90fbf0731c886c2937521e25772942577a182e7ace5bc561d10e3b" +dependencies = [ + "cap-primitives", + "once_cell", + "rustix", + "winx", +] + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "serde", + "time", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "convert_case" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-bforest" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cb658ef043a07ea4086c65f2e3d770b5dc60b8787a9ef54cf06d792cf613d82" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b36618d7ab9ad5da72935623292d364b5482ef42141e0145c0090bfc7f6b8dca" +dependencies = [ + "arrayvec", + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb7cab168dac35a2fc53a3591ee36d145d7fc2ebbdb5c70f1f9e35764157af5a" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcbdd64e35dfb910ff709e5b2d5e1348f626837685673726d985a620b9d8de5" + +[[package]] +name = "cranelift-entity" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9e39cfc857e7e539aa623e03bb6bec11f54aef3dfdef41adcfa7b594af3b54" +dependencies = [ + "serde", +] + +[[package]] +name = "cranelift-frontend" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78d28039844e3f7817e5a10cbb3d9adbc7188ee9cc4ba43536f304219fcfc077" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4183c68346d657c40ea06273cc0e9c3fe25f4e51e6decf534c079f34041c43c0" + +[[package]] +name = "cranelift-native" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dbf72319054ff725a26c579b4070187928ca38e55111b964723bdbacbb1993e" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.92.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3632b478ca00dfad77dbef3ce284f1199930519ab744827726a8e386a6db3f5" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset 0.8.0", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cxx" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dashmap" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" +dependencies = [ + "cfg-if", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "fd-lock" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ef1a30ae415c3a691a4f41afddc2dbcd6d70baf338368d85ebc1e8ed92cedb9" +dependencies = [ + "cfg-if", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "file-per-thread-logger" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" +dependencies = [ + "env_logger", + "log", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs-set-times" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" +dependencies = [ + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "hash-map-id" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9b18d12dd6839b1088e1618be94753c9002af636c26d4722d0fdb8118c4031" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "headers" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" +dependencies = [ + "base64 0.13.1", + "bitflags", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + +[[package]] +name = "io-extras" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d79107d6e60d78351e11f0a2dc9d0eaf304a7efb592e92603783afb8479c7d97" +dependencies = [ + "io-lifetimes", + "windows-sys 0.45.0", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "is-terminal" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "ittapi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e648c437172ce7d3ac35ca11a068755072054826fa455a916b43524fa4a62a7" +dependencies = [ + "anyhow", + "ittapi-sys", + "log", +] + +[[package]] +name = "ittapi-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9b32a4d23f72548178dde54f3c12c6b6a08598e25575c0d0fa5bd861e0dc1a5" +dependencies = [ + "cc", +] + +[[package]] +name = "jobserver" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" + +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lunatic" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca28bf24e13d6a921a4309768ac98efbbec1c3cb47f53b103af6e452d4370f09" +dependencies = [ + "bincode", + "lunatic-macros 0.12.0", + "lunatic-test 0.12.0", + "paste", + "serde", + "thiserror", +] + +[[package]] +name = "lunatic" +version = "0.13.0" +source = "git+https://github.com/lunatic-solutions/lunatic-rs#2a1210ebc87627908f49a82533c04acb4a96715a" +dependencies = [ + "bincode", + "lunatic-macros 0.13.0", + "lunatic-sqlite-api", + "lunatic-sys", + "lunatic-test 0.13.0", + "paste", + "serde", + "thiserror", +] + +[[package]] +name = "lunatic-common-api" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f80de581a7cb09986785ba1b8c4c1c89ab977545509a65182c38df718d2969d8" +dependencies = [ + "anyhow", + "wasmtime", +] + +[[package]] +name = "lunatic-control" +version = "0.12.0" +dependencies = [ + "serde", + "uuid", +] + +[[package]] +name = "lunatic-control-submillisecond" +version = "0.12.0" +dependencies = [ + "anyhow", + "base64-url", + "bincode", + "chrono", + "getrandom", + "lunatic 0.13.0", + "lunatic-control", + "lunatic-log 0.3.0 (git+https://github.com/lunatic-solutions/lunatic-log-rs?branch=lunatic-0-13-git)", + "serde", + "serde_json", + "submillisecond", + "uuid", +] + +[[package]] +name = "lunatic-error-api" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13fc77b40a51731788922c7370d4be50f7761b5abd62d86a6af1246db99f4c3b" +dependencies = [ + "anyhow", + "hash-map-id", + "lunatic-common-api", + "wasmtime", +] + +[[package]] +name = "lunatic-log" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b108cab8f10da677082ad72c35b6824ddecd533fdbc54960f247cbfcdfca648d" +dependencies = [ + "ansi_term", + "chrono", + "lunatic 0.12.1", + "serde", +] + +[[package]] +name = "lunatic-log" +version = "0.3.0" +source = "git+https://github.com/lunatic-solutions/lunatic-log-rs?branch=lunatic-0-13-git#1482d17fd95d9581b4978771a2cd61ac78187cf2" +dependencies = [ + "chrono", + "lunatic 0.13.0", + "serde", + "yansi", +] + +[[package]] +name = "lunatic-macros" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52122f17e685be82d3d938558b4f827ac0a1140adc39183af7a390298d79fd03" +dependencies = [ + "convert_case 0.5.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "lunatic-macros" +version = "0.13.0" +source = "git+https://github.com/lunatic-solutions/lunatic-rs#2a1210ebc87627908f49a82533c04acb4a96715a" +dependencies = [ + "convert_case 0.6.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "lunatic-networking-api" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dadd3702e2e74ed3e3ac16bfab2edd9e1c8b41f1cf977879335bbb6e0184d800" +dependencies = [ + "anyhow", + "hash-map-id", + "lunatic-common-api", + "lunatic-error-api", + "rustls-pemfile", + "tokio", + "tokio-rustls", + "wasmtime", + "webpki-roots", +] + +[[package]] +name = "lunatic-process" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e5e3870a96a9cfab05377a02408efbad1d60045f7c49f22eef066e7a64bf54d" +dependencies = [ + "anyhow", + "async-trait", + "dashmap", + "hash-map-id", + "log", + "lunatic-networking-api", + "serde", + "tokio", + "wasmtime", + "wasmtime-wasi", +] + +[[package]] +name = "lunatic-process-api" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1982e0445fae1a6f9eaa3ed48e66ab47725d6ed71aa6d55e05e28e00776af0" +dependencies = [ + "anyhow", + "hash-map-id", + "lunatic-common-api", + "lunatic-error-api", + "lunatic-process", + "lunatic-wasi-api", + "tokio", + "wasmtime", +] + +[[package]] +name = "lunatic-sqlite-api" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "541889638390fca366d0dd53310068741c2812029d77fe32a9345150b1d61097" +dependencies = [ + "anyhow", + "bincode", + "hash-map-id", + "lunatic-common-api", + "lunatic-error-api", + "lunatic-process", + "lunatic-process-api", + "serde", + "sqlite-bindings-lunatic", + "wasmtime", +] + +[[package]] +name = "lunatic-stdout-capture" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a66f75089f4a2afbedccdc167c2da5d0fc062825783872ffb97a3d6e6be417d" +dependencies = [ + "wasi-common", + "wiggle", +] + +[[package]] +name = "lunatic-sys" +version = "0.13.0" +source = "git+https://github.com/lunatic-solutions/lunatic-rs#2a1210ebc87627908f49a82533c04acb4a96715a" + +[[package]] +name = "lunatic-test" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2baee76cce00a0c693983edd92fafc4bede7c4756e1e2a9346c03b77a22fbc1a" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "lunatic-test" +version = "0.13.0" +source = "git+https://github.com/lunatic-solutions/lunatic-rs#2a1210ebc87627908f49a82533c04acb4a96715a" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "lunatic-wasi-api" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051c5610099b97ffe076072456b48c590a9c07abce3c8d17b8947494bdcfc761" +dependencies = [ + "anyhow", + "lunatic-common-api", + "lunatic-process", + "lunatic-stdout-capture", + "wasmtime", + "wasmtime-wasi", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "maybe-owned" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memfd" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +dependencies = [ + "rustix", +] + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.45.0", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "crc32fast", + "hashbrown", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regalloc2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" +dependencies = [ + "fxhash", + "log", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rust-format" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e7c00b6c3bf5e38a880eec01d7e829d12ca682079f8238a464def3c4b31627" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "rustix" +version = "0.36.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "itoa", + "libc", + "linux-raw-sys", + "once_cell", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustls" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +dependencies = [ + "base64 0.21.0", +] + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "serde" +version = "1.0.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shellexpand" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" +dependencies = [ + "dirs", +] + +[[package]] +name = "slice-group-by" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "sqlite-bindings-lunatic" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4280b6cc832984930555237163be0e6fd2d68c5448fed89224f7f88c6d114cc0" +dependencies = [ + "libc", + "sqlite3-sys", +] + +[[package]] +name = "sqlite3-src" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1815a7a02c996eb8e5c64f61fcb6fd9b12e593ce265c512c5853b2513635691" +dependencies = [ + "cc", + "pkg-config", +] + +[[package]] +name = "sqlite3-sys" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d47c99824fc55360ba00caf28de0b8a0458369b832e016a64c13af0ad9fbb9ee" +dependencies = [ + "libc", + "sqlite3-src", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "submillisecond" +version = "0.3.0" +source = "git+https://github.com/lunatic-solutions/submillisecond#56c571cfdc585b9747a4e14dbf6b8d9ff403666f" +dependencies = [ + "ansi_term", + "headers", + "http", + "httparse", + "lunatic 0.12.1", + "lunatic-log 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "mime", + "paste", + "percent-encoding", + "serde", + "serde_bytes", + "serde_json", + "submillisecond_macros", +] + +[[package]] +name = "submillisecond_macros" +version = "0.3.0" +source = "git+https://github.com/lunatic-solutions/submillisecond#56c571cfdc585b9747a4e14dbf6b8d9ff403666f" +dependencies = [ + "better-bae", + "lazy_static", + "mime_guess", + "proc-macro2", + "quote", + "regex", + "rust-format", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "system-interface" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f355df185d945435f24c51fda9bf01bea6acb6c0b753e1241e5cc05413a659d4" +dependencies = [ + "bitflags", + "cap-fs-ext", + "cap-std", + "fd-lock", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", + "winx", +] + +[[package]] +name = "target-lexicon" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi-cap-std-sync" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91109b23018beb7c9ecf090e3e4a81138a662c04a1d08ce46804ffddc27d49a5" +dependencies = [ + "anyhow", + "async-trait", + "cap-fs-ext", + "cap-rand", + "cap-std", + "cap-time-ext", + "fs-set-times", + "io-extras", + "io-lifetimes", + "is-terminal", + "once_cell", + "rustix", + "system-interface", + "tracing", + "wasi-common", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasi-common" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46604ebe82881f99d88095c171eb84ae078c6b2a13f8f8f20ec00da60c8f6faf" +dependencies = [ + "anyhow", + "bitflags", + "cap-rand", + "cap-std", + "io-extras", + "rustix", + "thiserror", + "tracing", + "wasmtime", + "wiggle", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "wasm-encoder" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.96.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adde01ade41ab9a5d10ec8ed0bb954238cf8625b5cd5a13093d6de2ad9c2be1a" +dependencies = [ + "indexmap", + "url", +] + +[[package]] +name = "wasmtime" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49ffcc607adc9da024e87ca814592d4bc67f5c5b58e488f5608d5734a1ebc23e" +dependencies = [ + "anyhow", + "async-trait", + "bincode", + "cfg-if", + "indexmap", + "libc", + "log", + "object", + "once_cell", + "paste", + "psm", + "rayon", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-cache", + "wasmtime-component-macro", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit", + "wasmtime-runtime", + "wat", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cb5dc4d79cd7b2453c395f64e9013d2ad90bd083be556d5565cb224ebe8d57" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-cache" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6b1611b04c29f2c4a434f109f6143a0719cb8b558370371d1bae7643aa173af" +dependencies = [ + "anyhow", + "base64 0.13.1", + "bincode", + "directories-next", + "file-per-thread-logger", + "log", + "rustix", + "serde", + "sha2", + "toml", + "windows-sys 0.42.0", + "zstd", +] + +[[package]] +name = "wasmtime-component-macro" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5c3d25a7d531582fbaa75ce6a86dddc8211c783cb247af053075a0fcc9d3d7" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff0e0e3a1310cdde7db4e8634bda696ca4f80c429fbd727fa827be5f9cb35d21" + +[[package]] +name = "wasmtime-cranelift" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66a3f2167a7436910c6cbac2408a7b599688d7114cb8821cb10879dae451759" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9350c919553cddf14f78f9452119c8004d7ef6bfebb79a41a21819ed0c5604d8" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-fiber" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7459893ae6d67f9b35b04f44df8dfc037ea7f3071d710b9f7866b79cb2c482ae" +dependencies = [ + "cc", + "cfg-if", + "rustix", + "wasmtime-asm-macros", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-jit" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ba5779ea786386432b94c9fc9ad5597346c319e8239db0d98d5be5cc109a7e" +dependencies = [ + "addr2line", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli", + "ittapi", + "log", + "object", + "rustc-demangle", + "serde", + "target-lexicon", + "wasmtime-environ", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", + "wasmtime-runtime", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9841a44c82c74101c10ad4f215392761a2523b3c6c838597962bdb6de75fdb3" +dependencies = [ + "object", + "once_cell", + "rustix", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd4356c2493002da3b111d470c2ecea65a3017009afce8adc46eaa5758739891" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-runtime" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd26efea7a790fcf430e663ba2519f0ab6eb8980adf8b0c58c62b727da77c2ec" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "indexmap", + "libc", + "log", + "mach", + "memfd", + "memoffset 0.6.5", + "paste", + "rand", + "rustix", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit-debug", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-types" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e1e4f66a2b9a114f9def450ab9971828c968db6ea6fccd613724b771fa4913" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + +[[package]] +name = "wasmtime-wasi" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aa31e718a1f7294fc44a9eef13abf6ef32fd0574d9d7b365fee9ca24730a822" +dependencies = [ + "anyhow", + "wasi-cap-std-sync", + "wasi-common", + "wasmtime", + "wiggle", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97566c073045a48b745f3559689295140f00fff7f2799efe8c89cc7e70ae007" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wast" +version = "35.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" +dependencies = [ + "leb128", +] + +[[package]] +name = "wast" +version = "55.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4984d3e1406571f4930ba5cf79bd70f75f41d0e87e17506e0bd19b0e5d085f05" +dependencies = [ + "leb128", + "memchr", + "unicode-width", + "wasm-encoder", +] + +[[package]] +name = "wat" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af2b53f4da14db05d32e70e9c617abdf6620c575bd5dd972b7400037b4df2091" +dependencies = [ + "wast 55.0.0", +] + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + +[[package]] +name = "wiggle" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4edae96a8cef2aaf1d2ce42a41814ee1a0fb55c5171de6b6166bd2d6fa2f5b7b" +dependencies = [ + "anyhow", + "async-trait", + "bitflags", + "thiserror", + "tracing", + "wasmtime", + "wiggle-macro", + "witx", +] + +[[package]] +name = "wiggle-generate" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3219ec3173dba79319622add6af2d4f71ec6fe9e446a119f39b1e8f76534ad2b" +dependencies = [ + "anyhow", + "heck", + "proc-macro2", + "quote", + "shellexpand", + "syn", + "witx", +] + +[[package]] +name = "wiggle-macro" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fd7c907d4640faf42369832a583304476aa0178cb7481c5772c0495effa8b2" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wiggle-generate", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "winx" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "129cd8ee937d535e1a239d9d3c9c0525af0454bc0967d9211a251be062513520" +dependencies = [ + "bitflags", + "io-lifetimes", + "windows-sys 0.45.0", +] + +[[package]] +name = "wit-parser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703eb1d2f89ff2c52d50f7ff002735e423cea75f0a5dc5c8a4626c4c47cd9ca6" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "pulldown-cmark", + "unicode-xid", +] + +[[package]] +name = "witx" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" +dependencies = [ + "anyhow", + "log", + "thiserror", + "wast 35.0.2", +] + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.7+zstd.1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" +dependencies = [ + "cc", + "libc", + "pkg-config", +] diff --git a/crates/lunatic-control-submillisecond/Cargo.toml b/crates/lunatic-control-submillisecond/Cargo.toml new file mode 100644 index 000000000..45c350b9e --- /dev/null +++ b/crates/lunatic-control-submillisecond/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "lunatic-control-submillisecond" +version = "0.12.0" +edition = "2021" +description = "TBD" +homepage = "https://lunatic.solutions" +repository = "https://github.com/lunatic-solutions/lunatic/tree/main/crates" +license = "Apache-2.0/MIT" + +[dependencies] +lunatic-control = { path = "../lunatic-control" } + +anyhow = "1.0" +base64-url = "1.4.13" +bincode = "1.3" +chrono = { version = "0.4.23", default-features = false, features = ["clock", "serde", "std"] } +getrandom = "0.2.8" +lunatic = { git = "https://github.com/lunatic-solutions/lunatic-rs", features = ["sqlite"] } +lunatic-log = { git = "https://github.com/lunatic-solutions/lunatic-log-rs", branch = "lunatic-0-13-git" } +serde = "1.0" +serde_json = "1.0.89" +submillisecond = { git = "https://github.com/lunatic-solutions/submillisecond", features = ["json"] } +uuid = "1.3" + +[workspace] diff --git a/crates/lunatic-control-submillisecond/README.md b/crates/lunatic-control-submillisecond/README.md new file mode 100644 index 000000000..68e3c5121 --- /dev/null +++ b/crates/lunatic-control-submillisecond/README.md @@ -0,0 +1,26 @@ +# Lunatic Control Server + +Lunatic Control Server is an HTTP server designed for managing Lunatic nodes. +It is built with Submillisecond and compiles to WebAssembly to run with Lunatic. + +### Running the Server Locally + +Before running the server locally, you need to build the Lunatic runtime by running the following command: + +```bash +cargo build --release +``` + +Next, follow the steps below to build and run the control server: + +1. Navigate to the `./crates/lunatic-control-submillisecond` directory. +2. Build the control server using the following command: + ```bash + cargo build --target wasm32-wasi + ``` +3. Finally, run the control server using the Lunatic runtime by executing the following command: + ```bash + ../../target/release/lunatic ./target/wasm32-wasi/debug/lunatic-control-submillisecond.wasm + ``` + Please note that the command above assumes that you are still in the `./crates/lunatic-control-submillisecond directory.` + If you are in a different directory, you will need to adjust the relative paths accordingly. diff --git a/crates/lunatic-control-submillisecond/src/api.rs b/crates/lunatic-control-submillisecond/src/api.rs new file mode 100644 index 000000000..0814fe6da --- /dev/null +++ b/crates/lunatic-control-submillisecond/src/api.rs @@ -0,0 +1,278 @@ +use std::fmt::Debug; +use std::fmt::Display; + +use lunatic::ap::ProcessRef; +use lunatic_log::error; +use serde::{de::DeserializeOwned, Serialize}; +use serde_json::json; +use submillisecond::{ + extract::FromRequest, + http::{self, header}, + response::{IntoResponse, Response}, + Handler, RequestContext, +}; + +use crate::server::{ControlServer, ControlServerRequests}; + +pub type ApiResponse = Result, ApiError>; + +pub fn ok(data: D) -> ApiResponse { + Ok(submillisecond::Json(data)) +} + +#[derive(Debug)] +pub enum ApiError { + Internal, + NotAuthenticated, + NotAuthorized, + InvalidData(String), + InvalidPathArg(String), + InvalidQueryArg(String), + PayloadTooLarge, + Custom { + code: &'static str, + message: Option, + }, +} + +impl ApiError { + pub fn code(&self) -> &str { + match self { + ApiError::Internal => "internal", + ApiError::NotAuthenticated => "unauthenticated", + ApiError::NotAuthorized => "unauthorized", + ApiError::InvalidData(_) => "invalid_data", + ApiError::InvalidPathArg(_) => "invalid_path_arg", + ApiError::InvalidQueryArg(_) => "invalid_query_arg", + ApiError::PayloadTooLarge => "payload_too_large", + ApiError::Custom { code, .. } => code, + } + } + + pub fn message(&self) -> Option<&str> { + match self { + ApiError::Internal => None, + ApiError::NotAuthenticated => Some("Not authenticated"), + ApiError::NotAuthorized => Some("Not authorized"), + ApiError::InvalidData(msg) => Some(msg), + ApiError::InvalidPathArg(msg) => Some(msg), + ApiError::InvalidQueryArg(msg) => Some(msg), + ApiError::PayloadTooLarge => Some("Payload too large"), + ApiError::Custom { message, .. } => message.as_deref(), + } + } + + pub fn log_internal(msg: &str) -> Self { + error!("{msg}"); + Self::Internal + } + + pub fn log_internal_err(msg: &str, err: impl std::fmt::Debug) -> Self { + error!("{msg}: {err:?}"); + Self::Internal + } + + pub fn custom(code: &'static str, message: String) -> Self { + Self::Custom { + code, + message: Some(message), + } + } + + pub fn custom_code(code: &'static str) -> Self { + Self::Custom { + code, + message: None, + } + } +} + +impl Display for ApiError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("Error ")?; + f.write_str(self.code())?; + let msg = self.message(); + if let Some(msg) = msg { + f.write_str(": ")?; + f.write_str(msg)?; + } + Ok(()) + } +} + +impl IntoResponse for ApiError { + fn into_response(self) -> Response { + use http::StatusCode as S; + use ApiError::*; + + let body = submillisecond::Json(json!({ + "message": self.message(), + "code": self.code(), + })); + + let status = match self { + Self::Internal => S::INTERNAL_SERVER_ERROR, + Self::NotAuthenticated => S::UNAUTHORIZED, + Self::NotAuthorized => S::FORBIDDEN, + Self::PayloadTooLarge => S::PAYLOAD_TOO_LARGE, + InvalidData(_) | InvalidPathArg(_) | InvalidQueryArg(_) | Custom { .. } => { + S::BAD_REQUEST + } + }; + + (status, body).into_response() + } +} + +pub struct ControlServerExtractor(pub ProcessRef); + +impl FromRequest for ControlServerExtractor { + type Rejection = ApiError; + + fn from_request(_req: &mut RequestContext) -> Result { + ControlServer::lookup() + .map(ControlServerExtractor) + .ok_or_else(|| ApiError::log_internal("ControlServer lookup not found")) + } +} + +pub struct JsonExtractor(pub T); + +impl FromRequest for JsonExtractor +where + T: DeserializeOwned + Debug, +{ + type Rejection = ApiError; + + fn from_request(req: &mut RequestContext) -> Result { + match submillisecond::Json::from_request(req) { + Ok(submillisecond::Json(value)) => Ok(JsonExtractor(value)), + Err(err) => Err(ApiError::InvalidData(err.to_string())), + } + } +} + +pub struct PathExtractor(pub T); + +impl FromRequest for PathExtractor +where + T: DeserializeOwned, +{ + type Rejection = ApiError; + + fn from_request(req: &mut RequestContext) -> Result { + match submillisecond::extract::Path::from_request(req) { + Ok(submillisecond::extract::Path(value)) => Ok(PathExtractor(value)), + Err(err) => Err(ApiError::InvalidPathArg(err.to_string())), + } + } +} + +pub struct HostExtractor(pub String); + +impl FromRequest for HostExtractor { + type Rejection = ApiError; + + fn from_request(req: &mut RequestContext) -> Result { + match submillisecond::extract::Host::from_request(req) { + Ok(submillisecond::extract::Host(value)) => Ok(HostExtractor(value)), + Err(err) => Err(ApiError::Custom { + code: "no_host", + message: Some(err.to_string()), + }), + } + } +} + +#[derive(Debug)] +pub struct NodeAuth { + pub registration_id: i64, + pub node_name: uuid::Uuid, +} + +impl FromRequest for NodeAuth { + type Rejection = ApiError; + + fn from_request(req: &mut RequestContext) -> Result { + let ControlServerExtractor(control) = ControlServerExtractor::from_request(req)?; + + let headers = req.headers(); + let auth_header = headers + .get(header::AUTHORIZATION) + .ok_or_else(|| { + ApiError::custom("no_auth_header", "Missing node authorization header".into()) + })? + .to_str() + .map_err(|_| { + ApiError::custom( + "invalid_auth_header", + "Invalid authorization header value".into(), + ) + })?; + + let token = auth_header + .strip_prefix("Bearer ") + .to_owned() + .ok_or_else(|| { + ApiError::custom( + "invalid_auth_token", + "Header value doesn't start with Bearer".into(), + ) + })?; + + let node_name = headers + .get("x-lunatic-node-name") + .ok_or_else(|| { + ApiError::custom( + "no_lunatic_node_name_header", + "Missing x-lunatic-node-name header".into(), + ) + })? + .to_str() + .map_err(|_| { + ApiError::custom( + "invalid_lunatic_node_name_header", + "Invalid x-lunatic-node-name header value".into(), + ) + })?; + + let node_name: uuid::Uuid = node_name.parse().map_err(|_| { + ApiError::custom( + "invalid_lunatic_node_name_header", + format!("Invalid x-lunatic-node-name header: {node_name} not a valid UUID"), + ) + })?; + + let (registration_id, reg) = control + .get_registrations() + .into_iter() + .find(|(_, r)| r.node_name == node_name && r.auth_token == token) + .ok_or(ApiError::NotAuthenticated)?; + let node_auth = NodeAuth { + registration_id: registration_id as i64, + node_name: reg.node_name, + }; + + Ok(node_auth) + } +} + +pub struct RequestBodyLimit { + limit: usize, +} + +impl RequestBodyLimit { + pub fn new(limit: usize) -> Self { + RequestBodyLimit { limit } + } +} + +impl Handler for RequestBodyLimit { + fn handle(&self, req: RequestContext) -> Response { + if req.body().len() > self.limit { + return ApiError::PayloadTooLarge.into_response(); + } + + req.next_handler() + } +} diff --git a/crates/lunatic-control-submillisecond/src/host.rs b/crates/lunatic-control-submillisecond/src/host.rs new file mode 100644 index 000000000..98709f87a --- /dev/null +++ b/crates/lunatic-control-submillisecond/src/host.rs @@ -0,0 +1,75 @@ +use serde::{Deserialize, Serialize}; + +mod api { + #[link(wasm_import_module = "lunatic::distributed")] + extern "C" { + pub fn test_root_cert(len_ptr: *mut u32) -> u32; + pub fn default_server_certificates( + cert_pem_ptr: *const u8, + cert_pem_len: u32, + key_pair_pem_ptr: *const u8, + key_pair_pem_len: u32, + len_ptr: *mut u32, + ) -> u32; + pub fn sign_node( + cert_pem_ptr: *const u8, + cert_pem_len: u32, + key_pair_pem_ptr: *const u8, + key_pair_pem_len: u32, + csr_pem_ptr: *const u8, + csr_pem_len: u32, + len_ptr: *mut u32, + ) -> u32; + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct CertPk { + pub cert: String, + pub pk: String, +} + +pub fn test_root_cert() -> CertPk { + let (cert, pk) = call_host_alloc(|len_ptr| unsafe { api::test_root_cert(len_ptr) }).unwrap(); + CertPk { cert, pk } +} + +pub fn default_server_certificates(cert_pem: &str, pk_pem: &str) -> CertPk { + let (cert, pk) = call_host_alloc(|len_ptr| unsafe { + api::default_server_certificates( + cert_pem.as_ptr(), + cert_pem.len() as u32, + pk_pem.as_ptr(), + pk_pem.len() as u32, + len_ptr, + ) + }) + .unwrap(); + CertPk { cert, pk } +} + +pub fn sign_node(cert_pem: &str, pk_pem: &str, csr_pem: &str) -> String { + call_host_alloc(|len_ptr| unsafe { + api::sign_node( + cert_pem.as_ptr(), + cert_pem.len() as u32, + pk_pem.as_ptr(), + pk_pem.len() as u32, + csr_pem.as_ptr(), + csr_pem.len() as u32, + len_ptr, + ) + }) + .unwrap() +} + +fn call_host_alloc(f: impl Fn(*mut u32) -> u32) -> bincode::Result +where + T: for<'de> Deserialize<'de>, +{ + let mut len = 0_u32; + let len_ptr = &mut len as *mut u32; + let ptr = f(len_ptr); + let data_vec = unsafe { Vec::from_raw_parts(ptr as *mut u8, len as usize, len as usize) }; + bincode::deserialize(&data_vec) +} diff --git a/crates/lunatic-control-submillisecond/src/main.rs b/crates/lunatic-control-submillisecond/src/main.rs new file mode 100644 index 000000000..bdc7b460d --- /dev/null +++ b/crates/lunatic-control-submillisecond/src/main.rs @@ -0,0 +1,40 @@ +mod api; +mod host; +mod routes; +mod server; + +use std::net::ToSocketAddrs; + +use api::RequestBodyLimit; +use lunatic::AbstractProcess; +use submillisecond::{router, Application}; + +use crate::routes::{add_module, get_module, list_nodes, node_started, node_stopped, register}; +use crate::server::ControlServer; + +fn main() -> anyhow::Result<()> { + let root_cert = host::test_root_cert(); + let ca_cert = host::default_server_certificates(&root_cert.cert, &root_cert.pk); + + ControlServer::link() + .start_as("ControlServer", ca_cert) + .unwrap(); + + let addrs: Vec<_> = (3030..3999_u16) + .flat_map(|port| ("127.0.0.1", port).to_socket_addrs().unwrap()) + .collect(); + + Application::new(router! { + with RequestBodyLimit::new(50 * 1024 * 1024); // 50 mb + + POST "/" => register + POST "/stopped" => node_stopped + POST "/started" => node_started + GET "/nodes" => list_nodes + POST "/module" => add_module + GET "/module/:id" => get_module + }) + .serve(addrs.as_slice())?; + + Ok(()) +} diff --git a/crates/lunatic-control-submillisecond/src/routes.rs b/crates/lunatic-control-submillisecond/src/routes.rs new file mode 100644 index 000000000..b064ba920 --- /dev/null +++ b/crates/lunatic-control-submillisecond/src/routes.rs @@ -0,0 +1,138 @@ +use lunatic_control::{ + api::{ + ControlUrls, ModuleBytes, ModuleId, NodeStart, NodeStarted, NodesList, Register, + Registration, + }, + NodeInfo, +}; +use lunatic_log::info; + +use crate::{ + api::{ + ok, ApiError, ApiResponse, ControlServerExtractor, HostExtractor, JsonExtractor, NodeAuth, + PathExtractor, + }, + server::{ControlServerMessages, ControlServerRequests}, +}; + +pub fn register( + ControlServerExtractor(control): ControlServerExtractor, + HostExtractor(host): HostExtractor, + JsonExtractor(reg): JsonExtractor, +) -> ApiResponse { + info!("Registration for node name {}", reg.node_name); + + let cert_pem = control.sign_node(reg.csr_pem.clone()); + + let mut authentication_token = [0u8; 32]; + getrandom::getrandom(&mut authentication_token).map_err(|err| { + ApiError::log_internal_err("Error generating random token for registration", err) + })?; + let authentication_token = base64_url::encode(&authentication_token); + + ControlServerMessages::register( + &control, + reg.clone(), + cert_pem.clone(), + authentication_token.clone(), + ); + + ok(Registration { + node_name: reg.node_name, + cert_pem, + authentication_token, + root_cert: control.root_cert(), + urls: ControlUrls { + api_base: format!("http://{host}/"), + nodes: format!("http://{host}/nodes"), + node_started: format!("http://{host}/started"), + node_stopped: format!("http://{host}/stopped"), + get_module: format!("http://{host}/module/{{id}}"), + add_module: format!("http://{host}/module"), + get_nodes: format!("http://{host}/nodes"), + }, + }) +} + +pub fn node_stopped( + node_auth: NodeAuth, + ControlServerExtractor(control): ControlServerExtractor, +) -> ApiResponse<()> { + info!("Node {} stopped", node_auth.node_name); + + control.stop_node(node_auth.registration_id as u64); + + ok(()) +} + +pub fn node_started( + node_auth: NodeAuth, + ControlServerExtractor(control): ControlServerExtractor, + JsonExtractor(data): JsonExtractor, +) -> ApiResponse { + control.stop_node(node_auth.registration_id as u64); + + let (node_id, _node_address) = control.start_node(node_auth.registration_id as u64, data); + + info!("Node {} started with id {}", node_auth.node_name, node_id); + + // TODO spawn all modules on node + + ok(NodeStarted { + node_id: node_id as i64, + }) +} + +pub fn list_nodes( + _node_auth: NodeAuth, + ControlServerExtractor(control): ControlServerExtractor, +) -> ApiResponse { + let all_nodes = control.get_nodes(); + let nds: Vec<_> = all_nodes + .into_values() + .filter(|n| n.status < 2 && !n.node_address.is_empty()) + .collect(); + let nodes: Vec<_> = control + .get_registrations() + .into_iter() + .filter_map(|(k, r)| { + nds.iter() + .find(|n| n.registration_id == k) + .map(|n| NodeInfo { + id: k, + address: n.node_address.parse().unwrap(), + name: r.node_name.to_string(), + }) + }) + .collect(); + + ok(NodesList { nodes }) +} + +pub fn add_module( + body: Vec, + node_auth: NodeAuth, + ControlServerExtractor(control): ControlServerExtractor, +) -> ApiResponse { + info!("Node {} add_module", node_auth.node_name); + + let module_id = control.add_module(body); + ok(ModuleId { module_id }) +} + +pub fn get_module( + node_auth: NodeAuth, + PathExtractor(id): PathExtractor, + ControlServerExtractor(control): ControlServerExtractor, +) -> ApiResponse { + info!("Node {} get_module {}", node_auth.node_name, id); + + let all_modules = control.get_modules(); + let bytes = all_modules + .into_iter() + .find(|(k, _)| k == &id) + .map(|(_, m)| m) + .ok_or_else(|| ApiError::custom_code("error_reading_bytes"))?; + + ok(ModuleBytes { bytes }) +} diff --git a/crates/lunatic-control-submillisecond/src/server.rs b/crates/lunatic-control-submillisecond/src/server.rs new file mode 100644 index 000000000..608cd18f3 --- /dev/null +++ b/crates/lunatic-control-submillisecond/src/server.rs @@ -0,0 +1,232 @@ +mod store; + +use std::{ + collections::HashMap, + ops::{Deref, DerefMut}, +}; + +use anyhow::Result; +use chrono::{DateTime, Utc}; +use lunatic::{ + abstract_process, + ap::{Config, ProcessRef}, +}; +use lunatic_control::api::{NodeStart, Register}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use crate::host::{self, CertPk}; + +use self::store::ControlServerStore; + +#[derive(Clone, Debug)] +pub struct ControlServer { + ca_cert: CertPk, + store: ControlServerStore, + registrations: HashMap, + nodes: HashMap, + modules: HashMap>, + next_registration_id: u64, + next_node_id: u64, + next_module_id: u64, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Registered { + pub node_name: Uuid, + pub csr_pem: String, + pub cert_pem: String, + pub auth_token: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct NodeDetails { + pub registration_id: u64, + pub status: i16, + pub created_at: DateTime, + pub stopped_at: Option>, + pub node_address: String, + pub attributes: BincodeJsonValue, +} + +impl ControlServer { + pub fn lookup() -> Option> { + ProcessRef::lookup("ControlServer") + } +} + +#[abstract_process(visibility = pub)] +impl ControlServer { + #[init] + fn init(_: Config, ca_cert: CertPk) -> Result { + Self::init_new(ca_cert).map_err(|err| err.to_string()) + } + + fn init_new(ca_cert: CertPk) -> anyhow::Result { + let store = ControlServerStore::connect("control_server.db")?; + + store.init()?; + + let registrations = store.load_registrations()?; + let nodes = store.load_nodes()?; + let modules = store.load_modules()?; + + let next_registration_id = registrations.keys().fold(1, |max, k| max.max(k + 1)); + let next_node_id = nodes.keys().fold(1, |max, k| max.max(k + 1)); + let next_module_id = modules.keys().fold(1, |max, k| max.max(k + 1)); + + Ok(ControlServer { + ca_cert, + store, + registrations, + nodes, + modules, + next_registration_id, + next_node_id, + next_module_id, + }) + } + + #[handle_message] + pub fn register(&mut self, reg: Register, cert_pem: String, auth_token: String) { + let id = self.next_registration_id; + self.next_registration_id += 1; + let registered = Registered { + node_name: reg.node_name, + csr_pem: reg.csr_pem, + cert_pem, + auth_token, + }; + self.store.add_registration(id, ®istered); + self.registrations.insert(id, registered); + } + + #[handle_request] + pub fn start_node(&mut self, registration_id: u64, data: NodeStart) -> (u64, String) { + let id = self.next_node_id; + self.next_node_id += 1; + let details = NodeDetails { + registration_id, + status: 0, + created_at: Utc::now(), + stopped_at: None, + node_address: data.node_address.to_string(), + attributes: serde_json::json!(data.attributes).into(), + }; + self.store.add_node(id, &details); + self.nodes.insert(id, details); + (id, data.node_address.to_string()) + } + + #[handle_message] + pub fn stop_node(&mut self, reg_id: u64) { + if let Some(mut node) = self.nodes.get_mut(®_id) { + node.status = 2; + node.stopped_at = Some(Utc::now()); + self.store.add_node(reg_id, node); + } + } + + #[handle_request] + pub fn add_module(&mut self, bytes: Vec) -> u64 { + let id = self.next_module_id; + self.next_module_id += 1; + self.store.add_module(id, bytes.clone()); + self.modules.insert(id, bytes); + id + } + + #[handle_request] + pub fn get_nodes(&self) -> HashMap { + self.nodes.clone() + } + + #[handle_request] + pub fn get_registrations(&self) -> HashMap { + self.registrations.clone() + } + + #[handle_request] + pub fn get_modules(&self) -> HashMap> { + self.modules.clone() + } + + #[handle_request] + pub fn root_cert(&self) -> String { + self.ca_cert.cert.clone() + } + + #[handle_request] + pub fn sign_node(&self, csr_pem: String) -> String { + host::sign_node(&self.ca_cert.cert, &self.ca_cert.pk, &csr_pem) + } +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct BincodeJsonValue(pub serde_json::Value); + +impl From for BincodeJsonValue { + fn from(value: serde_json::Value) -> Self { + BincodeJsonValue(value) + } +} + +impl From for serde_json::Value { + fn from(value: BincodeJsonValue) -> Self { + value.0 + } +} + +impl Deref for BincodeJsonValue { + type Target = serde_json::Value; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for BincodeJsonValue { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl Serialize for BincodeJsonValue { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + let bytes = serde_json::to_vec(&self.0) + .map_err(|err| ::custom(err.to_string()))?; + + serializer.serialize_bytes(&bytes) + } +} + +impl<'de> Deserialize<'de> for BincodeJsonValue { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct BincodeJsonValueVisitor; + + impl<'de> serde::de::Visitor<'de> for BincodeJsonValueVisitor { + type Value = BincodeJsonValue; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(formatter, "a byte slice of json") + } + + fn visit_bytes(self, v: &[u8]) -> std::result::Result + where + E: serde::de::Error, + { + serde_json::from_slice(v) + .map(BincodeJsonValue) + .map_err(|err| E::custom(err.to_string())) + } + } + + deserializer.deserialize_bytes(BincodeJsonValueVisitor) + } +} diff --git a/crates/lunatic-control-submillisecond/src/server/store.rs b/crates/lunatic-control-submillisecond/src/server/store.rs new file mode 100644 index 000000000..f34e5f094 --- /dev/null +++ b/crates/lunatic-control-submillisecond/src/server/store.rs @@ -0,0 +1,213 @@ +use std::collections::HashMap; + +use anyhow::anyhow; +use chrono::{DateTime, Utc}; +use lunatic::sqlite::{Query, SqliteClient, SqliteError}; + +use super::{BincodeJsonValue, NodeDetails, Registered}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct ControlServerStore { + client: SqliteClient, +} + +impl ControlServerStore { + pub fn connect(path: &str) -> Result { + let client = SqliteClient::connect(path)?; + Ok(ControlServerStore { client }) + } + + pub fn init(&self) -> anyhow::Result<()> { + self.client.execute( + r#"CREATE TABLE IF NOT EXISTS registrations ( + id INT PRIMARY KEY, + node_name TEXT NOT NULL, + csr_pem TEXT NOT NULL, + cert_pem TEXT NOT NULL, + auth_token TEXT NOT NULL + )"#, + )?; + self.client.execute( + r#"CREATE TABLE IF NOT EXISTS nodes ( + id INT PRIMARY KEY, + registration_id INT NOT NULL, + status INT NOT NULL, + created_at DATETIME NOT NULL, + stopped_at DATETIME, + node_address TEXT NOT NULL, + attributes BLOB + )"#, + )?; + self.client.execute( + "CREATE TABLE IF NOT EXISTS modules (id INT PRIMARY KEY, module BLOB NOT NULL)", + )?; + + Ok(()) + } + + pub fn load_registrations(&self) -> anyhow::Result> { + self.client + .prepare_query("SELECT id, node_name, csr_pem, cert_pem, auth_token FROM registrations") + .execute_iter() + .map(|columns| { + let mut cols = columns.into_iter(); + Ok(( + cols.next() + .and_then(|id| id.into_int64().map(|id| id as u64)) + .ok_or_else(|| anyhow!("missing or invalid id"))?, + Registered { + node_name: cols + .next() + .and_then(|node_name| node_name.into_text()) + .and_then(|node_name| node_name.parse().ok()) + .ok_or_else(|| anyhow!("missing or invalid node_name"))?, + csr_pem: cols + .next() + .and_then(|csr_pem| csr_pem.into_text()) + .ok_or_else(|| anyhow!("missing or invalid csr_pem"))?, + cert_pem: cols + .next() + .and_then(|cert_pem| cert_pem.into_text()) + .ok_or_else(|| anyhow!("missing or invalid cert_pem"))?, + auth_token: cols + .next() + .and_then(|auth_token| auth_token.into_text()) + .ok_or_else(|| anyhow!("missing or invalid auth_token"))?, + }, + )) + }) + .collect() + } + + pub fn load_nodes(&self) -> anyhow::Result> { + self.client + .prepare_query("SELECT id, registration_id, status, created_at, stopped_at, node_address, attributes FROM nodes") + .execute_iter() + .map(|columns| { + let mut cols = columns.into_iter(); + Ok(( + cols.next() + .and_then(|id| id.into_int64().map(|id| id as u64)) + .ok_or_else(|| anyhow!("missing or invalid id"))?, + NodeDetails { + registration_id: cols + .next() + .and_then(|registration_id| registration_id.as_int_any()) + .and_then(|registration_id| registration_id.try_into().ok()) + .ok_or_else(|| anyhow!("missing or invalid registration_id"))?, + status: cols + .next() + .and_then(|status| status.as_int_any()) + .and_then(|status| status.try_into().ok()) + .ok_or_else(|| anyhow!("missing or invalid status"))?, + created_at: cols + .next() + .and_then(|created_at| created_at.into_text()) + .and_then(|created_at| DateTime::parse_from_rfc3339(&created_at).ok()) + .map(|created_at| created_at.with_timezone(&Utc)) + .ok_or_else(|| anyhow!("missing or invalid created_at"))?, + stopped_at: cols + .next() + .and_then(|stopped_at| stopped_at.as_text().map(|stopped_at| DateTime::parse_from_rfc3339(&stopped_at).ok()).or_else(|| stopped_at.into_null().map(|_| None))) + .map(|created_at| created_at.map(|dt| dt.with_timezone(&Utc))) + .ok_or_else(|| anyhow!("missing or invalid stopped_at"))?, + node_address: cols + .next() + .and_then(|node_address| node_address.into_text()) + .ok_or_else(|| anyhow!("missing or invalid node_address"))?, + attributes: cols + .next() + .and_then(|attributes| attributes.into_blob()) + .and_then(|attributes| serde_json::from_slice(&attributes).ok().map(BincodeJsonValue)) + .ok_or_else(|| anyhow!("missing or invalid attributes"))?, + }, + )) + }) + .collect() + } + + pub fn load_modules(&self) -> anyhow::Result>> { + self.client + .prepare_query("SELECT id, module FROM modules") + .execute_iter() + .map(|columns| { + let mut cols = columns.into_iter(); + Ok(( + cols.next() + .and_then(|id| id.into_int64().map(|id| id as u64)) + .ok_or_else(|| anyhow!("missing or invalid id"))?, + cols.next() + .and_then(|registration_id| registration_id.into_blob()) + .ok_or_else(|| anyhow!("missing or invalid module"))?, + )) + }) + .collect() + } + + pub fn add_registration(&self, id: u64, registered: &Registered) { + self.client + .prepare_query( + r#" + INSERT INTO registrations ( + id, node_name, csr_pem, cert_pem, auth_token + ) VALUES (?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET + node_name=excluded.node_name, + csr_pem=excluded.csr_pem, + cert_pem=excluded.cert_pem, + auth_token=excluded.auth_token + "#, + ) + .bind(id as i64) + .bind(registered.node_name.to_string()) + .bind(®istered.csr_pem) + .bind(®istered.cert_pem) + .bind(®istered.auth_token) + .execute(); + } + + pub fn add_node(&self, id: u64, node: &NodeDetails) { + self.client + .prepare_query( + r#" + INSERT INTO nodes ( + id, + registration_id, + status, + created_at, + stopped_at, + node_address, + attributes + ) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET + registration_id=excluded.registration_id, + status=excluded.status, + created_at=excluded.created_at, + stopped_at=excluded.stopped_at, + node_address=excluded.node_address, + attributes=excluded.attributes + "#, + ) + .bind(id as i64) + .bind(node.registration_id as i64) + .bind(node.status as i32) + .bind(node.created_at.to_rfc3339()) + .bind(node.stopped_at.map(|dt| dt.to_rfc3339())) + .bind(&node.node_address) + .bind(serde_json::to_vec(&node.attributes).unwrap()) + .execute(); + } + + pub fn add_module(&self, id: u64, module: Vec) { + self.client + .prepare_query( + r#" + INSERT INTO modules (id, module) + VALUES (?, ?) + ON CONFLICT(id) DO UPDATE SET + module=excluded.module + "#, + ) + .bind(id as i64) + .bind(module) + .execute(); + } +} diff --git a/crates/lunatic-control/Cargo.toml b/crates/lunatic-control/Cargo.toml new file mode 100644 index 000000000..8cfdf367e --- /dev/null +++ b/crates/lunatic-control/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "lunatic-control" +version = "0.12.0" +edition = "2021" +description = "TBD" +homepage = "https://lunatic.solutions" +repository = "https://github.com/lunatic-solutions/lunatic/tree/main/crates" +license = "Apache-2.0/MIT" + +[dependencies] +serde = { workspace = true, features = ["derive"] } +uuid = { version = "1.0", features = ["serde", "v4"] } diff --git a/crates/lunatic-distributed/src/control/api.rs b/crates/lunatic-control/src/api.rs similarity index 99% rename from crates/lunatic-distributed/src/control/api.rs rename to crates/lunatic-control/src/api.rs index af290b4f4..4ceb62944 100644 --- a/crates/lunatic-distributed/src/control/api.rs +++ b/crates/lunatic-control/src/api.rs @@ -1,6 +1,7 @@ -use serde::{Deserialize, Serialize}; use std::{collections::HashMap, net::SocketAddr}; +use serde::{Deserialize, Serialize}; + use crate::NodeInfo; #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/crates/lunatic-control/src/lib.rs b/crates/lunatic-control/src/lib.rs new file mode 100644 index 000000000..f1834ded4 --- /dev/null +++ b/crates/lunatic-control/src/lib.rs @@ -0,0 +1,12 @@ +pub mod api; + +use std::net::SocketAddr; + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct NodeInfo { + pub id: u64, + pub address: SocketAddr, + pub name: String, +} diff --git a/crates/lunatic-distributed-api/Cargo.toml b/crates/lunatic-distributed-api/Cargo.toml index 2e630abda..5e3e7cb84 100644 --- a/crates/lunatic-distributed-api/Cargo.toml +++ b/crates/lunatic-distributed-api/Cargo.toml @@ -15,6 +15,8 @@ lunatic-process = { workspace = true } lunatic-process-api = { workspace = true } anyhow = { workspace = true } +bincode = { workspace = true } +rcgen = { version = "0.10", features = ["pem", "x509-parser"] } rmp-serde = "1.1.1" log = { workspace = true } tokio = { workspace = true, features = ["time"] } diff --git a/crates/lunatic-distributed-api/src/lib.rs b/crates/lunatic-distributed-api/src/lib.rs index 7aaf9f2ae..e8f14fb7d 100644 --- a/crates/lunatic-distributed-api/src/lib.rs +++ b/crates/lunatic-distributed-api/src/lib.rs @@ -1,7 +1,7 @@ use std::{future::Future, sync::Arc, time::Duration}; use anyhow::{anyhow, Result}; -use lunatic_common_api::{get_memory, IntoTrap}; +use lunatic_common_api::{get_memory, write_to_guest_vec, IntoTrap}; use lunatic_distributed::{ distributed::message::{ClientError, Spawn, Val}, DistributedCtx, @@ -12,6 +12,7 @@ use lunatic_process::{ message::{DataMessage, Message}, }; use lunatic_process_api::ProcessCtx; +use rcgen::{Certificate, CertificateParams, CertificateSigningRequest, KeyPair}; use tokio::time::timeout; use wasmtime::{Caller, Linker, ResourceLimiter}; @@ -43,6 +44,13 @@ where "copy_lookup_nodes_results", copy_lookup_nodes_results, )?; + linker.func_wrap1_async("lunatic::distributed", "test_root_cert", test_root_cert)?; + linker.func_wrap5_async( + "lunatic::distributed", + "default_server_certificates", + default_server_certificates, + )?; + linker.func_wrap7_async("lunatic::distributed", "sign_node", sign_node)?; Ok(()) } @@ -183,6 +191,144 @@ where } } +fn test_root_cert( + mut caller: Caller, + len_ptr: u32, +) -> Box> + Send + '_> +where + T: DistributedCtx + Send, + E: Environment, +{ + Box::new(async move { + let memory = get_memory(&mut caller)?; + let root_cert = lunatic_distributed::control::cert::test_root_cert() + .or_trap("lunatic::distributed::test_root_cert")?; + + let cert_pem = root_cert + .serialize_pem() + .or_trap("lunatic::distributed::test_root_cert")?; + let key_pair_pem = root_cert.serialize_private_key_pem(); + + let data = bincode::serialize(&(cert_pem, key_pair_pem)) + .or_trap("lunatic::distributed::test_root_cert")?; + let ptr = write_to_guest_vec(&mut caller, &memory, &data, len_ptr) + .await + .or_trap("lunatic::distributed::test_root_cert")?; + + Ok(ptr) + }) +} + +fn default_server_certificates( + mut caller: Caller, + cert_pem_ptr: u32, + cert_pem_len: u32, + pk_pem_ptr: u32, + pk_pem_len: u32, + len_ptr: u32, +) -> Box> + Send + '_> +where + T: DistributedCtx + Send, + E: Environment, +{ + Box::new(async move { + let memory = get_memory(&mut caller)?; + + let cert_pem_bytes = memory + .data(&caller) + .get(cert_pem_ptr as usize..(cert_pem_ptr + cert_pem_len) as usize) + .or_trap("lunatic::distributed::spawn::default_server_certificates")?; + let cert_pem = std::str::from_utf8(cert_pem_bytes) + .or_trap("lunatic::distributed::default_server_certificates")?; + + let pk_pem_bytes = memory + .data(&caller) + .get(pk_pem_ptr as usize..(pk_pem_ptr + pk_pem_len) as usize) + .or_trap("lunatic::distributed::default_server_certificates")?; + let pk_pem = std::str::from_utf8(pk_pem_bytes) + .or_trap("lunatic::distributed::default_server_certificates")?; + + let key_pair = KeyPair::from_pem(pk_pem) + .or_trap("lunatic::distributed::default_server_certificates")?; + let cert_params = CertificateParams::from_ca_cert_pem(cert_pem, key_pair) + .or_trap("lunatic::distributed::default_server_certificates")?; + + let root_cert = Certificate::from_params(cert_params) + .or_trap("lunatic::distributed::default_server_certificates")?; + + let (ctrl_cert, ctrl_pk) = + lunatic_distributed::control::cert::default_server_certificates(&root_cert)?; + + let data = bincode::serialize(&(ctrl_cert, ctrl_pk)) + .or_trap("lunatic::distributed::default_server_certificates")?; + let ptr = write_to_guest_vec(&mut caller, &memory, &data, len_ptr) + .await + .or_trap("lunatic::distributed::default_server_certificates")?; + + Ok(ptr) + }) +} + +#[allow(clippy::too_many_arguments)] +fn sign_node( + mut caller: Caller, + cert_pem_ptr: u32, + cert_pem_len: u32, + pk_pem_ptr: u32, + pk_pem_len: u32, + csr_pem_ptr: u32, + csr_pem_len: u32, + len_ptr: u32, +) -> Box> + Send + '_> +where + T: DistributedCtx + Send, + E: Environment, +{ + Box::new(async move { + let memory = get_memory(&mut caller)?; + + let cert_pem_bytes = memory + .data(&caller) + .get(cert_pem_ptr as usize..(cert_pem_ptr + cert_pem_len) as usize) + .or_trap("lunatic::distributed::spawn::sign_node")?; + let cert_pem = + std::str::from_utf8(cert_pem_bytes).or_trap("lunatic::distributed::sign_node")?; + + let pk_pem_bytes = memory + .data(&caller) + .get(pk_pem_ptr as usize..(pk_pem_ptr + pk_pem_len) as usize) + .or_trap("lunatic::distributed::sign_node")?; + let pk_pem = + std::str::from_utf8(pk_pem_bytes).or_trap("lunatic::distributed::sign_node")?; + + let csr_pem_bytes = memory + .data(&caller) + .get(csr_pem_ptr as usize..(csr_pem_ptr + csr_pem_len) as usize) + .or_trap("lunatic::distributed::sign_node")?; + let csr_pem = + std::str::from_utf8(csr_pem_bytes).or_trap("lunatic::distributed::sign_node")?; + + let key_pair = KeyPair::from_pem(pk_pem).or_trap("lunatic::distributed::sign_node")?; + let cert_params = CertificateParams::from_ca_cert_pem(cert_pem, key_pair) + .or_trap("lunatic::distributed::sign_node")?; + + let ca_cert = + Certificate::from_params(cert_params).or_trap("lunatic::distributed::sign_node")?; + + let Ok(cert_pem) = CertificateSigningRequest::from_pem(csr_pem) + .and_then(|sign_request| sign_request.serialize_pem_with_signer(&ca_cert)) else { + return Ok(0); + }; + + let data = bincode::serialize(&cert_pem).or_trap("lunatic::distributed::sign_node")?; + let ptr = write_to_guest_vec(&mut caller, &memory, &data, len_ptr) + .await + .or_trap("lunatic::distributed::sign_node")?; + + Ok(ptr) + }) +} + // Similar to a local spawn, it spawns a new process using the passed in function inside a module // as the entry point. The process is spawned on a node with id `node_id`. // diff --git a/crates/lunatic-distributed/Cargo.toml b/crates/lunatic-distributed/Cargo.toml index a561835ec..798f860a7 100644 --- a/crates/lunatic-distributed/Cargo.toml +++ b/crates/lunatic-distributed/Cargo.toml @@ -8,9 +8,9 @@ repository = "https://github.com/lunatic-solutions/lunatic/tree/main/crates" license = "Apache-2.0/MIT" [dependencies] +lunatic-control = { workspace = true } lunatic-process = { workspace = true } -uuid = { version = "1.0", features = ["serde", "v4"] } anyhow = { workspace = true } async_cell = "0.2.1" rmp-serde = "1.1.1" @@ -24,4 +24,5 @@ rustls = { version = "0.20" } rustls-pemfile = { workspace = true } serde = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["io-util", "rt", "sync", "time"] } +uuid = { version = "1.0", features = ["serde", "v4"] } wasmtime = { workspace = true } diff --git a/crates/lunatic-distributed/src/control/cert.rs b/crates/lunatic-distributed/src/control/cert.rs index 09f9d960f..54fab972e 100644 --- a/crates/lunatic-distributed/src/control/cert.rs +++ b/crates/lunatic-distributed/src/control/cert.rs @@ -26,29 +26,21 @@ boMyGfdI+xwp7ewOulGvpTcvdpehRANCAARlVNxYAwsmmFNc2EMBbZZVwL8GBtnn u8IROdDd68ixc0VBjfrV0zAM344lKJcs9slsMTEofoYvMCpIBhnSGyAF -----END PRIVATE KEY-----"""#; -pub fn root_cert( - test_ca: bool, - ca_cert: Option<&str>, - ca_keys: Option<&str>, -) -> Result { - if test_ca { - let key_pair = KeyPair::from_pem(TEST_ROOT_KEYS)?; - let root_params = CertificateParams::from_ca_cert_pem(TEST_ROOT_CERT, key_pair)?; - let root_cert = Certificate::from_params(root_params)?; - Ok(root_cert) - } else { - let ca_cert_pem = std::fs::read(Path::new( - ca_cert.ok_or_else(|| anyhow::anyhow!("Missing CA certificate."))?, - ))?; - let ca_keys_pem = std::fs::read(Path::new( - ca_keys.ok_or_else(|| anyhow::anyhow!("Missing CA keys."))?, - ))?; - let key_pair = KeyPair::from_pem(std::str::from_utf8(&ca_keys_pem)?)?; - let root_params = - CertificateParams::from_ca_cert_pem(std::str::from_utf8(&ca_cert_pem)?, key_pair)?; - let root_cert = Certificate::from_params(root_params)?; - Ok(root_cert) - } +pub fn test_root_cert() -> Result { + let key_pair = KeyPair::from_pem(TEST_ROOT_KEYS)?; + let root_params = CertificateParams::from_ca_cert_pem(TEST_ROOT_CERT, key_pair)?; + let root_cert = Certificate::from_params(root_params)?; + Ok(root_cert) +} + +pub fn root_cert(ca_cert: &str, ca_keys: &str) -> Result { + let ca_cert_pem = std::fs::read(Path::new(ca_cert))?; + let ca_keys_pem = std::fs::read(Path::new(ca_keys))?; + let key_pair = KeyPair::from_pem(std::str::from_utf8(&ca_keys_pem)?)?; + let root_params = + CertificateParams::from_ca_cert_pem(std::str::from_utf8(&ca_cert_pem)?, key_pair)?; + let root_cert = Certificate::from_params(root_params)?; + Ok(root_cert) } fn ctrl_cert() -> Result { diff --git a/crates/lunatic-distributed/src/control/client.rs b/crates/lunatic-distributed/src/control/client.rs index 5ac1fc3ae..df28339ed 100644 --- a/crates/lunatic-distributed/src/control/client.rs +++ b/crates/lunatic-distributed/src/control/client.rs @@ -1,5 +1,7 @@ use anyhow::{Context, Result}; use dashmap::DashMap; +use lunatic_control::api::*; +use lunatic_control::NodeInfo; use lunatic_process::runtimes::RawWasm; use reqwest::{Client as HttpClient, Url}; use serde::{de::DeserializeOwned, Serialize}; @@ -10,8 +12,6 @@ use std::{ time::Duration, }; -use crate::{control::api::*, NodeInfo}; - #[derive(Clone)] pub struct Client { inner: Arc, diff --git a/crates/lunatic-distributed/src/control/mod.rs b/crates/lunatic-distributed/src/control/mod.rs index ac4e6c963..89f74ecf9 100644 --- a/crates/lunatic-distributed/src/control/mod.rs +++ b/crates/lunatic-distributed/src/control/mod.rs @@ -1,6 +1,5 @@ pub mod client; //pub mod server; -pub mod api; pub mod cert; pub use client::Client; diff --git a/crates/lunatic-distributed/src/distributed/client.rs b/crates/lunatic-distributed/src/distributed/client.rs index 85975ee93..dc876c757 100644 --- a/crates/lunatic-distributed/src/distributed/client.rs +++ b/crates/lunatic-distributed/src/distributed/client.rs @@ -2,6 +2,7 @@ use anyhow::Result; use async_cell::sync::AsyncCell; use bytes::Bytes; use dashmap::DashMap; +use lunatic_control::NodeInfo; use std::sync::{atomic, atomic::AtomicU64, Arc}; use tokio::sync::mpsc::{self, unbounded_channel, UnboundedReceiver, UnboundedSender}; @@ -9,7 +10,6 @@ use crate::{ control, distributed::message::{ClientError, Request, Response}, quic::{self, RecvStream}, - NodeInfo, }; use super::message::Spawn; diff --git a/crates/lunatic-distributed/src/distributed/server.rs b/crates/lunatic-distributed/src/distributed/server.rs index 1ff604204..93591784d 100644 --- a/crates/lunatic-distributed/src/distributed/server.rs +++ b/crates/lunatic-distributed/src/distributed/server.rs @@ -38,15 +38,13 @@ impl Clone for ServerCtx { } } -pub fn root_cert(test_ca: bool, ca_cert: Option<&str>) -> Result { - if test_ca { - Ok(crate::control::cert::TEST_ROOT_CERT.to_string()) - } else { - let cert = std::fs::read( - ca_cert.ok_or_else(|| anyhow::anyhow!("Missing public root certificate."))?, - )?; - Ok(std::str::from_utf8(&cert)?.to_string()) - } +pub fn test_root_cert() -> String { + crate::control::cert::TEST_ROOT_CERT.to_string() +} + +pub fn root_cert(ca_cert: &str) -> Result { + let cert = std::fs::read(ca_cert)?; + Ok(std::str::from_utf8(&cert)?.to_string()) } pub fn gen_node_cert(node_name: &str) -> Result { diff --git a/crates/lunatic-distributed/src/lib.rs b/crates/lunatic-distributed/src/lib.rs index 9ecdd2a9a..9fc405c3f 100644 --- a/crates/lunatic-distributed/src/lib.rs +++ b/crates/lunatic-distributed/src/lib.rs @@ -8,8 +8,7 @@ use lunatic_process::{ runtimes::wasmtime::{WasmtimeCompiledModule, WasmtimeRuntime}, state::ProcessState, }; -use serde::{Deserialize, Serialize}; -use std::{net::SocketAddr, sync::Arc}; +use std::sync::Arc; pub trait DistributedCtx: ProcessState + Sized { fn new_dist_state( @@ -50,10 +49,3 @@ impl DistributedProcessState { self.node_id } } - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct NodeInfo { - pub id: u64, - pub address: SocketAddr, - pub name: String, -} diff --git a/crates/lunatic-sqlite-api/Cargo.toml b/crates/lunatic-sqlite-api/Cargo.toml index 831850faf..9558c53f4 100644 --- a/crates/lunatic-sqlite-api/Cargo.toml +++ b/crates/lunatic-sqlite-api/Cargo.toml @@ -10,15 +10,15 @@ version = "0.13.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bincode = "1.3" -serde = {version = "1.0", features = ["derive"]} +bincode = { workspace = true } +serde = { version = "1.0", features = ["derive"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -anyhow = {workspace = true} -hash-map-id = {workspace = true} -lunatic-common-api = {workspace = true} -lunatic-error-api = {workspace = true} -lunatic-process = {workspace = true} -lunatic-process-api = {workspace = true} -sqlite = {version = "0.30.4", package = "sqlite-bindings-lunatic"} -wasmtime = {workspace = true} +anyhow = { workspace = true } +hash-map-id = { workspace = true } +lunatic-common-api = { workspace = true } +lunatic-error-api = { workspace = true } +lunatic-process = { workspace = true } +lunatic-process-api = { workspace = true } +sqlite = { version = "0.30.4", package = "sqlite-bindings-lunatic" } +wasmtime = { workspace = true } diff --git a/crates/lunatic-sqlite-api/src/sqlite_bindings.rs b/crates/lunatic-sqlite-api/src/sqlite_bindings.rs index 267977dda..fad4ac8f6 100644 --- a/crates/lunatic-sqlite-api/src/sqlite_bindings.rs +++ b/crates/lunatic-sqlite-api/src/sqlite_bindings.rs @@ -1,6 +1,6 @@ use anyhow::Result; use hash_map_id::HashMapId; -use lunatic_common_api::{allocate_guest_memory, get_memory, IntoTrap}; +use lunatic_common_api::{get_memory, write_to_guest_vec, IntoTrap}; use lunatic_error_api::ErrorCtx; use lunatic_process::state::ProcessState; use lunatic_process_api::ProcessConfigCtx; @@ -8,11 +8,10 @@ use sqlite::{Connection, State, Statement}; use std::{ collections::HashMap, future::Future, - io::Write, path::Path, sync::{Arc, Mutex}, }; -use wasmtime::{Caller, Linker, Memory, ResourceLimiter}; +use wasmtime::{Caller, Linker, ResourceLimiter}; use crate::wire_format::{BindList, SqliteError, SqliteRow, SqliteValue}; @@ -256,38 +255,6 @@ fn statement_reset( Ok(()) } -// return a u64 which contains both the length of the pointer (usize=u32) and the pointer itself (u32) -async fn write_to_guest_vec( - mut caller: Caller<'_, T>, - _connection_id: u64, - memory: Memory, - encoded_vec: Vec, - opaque_ptr: u32, -) -> Result { - let alloc_len = encoded_vec.len(); - let alloc_ptr = { - let alloc_ptr = allocate_guest_memory(&mut caller, alloc_len as u32) - .await - .or_trap("lunatic::sqlite::write_to_guest_vec::alloc_response_vec")?; - - let (memory_slice, _) = memory.data_and_store_mut(&mut caller); - let mut alloc_vec = memory_slice - .get_mut(alloc_ptr as usize..(alloc_ptr as usize + alloc_len)) - .or_trap("lunatic::sqlite::write_to_guest_vec")?; - - alloc_vec - .write(&encoded_vec) - .or_trap("lunatic::sqlite::write_to_guest_vec")?; - - alloc_ptr - }; - - memory - .write(&mut caller, opaque_ptr as usize, &alloc_len.to_le_bytes()) - .or_trap("lunatic::sqlite::write_to_guest_vec")?; - Ok(alloc_ptr) -} - fn read_column( mut caller: Caller, statement_id: u64, @@ -298,12 +265,12 @@ fn read_column( // get state let memory = get_memory(&mut caller)?; let (_, state) = memory.data_and_store_mut(&mut caller); - let (connection_id, stmt) = get_statement!(state, statement_id); + let (_, stmt) = get_statement!(state, statement_id); let column = bincode::serialize(&SqliteValue::read_column(stmt, col_idx as usize)?) .or_trap("lunatic::sqlite::read_column")?; - write_to_guest_vec(caller, connection_id, memory, column, opaque_ptr).await + write_to_guest_vec(&mut caller, &memory, &column, opaque_ptr).await }) } @@ -316,14 +283,14 @@ fn column_names( // get state let memory = get_memory(&mut caller)?; let (_, state) = memory.data_and_store_mut(&mut caller); - let (connection_id, stmt) = get_statement!(state, statement_id); + let (_, stmt) = get_statement!(state, statement_id); let column_names = stmt.column_names().to_vec(); let column_names = bincode::serialize(&column_names).or_trap("lunatic::sqlite::column_names")?; - write_to_guest_vec(caller, connection_id, memory, column_names, opaque_ptr).await + write_to_guest_vec(&mut caller, &memory, &column_names, opaque_ptr).await }) } @@ -338,13 +305,13 @@ fn read_row( // get state let memory = get_memory(&mut caller)?; let (_, state) = memory.data_and_store_mut(&mut caller); - let (connection_id, stmt) = get_statement!(state, statement_id); + let (_, stmt) = get_statement!(state, statement_id); let read_row = SqliteRow::read_row(stmt)?; let row = bincode::serialize(&read_row).or_trap("lunatic::sqlite::read_row")?; - write_to_guest_vec(caller, connection_id, memory, row, opaque_ptr).await + write_to_guest_vec(&mut caller, &memory, &row, opaque_ptr).await }) } @@ -365,7 +332,7 @@ fn last_error( Box::new(async move { // get state let memory = get_memory(&mut caller)?; - let (connection_id, column_name) = { + let (_, column_name) = { let (_, state) = memory.data_and_store_mut(&mut caller); let (connection_id, statement) = get_statement!(state, statement_id); @@ -435,13 +402,6 @@ fn column_name( ) }; - write_to_guest_vec( - caller, - connection_id, - memory, - column_name.into_bytes(), - opaque_ptr, - ) - .await + write_to_guest_vec(&mut caller, &memory, column_name.as_bytes(), opaque_ptr).await }) } diff --git a/crates/lunatic-sqlite-api/src/wire_format/bind_values/host_api.rs b/crates/lunatic-sqlite-api/src/wire_format/bind_values/host_api.rs index 5d10f3584..21a7cfa8d 100644 --- a/crates/lunatic-sqlite-api/src/wire_format/bind_values/host_api.rs +++ b/crates/lunatic-sqlite-api/src/wire_format/bind_values/host_api.rs @@ -8,7 +8,7 @@ impl BindPair { pub fn bind(&self, statement: &mut Statement) -> Result<()> { if let BindKey::Numeric(idx) = self.0 { return match self.1.clone() { - BindValue::Null => todo!(), + BindValue::Null => statement.bind((idx, ())), BindValue::Blob(b) => statement.bind((idx, &b[..])), BindValue::Text(t) => statement.bind((idx, t.as_str())), BindValue::Double(d) => statement.bind((idx, d)), @@ -19,7 +19,7 @@ impl BindPair { } match self.1.clone() { BindValue::Blob(b) => statement.bind(&[&b[..]][..]), - BindValue::Null => todo!(), + BindValue::Null => statement.bind(&[()][..]), BindValue::Text(t) => statement.bind(&[t.as_str()][..]), BindValue::Double(d) => statement.bind(&[d][..]), BindValue::Int(i) => statement.bind(&[i as i64][..]),