diff --git a/Cargo.lock b/Cargo.lock index 3aaeeec5..4a3db6c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,6 +152,19 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "async-compat" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bab94bde396a3f7b4962e396fdad640e241ed797d4d8d77fc8c237d14c58fc0" +dependencies = [ + "futures-core", + "futures-io", + "once_cell", + "pin-project-lite", + "tokio", +] + [[package]] name = "async-trait" version = "0.1.86" @@ -184,48 +197,14 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" -[[package]] -name = "axum" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" -dependencies = [ - "async-trait", - "axum-core 0.4.5", - "axum-macros", - "bytes", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-util", - "itoa", - "matchit 0.7.3", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "serde_json", - "serde_path_to_error", - "serde_urlencoded", - "sync_wrapper", - "tokio", - "tower 0.5.2", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "axum" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" dependencies = [ - "axum-core 0.5.0", + "axum-core", + "axum-macros", "bytes", "form_urlencoded", "futures-util", @@ -235,7 +214,7 @@ dependencies = [ "hyper", "hyper-util", "itoa", - "matchit 0.8.4", + "matchit", "memchr", "mime", "percent-encoding", @@ -253,27 +232,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "axum-core" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http", - "http-body", - "http-body-util", - "mime", - "pin-project-lite", - "rustversion", - "sync_wrapper", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "axum-core" version = "0.5.0" @@ -296,21 +254,19 @@ dependencies = [ [[package]] name = "axum-extra" -version = "0.9.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c794b30c904f0a1c2fb7740f7df7f7972dfaa14ef6f57cb6178dc63e5dca2f04" +checksum = "460fc6f625a1f7705c6cf62d0d070794e94668988b1c38111baeec177c715f7b" dependencies = [ - "axum 0.7.9", - "axum-core 0.4.5", + "axum", + "axum-core", "bytes", - "fastrand", "futures-util", "headers", "http", "http-body", "http-body-util", "mime", - "multer", "pin-project-lite", "serde", "tokio", @@ -322,9 +278,9 @@ dependencies = [ [[package]] name = "axum-macros" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" +checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c" dependencies = [ "proc-macro2", "quote", @@ -365,7 +321,7 @@ dependencies = [ "getrandom 0.2.15", "instant", "pin-project-lite", - "rand", + "rand 0.8.5", "tokio", ] @@ -381,7 +337,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -487,9 +443,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.13" +version = "1.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" dependencies = [ "shlex", ] @@ -516,7 +472,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -581,9 +537,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.29" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" +checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" dependencies = [ "clap_builder", "clap_derive", @@ -591,9 +547,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.29" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" +checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" dependencies = [ "anstream", "anstyle", @@ -717,6 +673,16 @@ dependencies = [ "url", ] +[[package]] +name = "cordyceps" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec10f0a762d93c4498d2e97a333805cb6250d60bead623f71d8034f9a4152ba3" +dependencies = [ + "loom", + "tracing", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -857,7 +823,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "typenum", ] @@ -905,11 +871,12 @@ dependencies = [ [[package]] name = "dashmap" -version = "5.5.3" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", + "crossbeam-utils", "hashbrown 0.14.5", "lock_api", "once_cell", @@ -976,6 +943,12 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "diatomic-waker" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab03c107fafeb3ee9f5925686dbb7a73bc76e3932abb0d2b365cb64b169cf04c" + [[package]] name = "digest" version = "0.10.7" @@ -1021,9 +994,9 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" dependencies = [ "litrs", ] @@ -1068,7 +1041,6 @@ checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core", "serde", "sha2", "subtle", @@ -1127,9 +1099,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -1230,6 +1202,18 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-buffered" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34acda8ae8b63fbe0b2195c998b180cff89a8212fb2622a78b572a9f1c6f7684" +dependencies = [ + "cordyceps", + "diatomic-waker", + "futures-core", + "pin-project-lite", +] + [[package]] name = "futures-channel" version = "0.3.31" @@ -1339,6 +1323,19 @@ version = "0.99.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b32dfe1fdfc0bbde1f22a5da25355514b5e450c33a6af6770884c8750aedfbc" +[[package]] +name = "generator" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1370,9 +1367,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.13.3+wasi-0.2.2", - "windows-targets", + "wasm-bindgen", + "windows-targets 0.52.6", ] [[package]] @@ -1383,29 +1382,30 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "governor" -version = "0.6.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a7f542ee6b35af73b06abc0dad1c1bae89964e4e253bc4b587b91c9637867b" +checksum = "842dc78579ce01e6a1576ad896edc92fca002dd60c9c3746b7fc2bec6fb429d0" dependencies = [ "cfg-if", "dashmap", - "futures", + "futures-sink", "futures-timer", + "futures-util", "no-std-compat", "nonzero_ext", "parking_lot", "portable-atomic", "quanta", - "rand", + "rand 0.8.5", "smallvec", "spinning_top", ] [[package]] name = "h2" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "5017294ff4bb30944501348f6f8e42e6ad28f42c8bbef7a74029aff064a4e3c2" dependencies = [ "atomic-waker", "bytes", @@ -1495,24 +1495,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "heed" -version = "0.20.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d4f449bab7320c56003d37732a917e18798e2f1709d80263face2b4f9436ddb" -dependencies = [ - "bitflags", - "byteorder", - "heed-traits", - "heed-types 0.20.1", - "libc", - "lmdb-master-sys", - "once_cell", - "page_size", - "synchronoise", - "url", -] - [[package]] name = "heed" version = "0.21.0" @@ -1522,7 +1504,7 @@ dependencies = [ "bitflags", "byteorder", "heed-traits", - "heed-types 0.21.0", + "heed-types", "libc", "lmdb-master-sys", "once_cell", @@ -1538,16 +1520,6 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb3130048d404c57ce5a1ac61a903696e8fcde7e8c2991e9fcfc1f27c3ef74ff" -[[package]] -name = "heed-types" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d3f528b053a6d700b2734eabcd0fd49cb8230647aa72958467527b0b7917114" -dependencies = [ - "byteorder", - "heed-traits", -] - [[package]] name = "heed-types" version = "0.21.0" @@ -1621,14 +1593,16 @@ checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" [[package]] name = "http-relay" -version = "0.1.0" -source = "git+https://github.com/pubky/pubky?branch=v0.4.0-rc1#30237c43cbd07d472cd5e5b77b64a343d832647e" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0043bce2a7f4a4fbc870c4489223052b3aba084ead8a39581ea69d3e9a3e04a9" dependencies = [ "anyhow", - "axum 0.7.9", + "axum", "axum-server", "futures-util", "tokio", + "tower-http", "tracing", "url", ] @@ -2058,23 +2032,39 @@ version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +[[package]] +name = "loom" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + [[package]] name = "lru" -version = "0.12.5" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" [[package]] name = "mainline" -version = "4.2.0" -source = "git+https://github.com/pubky/mainline?branch=v5-rc1#9899b4dd582d53d75f7ada7bde3c345d21fe4f29" +version = "5.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb915972046c6df12b1292ed24f7382ed21facd440f9f6ca9c38e0b702217009" dependencies = [ "crc", "document-features", + "dyn-clone", "ed25519-dalek", "flume", + "futures-lite", "lru", - "rand", + "rand 0.9.0", "serde", "serde_bencode", "serde_bytes", @@ -2092,12 +2082,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - [[package]] name = "matchit" version = "0.8.4" @@ -2155,23 +2139,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "multer" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" -dependencies = [ - "bytes", - "encoding_rs", - "futures-util", - "http", - "httparse", - "memchr", - "mime", - "spin", - "version_check", -] - [[package]] name = "nanorand" version = "0.7.0" @@ -2338,9 +2305,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.70" +version = "0.10.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" +checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" dependencies = [ "bitflags", "cfg-if", @@ -2370,9 +2337,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.105" +version = "0.9.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" +checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" dependencies = [ "cc", "libc", @@ -2422,7 +2389,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -2441,7 +2408,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" dependencies = [ "base64ct", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -2484,7 +2451,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", - "rand", + "rand 0.8.5", ] [[package]] @@ -2543,27 +2510,59 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkarr" -version = "3.0.0" -source = "git+https://github.com/pubky/pkarr?branch=v3-rc1#2d0f4ba0ac6741974201c85dc5703f094ea948b1" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb8be2e97e822e41c6e254706e732e02ca2c49f4da038042c11d5a5e5961a164" dependencies = [ + "async-compat", "base32", "byteorder", + "bytes", + "cfg_aliases", "document-features", "dyn-clone", "ed25519-dalek", - "flume", - "futures", + "futures-lite", + "getrandom 0.2.15", + "heed", + "log", + "lru", + "mainline", + "page_size", + "pubky-timestamp", + "self_cell", + "serde", + "sha1_smol", + "simple-dns", + "thiserror 2.0.11", + "tokio", + "tracing", + "wasm-bindgen-futures", +] + +[[package]] +name = "pkarr" +version = "3.3.1" +source = "git+https://github.com/pubky/pkarr?rev=4269e68#4269e689c1782600a603e214eea621230ff04e7d" +dependencies = [ + "async-compat", + "base32", + "byteorder", + "bytes", + "cfg_aliases", + "document-features", + "dyn-clone", + "ed25519-dalek", + "futures-buffered", "futures-lite", "genawaiter", "getrandom 0.2.15", - "heed 0.20.5", - "js-sys", + "heed", + "log", "lru", "mainline", - "once_cell", "page_size", "pubky-timestamp", - "rand", "reqwest", "rustls", "rustls-webpki", @@ -2580,11 +2579,11 @@ dependencies = [ [[package]] name = "pkarr-relay" -version = "0.1.0" -source = "git+https://github.com/pubky/pkarr?branch=v3-rc1#2d0f4ba0ac6741974201c85dc5703f094ea948b1" +version = "0.5.6" +source = "git+https://github.com/pubky/pkarr?rev=4269e68#4269e689c1782600a603e214eea621230ff04e7d" dependencies = [ "anyhow", - "axum 0.7.9", + "axum", "axum-server", "bytes", "clap", @@ -2593,8 +2592,7 @@ dependencies = [ "http", "httpdate", "mainline", - "pkarr", - "pubky-timestamp", + "pkarr 3.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustls", "serde", "thiserror 2.0.11", @@ -2604,6 +2602,7 @@ dependencies = [ "tower_governor", "tracing", "tracing-subscriber", + "url", ] [[package]] @@ -2692,7 +2691,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -2712,20 +2711,24 @@ checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" [[package]] name = "pubky" -version = "0.3.0" -source = "git+https://github.com/pubky/pubky?branch=v0.4.0-rc1#30237c43cbd07d472cd5e5b77b64a343d832647e" +version = "0.4.0" +source = "git+https://github.com/pubky/pubky?branch=main#3489a88ed5b018f76273ec4f5d1fcdc2752d1d33" dependencies = [ "anyhow", "base64 0.22.1", "bytes", + "cfg_aliases", "console_log", "cookie", "cookie_store", + "flume", "futures-lite", + "futures-util", + "getrandom 0.2.15", + "getrandom 0.3.1", "js-sys", "log", - "mainline", - "pkarr", + "pkarr 3.3.1 (git+https://github.com/pubky/pkarr?rev=4269e68)", "pubky-common", "reqwest", "thiserror 2.0.11", @@ -2739,14 +2742,14 @@ dependencies = [ [[package]] name = "pubky-app-specs" -version = "0.3.0" -source = "git+https://github.com/pubky/pubky-app-specs#fb0cd01d616e9089e3513d5600ae99ced276f6ed" +version = "0.3.1" +source = "git+https://github.com/pubky/pubky-app-specs?branch=main#dec1359e2b593f74c1d12b1192c7d21123010719" dependencies = [ "base32", "blake3", "js-sys", "mime", - "pkarr", + "pkarr 3.3.1 (git+https://github.com/pubky/pkarr?rev=4269e68)", "serde", "serde-wasm-bindgen", "serde_json", @@ -2758,8 +2761,8 @@ dependencies = [ [[package]] name = "pubky-common" -version = "0.1.0" -source = "git+https://github.com/pubky/pubky?branch=v0.4.0-rc1#30237c43cbd07d472cd5e5b77b64a343d832647e" +version = "0.3.0" +source = "git+https://github.com/pubky/pubky?branch=main#3489a88ed5b018f76273ec4f5d1fcdc2752d1d33" dependencies = [ "argon2", "base32", @@ -2768,10 +2771,10 @@ dependencies = [ "ed25519-dalek", "js-sys", "once_cell", - "pkarr", + "pkarr 3.3.1 (git+https://github.com/pubky/pkarr?rev=4269e68)", "postcard", "pubky-timestamp", - "rand", + "rand 0.9.0", "serde", "thiserror 2.0.11", ] @@ -2779,10 +2782,10 @@ dependencies = [ [[package]] name = "pubky-homeserver" version = "0.1.0" -source = "git+https://github.com/pubky/pubky?branch=v0.4.0-rc1#30237c43cbd07d472cd5e5b77b64a343d832647e" +source = "git+https://github.com/pubky/pubky?branch=main#3489a88ed5b018f76273ec4f5d1fcdc2752d1d33" dependencies = [ "anyhow", - "axum 0.7.9", + "axum", "axum-extra", "axum-server", "base32", @@ -2791,14 +2794,11 @@ dependencies = [ "dirs-next", "flume", "futures-util", - "heed 0.21.0", + "heed", "hex", - "http-relay", "httpdate", - "mainline", "page_size", - "pkarr", - "pkarr-relay", + "pkarr 3.3.1 (git+https://github.com/pubky/pkarr?rev=4269e68)", "postcard", "pubky-common", "serde", @@ -2818,7 +2818,7 @@ version = "0.2.0" dependencies = [ "anyhow", "async-trait", - "axum 0.8.1", + "axum", "base32", "blake3", "bytes", @@ -2829,14 +2829,14 @@ dependencies = [ "env_logger", "httpc-test", "log", - "mainline", "neo4rs", "once_cell", - "pkarr", + "pkarr 3.3.1 (git+https://github.com/pubky/pkarr?rev=4269e68)", "pubky", "pubky-app-specs", "pubky-homeserver", - "rand", + "pubky-testnet", + "rand 0.8.5", "rand_distr", "redis", "reqwest", @@ -2851,11 +2851,28 @@ dependencies = [ "utoipa-swagger-ui", ] +[[package]] +name = "pubky-testnet" +version = "0.1.0" +source = "git+https://github.com/pubky/pubky?branch=main#3489a88ed5b018f76273ec4f5d1fcdc2752d1d33" +dependencies = [ + "anyhow", + "http-relay", + "mainline", + "pkarr-relay", + "pubky", + "pubky-common", + "pubky-homeserver", + "tokio", + "tracing-subscriber", + "url", +] + [[package]] name = "pubky-timestamp" -version = "0.2.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084b6e5bfcc186781b71257d636b660f20e94bb588c3ba52393fd9faf7a7bfda" +checksum = "44aafc63c1eab1905e8a8378d2b085500540c9935b6d028908c8a50a5a246a3d" dependencies = [ "base32", "document-features", @@ -2917,7 +2934,7 @@ checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", "getrandom 0.2.15", - "rand", + "rand 0.8.5", "ring", "rustc-hash", "rustls", @@ -2931,9 +2948,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" +checksum = "e46f3055866785f6b92bc6164b76be02ca8f2eb4b002c0354b28cf4c119e5944" dependencies = [ "cfg_aliases", "libc", @@ -2959,8 +2976,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.1", + "zerocopy 0.8.18", ] [[package]] @@ -2970,7 +2998,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.1", ] [[package]] @@ -2982,6 +3020,16 @@ dependencies = [ "getrandom 0.2.15", ] +[[package]] +name = "rand_core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3" +dependencies = [ + "getrandom 0.3.1", + "zerocopy 0.8.18", +] + [[package]] name = "rand_distr" version = "0.4.3" @@ -2989,14 +3037,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", ] [[package]] name = "raw-cpuid" -version = "11.3.0" +version = "11.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6928fa44c097620b706542d428957635951bade7143269085389d42c8a4927e" +checksum = "529468c1335c1c03919960dfefdb1b3648858c20d7ec2d0663e728e4a717efbc" dependencies = [ "bitflags", ] @@ -3180,15 +3228,14 @@ checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" [[package]] name = "ring" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24" dependencies = [ "cc", "cfg-if", "getrandom 0.2.15", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -3356,6 +3403,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -3548,7 +3601,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -3583,9 +3636,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" @@ -3717,9 +3770,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.16.0" +version = "3.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", "fastrand", @@ -3996,12 +4049,11 @@ dependencies = [ [[package]] name = "tower-cookies" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fd0118512cf0b3768f7fcccf0bef1ae41d68f2b45edc1e77432b36c97c56c6d" +checksum = "151b5a3e3c45df17466454bb74e9ecedecc955269bdedbf4d150dfa393b55a36" dependencies = [ - "async-trait", - "axum-core 0.4.5", + "axum-core", "cookie", "futures-util", "http", @@ -4050,16 +4102,16 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tower_governor" -version = "0.4.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aea939ea6cfa7c4880f3e7422616624f97a567c16df67b53b11f0d03917a8e46" +checksum = "57a2ccff6830fa835371af7541e561a90e4c07b84f72991ebac4b3cb6790dc0d" dependencies = [ - "axum 0.7.9", + "axum", "forwarded-header-value", "governor", "http", "pin-project", - "thiserror 1.0.69", + "thiserror 2.0.11", "tower 0.5.2", "tracing", ] @@ -4134,9 +4186,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unicase" @@ -4146,9 +4198,9 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" [[package]] name = "unicode-xid" @@ -4230,7 +4282,7 @@ version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "161166ec520c50144922a625d8bc4925cc801b2dda958ab69878527c0e5c5d61" dependencies = [ - "axum 0.8.1", + "axum", "base64 0.22.1", "mime_guess", "regex", @@ -4425,13 +4477,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-core" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -4442,7 +4503,7 @@ checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result", "windows-strings", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -4451,7 +4512,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -4461,7 +4522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ "windows-result", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -4470,7 +4531,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -4479,7 +4540,22 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -4488,28 +4564,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -4522,24 +4616,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -4607,7 +4725,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79386d31a42a4996e3336b0919ddb90f81112af416270cff95b5f5af22b839c2" +dependencies = [ + "zerocopy-derive 0.8.18", ] [[package]] @@ -4621,6 +4748,17 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "zerocopy-derive" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76331675d372f91bf8d17e13afbd5fe639200b73d01f0fc748bb059f9cca2db7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "zerofrom" version = "0.1.5" diff --git a/Cargo.toml b/Cargo.toml index c5763db0..ac89ae49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ build = "build.rs" [dependencies] bytes = "1.9.0" # Enforce this version as Pubky and Axum conflict v1.7.1 vs v1.9.0 -pkarr = { git = "https://github.com/pubky/pkarr", branch = "v3-rc1", package = "pkarr" } -mainline = { git = "https://github.com/pubky/mainline", branch = "v5-rc1", default-features = false } -pubky = { git = "https://github.com/pubky/pubky", branch = "v0.4.0-rc1" } -pubky-app-specs = { git = "https://github.com/pubky/pubky-app-specs", features = [ +pkarr = { git = "https://github.com/pubky/pkarr", rev = "4269e68" } # a few commits after v3.3.1 +pubky = { git = "https://github.com/pubky/pubky", branch = "main" } +pubky-testnet = { git = "https://github.com/pubky/pubky", branch = "main" } +pubky-app-specs = { git = "https://github.com/pubky/pubky-app-specs", branch = "main", features = [ "openapi", ] } tokio = { version = "1.43.0", features = ["full"] } @@ -43,7 +43,7 @@ reqwest = "0.12.9" anyhow = "1.0.95" httpc-test = "0.1.10" criterion = { version = "0.5.1", features = ["async_tokio"] } -pubky-homeserver = { git = "https://github.com/pubky/pubky", branch = "v0.4.0-rc1" } +pubky-homeserver = { git = "https://github.com/pubky/pubky", branch = "main" } rand = "0.8.5" rand_distr = "0.4.3" tokio-shared-rt = "0.1" diff --git a/benches/watcher.rs b/benches/watcher.rs index fa45d734..d038fbf0 100644 --- a/benches/watcher.rs +++ b/benches/watcher.rs @@ -1,10 +1,8 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use mainline::Testnet; use pkarr::Keypair; -use pubky::Client; use pubky_app_specs::{PubkyAppUser, PubkyAppUserLink}; -use pubky_homeserver::Homeserver; use pubky_nexus::EventProcessor; +use pubky_testnet::Testnet; use setup::run_setup; use std::time::Duration; use tokio::runtime::Runtime; @@ -18,9 +16,9 @@ mod setup; /// 4. Delete the profile.json async fn create_homeserver_with_events() -> (Testnet, String) { // Create the test environment - let testnet = Testnet::new(3).unwrap(); - let homeserver = Homeserver::start_test(&testnet).await.unwrap(); - let client = Client::builder().testnet(&testnet).build().unwrap(); + let testnet = Testnet::run().await.unwrap(); + let homeserver = testnet.run_homeserver().await.unwrap(); + let client = testnet.client_builder().build().unwrap(); let homeserver_url = homeserver.url().to_string(); // Generate user data diff --git a/examples/from_file.rs b/examples/from_file.rs index 7514f250..c4a65e39 100644 --- a/examples/from_file.rs +++ b/examples/from_file.rs @@ -15,7 +15,7 @@ async fn main() -> Result<(), DynError> { let config = Config::from_env(); StackManager::setup(&config).await; - PubkyConnector::initialise(&config, None).await?; + PubkyConnector::initialise(&config).await?; let mut event_processor = EventProcessor::from_config(&config).await?; diff --git a/examples/stress_network_sim.rs b/examples/stress_network_sim.rs index ca63df85..5ed9b638 100644 --- a/examples/stress_network_sim.rs +++ b/examples/stress_network_sim.rs @@ -39,10 +39,13 @@ async fn main() -> Result<()> { let config = Config::from_env(); // Initialize the Client based on configuration - let client = match config.testnet { - true => Client::testnet()?, - false => Client::new()?, - }; + // let client = match config.testnet { + // true => Client::testnet()?, + // false => Client::new()?, + // }; + + // Only mainnet + let client = Client::builder().build()?; // Convert the homeserver from the config into a PublicKey let homeserver = PublicKey::try_from(config.homeserver.as_str())?; diff --git a/examples/test_testnet.rs b/examples/test_testnet.rs new file mode 100644 index 00000000..551ba663 --- /dev/null +++ b/examples/test_testnet.rs @@ -0,0 +1,38 @@ +use pkarr::Keypair; +use pubky_testnet::Testnet; + +#[tokio::main] +async fn main() { + // Run a new testnet. + let testnet = Testnet::run().await.unwrap(); + + // Optionally create and run a Homeserver. + let server = testnet.run_homeserver().await.unwrap(); + + // Create a Pubky Client from the testnet. + let client = testnet.client_builder().build().unwrap(); + + let keypair = Keypair::random(); + + client.signup(&keypair, &server.public_key()).await.unwrap(); + client + .put(format!( + "pubky://{}/pub/pubky.app/object", + keypair.public_key(), + )) + .body([0, 1, 2, 3].to_vec()) + .send() + .await + .unwrap(); + + let response = client + .get(format!( + "https://{}/events/?cursor=0000000000000&limit=1000", + server.public_key() + )) + .send() + .await + .unwrap(); + + println!("Event Lines: {}", response.text().await.unwrap()) +} diff --git a/src/db/connectors/pubky.rs b/src/db/connectors/pubky.rs index 98ea92c9..e43d05d8 100644 --- a/src/db/connectors/pubky.rs +++ b/src/db/connectors/pubky.rs @@ -1,10 +1,10 @@ -use crate::Config; -use mainline::Testnet; use pubky::Client; use std::sync::Arc; use thiserror::Error; use tokio::sync::OnceCell; +use crate::Config; + static PUBKY_CONNECTOR_SINGLETON: OnceCell> = OnceCell::const_new(); #[derive(Debug, Error)] @@ -26,26 +26,20 @@ pub struct PubkyConnector; impl PubkyConnector { /// Initializes the PubkyConnector singleton with the given configuration - pub async fn initialise( - config: &Config, - testnet: Option<&Testnet>, - ) -> Result<(), PubkyConnectorError> { + pub async fn initialise(config: &Config) -> Result<(), PubkyConnectorError> { PUBKY_CONNECTOR_SINGLETON .get_or_try_init(|| async { - let pubky_client = match testnet { - Some(testnet) => Client::builder() - .testnet(testnet) + let client = match config.testnet { + true => Client::builder() + .testnet() + .build() + .map_err(|e| PubkyConnectorError::ClientError(e.to_string()))?, + false => Client::builder() .build() .map_err(|e| PubkyConnectorError::ClientError(e.to_string()))?, - None => match config.testnet { - true => Client::testnet() - .map_err(|e| PubkyConnectorError::ClientError(e.to_string()))?, - false => Client::new() - .map_err(|e| PubkyConnectorError::ClientError(e.to_string()))?, - }, }; - Ok(Arc::new(pubky_client)) + Ok(Arc::new(client)) }) .await .map(|_| ()) @@ -58,4 +52,11 @@ impl PubkyConnector { .cloned() .ok_or(PubkyConnectorError::NotInitialized) } + + pub async fn init_from_client(client: Client) -> Result<(), PubkyConnectorError> { + PUBKY_CONNECTOR_SINGLETON + .get_or_try_init(|| async { Ok(Arc::new(client)) }) + .await + .map(|_| ()) + } } diff --git a/src/watcher.rs b/src/watcher.rs index 5a49de2d..c6942454 100644 --- a/src/watcher.rs +++ b/src/watcher.rs @@ -11,7 +11,7 @@ async fn main() -> Result<(), Box> { StackManager::setup(&config).await; - PubkyConnector::initialise(&config, None).await?; + PubkyConnector::initialise(&config).await?; let mut event_processor = EventProcessor::from_config(&config).await?; diff --git a/tests/watcher/users/del_with_relations.rs b/tests/watcher/users/del_with_relations.rs index f5576f2e..bae44648 100644 --- a/tests/watcher/users/del_with_relations.rs +++ b/tests/watcher/users/del_with_relations.rs @@ -13,6 +13,7 @@ use pubky_nexus::{ models::user::{UserCounts, UserView}, PubkyConnector, }; + #[tokio_shared_rt::test(shared)] async fn test_delete_user_with_relationships() -> Result<()> { let mut test = WatcherTest::setup().await?; @@ -83,7 +84,7 @@ async fn test_delete_user_with_relationships() -> Result<()> { test.cleanup_post(&user_id, &post_id).await?; // Write and delete the user again; this time it should be fully removed - test.create_user(&keypair, &user).await?; + test.create_profile(&user_id, &user).await?; test.cleanup_user(&user_id).await?; // Attempt to find user details; should not exist @@ -151,7 +152,7 @@ async fn test_delete_user_with_relationships() -> Result<()> { name: "Watcher:UserDeleteWith:UserWith".to_string(), status: Some("Zombie soon".to_string()), }; - let _ = test.create_user(&keypair, &user_with).await?; + let _ = test.create_profile(&user_with_id, &user_with).await?; // Create a post to establish a relationship let post_b = PubkyAppPost { @@ -210,7 +211,7 @@ async fn test_delete_user_with_relationships() -> Result<()> { test.cleanup_post(&user_with_id, &post_b_id).await?; // Write and delete the user again; this time it should be fully removed - test.create_user(&keypair, &user_with).await?; + test.create_profile(&user_with_id, &user_with).await?; test.cleanup_user(&user_with_id).await?; // Delete the file test.cleanup_file(&user_with_id, &file_id).await?; diff --git a/tests/watcher/utils/dht.rs b/tests/watcher/utils/dht.rs deleted file mode 100644 index 11663afd..00000000 --- a/tests/watcher/utils/dht.rs +++ /dev/null @@ -1,49 +0,0 @@ -use anyhow::{anyhow, Error}; -use log::warn; -use mainline::Testnet; -use std::sync::Arc; -use tokio::sync::OnceCell; - -static DHT_TESTNET_NETWORK_SINGLETON: OnceCell = OnceCell::const_new(); - -/// Represents a test network for the Distributed Hash Table (DHT). -pub struct TestnetDHTNetwork { - nodes: Arc, -} - -impl TestnetDHTNetwork { - /// Initializes the DHT test network singleton. - /// - /// Sets up the global `DHT_TESTNET_NETWORK_SINGLETON` with a new - /// `TestnetDHTNetwork` instance if it has not already been initialized. - /// The initialization creates a testnet with a specified capacity. - /// # Parameters - /// - `nodes`: The number of DHT nodes to create in the testnet network. - pub fn initialise(nodes: usize) -> Result<(), Error> { - if DHT_TESTNET_NETWORK_SINGLETON.get().is_some() { - return Ok(()); - } - let testnet = Self { - // TODO: maybe add the node number in environment variable - nodes: Arc::new(Testnet::new(nodes)?), - }; - if let Err(_) = DHT_TESTNET_NETWORK_SINGLETON.set(testnet) { - warn!("DHT Testnet network was already initialized."); - return Ok(()); - } - - Ok(()) - } - - /// Retrieves the DHT test network nodes. - /// - /// Provides access to the global DHT network's nodes stored in - /// the `DHT_TESTNET_NETWORK_SINGLETON` - pub fn get_testnet_dht_nodes() -> Result, Error> { - if let Some(resolver) = DHT_TESTNET_NETWORK_SINGLETON.get() { - Ok(resolver.nodes.clone()) - } else { - Err(anyhow!("DHT testnet network not initialised")) - } - } -} diff --git a/tests/watcher/utils/mod.rs b/tests/watcher/utils/mod.rs index b9191fd5..e99d313c 100644 --- a/tests/watcher/utils/mod.rs +++ b/tests/watcher/utils/mod.rs @@ -1,2 +1,2 @@ -mod dht; +pub mod testnet; pub mod watcher; diff --git a/tests/watcher/utils/testnet.rs b/tests/watcher/utils/testnet.rs new file mode 100644 index 00000000..c0a0aa34 --- /dev/null +++ b/tests/watcher/utils/testnet.rs @@ -0,0 +1,29 @@ +use anyhow::Error; +use pubky_testnet::Testnet; +use std::sync::Arc; +use tokio::sync::OnceCell; + +static TESTNET_NETWORK: OnceCell = OnceCell::const_new(); + +/// Represents a test network for the Distributed Hash Table (DHT). +pub struct TestnetNetwork { + nodes: Arc, +} + +impl TestnetNetwork { + /// Returns the testnet. This method will initialize the testnet if it hasn't been + /// already, and will wait for the initialization to complete if another task is doing it. + pub async fn get() -> Result, Error> { + let network = TESTNET_NETWORK + .get_or_init(|| async { + let testnet = Testnet::run() + .await + .expect("Failed to run testnet with hardcoded configurations"); + TestnetNetwork { + nodes: Arc::new(testnet), + } + }) + .await; + Ok(network.nodes.clone()) + } +} diff --git a/tests/watcher/utils/watcher.rs b/tests/watcher/utils/watcher.rs index d58e2737..eef46c11 100644 --- a/tests/watcher/utils/watcher.rs +++ b/tests/watcher/utils/watcher.rs @@ -1,6 +1,4 @@ -use std::time::Duration; - -use super::dht::TestnetDHTNetwork; +use super::testnet::TestnetNetwork; use anyhow::{anyhow, Result}; use chrono::Utc; use log::debug; @@ -13,6 +11,7 @@ use pubky_nexus::events::retry::event::RetryEvent; use pubky_nexus::events::Event; use pubky_nexus::types::DynError; use pubky_nexus::{Config, EventProcessor, PubkyConnector, StackManager}; +use std::time::Duration; /// Struct to hold the setup environment for tests pub struct WatcherTest { @@ -40,13 +39,15 @@ impl WatcherTest { let config = Config::from_env(); StackManager::setup(&config).await; - TestnetDHTNetwork::initialise(10)?; - let testnet = TestnetDHTNetwork::get_testnet_dht_nodes()?; + // testnet initialization is time expensive, we only init one per process + let testnet = TestnetNetwork::get().await?; - let homeserver = Homeserver::start_test(&testnet).await?; + let homeserver = testnet.run_homeserver().await.unwrap(); let homeserver_id = homeserver.public_key().to_string(); - match PubkyConnector::initialise(&config, Some(&testnet)).await { + let client = testnet.client_builder().build().unwrap(); + + match PubkyConnector::init_from_client(client).await { Ok(_) => debug!("WatcherTest: PubkyConnector initialised"), Err(e) => debug!("WatcherTest: {}", e), } @@ -145,6 +146,18 @@ impl WatcherTest { Ok(user_id) } + pub async fn create_profile(&mut self, user_id: &str, user: &PubkyAppUser) -> Result { + let pubky_client = PubkyConnector::get_pubky_client()?; + let url = format!("pubky://{}/pub/pubky.app/profile.json", user_id); + + // Write the user profile in the pubky.app repository + pubky_client.put(url.as_str()).json(&user).send().await?; + + // Index to Nexus from Homeserver using the events processor + self.ensure_event_processing_complete().await?; + Ok(user_id.to_string()) + } + pub async fn create_post(&mut self, user_id: &str, post: &PubkyAppPost) -> Result { let post_id = post.create_id(); let url = format!("pubky://{}/pub/pubky.app/posts/{}", user_id, post_id);