From a7e64695f92d7ce345eb63eec69fee840002f35f Mon Sep 17 00:00:00 2001 From: Shunsuke Watanabe Date: Sun, 9 Jun 2024 14:28:15 +0900 Subject: [PATCH] Bump hyper version to v1 (#184) * major update hyper version * make subway server builder compatible with hyper v1 * update jsonrpsee dep to v0.23.x * remove unncessary clone * cargo fmt * fix format issue * overwrite addr to the one with actual allocated port --- Cargo.lock | 466 +++++++++++++-------- Cargo.toml | 10 +- benches/bench/helpers.rs | 22 +- src/extensions/client/mock.rs | 6 +- src/extensions/client/mod.rs | 10 +- src/extensions/server/mod.rs | 237 ++++++----- src/extensions/server/proxy_get_request.rs | 62 +-- src/server.rs | 10 +- 8 files changed, 490 insertions(+), 333 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 160cd18..ade4dbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,9 +138,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-compression" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c90a406b4495d129f00461241616194cb8a032c8d1c53c657f0961d5f8e0498" +checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" dependencies = [ "brotli", "flate2", @@ -196,6 +196,12 @@ dependencies = [ "syn", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -213,9 +219,9 @@ dependencies = [ "bitflags 1.3.2", "bytes 1.6.0", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "itoa", "matchit", "memchr", @@ -239,8 +245,8 @@ dependencies = [ "async-trait", "bytes 1.6.0", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "mime", "rustversion", "tower-layer", @@ -262,12 +268,6 @@ dependencies = [ "rustc-demangle", ] -[[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.7" @@ -331,15 +331,6 @@ dependencies = [ "generic-array 0.12.4", ] -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -371,9 +362,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6221fe77a248b9117d431ad93761222e1cf8ff282d9d1d5d9f53d6299a1cf76" +checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -465,6 +456,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "0.1.10" @@ -564,6 +561,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes 1.6.0", + "memchr", +] + [[package]] name = "compact_str" version = "0.7.1" @@ -786,15 +793,6 @@ dependencies = [ "generic-array 0.12.4", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "digest" version = "0.10.7" @@ -1155,7 +1153,7 @@ dependencies = [ "futures-core", "futures-sink", "gloo-utils", - "http", + "http 0.2.12", "js-sys", "pin-project", "serde", @@ -1218,7 +1216,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util 0.7.11", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes 1.6.0", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap 2.2.6", "slab", "tokio", @@ -1290,6 +1307,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes 1.6.0", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1297,15 +1325,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes 1.6.0", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes 1.6.0", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes 1.6.0", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", "pin-project-lite", ] [[package]] name = "http-range-header" -version = "0.3.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a" [[package]] name = "httparse" @@ -1335,9 +1386,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1349,20 +1400,43 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes 1.6.0", + "futures-channel", + "futures-util", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", - "http", - "hyper", + "http 1.1.0", + "hyper 1.3.1", + "hyper-util", "log", - "rustls 0.21.12", - "rustls-native-certs 0.6.3", + "rustls", + "rustls-pki-types", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", + "tower-service", ] [[package]] @@ -1371,12 +1445,32 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.28", "pin-project-lite", "tokio", "tokio-io-timeout", ] +[[package]] +name = "hyper-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +dependencies = [ + "bytes 1.6.0", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.3.1", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1548,6 +1642,26 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jni" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.31" @@ -1588,7 +1702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff" dependencies = [ "futures", - "hyper", + "hyper 0.14.28", "jsonrpc-core", "jsonrpc-server-utils", "log", @@ -1647,9 +1761,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdb12a2381ea5b2e68c3469ec604a007b367778cdb14d09612c8069ebd616ad" +checksum = "67210bd846b2dca59dc73f34717d6e1589305d506cdd6f14c849115d08e40876" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -1665,40 +1779,44 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4978087a58c3ab02efc5b07c5e5e2803024536106fd5506f558db172c889b3aa" +checksum = "e4c171d64176ae8f57eec75bca9f9dda2b2f746314adef9160a5bbbb2a7c82cb" dependencies = [ + "base64 0.22.1", "futures-channel", "futures-util", "gloo-net", - "http", + "http 1.1.0", "jsonrpsee-core", "pin-project", - "rustls-native-certs 0.7.0", + "rustls", "rustls-pki-types", + "rustls-platform-verifier", "soketto", "thiserror", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls", "tokio-util 0.7.11", "tracing", "url", - "webpki-roots", ] [[package]] name = "jsonrpsee-core" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257e1ec385e07b0255dde0b933f948b5c8b8c28d42afda9587c3a967b896d" +checksum = "5e966c12c8b6c1790ce67683c792cea9dd250860df49f6b64f1b1ff6c6946850" dependencies = [ "anyhow", "async-trait", "beef", + "bytes 1.6.0", "futures-timer", "futures-util", - "hyper", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "jsonrpsee-types", "parking_lot 0.12.2", "pin-project", @@ -1715,15 +1833,20 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ccf93fc4a0bfe05d851d37d7c32b7f370fe94336b52a2f0efc5f1981895c2e5" +checksum = "bb0187f1969287e5890d84460fe9f6556d98231e70b06179d4416e5c8c47167d" dependencies = [ "async-trait", - "hyper", + "base64 0.22.1", + "http-body 1.0.0", + "hyper 1.3.1", "hyper-rustls", + "hyper-util", "jsonrpsee-core", "jsonrpsee-types", + "rustls", + "rustls-platform-verifier", "serde", "serde_json", "thiserror", @@ -1735,11 +1858,11 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d0bb047e79a143b32ea03974a6bf59b62c2a4c5f5d42a381c907a8bbb3f75c0" +checksum = "9f7af1b5071dc1c61b06900f8f3e17f886b1b08e926166e575018643879f63b6" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro-crate", "proc-macro2", "quote", @@ -1748,13 +1871,17 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12d8b6a9674422a8572e0b0abb12feeb3f2aeda86528c80d0350c2bd0923ab41" +checksum = "ba63ec742f5f9c4016ca4c443d04dc3ca56e240a26ebe6e56609a5109bd9d13f" dependencies = [ + "anyhow", "futures-util", - "http", - "hyper", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-util", "jsonrpsee-core", "jsonrpsee-types", "pin-project", @@ -1772,12 +1899,13 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150d6168405890a7a3231a3c74843f58b8959471f6df76078db2619ddee1d07d" +checksum = "328c33717b7bdc4f47cdf31c21d5449c5b713a800cb05cb767841ccf2944f9d9" dependencies = [ "anyhow", "beef", + "http 1.1.0", "serde", "serde_json", "thiserror", @@ -1785,9 +1913,9 @@ dependencies = [ [[package]] name = "jsonrpsee-wasm-client" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f448d8eacd945cc17b6c0b42c361531ca36a962ee186342a97cdb8fca679cd77" +checksum = "6c1c1b2f71c32f763d85c1b9836c1a522377b3972177a76b3e66ba42f2582929" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -1796,11 +1924,11 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.22.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58b9db2dfd5bb1194b0ce921504df9ceae210a345bc2f6c5a61432089bbab070" +checksum = "aeb22661e1c018eb503d5a47be2d39a176de832b047d2757fa86b3d2b34fc84e" dependencies = [ - "http", + "http 1.1.0", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", @@ -2074,6 +2202,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "num-bigint" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "num-format" version = "0.4.4" @@ -2084,6 +2222,15 @@ dependencies = [ "itoa", ] +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -2136,12 +2283,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "openssl-probe" version = "0.1.5" @@ -2171,7 +2312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e09667367cb509f10d7cf5960a83f9c4d96e93715f750b164b4b98d46c3cbf4" dependencies = [ "futures-core", - "http", + "http 0.2.12", "indexmap 2.2.6", "itertools 0.11.0", "once_cell", @@ -2193,7 +2334,7 @@ checksum = "7f51189ce8be654f9b5f7e70e49967ed894e84a06fc35c6c042e64ac1fc5399e" dependencies = [ "async-trait", "bytes 1.6.0", - "http", + "http 0.2.12", "opentelemetry", "reqwest", ] @@ -2281,7 +2422,7 @@ dependencies = [ "mio 0.6.23", "mio-extras", "rand 0.7.3", - "sha-1 0.8.2", + "sha-1", "slab", "url", ] @@ -2783,10 +2924,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "ipnet", "js-sys", "log", @@ -2885,42 +3026,19 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.12" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" -dependencies = [ - "log", - "ring", - "rustls-webpki 0.101.7", - "sct", -] - -[[package]] -name = "rustls" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "ebbbdb961df0ad3f2652da8f3fdc4b36122f568f968f45ad3316f26c025c677b" dependencies = [ "log", + "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.3", + "rustls-webpki", "subtle", "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" -dependencies = [ - "openssl-probe", - "rustls-pemfile 1.0.4", - "schannel", - "security-framework", -] - [[package]] name = "rustls-native-certs" version = "0.7.0" @@ -2928,21 +3046,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.2", + "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.1.2" @@ -2960,15 +3069,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] -name = "rustls-webpki" -version = "0.101.7" +name = "rustls-platform-verifier" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +checksum = "b5f0d26fa1ce3c790f9590868f0109289a044acb954525f933e2aa3b871c157d" dependencies = [ - "ring", - "untrusted", + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-roots", + "winapi 0.3.9", ] +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad" + [[package]] name = "rustls-webpki" version = "0.102.3" @@ -3016,16 +3142,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "security-framework" version = "2.11.0" @@ -3036,6 +3152,7 @@ dependencies = [ "core-foundation", "core-foundation-sys", "libc", + "num-bigint", "security-framework-sys", ] @@ -3126,20 +3243,18 @@ dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", - "opaque-debug 0.2.3", + "opaque-debug", ] [[package]] -name = "sha-1" -version = "0.9.8" +name = "sha1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "block-buffer 0.9.0", "cfg-if 1.0.0", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.1", + "digest 0.10.7", ] [[package]] @@ -3190,18 +3305,18 @@ dependencies = [ [[package]] name = "soketto" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" +checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" dependencies = [ - "base64 0.13.1", + "base64 0.22.1", "bytes 1.6.0", "futures", - "http", + "http 1.1.0", "httparse", "log", "rand 0.8.5", - "sha-1 0.9.8", + "sha1", ] [[package]] @@ -3262,7 +3377,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8fe06b03b8a291c09507c42f92a2c2c10dd3d62975d02c7f64a92d87bfe09b" dependencies = [ - "hyper", + "hyper 0.14.28", "log", "prometheus", "thiserror", @@ -3291,8 +3406,10 @@ dependencies = [ "futures-util", "garde", "governor", - "http", - "hyper", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", "jsonrpc-http-server", "jsonrpc-pubsub", "jsonrpc-ws-server", @@ -3516,21 +3633,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.12", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.22.4", + "rustls", "rustls-pki-types", "tokio", ] @@ -3603,10 +3710,10 @@ dependencies = [ "axum", "base64 0.21.7", "bytes 1.6.0", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-timeout", "percent-encoding", "pin-project", @@ -3642,9 +3749,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "async-compression", "base64 0.21.7", @@ -3652,8 +3759,9 @@ dependencies = [ "bytes 1.6.0", "futures-core", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "http-range-header", "httpdate", "iri-string", diff --git a/Cargo.toml b/Cargo.toml index b3bb361..a60fd2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,10 @@ chrono = "0.4.24" clap = { version = "4.1.1", features = ["derive"] } enumflags2 = "0.7.7" futures = "0.3.25" -http = "0.2" -hyper = "0.14" +http = "1" +http-body = "1" +http-body-util = "0.1" +hyper = "1.3" moka = { version = "0.12", features = ["future"] } opentelemetry = { version = "0.21.0" } opentelemetry-datadog = { version = "0.9.0", features = ["reqwest-client"] } @@ -39,13 +41,13 @@ serde_yaml = "0.9.17" substrate-prometheus-endpoint = "0.17.0" tokio = { version = "1.24.2", features = ["full"] } tower = { version = "0.4.13", features = ["full"] } -tower-http = { version = "0.4", features = ["full"] } +tower-http = { version = "0.5.2", features = ["full"] } tracing = "0.1.40" tracing-serde = "0.1.3" tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] } garde = { version = "0.18", features = ["full"] } -jsonrpsee = { version = "0.22.1",features = ["full"] } +jsonrpsee = { version = "0.23", features = ["full"] } governor = { path = "./vendor/governor/governor" } [dev-dependencies] diff --git a/benches/bench/helpers.rs b/benches/bench/helpers.rs index 9a2d8c8..4be9906 100644 --- a/benches/bench/helpers.rs +++ b/benches/bench/helpers.rs @@ -40,7 +40,7 @@ pub async fn ws_server(handle: tokio::runtime::Handle, url: &str) -> (String, js SUB_METHOD_NAME, SUB_METHOD_NAME, UNSUB_METHOD_NAME, - |_params, pending, _ctx| async move { + |_params, pending, _ctx, _| async move { let sink = pending.accept().await?; let msg = SubscriptionMessage::from_json(&"Hello")?; sink.send(msg).await?; @@ -53,7 +53,7 @@ pub async fn ws_server(handle: tokio::runtime::Handle, url: &str) -> (String, js "chain_subscribeNewHeads", "chain_newHead", "chain_unsubscribeNewHeads", - |_params, pending, _ctx| async move { + |_params, pending, _ctx, _| async move { let sink = pending.accept().await?; let msg = SubscriptionMessage::from_json(&serde_json::json!({ "number": "0x4321" }))?; sink.send(msg).await?; @@ -66,7 +66,7 @@ pub async fn ws_server(handle: tokio::runtime::Handle, url: &str) -> (String, js "chain_subscribeFinalizedHeads", "chain_finalizedHead", "chain_unsubscribeFinalizedHeads", - |_params, pending, _ctx| async move { + |_params, pending, _ctx, _| async move { let sink = pending.accept().await?; let msg = SubscriptionMessage::from_json(&serde_json::json!({ "number": "0x4321" }))?; sink.send(msg).await?; @@ -84,47 +84,47 @@ fn gen_rpc_module() -> jsonrpsee::RpcModule<()> { let mut module = jsonrpsee::RpcModule::new(()); module - .register_method(SYNC_FAST_CALL, |_, _| Ok::<_, ErrorObjectOwned>("lo")) + .register_method(SYNC_FAST_CALL, |_, _, _| Ok::<_, ErrorObjectOwned>("lo")) .unwrap(); module - .register_async_method(ASYNC_FAST_CALL, |_, _| async { + .register_async_method(ASYNC_FAST_CALL, |_, _, _| async { Result::<_, ErrorObjectOwned>::Ok("lo") }) .unwrap(); module - .register_method(SYNC_MEM_CALL, |_, _| Ok::<_, ErrorObjectOwned>("A".repeat(MIB))) + .register_method(SYNC_MEM_CALL, |_, _, _| Ok::<_, ErrorObjectOwned>("A".repeat(MIB))) .unwrap(); module - .register_async_method(ASYNC_MEM_CALL, |_, _| async move { + .register_async_method(ASYNC_MEM_CALL, |_, _, _| async move { Result::<_, ErrorObjectOwned>::Ok("A".repeat(MIB)) }) .unwrap(); module - .register_method(SYNC_SLOW_CALL, |_, _| { + .register_method(SYNC_SLOW_CALL, |_, _, _| { std::thread::sleep(SLOW_CALL); Ok::<_, ErrorObjectOwned>("slow call") }) .unwrap(); module - .register_async_method(ASYNC_SLOW_CALL, |_, _| async move { + .register_async_method(ASYNC_SLOW_CALL, |_, _, _| async move { tokio::time::sleep(SLOW_CALL).await; Result::<_, ErrorObjectOwned>::Ok("slow call async") }) .unwrap(); module - .register_async_method(ASYNC_INJECT_CALL, |_, _| async move { + .register_async_method(ASYNC_INJECT_CALL, |_, _, _| async move { tokio::time::sleep(SLOW_CALL).await; Result::<_, ErrorObjectOwned>::Ok("inject call async") }) .unwrap(); module - .register_async_method("chain_getBlockHash", |_, _| async move { + .register_async_method("chain_getBlockHash", |_, _, _| async move { tokio::time::sleep(SLOW_CALL).await; Result::<_, ErrorObjectOwned>::Ok("0x42") }) diff --git a/src/extensions/client/mock.rs b/src/extensions/client/mock.rs index fbe0864..69d040c 100644 --- a/src/extensions/client/mock.rs +++ b/src/extensions/client/mock.rs @@ -34,7 +34,7 @@ impl TestServerBuilder { pub fn register_method(&mut self, name: &'static str) -> mpsc::Receiver { let (tx, rx) = mpsc::channel::(100); self.module - .register_async_method(name, move |params, _| { + .register_async_method(name, move |params, _, _| { let tx = tx.clone(); let params = params.parse::().unwrap(); async move { @@ -56,7 +56,7 @@ impl TestServerBuilder { ) -> mpsc::Receiver { let (tx, rx) = mpsc::channel::(100); self.module - .register_subscription(sub_name, method_name, unsub_name, move |params, sink, _| { + .register_subscription(sub_name, method_name, unsub_name, move |params, sink, _, _| { let tx = tx.clone(); let params = params.parse::().unwrap(); tokio::spawn(async move { @@ -76,7 +76,7 @@ impl TestServerBuilder { unsub_name: &'static str, ) { self.module - .register_subscription(sub_name, method_name, unsub_name, move |_, sink, _| async { + .register_subscription(sub_name, method_name, unsub_name, move |_, sink, _, _| async { sink.reject(errors::map_error(Error::Call(ErrorObject::owned( 1010, "Invalid Transaction", diff --git a/src/extensions/client/mod.rs b/src/extensions/client/mod.rs index c931d5e..2e03ea7 100644 --- a/src/extensions/client/mod.rs +++ b/src/extensions/client/mod.rs @@ -250,10 +250,7 @@ impl Client { Err(err) => { tracing::debug!("Request failed: {:?}", err); match err { - Error::RequestTimeout - | Error::Transport(_) - | Error::RestartNeeded(_) - | Error::MaxSlotsExceeded => { + Error::RequestTimeout | Error::Transport(_) | Error::RestartNeeded(_) => { tokio::time::sleep(get_backoff_time(&request_backoff_counter)).await; // make sure it's still connected @@ -329,10 +326,7 @@ impl Client { Err(err) => { tracing::debug!("Subscribe failed: {:?}", err); match err { - Error::RequestTimeout - | Error::Transport(_) - | Error::RestartNeeded(_) - | Error::MaxSlotsExceeded => { + Error::RequestTimeout | Error::Transport(_) | Error::RestartNeeded(_) => { tokio::time::sleep(get_backoff_time(&request_backoff_counter)).await; // make sure it's still connected diff --git a/src/extensions/server/mod.rs b/src/extensions/server/mod.rs index d284f42..4e38e64 100644 --- a/src/extensions/server/mod.rs +++ b/src/extensions/server/mod.rs @@ -1,22 +1,20 @@ use async_trait::async_trait; +use futures::FutureExt; use http::header::HeaderValue; -use hyper::server::conn::AddrStream; -use hyper::service::Service; -use hyper::service::{make_service_fn, service_fn}; use jsonrpsee::server::{ - middleware::rpc::RpcServiceBuilder, stop_channel, ws, BatchRequestConfig, RandomStringIdProvider, RpcModule, - ServerBuilder, ServerHandle, + middleware::rpc::RpcServiceBuilder, serve_with_graceful_shutdown, stop_channel, ws, BatchRequestConfig, + RandomStringIdProvider, RpcModule, ServerHandle, StopHandle, TowerServiceBuilder, }; use jsonrpsee::Methods; +use tokio::net::TcpListener; -use serde::ser::StdError; use serde::Deserialize; use std::str::FromStr; use std::sync::Arc; use std::{future::Future, net::SocketAddr}; use tower::layer::layer_fn; -use tower::ServiceBuilder; +use tower::Service; use tower_http::cors::{AllowOrigin, CorsLayer}; use super::{Extension, ExtensionRegistry}; @@ -113,108 +111,151 @@ impl SubwayServerBuilder { ) -> anyhow::Result<(SocketAddr, ServerHandle)> { let config = self.config.clone(); - let (stop_handle, server_handle) = stop_channel(); - let handle = stop_handle.clone(); let rpc_module = rpc_module_builder().await?; - // make_service handle each connection - let make_service = make_service_fn(move |socket: &AddrStream| { - let socket_ip = socket.remote_addr().ip().to_string(); - - let http_middleware: ServiceBuilder<_> = tower::ServiceBuilder::new() - .layer(cors_layer(config.cors.clone()).expect("Invalid CORS config")) - .layer( - ProxyGetRequestLayer::new( - config - .http_methods - .iter() - .map(|m| ProxyGetRequestMethod { - path: m.path.clone(), - method: m.method.clone(), - }) - .collect(), - ) - .expect("Invalid health config"), - ); - - let rpc_module = rpc_module.clone(); - let stop_handle = stop_handle.clone(); - let rate_limit_builder = rate_limit_builder.clone(); - let rpc_method_weights = rpc_method_weights.clone(); - let rpc_metrics = rpc_metrics.clone(); - - async move { - // service_fn handle each request - Ok::<_, Box>(service_fn(move |req| { + let http_middleware = tower::ServiceBuilder::new() + .layer(cors_layer(config.cors.clone()).expect("Invalid CORS config")) + .layer( + ProxyGetRequestLayer::new( + config + .http_methods + .iter() + .map(|m| ProxyGetRequestMethod { + path: m.path.clone(), + method: m.method.clone(), + }) + .collect(), + ) + .expect("Invalid health config"), + ); + + let batch_request_config = match config.max_batch_size { + Some(0) => BatchRequestConfig::Disabled, + Some(max_size) => BatchRequestConfig::Limit(max_size), + None => BatchRequestConfig::Unlimited, + }; + + let ip_addr = std::net::IpAddr::from_str(&self.config.listen_address)?; + let addr = SocketAddr::new(ip_addr, self.config.port); + + let listener = TcpListener::bind(addr).await?; + let addr = listener.local_addr()?; + + // This state is cloned for every connection + // all these types based on Arcs and it should + // be relatively cheap to clone them. + // + // Make sure that nothing expensive is cloned here + // when doing this or use an `Arc`. + #[derive(Clone)] + struct PerConnection { + methods: Methods, + stop_handle: StopHandle, + rpc_metrics: RpcMetrics, + svc_builder: TowerServiceBuilder, + rate_limit_builder: Option>, + rpc_method_weights: MethodWeights, + } + + // Each RPC call/connection get its own `stop_handle` + // to able to determine whether the server has been stopped or not. + // + // To keep the server running the `server_handle` + // must be kept and it can also be used to stop the server. + let (stop_handle, server_handle) = stop_channel(); + + let per_conn = PerConnection { + methods: rpc_module.into(), + stop_handle: stop_handle.clone(), + rpc_metrics, + svc_builder: jsonrpsee::server::Server::builder() + .set_http_middleware(http_middleware) + .set_batch_request_config(batch_request_config) + .max_connections(config.max_connections) + .set_id_provider(RandomStringIdProvider::new(16)) + .to_service_builder(), + rate_limit_builder, + rpc_method_weights, + }; + + tokio::spawn(async move { + loop { + // The `tokio::select!` macro is used to wait for either of the + // listeners to accept a new connection or for the server to be + // stopped. + let (sock, remote_addr) = tokio::select! { + res = listener.accept() => { + match res { + Ok((stream, remote_addr)) => (stream, remote_addr), + Err(e) => { + tracing::error!("failed to accept v4 connection: {:?}", e); + continue; + } + } + } + _ = per_conn.stop_handle.clone().shutdown() => break, + }; + + let per_conn2 = per_conn.clone(); + + // service_fn handle each connection + let svc = tower::service_fn(move |req: hyper::Request| { + let PerConnection { + methods, + stop_handle, + rpc_metrics, + svc_builder, + rate_limit_builder, + rpc_method_weights, + } = per_conn2.clone(); + let is_websocket = ws::is_upgrade_request(&req); let protocol = if is_websocket { Protocol::Ws } else { Protocol::Http }; - let mut socket_ip = socket_ip.clone(); - let methods: Methods = rpc_module.clone().into(); - let stop_handle = stop_handle.clone(); - let http_middleware = http_middleware.clone(); - let rpc_metrics = rpc_metrics.clone(); - let call_metrics = rpc_metrics.call_metrics(); - + let mut socket_ip = remote_addr.ip().to_string(); if let Some(true) = rate_limit_builder.as_ref().map(|r| r.use_xff()) { socket_ip = req.xxf_ip().unwrap_or(socket_ip); } - let rpc_middleware = RpcServiceBuilder::new() - .option_layer( - rate_limit_builder - .as_ref() - .and_then(|r| r.ip_limit(socket_ip, rpc_method_weights.clone())), - ) - .option_layer( - rate_limit_builder - .as_ref() - .and_then(|r| r.connection_limit(rpc_method_weights.clone())), - ) - .option_layer( - call_metrics - .as_ref() - .map(|(a, b, c)| layer_fn(|s| PrometheusService::new(s, protocol, a, b, c))), - ); - - let batch_request_config = match config.max_batch_size { - Some(0) => BatchRequestConfig::Disabled, - Some(max_size) => BatchRequestConfig::Limit(max_size), - None => BatchRequestConfig::Unlimited, - }; - - let service_builder = ServerBuilder::default() - .set_rpc_middleware(rpc_middleware) - .set_http_middleware(http_middleware) - .max_connections(config.max_connections) - .set_batch_request_config(batch_request_config) - .set_id_provider(RandomStringIdProvider::new(16)) - .to_service_builder(); - - let mut service = service_builder.build(methods, stop_handle); - - if is_websocket { - let on_ws_close = service.on_session_closed(); - rpc_metrics.ws_open(); - tokio::spawn(async move { - on_ws_close.await; - rpc_metrics.ws_closed(); - }); - } - service.call(req) - })) - } - }); - - let ip_addr = std::net::IpAddr::from_str(&self.config.listen_address)?; - let addr = SocketAddr::new(ip_addr, self.config.port); + let call_metrics = rpc_metrics.call_metrics(); - let server = hyper::Server::bind(&addr).serve(make_service); - let addr = server.local_addr(); + async move { + let rpc_middleware = + RpcServiceBuilder::new() + .option_layer( + rate_limit_builder + .as_ref() + .and_then(|r| r.ip_limit(socket_ip, rpc_method_weights.clone())), + ) + .option_layer( + rate_limit_builder + .as_ref() + .and_then(|r| r.connection_limit(rpc_method_weights.clone())), + ) + .option_layer(call_metrics.as_ref().map(move |(a, b, c)| { + layer_fn(move |s| PrometheusService::new(s, protocol, a, b, c)) + })); + + let mut service = svc_builder + .set_rpc_middleware(rpc_middleware) + .build(methods, stop_handle); + + if is_websocket { + let on_ws_close = service.on_session_closed(); + rpc_metrics.ws_open(); + tokio::spawn(async move { + on_ws_close.await; + rpc_metrics.ws_closed(); + }); + } + + service.call(req).await.map_err(|e| anyhow::anyhow!("{:?}", e)) + } + .boxed() + }); - tokio::spawn(async move { - let graceful = server.with_graceful_shutdown(async move { handle.shutdown().await }); - graceful.await.unwrap() + tokio::spawn(serve_with_graceful_shutdown(sock, svc, stop_handle.clone().shutdown())); + } }); Ok((addr, server_handle)) diff --git a/src/extensions/server/proxy_get_request.rs b/src/extensions/server/proxy_get_request.rs index ac5a3be..7e62a68 100644 --- a/src/extensions/server/proxy_get_request.rs +++ b/src/extensions/server/proxy_get_request.rs @@ -27,15 +27,19 @@ //! Middleware that proxies requests at a specified URI to internal //! RPC method calls. +use hyper::body::Bytes; use hyper::header::{ACCEPT, CONTENT_TYPE}; use hyper::http::HeaderValue; -use hyper::{Body, Method, Request, Response, Uri}; +use hyper::{Method, Uri}; use jsonrpsee::{ - core::client::Error as RpcError, + core::{ + client::Error as RpcError, + http_helpers::{Body as HttpBody, Request as HttpRequest, Response as HttpResponse}, + BoxError, + }, types::{Id, RequestSer}, }; use std::collections::HashMap; -use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; @@ -97,15 +101,18 @@ impl ProxyGetRequest { } } -impl Service> for ProxyGetRequest +impl Service> for ProxyGetRequest where - S: Service, Response = Response>, + S: Service, S::Response: 'static, - S::Error: Into> + 'static, + S::Error: Into + 'static, S::Future: Send + 'static, + B: http_body::Body + Send + 'static, + B::Data: Send, + B::Error: Into, { type Response = S::Response; - type Error = Box; + type Error = BoxError; type Future = Pin> + Send + 'static>>; #[inline] @@ -113,12 +120,12 @@ where self.inner.poll_ready(cx).map_err(Into::into) } - fn call(&mut self, mut req: Request) -> Self::Future { + fn call(&mut self, mut req: HttpRequest) -> Self::Future { let method = self.methods.get(req.uri().path()); let modify = method.is_some() && req.method() == Method::GET; // Proxy the request to the appropriate method call. - if modify { + let req = if modify { // RPC methods are accessed with `POST`. *req.method_mut() = Method::POST; // Precautionary remove the URI. @@ -129,14 +136,20 @@ where .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req.headers_mut() .insert(ACCEPT, HeaderValue::from_static("application/json")); + // Adjust the body to reflect the method call. + // let bytes = serde_json::to_vec(&RequestSer::borrowed(&Id::Number(0), method.unwrap(), None)) + // .expect("Valid request; qed"); + // let body = HttpBody::from(bytes); // Adjust the body to reflect the method call. - let body = Body::from( - serde_json::to_string(&RequestSer::borrowed(&Id::Number(0), method.unwrap(), None)) - .expect("Valid request; qed"), - ); - req = req.map(|_| body); - } + let bytes = serde_json::to_vec(&RequestSer::borrowed(&Id::Number(0), method.unwrap(), None)) + .expect("Valid request; qed"); + let body = HttpBody::from(bytes); + + req.map(|_| body) + } else { + req.map(HttpBody::new) + }; // Call the inner service and get a future that resolves to the response. let fut = self.inner.call(req); @@ -151,7 +164,7 @@ where } let body = res.into_body(); - let bytes = hyper::body::to_bytes(body).await?; + let bytes = http_body_util::BodyExt::collect(body).await?.to_bytes(); #[derive(serde::Deserialize, Debug)] struct RpcPayload<'a> { @@ -173,17 +186,16 @@ where } mod response { - use jsonrpsee::types::{error::ErrorCode, ErrorObjectOwned, Id, Response, ResponsePayload}; + use jsonrpsee::{ + core::http_helpers::{Body as HttpBody, Response as HttpResponse}, + types::{error::ErrorCode, ErrorObjectOwned, Id, Response, ResponsePayload}, + }; const JSON: &str = "application/json; charset=utf-8"; /// Create a response body. - fn from_template>( - status: hyper::StatusCode, - body: S, - content_type: &'static str, - ) -> hyper::Response { - hyper::Response::builder() + fn from_template(status: hyper::StatusCode, body: impl Into, content_type: &'static str) -> HttpResponse { + HttpResponse::builder() .status(status) .header("content-type", hyper::header::HeaderValue::from_static(content_type)) .body(body.into()) @@ -193,11 +205,11 @@ mod response { } /// Create a valid JSON response. - pub(crate) fn ok_response(body: String) -> hyper::Response { + pub(crate) fn ok_response(body: impl Into) -> HttpResponse { from_template(hyper::StatusCode::OK, body, JSON) } /// Create a response for json internal error. - pub(crate) fn internal_error() -> hyper::Response { + pub(crate) fn internal_error() -> HttpResponse { let err = ResponsePayload::<()>::error(ErrorObjectOwned::from(ErrorCode::InternalError)); let rp = Response::new(err, Id::Null); let error = serde_json::to_string(&rp).expect("built from known-good data; qed"); diff --git a/src/server.rs b/src/server.rs index 2f062ac..6bf2f0c 100644 --- a/src/server.rs +++ b/src/server.rs @@ -81,7 +81,7 @@ pub async fn build(config: Config) -> anyhow::Result { let method_name = string_to_static_str(method.method.clone()); - module.register_async_method(method_name, move |params, _| { + module.register_async_method(method_name, move |params, _, _| { let method_middlewares = method_middlewares.clone(); async move { let parsed = params.parse::()?; @@ -147,7 +147,7 @@ pub async fn build(config: Config) -> anyhow::Result { subscribe_name, name, unsubscribe_name, - move |params, pending_sink, _| { + move |params, pending_sink, _, _| { let subscription_middlewares = subscription_middlewares.clone(); async move { let parsed = params.parse::()?; @@ -204,7 +204,7 @@ pub async fn build(config: Config) -> anyhow::Result { rpc_methods.sort(); - module.register_method("rpc_methods", move |_, _| { + module.register_method("rpc_methods", move |_, _, _| { Ok::(json!({ "version": 1, "methods": rpc_methods @@ -315,10 +315,10 @@ mod tests { let mut module = RpcModule::new(()); module - .register_method(PHO, |_, _| Ok::(BAR.to_string())) + .register_method(PHO, |_, _, _| Ok::(BAR.to_string())) .unwrap(); module - .register_async_method(TIMEOUT, |_, _| async { + .register_async_method(TIMEOUT, |_, _, _| async { loop { tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; }