diff --git a/Cargo.lock b/Cargo.lock index 587c3196c21..6ed18958add 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -50,7 +50,7 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "const-random", "getrandom 0.2.10", "once_cell", @@ -133,6 +133,28 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "async-trait" version = "0.1.74" @@ -162,6 +184,59 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fb79c228270dcf2426e74864cabc94babb5dbab01a4314e702d2f16540e1591" +dependencies = [ + "async-trait", + "axum-core", + "base64 0.21.5", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sha1", + "sync_wrapper", + "tokio", + "tokio-tungstenite", + "tower", + "tower-http", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -170,13 +245,19 @@ checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object", "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.5" @@ -249,34 +330,13 @@ dependencies = [ "cty", ] -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -294,44 +354,18 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" -[[package]] -name = "bstr" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "bumpalo" version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - [[package]] name = "bytes" version = "1.5.0" @@ -393,12 +427,6 @@ dependencies = [ "nom", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -411,7 +439,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cipher", "cpufeatures", ] @@ -545,7 +573,7 @@ dependencies = [ name = "ckb-bin" version = "0.113.0-pre" dependencies = [ - "base64", + "base64 0.21.5", "ckb-app-config", "ckb-async-runtime", "ckb-build-info", @@ -798,7 +826,7 @@ dependencies = [ name = "ckb-gen-types" version = "0.113.0-pre" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "ckb-error", "ckb-fixed-hash", "ckb-hash", @@ -979,7 +1007,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ccb671c5921be8a84686e6212ca184cb1d7c51cadcdbfcbd1cc3f042f5dfb8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1043,7 +1071,7 @@ dependencies = [ name = "ckb-miner" version = "0.113.0-pre" dependencies = [ - "base64", + "base64 0.21.5", "ckb-app-config", "ckb-async-runtime", "ckb-channel", @@ -1112,7 +1140,7 @@ dependencies = [ "tempfile", "tentacle", "tokio", - "tokio-util 0.7.10", + "tokio-util", "trust-dns-resolver", ] @@ -1250,7 +1278,11 @@ dependencies = [ name = "ckb-rpc" version = "0.113.0-pre" dependencies = [ + "async-stream", + "async-trait", + "axum", "ckb-app-config", + "ckb-async-runtime", "ckb-chain", "ckb-chain-spec", "ckb-constant", @@ -1268,6 +1300,7 @@ dependencies = [ "ckb-pow", "ckb-reward-calculator", "ckb-shared", + "ckb-stop-handler", "ckb-store", "ckb-sync", "ckb-systemtime", @@ -1278,20 +1311,18 @@ dependencies = [ "ckb-util", "ckb-verification", "ckb-verification-traits", + "futures-util", "itertools 0.11.0", "jsonrpc-core", - "jsonrpc-derive", - "jsonrpc-http-server", - "jsonrpc-pubsub", - "jsonrpc-server-utils", - "jsonrpc-tcp-server", - "jsonrpc-ws-server", + "jsonrpc-utils", "pretty_assertions", "reqwest", "serde", "serde_json", "tempfile", "tokio", + "tokio-util", + "tower-http", ] [[package]] @@ -1387,7 +1418,7 @@ dependencies = [ "once_cell", "rand 0.8.5", "tokio", - "tokio-util 0.7.10", + "tokio-util", ] [[package]] @@ -1529,7 +1560,7 @@ dependencies = [ "slab", "tempfile", "tokio", - "tokio-util 0.7.10", + "tokio-util", ] [[package]] @@ -1537,7 +1568,7 @@ name = "ckb-types" version = "0.113.0-pre" dependencies = [ "bit-vec", - "bytes 1.5.0", + "bytes", "ckb-channel", "ckb-constant", "ckb-error", @@ -1629,7 +1660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc004a826b9bc9319ffae0b8415690e1b5f1482266d55fbd43843aa40ddcd63" dependencies = [ "byteorder", - "bytes 1.5.0", + "bytes", "cc", "ckb-vm-definitions", "derive_more", @@ -1773,7 +1804,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1818,7 +1849,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -1828,7 +1859,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] @@ -1840,7 +1871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", "memoffset", "scopeguard", @@ -1852,7 +1883,7 @@ version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1867,7 +1898,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.7", + "generic-array", "rand_core 0.6.4", "typenum", ] @@ -1942,7 +1973,7 @@ version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "num_cpus", ] @@ -1990,22 +2021,13 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -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", + "generic-array", ] [[package]] @@ -2014,7 +2036,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "crypto-common", "subtle", ] @@ -2052,7 +2074,7 @@ version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -2107,12 +2129,6 @@ dependencies = [ "rand 0.7.3", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "faster-hex" version = "0.6.1" @@ -2210,25 +2226,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" dependencies = [ "libc", - "winapi 0.3.9", -] - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags 1.3.2", - "fuchsia-zircon-sys", + "winapi", ] -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - [[package]] name = "futures" version = "0.3.28" @@ -2269,7 +2269,6 @@ dependencies = [ "futures-core", "futures-task", "futures-util", - "num_cpus", ] [[package]] @@ -2334,15 +2333,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -2359,7 +2349,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", @@ -2372,7 +2362,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi 0.11.0+wasi-snapshot-preview1", ] @@ -2389,19 +2379,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "globset" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" -dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", -] - [[package]] name = "goblin" version = "0.2.3" @@ -2456,7 +2433,7 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ - "bytes 1.5.0", + "bytes", "fnv", "futures-core", "futures-sink", @@ -2465,7 +2442,7 @@ dependencies = [ "indexmap 1.9.3", "slab", "tokio", - "tokio-util 0.7.10", + "tokio-util", "tracing", ] @@ -2512,7 +2489,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2559,7 +2536,7 @@ checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" dependencies = [ "libc", "match_cfg", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2568,7 +2545,7 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ - "bytes 1.5.0", + "bytes", "fnv", "itoa", ] @@ -2579,11 +2556,17 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ - "bytes 1.5.0", + "bytes", "http", "pin-project-lite", ] +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + [[package]] name = "httparse" version = "1.8.0" @@ -2608,7 +2591,7 @@ version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ - "bytes 1.5.0", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -2632,7 +2615,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes 1.5.0", + "bytes", "hyper", "native-tls", "tokio", @@ -2738,7 +2721,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -2747,16 +2730,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", + "cfg-if", ] [[package]] @@ -2767,7 +2741,7 @@ checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" dependencies = [ "socket2 0.3.19", "widestring", - "winapi 0.3.9", + "winapi", "winreg 0.6.2", ] @@ -2861,102 +2835,33 @@ dependencies = [ ] [[package]] -name = "jsonrpc-derive" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b939a78fa820cdfcb7ee7484466746a7377760970f6f9c6fe19f9edcc8a38d2" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "jsonrpc-http-server" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff" -dependencies = [ - "futures", - "hyper", - "jsonrpc-core", - "jsonrpc-server-utils", - "log", - "net2", - "parking_lot 0.11.2", - "unicase", -] - -[[package]] -name = "jsonrpc-pubsub" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" -dependencies = [ - "futures", - "jsonrpc-core", - "lazy_static", - "log", - "parking_lot 0.11.2", - "rand 0.7.3", - "serde", -] - -[[package]] -name = "jsonrpc-server-utils" -version = "18.0.0" +name = "jsonrpc-utils" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4fdea130485b572c39a460d50888beb00afb3e35de23ccd7fad8ff19f0e0d4" +checksum = "dfe6601e4eedf0730aebf2ad532cd22c05c67d3cb20105577dd12a5f004abd3b" dependencies = [ - "bytes 1.5.0", - "futures", - "globset", + "anyhow", + "axum", + "futures-core", + "futures-util", + "hex", "jsonrpc-core", - "lazy_static", - "log", + "jsonrpc-utils-macros", + "pin-project-lite", + "rand 0.8.5", + "serde_json", "tokio", - "tokio-stream", - "tokio-util 0.6.10", - "unicase", ] [[package]] -name = "jsonrpc-tcp-server" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a0a0d35558123e93743d467285196905da1368500378cb5352b71856377874" -dependencies = [ - "jsonrpc-core", - "jsonrpc-server-utils", - "log", - "parking_lot 0.11.2", - "tower-service", -] - -[[package]] -name = "jsonrpc-ws-server" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f892c7d766369475ab7b0669f417906302d7c0fb521285c0a0c92e52e7c8e946" -dependencies = [ - "futures", - "jsonrpc-core", - "jsonrpc-server-utils", - "log", - "parity-ws", - "parking_lot 0.11.2", - "slab", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "jsonrpc-utils-macros" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +checksum = "34fe3ce66f7e4909575f6be478862325559bf5b5d0a681d106aae2c9849e1857" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "proc-macro2", + "quote", + "syn 2.0.38", ] [[package]] @@ -2992,8 +2897,8 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ - "cfg-if 1.0.0", - "winapi 0.3.9", + "cfg-if", + "winapi", ] [[package]] @@ -3063,6 +2968,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" +[[package]] +name = "matchit" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" + [[package]] name = "memchr" version = "2.6.4" @@ -3093,7 +3004,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "171d2f700835121c3b04ccf0880882987a050fd5c7ae88148abf537d33dd3a56" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -3140,25 +3051,6 @@ dependencies = [ "adler", ] -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - [[package]] name = "mio" version = "0.8.9" @@ -3170,38 +3062,14 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "mio-extras" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" -dependencies = [ - "lazycell", - "log", - "mio 0.6.23", - "slab", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - [[package]] name = "molecule" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd9767ab5e5f2ea40f71ff4c8bdb633c50509052e093c2fdd0e390a749dfa3" dependencies = [ - "bytes 1.5.0", - "cfg-if 1.0.0", + "bytes", + "cfg-if", "faster-hex", ] @@ -3247,17 +3115,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "net2" -version = "0.2.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - [[package]] name = "nix" version = "0.27.1" @@ -3265,7 +3122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ "bitflags 2.4.1", - "cfg-if 1.0.0", + "cfg-if", "libc", ] @@ -3393,12 +3250,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -3412,7 +3263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" dependencies = [ "bitflags 2.4.1", - "cfg-if 1.0.0", + "cfg-if", "foreign-types", "libc", "once_cell", @@ -3459,24 +3310,6 @@ dependencies = [ "hashbrown 0.13.2", ] -[[package]] -name = "parity-ws" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5983d3929ad50f12c3eb9a6743f19d691866ecd44da74c0a3308c3f8a56df0c6" -dependencies = [ - "byteorder", - "bytes 0.4.12", - "httparse", - "log", - "mio 0.6.23", - "mio-extras", - "rand 0.7.3", - "sha-1 0.8.2", - "slab", - "url", -] - [[package]] name = "parking_lot" version = "0.11.2" @@ -3504,12 +3337,12 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "instant", "libc", "redox_syscall 0.2.16", "smallvec", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -3519,7 +3352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "backtrace", - "cfg-if 1.0.0", + "cfg-if", "libc", "petgraph", "redox_syscall 0.4.1", @@ -3600,6 +3433,26 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -3659,7 +3512,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", - "opaque-debug 0.3.0", + "opaque-debug", "universal-hash", ] @@ -3695,15 +3548,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3743,7 +3587,7 @@ version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fnv", "lazy_static", "memchr", @@ -3797,7 +3641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d98dc777a7a39b76b1a26ae9d3f691f4c1bc0455090aa0b64dfa8cb7fc34c135" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -3968,7 +3812,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f97f7665e51f23760e9e4949d454a4782c76ef954acaeec9d1b0f48a58e4529e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "rustix", "windows", ] @@ -4014,8 +3858,8 @@ version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64", - "bytes 1.5.0", + "base64 0.21.5", + "bytes", "encoding_rs", "futures-core", "futures-util", @@ -4094,7 +3938,7 @@ dependencies = [ "spin", "untrusted", "web-sys", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -4103,7 +3947,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "ordered-multimap", ] @@ -4141,6 +3985,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" + [[package]] name = "rusty-fork" version = "0.3.0" @@ -4372,6 +4222,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7f05c1d5476066defcdfacce1f52fc3cae3af1d3089727100c02ae92e5abbe0" +dependencies = [ + "serde", +] + [[package]] name = "serde_plain" version = "0.3.0" @@ -4393,25 +4252,13 @@ dependencies = [ "serde", ] -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha-1" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.10.7", ] @@ -4422,7 +4269,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.10.7", ] @@ -4433,7 +4280,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.10.7", ] @@ -4513,9 +4360,9 @@ version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -4525,7 +4372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -4550,12 +4397,12 @@ version = "9.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7a2b3c2bc9693bcb40870c4e9b5bf0d79f9cb46273321bf855ec513e919082" dependencies = [ - "base64", + "base64 0.21.5", "digest 0.10.7", "hex", "miette", "serde", - "sha-1 0.10.1", + "sha-1", "sha2", "thiserror", "xxhash-rust", @@ -4601,13 +4448,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "tempfile" version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fastrand", "redox_syscall 0.3.5", "rustix", @@ -4621,7 +4474,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ffbbdb4f54a9605ceda168884efcf5fb24ef655103362af211e6cfe61eff832" dependencies = [ "async-trait", - "bytes 1.5.0", + "bytes", "futures", "igd", "js-sys", @@ -4637,11 +4490,11 @@ dependencies = [ "tentacle-secio", "thiserror", "tokio", - "tokio-util 0.7.10", + "tokio-util", "tokio-yamux", "wasm-bindgen", "wasm-bindgen-futures", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -4651,7 +4504,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "895b25a7de42f7bba27b011495a4a48ea7f0591c079f59c8fdb07936ca8aa3d1" dependencies = [ "bs58", - "bytes 1.5.0", + "bytes", "serde", "sha2", "unsigned-varint", @@ -4664,7 +4517,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78a41abd9ae459d1f744f59670d8f4e9a25c4597b12b9060740fbd17bf9687fc" dependencies = [ "bs58", - "bytes 1.5.0", + "bytes", "chacha20poly1305", "futures", "hmac", @@ -4679,7 +4532,7 @@ dependencies = [ "secp256k1", "sha2", "tokio", - "tokio-util 0.7.10", + "tokio-util", "unsigned-varint", "x25519-dalek", ] @@ -4730,7 +4583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -4834,9 +4687,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", - "bytes 1.5.0", + "bytes", "libc", - "mio 0.8.9", + "mio", "num_cpus", "parking_lot 0.12.1", "pin-project-lite", @@ -4879,17 +4732,15 @@ dependencies = [ ] [[package]] -name = "tokio-util" -version = "0.6.10" +name = "tokio-tungstenite" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" dependencies = [ - "bytes 1.5.0", - "futures-core", - "futures-sink", + "futures-util", "log", - "pin-project-lite", "tokio", + "tungstenite", ] [[package]] @@ -4898,7 +4749,7 @@ version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ - "bytes 1.5.0", + "bytes", "futures-core", "futures-sink", "pin-project-lite", @@ -4912,12 +4763,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2ed88a04bfbf9e70343a5748a423200ee0591c55e7e487d784a55ee8af17db9" dependencies = [ - "bytes 1.5.0", + "bytes", "futures", "log", "nohash-hasher", "tokio", - "tokio-util 0.7.10", + "tokio-util", ] [[package]] @@ -4929,6 +4780,48 @@ dependencies = [ "serde", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" +dependencies = [ + "bitflags 1.3.2", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tokio", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + [[package]] name = "tower-service" version = "0.3.2" @@ -4941,6 +4834,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-core", ] @@ -4961,7 +4855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca94d4e9feb6a181c690c4040d7a24ef34018d8313ac5044a61d21222ae24e31" dependencies = [ "async-trait", - "cfg-if 1.0.0", + "cfg-if", "data-encoding", "enum-as-inner", "futures-channel", @@ -4985,7 +4879,7 @@ version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ecae383baad9995efaa34ce8e57d12c3f305e545887472a492b838f4b5cfb77a" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "futures-util", "ipconfig", "lazy_static", @@ -5005,6 +4899,25 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "tungstenite" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" +dependencies = [ + "base64 0.13.1", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "rand 0.8.5", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.17.0" @@ -5035,15 +4948,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" -[[package]] -name = "unicase" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-bidi" version = "0.3.13" @@ -5111,6 +5015,12 @@ dependencies = [ "serde", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8parse" version = "0.2.1" @@ -5185,7 +5095,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] @@ -5210,7 +5120,7 @@ version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "wasm-bindgen", "web-sys", @@ -5279,12 +5189,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f44b95f62d34113cf558c93511ac93027e03e9c29a60dd0fd70e6e025c7270a" -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -5295,12 +5199,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -5313,7 +5211,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -5479,7 +5377,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -5488,20 +5386,10 @@ version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "windows-sys 0.48.0", ] -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - [[package]] name = "x25519-dalek" version = "1.1.1" diff --git a/ckb-bin/src/subcommand/run.rs b/ckb-bin/src/subcommand/run.rs index fd6355af330..64185401926 100644 --- a/ckb-bin/src/subcommand/run.rs +++ b/ckb-bin/src/subcommand/run.rs @@ -12,7 +12,6 @@ pub fn run(args: RunArgs, version: Version, async_handle: Handle) -> Result<(), deadlock_detection(); info!("ckb version: {}", version); - let mut launcher = Launcher::new(args, version, async_handle); let block_assembler_config = launcher.sanitize_block_assembler_config()?; @@ -45,7 +44,7 @@ pub fn run(args: RunArgs, version: Version, async_handle: Handle) -> Result<(), launcher.start_block_filter(&shared); - let (network_controller, _rpc_server) = launcher.start_network_and_rpc( + let network_controller = launcher.start_network_and_rpc( &shared, chain_controller.clone(), miner_enable, diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index eaf36a7eed4..adf0bb27ea1 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -17,19 +17,14 @@ ckb-shared = { path = "../shared", version = "= 0.113.0-pre" } ckb-store = { path = "../store", version = "= 0.113.0-pre" } ckb-sync = { path = "../sync", version = "= 0.113.0-pre" } ckb-chain = { path = "../chain", version = "= 0.113.0-pre" } -ckb-logger = { path = "../util/logger", version = "= 0.113.0-pre"} -ckb-logger-service = { path = "../util/logger-service", version = "= 0.113.0-pre"} +ckb-logger = { path = "../util/logger", version = "= 0.113.0-pre" } +ckb-logger-service = { path = "../util/logger-service", version = "= 0.113.0-pre" } ckb-network-alert = { path = "../util/network-alert", version = "= 0.113.0-pre" } ckb-app-config = { path = "../util/app-config", version = "= 0.113.0-pre" } ckb-constant = { path = "../util/constant", version = "= 0.113.0-pre" } jsonrpc-core = "18.0" -jsonrpc-derive = "18.0" -jsonrpc-http-server = "18.0" -jsonrpc-tcp-server = "18.0" -jsonrpc-ws-server = "18.0" -jsonrpc-server-utils = "18.0" -jsonrpc-pubsub = "18.0" serde_json = "1.0" +jsonrpc-utils = { version = "0.2.6", features = ["server", "macros", "axum"] } ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.113.0-pre" } ckb-verification = { path = "../verification", version = "= 0.113.0-pre" } ckb-verification-traits = { path = "../verification/traits", version = "= 0.113.0-pre" } @@ -43,8 +38,16 @@ ckb-tx-pool = { path = "../tx-pool", version = "= 0.113.0-pre" } ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.113.0-pre" } ckb-pow = { path = "../pow", version = "= 0.113.0-pre" } ckb-indexer = { path = "../util/indexer", version = "= 0.113.0-pre" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.113.0-pre" } itertools.workspace = true tokio = "1" +async-trait = "0.1" +axum = "0.6.1" +tokio-util = { version = "0.7.3", features = ["codec"] } +futures-util = { version = "0.3.21" } +tower-http = { version = "0.3.5", features = ["timeout"] } +async-stream = "0.3.3" +ckb-async-runtime = { path = "../util/runtime", version = "= 0.113.0-pre" } [dev-dependencies] reqwest = { version = "=0.11.20", features = ["blocking", "json"] } diff --git a/rpc/README.md b/rpc/README.md index 3dec06f930e..a243ae33ba0 100644 --- a/rpc/README.md +++ b/rpc/README.md @@ -99,7 +99,6 @@ The crate `ckb-rpc`'s minimum supported rustc version is 1.71.1. * [Method `get_deployments_info`](#method-get_deployments_info) * [Module Subscription](#module-subscription) * [Method `subscribe`](#method-subscribe) - * [Method `unsubscribe`](#method-unsubscribe) * [RPC Errors](#rpc-errors) * [RPC Types](#rpc-types) * [Type `Alert`](#type-alert) @@ -4956,7 +4955,7 @@ The type of the `params.result` in the push message is a two-elements array, whe ###### Examples -Request +Subscribe Request ``` @@ -4971,32 +4970,19 @@ Request ``` -Response +Subscribe Response ``` { "id": 42, "jsonrpc": "2.0", - "result": "0x2a" + "result": "0xf3" } ``` -#### Method `unsubscribe` -* `unsubscribe(id)` - * `id`: `string` -* result: `boolean` - -Unsubscribes from a subscribed topic. - -###### Params - -* `id` - Subscription ID - -###### Examples - -Request +Unsubscribe Request ``` @@ -5005,13 +4991,13 @@ Request "jsonrpc": "2.0", "method": "unsubscribe", "params": [ - "0x2a" + "0xf3" ] } ``` -Response +Unsubscribe Response ``` diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index ebbd2227e4b..3156c6003f4 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -10,9 +10,12 @@ pub mod module; #[cfg(test)] mod tests; +use jsonrpc_core::MetaIoHandler; +use jsonrpc_utils::pub_sub::Session; + pub use crate::error::RPCError; pub use crate::server::RpcServer; pub use crate::service_builder::ServiceBuilder; #[doc(hidden)] -pub type IoHandler = jsonrpc_pubsub::PubSubHandler>; +pub type IoHandler = MetaIoHandler>; diff --git a/rpc/src/module/alert.rs b/rpc/src/module/alert.rs index d1c6ce77624..f75bc6014cb 100644 --- a/rpc/src/module/alert.rs +++ b/rpc/src/module/alert.rs @@ -1,12 +1,14 @@ use crate::error::RPCError; +use async_trait::async_trait; use ckb_jsonrpc_types::Alert; use ckb_logger::error; use ckb_network::{NetworkController, SupportProtocols}; use ckb_network_alert::{notifier::Notifier as AlertNotifier, verifier::Verifier as AlertVerifier}; use ckb_types::{packed, prelude::*}; use ckb_util::Mutex; + use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::sync::Arc; /// RPC Module Alert for network alerts. @@ -15,7 +17,8 @@ use std::sync::Arc; /// /// The alerts must be signed by 2-of-4 signatures, where the public keys are hard-coded in the source code /// and belong to early CKB developers. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait AlertRpc { /// Sends an alert. /// @@ -70,6 +73,7 @@ pub trait AlertRpc { fn send_alert(&self, alert: Alert) -> Result<()>; } +#[derive(Clone)] pub(crate) struct AlertRpcImpl { network_controller: NetworkController, verifier: Arc, @@ -90,6 +94,7 @@ impl AlertRpcImpl { } } +#[async_trait] impl AlertRpc for AlertRpcImpl { fn send_alert(&self, alert: Alert) -> Result<()> { let alert: packed::Alert = alert.into(); diff --git a/rpc/src/module/chain.rs b/rpc/src/module/chain.rs index fdbab35d671..f19a5b71e01 100644 --- a/rpc/src/module/chain.rs +++ b/rpc/src/module/chain.rs @@ -1,5 +1,6 @@ use crate::error::RPCError; use crate::util::FeeRateCollector; +use async_trait::async_trait; use ckb_jsonrpc_types::{ BlockEconomicState, BlockFilter, BlockNumber, BlockResponse, BlockView, CellWithStatus, Consensus, EpochNumber, EpochView, EstimateCycles, FeeRateStatistics, HeaderView, OutPoint, @@ -26,7 +27,7 @@ use ckb_types::{ use ckb_verification::ScriptVerifier; use ckb_verification::TxVerifyEnv; use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::collections::HashSet; use std::sync::Arc; @@ -52,7 +53,8 @@ use std::sync::Arc; /// * it is found as an output in any transaction in the [canonical chain](#canonical-chain), /// and /// * it is not found as an input in any transaction in the canonical chain. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait ChainRpc { /// Returns the information about a block by hash. /// @@ -1606,6 +1608,7 @@ pub trait ChainRpc { fn get_fee_rate_statistics(&self, target: Option) -> Result>; } +#[derive(Clone)] pub(crate) struct ChainRpcImpl { pub shared: Shared, } @@ -1614,6 +1617,7 @@ const DEFAULT_BLOCK_VERBOSITY_LEVEL: u32 = 2; const DEFAULT_HEADER_VERBOSITY_LEVEL: u32 = 1; const DEFAULT_GET_TRANSACTION_VERBOSITY_LEVEL: u32 = 2; +#[async_trait] impl ChainRpc for ChainRpcImpl { fn get_block( &self, diff --git a/rpc/src/module/debug.rs b/rpc/src/module/debug.rs index eabf49d87d8..350cbdd1c5c 100644 --- a/rpc/src/module/debug.rs +++ b/rpc/src/module/debug.rs @@ -1,15 +1,16 @@ +use async_trait::async_trait; use ckb_jsonrpc_types::{ExtraLoggerConfig, MainLoggerConfig}; use ckb_logger_service::Logger; use jsonrpc_core::{Error, ErrorCode::InternalError, Result}; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::time; - /// RPC Module Debug for internal RPC methods. /// /// **This module is for CKB developers and will not guarantee compatibility.** The methods here /// will be changed or removed without advanced notification. -#[rpc(server)] #[doc(hidden)] +#[rpc] +#[async_trait] pub trait DebugRpc { /// Dumps jemalloc memory profiling information into a file. /// @@ -35,8 +36,10 @@ pub trait DebugRpc { fn set_extra_logger(&self, name: String, config_opt: Option) -> Result<()>; } +#[derive(Clone)] pub(crate) struct DebugRpcImpl {} +#[async_trait] impl DebugRpc for DebugRpcImpl { fn jemalloc_profiling_dump(&self) -> Result { let timestamp = time::SystemTime::now() diff --git a/rpc/src/module/experiment.rs b/rpc/src/module/experiment.rs index 0486c9009a7..55edc5dd5a1 100644 --- a/rpc/src/module/experiment.rs +++ b/rpc/src/module/experiment.rs @@ -1,5 +1,6 @@ use crate::error::RPCError; use crate::module::chain::CyclesEstimator; +use async_trait::async_trait; use ckb_dao::DaoCalculator; use ckb_jsonrpc_types::{ Capacity, DaoWithdrawingCalculationKind, EstimateCycles, OutPoint, Transaction, @@ -8,14 +9,15 @@ use ckb_shared::{shared::Shared, Snapshot}; use ckb_store::ChainStore; use ckb_types::{core, packed, prelude::*}; use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; /// RPC Module Experiment for experimenting methods. /// /// **EXPERIMENTAL warning** /// /// The methods here may be removed or changed in future releases without prior notifications. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait ExperimentRpc { /// Dry run a transaction and return the execution cycles. /// @@ -162,10 +164,12 @@ pub trait ExperimentRpc { ) -> Result; } +#[derive(Clone)] pub(crate) struct ExperimentRpcImpl { pub shared: Shared, } +#[async_trait] impl ExperimentRpc for ExperimentRpcImpl { fn dry_run_transaction(&self, tx: Transaction) -> Result { let tx: packed::Transaction = tx.into(); diff --git a/rpc/src/module/indexer.rs b/rpc/src/module/indexer.rs index ea7578b9e3c..aa8cb29c8c9 100644 --- a/rpc/src/module/indexer.rs +++ b/rpc/src/module/indexer.rs @@ -1,14 +1,16 @@ use crate::error::RPCError; +use async_trait::async_trait; use ckb_indexer::IndexerHandle; use ckb_jsonrpc_types::{ IndexerCell, IndexerCellsCapacity, IndexerOrder, IndexerPagination, IndexerSearchKey, IndexerTip, IndexerTx, JsonBytes, Uint32, }; use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; /// RPC Module Indexer. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait IndexerRpc { /// Returns the indexed tip /// @@ -873,6 +875,7 @@ pub trait IndexerRpc { ) -> Result>; } +#[derive(Clone)] pub(crate) struct IndexerRpcImpl { pub(crate) handle: IndexerHandle, } @@ -883,6 +886,7 @@ impl IndexerRpcImpl { } } +#[async_trait] impl IndexerRpc for IndexerRpcImpl { fn get_indexer_tip(&self) -> Result> { self.handle diff --git a/rpc/src/module/miner.rs b/rpc/src/module/miner.rs index a334e881807..9a043804ddd 100644 --- a/rpc/src/module/miner.rs +++ b/rpc/src/module/miner.rs @@ -1,4 +1,5 @@ use crate::error::RPCError; +use async_trait::async_trait; use ckb_chain::chain::ChainController; use ckb_jsonrpc_types::{Block, BlockTemplate, Uint64, Version}; use ckb_logger::{debug, error, info, warn}; @@ -9,7 +10,7 @@ use ckb_types::{core, packed, prelude::*, H256}; use ckb_verification::HeaderVerifier; use ckb_verification_traits::Verifier; use jsonrpc_core::{Error, Result}; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::collections::HashSet; use std::fmt::Debug; use std::sync::Arc; @@ -18,7 +19,8 @@ use std::sync::Arc; /// /// A miner gets a template from CKB, optionally selects transactions, resolves the PoW puzzle, and /// submits the found new block. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait MinerRpc { /// Returns block template for miners. /// @@ -223,12 +225,14 @@ pub trait MinerRpc { fn submit_block(&self, work_id: String, block: Block) -> Result; } +#[derive(Clone)] pub(crate) struct MinerRpcImpl { pub network_controller: NetworkController, pub shared: Shared, pub chain: ChainController, } +#[async_trait] impl MinerRpc for MinerRpcImpl { fn get_block_template( &self, diff --git a/rpc/src/module/mod.rs b/rpc/src/module/mod.rs index e55ac1bde0d..ad554dc63e5 100644 --- a/rpc/src/module/mod.rs +++ b/rpc/src/module/mod.rs @@ -131,17 +131,17 @@ pub(crate) use self::miner::MinerRpcImpl; pub(crate) use self::net::NetRpcImpl; pub(crate) use self::pool::PoolRpcImpl; pub(crate) use self::stats::StatsRpcImpl; -pub(crate) use self::subscription::{SubscriptionRpcImpl, SubscriptionSession}; +pub(crate) use self::subscription::SubscriptionRpcImpl; pub(crate) use self::test::IntegrationTestRpcImpl; -pub use self::alert::AlertRpc; -pub use self::chain::ChainRpc; -pub use self::debug::DebugRpc; -pub use self::experiment::ExperimentRpc; -pub use self::indexer::IndexerRpc; -pub use self::miner::MinerRpc; -pub use self::net::NetRpc; -pub use self::pool::PoolRpc; -pub use self::stats::StatsRpc; -pub use self::subscription::SubscriptionRpc; -pub use self::test::IntegrationTestRpc; +pub use self::alert::{add_alert_rpc_methods, AlertRpc}; +pub use self::chain::{add_chain_rpc_methods, ChainRpc}; +pub use self::debug::{add_debug_rpc_methods, DebugRpc}; +pub use self::experiment::{add_experiment_rpc_methods, ExperimentRpc}; +pub use self::indexer::{add_indexer_rpc_methods, IndexerRpc}; +pub use self::miner::{add_miner_rpc_methods, MinerRpc}; +pub use self::net::{add_net_rpc_methods, NetRpc}; +pub use self::pool::{add_pool_rpc_methods, PoolRpc}; +pub use self::stats::{add_stats_rpc_methods, StatsRpc}; +pub use self::subscription::{add_subscription_rpc_methods, SubscriptionRpc}; +pub use self::test::{add_integration_test_rpc_methods, IntegrationTestRpc}; diff --git a/rpc/src/module/net.rs b/rpc/src/module/net.rs index bef8e6d91c6..289ffb1710a 100644 --- a/rpc/src/module/net.rs +++ b/rpc/src/module/net.rs @@ -1,4 +1,5 @@ use crate::error::RPCError; +use async_trait::async_trait; use ckb_jsonrpc_types::{ BannedAddr, LocalNode, LocalNodeProtocol, NodeAddress, PeerSyncState, RemoteNode, RemoteNodeProtocol, SyncState, Timestamp, @@ -7,14 +8,15 @@ use ckb_network::{extract_peer_id, multiaddr::Multiaddr, NetworkController}; use ckb_sync::SyncShared; use ckb_systemtime::unix_time_as_millis; use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::sync::Arc; const MAX_ADDRS: usize = 50; const DEFAULT_BAN_DURATION: u64 = 24 * 60 * 60 * 1000; // 1 day /// RPC Module Net for P2P network. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait NetRpc { /// Returns the local node information. /// @@ -531,11 +533,13 @@ pub trait NetRpc { fn ping_peers(&self) -> Result<()>; } +#[derive(Clone)] pub(crate) struct NetRpcImpl { pub network_controller: NetworkController, pub sync_shared: Arc, } +#[async_trait] impl NetRpc for NetRpcImpl { fn local_node_info(&self) -> Result { Ok(LocalNode { diff --git a/rpc/src/module/pool.rs b/rpc/src/module/pool.rs index cdad05f9478..854f8988ad3 100644 --- a/rpc/src/module/pool.rs +++ b/rpc/src/module/pool.rs @@ -1,4 +1,5 @@ use crate::error::RPCError; +use async_trait::async_trait; use ckb_chain_spec::consensus::Consensus; use ckb_constant::hardfork::{mainnet, testnet}; use ckb_jsonrpc_types::{ @@ -9,11 +10,12 @@ use ckb_shared::shared::Shared; use ckb_types::{core, packed, prelude::*, H256}; use ckb_verification::{Since, SinceMetric}; use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::sync::Arc; /// RPC Module Pool for transaction memory pool. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait PoolRpc { /// Submits a new transaction into the transaction pool. If the transaction is already in the /// pool, rebroadcast it to peers. @@ -324,6 +326,7 @@ pub trait PoolRpc { fn tx_pool_ready(&self) -> Result; } +#[derive(Clone)] pub(crate) struct PoolRpcImpl { shared: Shared, well_known_lock_scripts: Vec, @@ -428,6 +431,7 @@ fn build_well_known_type_scripts(chain_spec_name: &str) -> Vec { }).expect("checked json str").into_iter().map(Into::into).collect() } +#[async_trait] impl PoolRpc for PoolRpcImpl { fn tx_pool_ready(&self) -> Result { let tx_pool = self.shared.tx_pool_controller(); diff --git a/rpc/src/module/stats.rs b/rpc/src/module/stats.rs index b4162b0e402..b9adec9f4b5 100644 --- a/rpc/src/module/stats.rs +++ b/rpc/src/module/stats.rs @@ -1,3 +1,4 @@ +use async_trait::async_trait; use ckb_jsonrpc_types::{AlertMessage, ChainInfo, DeploymentInfo, DeploymentPos, DeploymentsInfo}; use ckb_network_alert::notifier::Notifier as AlertNotifier; use ckb_shared::shared::Shared; @@ -5,12 +6,13 @@ use ckb_traits::HeaderFieldsProvider; use ckb_types::prelude::Unpack; use ckb_util::Mutex; use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::collections::BTreeMap; use std::sync::Arc; /// RPC Module Stats for getting various statistic data. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait StatsRpc { /// Returns statistics about the chain. /// @@ -99,11 +101,13 @@ pub trait StatsRpc { fn get_deployments_info(&self) -> Result; } +#[derive(Clone)] pub(crate) struct StatsRpcImpl { pub shared: Shared, pub alert_notifier: Arc>, } +#[async_trait] impl StatsRpc for StatsRpcImpl { fn get_blockchain_info(&self) -> Result { let chain = self.shared.consensus().id.clone(); diff --git a/rpc/src/module/subscription.rs b/rpc/src/module/subscription.rs index c5ca5e5160d..25bfe5845f2 100644 --- a/rpc/src/module/subscription.rs +++ b/rpc/src/module/subscription.rs @@ -1,45 +1,12 @@ +use async_trait::async_trait; +use ckb_async_runtime::Handle; use ckb_jsonrpc_types::Topic; use ckb_notify::NotifyController; - -use jsonrpc_core::{Metadata, Result}; -use jsonrpc_derive::rpc; -use jsonrpc_pubsub::{ - typed::{Sink, Subscriber}, - PubSubMetadata, Session, SubscriptionId, -}; -use std::collections::HashMap; -use std::collections::HashSet; -use std::sync::Arc; -use std::sync::{ - atomic::{AtomicUsize, Ordering}, - RwLock, -}; -use tokio::runtime::Handle; - -const SUBSCRIBER_NAME: &str = "TcpSubscription"; - -#[derive(Clone, Debug)] -pub struct SubscriptionSession { - pub(crate) subscription_ids: Arc>>, - pub(crate) session: Arc, -} - -impl SubscriptionSession { - pub fn new(session: Session) -> Self { - Self { - subscription_ids: Arc::new(RwLock::new(HashSet::new())), - session: Arc::new(session), - } - } -} - -impl Metadata for SubscriptionSession {} - -impl PubSubMetadata for SubscriptionSession { - fn session(&self) -> Option> { - Some(Arc::clone(&self.session)) - } -} +use ckb_stop_handler::new_tokio_exit_rx; +use futures_util::{stream::BoxStream, Stream}; +use jsonrpc_core::Result; +use jsonrpc_utils::{pub_sub::PublishMsg, rpc}; +use tokio::sync::broadcast; /// RPC Module Subscription that CKB node will push new messages to subscribers. /// @@ -78,11 +45,13 @@ impl PubSubMetadata for SubscriptionSession { /// socket.send(`{"id": 2, "jsonrpc": "2.0", "method": "unsubscribe", "params": ["0x0"]}`) /// ``` #[allow(clippy::needless_return)] -#[rpc(server)] +#[rpc] +#[async_trait] pub trait SubscriptionRpc { /// Context to implement the subscription RPC. - type Metadata; + /// The stream of subscription messages. + type S: Stream> + Send + 'static; /// Subscribes to a topic. /// /// ## Params @@ -149,7 +118,7 @@ pub trait SubscriptionRpc { /// /// ## Examples /// - /// Request + /// Subscribe Request /// /// ```json /// { @@ -162,27 +131,17 @@ pub trait SubscriptionRpc { /// } /// ``` /// - /// Response + /// Subscribe Response /// /// ```json /// { /// "id": 42, /// "jsonrpc": "2.0", - /// "result": "0x2a" + /// "result": "0xf3" /// } /// ``` - #[pubsub(subscription = "subscribe", subscribe, name = "subscribe")] - fn subscribe(&self, meta: Self::Metadata, subscriber: Subscriber, topic: Topic); - - /// Unsubscribes from a subscribed topic. - /// - /// ## Params /// - /// * `id` - Subscription ID - /// - /// ## Examples - /// - /// Request + /// Unsubscribe Request /// /// ```json /// { @@ -190,12 +149,12 @@ pub trait SubscriptionRpc { /// "jsonrpc": "2.0", /// "method": "unsubscribe", /// "params": [ - /// "0x2a" + /// "0xf3" /// ] /// } /// ``` /// - /// Response + /// Unsubscribe Response /// /// ```json /// { @@ -204,78 +163,52 @@ pub trait SubscriptionRpc { /// "result": true /// } /// ``` - #[pubsub(subscription = "subscribe", unsubscribe, name = "unsubscribe")] - fn unsubscribe(&self, meta: Option, id: SubscriptionId) -> Result; + /// + #[rpc(pub_sub(notify = "subscribe", unsubscribe = "unsubscribe"))] + fn subscribe(&self, topic: Topic) -> Result; } -type Subscribers = HashMap>; - -#[derive(Default)] +#[derive(Clone)] pub struct SubscriptionRpcImpl { - pub(crate) id_generator: AtomicUsize, - pub(crate) subscribers: Arc>>, + pub new_tip_header_sender: broadcast::Sender>, + pub new_tip_block_sender: broadcast::Sender>, + pub new_transaction_sender: broadcast::Sender>, + pub proposed_transaction_sender: broadcast::Sender>, + pub new_reject_transaction_sender: broadcast::Sender>, } -impl SubscriptionRpc for SubscriptionRpcImpl { - type Metadata = Option; - - fn subscribe(&self, meta: Self::Metadata, subscriber: Subscriber, topic: Topic) { - if let Some(session) = meta { - let id = SubscriptionId::String(format!( - "{:#x}", - self.id_generator.fetch_add(1, Ordering::SeqCst) - )); - if let Ok(sink) = subscriber.assign_id(id.clone()) { - let mut subscribers = self - .subscribers - .write() - .expect("acquiring subscribers write lock"); - subscribers - .entry(topic) - .or_default() - .insert(id.clone(), sink); - - session - .subscription_ids - .write() - .expect("acquiring subscription_ids write lock") - .insert(id); - } - } - } +macro_rules! publiser_send { + ($ty:ty, $info:expr, $sender:ident) => {{ + let msg: $ty = $info.into(); + let json_string = serde_json::to_string(&msg).expect("serialization should be ok"); + drop($sender.send(PublishMsg::result(&json_string))); + }}; +} - fn unsubscribe(&self, meta: Option, id: SubscriptionId) -> Result { - let mut subscribers = self - .subscribers - .write() - .expect("acquiring subscribers write lock"); - match meta { - // unsubscribe handler method is explicitly called. - Some(Some(session)) => { - if session - .subscription_ids - .write() - .expect("acquiring subscription_ids write lock") - .remove(&id) - { - Ok(subscribers.values_mut().any(|s| s.remove(&id).is_some())) - } else { - Ok(false) - } - } - // closed or dropped connection - _ => { - subscribers.values_mut().for_each(|s| { - s.remove(&id); - }); - Ok(true) - } - } +#[async_trait] +impl SubscriptionRpc for SubscriptionRpcImpl { + type S = BoxStream<'static, PublishMsg>; + fn subscribe(&self, topic: Topic) -> Result { + let tx = match topic { + Topic::NewTipHeader => self.new_tip_header_sender.clone(), + Topic::NewTipBlock => self.new_tip_block_sender.clone(), + Topic::NewTransaction => self.new_transaction_sender.clone(), + Topic::ProposedTransaction => self.proposed_transaction_sender.clone(), + Topic::RejectedTransaction => self.new_reject_transaction_sender.clone(), + }; + let mut rx = tx.subscribe(); + Ok(Box::pin(async_stream::stream! { + while let Ok(msg) = rx.recv().await { + yield msg; + } + })) } } impl SubscriptionRpcImpl { pub fn new(notify_controller: NotifyController, handle: Handle) -> Self { + const SUBSCRIBER_NAME: &str = "TcpSubscription"; + let mut new_block_receiver = handle.block_on(notify_controller.subscribe_new_block(SUBSCRIBER_NAME.to_string())); let mut new_transaction_receiver = handle @@ -286,64 +219,52 @@ impl SubscriptionRpcImpl { let mut reject_transaction_receiver = handle .block_on(notify_controller.subscribe_reject_transaction(SUBSCRIBER_NAME.to_string())); - let subscription_rpc_impl = SubscriptionRpcImpl::default(); - let subscribers = Arc::clone(&subscription_rpc_impl.subscribers); - handle.spawn(async move { - loop { - tokio::select! { - Some(block) = new_block_receiver.recv() => { - let subscribers = subscribers.read().expect("acquiring subscribers read lock"); - if let Some(new_tip_header_subscribers) = subscribers.get(&Topic::NewTipHeader) { - let header: ckb_jsonrpc_types::HeaderView = block.header().into(); - let json_string = Ok(serde_json::to_string(&header).expect("serialization should be ok")); - for sink in new_tip_header_subscribers.values() { - let _ = sink.notify(json_string.clone()); - } - } - if let Some(new_tip_block_subscribers) = subscribers.get(&Topic::NewTipBlock) { - let block: ckb_jsonrpc_types::BlockView = block.into(); - let json_string = Ok(serde_json::to_string(&block).expect("serialization should be ok")); - for sink in new_tip_block_subscribers.values() { - let _ = sink.notify(json_string.clone()); - } - } - }, - Some(tx_entry) = new_transaction_receiver.recv() => { - let subscribers = subscribers.read().expect("acquiring subscribers read lock"); - if let Some(new_transaction_subscribers) = subscribers.get(&Topic::NewTransaction) { - let entry: ckb_jsonrpc_types::PoolTransactionEntry = tx_entry.into(); - let json_string = Ok(serde_json::to_string(&entry).expect("serialization should be ok")); - for sink in new_transaction_subscribers.values() { - let _ = sink.notify(json_string.clone()); - } - } - }, - Some(tx_entry) = proposed_transaction_receiver.recv() => { - let subscribers = subscribers.read().expect("acquiring subscribers read lock"); - if let Some(new_transaction_subscribers) = subscribers.get(&Topic::ProposedTransaction) { - let entry: ckb_jsonrpc_types::PoolTransactionEntry = tx_entry.into(); - let json_string = Ok(serde_json::to_string(&entry).expect("serialization should be ok")); - for sink in new_transaction_subscribers.values() { - let _ = sink.notify(json_string.clone()); - } - } - }, - Some((tx_entry, reject)) = reject_transaction_receiver.recv() => { - let subscribers = subscribers.read().expect("acquiring subscribers read lock"); - if let Some(new_transaction_subscribers) = subscribers.get(&Topic::RejectedTransaction) { - let entry: ckb_jsonrpc_types::PoolTransactionEntry = tx_entry.into(); - let reject: ckb_jsonrpc_types::PoolTransactionReject = reject.into(); - let json_string = Ok(serde_json::to_string(&(entry, reject)).expect("serialization should be ok")); - for sink in new_transaction_subscribers.values() { - let _ = sink.notify(json_string.clone()); - } + let (new_tip_header_sender, _) = broadcast::channel(10); + let (new_tip_block_sender, _) = broadcast::channel(10); + let (proposed_transaction_sender, _) = broadcast::channel(10); + let (new_transaction_sender, _) = broadcast::channel(10); + let (new_reject_transaction_sender, _) = broadcast::channel(10); + + let stop_rx = new_tokio_exit_rx(); + handle.spawn({ + let new_tip_header_sender = new_tip_header_sender.clone(); + let new_tip_block_sender = new_tip_block_sender.clone(); + let new_transaction_sender = new_transaction_sender.clone(); + let proposed_transaction_sender = proposed_transaction_sender.clone(); + let new_reject_transaction_sender = new_reject_transaction_sender.clone(); + async move { + loop { + tokio::select! { + Some(block) = new_block_receiver.recv() => { + publiser_send!(ckb_jsonrpc_types::HeaderView, block.header(), new_tip_header_sender); + publiser_send!(ckb_jsonrpc_types::BlockView, block, new_tip_block_sender); + }, + Some(tx_entry) = new_transaction_receiver.recv() => { + publiser_send!(ckb_jsonrpc_types::PoolTransactionEntry, tx_entry, new_transaction_sender); + }, + Some(tx_entry) = proposed_transaction_receiver.recv() => { + publiser_send!(ckb_jsonrpc_types::PoolTransactionEntry, tx_entry, proposed_transaction_sender); + }, + Some((tx_entry, reject)) = reject_transaction_receiver.recv() => { + publiser_send!((ckb_jsonrpc_types::PoolTransactionEntry, ckb_jsonrpc_types::PoolTransactionReject), + (tx_entry.into(), reject.into()), + new_reject_transaction_sender); } + _ = stop_rx.cancelled() => { + break; + }, + else => break, } - else => break, } } }); - subscription_rpc_impl + Self { + new_tip_header_sender, + new_tip_block_sender, + new_transaction_sender, + proposed_transaction_sender, + new_reject_transaction_sender, + } } } diff --git a/rpc/src/module/test.rs b/rpc/src/module/test.rs index d56c85239fc..1452a1af318 100644 --- a/rpc/src/module/test.rs +++ b/rpc/src/module/test.rs @@ -1,4 +1,5 @@ use crate::error::RPCError; +use async_trait::async_trait; use ckb_chain::chain::ChainController; use ckb_dao::DaoCalculator; use ckb_jsonrpc_types::{Block, BlockTemplate, Byte32, EpochNumberWithFraction, Transaction}; @@ -20,12 +21,13 @@ use ckb_types::{ }; use ckb_verification_traits::Switch; use jsonrpc_core::Result; -use jsonrpc_derive::rpc; +use jsonrpc_utils::rpc; use std::collections::HashSet; use std::sync::Arc; /// RPC for Integration Test. -#[rpc(server)] +#[rpc] +#[async_trait] pub trait IntegrationTestRpc { /// process block without any block verification. /// @@ -498,12 +500,14 @@ pub trait IntegrationTestRpc { fn calculate_dao_field(&self, block_template: BlockTemplate) -> Result; } +#[derive(Clone)] pub(crate) struct IntegrationTestRpcImpl { pub network_controller: NetworkController, pub shared: Shared, pub chain: ChainController, } +#[async_trait] impl IntegrationTestRpc for IntegrationTestRpcImpl { fn process_block_without_verify(&self, data: Block, broadcast: bool) -> Result> { let block: packed::Block = data.into(); diff --git a/rpc/src/server.rs b/rpc/src/server.rs index c778f961c3d..08550d97303 100644 --- a/rpc/src/server.rs +++ b/rpc/src/server.rs @@ -1,19 +1,30 @@ -use crate::module::{SubscriptionRpc, SubscriptionRpcImpl, SubscriptionSession}; use crate::IoHandler; +use axum::routing::post; +use axum::{Extension, Router}; use ckb_app_config::RpcConfig; +use ckb_async_runtime::Handle; +use ckb_error::AnyError; use ckb_logger::info; -use ckb_notify::NotifyController; -use jsonrpc_pubsub::Session; -use jsonrpc_server_utils::cors::AccessControlAllowOrigin; -use jsonrpc_server_utils::hosts::DomainsValidation; + +use ckb_stop_handler::{new_tokio_exit_rx, CancellationToken}; +use futures_util::{SinkExt, TryStreamExt}; +use jsonrpc_core::MetaIoHandler; +use jsonrpc_utils::axum_utils::{handle_jsonrpc, handle_jsonrpc_ws}; +use jsonrpc_utils::pub_sub::Session; +use jsonrpc_utils::stream::{serve_stream_sink, StreamMsg, StreamServerConfig}; use std::net::{SocketAddr, ToSocketAddrs}; -use tokio::runtime::Handle; +use std::sync::Arc; +use std::time::Duration; +use tokio::net::TcpListener; +use tokio_util::codec::{FramedRead, FramedWrite, LinesCodec, LinesCodecError}; +use tower_http::timeout::TimeoutLayer; #[doc(hidden)] +#[derive(Debug)] pub struct RpcServer { - pub(crate) http: jsonrpc_http_server::Server, - pub(crate) _tcp: Option, - pub(crate) _ws: Option, + pub http_address: SocketAddr, + pub tcp_address: Option, + pub ws_address: Option, } impl RpcServer { @@ -23,96 +34,145 @@ impl RpcServer { /// /// * `config` - RPC config options. /// * `io_handler` - RPC methods handler. See [ServiceBuilder](../service_builder/struct.ServiceBuilder.html). - /// * `notify_controller` - Controller emitting notifications. - pub fn new( - config: RpcConfig, - io_handler: IoHandler, - notify_controller: &NotifyController, - handle: Handle, - ) -> RpcServer { - let http = jsonrpc_http_server::ServerBuilder::new(io_handler.clone()) - .cors(DomainsValidation::AllowOnly(vec![ - AccessControlAllowOrigin::Null, - AccessControlAllowOrigin::Any, - ])) - .event_loop_executor(handle.clone()) - .max_request_body_size(config.max_request_body_size) - .health_api(("/ping", "ping")) - .start_http( - &config - .listen_address - .to_socket_addrs() - .expect("config listen_address parsed") - .next() - .expect("config listen_address parsed"), - ) - .expect("Start Jsonrpc HTTP service"); - info!( - "Listen HTTP RPC server on address {}", - config.listen_address - ); - - let _tcp = config - .tcp_listen_address - .as_ref() - .map(|tcp_listen_address| { - let subscription_rpc_impl = - SubscriptionRpcImpl::new(notify_controller.clone(), handle.clone()); - let mut handler = io_handler.clone(); - if config.subscription_enable() { - handler.extend_with(subscription_rpc_impl.to_delegate()); - } - let tcp_server = jsonrpc_tcp_server::ServerBuilder::with_meta_extractor( - handler, - |context: &jsonrpc_tcp_server::RequestContext| { - Some(SubscriptionSession::new(Session::new( - context.sender.clone(), - ))) - }, - ) - .start( - &tcp_listen_address - .to_socket_addrs() - .expect("config tcp_listen_address parsed") - .next() - .expect("config tcp_listen_address parsed"), - ) - .expect("Start Jsonrpc TCP service"); - info!("Listen TCP RPC server on address {}", tcp_listen_address); - - tcp_server + /// * `handler` - Tokio runtime handle. + pub fn new(config: RpcConfig, io_handler: IoHandler, handler: Handle) -> Self { + let rpc = Arc::new(io_handler); + + let http_address = Self::start_server( + &rpc, + config.listen_address.to_owned(), + handler.clone(), + false, + ) + .map(|local_addr| { + info!("Listen HTTP RPCServer on address: {}", local_addr); + local_addr + }) + .unwrap(); + + let ws_address = if let Some(addr) = config.ws_listen_address { + let local_addr = Self::start_server(&rpc, addr, handler.clone(), true).map(|addr| { + info!("Listen WebSocket RPCServer on address: {}", addr); + addr }); + local_addr.ok() + } else { + None + }; - let _ws = config.ws_listen_address.as_ref().map(|ws_listen_address| { - let subscription_rpc_impl = SubscriptionRpcImpl::new(notify_controller.clone(), handle); - let mut handler = io_handler.clone(); - if config.subscription_enable() { - handler.extend_with(subscription_rpc_impl.to_delegate()); - } - let ws_server = jsonrpc_ws_server::ServerBuilder::with_meta_extractor( - handler, - |context: &jsonrpc_ws_server::RequestContext| { - Some(SubscriptionSession::new(Session::new(context.sender()))) - }, - ) - .start( - &ws_listen_address + let tcp_address = if let Some(addr) = config.tcp_listen_address { + let local_addr = handler.block_on(Self::start_tcp_server(rpc, addr)); + if let Ok(addr) = &local_addr { + info!("Listen TCP RPCServer on address: {}", addr); + }; + local_addr.ok() + } else { + None + }; + + Self { + http_address, + tcp_address, + ws_address, + } + } + + fn start_server( + rpc: &Arc>>, + address: String, + handler: Handle, + enable_websocket: bool, + ) -> Result { + let stream_config = StreamServerConfig::default() + .with_channel_size(4) + .with_pipeline_size(4); + + // HTTP and WS server. + let method_router = + post(handle_jsonrpc::>).get(handle_jsonrpc_ws::>); + let mut app = Router::new() + .route("/", method_router.clone()) + .route("/*path", method_router) + .layer(Extension(Arc::clone(rpc))) + .layer(TimeoutLayer::new(Duration::from_secs(30))); + + if enable_websocket { + let ws_config: StreamServerConfig = + stream_config + .with_keep_alive(true) + .with_shutdown(async move { + new_tokio_exit_rx().cancelled().await; + }); + app = app.layer(Extension(ws_config)); + } + + let (tx_addr, rx_addr) = tokio::sync::oneshot::channel::(); + + handler.spawn(async move { + let server = axum::Server::bind( + &address .to_socket_addrs() - .expect("config ws_listen_address parsed") + .expect("config listen_address parsed") .next() - .expect("config ws_listen_address parsed"), + .expect("config listen_address parsed"), ) - .expect("Start Jsonrpc WebSocket service"); - info!("Listen WS RPC server on address {}", ws_listen_address); + .serve(app.clone().into_make_service()); - ws_server + let _ = tx_addr.send(server.local_addr()); + let graceful = server.with_graceful_shutdown(async move { + new_tokio_exit_rx().cancelled().await; + }); + drop(graceful.await); }); - RpcServer { http, _tcp, _ws } + let rx_addr = handler.block_on(rx_addr)?; + Ok(rx_addr) } - /// Gets the HTTP RPC endpoint. - pub fn http_address(&self) -> &SocketAddr { - self.http.address() + async fn start_tcp_server( + rpc: Arc>>, + tcp_listen_address: String, + ) -> Result { + // TCP server with line delimited json codec. + let listener = TcpListener::bind(tcp_listen_address).await?; + let tcp_address = listener.local_addr()?; + tokio::spawn(async move { + let codec = LinesCodec::new_with_max_length(2 * 1024 * 1024); + let stream_config = StreamServerConfig::default() + .with_channel_size(4) + .with_pipeline_size(4) + .with_shutdown(async move { + new_tokio_exit_rx().cancelled().await; + }); + + let exit_signal: CancellationToken = new_tokio_exit_rx(); + tokio::select! { + _ = async { + while let Ok((stream, _)) = listener.accept().await { + let rpc = Arc::clone(&rpc); + let stream_config = stream_config.clone(); + let codec = codec.clone(); + tokio::spawn(async move { + let (r, w) = stream.into_split(); + let r = FramedRead::new(r, codec.clone()).map_ok(StreamMsg::Str); + let w = FramedWrite::new(w, codec).with(|msg| async move { + Ok::<_, LinesCodecError>(match msg { + StreamMsg::Str(msg) => msg, + _ => "".into(), + }) + }); + tokio::pin!(w); + if let Err(err) = serve_stream_sink(&rpc, w, r, stream_config).await { + info!("TCP RPCServer error: {:?}", err); + } + }); + } + } => {}, + _ = exit_signal.cancelled() => { + info!("TCP RPCServer stopped"); + } + } + }); + Ok(tcp_address) } } diff --git a/rpc/src/service_builder.rs b/rpc/src/service_builder.rs index 19372ce8a0c..ceecf2316c2 100644 --- a/rpc/src/service_builder.rs +++ b/rpc/src/service_builder.rs @@ -1,12 +1,13 @@ #![allow(deprecated)] -use crate::error::RPCError; -use crate::module::SubscriptionSession; use crate::module::{ - AlertRpc, AlertRpcImpl, ChainRpc, ChainRpcImpl, DebugRpc, DebugRpcImpl, ExperimentRpc, - ExperimentRpcImpl, IndexerRpc, IndexerRpcImpl, IntegrationTestRpc, IntegrationTestRpcImpl, - MinerRpc, MinerRpcImpl, NetRpc, NetRpcImpl, PoolRpc, PoolRpcImpl, StatsRpc, StatsRpcImpl, + add_alert_rpc_methods, add_chain_rpc_methods, add_debug_rpc_methods, + add_experiment_rpc_methods, add_indexer_rpc_methods, add_integration_test_rpc_methods, + add_miner_rpc_methods, add_net_rpc_methods, add_pool_rpc_methods, add_stats_rpc_methods, + add_subscription_rpc_methods, AlertRpcImpl, ChainRpcImpl, DebugRpcImpl, ExperimentRpcImpl, + IndexerRpcImpl, IntegrationTestRpcImpl, MinerRpcImpl, NetRpcImpl, PoolRpcImpl, StatsRpcImpl, + SubscriptionRpcImpl, }; -use crate::IoHandler; +use crate::{IoHandler, RPCError}; use ckb_app_config::{DBConfig, IndexerConfig, RpcConfig}; use ckb_chain::chain::ChainController; use ckb_indexer::IndexerService; @@ -17,7 +18,9 @@ use ckb_shared::shared::Shared; use ckb_sync::SyncShared; use ckb_types::packed::Script; use ckb_util::Mutex; +use jsonrpc_core::MetaIoHandler; use jsonrpc_core::RemoteProcedure; +use jsonrpc_utils::pub_sub::Session; use std::sync::Arc; const DEPRECATED_RPC_PREFIX: &str = "deprecated."; @@ -28,6 +31,19 @@ pub struct ServiceBuilder<'a> { io_handler: IoHandler, } +macro_rules! set_rpc_module_methods { + ($self:ident, $name:expr, $check:ident, $add_methods:ident, $methods:expr) => {{ + let mut meta_io = MetaIoHandler::default(); + $add_methods(&mut meta_io, $methods); + if $self.config.$check() { + $self.add_methods(meta_io); + } else { + $self.update_disabled_methods($name, meta_io); + } + $self + }}; +} + impl<'a> ServiceBuilder<'a> { /// Creates the RPC service builder from config. pub fn new(config: &'a RpcConfig) -> Self { @@ -39,13 +55,8 @@ impl<'a> ServiceBuilder<'a> { /// Mounts methods from module Chain if it is enabled in the config. pub fn enable_chain(mut self, shared: Shared) -> Self { - let rpc_methods = ChainRpcImpl { shared }.to_delegate(); - if self.config.chain_enable() { - self.add_methods(rpc_methods); - } else { - self.update_disabled_methods("Chain", rpc_methods); - } - self + let methods = ChainRpcImpl { shared }; + set_rpc_module_methods!(self, "Chain", chain_enable, add_chain_rpc_methods, methods) } /// Mounts methods from module Pool if it is enabled in the config. @@ -55,18 +66,12 @@ impl<'a> ServiceBuilder<'a> { extra_well_known_lock_scripts: Vec