From 9c8021d57de7be3dab644195f9218832755b5a3f Mon Sep 17 00:00:00 2001 From: driftluo Date: Wed, 25 Sep 2024 15:13:51 +0800 Subject: [PATCH] chore: remove deny with sqlx --- Cargo.lock | 537 ++++++++++++------ deny.toml | 92 ++- util/rich-indexer/Cargo.toml | 9 +- util/rich-indexer/src/indexer/insert.rs | 14 +- util/rich-indexer/src/indexer/remove.rs | 18 +- .../async_indexer_handle/get_transactions.rs | 4 +- util/rich-indexer/src/store.rs | 26 +- util/rich-indexer/src/tests/mod.rs | 2 +- 8 files changed, 445 insertions(+), 257 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d581a41dae..15e1abbdaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -189,9 +189,9 @@ dependencies = [ [[package]] name = "atoi" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ "num-traits", ] @@ -283,15 +283,21 @@ dependencies = [ [[package]] name = "base64" -version = "0.13.1" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bindgen" @@ -342,6 +348,9 @@ name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +dependencies = [ + "serde", +] [[package]] name = "blake2b-ref" @@ -1922,6 +1931,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.8" @@ -1972,6 +1990,12 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const-random" version = "0.1.18" @@ -2296,6 +2320,17 @@ dependencies = [ "uuid", ] +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -2337,30 +2372,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dlv-list" version = "0.5.2" @@ -2393,6 +2409,9 @@ name = "either" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +dependencies = [ + "serde", +] [[package]] name = "encode_unicode" @@ -2415,7 +2434,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2450,11 +2469,27 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + [[package]] name = "event-listener" -version = "2.5.3" +version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] [[package]] name = "fail" @@ -2541,14 +2576,13 @@ dependencies = [ [[package]] name = "flume" -version = "0.10.14" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ "futures-core", "futures-sink", - "pin-project", - "spin 0.9.8", + "spin", ] [[package]] @@ -2635,13 +2669,13 @@ dependencies = [ [[package]] name = "futures-intrusive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot 0.11.2", + "parking_lot 0.12.1", ] [[package]] @@ -2880,9 +2914,9 @@ checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -2890,11 +2924,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.8.4" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -2924,9 +2958,12 @@ name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -dependencies = [ - "unicode-segmentation", -] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -3218,7 +3255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -3405,6 +3442,9 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] [[package]] name = "lazycell" @@ -3434,22 +3474,11 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "libredox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.2", - "libc", - "redox_syscall 0.4.1", -] - [[package]] name = "libsqlite3-sys" -version = "0.24.2" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" dependencies = [ "cc", "pkg-config", @@ -3749,6 +3778,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -3765,6 +3811,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -3928,6 +3985,12 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + [[package]] name = "parking_lot" version = "0.11.2" @@ -4006,6 +4069,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -4175,6 +4247,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.30" @@ -4539,17 +4632,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_users" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" -dependencies = [ - "getrandom 0.2.12", - "libredox", - "thiserror", -] - [[package]] name = "reflink-copy" version = "0.1.15" @@ -4682,31 +4764,36 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.20" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", + "getrandom 0.2.12", "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", + "spin", + "untrusted", + "windows-sys 0.48.0", ] [[package]] -name = "ring" -version = "0.17.7" +name = "rsa" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" dependencies = [ - "cc", - "getrandom 0.2.12", - "libc", - "spin 0.9.8", - "untrusted 0.9.0", - "windows-sys 0.48.0", + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", ] [[package]] @@ -4755,23 +4842,43 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.9" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ - "log", - "ring 0.16.20", - "sct", - "webpki", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", ] [[package]] name = "rustls-pemfile" -version = "1.0.4" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -4842,16 +4949,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring 0.17.7", - "untrusted 0.9.0", -] - [[package]] name = "secp256k1" version = "0.29.0" @@ -5120,6 +5217,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -5166,6 +5273,9 @@ name = "smallvec" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +dependencies = [ + "serde", +] [[package]] name = "smartstring" @@ -5205,12 +5315,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -5220,6 +5324,16 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "sql-builder" version = "3.1.1" @@ -5243,98 +5357,199 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.6.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" +checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" dependencies = [ "sqlx-core", "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", ] [[package]] name = "sqlx-core" -version = "0.6.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" dependencies = [ - "ahash 0.7.8", "atoi", - "base64 0.13.1", - "bitflags 1.3.2", "byteorder", "bytes", "crc", "crossbeam-queue", - "dirs", - "dotenvy", "either", "event-listener", - "flume", "futures-channel", "futures-core", - "futures-executor", "futures-intrusive", + "futures-io", "futures-util", + "hashbrown 0.14.5", "hashlink", "hex", - "hkdf", - "hmac", - "indexmap 1.9.3", - "itoa", - "libc", - "libsqlite3-sys", + "indexmap 2.2.5", "log", - "md-5", "memchr", "once_cell", "paste", "percent-encoding", - "rand 0.8.5", "rustls", "rustls-pemfile", "serde", "serde_json", - "sha1", "sha2", "smallvec", "sqlformat", - "sqlx-rt", - "stringprep", "thiserror", + "tokio", "tokio-stream", + "tracing", "url", "webpki-roots", - "whoami", ] [[package]] name = "sqlx-macros" -version = "0.6.3" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.52", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" +checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" dependencies = [ "dotenvy", "either", - "heck", + "heck 0.5.0", + "hex", "once_cell", "proc-macro2", "quote", + "serde", + "serde_json", "sha2", "sqlx-core", - "sqlx-rt", - "syn 1.0.109", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 2.0.52", + "tempfile", + "tokio", "url", ] [[package]] -name = "sqlx-rt" -version = "0.6.3" +name = "sqlx-mysql" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64bb4714269afa44aef2755150a0fc19d756fb580a67db8885608cf02f47d06a" +dependencies = [ + "atoi", + "base64 0.22.1", + "bitflags 2.4.2", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.5", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" +checksum = "6fa91a732d854c5d7726349bb4bb879bb9478993ceb764247660aee25f67c2f8" dependencies = [ + "atoi", + "base64 0.22.1", + "bitflags 2.4.2", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", "once_cell", - "tokio", - "tokio-rustls", + "rand 0.8.5", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "tracing", + "url", ] [[package]] @@ -5484,7 +5699,7 @@ dependencies = [ "openssl-sys", "rand 0.8.5", "rand_core 0.6.4", - "ring 0.17.7", + "ring", "secp256k1", "sha2", "tokio", @@ -5727,17 +5942,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls", - "tokio", - "webpki", -] - [[package]] name = "tokio-stream" version = "0.1.14" @@ -6135,12 +6339,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -6331,23 +6529,13 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" -dependencies = [ - "ring 0.17.7", - "untrusted 0.9.0", -] - [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ - "webpki", + "rustls-pki-types", ] [[package]] @@ -6370,7 +6558,6 @@ checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ "redox_syscall 0.4.1", "wasite", - "web-sys", ] [[package]] diff --git a/deny.toml b/deny.toml index 0add03b4f6..6965c57f0b 100644 --- a/deny.toml +++ b/deny.toml @@ -23,13 +23,13 @@ # dependencies not shared by any other crates, would be ignored, as the target # list here is effectively saying which targets you are building for. targets = [ - # The triple can be any string, but only the target triples built in to - # rustc (as of 1.40) can be checked against actual config expressions - #"x86_64-unknown-linux-musl", - # You can also specify which target_features you promise are enabled for a - # particular target. target_features are currently not validated against - # the actual valid features supported by the target architecture. - #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, + # The triple can be any string, but only the target triples built in to + # rustc (as of 1.40) can be checked against actual config expressions + #"x86_64-unknown-linux-musl", + # You can also specify which target_features you promise are enabled for a + # particular target. target_features are currently not validated against + # the actual valid features supported by the target architecture. + #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, ] # When creating the dependency graph used as the source of truth when checks are # executed, this field can be used to prune crates from the graph, removing them @@ -70,23 +70,13 @@ feature-depth = 1 # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ -# https://rustsec.org/advisories/RUSTSEC-2024-0363 -# https://github.com/launchbadge/sqlx/issues/3440 -# The queries for the rich indexer receive input parameters via RPC, and the data size is far less than 4GB, so this issue can be temporarily ignored while waiting for sqlx to be fixed. - "RUSTSEC-2024-0363", -# https://rustsec.org/advisories/RUSTSEC-2022-0090 -# It was sometimes possible for SQLite versions >= 1.0.12, < 3.39.2 to allow an array-bounds overflow when large string were input into SQLite's `printf` function. - "RUSTSEC-2022-0090", -# https://rustsec.org/advisories/RUSTSEC-2024-0336 -# `rustls::ConnectionCommon::complete_io` could fall into an infinite loop based on network input - "RUSTSEC-2024-0336", -# Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0370 -# proc-macro-error's maintainer seems to be unreachable, with no commits for 2 years, no releases pushed for 4 years, and no activity on the GitLab repo or response to email. - "RUSTSEC-2024-0370" -#"RUSTSEC-0000-0000", -#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, -#"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish -#{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, + # Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0370 + # proc-macro-error's maintainer seems to be unreachable, with no commits for 2 years, no releases pushed for 4 years, and no activity on the GitLab repo or response to email. + "RUSTSEC-2024-0370", + #"RUSTSEC-0000-0000", + #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, + #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish + #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, ] # If this is true, then cargo deny will use the git executable to fetch advisory database. # If this is false, then it uses a built-in git library. @@ -102,16 +92,16 @@ ignore = [ # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. allow = [ - "MIT", - "Apache-2.0", - "MPL-2.0", - "BSL-1.0", - "BSD-3-Clause", - "ISC", - "CC0-1.0", - "Unicode-DFS-2016", - "OpenSSL" - #"Apache-2.0 WITH LLVM-exception", + "MIT", + "Apache-2.0", + "MPL-2.0", + "BSL-1.0", + "BSD-3-Clause", + "ISC", + "CC0-1.0", + "Unicode-DFS-2016", + "OpenSSL", + #"Apache-2.0 WITH LLVM-exception", ] # The confidence threshold for detecting a license from license text. # The higher the value, the more closely the license text must be to the @@ -121,9 +111,9 @@ confidence-threshold = 0.8 # Allow 1 or more licenses on a per-crate basis, so that particular licenses # aren't accepted for every possible crate as with the normal allow list exceptions = [ - # Each entry is the crate and version constraint, and its specific allow - # list - # { allow = ["Zlib"], crate = "adler32" }, + # Each entry is the crate and version constraint, and its specific allow + # list + # { allow = ["Zlib"], crate = "adler32" }, ] # Some crates don't have (easily) machine readable licensing information, @@ -140,8 +130,8 @@ expression = "MIT AND ISC AND OpenSSL" # and the crate will be checked normally, which may produce warnings or errors # depending on the rest of your configuration license-files = [ -# Each entry is a crate relative path, and the (opaque) hash of its contents -{ path = "LICENSE", hash = 0xbd0eed23 } + # Each entry is a crate relative path, and the (opaque) hash of its contents + { path = "LICENSE", hash = 0xbd0eed23 }, ] [licenses.private] @@ -154,7 +144,7 @@ ignore = true # is only published to private registries, and ignore is true, the crate will # not have its license(s) checked registries = [ - #"https://sekretz.com/registry + #"https://sekretz.com/registry ] # This section is considered when running `cargo deny check bans`. @@ -181,16 +171,16 @@ workspace-default-features = "allow" external-default-features = "allow" # List of crates that are allowed. Use with care! allow = [ - #"ansi_term@0.11.0", - #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, ] # List of crates to deny deny = [ - #"ansi_term@0.11.0", - #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, - # Wrapper crates can optionally be specified to allow the crate when it - # is a direct dependency of the otherwise banned crate - #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, + # Wrapper crates can optionally be specified to allow the crate when it + # is a direct dependency of the otherwise banned crate + #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, ] # List of features to allow/deny @@ -218,16 +208,16 @@ deny = [ # Certain crates/versions that will be skipped when doing duplicate detection. skip = [ - #"ansi_term@0.11.0", - #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, ] # Similarly to `skip` allows you to skip certain crates during duplicate # detection. Unlike skip, it also includes the entire tree of transitive # dependencies starting at the specified crate, up to a certain depth, which is # by default infinite. skip-tree = [ - #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies - #{ crate = "ansi_term@0.11.0", depth = 20 }, + #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies + #{ crate = "ansi_term@0.11.0", depth = 20 }, ] # This section is considered when running `cargo deny check sources`. diff --git a/util/rich-indexer/Cargo.toml b/util/rich-indexer/Cargo.toml index 434b1f1586..093008b0fd 100644 --- a/util/rich-indexer/Cargo.toml +++ b/util/rich-indexer/Cargo.toml @@ -23,9 +23,14 @@ log = "0.4" num-bigint = "0.4" once_cell = "1.8.0" sql-builder = "3.1" -sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "any", "sqlite", "postgres"] } +sqlx = { version = "0.8.2", features = [ + "runtime-tokio-rustls", + "any", + "sqlite", + "postgres", +] } include_dir = "0.7" -tempfile = "3" +tempfile.workspace = true [dev-dependencies] hex = "0.4" diff --git a/util/rich-indexer/src/indexer/insert.rs b/util/rich-indexer/src/indexer/insert.rs index ab9edccaf1..61e1399c1f 100644 --- a/util/rich-indexer/src/indexer/insert.rs +++ b/util/rich-indexer/src/indexer/insert.rs @@ -418,7 +418,7 @@ pub(crate) async fn spend_cell( ) .bind(output_tx_hash) .bind(output_index as i32) - .execute(&mut *tx) + .execute(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))? .rows_affected(); @@ -458,7 +458,7 @@ pub(crate) async fn query_output_cell( ) .bind(output_tx_hash) .bind(output_index as i32) - .fetch_optional(tx) + .fetch_optional(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; @@ -484,7 +484,7 @@ pub(crate) async fn query_output_id( ) .bind(output_tx_hash) .bind(output_index as i32) - .fetch_optional(tx) + .fetch_optional(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string())) .map(|row| row.map(|row| row.get::("id"))) @@ -508,7 +508,7 @@ pub(crate) async fn query_script_id( .bind(code_hash) .bind(hash_type) .bind(args) - .fetch_optional(tx) + .fetch_optional(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string())) .map(|row| row.map(|row| row.get::("id"))) @@ -528,7 +528,7 @@ pub(crate) async fn query_block_id( "#, ) .bind(block_hash) - .fetch_optional(tx) + .fetch_optional(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string())) .map(|row| row.map(|row| row.get::("id"))) @@ -666,7 +666,7 @@ async fn bulk_insert( // execute query - .execute(&mut *tx) + .execute(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; } @@ -695,7 +695,7 @@ async fn bulk_insert_and_return_ids( // execute let mut rows = query - .fetch_all(&mut *tx) + .fetch_all(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; id_list.append(&mut rows); diff --git a/util/rich-indexer/src/indexer/remove.rs b/util/rich-indexer/src/indexer/remove.rs index 7f4bf24f4c..9e6c3a05c5 100644 --- a/util/rich-indexer/src/indexer/remove.rs +++ b/util/rich-indexer/src/indexer/remove.rs @@ -76,7 +76,7 @@ async fn remove_batch_by_blobs( // execute query - .execute(tx) + .execute(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; @@ -98,7 +98,7 @@ async fn reset_spent_cells(tx_id_list: &[i64], tx: &mut Transaction<'_, Any>) -> .map_err(|err| Error::DB(err.to_string()))?; sqlx::query(&query) - .execute(&mut *tx) + .execute(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; @@ -117,7 +117,7 @@ async fn query_uncle_id_list_by_block_id( "#, ) .bind(block_id) - .fetch_all(tx) + .fetch_all(tx.as_mut()) .await .map(|rows| rows.into_iter().map(|row| row.get("uncle_id")).collect()) .map_err(|err| Error::DB(err.to_string())) @@ -131,7 +131,7 @@ async fn query_tip_id(tx: &mut Transaction<'_, Any>) -> Result, Erro LIMIT 1 "#, ) - .fetch_optional(tx) + .fetch_optional(tx.as_mut()) .await .map(|res| res.map(|row| row.get::("id"))) .map_err(|err| Error::DB(err.to_string())) @@ -150,7 +150,7 @@ async fn query_tx_id_list_by_block_id( "#, ) .bind(block_id) - .fetch_all(tx) + .fetch_all(tx.as_mut()) .await .map(|rows| { rows.into_iter() @@ -185,7 +185,7 @@ async fn query_outputs_by_tx_id_list( // execute query - .fetch_all(&mut *tx) + .fetch_all(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string())) .map(|rows| { @@ -215,7 +215,7 @@ async fn script_exists_in_output( "#, ) .bind(script_id) - .fetch_one(&mut *tx) + .fetch_one(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; @@ -229,11 +229,11 @@ async fn script_exists_in_output( "#, ) .bind(script_id) - .fetch_one(&mut *tx) + .fetch_one(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; - Ok(row_lock.get::(0) || row_type.get::(0)) + Ok(row_lock.get::(0) == 1 || row_type.get::(0) == 1) } fn sqlx_param_placeholders(range: std::ops::Range) -> Result, Error> { diff --git a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs index ff58aa0a6f..5049dedb87 100644 --- a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs +++ b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs @@ -249,7 +249,7 @@ pub async fn get_tx_with_cell( // fetch let outputs = query - .fetch_all(&mut *tx) + .fetch_all(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))? .iter() @@ -399,7 +399,7 @@ pub async fn get_tx_with_cells( // fetch let outputs = query - .fetch_all(&mut *tx) + .fetch_all(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))? .iter() diff --git a/util/rich-indexer/src/store.rs b/util/rich-indexer/src/store.rs index 22c910ff2a..856a33f9e2 100644 --- a/util/rich-indexer/src/store.rs +++ b/util/rich-indexer/src/store.rs @@ -5,10 +5,10 @@ use include_dir::{include_dir, Dir}; use log::LevelFilter; use once_cell::sync::OnceCell; use sqlx::{ - any::{Any, AnyArguments, AnyConnectOptions, AnyPool, AnyPoolOptions, AnyRow}, + any::{Any, AnyArguments, AnyConnectOptions, AnyPoolOptions, AnyRow}, migrate::Migrator, query::{Query, QueryAs}, - ConnectOptions, IntoArguments, Row, Transaction, + AnyPool, ConnectOptions, IntoArguments, Row, Transaction, }; use tempfile::tempdir; @@ -18,7 +18,7 @@ use std::path::PathBuf; use std::str::FromStr; use std::{fmt::Debug, sync::Arc, time::Duration}; -const MEMORY_DB: &str = ":memory:"; +const MEMORY_DB: &str = "sqlite://?mode=memory"; const SQL_SQLITE_CREATE_TABLE: &str = include_str!("../resources/create_sqlite_table.sql"); const SQL_SQLITE_CREATE_INDEX: &str = include_str!("../resources/create_sqlite_index.sql"); const SQL_POSTGRES_CREATE_TABLE: &str = include_str!("../resources/create_postgres_table.sql"); @@ -41,18 +41,24 @@ impl Debug for SQLXPool { impl SQLXPool { pub async fn connect(&mut self, db_config: &RichIndexerConfig) -> Result<()> { - let pool_options = AnyPoolOptions::new() + // if not init, it will panic, see doc for more + sqlx::any::install_default_drivers(); + let mut pool_options = AnyPoolOptions::new() .max_connections(10) .min_connections(0) .acquire_timeout(Duration::from_secs(60)) .max_lifetime(Duration::from_secs(1800)) .idle_timeout(Duration::from_secs(30)); + if db_config.store == Into::::into(MEMORY_DB) { + // See related issue: https://github.com/launchbadge/sqlx/issues/2510 + pool_options = pool_options.max_connections(1); + } let pool = match db_config.db_type { DBDriver::Sqlite => { let require_init = is_sqlite_require_init(db_config); let uri = build_url_for_sqlite(db_config); - let mut connection_options = AnyConnectOptions::from_str(&uri)?; - connection_options.log_statements(LevelFilter::Trace); + let connection_options = + AnyConnectOptions::from_str(&uri)?.log_statements(LevelFilter::Trace); let pool = pool_options.connect_with(connection_options).await?; log::info!("SQLite is connected."); self.pool @@ -67,8 +73,8 @@ impl SQLXPool { DBDriver::Postgres => { let require_init = self.is_postgres_require_init(db_config).await?; let uri = build_url_for_postgres(db_config); - let mut connection_options = AnyConnectOptions::from_str(&uri)?; - connection_options.log_statements(LevelFilter::Trace); + let connection_options = + AnyConnectOptions::from_str(&uri)?.log_statements(LevelFilter::Trace); let pool = pool_options.connect_with(connection_options).await?; log::info!("PostgreSQL is connected."); self.pool @@ -209,8 +215,8 @@ impl SQLXPool { let mut temp_config = db_config.clone(); temp_config.db_name = "postgres".to_string(); let uri = build_url_for_postgres(&temp_config); - let mut connection_options = AnyConnectOptions::from_str(&uri)?; - connection_options.log_statements(LevelFilter::Trace); + let connection_options = + AnyConnectOptions::from_str(&uri)?.log_statements(LevelFilter::Trace); let tmp_pool_options = AnyPoolOptions::new(); let pool = tmp_pool_options.connect_with(connection_options).await?; diff --git a/util/rich-indexer/src/tests/mod.rs b/util/rich-indexer/src/tests/mod.rs index 5493fe5291..c398f9c457 100644 --- a/util/rich-indexer/src/tests/mod.rs +++ b/util/rich-indexer/src/tests/mod.rs @@ -14,7 +14,7 @@ use ckb_jsonrpc_types::{ use ckb_types::h256; use ckb_types::prelude::*; -const MEMORY_DB: &str = ":memory:"; +const MEMORY_DB: &str = "sqlite://?mode=memory"; const BLOCK_DIR: &str = "./src/tests/data/blocks/"; async fn connect_sqlite(store_path: &str) -> SQLXPool {