From 4cd7dce2b2e5e457131079fa9073cb3d8ab06594 Mon Sep 17 00:00:00 2001 From: driftluo Date: Wed, 23 Oct 2024 15:23:01 +0800 Subject: [PATCH] chore: upgrade deps --- Cargo.lock | 544 +++++++++++++----- benches/Cargo.toml | 1 - benches/benches/benchmarks/util.rs | 28 +- chain/Cargo.toml | 9 +- chain/src/tests/block_assembler.rs | 15 - ckb-bin/Cargo.toml | 2 +- db-migration/Cargo.toml | 1 - db-migration/src/lib.rs | 4 +- error/Cargo.toml | 4 +- error/src/lib.rs | 2 +- miner/Cargo.toml | 10 +- miner/src/client.rs | 94 +-- network/Cargo.toml | 18 +- network/src/protocols/tests/mod.rs | 3 +- .../src/services/dns_seeding/seed_record.rs | 8 +- rpc/Cargo.toml | 2 +- shared/Cargo.toml | 19 +- shared/src/shared_builder.rs | 8 +- spec/Cargo.toml | 8 +- sync/Cargo.toml | 3 +- sync/src/tests/net_time_checker.rs | 3 +- test/Cargo.toml | 9 +- test/src/global.rs | 21 +- test/src/main.rs | 98 ++-- test/src/rpc.rs | 14 +- tx-pool/Cargo.toml | 18 +- tx-pool/src/block_assembler/mod.rs | 14 +- util/Cargo.toml | 3 +- util/app-config/Cargo.toml | 2 +- util/crypto/Cargo.toml | 1 - util/crypto/src/secp/mod.rs | 8 +- util/jsonrpc-types/Cargo.toml | 1 - util/jsonrpc-types/src/tests/blockchain.rs | 8 +- util/logger-service/Cargo.toml | 3 +- util/logger-service/src/lib.rs | 8 +- util/memory-tracker/Cargo.toml | 1 - util/memory-tracker/src/process.rs | 4 +- util/metrics-service/Cargo.toml | 5 +- util/metrics-service/src/lib.rs | 66 ++- util/metrics/Cargo.toml | 1 - util/metrics/src/lib.rs | 5 +- util/network-alert/Cargo.toml | 9 +- util/network-alert/src/tests/test_notifier.rs | 3 +- util/rich-indexer/Cargo.toml | 1 - util/rich-indexer/src/store.rs | 4 +- util/src/strings.rs | 2 +- util/stop-handler/Cargo.toml | 1 - util/stop-handler/src/stop_register.rs | 16 +- util/test-chain-utils/Cargo.toml | 7 +- util/test-chain-utils/src/chain.rs | 31 +- util/types/Cargo.toml | 3 +- util/types/src/core/cell.rs | 4 +- util/types/src/global.rs | 4 +- verification/Cargo.toml | 8 +- 54 files changed, 729 insertions(+), 440 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd09682ce5..437005b03e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -197,13 +197,19 @@ dependencies = [ "num-traits", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "attohttpc" version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb8867f378f33f78a811a8eb9bf108ad99430d7aad43315dd9319c827ef6247" dependencies = [ - "http", + "http 0.2.12", "log", "url", "wildmatch", @@ -227,9 +233,9 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", "itoa", "matchit", "memchr", @@ -242,7 +248,7 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper", + "sync_wrapper 0.1.2", "tokio", "tokio-tungstenite", "tower", @@ -259,8 +265,8 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "mime", "rustversion", "tower-layer", @@ -387,12 +393,6 @@ dependencies = [ "rand 0.8.5", ] -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - [[package]] name = "bs58" version = "0.5.1" @@ -435,13 +435,12 @@ dependencies = [ [[package]] name = "cacache" -version = "12.0.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142316461ed3a3dfcba10417317472da5bfd0461e4d276bf7c07b330766d9490" +checksum = "a61ff12b19d89c752c213316b87fdb4a587f073d219b893cc56974b8c9f39bf7" dependencies = [ "digest", "either", - "futures", "hex", "libc", "memmap2", @@ -455,8 +454,6 @@ dependencies = [ "ssri", "tempfile", "thiserror", - "tokio", - "tokio-stream", "walkdir", ] @@ -662,7 +659,6 @@ dependencies = [ "ckb-verification", "ckb-verification-traits", "criterion", - "lazy_static", "rand 0.8.5", "tempfile", ] @@ -765,7 +761,6 @@ dependencies = [ "dashmap", "faux", "is_sorted", - "lazy_static", "minstant", "tempfile", ] @@ -817,7 +812,6 @@ version = "0.119.0-pre" dependencies = [ "ckb-fixed-hash", "faster-hex", - "lazy_static", "rand 0.8.5", "secp256k1", "thiserror", @@ -873,7 +867,6 @@ dependencies = [ "ckb-stop-handler", "console", "indicatif", - "once_cell", "tempfile", ] @@ -887,7 +880,7 @@ version = "0.119.0-pre" dependencies = [ "anyhow", "ckb-occupied-capacity", - "derive_more", + "derive_more 1.0.0", "thiserror", ] @@ -1014,7 +1007,6 @@ dependencies = [ "ckb-types", "ckb_schemars", "faster-hex", - "lazy_static", "proptest", "regex", "serde", @@ -1109,7 +1101,6 @@ dependencies = [ "ckb-util", "env_logger", "log", - "once_cell", "regex", "sentry", "tempfile", @@ -1125,7 +1116,6 @@ dependencies = [ "ckb-logger", "ckb-metrics", "libc", - "once_cell", "tikv-jemalloc-ctl", "tikv-jemalloc-sys", ] @@ -1143,7 +1133,6 @@ dependencies = [ name = "ckb-metrics" version = "0.119.0-pre" dependencies = [ - "once_cell", "prometheus", "prometheus-static-metric", ] @@ -1165,8 +1154,11 @@ dependencies = [ "ckb-metrics-config", "ckb-stop-handler", "ckb-util", - "hyper", + "http-body-util", + "hyper 1.5.0", + "hyper-util", "prometheus", + "tokio", ] [[package]] @@ -1213,8 +1205,10 @@ dependencies = [ "console", "eaglesong", "futures", - "hyper", + "http-body-util", + "hyper 1.5.0", "hyper-tls", + "hyper-util", "indicatif", "jsonrpc-core", "lru", @@ -1241,7 +1235,7 @@ version = "0.119.0-pre" dependencies = [ "bitflags 1.3.2", "bloom-filters", - "bs58 0.4.0", + "bs58", "ckb-app-config", "ckb-hash", "ckb-logger", @@ -1255,9 +1249,7 @@ dependencies = [ "faster-hex", "futures", "ipnetwork", - "lazy_static", "num_cpus", - "once_cell", "proptest", "rand 0.8.5", "secp256k1", @@ -1265,7 +1257,7 @@ dependencies = [ "serde", "serde_json", "snap", - "socket2 0.5.7", + "socket2", "tempfile", "tentacle", "tokio", @@ -1291,7 +1283,6 @@ dependencies = [ "ckb-util", "faster-hex", "lru", - "once_cell", "semver", "serde_json", ] @@ -1408,7 +1399,6 @@ dependencies = [ "include_dir", "log", "num-bigint", - "once_cell", "rand 0.8.5", "serde_json", "sql-builder", @@ -1551,7 +1541,6 @@ dependencies = [ "ckb-util", "ckb-verification", "dashmap", - "once_cell", "sled", "tempfile", "tokio", @@ -1587,7 +1576,6 @@ dependencies = [ "ckb-util", "ctrlc", "libc", - "once_cell", "rand 0.8.5", "tokio", "tokio-util", @@ -1647,7 +1635,6 @@ dependencies = [ "itertools 0.11.0", "keyed_priority_queue", "lru", - "once_cell", "rand 0.8.5", "sentry", "tempfile", @@ -1686,7 +1673,6 @@ dependencies = [ "ckb-traits", "ckb-types", "ckb-util", - "lazy_static", "tempfile", ] @@ -1723,7 +1709,9 @@ dependencies = [ "ckb-types", "ckb-util", "ckb-verification", - "hyper", + "http-body-util", + "hyper 1.5.0", + "hyper-util", "lru", "multi_index_map", "num_cpus", @@ -1752,12 +1740,11 @@ dependencies = [ "ckb-merkle-mountain-range", "ckb-occupied-capacity", "ckb-rational", - "derive_more", + "derive_more 1.0.0", "golomb-coded-set", "merkle-cbt", "molecule", "numext-fixed-uint", - "once_cell", "paste", "proptest", ] @@ -1768,7 +1755,6 @@ version = "0.119.0-pre" dependencies = [ "ckb-fixed-hash", "linked-hash-map", - "once_cell", "parking_lot 0.12.3", "regex", ] @@ -1789,7 +1775,7 @@ dependencies = [ "ckb-traits", "ckb-types", "ckb-verification-traits", - "derive_more", + "derive_more 1.0.0", "lru", "tokio", ] @@ -1838,7 +1824,7 @@ dependencies = [ "bytes", "cc", "ckb-vm-definitions", - "derive_more", + "derive_more 0.99.18", "goblin 0.2.3", "goblin 0.4.0", "rand 0.7.3", @@ -2356,6 +2342,27 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", + "unicode-xid", +] + [[package]] name = "deunicode" version = "1.6.0" @@ -2433,14 +2440,14 @@ dependencies = [ [[package]] name = "enum-as-inner" -version = "0.3.4" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.79", ] [[package]] @@ -2555,6 +2562,18 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "findshlibs" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40b9e59cd0f7e0806cca4be089683ecb6434e602038df21fe6bf6711b2f07f64" +dependencies = [ + "cc", + "lazy_static", + "libc", + "winapi", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -2866,7 +2885,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap 2.6.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap 2.6.0", "slab", "tokio", @@ -2956,12 +2994,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -3024,6 +3056,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "hostname" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9c7c7c8ac16c798734b8a24560c1362120597c40d5e1459f09498f8f6c8f2ba" +dependencies = [ + "cfg-if", + "libc", + "windows 0.52.0", +] + [[package]] name = "http" version = "0.2.12" @@ -3035,6 +3078,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -3042,7 +3096,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -3089,27 +3166,65 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.7", + "socket2", "tokio", "tower-service", "tracing", "want", ] +[[package]] +name = "hyper" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.5.0", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-timeout" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.31", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -3117,15 +3232,37 @@ dependencies = [ [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", - "hyper", + "http-body-util", + "hyper 1.5.0", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.5.0", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", ] [[package]] @@ -3159,11 +3296,10 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] @@ -3299,14 +3435,14 @@ dependencies = [ [[package]] name = "ipconfig" -version = "0.2.2" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.3.19", + "socket2", "widestring", - "winapi", - "winreg 0.6.2", + "windows-sys 0.48.0", + "winreg", ] [[package]] @@ -3317,9 +3453,9 @@ checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "ipnetwork" -version = "0.18.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4088d739b183546b239688ddbc79891831df421773df95e236daf7867866d355" +checksum = "bf466541e9d546596ee94f9f69590f89473455f88372423e0008fc1a7daf100e" dependencies = [ "serde", ] @@ -3564,12 +3700,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - [[package]] name = "matchit" version = "0.7.3" @@ -3998,6 +4128,17 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "os_info" +version = "3.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092" +dependencies = [ + "log", + "serde", + "windows-sys 0.52.0", +] + [[package]] name = "parking" version = "2.2.1" @@ -4656,7 +4797,7 @@ checksum = "dc31414597d1cd7fdd2422798b7652a6329dda0fe0219e6335a13d5bcaa9aeb6" dependencies = [ "cfg-if", "rustix", - "windows", + "windows 0.58.0", ] [[package]] @@ -4705,20 +4846,24 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bytes", "encoding_rs", + "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.0", + "hyper-rustls", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -4727,9 +4872,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper 1.0.1", + "system-configuration", "tokio", "tokio-native-tls", "tower-service", @@ -4737,7 +4885,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg 0.50.0", + "windows-registry", ] [[package]] @@ -4746,7 +4894,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" dependencies = [ - "hostname", + "hostname 0.3.1", "quick-error", ] @@ -5014,40 +5162,45 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "sentry" -version = "0.26.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904eca4fb30c6112a1dae60c0a9e29cfb42f42129da4260f1ee20e94151b62e3" +checksum = "5484316556650182f03b43d4c746ce0e3e48074a21e2f51244b648b6542e1066" dependencies = [ "httpdate", + "native-tls", "reqwest", "sentry-backtrace", "sentry-contexts", "sentry-core", + "sentry-debug-images", "sentry-log", "sentry-panic", + "sentry-tracing", "tokio", + "ureq", ] [[package]] name = "sentry-backtrace" -version = "0.26.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1671189d1b759879fa4bdde46c50a499abb14332ed81f84fc6f60658f41b2fdb" +checksum = "40aa225bb41e2ec9d7c90886834367f560efc1af028f1c5478a6cce6a59c463a" dependencies = [ "backtrace", - "lazy_static", + "once_cell", "regex", "sentry-core", ] [[package]] name = "sentry-contexts" -version = "0.26.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db80ceff16bb1a4b2689b8758e5e61e405fc4d8ff9f2d1b5b845b76ce37fa34e" +checksum = "1a8dd746da3d16cb8c39751619cefd4fcdbd6df9610f3310fd646b55f6e39910" dependencies = [ - "hostname", + "hostname 0.4.0", "libc", + "os_info", "rustc_version", "sentry-core", "uname", @@ -5055,22 +5208,33 @@ dependencies = [ [[package]] name = "sentry-core" -version = "0.26.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c9f509d3959ed4dbbd80ca42572caad682aaa1cdd92c719e0815d0e87f82c96" +checksum = "161283cfe8e99c8f6f236a402b9ccf726b201f365988b5bb637ebca0abbd4a30" dependencies = [ - "lazy_static", + "once_cell", "rand 0.8.5", "sentry-types", "serde", "serde_json", ] +[[package]] +name = "sentry-debug-images" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc6b25e945fcaa5e97c43faee0267eebda9f18d4b09a251775d8fef1086238a" +dependencies = [ + "findshlibs", + "once_cell", + "sentry-core", +] + [[package]] name = "sentry-log" -version = "0.26.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4e00357035f6af5404870048167affaa551e15e0bee6efa2157e4b9bec6a453" +checksum = "75bbcc61886955045a1dd4bdb173412a80bb2571be3c5bfcf7eb8f55a442bbf5" dependencies = [ "log", "sentry-core", @@ -5078,23 +5242,35 @@ dependencies = [ [[package]] name = "sentry-panic" -version = "0.26.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8b442769cc34115f64393f7bfe4f863c3c38749e0c0b9613a7ae25b37c7ba53" +checksum = "bc74f229c7186dd971a9491ffcbe7883544aa064d1589bd30b83fb856cd22d63" dependencies = [ "sentry-backtrace", "sentry-core", ] +[[package]] +name = "sentry-tracing" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3c5faf2103cd01eeda779ea439b68c4ee15adcdb16600836e97feafab362ec" +dependencies = [ + "sentry-backtrace", + "sentry-core", + "tracing-core", + "tracing-subscriber", +] + [[package]] name = "sentry-types" -version = "0.26.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "254b600e93e9ef00a48382c9f1e86d27884bd9a5489efa4eb9210c20c72e88a6" +checksum = "5d68cdf6bc41b8ff3ae2a9c4671e97426dcdd154cc1d4b6b72813f285d6b163f" dependencies = [ "debugid", - "getrandom 0.2.15", "hex", + "rand 0.8.5", "serde", "serde_json", "thiserror", @@ -5311,17 +5487,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" -[[package]] -name = "socket2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" -dependencies = [ - "cfg-if", - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.5.7" @@ -5447,7 +5612,7 @@ checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" dependencies = [ "dotenvy", "either", - "heck 0.5.0", + "heck", "hex", "once_cell", "proc-macro2", @@ -5648,6 +5813,36 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.13.0" @@ -5679,7 +5874,7 @@ dependencies = [ "once_cell", "parking_lot 0.12.3", "rand 0.8.5", - "socket2 0.5.7", + "socket2", "tentacle-multiaddr", "tentacle-secio", "thiserror", @@ -5697,7 +5892,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9e71b28bf0bbf274b92f47cb2c5b42755d84a11e2246cf7bcb7b65c89483b9" dependencies = [ - "bs58 0.5.1", + "bs58", "bytes", "serde", "sha2", @@ -5710,7 +5905,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cac8b23a7879426a4961acea6ae66287f7fe9a934d131a722cbb88f145e97fea" dependencies = [ - "bs58 0.5.1", + "bs58", "bytes", "chacha20poly1305", "futures", @@ -5927,7 +6122,7 @@ dependencies = [ "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.7", + "socket2", "tokio-macros", "tracing", "windows-sys 0.52.0", @@ -5964,6 +6159,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.16" @@ -6034,10 +6240,10 @@ dependencies = [ "axum", "base64 0.21.7", "bytes", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", "hyper-timeout", "percent-encoding", "pin-project", @@ -6080,8 +6286,8 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "http-range-header", "pin-project-lite", "tokio", @@ -6151,9 +6357,9 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.20.4" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca94d4e9feb6a181c690c4040d7a24ef34018d8313ac5044a61d21222ae24e31" +checksum = "3119112651c157f4488931a01e586aa459736e9d6046d3bd9105ffb69352d374" dependencies = [ "async-trait", "cfg-if", @@ -6162,35 +6368,36 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna 0.2.3", + "idna 0.4.0", "ipnet", - "lazy_static", - "log", + "once_cell", "rand 0.8.5", "smallvec", "thiserror", "tinyvec", "tokio", + "tracing", "url", ] [[package]] name = "trust-dns-resolver" -version = "0.20.4" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecae383baad9995efaa34ce8e57d12c3f305e545887472a492b838f4b5cfb77a" +checksum = "10a3e6c3aff1718b3c73e395d1f35202ba2ffa847c6a62eea0db8fb4cfe30be6" dependencies = [ "cfg-if", "futures-util", "ipconfig", - "lazy_static", - "log", "lru-cache", - "parking_lot 0.11.2", + "once_cell", + "parking_lot 0.12.3", + "rand 0.8.5", "resolv-conf", "smallvec", "thiserror", "tokio", + "tracing", "trust-dns-proto", ] @@ -6209,7 +6416,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.12", "httparse", "log", "rand 0.8.5", @@ -6344,6 +6551,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "unicode_categories" version = "0.1.1" @@ -6372,6 +6585,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "ureq" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" +dependencies = [ + "base64 0.22.1", + "log", + "native-tls", + "once_cell", + "url", +] + [[package]] name = "url" version = "2.5.2" @@ -6590,9 +6816,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.4.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "wildmatch" @@ -6631,6 +6857,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core 0.52.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.58.0" @@ -6685,6 +6921,17 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.2.0" @@ -6852,15 +7099,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winreg" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" -dependencies = [ - "winapi", -] - [[package]] name = "winreg" version = "0.50.0" diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 91858206ef..c5f5037f95 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -24,7 +24,6 @@ ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0 ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0-pre" } ckb-dao = { path = "../util/dao", version = "= 0.119.0-pre" } ckb-system-scripts = { version = "= 0.5.4" } -lazy_static = "1.3.0" ckb-crypto = { path = "../util/crypto", version = "= 0.119.0-pre" } ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0-pre" } ckb-verification = { path = "../verification", version = "= 0.119.0-pre" } diff --git a/benches/benches/benchmarks/util.rs b/benches/benches/benchmarks/util.rs index a9f64d0a50..e64401c975 100644 --- a/benches/benches/benchmarks/util.rs +++ b/benches/benches/benchmarks/util.rs @@ -23,7 +23,6 @@ use ckb_types::{ utilities::difficulty_to_compact, H160, H256, U256, }; -use lazy_static::lazy_static; use rand::random; use std::collections::HashSet; @@ -200,19 +199,19 @@ pub fn gen_always_success_block( const PRIVKEY: H256 = h256!("0xb2b3324cece882bca684eaf202667bb56ed8e8c2fd4b4dc71f615ebd6d9055a5"); const PUBKEY_HASH: H160 = h160!("0x779e5930892a0a9bf2fedfe048f685466c7d0396"); -lazy_static! { - static ref SECP_DATA_CELL: (CellOutput, Bytes) = { - let raw_data = BUNDLED_CELL - .get("specs/cells/secp256k1_data") - .expect("load secp256k1_blake160_sighash_all"); - let data: Bytes = raw_data.to_vec().into(); +static SECP_DATA_CELL: std::sync::LazyLock<(CellOutput, Bytes)> = std::sync::LazyLock::new(|| { + let raw_data = BUNDLED_CELL + .get("specs/cells/secp256k1_data") + .expect("load secp256k1_blake160_sighash_all"); + let data: Bytes = raw_data.to_vec().into(); - let cell = CellOutput::new_builder() - .capacity(Capacity::bytes(data.len()).unwrap().pack()) - .build(); - (cell, data) - }; - static ref SECP_CELL: (CellOutput, Bytes, Script) = { + let cell = CellOutput::new_builder() + .capacity(Capacity::bytes(data.len()).unwrap().pack()) + .build(); + (cell, data) +}); +static SECP_CELL: std::sync::LazyLock<(CellOutput, Bytes, Script)> = + std::sync::LazyLock::new(|| { let raw_data = BUNDLED_CELL .get("specs/cells/secp256k1_blake160_sighash_all") .expect("load secp256k1_blake160_sighash_all"); @@ -229,8 +228,7 @@ lazy_static! { .build(); (cell, data, script) - }; -} + }); pub fn secp_cell() -> &'static (CellOutput, Bytes, Script) { &SECP_CELL diff --git a/chain/Cargo.toml b/chain/Cargo.toml index ba04ed20b3..3218f54327 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -41,12 +41,15 @@ dashmap = "4.0" ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0-pre" } ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0-pre" } ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.119.0-pre" } -ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0-pre", features = ["internal"] } +ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0-pre", features = [ + "internal", +] } ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0-pre" } ckb-network = { path = "../network", version = "= 0.119.0-pre" } -lazy_static = "1.4" tempfile.workspace = true -ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre" ,features = ["enable_faketime"]} +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre", features = [ + "enable_faketime", +] } ckb-logger-service = { path = "../util/logger-service", version = "= 0.119.0-pre" } [features] diff --git a/chain/src/tests/block_assembler.rs b/chain/src/tests/block_assembler.rs index caf0eb84ca..6e8a71e516 100644 --- a/chain/src/tests/block_assembler.rs +++ b/chain/src/tests/block_assembler.rs @@ -19,7 +19,6 @@ use ckb_types::{ }; use ckb_verification::{BlockVerifier, HeaderVerifier}; use ckb_verification_traits::{Switch, Verifier}; -use lazy_static::lazy_static; use std::sync::Arc; fn start_chain(consensus: Option) -> (ChainController, Shared) { @@ -57,20 +56,6 @@ fn start_chain(consensus: Option) -> (ChainController, Shared) { (chain_controller, shared) } -lazy_static! { - static ref BASIC_BLOCK_SIZE: u64 = { - let (_chain_controller, shared) = start_chain(None); - - let block_template = shared - .get_block_template(None, None, None) - .unwrap() - .unwrap(); - - let block: Block = block_template.into(); - block.serialized_size_without_uncle_proposals() as u64 - }; -} - #[test] fn test_get_block_template() { let (_chain_controller, shared) = start_chain(None); diff --git a/ckb-bin/Cargo.toml b/ckb-bin/Cargo.toml index c6be0d57c7..b4087ae4cc 100644 --- a/ckb-bin/Cargo.toml +++ b/ckb-bin/Cargo.toml @@ -44,7 +44,7 @@ ckb-constant = { path = "../util/constant", version = "= 0.119.0-pre" } base64 = "0.21.0" tempfile.workspace = true rayon = "1.0" -sentry = { version = "0.26.0", optional = true } +sentry = { version = "0.34.0", optional = true } is-terminal = "0.4.7" fdlimit = "0.2.1" ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0-pre" } diff --git a/db-migration/Cargo.toml b/db-migration/Cargo.toml index 9e2d55a08d..facbfa1997 100644 --- a/db-migration/Cargo.toml +++ b/db-migration/Cargo.toml @@ -17,7 +17,6 @@ ckb-error = { path = "../error", version = "= 0.119.0-pre" } ckb-db-schema = { path = "../db-schema", version = "= 0.119.0-pre" } ckb-channel = { path = "../util/channel", version = "= 0.119.0-pre" } ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0-pre" } -once_cell = "1.8.0" indicatif = "0.16" console = ">=0.9.1, <1.0.0" diff --git a/db-migration/src/lib.rs b/db-migration/src/lib.rs index fa2ba321dc..d3aa913325 100644 --- a/db-migration/src/lib.rs +++ b/db-migration/src/lib.rs @@ -9,17 +9,17 @@ use ckb_logger::{debug, error, info}; use ckb_stop_handler::register_thread; use console::Term; pub use indicatif::{HumanDuration, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle}; -use once_cell::sync::OnceCell; use std::cmp::Ordering; use std::collections::BTreeMap; use std::collections::VecDeque; use std::sync::Arc; use std::sync::Mutex; +use std::sync::OnceLock; use std::thread; use std::thread::JoinHandle; /// Shutdown flag for background migration. -pub static SHUTDOWN_BACKGROUND_MIGRATION: OnceCell = OnceCell::new(); +pub static SHUTDOWN_BACKGROUND_MIGRATION: OnceLock = OnceLock::new(); #[cfg(test)] mod tests; diff --git a/error/Cargo.toml b/error/Cargo.toml index b9b90d8faa..03fb94d9a7 100644 --- a/error/Cargo.toml +++ b/error/Cargo.toml @@ -12,4 +12,6 @@ repository = "https://github.com/nervosnetwork/ckb" thiserror = "1.0.22" anyhow = "1.0.34" ckb-occupied-capacity = { path = "../util/occupied-capacity", version = "= 0.119.0-pre" } -derive_more = { version = "0.99.0", default-features = false, features = ["display"] } +derive_more = { version = "1", default-features = false, features = [ + "display", +] } diff --git a/error/src/lib.rs b/error/src/lib.rs index 2c2dfa575e..528c1ad513 100644 --- a/error/src/lib.rs +++ b/error/src/lib.rs @@ -89,7 +89,7 @@ impl fmt::Display for AnyError { impl fmt::Debug for AnyError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) + derive_more::Display::fmt(self, f) } } /// Return whether the error's kind is `InternalErrorKind::Database` diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 29e4fcbc77..dda397ed0b 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -20,8 +20,14 @@ rand_distr = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0-pre" } -hyper = { version = "0.14", features = ["client", "http2", "http1", "server"] } -hyper-tls = "0.5" +hyper = { version = "1", features = ["client", "http2", "http1", "server"] } +hyper-util = { version = "0.1", features = [ + "server-auto", + "server-graceful", + "client-legacy", +] } +http-body-util = "0.1" +hyper-tls = "0.6" futures = "0.3" lru = "0.7.1" ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0-pre" } diff --git a/miner/src/client.rs b/miner/src/client.rs index 1cea7e2ae0..e5f53360aa 100644 --- a/miner/src/client.rs +++ b/miner/src/client.rs @@ -11,11 +11,17 @@ use ckb_types::{ H256, }; use futures::prelude::*; +use http_body_util::{BodyExt, Empty, Full}; use hyper::{ - body::{to_bytes, Buf, Bytes}, + body::{Buf, Bytes}, header::{HeaderValue, CONTENT_TYPE}, - service::{make_service_fn, service_fn}, - Body, Client as HttpClient, Error as HyperError, Method, Request, Response, Server, Uri, + service::service_fn, + Error as HyperError, Request, Response, Uri, +}; +use hyper_util::{ + client::legacy::{Client as HttpClient, Error as ClientError}, + rt::TokioExecutor, + server::{conn::auto, graceful::GracefulShutdown}, }; use jsonrpc_core::{ error::Error as RpcFail, error::ErrorCode as RpcFailCode, id::Id, params::Params, @@ -23,18 +29,21 @@ use jsonrpc_core::{ }; use serde_json::error::Error as JsonError; use serde_json::{self, json, Value}; -use std::convert::Infallible; use std::net::SocketAddr; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; use std::{convert::Into, time}; -use tokio::sync::{mpsc, oneshot}; +use tokio::{ + net::TcpListener, + sync::{mpsc, oneshot}, +}; type RpcRequest = (oneshot::Sender>, MethodCall); #[derive(Debug)] pub enum RpcError { Http(HyperError), + Client(ClientError), Canceled, //oneshot canceled Json(JsonError), Fail(RpcFail), @@ -53,7 +62,7 @@ impl Rpc { let stop_rx: CancellationToken = new_tokio_exit_rx(); let https = hyper_tls::HttpsConnector::new(); - let client = HttpClient::builder().build(https); + let client = HttpClient::builder(TokioExecutor::new()).build::<_, Full>(https); let loop_handle = handle.clone(); handle.spawn(async move { loop { @@ -62,15 +71,14 @@ impl Rpc { let (sender, call): RpcRequest = item; let req_url = url.clone(); let request_json = serde_json::to_vec(&call).expect("valid rpc call"); - let mut req = Request::new(Body::from(request_json)); - *req.method_mut() = Method::POST; - *req.uri_mut() = req_url; - req.headers_mut() - .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); + + let mut req = Request::builder().uri(req_url).method("POST").header(CONTENT_TYPE, "application/json"); + if let Some(value) = parse_authorization(&url) { - req.headers_mut() - .append(hyper::header::AUTHORIZATION, value); + req = req + .header(hyper::header::AUTHORIZATION, value); } + let req = req.body(Full::new(Bytes::from(request_json))).unwrap(); let client = client.clone(); loop_handle.spawn(async move { let request = match client @@ -78,8 +86,8 @@ impl Rpc { .await .map(|res|res.into_body()) { - Ok(body) => to_bytes(body).await.map_err(RpcError::Http), - Err(err) => Err(RpcError::Http(err)), + Ok(body) => BodyExt::collect(body).await.map_err(RpcError::Http).map(|t| t.to_bytes()), + Err(err) => Err(RpcError::Client(err)), }; if sender.send(request).is_err() { error!("rpc response send back error") @@ -224,23 +232,42 @@ Otherwise ckb-miner will malfunction and stop submitting valid blocks after a ce } async fn listen_block_template_notify(&self, addr: SocketAddr) { - let client = self.clone(); - let make_service = make_service_fn(move |_conn| { - let client = client.clone(); - let service = service_fn(move |req| handle(client.clone(), req)); - async move { Ok::<_, Infallible>(service) } - }); - - let server = Server::bind(&addr).serve(make_service); + let listener = TcpListener::bind(addr).await.unwrap(); + let server = auto::Builder::new(TokioExecutor::new()); + let graceful = GracefulShutdown::new(); let stop_rx: CancellationToken = new_tokio_exit_rx(); - let graceful = server.with_graceful_shutdown(async move { - stop_rx.cancelled().await; - info!("Miner client received exit signal. Exit now"); - }); - if let Err(e) = graceful.await { - error!("server error: {}", e); + loop { + let client = self.clone(); + let handle = service_fn(move |req| handle(client.clone(), req)); + tokio::select! { + conn = listener.accept() => { + let (stream, _) = match conn { + Ok(conn) => conn, + Err(e) => { + info!("accept error: {}", e); + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + continue; + } + }; + let stream = hyper_util::rt::TokioIo::new(Box::pin(stream)); + let conn = server.serve_connection_with_upgrades(stream, handle); + + let conn = graceful.watch(conn.into_owned()); + tokio::spawn(async move { + if let Err(err) = conn.await { + info!("connection error: {}", err); + } + }); + }, + _ = stop_rx.cancelled() => { + info!("Miner client received exit signal. Exit now"); + break; + } + } } + drop(listener); + graceful.shutdown().await; } async fn poll_block_template(&self) { @@ -327,14 +354,17 @@ Otherwise ckb-miner will malfunction and stop submitting valid blocks after a ce type Error = Box; -async fn handle(client: Client, req: Request) -> Result, Error> { - let body = hyper::body::aggregate(req).await?; +async fn handle( + client: Client, + req: Request, +) -> Result>, Error> { + let body = BodyExt::collect(req).await?.aggregate(); if let Ok(template) = serde_json::from_reader(body.reader()) { client.update_block_template(template); } - Ok(Response::new(Body::empty())) + Ok(Response::new(Empty::new())) } async fn parse_response(output: Output) -> Result { diff --git a/network/Cargo.toml b/network/Cargo.toml index 8818bd3fd2..90cf548193 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -21,16 +21,15 @@ tokio = { version = "1", features = ["sync", "macros"] } tokio-util = { version = "0.7", features = ["codec"] } futures = "0.3" ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre" } -lazy_static = { version = "1.3.0", optional = true } -bs58 = { version = "0.4.0", optional = true } -sentry = { version = "0.26.0", optional = true } +bs58 = { version = "0.5.0", optional = true } +sentry = { version = "0.34.0", optional = true } faster-hex = { version = "0.6", optional = true } ckb-hash = { path = "../util/hash", version = "= 0.119.0-pre" } secp256k1 = { version = "0.29", features = ["recovery"], optional = true } -trust-dns-resolver = { version = "0.20", optional = true } +trust-dns-resolver = { version = "0.23", optional = true } snap = "1" ckb-types = { path = "../util/types", version = "= 0.119.0-pre" } -ipnetwork = "0.18" +ipnetwork = "0.20" serde_json = "1.0" bloom-filters = "0.1" ckb-spawn = { path = "../util/spawn", version = "= 0.119.0-pre" } @@ -45,13 +44,7 @@ p2p = { version = "0.6.1", package = "tentacle", features = [ [features] with_sentry = ["sentry"] -with_dns_seeding = [ - "lazy_static", - "bs58", - "faster-hex", - "trust-dns-resolver", - "secp256k1", -] +with_dns_seeding = ["bs58", "faster-hex", "trust-dns-resolver", "secp256k1"] fuzz = [] [dev-dependencies] @@ -59,7 +52,6 @@ tempfile.workspace = true criterion = "0.5" proptest = "1.0" num_cpus = "1.10" -once_cell = "1.8.0" ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre", features = [ "enable_faketime", ] } diff --git a/network/src/protocols/tests/mod.rs b/network/src/protocols/tests/mod.rs index d30eba3d20..663ebf1dad 100644 --- a/network/src/protocols/tests/mod.rs +++ b/network/src/protocols/tests/mod.rs @@ -230,8 +230,7 @@ fn net_service_start( let control = p2p_service.control().clone().into(); let (addr_sender, addr_receiver) = ::std::sync::mpsc::channel(); - static RT: once_cell::sync::OnceCell = - once_cell::sync::OnceCell::new(); + static RT: std::sync::OnceLock = std::sync::OnceLock::new(); let rt = RT.get_or_init(|| { let num_threads = ::std::cmp::max(num_cpus::get(), 4); diff --git a/network/src/services/dns_seeding/seed_record.rs b/network/src/services/dns_seeding/seed_record.rs index 80abd6e271..20ec1affcc 100644 --- a/network/src/services/dns_seeding/seed_record.rs +++ b/network/src/services/dns_seeding/seed_record.rs @@ -6,7 +6,6 @@ use std::{ }; use ckb_hash::blake2b_256; -use lazy_static::lazy_static; use p2p::{ multiaddr::{Multiaddr, Protocol}, secio::PeerId, @@ -17,10 +16,9 @@ use secp256k1::{ Message, PublicKey, }; -lazy_static! { - pub(crate) static ref SECP256K1: secp256k1::Secp256k1 = - secp256k1::Secp256k1::new(); -} +pub(crate) static SECP256K1: std::sync::LazyLock> = + std::sync::LazyLock::new(secp256k1::Secp256k1::new); + pub(crate) const SEP: char = ';'; // Format: diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 0249d1e746..7d1675b21e 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -53,7 +53,7 @@ ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0-pre" } # issue tracking: https://github.com/GREsau/schemars/pull/251 schemars = { version = "0.8.19", package = "ckb_schemars" } [dev-dependencies] -reqwest = { version = "=0.11.20", features = ["blocking", "json"] } +reqwest = { version = "0.12", features = ["blocking", "json"] } serde = { version = "1.0", features = ["derive"] } ckb-shared = { path = "../shared", version = "= 0.119.0-pre" } ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0-pre" } diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 58f96716c8..26698b6d50 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -29,7 +29,6 @@ ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre" } ckb-channel = { path = "../util/channel", version = "= 0.119.0-pre" } ckb-app-config = { path = "../util/app-config", version = "= 0.119.0-pre" } ckb-migrate = { path = "../util/migrate", version = "= 0.119.0-pre" } -once_cell = "1.8.0" ckb-util = { path = "../util", version = "= 0.119.0-pre" } ckb-metrics = { path = "../util/metrics", version = "= 0.119.0-pre" } bitflags = "1.0" @@ -39,9 +38,21 @@ sled = "0.34.7" dashmap = "4.0" [dev-dependencies] -ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre", features = ["enable_faketime"] } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre", features = [ + "enable_faketime", +] } [features] -portable = ["ckb-db/portable", "ckb-store/portable", "ckb-tx-pool/portable", "ckb-migrate/portable"] -march-native = ["ckb-db/march-native", "ckb-store/march-native", "ckb-tx-pool/march-native", "ckb-migrate/march-native"] +portable = [ + "ckb-db/portable", + "ckb-store/portable", + "ckb-tx-pool/portable", + "ckb-migrate/portable", +] +march-native = [ + "ckb-db/march-native", + "ckb-store/march-native", + "ckb-tx-pool/march-native", + "ckb-migrate/march-native", +] stats = [] diff --git a/shared/src/shared_builder.rs b/shared/src/shared_builder.rs index 444ef4fe9e..d5644cacb5 100644 --- a/shared/src/shared_builder.rs +++ b/shared/src/shared_builder.rs @@ -160,7 +160,6 @@ impl SharedBuilder { /// Generates the SharedBuilder with temp db /// NOTICE: this is only used in testing pub fn with_temp_db() -> Self { - use once_cell::{sync, unsync}; use std::{ borrow::Borrow, sync::atomic::{AtomicUsize, Ordering}, @@ -172,18 +171,17 @@ impl SharedBuilder { thread_local! { // NOTICE:we can't put the runtime directly into thread_local here, // on windows the runtime in thread_local will get stuck when dropping - static RUNTIME_HANDLE: unsync::OnceCell = const { unsync::OnceCell::new() }; + static RUNTIME_HANDLE: std::cell::OnceCell = const { std::cell::OnceCell::new() }; } static DB_COUNT: AtomicUsize = AtomicUsize::new(0); - static TMP_DIR: sync::OnceCell = sync::OnceCell::new(); + static TMP_DIR: std::sync::OnceLock = std::sync::OnceLock::new(); let db = { let db_id = DB_COUNT.fetch_add(1, Ordering::SeqCst); let db_base_dir = TMP_DIR .borrow() - .get_or_try_init(TempDir::new) - .unwrap() + .get_or_init(|| TempDir::new().unwrap()) .path() .to_path_buf(); let db_dir = db_base_dir.join(format!("db_{db_id}")); diff --git a/spec/Cargo.toml b/spec/Cargo.toml index d25714b549..157e9b140c 100644 --- a/spec/Cargo.toml +++ b/spec/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] serde = { version = "1.0", features = ["derive"] } toml = "0.5" -cacache = { version = "12.0.0", default-features = false, features = ["tokio-runtime", "mmap"] } +cacache = { version = "13.0.0", default-features = false, features = ["mmap"] } ckb-constant = { path = "../util/constant", version = "= 0.119.0-pre" } ckb-types = { path = "../util/types", version = "= 0.119.0-pre" } ckb-pow = { path = "../pow", version = "= 0.119.0-pre" } @@ -19,11 +19,11 @@ ckb-resource = { path = "../resource", version = "= 0.119.0-pre" } ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0-pre" } ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0-pre" } ckb-rational = { path = "../util/rational", version = "= 0.119.0-pre" } -ckb-crypto = { path = "../util/crypto", version = "= 0.119.0-pre"} -ckb-hash = { path = "../util/hash", version = "= 0.119.0-pre"} +ckb-crypto = { path = "../util/crypto", version = "= 0.119.0-pre" } +ckb-hash = { path = "../util/hash", version = "= 0.119.0-pre" } ckb-error = { path = "../error", version = "= 0.119.0-pre" } ckb-traits = { path = "../traits", version = "= 0.119.0-pre" } -ckb-logger = {path = "../util/logger", version = "= 0.119.0-pre"} +ckb-logger = { path = "../util/logger", version = "= 0.119.0-pre" } [dev-dependencies] diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 9aa237cfcb..7115dacd98 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -25,7 +25,7 @@ ckb-channel = { path = "../util/channel", version = "= 0.119.0-pre" } ckb-traits = { path = "../traits", version = "= 0.119.0-pre" } ckb-error = { path = "../error", version = "= 0.119.0-pre" } ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0-pre" } -sentry = { version = "0.26.0", optional = true } +sentry = { version = "0.34.0", optional = true } ckb-constant = { path = "../util/constant", version = "= 0.119.0-pre" } ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0-pre" } tokio = { version = "1", features = ["sync"] } @@ -48,7 +48,6 @@ ckb-chain = { path = "../chain", version = "= 0.119.0-pre", features = [ "mock", ] } faux = "^0.1" -once_cell = "1.8.0" ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre", features = [ "enable_faketime", ] } diff --git a/sync/src/tests/net_time_checker.rs b/sync/src/tests/net_time_checker.rs index 846e07d796..89d631d5ee 100644 --- a/sync/src/tests/net_time_checker.rs +++ b/sync/src/tests/net_time_checker.rs @@ -109,8 +109,7 @@ fn net_service_start() -> Node { let control = p2p_service.control().clone().into(); let (addr_sender, addr_receiver) = ::std::sync::mpsc::channel(); - static RT: once_cell::sync::OnceCell = - once_cell::sync::OnceCell::new(); + static RT: std::sync::OnceLock = std::sync::OnceLock::new(); let rt = RT.get_or_init(|| { tokio::runtime::Builder::new_multi_thread() diff --git a/test/Cargo.toml b/test/Cargo.toml index 3ea017891c..0e8cde775e 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -clap = { version = "=3.2.21" } +clap = { version = "4" } toml = "0.5.0" ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0-pre" } ckb-app-config = { path = "../util/app-config", version = "= 0.119.0-pre" } @@ -33,21 +33,20 @@ ckb-db = { path = "../db", version = "= 0.119.0-pre" } ckb-store = { path = "../store", version = "= 0.119.0-pre" } ckb-shared = { path = "../shared", version = "= 0.119.0-pre" } tempfile = "3" -reqwest = { version = "=0.11.20", features = ["blocking", "json"] } +reqwest = { version = "0.12", features = ["blocking", "json"] } rand = "0.8" ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre" } serde_json = "1.0" -lazy_static = "1.4.0" byteorder = "1.3.1" jsonrpc-core = "18.0" ctrlc = { version = "3.1", features = ["termination"] } log = "0.4" [target.'cfg(not(target_os="windows"))'.dependencies] -nix = { version = "0.24.0", default-features = false, features = ["signal"] } +nix = { version = "0.29.0", default-features = false, features = ["signal"] } [target.'cfg(target_os="windows")'.dependencies] -windows-sys = { version = "0.52", features = [ +windows-sys = { version = "0.59", features = [ "Win32_Foundation", "Win32_System_Threading", "Win32_Security", diff --git a/test/src/global.rs b/test/src/global.rs index ee453eb6c7..07619ac5dd 100644 --- a/test/src/global.rs +++ b/test/src/global.rs @@ -1,18 +1,17 @@ use ckb_util::Mutex; -use lazy_static::lazy_static; use std::path::PathBuf; use std::sync::atomic::AtomicU16; -lazy_static! { - pub static ref BINARY_PATH: Mutex = Mutex::new(PathBuf::new()); - pub static ref VENDOR_PATH: Mutex = { - let default = ::std::env::current_dir() - .expect("can't get current_dir") - .join("vendor"); - Mutex::new(default) - }; - pub static ref PORT_COUNTER: AtomicU16 = AtomicU16::new(9000); -} +pub static BINARY_PATH: std::sync::LazyLock> = + std::sync::LazyLock::new(|| Mutex::new(PathBuf::new())); +pub static VENDOR_PATH: std::sync::LazyLock> = std::sync::LazyLock::new(|| { + let default = ::std::env::current_dir() + .expect("can't get current_dir") + .join("vendor"); + Mutex::new(default) +}); +pub static PORT_COUNTER: std::sync::LazyLock = + std::sync::LazyLock::new(|| AtomicU16::new(9000)); pub fn binary() -> PathBuf { (*BINARY_PATH.lock()).clone() diff --git a/test/src/main.rs b/test/src/main.rs index 038b947452..d03e672e59 100644 --- a/test/src/main.rs +++ b/test/src/main.rs @@ -8,7 +8,7 @@ use ckb_test::{ }; use ckb_types::core::ScriptHashType; use ckb_util::Mutex; -use clap::{App, Arg}; +use clap::{Arg, Command}; use rand::{seq::SliceRandom, thread_rng}; use std::any::Any; use std::cmp::min; @@ -17,7 +17,6 @@ use std::env; use std::fs::{self, read_to_string, File}; use std::io::{self, BufRead, BufReader, Write}; use std::path::{Path, PathBuf}; -use std::str::FromStr; use std::sync::atomic::Ordering; use std::sync::Arc; use std::time::{Duration, Instant}; @@ -42,27 +41,24 @@ fn main() { let clap_app = clap_app(); let matches = clap_app.get_matches(); - let binary = matches.value_of_t_or_exit::("binary"); - let start_port = matches.value_of_t_or_exit::("port"); - let spec_names_to_run: Vec<_> = matches.values_of("specs").unwrap_or_default().collect(); - let max_time = if matches.is_present("max-time") { - matches.value_of_t_or_exit::("max-time") - } else { - 0 - }; - let worker_count = matches.value_of_t_or_exit::("concurrent"); + let binary = matches.get_one::("binary").cloned().unwrap(); + let start_port = matches.get_one::("port").cloned().unwrap(); + let spec_names_to_run: Vec<_> = matches + .get_many::("specs") + .unwrap_or_default() + .map(|v| v.as_str()) + .collect(); + let max_time = matches.get_one::("max-time").cloned().unwrap(); + let worker_count = matches.get_one::("concurrent").cloned().unwrap(); let vendor = matches - .value_of_t::("vendor") - .unwrap_or_else(|_| current_dir().join("vendor")); - let log_file_opt = matches - .value_of("log-file") - .map(PathBuf::from_str) - .transpose() - .unwrap_or_else(|err| panic!("failed to parse the log file path since {err}")); - let fail_fast = !matches.is_present("no-fail-fast"); - let report = !matches.is_present("no-report"); - let clean_tmp = !matches.is_present("keep-tmp-data"); - let verbose = matches.is_present("verbose"); + .get_one::("vendor") + .cloned() + .unwrap_or_else(|| current_dir().join("vendor")); + let log_file_opt = matches.get_one::("log-file").cloned(); + let fail_fast = !matches.get_flag("no-fail-fast"); + let report = !matches.get_flag("no-report"); + let clean_tmp = !matches.get_flag("keep-tmp-data"); + let verbose = matches.get_flag("verbose"); let logger_guard = { let filter = if !verbose { @@ -100,7 +96,7 @@ fn main() { .unwrap_or_else(|err| panic!("failed to init the logger service since {err}")) }; - if matches.is_present("list-specs") { + if matches.get_flag("list-specs") { list_specs(); return; } @@ -298,71 +294,83 @@ fn main() { drop(logger_guard); } -fn clap_app() -> App<'static> { - App::new("ckb-test") +fn clap_app() -> Command { + Command::new("ckb-test") .arg( - Arg::with_name("binary") + Arg::new("binary") .short('b') .long("bin") - .takes_value(true) - .value_name("PATH") + .action(clap::ArgAction::Set) + .value_parser(clap::value_parser!(PathBuf)) .help("Path to ckb executable") .default_value("../target/release/ckb"), ) .arg( - Arg::with_name("port") + Arg::new("port") .short('p') .long("port") - .takes_value(true) + .action(clap::ArgAction::Set) + .value_parser(clap::value_parser!(u16)) .help("Starting port number used to start ckb nodes") .default_value("9000"), ) .arg( - Arg::with_name("max-time") + Arg::new("max-time") .long("max-time") - .takes_value(true) - .value_name("SECONDS") - .help("Exit when total running time exceeds this limit"), + .action(clap::ArgAction::Set) + .value_parser(clap::value_parser!(u64)) + .help("Exit when total running time exceeds this limit") + .default_value("0"), ) .arg( - Arg::with_name("list-specs") + Arg::new("list-specs") .long("list-specs") + .action(clap::ArgAction::SetTrue) .help("list all specs"), ) - .arg(Arg::with_name("specs").multiple(true).help("Specs to run")) .arg( - Arg::with_name("concurrent") + Arg::new("specs") + .action(clap::ArgAction::Append) + .help("Specs to run"), + ) + .arg( + Arg::new("concurrent") .short('c') .long("concurrent") - .takes_value(true) + .action(clap::ArgAction::Set) + .value_parser(clap::value_parser!(usize)) .help("The number of specs can running concurrently") .default_value("4"), ) .arg( - Arg::with_name("verbose") + Arg::new("verbose") .long("verbose") + .action(clap::ArgAction::SetTrue) .help("Show verbose log"), ) .arg( - Arg::with_name("no-fail-fast") + Arg::new("no-fail-fast") .long("no-fail-fast") + .action(clap::ArgAction::SetTrue) .help("Run all tests regardless of failure"), ) .arg( - Arg::with_name("no-report") + Arg::new("no-report") .long("no-report") + .action(clap::ArgAction::SetTrue) .help("Do not show integration test report"), ) .arg( - Arg::with_name("log-file") + Arg::new("log-file") .long("log-file") - .takes_value(true) + .action(clap::ArgAction::Set) + .value_parser(clap::value_parser!(PathBuf)) .help("Write log outputs into file."), ) - .arg(Arg::with_name("keep-tmp-data").long("keep-tmp-data").help( + .arg(Arg::new("keep-tmp-data").long("keep-tmp-data").action(clap::ArgAction::SetTrue).help( "Keep all temporary files. Default: only keep temporary file for the failed tests.", )) - .arg(Arg::with_name("vendor").long("vendor")) + .arg(Arg::new("vendor").long("vendor").action(clap::ArgAction::SetTrue).value_parser(clap::value_parser!(PathBuf))) } fn filter_specs( diff --git a/test/src/rpc.rs b/test/src/rpc.rs index bb4b9a81dc..0cafcbe572 100644 --- a/test/src/rpc.rs +++ b/test/src/rpc.rs @@ -16,14 +16,14 @@ use ckb_types::core::{ Version as CoreVersion, }; use ckb_types::{packed::Byte32, prelude::*, H256}; -use lazy_static::lazy_static; -lazy_static! { - pub static ref HTTP_CLIENT: reqwest::blocking::Client = reqwest::blocking::Client::builder() - .timeout(::std::time::Duration::from_secs(30)) - .build() - .expect("reqwest Client build"); -} +pub static HTTP_CLIENT: std::sync::LazyLock = + std::sync::LazyLock::new(|| { + reqwest::blocking::Client::builder() + .timeout(::std::time::Duration::from_secs(30)) + .build() + .expect("reqwest Client build") + }); pub struct RpcClient { inner: Inner, diff --git a/tx-pool/Cargo.toml b/tx-pool/Cargo.toml index 79e459a362..cc42e7b52f 100644 --- a/tx-pool/Cargo.toml +++ b/tx-pool/Cargo.toml @@ -25,7 +25,7 @@ ckb-util = { path = "../util", version = "= 0.119.0-pre" } ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0-pre" } ckb-chain-spec = { path = "../spec", version = "= 0.119.0-pre" } ckb-snapshot = { path = "../util/snapshot", version = "= 0.119.0-pre" } -ckb-metrics = {path = "../util/metrics", version = "= 0.119.0-pre"} +ckb-metrics = { path = "../util/metrics", version = "= 0.119.0-pre" } ckb-error = { path = "../error", version = "= 0.119.0-pre" } tokio = { version = "1", features = ["sync", "process"] } ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0-pre" } @@ -36,10 +36,12 @@ ckb-channel = { path = "../util/channel", version = "= 0.119.0-pre" } ckb-traits = { path = "../traits", version = "= 0.119.0-pre" } ckb-db = { path = "../db", version = "= 0.119.0-pre" } ckb-script = { path = "../script", version = "= 0.119.0-pre" } -sentry = { version = "0.26.0", optional = true } +sentry = { version = "0.34.0", optional = true } serde_json = "1.0" rand = "0.8.4" -hyper = { version = "0.14", features = ["http1", "client", "tcp"] } +hyper = { version = "1", features = ["http1", "http2", "client"] } +hyper-util = { version = "0.1", features = ["client-legacy", "http1", "http2"] } +http-body-util = "0.1" multi_index_map = "0.6.0" slab = "0.4" rustc-hash = "1.1" @@ -48,11 +50,17 @@ tokio-util = "0.7.8" [dev-dependencies] tempfile.workspace = true ckb-hash = { path = "../util/hash", version = "= 0.119.0-pre" } -ckb-systemtime = {path = "../util/systemtime", version = "= 0.119.0-pre", features = ["enable_faketime"]} +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre", features = [ + "enable_faketime", +] } [features] default = [] internal = [] with_sentry = ["sentry"] portable = ["ckb-db/portable", "ckb-store/portable", "ckb-snapshot/portable"] -march-native = ["ckb-db/march-native", "ckb-store/march-native", "ckb-snapshot/march-native"] +march-native = [ + "ckb-db/march-native", + "ckb-store/march-native", + "ckb-snapshot/march-native", +] diff --git a/tx-pool/src/block_assembler/mod.rs b/tx-pool/src/block_assembler/mod.rs index 81acca0951..dc6e0a1e93 100644 --- a/tx-pool/src/block_assembler/mod.rs +++ b/tx-pool/src/block_assembler/mod.rs @@ -21,6 +21,7 @@ use ckb_snapshot::Snapshot; use ckb_store::ChainStore; use ckb_systemtime::unix_time_as_millis; use ckb_types::{ + bytes, core::{ cell::{OverlayCellChecker, TransactionsChecker}, BlockNumber, Capacity, Cycle, EpochExt, EpochNumberWithFraction, ScriptHashType, @@ -32,7 +33,9 @@ use ckb_types::{ }, prelude::*, }; -use hyper::{client::HttpConnector, Body, Client, Method, Request}; +use http_body_util::Full; +use hyper::{Method, Request}; +use hyper_util::client::legacy::{connect::HttpConnector, Client}; use std::collections::HashSet; use std::sync::{ atomic::{AtomicU64, Ordering}, @@ -99,7 +102,7 @@ pub struct BlockAssembler { pub(crate) work_id: Arc, pub(crate) candidate_uncles: Arc>, pub(crate) current: Arc>, - pub(crate) poster: Arc>, + pub(crate) poster: Arc>>, } impl BlockAssembler { @@ -158,7 +161,10 @@ impl BlockAssembler { work_id: Arc::new(work_id), candidate_uncles: Arc::new(Mutex::new(CandidateUncles::new())), current: Arc::new(Mutex::new(current)), - poster: Arc::new(Client::new()), + poster: Arc::new( + Client::builder(hyper_util::rt::TokioExecutor::new()) + .build::<_, Full>(HttpConnector::new()), + ), } } @@ -646,7 +652,7 @@ impl BlockAssembler { .method(Method::POST) .uri(url.as_ref()) .header("content-type", "application/json") - .body(Body::from(template_json.to_owned())) + .body(Full::new(template_json.to_owned().into())) { let client = Arc::clone(&self.poster); let url = url.to_owned(); diff --git a/util/Cargo.toml b/util/Cargo.toml index ca722018ec..74174a25b7 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -10,9 +10,8 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] parking_lot = "0.12" -linked-hash-map = { version = "0.5", features = ["serde_impl"] } +linked-hash-map = { version = "0.5", features = ["serde_impl"] } regex = "1.1.6" -once_cell = "1.8.0" [dev-dependencies] ckb-fixed-hash = { path = "fixed-hash", version = "= 0.119.0-pre" } diff --git a/util/app-config/Cargo.toml b/util/app-config/Cargo.toml index bf57c112eb..dd77fec8a3 100644 --- a/util/app-config/Cargo.toml +++ b/util/app-config/Cargo.toml @@ -25,7 +25,7 @@ ckb-types = { path = "../types", version = "= 0.119.0-pre" } secio = { version = "0.6", package = "tentacle-secio" } multiaddr = { version = "0.3.0", package = "tentacle-multiaddr" } rand = "0.8" -sentry = { version = "0.26.0", optional = true } +sentry = { version = "0.34.0", optional = true } ckb-systemtime = { path = "../systemtime", version = "= 0.119.0-pre" } url = { version = "2.2.2", features = ["serde"] } ubyte = { version = "0.10", features = ["serde"] } diff --git a/util/crypto/Cargo.toml b/util/crypto/Cargo.toml index e843e635c3..17b010eab8 100644 --- a/util/crypto/Cargo.toml +++ b/util/crypto/Cargo.toml @@ -10,7 +10,6 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.119.0-pre" } -lazy_static = "1.3" secp256k1 = { version = "0.29", features = ["recovery"], optional = true } thiserror = "1.0.22" rand = { version = "0.8", features = ["small_rng"] } diff --git a/util/crypto/src/secp/mod.rs b/util/crypto/src/secp/mod.rs index 32ff3effbf..3ce6a62450 100644 --- a/util/crypto/src/secp/mod.rs +++ b/util/crypto/src/secp/mod.rs @@ -1,15 +1,13 @@ //! `secp256k1` wrapper use ckb_fixed_hash::H256; -use lazy_static::lazy_static; /// A (hashed) message input to an ECDSA signature pub type Message = H256; -lazy_static! { - /// The reference to lazily-initialized static secp256k1 engine, used to execute all signature operations - pub static ref SECP256K1: secp256k1::Secp256k1 = secp256k1::Secp256k1::new(); -} +/// The reference to lazily-initialized static secp256k1 engine, used to execute all signature operations +pub static SECP256K1: std::sync::LazyLock> = + std::sync::LazyLock::new(secp256k1::Secp256k1::new); mod error; mod generator; diff --git a/util/jsonrpc-types/Cargo.toml b/util/jsonrpc-types/Cargo.toml index 279bcc7382..04afdc6945 100644 --- a/util/jsonrpc-types/Cargo.toml +++ b/util/jsonrpc-types/Cargo.toml @@ -19,4 +19,3 @@ schemars = { version = "0.8.19", package = "ckb_schemars" } [dev-dependencies] proptest = "1.0" regex = "1.1" -lazy_static = "1.3" diff --git a/util/jsonrpc-types/src/tests/blockchain.rs b/util/jsonrpc-types/src/tests/blockchain.rs index a82be1a06b..38d1294c82 100644 --- a/util/jsonrpc-types/src/tests/blockchain.rs +++ b/util/jsonrpc-types/src/tests/blockchain.rs @@ -1,5 +1,4 @@ use ckb_types::{bytes::Bytes, core, h256, packed, prelude::*}; -use lazy_static::lazy_static; use proptest::{collection::size_range, prelude::*}; use regex::Regex; @@ -160,9 +159,10 @@ fn _test_block_convert(data: Bytes, arg: Bytes) -> Result<(), TestCaseError> { } fn header_field_format_check(json: &str) { - lazy_static! { - static ref RE: Regex = Regex::new("\"(version|compact_target|parent_hash|timestamp|number|epoch|transactions_root|proposals_hash|extra_hash|dao|nonce)\":\"(?P.*?\")").unwrap(); - } + static RE: std::sync::LazyLock = std::sync::LazyLock::new(|| { + Regex::new("\"(version|compact_target|parent_hash|timestamp|number|epoch|transactions_root|proposals_hash|extra_hash|dao|nonce)\":\"(?P.*?\")").unwrap() + }); + for caps in RE.captures_iter(json) { assert!(&caps["value"].starts_with("0x")); } diff --git a/util/logger-service/Cargo.toml b/util/logger-service/Cargo.toml index 1dae10143f..e18715b940 100644 --- a/util/logger-service/Cargo.toml +++ b/util/logger-service/Cargo.toml @@ -15,10 +15,9 @@ ckb-channel = { path = "../channel", version = "= 0.119.0-pre" } yansi = "0.5" log = "0.4" env_logger = "0.10" -once_cell = "1.8.0" regex = "1.1.6" backtrace = "0.3" -sentry = { version = "0.26.0", optional = true, features = ["log"] } +sentry = { version = "0.34.0", optional = true, features = ["log"] } time = { version = "0.3.36", features = ["formatting"] } [dev-dependencies] diff --git a/util/logger-service/src/lib.rs b/util/logger-service/src/lib.rs index 37c7eb2684..f4b7765405 100644 --- a/util/logger-service/src/lib.rs +++ b/util/logger-service/src/lib.rs @@ -4,11 +4,11 @@ use backtrace::Backtrace; use ckb_channel::{self, unbounded}; use env_logger::filter::{Builder, Filter}; use log::{LevelFilter, Log, Metadata, Record, SetLoggerError}; -use once_cell::sync::OnceCell; use regex::Regex; use std::collections::HashMap; use std::io::Write; use std::path::{Path, PathBuf}; +use std::sync::OnceLock; use std::{fs, panic, process, sync, thread}; use time::{ format_description::{self, FormatItem}, @@ -22,9 +22,9 @@ use yansi::Paint; #[cfg(test)] mod tests; -static CONTROL_HANDLE: OnceCell> = OnceCell::new(); -static FORMAT: OnceCell>> = OnceCell::new(); -static RE: OnceCell = OnceCell::new(); +static CONTROL_HANDLE: OnceLock> = OnceLock::new(); +static FORMAT: OnceLock>> = OnceLock::new(); +static RE: OnceLock = OnceLock::new(); enum Message { Record { diff --git a/util/memory-tracker/Cargo.toml b/util/memory-tracker/Cargo.toml index 10e1739b0d..8c787a8d2b 100644 --- a/util/memory-tracker/Cargo.toml +++ b/util/memory-tracker/Cargo.toml @@ -17,7 +17,6 @@ ckb-db = { path = "../../db", version = "= 0.119.0-pre" } jemalloc-ctl = { package = "tikv-jemalloc-ctl", version = "0.5.0" } jemalloc-sys = { package = "tikv-jemalloc-sys", version = "0.5.0" } libc = "0.2" -once_cell = "1.8.0" [features] default = [] diff --git a/util/memory-tracker/src/process.rs b/util/memory-tracker/src/process.rs index 0a3ad8d392..8ea2be1a26 100644 --- a/util/memory-tracker/src/process.rs +++ b/util/memory-tracker/src/process.rs @@ -122,7 +122,7 @@ pub struct Memory { impl FromStr for Memory { type Err = io::Error; fn from_str(value: &str) -> Result { - static PAGE_SIZE: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); + static PAGE_SIZE: std::sync::OnceLock = std::sync::OnceLock::new(); let page_size = PAGE_SIZE.get_or_init(|| unsafe { libc::sysconf(libc::_SC_PAGESIZE) as u64 }); let mut parts = value.split_ascii_whitespace(); @@ -179,7 +179,7 @@ impl FromStr for Memory { } fn get_current_process_memory() -> Result { - static PID: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); + static PID: std::sync::OnceLock = std::sync::OnceLock::new(); let pid = PID.get_or_init(|| unsafe { libc::getpid() }); let content = fs::read_to_string(format!("/proc/{pid}/statm"))?; diff --git a/util/metrics-service/Cargo.toml b/util/metrics-service/Cargo.toml index 5401df511a..aa12084c7c 100644 --- a/util/metrics-service/Cargo.toml +++ b/util/metrics-service/Cargo.toml @@ -15,5 +15,8 @@ ckb-logger = { path = "../logger", version = "= 0.119.0-pre" } ckb-async-runtime = { path = "../runtime", version = "= 0.119.0-pre" } ckb-util = { path = "..", version = "= 0.119.0-pre" } prometheus = "0.13.3" -hyper = { version = "0.14", features = ["http1", "tcp", "server"] } +hyper = { version = "1", features = ["http1", "http2", "server"] } +http-body-util = "0.1" +hyper-util = { version = "0.1", features = ["server-auto", "server-graceful"] } ckb-stop-handler = { path = "../stop-handler", version = "= 0.119.0-pre" } +tokio = { version = "1", features = ["sync"] } diff --git a/util/metrics-service/src/lib.rs b/util/metrics-service/src/lib.rs index c997671c7a..ca6e4505db 100644 --- a/util/metrics-service/src/lib.rs +++ b/util/metrics-service/src/lib.rs @@ -1,13 +1,18 @@ //! The service which handles the metrics data in CKB. -use std::{convert::Infallible, net::SocketAddr}; +use std::net::SocketAddr; +use http_body_util::Full; use hyper::{ - header::CONTENT_TYPE, - service::{make_service_fn, service_fn}, - Body, Error as HyperError, Method, Request, Response, Server, + body::Bytes, header::CONTENT_TYPE, service::service_fn, Error as HyperError, Method, Request, + Response, +}; +use hyper_util::{ + rt::TokioExecutor, + server::{conn::auto, graceful::GracefulShutdown}, }; use prometheus::Encoder as _; +use tokio::net::TcpListener; use ckb_async_runtime::Handle; use ckb_logger::info; @@ -56,28 +61,51 @@ fn run_exporter(exporter: Exporter, handle: &Handle) -> Result<(), String> { let addr = listen_address .parse::() .map_err(|err| format!("failed to parse listen_address because {err}"))?; - let make_svc = make_service_fn(move |_conn| async move { - Ok::<_, Infallible>(service_fn(start_prometheus_service)) - }); + let make_svc = service_fn(start_prometheus_service); ckb_logger::info!("Start prometheus exporter at {}", addr); handle.spawn(async move { - let server = Server::bind(&addr) - .serve(make_svc) - .with_graceful_shutdown(async { - let exit_rx: CancellationToken = new_tokio_exit_rx(); - exit_rx.cancelled().await; - info!("Prometheus server received exit signal; exit now"); - }); - if let Err(err) = server.await { - ckb_logger::error!("prometheus server error: {}", err); + let listener = TcpListener::bind(&addr).await.unwrap(); + let server = auto::Builder::new(TokioExecutor::new()); + let graceful = GracefulShutdown::new(); + let stop_rx: CancellationToken = new_tokio_exit_rx(); + loop { + tokio::select! { + conn = listener.accept() => { + let (stream, _) = match conn { + Ok(conn) => conn, + Err(e) => { + eprintln!("accept error: {}", e); + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + continue; + } + }; + let stream = hyper_util::rt::TokioIo::new(Box::pin(stream)); + let conn = server.serve_connection_with_upgrades(stream, make_svc); + + let conn = graceful.watch(conn.into_owned()); + tokio::spawn(async move { + if let Err(err) = conn.await { + info!("connection error: {}", err); + } + }); + }, + _ = stop_rx.cancelled() => { + info!("Prometheus server received exit signal; exit now"); + break; + } + } } + drop(listener); + graceful.shutdown().await; }); } } Ok(()) } -async fn start_prometheus_service(req: Request) -> Result, HyperError> { +async fn start_prometheus_service( + req: Request, +) -> Result>, HyperError> { Ok(match (req.method(), req.uri().path()) { (&Method::GET, "/") => { let mut buffer = vec![]; @@ -87,11 +115,11 @@ async fn start_prometheus_service(req: Request) -> Result, Response::builder() .status(200) .header(CONTENT_TYPE, encoder.format_type()) - .body(Body::from(buffer)) + .body(Full::new(Bytes::from(buffer))) } _ => Response::builder() .status(404) - .body(Body::from("Page Not Found")), + .body(Full::from("Page Not Found")), } .unwrap()) } diff --git a/util/metrics/Cargo.toml b/util/metrics/Cargo.toml index c74de3d3f3..1f5431300f 100644 --- a/util/metrics/Cargo.toml +++ b/util/metrics/Cargo.toml @@ -11,4 +11,3 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] prometheus = "0.13.3" prometheus-static-metric = "0.5.1" -once_cell = "1.17.1" diff --git a/util/metrics/src/lib.rs b/util/metrics/src/lib.rs index 41b9d7d895..6ea701f0e4 100644 --- a/util/metrics/src/lib.rs +++ b/util/metrics/src/lib.rs @@ -126,7 +126,7 @@ pub struct Metrics { pub ckb_inflight_timeout_count: IntCounter, } -static METRICS: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { +static METRICS: std::sync::LazyLock = std::sync::LazyLock::new(|| { Metrics { ckb_chain_tip: register_int_gauge!("ckb_chain_tip", "The CKB chain tip header number").unwrap(), ckb_chain_unverified_tip: register_int_gauge!( @@ -314,8 +314,7 @@ static METRICS: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { /// Indicate whether the metrics service is enabled. /// This value will set by ckb-metrics-service -pub static METRICS_SERVICE_ENABLED: once_cell::sync::OnceCell = - once_cell::sync::OnceCell::new(); +pub static METRICS_SERVICE_ENABLED: std::sync::OnceLock = std::sync::OnceLock::new(); thread_local! { static ENABLE_COLLECT_METRICS: Cell>= Cell::default(); diff --git a/util/network-alert/Cargo.toml b/util/network-alert/Cargo.toml index e39cd7272f..0a703190b1 100644 --- a/util/network-alert/Cargo.toml +++ b/util/network-alert/Cargo.toml @@ -13,9 +13,9 @@ ckb-multisig = { path = "../multisig", version = "= 0.119.0-pre" } ckb-types = { path = "../types", version = "= 0.119.0-pre" } ckb-util = { path = "..", version = "= 0.119.0-pre" } ckb-network = { path = "../../network", version = "= 0.119.0-pre" } -ckb-notify = { path = "../../notify", version = "= 0.119.0-pre"} +ckb-notify = { path = "../../notify", version = "= 0.119.0-pre" } ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0-pre" } -ckb-logger = { path = "../logger", version = "= 0.119.0-pre"} +ckb-logger = { path = "../logger", version = "= 0.119.0-pre" } ckb-app-config = { path = "../app-config", version = "= 0.119.0-pre" } ckb-error = { path = "../../error", version = "= 0.119.0-pre" } ckb-systemtime = { path = "../systemtime", version = "= 0.119.0-pre" } @@ -25,7 +25,8 @@ semver = "1.0" [dev-dependencies] ckb-crypto = { path = "../crypto", version = "= 0.119.0-pre" } ckb-async-runtime = { path = "../runtime", version = "= 0.119.0-pre" } -once_cell = "1.8.0" -ckb-systemtime = {path = "../systemtime", version = "= 0.119.0-pre", features = ["enable_faketime"]} +ckb-systemtime = { path = "../systemtime", version = "= 0.119.0-pre", features = [ + "enable_faketime", +] } faster-hex = "0.6" serde_json = "1.0" diff --git a/util/network-alert/src/tests/test_notifier.rs b/util/network-alert/src/tests/test_notifier.rs index 2145eb6d07..eb8b906537 100644 --- a/util/network-alert/src/tests/test_notifier.rs +++ b/util/network-alert/src/tests/test_notifier.rs @@ -3,7 +3,6 @@ use ckb_async_runtime::{new_background_runtime, Handle}; use ckb_notify::NotifyService; use ckb_types::{packed, prelude::*}; -use once_cell::unsync; fn build_alert( id: u32, @@ -26,7 +25,7 @@ fn new_notifier(version: &str) -> Notifier { thread_local! { // NOTICE:we can't put the runtime directly into thread_local here, // on windows the runtime in thread_local will get stuck when dropping - static RUNTIME_HANDLE: unsync::OnceCell = const { unsync::OnceCell::new() }; + static RUNTIME_HANDLE: std::cell::OnceCell = const { std::cell::OnceCell::new() }; } let notify_controller = RUNTIME_HANDLE.with(|runtime| { diff --git a/util/rich-indexer/Cargo.toml b/util/rich-indexer/Cargo.toml index 093008b0fd..b3de5e7bd9 100644 --- a/util/rich-indexer/Cargo.toml +++ b/util/rich-indexer/Cargo.toml @@ -21,7 +21,6 @@ ckb-types = { path = "../types", version = "= 0.119.0-pre" } futures = "0.3" log = "0.4" num-bigint = "0.4" -once_cell = "1.8.0" sql-builder = "3.1" sqlx = { version = "0.8.2", features = [ "runtime-tokio-rustls", diff --git a/util/rich-indexer/src/store.rs b/util/rich-indexer/src/store.rs index 2860005292..f4decd8d99 100644 --- a/util/rich-indexer/src/store.rs +++ b/util/rich-indexer/src/store.rs @@ -3,13 +3,13 @@ use ckb_app_config::{DBDriver, RichIndexerConfig}; use futures::TryStreamExt; use include_dir::{include_dir, Dir}; use log::LevelFilter; -use once_cell::sync::OnceCell; use sqlx::{ any::{Any, AnyArguments, AnyConnectOptions, AnyPoolOptions, AnyRow}, migrate::Migrator, query::{Query, QueryAs}, AnyPool, ConnectOptions, IntoArguments, Row, Transaction, }; +use std::sync::OnceLock; use tempfile::tempdir; use std::fs::{self, OpenOptions}; @@ -27,7 +27,7 @@ static MIGRATIONS_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/resources/mig #[derive(Clone, Default)] pub struct SQLXPool { - pool: Arc>, + pool: Arc>, pub(crate) db_driver: DBDriver, } diff --git a/util/src/strings.rs b/util/src/strings.rs index 9d8b67af58..9fe79a64a8 100644 --- a/util/src/strings.rs +++ b/util/src/strings.rs @@ -18,7 +18,7 @@ use regex::Regex; /// ``` pub fn check_if_identifier_is_valid(ident: &str) -> Result<(), String> { const IDENT_PATTERN: &str = r#"^[0-9a-zA-Z_-]+$"#; - static RE: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); + static RE: std::sync::OnceLock = std::sync::OnceLock::new(); // IDENT_PATTERN is a correct regular expression, so unwrap here let re = RE.get_or_init(|| Regex::new(IDENT_PATTERN).unwrap()); diff --git a/util/stop-handler/Cargo.toml b/util/stop-handler/Cargo.toml index 6d8e34936b..60d24bd9a3 100644 --- a/util/stop-handler/Cargo.toml +++ b/util/stop-handler/Cargo.toml @@ -13,7 +13,6 @@ ckb-logger = { path = "../logger", version = "= 0.119.0-pre" } tokio = { version = "1", features = ["sync", "rt-multi-thread"] } ckb-channel = { path = "../channel", version = "= 0.119.0-pre" } ckb-util = { path = "..", version = "= 0.119.0-pre" } -once_cell = "1.8.0" ckb-async-runtime = { path = "../runtime", version = "= 0.119.0-pre" } tokio-util = "0.7.8" diff --git a/util/stop-handler/src/stop_register.rs b/util/stop-handler/src/stop_register.rs index 73b3efbe1d..d522a12e59 100644 --- a/util/stop-handler/src/stop_register.rs +++ b/util/stop-handler/src/stop_register.rs @@ -28,21 +28,21 @@ pub fn wait_all_ckb_services_exit() { info!("All ckb threads have been stopped"); } -static CKB_HANDLES: once_cell::sync::Lazy> = - once_cell::sync::Lazy::new(|| { +static CKB_HANDLES: std::sync::LazyLock> = + std::sync::LazyLock::new(|| { Mutex::new(CkbServiceHandles { thread_handles: vec![], }) }); -static RECEIVED_STOP_SIGNAL: once_cell::sync::Lazy = - once_cell::sync::Lazy::new(AtomicBool::default); +static RECEIVED_STOP_SIGNAL: std::sync::LazyLock = + std::sync::LazyLock::new(AtomicBool::default); -static TOKIO_EXIT: once_cell::sync::Lazy = - once_cell::sync::Lazy::new(CancellationToken::new); +static TOKIO_EXIT: std::sync::LazyLock = + std::sync::LazyLock::new(CancellationToken::new); -static CROSSBEAM_EXIT_SENDERS: once_cell::sync::Lazy>>> = - once_cell::sync::Lazy::new(|| Mutex::new(vec![])); +static CROSSBEAM_EXIT_SENDERS: std::sync::LazyLock>>> = + std::sync::LazyLock::new(|| Mutex::new(vec![])); /// Create a new CancellationToken for exit signal pub fn new_tokio_exit_rx() -> CancellationToken { diff --git a/util/test-chain-utils/Cargo.toml b/util/test-chain-utils/Cargo.toml index 5a53719275..558e8674ef 100644 --- a/util/test-chain-utils/Cargo.toml +++ b/util/test-chain-utils/Cargo.toml @@ -9,14 +9,13 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = {path = "../types", version = "= 0.119.0-pre"} +ckb-types = { path = "../types", version = "= 0.119.0-pre" } ckb-db = { path = "../../db", version = "= 0.119.0-pre" } ckb-store = { path = "../../store", version = "= 0.119.0-pre" } ckb-chain-spec = { path = "../../spec", version = "= 0.119.0-pre" } ckb-dao-utils = { path = "../dao/utils", version = "= 0.119.0-pre" } ckb-dao = { path = "../dao", version = "= 0.119.0-pre" } ckb-traits = { path = "../../traits", version = "= 0.119.0-pre" } -lazy_static = "1.3.0" ckb-systemtime = { path = "../systemtime", version = "= 0.119.0-pre" } ckb-resource = { path = "../../resource", version = "= 0.119.0-pre" } ckb-db-schema = { path = "../../db-schema", version = "= 0.119.0-pre" } @@ -24,4 +23,6 @@ ckb-util = { path = "..", version = "= 0.119.0-pre" } tempfile.workspace = true [dev-dependencies] -ckb-systemtime = { path = "../systemtime", version = "= 0.119.0-pre", features = ["enable_faketime"] } +ckb-systemtime = { path = "../systemtime", version = "= 0.119.0-pre", features = [ + "enable_faketime", +] } diff --git a/util/test-chain-utils/src/chain.rs b/util/test-chain-utils/src/chain.rs index 7669089979..7535ea7de4 100644 --- a/util/test-chain-utils/src/chain.rs +++ b/util/test-chain-utils/src/chain.rs @@ -16,7 +16,6 @@ use ckb_types::{ utilities::difficulty_to_compact, H256, U256, }; -use lazy_static::lazy_static; use std::fs::File; use std::io::Read; use std::path::Path; @@ -39,10 +38,8 @@ fn load_cell_from_path(path: &str) -> (CellOutput, Bytes, Script) { (cell, data, script) } -lazy_static! { - static ref SUCCESS_CELL: (CellOutput, Bytes, Script) = - load_cell_from_path("../../script/testdata/always_success"); -} +static SUCCESS_CELL: std::sync::LazyLock<(CellOutput, Bytes, Script)> = + std::sync::LazyLock::new(|| load_cell_from_path("../../script/testdata/always_success")); // #include "ckb_syscalls.h" @@ -60,10 +57,8 @@ lazy_static! { // return 0; // } -lazy_static! { - static ref LOAD_INPUT_DATA_HASH: (CellOutput, Bytes, Script) = - load_cell_from_path("vendor/load_input_data_hash"); -} +static LOAD_INPUT_DATA_HASH: std::sync::LazyLock<(CellOutput, Bytes, Script)> = + std::sync::LazyLock::new(|| load_cell_from_path("vendor/load_input_data_hash")); /// Script for loading input data hash from input data. #[doc(hidden)] @@ -86,10 +81,8 @@ pub fn load_input_data_hash_cell() -> &'static (CellOutput, Bytes, Script) { // return 0; // } -lazy_static! { - static ref LOAD_INPUT_ONE_BYTE: (CellOutput, Bytes, Script) = - load_cell_from_path("vendor/load_input_one_byte"); -} +static LOAD_INPUT_ONE_BYTE: std::sync::LazyLock<(CellOutput, Bytes, Script)> = + std::sync::LazyLock::new(|| load_cell_from_path("vendor/load_input_one_byte")); /// Script for loading one byte from input data. #[doc(hidden)] @@ -103,10 +96,8 @@ pub fn always_success_cell() -> &'static (CellOutput, Bytes, Script) { &SUCCESS_CELL } -lazy_static! { - static ref IS_EVEN_LIB: (CellOutput, Bytes, Script) = - load_cell_from_path("../../script/testdata/is_even.lib"); -} +static IS_EVEN_LIB: std::sync::LazyLock<(CellOutput, Bytes, Script)> = + std::sync::LazyLock::new(|| load_cell_from_path("../../script/testdata/is_even.lib")); #[doc(hidden)] pub fn is_even_lib() -> &'static (CellOutput, Bytes, Script) { @@ -114,10 +105,8 @@ pub fn is_even_lib() -> &'static (CellOutput, Bytes, Script) { } // from script/testdata without ty_pause -lazy_static! { - static ref LOAD_IS_EVEN: (CellOutput, Bytes, Script) = - load_cell_from_path("vendor/load_is_even_with_snapshot"); -} +static LOAD_IS_EVEN: std::sync::LazyLock<(CellOutput, Bytes, Script)> = + std::sync::LazyLock::new(|| load_cell_from_path("vendor/load_is_even_with_snapshot")); #[doc(hidden)] pub fn load_is_even() -> &'static (CellOutput, Bytes, Script) { diff --git a/util/types/Cargo.toml b/util/types/Cargo.toml index f73489ec43..d73cdb39a1 100644 --- a/util/types/Cargo.toml +++ b/util/types/Cargo.toml @@ -26,8 +26,7 @@ ckb-gen-types = { path = "../gen-types", version = "= 0.119.0-pre" } bit-vec = "0.6.3" ckb-error = { path = "../../error", version = "= 0.119.0-pre" } ckb-rational = { path = "../rational", version = "= 0.119.0-pre" } -once_cell = "1.8.0" -derive_more = { version = "0.99.0", default-features = false, features = [ +derive_more = { version = "1", default-features = false, features = [ "display", ] } ckb-merkle-mountain-range = "0.5.2" diff --git a/util/types/src/core/cell.rs b/util/types/src/core/cell.rs index e5b62499ab..c7be1c4d64 100644 --- a/util/types/src/core/cell.rs +++ b/util/types/src/core/cell.rs @@ -8,10 +8,10 @@ use crate::{ }; use ckb_error::Error; use ckb_occupied_capacity::Result as CapacityResult; -use once_cell::sync::OnceCell; use std::collections::{hash_map::Entry, HashMap, HashSet}; use std::fmt; use std::hash::{BuildHasher, Hash, Hasher}; +use std::sync::OnceLock; /// TODO(doc): @quake #[derive(Debug)] @@ -25,7 +25,7 @@ pub enum ResolvedDep { /// type alias system cells map pub type SystemCellMap = HashMap; /// system cell memory map cache -pub static SYSTEM_CELL: OnceCell = OnceCell::new(); +pub static SYSTEM_CELL: OnceLock = OnceLock::new(); const MAX_DEP_EXPANSION_LIMIT: usize = 2048; diff --git a/util/types/src/global.rs b/util/types/src/global.rs index 9c02d6aac9..ed43a77516 100644 --- a/util/types/src/global.rs +++ b/util/types/src/global.rs @@ -1,7 +1,7 @@ //! Global data, initialized in the launch phase. -use once_cell::sync::OnceCell; use std::path::PathBuf; +use std::sync::OnceLock; /// ckb data directory path, located under root/data, initialized during the launch phase -pub static DATA_DIR: OnceCell = OnceCell::new(); +pub static DATA_DIR: OnceLock = OnceLock::new(); diff --git a/verification/Cargo.toml b/verification/Cargo.toml index c60cb91800..4565967bc4 100644 --- a/verification/Cargo.toml +++ b/verification/Cargo.toml @@ -19,11 +19,15 @@ ckb-chain-spec = { path = "../spec", version = "= 0.119.0-pre" } ckb-dao = { path = "../util/dao", version = "= 0.119.0-pre" } ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0-pre" } ckb-error = { path = "../error", version = "= 0.119.0-pre" } -derive_more = { version = "0.99.0", default-features=false, features = ["display"] } +derive_more = { version = "1", default-features = false, features = [ + "display", +] } ckb-verification-traits = { path = "./traits", version = "= 0.119.0-pre" } tokio = { version = "1", features = ["sync", "process"] } [dev-dependencies] ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0-pre" } ckb-resource = { path = "../resource", version = "= 0.119.0-pre" } -ckb-systemtime = {path = "../util/systemtime", version = "= 0.119.0-pre", features=["enable_faketime"]} +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0-pre", features = [ + "enable_faketime", +] }