diff --git a/.github/workflows/ci_integration_tests_macos.yaml b/.github/workflows/ci_integration_tests_macos.yaml index ae0fc371ef..2be0e75b8a 100644 --- a/.github/workflows/ci_integration_tests_macos.yaml +++ b/.github/workflows/ci_integration_tests_macos.yaml @@ -64,7 +64,7 @@ jobs: shell: bash - name: upload log files if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ runner.os }}_integration.log path: ${{ env.CKB_INTEGRATION_TEST_TMP }}/integration.log diff --git a/.github/workflows/ci_integration_tests_ubuntu.yaml b/.github/workflows/ci_integration_tests_ubuntu.yaml index dcb7f3e410..77c2b18c07 100644 --- a/.github/workflows/ci_integration_tests_ubuntu.yaml +++ b/.github/workflows/ci_integration_tests_ubuntu.yaml @@ -72,7 +72,7 @@ jobs: shell: bash - name: upload log files if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ runner.os }}_integration.log path: ${{ env.CKB_INTEGRATION_TEST_TMP }}/integration.log diff --git a/.github/workflows/ci_integration_tests_windows.yaml b/.github/workflows/ci_integration_tests_windows.yaml index 2ee12d3e9e..edcc871789 100644 --- a/.github/workflows/ci_integration_tests_windows.yaml +++ b/.github/workflows/ci_integration_tests_windows.yaml @@ -76,7 +76,7 @@ jobs: shell: bash - name: upload log files if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ runner.os }}_integration.log path: ${{ env.CKB_INTEGRATION_TEST_TMP }}/integration.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d6c2fe15b..e0a5885079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # CHANGELOG +## [v0.119.0](https://github.com/nervosnetwork/ckb/compare/v0.118.0...v0.119.0) (2024-10-25) + +### Features + +- #4635: Intro preview chain (@zhangsoledad) + + Introduces a new chain operation to provide a preview environment for the upcoming hardfork on the Nervos CKB network. The new chain allows users and developers to test and review the hardfork changes before they are officially deployed on the mainnet, ensuring all updates and features are thoroughly validated. This preview chain helps improve the security and reliability of the hard fork process, minimizing potential risks before the main deployment. + +### Bug Fixes + +- #4623: Fix atomic ordering in multi-thread (@driftluo) +- #4664 **script:** Remove isa a in version 2 (@mohanson) +- #4677: fix(script): fixed panic when calling `inherited_fds` in root process (@zhangsoledad) + +### Improvements + +- #4561: Recover possible transaction in conflicted cache when RBF (@chenyukang) +- #4641: Let BlockFilter exit if ckb has received exit signal (@eval-exec) +- #4654: `get_fee_rate_statistics` should aware `block_ext.txs_sizes` length is `block_ext.txs_fees` length + 1 (@eval-exec) +- #4509: Improve query performance of `get_cells` in rich-indexer (@EthanYuan) +- #4674: Remove empty entry for `OrphanPool` (@eval-exec) + ## [v0.118.0](https://github.com/nervosnetwork/ckb/compare/v0.117.0...v0.118.0) (2024-09-12) ### Features diff --git a/Cargo.lock b/Cargo.lock index 754dc1a382..775d510e66 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" @@ -416,9 +425,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -585,7 +594,7 @@ dependencies = [ [[package]] name = "ckb" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-bin", "ckb-build-info", @@ -595,11 +604,10 @@ dependencies = [ [[package]] name = "ckb-app-config" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-build-info", "ckb-chain-spec", - "ckb-constant", "ckb-jsonrpc-types", "ckb-logger", "ckb-logger-config", @@ -608,13 +616,11 @@ dependencies = [ "ckb-resource", "ckb-systemtime", "ckb-types", - "clap", "path-clean", "rand 0.8.5", "sentry", "serde", "serde_json", - "serde_plain", "tempfile", "tentacle-multiaddr", "tentacle-secio", @@ -625,7 +631,7 @@ dependencies = [ [[package]] name = "ckb-async-runtime" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-logger", "ckb-spawn", @@ -634,7 +640,7 @@ dependencies = [ [[package]] name = "ckb-benches" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-chain", @@ -661,7 +667,7 @@ dependencies = [ [[package]] name = "ckb-bin" -version = "0.118.0" +version = "0.119.0" dependencies = [ "base64 0.21.7", "ckb-app-config", @@ -671,6 +677,7 @@ dependencies = [ "ckb-chain-iter", "ckb-chain-spec", "ckb-channel", + "ckb-constant", "ckb-instrument", "ckb-jsonrpc-types", "ckb-launcher", @@ -707,7 +714,7 @@ dependencies = [ [[package]] name = "ckb-block-filter" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-async-runtime", "ckb-logger", @@ -719,11 +726,11 @@ dependencies = [ [[package]] name = "ckb-build-info" -version = "0.118.0" +version = "0.119.0" [[package]] name = "ckb-chain" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-chain-spec", @@ -763,7 +770,7 @@ dependencies = [ [[package]] name = "ckb-chain-iter" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-store", "ckb-types", @@ -771,7 +778,7 @@ dependencies = [ [[package]] name = "ckb-chain-spec" -version = "0.118.0" +version = "0.119.0" dependencies = [ "cacache", "ckb-constant", @@ -793,18 +800,18 @@ dependencies = [ [[package]] name = "ckb-channel" -version = "0.118.0" +version = "0.119.0" dependencies = [ "crossbeam-channel", ] [[package]] name = "ckb-constant" -version = "0.118.0" +version = "0.119.0" [[package]] name = "ckb-crypto" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-fixed-hash", "faster-hex", @@ -816,7 +823,7 @@ dependencies = [ [[package]] name = "ckb-dao" -version = "0.118.0" +version = "0.119.0" dependencies = [ "byteorder", "ckb-chain-spec", @@ -831,7 +838,7 @@ dependencies = [ [[package]] name = "ckb-dao-utils" -version = "0.118.0" +version = "0.119.0" dependencies = [ "byteorder", "ckb-error", @@ -840,7 +847,7 @@ dependencies = [ [[package]] name = "ckb-db" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-db-schema", @@ -853,7 +860,7 @@ dependencies = [ [[package]] name = "ckb-db-migration" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-channel", @@ -870,11 +877,11 @@ dependencies = [ [[package]] name = "ckb-db-schema" -version = "0.118.0" +version = "0.119.0" [[package]] name = "ckb-error" -version = "0.118.0" +version = "0.119.0" dependencies = [ "anyhow", "ckb-occupied-capacity", @@ -884,7 +891,7 @@ dependencies = [ [[package]] name = "ckb-fixed-hash" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-fixed-hash-core", "ckb-fixed-hash-macros", @@ -892,7 +899,7 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-core" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb_schemars", "faster-hex", @@ -903,7 +910,7 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-macros" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-fixed-hash-core", "proc-macro2", @@ -913,7 +920,7 @@ dependencies = [ [[package]] name = "ckb-freezer" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-error", "ckb-logger", @@ -929,7 +936,7 @@ dependencies = [ [[package]] name = "ckb-gen-types" -version = "0.118.0" +version = "0.119.0" dependencies = [ "cfg-if", "ckb-error", @@ -942,7 +949,7 @@ dependencies = [ [[package]] name = "ckb-hash" -version = "0.118.0" +version = "0.119.0" dependencies = [ "blake2b-ref", "blake2b-rs", @@ -950,7 +957,7 @@ dependencies = [ [[package]] name = "ckb-indexer" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-async-runtime", @@ -967,7 +974,7 @@ dependencies = [ [[package]] name = "ckb-indexer-sync" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-async-runtime", @@ -987,7 +994,7 @@ dependencies = [ [[package]] name = "ckb-instrument" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-chain", "ckb-chain-iter", @@ -1000,7 +1007,7 @@ dependencies = [ [[package]] name = "ckb-jsonrpc-types" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-types", "ckb_schemars", @@ -1014,7 +1021,7 @@ dependencies = [ [[package]] name = "ckb-launcher" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-async-runtime", @@ -1054,7 +1061,7 @@ dependencies = [ [[package]] name = "ckb-light-client-protocol-server" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-chain", @@ -1076,14 +1083,14 @@ dependencies = [ [[package]] name = "ckb-logger" -version = "0.118.0" +version = "0.119.0" dependencies = [ "log", ] [[package]] name = "ckb-logger-config" -version = "0.118.0" +version = "0.119.0" dependencies = [ "serde", "toml", @@ -1091,7 +1098,7 @@ dependencies = [ [[package]] name = "ckb-logger-service" -version = "0.118.0" +version = "0.119.0" dependencies = [ "backtrace", "ckb-channel", @@ -1110,7 +1117,7 @@ dependencies = [ [[package]] name = "ckb-memory-tracker" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-db", "ckb-logger", @@ -1132,7 +1139,7 @@ dependencies = [ [[package]] name = "ckb-metrics" -version = "0.118.0" +version = "0.119.0" dependencies = [ "once_cell", "prometheus", @@ -1141,14 +1148,14 @@ dependencies = [ [[package]] name = "ckb-metrics-config" -version = "0.118.0" +version = "0.119.0" dependencies = [ "serde", ] [[package]] name = "ckb-metrics-service" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-async-runtime", "ckb-logger", @@ -1162,7 +1169,7 @@ dependencies = [ [[package]] name = "ckb-migrate" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-chain-spec", @@ -1181,7 +1188,7 @@ dependencies = [ [[package]] name = "ckb-migration-template" -version = "0.118.0" +version = "0.119.0" dependencies = [ "quote", "syn 1.0.109", @@ -1189,7 +1196,7 @@ dependencies = [ [[package]] name = "ckb-miner" -version = "0.118.0" +version = "0.119.0" dependencies = [ "base64 0.21.7", "ckb-app-config", @@ -1218,7 +1225,7 @@ dependencies = [ [[package]] name = "ckb-multisig" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-crypto", "ckb-error", @@ -1228,7 +1235,7 @@ dependencies = [ [[package]] name = "ckb-network" -version = "0.118.0" +version = "0.119.0" dependencies = [ "bitflags 1.3.2", "bloom-filters", @@ -1266,7 +1273,7 @@ dependencies = [ [[package]] name = "ckb-network-alert" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-async-runtime", @@ -1289,7 +1296,7 @@ dependencies = [ [[package]] name = "ckb-notify" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-async-runtime", @@ -1301,7 +1308,7 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-occupied-capacity-core", "ckb-occupied-capacity-macros", @@ -1309,14 +1316,14 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-core" -version = "0.118.0" +version = "0.119.0" dependencies = [ "serde", ] [[package]] name = "ckb-occupied-capacity-macros" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-occupied-capacity-core", "quote", @@ -1325,7 +1332,7 @@ dependencies = [ [[package]] name = "ckb-pow" -version = "0.118.0" +version = "0.119.0" dependencies = [ "byteorder", "ckb-hash", @@ -1337,7 +1344,7 @@ dependencies = [ [[package]] name = "ckb-proposal-table" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-chain-spec", "ckb-logger", @@ -1346,7 +1353,7 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.118.0" +version = "0.119.0" dependencies = [ "numext-fixed-uint", "proptest", @@ -1355,7 +1362,7 @@ dependencies = [ [[package]] name = "ckb-resource" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-system-scripts", "ckb-types", @@ -1369,7 +1376,7 @@ dependencies = [ [[package]] name = "ckb-reward-calculator" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-chain-spec", "ckb-dao", @@ -1385,7 +1392,7 @@ dependencies = [ [[package]] name = "ckb-rich-indexer" -version = "0.118.0" +version = "0.119.0" dependencies = [ "anyhow", "ckb-app-config", @@ -1396,6 +1403,7 @@ dependencies = [ "ckb-types", "futures", "hex", + "include_dir", "log", "num-bigint", "once_cell", @@ -1403,6 +1411,7 @@ dependencies = [ "serde_json", "sql-builder", "sqlx", + "tempfile", "tokio", ] @@ -1419,7 +1428,7 @@ dependencies = [ [[package]] name = "ckb-rpc" -version = "0.118.0" +version = "0.119.0" dependencies = [ "async-stream", "async-trait", @@ -1473,7 +1482,7 @@ dependencies = [ [[package]] name = "ckb-rpc-gen" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-rpc", "ckb_schemars", @@ -1486,7 +1495,7 @@ dependencies = [ [[package]] name = "ckb-script" -version = "0.118.0" +version = "0.119.0" dependencies = [ "byteorder", "ckb-chain-spec", @@ -1514,7 +1523,7 @@ dependencies = [ [[package]] name = "ckb-shared" -version = "0.118.0" +version = "0.119.0" dependencies = [ "arc-swap", "bitflags 1.3.2", @@ -1548,7 +1557,7 @@ dependencies = [ [[package]] name = "ckb-snapshot" -version = "0.118.0" +version = "0.119.0" dependencies = [ "arc-swap", "ckb-chain-spec", @@ -1564,11 +1573,11 @@ dependencies = [ [[package]] name = "ckb-spawn" -version = "0.118.0" +version = "0.119.0" [[package]] name = "ckb-stop-handler" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-async-runtime", "ckb-channel", @@ -1584,7 +1593,7 @@ dependencies = [ [[package]] name = "ckb-store" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-chain-spec", @@ -1602,7 +1611,7 @@ dependencies = [ [[package]] name = "ckb-sync" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-chain", @@ -1658,11 +1667,11 @@ dependencies = [ [[package]] name = "ckb-systemtime" -version = "0.118.0" +version = "0.119.0" [[package]] name = "ckb-test-chain-utils" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-chain-spec", "ckb-dao", @@ -1681,14 +1690,14 @@ dependencies = [ [[package]] name = "ckb-traits" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-types", ] [[package]] name = "ckb-tx-pool" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-app-config", "ckb-async-runtime", @@ -1728,7 +1737,7 @@ dependencies = [ [[package]] name = "ckb-types" -version = "0.118.0" +version = "0.119.0" dependencies = [ "bit-vec", "bytes", @@ -1753,7 +1762,7 @@ dependencies = [ [[package]] name = "ckb-util" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-fixed-hash", "linked-hash-map", @@ -1764,7 +1773,7 @@ dependencies = [ [[package]] name = "ckb-verification" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-chain-spec", "ckb-dao", @@ -1785,7 +1794,7 @@ dependencies = [ [[package]] name = "ckb-verification-contextual" -version = "0.118.0" +version = "0.119.0" dependencies = [ "ckb-async-runtime", "ckb-chain", @@ -1811,7 +1820,7 @@ dependencies = [ [[package]] name = "ckb-verification-traits" -version = "0.118.0" +version = "0.119.0" dependencies = [ "bitflags 1.3.2", "ckb-error", @@ -1923,6 +1932,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" @@ -1973,6 +1991,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" @@ -2297,6 +2321,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" @@ -2338,30 +2373,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" @@ -2394,6 +2410,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" @@ -2416,7 +2435,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", @@ -2451,11 +2470,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" @@ -2542,14 +2577,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]] @@ -2636,13 +2670,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]] @@ -2881,9 +2915,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", @@ -2891,11 +2925,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]] @@ -2925,9 +2959,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" @@ -3162,6 +3199,25 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "include_dir" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "includedir" version = "0.6.0" @@ -3200,7 +3256,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -3387,6 +3443,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" @@ -3416,22 +3475,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", @@ -3731,6 +3779,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" @@ -3747,6 +3812,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" @@ -3910,6 +3986,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" @@ -3988,6 +4070,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" @@ -4157,6 +4248,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" @@ -4521,17 +4633,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" @@ -4664,31 +4765,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]] @@ -4737,23 +4843,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]] @@ -4824,16 +4950,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" @@ -4974,18 +5090,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -5102,6 +5218,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" @@ -5148,6 +5274,9 @@ name = "smallvec" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +dependencies = [ + "serde", +] [[package]] name = "smartstring" @@ -5187,12 +5316,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" @@ -5202,6 +5325,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" @@ -5225,98 +5358,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 = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" +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 = "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]] @@ -5466,7 +5700,7 @@ dependencies = [ "openssl-sys", "rand 0.8.5", "rand_core 0.6.4", - "ring 0.17.7", + "ring", "secp256k1", "sha2", "tokio", @@ -5595,9 +5829,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -5616,9 +5850,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -5709,17 +5943,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" @@ -5745,16 +5968,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -6117,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" @@ -6313,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]] @@ -6352,7 +6558,6 @@ checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ "redox_syscall 0.4.1", "wasite", - "web-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b491da1009..2d4b098bd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,11 +11,11 @@ repository = "https://github.com/nervosnetwork/ckb" rust-version = "1.75.0" [build-dependencies] -ckb-build-info = { path = "util/build-info", version = "= 0.118.0" } +ckb-build-info = { path = "util/build-info", version = "= 0.119.0" } [dependencies] -ckb-build-info = { path = "util/build-info", version = "= 0.118.0" } -ckb-bin = { path = "ckb-bin", version = "= 0.118.0" } +ckb-build-info = { path = "util/build-info", version = "= 0.119.0" } +ckb-bin = { path = "ckb-bin", version = "= 0.119.0" } console-subscriber = { version = "0.2.0", optional = true } [dev-dependencies] diff --git a/Makefile b/Makefile index 91ef1c2a5d..7882a0524b 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ doc-test: ## Run doc tests .PHONY: cli-test cli-test: prod # Run ckb command line usage bats test - ./util/app-config/src/tests/bats_tests/cli_test.sh + ./ckb-bin/src/tests/bats_tests/cli_test.sh .PHONY: test test: ## Run all tests, including some tests can be time-consuming to execute (tagged with [ignore]) diff --git a/README.md b/README.md index 0b883d1d93..3fe484b229 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [Nervos CKB](https://www.nervos.org/) - The Common Knowledge Base -[![Version](https://img.shields.io/badge/version-0.118.0--rc2-orange.svg)](https://github.com/nervosnetwork/ckb/releases) +[![Version](https://img.shields.io/badge/version-0.119.0--rc2-orange.svg)](https://github.com/nervosnetwork/ckb/releases) [![Nervos Talk](https://img.shields.io/badge/discuss-on%20Nervos%20Talk-3CC68A.svg)](https://talk.nervos.org/t/where-to-discuss-ckb-and-how-to-ask-for-support/6024) master | develop diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 6218ba3302..c47a906dc2 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-benches" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -13,25 +13,25 @@ repository = "https://github.com/nervosnetwork/ckb" [dev-dependencies] criterion = "0.5" -ckb-chain = { path = "../chain", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-shared = { path = "../shared", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } +ckb-chain = { path = "../chain", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } rand = "0.8" -ckb-hash = { path = "../util/hash", version = "= 0.118.0" } -ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.118.0" } -ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.118.0" } -ckb-dao = { path = "../util/dao", version = "= 0.118.0" } +ckb-hash = { path = "../util/hash", version = "= 0.119.0" } +ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0" } +ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0" } +ckb-dao = { path = "../util/dao", version = "= 0.119.0" } ckb-system-scripts = { version = "= 0.5.4" } lazy_static = "1.3.0" -ckb-crypto = { path = "../util/crypto", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } -ckb-verification = { path = "../verification", version = "= 0.118.0" } -ckb-verification-traits = { path = "../verification/traits", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-resource = { path = "../resource", version = "= 0.118.0" } -ckb-network = { path = "../network", version = "= 0.118.0" } +ckb-crypto = { path = "../util/crypto", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } +ckb-verification = { path = "../verification", version = "= 0.119.0" } +ckb-verification-traits = { path = "../verification/traits", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-resource = { path = "../resource", version = "= 0.119.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } tempfile.workspace = true [[bench]] diff --git a/block-filter/Cargo.toml b/block-filter/Cargo.toml index a3c81d997b..844cd21f10 100644 --- a/block-filter/Cargo.toml +++ b/block-filter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-block-filter" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,9 +11,9 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-shared = { path = "../shared", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } diff --git a/chain/Cargo.toml b/chain/Cargo.toml index 49799e76ac..2c6a7b0f77 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-chain" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,45 +9,45 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-metrics = { path = "../util/metrics", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-shared = { path = "../shared", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-verification = { path = "../verification", version = "= 0.118.0" } -ckb-verification-contextual = { path = "../verification/contextual", version = "= 0.118.0" } -ckb-verification-traits = { path = "../verification/traits", version = "= 0.118.0" } -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } -ckb-proposal-table = { path = "../util/proposal-table", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-db = { path = "../db", version = "= 0.118.0" } -ckb-db-schema = { path = "../db-schema", version = "= 0.118.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-metrics = { path = "../util/metrics", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-verification = { path = "../verification", version = "= 0.119.0" } +ckb-verification-contextual = { path = "../verification/contextual", version = "= 0.119.0" } +ckb-verification-traits = { path = "../verification/traits", version = "= 0.119.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } +ckb-proposal-table = { path = "../util/proposal-table", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-db = { path = "../db", version = "= 0.119.0" } +ckb-db-schema = { path = "../db-schema", version = "= 0.119.0" } faux = { version = "^0.1", optional = true } ckb-merkle-mountain-range = "0.5.2" is_sorted = "0.1.1" -ckb-constant = { path = "../util/constant", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } +ckb-constant = { path = "../util/constant", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } crossbeam = "0.8.2" -ckb-network = { path = "../network", version = "= 0.118.0" } -ckb-tx-pool = { path = "../tx-pool", version = "= 0.118.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } +ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0" } minstant = "0.1.4" dashmap = "4.0" [dev-dependencies] -ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.118.0" } -ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.118.0" } -ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.118.0" } -ckb-tx-pool = { path = "../tx-pool", version = "= 0.118.0", features = ["internal"] } -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } -ckb-network = { path = "../network", version = "= 0.118.0" } +ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0" } +ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0" } +ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.119.0" } +ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0", features = ["internal"] } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } lazy_static = "1.4" tempfile.workspace = true -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" ,features = ["enable_faketime"]} -ckb-logger-service = { path = "../util/logger-service", version = "= 0.118.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" ,features = ["enable_faketime"]} +ckb-logger-service = { path = "../util/logger-service", version = "= 0.119.0" } [features] default = [] diff --git a/ckb-bin/Cargo.toml b/ckb-bin/Cargo.toml index dc90beab8a..ebe20dec06 100644 --- a/ckb-bin/Cargo.toml +++ b/ckb-bin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-bin" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,42 +9,45 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -clap = { version = "=4.4" } +clap = { version = "=4.4", features = ["string", "wrap_help"] } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } serde_plain = "0.3.0" toml = "0.5" -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-logger-service = { path = "../util/logger-service", version = "= 0.118.0" } -ckb-metrics-service = { path = "../util/metrics-service", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } -ckb-chain = { path = "../chain", version = "= 0.118.0" } -ckb-shared = { path = "../shared", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-miner = { path = "../miner", version = "= 0.118.0" } -ckb-network = { path = "../network", version = "= 0.118.0" } -ckb-resource = { path = "../resource", version = "= 0.118.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-logger-service = { path = "../util/logger-service", version = "= 0.119.0" } +ckb-metrics-service = { path = "../util/metrics-service", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } +ckb-chain = { path = "../chain", version = "= 0.119.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-miner = { path = "../miner", version = "= 0.119.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } +ckb-resource = { path = "../resource", version = "= 0.119.0" } ctrlc = { version = "3.1", features = ["termination"] } -ckb-instrument = { path = "../util/instrument", version = "= 0.118.0", features = ["progress_bar"] } -ckb-build-info = { path = "../util/build-info", version = "= 0.118.0" } -ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.118.0" } -ckb-chain-iter = { path = "../util/chain-iter", version = "= 0.118.0" } -ckb-verification-traits = { path = "../verification/traits", version = "= 0.118.0" } -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } -ckb-migrate = { path = "../util/migrate", version = "= 0.118.0" } -ckb-launcher = { path = "../util/launcher", version = "= 0.118.0" } +ckb-instrument = { path = "../util/instrument", version = "= 0.119.0", features = [ + "progress_bar", +] } +ckb-build-info = { path = "../util/build-info", version = "= 0.119.0" } +ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.119.0" } +ckb-chain-iter = { path = "../util/chain-iter", version = "= 0.119.0" } +ckb-verification-traits = { path = "../verification/traits", version = "= 0.119.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } +ckb-migrate = { path = "../util/migrate", version = "= 0.119.0" } +ckb-launcher = { path = "../util/launcher", version = "= 0.119.0" } +ckb-constant = { path = "../util/constant", version = "= 0.119.0" } base64 = "0.21.0" tempfile.workspace = true rayon = "1.0" sentry = { version = "0.26.0", optional = true } is-terminal = "0.4.7" fdlimit = "0.2.1" -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } tokio = { version = "1", features = ["sync"] } [target.'cfg(not(target_os="windows"))'.dependencies] @@ -55,7 +58,13 @@ colored = "2.0" [features] deadlock_detection = ["ckb-util/deadlock_detection"] profiling = ["ckb-memory-tracker/profiling", "ckb-shared/stats"] -with_sentry = ["sentry", "ckb-launcher/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry", "ckb-logger-service/with_sentry"] +with_sentry = [ + "sentry", + "ckb-launcher/with_sentry", + "ckb-network/with_sentry", + "ckb-app-config/with_sentry", + "ckb-logger-service/with_sentry", +] with_dns_seeding = ["ckb-network/with_dns_seeding"] portable = ["ckb-launcher/portable"] march-native = ["ckb-launcher/march-native"] diff --git a/ckb-bin/src/cli.rs b/ckb-bin/src/cli.rs new file mode 100644 index 0000000000..fbda878d75 --- /dev/null +++ b/ckb-bin/src/cli.rs @@ -0,0 +1,651 @@ +//! CKB command line arguments parser. +use ckb_build_info::Version; +use ckb_resource::{AVAILABLE_SPECS, DEFAULT_P2P_PORT, DEFAULT_RPC_PORT, DEFAULT_SPEC}; +use clap::{Arg, ArgGroup, ArgMatches, Command}; + +pub use ckb_app_config::cli::*; + +/// Subcommand `export`. +pub const CMD_EXPORT: &str = "export"; +/// Subcommand `import`. +pub const CMD_IMPORT: &str = "import"; +/// Subcommand `init`. +pub const CMD_INIT: &str = "init"; +/// Subcommand `replay`. +pub const CMD_REPLAY: &str = "replay"; +/// Subcommand `stats`. +pub const CMD_STATS: &str = "stats"; +/// Subcommand `list-hashes`. +pub const CMD_LIST_HASHES: &str = "list-hashes"; +/// Subcommand `peer-id`. +pub const CMD_PEERID: &str = "peer-id"; +/// Subcommand `gen`. +pub const CMD_GEN_SECRET: &str = "gen"; +/// Subcommand `from-secret`. +pub const CMD_FROM_SECRET: &str = "from-secret"; +/// Subcommand `migrate`. +pub const CMD_MIGRATE: &str = "migrate"; +/// Subcommand `daemon` +pub const CMD_DAEMON: &str = "daemon"; +/// Command line argument `--config-dir`. +pub const ARG_CONFIG_DIR: &str = "config-dir"; +/// Command line argument `--format`. +pub const ARG_FORMAT: &str = "format"; +/// Command line argument `--target`. +pub const ARG_TARGET: &str = "target"; +/// Command line argument `--source`. +pub const ARG_SOURCE: &str = "source"; +/// Command line argument `--data`. +pub const ARG_DATA: &str = "data"; +/// Command line argument `--list-chains`. +pub const ARG_LIST_CHAINS: &str = "list-chains"; +/// Command line argument `--interactive`. +pub const ARG_INTERACTIVE: &str = "interactive"; +/// Command line argument `--chain`. +pub const ARG_CHAIN: &str = "chain"; +/// Command line argument `--import-spec`. +pub const ARG_IMPORT_SPEC: &str = "import-spec"; +/// The argument for the genesis message. +pub const ARG_GENESIS_MESSAGE: &str = "genesis-message"; +/// Command line argument `--p2p-port`. +pub const ARG_P2P_PORT: &str = "p2p-port"; +/// Command line argument `--rpc-port`. +pub const ARG_RPC_PORT: &str = "rpc-port"; +/// Command line argument `--force`. +pub const ARG_FORCE: &str = "force"; +/// Command line argument `--include-background`. +pub const ARG_INCLUDE_BACKGROUND: &str = "include-background"; +/// Command line argument `--log-to`. +pub const ARG_LOG_TO: &str = "log-to"; +/// Command line argument `--bundled`. +pub const ARG_BUNDLED: &str = "bundled"; +/// Command line argument `--ba-code-hash`. +pub const ARG_BA_CODE_HASH: &str = "ba-code-hash"; +/// Command line argument `--ba-arg`. +pub const ARG_BA_ARG: &str = "ba-arg"; +/// Command line argument `--ba-hash-type`. +pub const ARG_BA_HASH_TYPE: &str = "ba-hash-type"; +/// Command line argument `--ba-message`. +pub const ARG_BA_MESSAGE: &str = "ba-message"; +/// Command line argument `--ba-advanced`. +pub const ARG_BA_ADVANCED: &str = "ba-advanced"; +/// Command line argument `--daemon` +pub const ARG_DAEMON: &str = "daemon"; +/// Command line argument `--indexer`. +pub const ARG_INDEXER: &str = "indexer"; +/// Command line argument `--rich-indexer`. +pub const ARG_RICH_INDEXER: &str = "rich-indexer"; +/// Command line argument `--from`. +pub const ARG_FROM: &str = "from"; +/// Command line argument `--to`. +pub const ARG_TO: &str = "to"; +/// Command line argument `--all`. +pub const ARG_ALL: &str = "all"; +/// Command line argument `--limit`. +pub const ARG_LIMIT: &str = "limit"; +/// Command line argument `--database`. +pub const ARG_DATABASE: &str = "database"; +/// Command line argument `--network`. +pub const ARG_NETWORK: &str = "network"; +/// Command line argument `--network-peer-store`. +pub const ARG_NETWORK_PEER_STORE: &str = "network-peer-store"; +/// Command line argument `--network-secret-key`. +pub const ARG_NETWORK_SECRET_KEY: &str = "network-secret-key"; +/// Command line argument `--logs`. +pub const ARG_LOGS: &str = "logs"; +/// Command line argument `--tmp-target`. +pub const ARG_TMP_TARGET: &str = "tmp-target"; +/// Command line argument `--secret-path`. +pub const ARG_SECRET_PATH: &str = "secret-path"; +/// Command line argument `--profile`. +pub const ARG_PROFILE: &str = "profile"; +/// Command line argument `--sanity-check`. +pub const ARG_SANITY_CHECK: &str = "sanity-check"; +/// Command line argument `--full-verification`. +pub const ARG_FULL_VERIFICATION: &str = "full-verification"; +/// Command line argument `--skip-spec-check`. +pub const ARG_SKIP_CHAIN_SPEC_CHECK: &str = "skip-spec-check"; +/// Present `overwrite-spec` arg to force overriding the chain spec in the database with the present configured chain spec +pub const ARG_OVERWRITE_CHAIN_SPEC: &str = "overwrite-spec"; +/// Command line argument `--assume-valid-target`. +pub const ARG_ASSUME_VALID_TARGET: &str = "assume-valid-target"; +/// Command line argument `--check`. +pub const ARG_MIGRATE_CHECK: &str = "check"; +/// Command line argument `daemon --check` +pub const ARG_DAEMON_CHECK: &str = "check"; +/// Command line argument `daemon --stop` +pub const ARG_DAEMON_STOP: &str = "stop"; + +/// Command line arguments group `ba` for block assembler. +const GROUP_BA: &str = "ba"; + +/// return root clap Command +pub fn basic_app() -> Command { + let command = Command::new(BIN_NAME) + .author("Nervos Core Dev ") + .about("Nervos CKB - The Common Knowledge Base") + .subcommand_required(true) + .arg_required_else_help(true) + .term_width(110) + .arg( + Arg::new(ARG_CONFIG_DIR) + .global(true) + .short('C') + .value_name("path") + .action(clap::ArgAction::Set) + .help( + "Run as if CKB was started in , instead of the current working directory.", + ), + ) + .subcommand(run()) + .subcommand(miner()) + .subcommand(export()) + .subcommand(import()) + .subcommand(list_hashes()) + .subcommand(init()) + .subcommand(replay()) + .subcommand(stats()) + .subcommand(reset_data()) + .subcommand(peer_id()) + .subcommand(migrate()); + + #[cfg(not(target_os = "windows"))] + let command = command.subcommand(daemon()); + + command +} + +/// Parse the command line arguments by supplying the version information. +/// +/// The version is used to generate the help message and output for `--version`. +pub fn get_bin_name_and_matches(version: &Version) -> (String, ArgMatches) { + let bin_name = std::env::args() + .next() + .unwrap_or_else(|| BIN_NAME.to_owned()); + let matches = basic_app() + .version(version.short()) + .long_version(version.long()) + .get_matches(); + (bin_name, matches) +} + +fn run() -> Command { + let command = Command::new(CMD_RUN) + .about("Run CKB node") + .arg( + Arg::new(ARG_BA_ADVANCED) + .long(ARG_BA_ADVANCED) + .action(clap::ArgAction::SetTrue) + .help("Allow any block assembler code hash and args"), + ) + .arg( + Arg::new(ARG_SKIP_CHAIN_SPEC_CHECK) + .long(ARG_SKIP_CHAIN_SPEC_CHECK) + .action(clap::ArgAction::SetTrue) + .help("Skip checking the chain spec with the hash stored in the database"), + ).arg( + Arg::new(ARG_OVERWRITE_CHAIN_SPEC) + .long(ARG_OVERWRITE_CHAIN_SPEC) + .action(clap::ArgAction::SetTrue) + .help("Overwrite the chain spec in the database with the present configured chain spec") + ).arg( + Arg::new(ARG_ASSUME_VALID_TARGET) + .long(ARG_ASSUME_VALID_TARGET) + .action(clap::ArgAction::Set) + .value_parser(is_h256) + .help(format!("This parameter specifies the hash of a block. \ +When the height does not reach this block's height, script execution will be disabled, \ +meaning it will skip the verification of the script content. \n\n\ +Please note that when this option is enabled, the header will be synchronized to \ +the highest block currently found. During this period, if the assume valid target is found, \ +the block download starts; \ +If the assume valid target is either absent or has a timestamp within 24 hours of the current time, \ +the target considered invalid, and the block download proceeds with full verification. \n\n\n\ +default(MainNet): {}\n +default(TestNet): {}\n\n +You can explicitly set the value to 0x0000000000000000000000000000000000000000000000000000000000000000 \ +to disable the default behavior and execute full verification for all blocks, \ +", + ckb_constant::default_assume_valid_target::mainnet::DEFAULT_ASSUME_VALID_TARGET, + ckb_constant::default_assume_valid_target::testnet::DEFAULT_ASSUME_VALID_TARGET)) + ).arg( + Arg::new(ARG_INDEXER) + .long(ARG_INDEXER) + .action(clap::ArgAction::SetTrue) + .help("Start the built-in indexer service"), + ) + .arg( + Arg::new(ARG_RICH_INDEXER) + .long(ARG_RICH_INDEXER) + .action(clap::ArgAction::SetTrue) + .help("Start the built-in rich-indexer service"), + ); + + #[cfg(not(target_os = "windows"))] + let command = command.arg( + Arg::new(ARG_DAEMON) + .long(ARG_DAEMON) + .action(clap::ArgAction::SetTrue) + .help( + "Starts ckb as a daemon, \ + which will run in the background and output logs to the specified log file", + ), + ); + command +} + +fn miner() -> Command { + Command::new(CMD_MINER).about("Runs ckb miner").arg( + Arg::new(ARG_LIMIT) + .short('l') + .long(ARG_LIMIT) + .action(clap::ArgAction::Set) + .value_parser(clap::value_parser!(u128)) + .default_value("0") + .help( + "Exit after finding this specific number of nonces; \ + 0 means the miner will never exit. [default: 0]", + ), + ) +} + +fn reset_data() -> Command { + Command::new(CMD_RESET_DATA) + .about( + "Truncate the database directory\n\ + Example:\n\ + ckb reset-data --force --database", + ) + .arg( + Arg::new(ARG_FORCE) + .short('f') + .long(ARG_FORCE) + .action(clap::ArgAction::SetTrue) + .help("Delete data without interactive prompt"), + ) + .arg( + Arg::new(ARG_ALL) + .long(ARG_ALL) + .action(clap::ArgAction::SetTrue) + .help("Delete the whole data directory"), + ) + .arg( + Arg::new(ARG_DATABASE) + .long(ARG_DATABASE) + .action(clap::ArgAction::SetTrue) + .help("Delete only `data/db`"), + ) + .arg( + Arg::new(ARG_INDEXER) + .long(ARG_INDEXER) + .action(clap::ArgAction::SetTrue) + .help("Delete only `data/indexer/store`"), + ) + .arg( + Arg::new(ARG_RICH_INDEXER) + .long(ARG_RICH_INDEXER) + .action(clap::ArgAction::SetTrue) + .help("Delete only `data/indexer/sqlite`"), + ) + .arg( + Arg::new(ARG_NETWORK) + .long(ARG_NETWORK) + .action(clap::ArgAction::SetTrue) + .help("Delete both peer store and secret key"), + ) + .arg( + Arg::new(ARG_NETWORK_PEER_STORE) + .long(ARG_NETWORK_PEER_STORE) + .action(clap::ArgAction::SetTrue) + .help("Delete only `data/network/peer_store`"), + ) + .arg( + Arg::new(ARG_NETWORK_SECRET_KEY) + .long(ARG_NETWORK_SECRET_KEY) + .action(clap::ArgAction::SetTrue) + .help("Delete only `data/network/secret_key`"), + ) + .arg( + Arg::new(ARG_LOGS) + .long(ARG_LOGS) + .action(clap::ArgAction::SetTrue) + .help("Delete only `data/logs`"), + ) +} + +pub(crate) fn stats() -> Command { + Command::new(CMD_STATS) + .about( + "Chain stats\n\ + Example:\n\ + ckb -C stats --from 1 --to 500", + ) + .arg( + Arg::new(ARG_FROM) + .long(ARG_FROM) + .value_parser(clap::value_parser!(u64)) + .action(clap::ArgAction::Set) + .help("Specify from block number"), + ) + .arg( + Arg::new(ARG_TO) + .long(ARG_TO) + .value_parser(clap::value_parser!(u64)) + .action(clap::ArgAction::Set) + .help("Specify to block number"), + ) +} + +fn replay() -> Command { + Command::new(CMD_REPLAY) + .about("Replay CKB process block") + .override_help(" + --tmp-target --profile 1 10,\n + --tmp-target --sanity-check,\n + ") + .arg(Arg::new(ARG_TMP_TARGET).long(ARG_TMP_TARGET).value_parser(clap::builder::PathBufValueParser::new()).action(clap::ArgAction::Set).required(true).help( + "Specify a target path. The profile command makes a temporary directory within the specified target path. This temporary directory will be automatically deleted when the command completes.", + )) + .arg(Arg::new(ARG_PROFILE).long(ARG_PROFILE).action(clap::ArgAction::SetTrue).help( + "Enable profile", + )) + .arg( + Arg::new(ARG_FROM) + .value_parser(clap::value_parser!(u64)) + .help("Specify profile from block number"), + ) + .arg( + Arg::new(ARG_TO) + .value_parser(clap::value_parser!(u64)) + .help("Specify profile to block number"), + ) + .arg( + Arg::new(ARG_SANITY_CHECK).long(ARG_SANITY_CHECK).action(clap::ArgAction::SetTrue).help("Enable sanity check") + ) + .arg( + Arg::new(ARG_FULL_VERIFICATION).long(ARG_FULL_VERIFICATION).action(clap::ArgAction::SetTrue).help("Enable sanity check") + ) + .group( + ArgGroup::new("mode") + .args([ARG_PROFILE, ARG_SANITY_CHECK]) + .required(true) + ) +} + +fn export() -> Command { + Command::new(CMD_EXPORT).about("Export CKB data").arg( + Arg::new(ARG_TARGET) + .short('t') + .long(ARG_TARGET) + .value_name("path") + .value_parser(clap::builder::PathBufValueParser::new()) + .required(true) + .help("Specify the export target path"), + ) +} + +fn import() -> Command { + Command::new(CMD_IMPORT).about("Import CKB data").arg( + Arg::new(ARG_SOURCE) + .index(1) + .value_name("path") + .value_parser(clap::builder::PathBufValueParser::new()) + .required(true) + .help("Specify the exported data path"), + ) +} + +fn migrate() -> Command { + Command::new(CMD_MIGRATE) + .about("Run CKB migration") + .arg( + Arg::new(ARG_MIGRATE_CHECK) + .long(ARG_MIGRATE_CHECK) + .action(clap::ArgAction::SetTrue) + .help( + "Perform database version check without migrating. \ + If migration is in need, ExitCode(0) is returned; \ + otherwise ExitCode(64) is returned", + ), + ) + .arg( + Arg::new(ARG_FORCE) + .long(ARG_FORCE) + .action(clap::ArgAction::SetTrue) + .conflicts_with(ARG_MIGRATE_CHECK) + .help("Migrate without interactive prompt"), + ) + .arg( + Arg::new(ARG_INCLUDE_BACKGROUND) + .long(ARG_INCLUDE_BACKGROUND) + .action(clap::ArgAction::SetTrue) + .help("Whether include background migrations"), + ) +} + +#[cfg(not(target_os = "windows"))] +fn daemon() -> Command { + Command::new(CMD_DAEMON) + .about("Runs ckb daemon command") + .arg( + Arg::new(ARG_DAEMON_CHECK) + .long(ARG_DAEMON_CHECK) + .action(clap::ArgAction::SetTrue) + .help("Check the daemon status"), + ) + .arg( + Arg::new(ARG_DAEMON_STOP) + .long(ARG_DAEMON_STOP) + .action(clap::ArgAction::SetTrue) + .conflicts_with(ARG_DAEMON_CHECK) + .help("Stop the daemon process, both the miner and the node"), + ) +} + +fn list_hashes() -> Command { + Command::new(CMD_LIST_HASHES) + .about("List well known hashes") + .arg( + Arg::new(ARG_BUNDLED) + .short('b') + .long(ARG_BUNDLED) + .action(clap::ArgAction::SetTrue) + .help( + "List hashes of the bundled chain specs, instead of the current effective ones.", + ), + ) + .arg( + Arg::new(ARG_FORMAT) + .short('f') + .long(ARG_FORMAT) + .value_parser(["json", "toml"]) + .default_value("toml") + .help("Set the format of the printed hashes"), + ) +} + +fn init() -> Command { + Command::new(CMD_INIT) + .about("Create a CKB directory or re-initialize an existing one") + .arg( + Arg::new(ARG_INTERACTIVE) + .short('i') + .long(ARG_INTERACTIVE) + .action(clap::ArgAction::SetTrue) + .help("Interactive mode"), + ) + .arg( + Arg::new(ARG_LIST_CHAINS) + .short('l') + .long(ARG_LIST_CHAINS) + .action(clap::ArgAction::SetTrue) + .help("List available options for --chain"), + ) + .arg( + Arg::new(ARG_CHAIN) + .short('c') + .long(ARG_CHAIN) + .value_parser( + AVAILABLE_SPECS + .iter() + .map(|v| v.to_string()) + .collect::>(), + ) + .default_value(DEFAULT_SPEC) + .help("Initialize CKB directory for "), + ) + .arg( + Arg::new(ARG_IMPORT_SPEC) + .long(ARG_IMPORT_SPEC) + .action(clap::ArgAction::Set) + .help( + "Use the specified file as the chain spec. Specially, \ + The dash \"-\" denotes importing the spec from stdin encoded in base64", + ), + ) + .arg( + Arg::new(ARG_LOG_TO) + .long(ARG_LOG_TO) + .value_parser(["file", "stdout", "both"]) + .default_value("both") + .help("Configure where the logs should be printed"), + ) + .arg( + Arg::new(ARG_FORCE) + .short('f') + .long(ARG_FORCE) + .action(clap::ArgAction::SetTrue) + .help("Enforce overwriting existing files"), + ) + .arg( + Arg::new(ARG_RPC_PORT) + .long(ARG_RPC_PORT) + .default_value(DEFAULT_RPC_PORT) + .help("Replace CKB RPC port in the created config file"), + ) + .arg( + Arg::new(ARG_P2P_PORT) + .long(ARG_P2P_PORT) + .default_value(DEFAULT_P2P_PORT) + .help("Replace CKB P2P port in the created config file"), + ) + .arg( + Arg::new(ARG_BA_CODE_HASH) + .long(ARG_BA_CODE_HASH) + .value_name("code_hash") + .value_parser(is_h256) + .action(clap::ArgAction::Set) + .help( + "Set code_hash in [block_assembler] \ + [default: secp256k1 if --ba-arg is present]", + ), + ) + .arg( + Arg::new(ARG_BA_ARG) + .long(ARG_BA_ARG) + .value_name("arg") + .action(clap::ArgAction::Append) + .value_parser(is_hex) + .help("Set args in [block_assembler]"), + ) + .arg( + Arg::new(ARG_BA_HASH_TYPE) + .long(ARG_BA_HASH_TYPE) + .value_name("hash_type") + .action(clap::ArgAction::Set) + .value_parser(["data", "type", "data1"]) + .default_value("type") + .help("Set hash type in [block_assembler]"), + ) + .group( + ArgGroup::new(GROUP_BA) + .args([ARG_BA_CODE_HASH, ARG_BA_ARG]) + .multiple(true), + ) + .arg( + Arg::new(ARG_BA_MESSAGE) + .long(ARG_BA_MESSAGE) + .value_name("message") + .value_parser(is_hex) + .requires(GROUP_BA) + .help("Set message in [block_assembler]"), + ) + .arg(Arg::new("export-specs").long("export-specs").hide(true)) + .arg(Arg::new("list-specs").long("list-specs").hide(true)) + .arg( + Arg::new("spec") + .short('s') + .long("spec") + .action(clap::ArgAction::Set) + .hide(true), + ) + .arg( + Arg::new(ARG_GENESIS_MESSAGE) + .long(ARG_GENESIS_MESSAGE) + .value_name(ARG_GENESIS_MESSAGE) + .action(clap::ArgAction::Set) + .help( + "Specify a string as the genesis message. \ + This only works for dev chains. \ + If no message is provided, use the current timestamp.", + ), + ) +} + +fn peer_id() -> Command { + Command::new(CMD_PEERID) + .about("About peer id, base on Secp256k1") + .subcommand_required(true) + .subcommand( + Command::new(CMD_FROM_SECRET) + .about("Generate peer id from secret file") + .arg( + Arg::new(ARG_SECRET_PATH) + .action(clap::ArgAction::Set) + .long(ARG_SECRET_PATH) + .required(true) + .help("Generate peer id from secret file path"), + ), + ) + .subcommand( + Command::new(CMD_GEN_SECRET) + .about("Generate random key to file") + .arg( + Arg::new(ARG_SECRET_PATH) + .long(ARG_SECRET_PATH) + .required(true) + .action(clap::ArgAction::Set) + .help("Generate peer id to file path"), + ), + ) +} + +fn is_hex(hex: &str) -> Result { + let tmp = hex.as_bytes(); + if tmp.len() < 2 { + Err("Must be a 0x-prefixed hexadecimal string".to_string()) + } else if tmp.len() & 1 != 0 { + Err("Hexadecimal strings must be of even length".to_string()) + } else if tmp[..2] == b"0x"[..] { + for byte in &tmp[2..] { + match byte { + b'A'..=b'F' | b'a'..=b'f' | b'0'..=b'9' => continue, + invalid_char => { + return Err(format!("Hex has invalid char: {invalid_char}")); + } + } + } + + Ok(hex.to_string()) + } else { + Err("Must 0x-prefixed hexadecimal string".to_string()) + } +} + +fn is_h256(hex: &str) -> Result { + if hex.len() != 66 { + Err("Must be 0x-prefixed hexadecimal string and string length is 66".to_owned()) + } else { + is_hex(hex) + } +} diff --git a/ckb-bin/src/lib.rs b/ckb-bin/src/lib.rs index 23c09d238b..cb62c8613b 100644 --- a/ckb-bin/src/lib.rs +++ b/ckb-bin/src/lib.rs @@ -1,16 +1,22 @@ //! CKB executable. //! //! This crate is created to reduce the link time to build CKB. +#[allow(dead_code)] +mod cli; mod helper; +mod setup; mod setup_guard; mod subcommand; -use ckb_app_config::{cli, ExitCode, Setup}; +#[cfg(test)] +mod tests; +use ckb_app_config::ExitCode; use ckb_async_runtime::new_global_runtime; use ckb_build_info::Version; use ckb_logger::{debug, info}; use ckb_network::tokio; use clap::ArgMatches; use helper::raise_fd_limit; +use setup::Setup; use setup_guard::SetupGuard; #[cfg(not(target_os = "windows"))] diff --git a/ckb-bin/src/setup.rs b/ckb-bin/src/setup.rs new file mode 100644 index 0000000000..789323d250 --- /dev/null +++ b/ckb-bin/src/setup.rs @@ -0,0 +1,476 @@ +#[cfg(not(target_os = "windows"))] +use ckb_app_config::DaemonArgs; +use ckb_app_config::{ + generate_random_key, read_secret_key, write_secret_to_file, AppConfig, CustomizeSpec, ExitCode, + ExportArgs, ImportArgs, InitArgs, MigrateArgs, MinerArgs, PeerIDArgs, ReplayArgs, + ResetDataArgs, RunArgs, StatsArgs, +}; +use ckb_chain_spec::{consensus::Consensus, ChainSpec}; +use ckb_jsonrpc_types::ScriptHashType; +use ckb_logger::info; +use ckb_types::{u256, H256, U256}; +use clap::ArgMatches; +use std::{path::PathBuf, str::FromStr}; + +use crate::cli; + +// 500_000 total difficulty +const MIN_CHAIN_WORK_500K: U256 = u256!("0x3314412053c82802a7"); + +/// A struct including all the information to start the ckb process. +pub struct Setup { + /// Subcommand name. + /// + /// For example, this is set to `run` when ckb is executed with `ckb run`. + #[cfg(feature = "with_sentry")] + pub subcommand_name: String, + /// The config file for the current subcommand. + pub config: AppConfig, + /// Whether sentry is enabled. + #[cfg(feature = "with_sentry")] + pub is_sentry_enabled: bool, +} + +impl Setup { + /// Boots the ckb process by parsing the command line arguments and loading the config file. + pub fn from_matches( + bin_name: String, + subcommand_name: &str, + matches: &ArgMatches, + ) -> Result { + let root_dir = Self::root_dir_from_matches(matches)?; + let mut config = AppConfig::load_for_subcommand(root_dir, subcommand_name)?; + config.set_bin_name(bin_name); + #[cfg(feature = "with_sentry")] + let is_sentry_enabled = is_daemon(subcommand_name) && config.sentry().is_enabled(); + + Ok(Setup { + #[cfg(feature = "with_sentry")] + subcommand_name: subcommand_name.to_string(), + config, + #[cfg(feature = "with_sentry")] + is_sentry_enabled, + }) + } + + /// Executes `ckb run`. + pub fn run(self, matches: &ArgMatches) -> Result { + let consensus = self.consensus()?; + let chain_spec_hash = self.chain_spec()?.hash; + let mut config = self.config.into_ckb()?; + + let mainnet_genesis = ckb_chain_spec::ChainSpec::load_from( + &ckb_resource::Resource::bundled("specs/mainnet.toml".to_string()), + ) + .expect("load mainnet spec fail") + .build_genesis() + .expect("build mainnet genesis fail"); + config.network.sync.min_chain_work = + if consensus.genesis_block.hash() == mainnet_genesis.hash() { + MIN_CHAIN_WORK_500K + } else { + u256!("0x0") + }; + + let arg_assume_valid_target = matches.get_one::(cli::ARG_ASSUME_VALID_TARGET); + + config.network.sync.assume_valid_target = + arg_assume_valid_target.and_then(|s| H256::from_str(&s[2..]).ok()); + if config.network.sync.assume_valid_target.is_none() { + config.network.sync.assume_valid_target = match consensus.id.as_str() { + ckb_constant::hardfork::mainnet::CHAIN_SPEC_NAME => Some( + H256::from_str(&ckb_constant::default_assume_valid_target::mainnet::DEFAULT_ASSUME_VALID_TARGET[2..]) + .expect("default assume_valid_target for mainnet must be valid"), + ), + ckb_constant::hardfork::testnet::CHAIN_SPEC_NAME => Some( + H256::from_str(&ckb_constant::default_assume_valid_target::testnet::DEFAULT_ASSUME_VALID_TARGET[2..]) + .expect("default assume_valid_target for testnet must be valid"), + ), + _ => None, + }; + } + + if let Some(ref assume_valid_target) = config.network.sync.assume_valid_target { + if assume_valid_target + == &H256::from_slice(&[0; 32]).expect("must parse Zero h256 successful") + { + info!("Disable assume valid target since assume_valid_target is zero"); + config.network.sync.assume_valid_target = None + } else { + info!("assume_valid_target set to 0x{}", assume_valid_target); + } + } + + Ok(RunArgs { + config, + consensus, + block_assembler_advanced: matches.get_flag(cli::ARG_BA_ADVANCED), + skip_chain_spec_check: matches.get_flag(cli::ARG_SKIP_CHAIN_SPEC_CHECK), + overwrite_chain_spec: matches.get_flag(cli::ARG_OVERWRITE_CHAIN_SPEC), + chain_spec_hash, + indexer: matches.get_flag(cli::ARG_INDEXER), + rich_indexer: matches.get_flag(cli::ARG_RICH_INDEXER), + #[cfg(not(target_os = "windows"))] + daemon: matches.get_flag(cli::ARG_DAEMON), + }) + } + + /// `migrate` subcommand has one `flags` arg, trigger this arg with "--check" + pub fn migrate(self, matches: &ArgMatches) -> Result { + let consensus = self.consensus()?; + let config = self.config.into_ckb()?; + let check = matches.get_flag(cli::ARG_MIGRATE_CHECK); + let force = matches.get_flag(cli::ARG_FORCE); + let include_background = matches.get_flag(cli::ARG_INCLUDE_BACKGROUND); + + Ok(MigrateArgs { + config, + consensus, + check, + force, + include_background, + }) + } + + /// Executes `ckb miner`. + pub fn miner(self, matches: &ArgMatches) -> Result { + let spec = self.chain_spec()?; + let memory_tracker = self.config.memory_tracker().to_owned(); + let config = self.config.into_miner()?; + let pow_engine = spec.pow_engine(); + let limit = *matches + .get_one::(cli::ARG_LIMIT) + .expect("has default value"); + + Ok(MinerArgs { + pow_engine, + config: config.miner, + memory_tracker, + limit, + }) + } + + /// Executes `ckb replay`. + pub fn replay(self, matches: &ArgMatches) -> Result { + let consensus = self.consensus()?; + let config = self.config.into_ckb()?; + let tmp_target = matches + .get_one::(cli::ARG_TMP_TARGET) + .ok_or_else(|| { + eprintln!("Args Error: {:?} no found", cli::ARG_TMP_TARGET); + ExitCode::Cli + })? + .clone(); + let profile = if matches.get_flag(cli::ARG_PROFILE) { + let from = matches.get_one::(cli::ARG_FROM).cloned(); + let to = matches.get_one::(cli::ARG_TO).cloned(); + Some((from, to)) + } else { + None + }; + let sanity_check = matches.get_flag(cli::ARG_SANITY_CHECK); + let full_verification = matches.get_flag(cli::ARG_FULL_VERIFICATION); + Ok(ReplayArgs { + config, + consensus, + tmp_target, + profile, + sanity_check, + full_verification, + }) + } + + /// Executes `ckb stats`. + pub fn stats(self, matches: &ArgMatches) -> Result { + let consensus = self.consensus()?; + let config = self.config.into_ckb()?; + + let from = matches.get_one::(cli::ARG_FROM).cloned(); + let to = matches.get_one::(cli::ARG_TO).cloned(); + + Ok(StatsArgs { + config, + consensus, + from, + to, + }) + } + + /// Executes `ckb import`. + pub fn import(self, matches: &ArgMatches) -> Result { + let consensus = self.consensus()?; + let config = self.config.into_ckb()?; + let source = matches + .get_one::(cli::ARG_SOURCE) + .ok_or_else(|| { + eprintln!("Args Error: {:?} no found", cli::ARG_SOURCE); + ExitCode::Cli + })? + .clone(); + + Ok(ImportArgs { + config, + consensus, + source, + }) + } + + /// Executes `ckb export`. + pub fn export(self, matches: &ArgMatches) -> Result { + let consensus = self.consensus()?; + let config = self.config.into_ckb()?; + let target = matches + .get_one::(cli::ARG_TARGET) + .ok_or_else(|| { + eprintln!("Args Error: {:?} no found", cli::ARG_TARGET); + ExitCode::Cli + })? + .clone(); + + Ok(ExportArgs { + config, + consensus, + target, + }) + } + + /// Executes `ckb daemon`. + #[cfg(not(target_os = "windows"))] + pub fn daemon(self, matches: &ArgMatches) -> Result { + let check = matches.get_flag(cli::ARG_DAEMON_CHECK); + let stop = matches.get_flag(cli::ARG_DAEMON_STOP); + let pid_file = Setup::daemon_pid_file_path(matches)?; + Ok(DaemonArgs { + check, + stop, + pid_file, + }) + } + + /// Executes `ckb init`. + pub fn init(matches: &ArgMatches) -> Result { + if matches.contains_id("list-specs") { + eprintln!( + "Deprecated: Option `--list-specs` is deprecated, use `--list-chains` instead" + ); + } + if matches.contains_id("spec") { + eprintln!("Deprecated: Option `--spec` is deprecated, use `--chain` instead"); + } + if matches.contains_id("export-specs") { + eprintln!("Deprecated: Option `--export-specs` is deprecated"); + } + + let root_dir = Self::root_dir_from_matches(matches)?; + let list_chains = + matches.get_flag(cli::ARG_LIST_CHAINS) || matches.contains_id("list-specs"); + let interactive = matches.get_flag(cli::ARG_INTERACTIVE); + let force = matches.get_flag(cli::ARG_FORCE); + let chain = if !matches.contains_id("spec") { + matches + .get_one::(cli::ARG_CHAIN) + .expect("has default value") + .to_string() + } else { + matches.get_one::("spec").unwrap().to_string() + }; + let rpc_port = matches + .get_one::(cli::ARG_RPC_PORT) + .expect("has default value") + .to_string(); + let p2p_port = matches + .get_one::(cli::ARG_P2P_PORT) + .expect("has default value") + .to_string(); + let (log_to_file, log_to_stdout) = match matches + .get_one::(cli::ARG_LOG_TO) + .map(|s| s.as_str()) + { + Some("file") => (true, false), + Some("stdout") => (false, true), + Some("both") => (true, true), + _ => unreachable!(), + }; + + let block_assembler_code_hash = matches.get_one::(cli::ARG_BA_CODE_HASH).cloned(); + let block_assembler_args: Vec<_> = matches + .get_many::(cli::ARG_BA_ARG) + .unwrap_or_default() + .map(|a| a.to_owned()) + .collect(); + let block_assembler_hash_type = matches + .get_one::(cli::ARG_BA_HASH_TYPE) + .and_then(|hash_type| serde_plain::from_str::(hash_type).ok()) + .expect("has default value"); + let block_assembler_message = matches.get_one::(cli::ARG_BA_MESSAGE).cloned(); + + let import_spec = matches.get_one::(cli::ARG_IMPORT_SPEC).cloned(); + + let customize_spec = { + let genesis_message = matches.get_one::(cli::ARG_GENESIS_MESSAGE).cloned(); + CustomizeSpec { genesis_message } + }; + + Ok(InitArgs { + interactive, + root_dir, + chain, + rpc_port, + p2p_port, + list_chains, + force, + log_to_file, + log_to_stdout, + block_assembler_code_hash, + block_assembler_args, + block_assembler_hash_type, + block_assembler_message, + import_spec, + customize_spec, + }) + } + + /// Executes `ckb reset-data`. + pub fn reset_data(self, matches: &ArgMatches) -> Result { + let config = self.config.into_ckb()?; + let data_dir = config.data_dir; + let db_path = config.db.path; + let indexer_path = config.indexer.store; + let rich_indexer_path = config + .indexer + .rich_indexer + .store + .parent() + .expect("rich-indexer store path should have parent dir") + .to_path_buf(); + let network_config = config.network; + let network_dir = network_config.path.clone(); + let network_peer_store_path = network_config.peer_store_path(); + let network_secret_key_path = network_config.secret_key_path(); + let logs_dir = Some(config.logger.log_dir); + + let force = matches.get_flag(cli::ARG_FORCE); + let all = matches.get_flag(cli::ARG_ALL); + let database = matches.get_flag(cli::ARG_DATABASE); + let indexer = matches.get_flag(cli::ARG_INDEXER); + let rich_indexer = matches.get_flag(cli::ARG_RICH_INDEXER); + let network = matches.get_flag(cli::ARG_NETWORK); + let network_peer_store = matches.get_flag(cli::ARG_NETWORK_PEER_STORE); + let network_secret_key = matches.get_flag(cli::ARG_NETWORK_SECRET_KEY); + let logs = matches.get_flag(cli::ARG_LOGS); + + Ok(ResetDataArgs { + force, + all, + database, + indexer, + rich_indexer, + network, + network_peer_store, + network_secret_key, + logs, + data_dir, + db_path, + indexer_path, + rich_indexer_path, + network_dir, + network_peer_store_path, + network_secret_key_path, + logs_dir, + }) + } + + /// Resolves the root directory for ckb from the command line arguments. + pub fn root_dir_from_matches(matches: &ArgMatches) -> Result { + let config_dir = match matches.get_one::(cli::ARG_CONFIG_DIR) { + Some(arg_config_dir) => PathBuf::from(arg_config_dir), + None => ::std::env::current_dir()?, + }; + std::fs::create_dir_all(&config_dir)?; + Ok(config_dir) + } + + /// Resolves the pid file path for ckb from the command line arguments. + #[cfg(not(target_os = "windows"))] + pub fn daemon_pid_file_path(matches: &ArgMatches) -> Result { + let root_dir = Self::root_dir_from_matches(matches)?; + Ok(root_dir.join("data/daemon/ckb-run.pid")) + } + + /// Loads the chain spec. + #[cfg(feature = "with_sentry")] + fn chain_spec(&self) -> Result { + let result = self.config.chain_spec(); + if let Ok(spec) = &result { + if self.is_sentry_enabled { + sentry::configure_scope(|scope| { + scope.set_tag("spec.name", &spec.name); + scope.set_tag("spec.pow", &spec.pow); + }); + } + } + + result + } + + #[cfg(not(feature = "with_sentry"))] + fn chain_spec(&self) -> Result { + self.config.chain_spec() + } + + /// Gets the consensus. + #[cfg(feature = "with_sentry")] + pub fn consensus(&self) -> Result { + let result = consensus_from_spec(&self.chain_spec()?); + + if let Ok(consensus) = &result { + if self.is_sentry_enabled { + sentry::configure_scope(|scope| { + scope.set_tag("genesis", consensus.genesis_hash()); + }); + } + } + + result + } + + /// Gets the consensus. + #[cfg(not(feature = "with_sentry"))] + pub fn consensus(&self) -> Result { + consensus_from_spec(&self.chain_spec()?) + } + + /// Gets the network peer id by reading the network secret key. + pub fn peer_id(matches: &ArgMatches) -> Result { + let path = matches + .get_one::(cli::ARG_SECRET_PATH) + .expect("required on command line"); + match read_secret_key(path.into()) { + Ok(Some(key)) => Ok(PeerIDArgs { + peer_id: key.peer_id(), + }), + Err(_) => Err(ExitCode::Failure), + Ok(None) => Err(ExitCode::IO), + } + } + + /// Generates the network secret key. + pub fn gen(matches: &ArgMatches) -> Result<(), ExitCode> { + let path = matches + .get_one::(cli::ARG_SECRET_PATH) + .expect("required on command line"); + write_secret_to_file(&generate_random_key(), path.into()).map_err(|_| ExitCode::IO) + } +} + +#[cfg(feature = "with_sentry")] +fn is_daemon(subcommand_name: &str) -> bool { + matches!(subcommand_name, cli::CMD_RUN | cli::CMD_MINER) +} + +fn consensus_from_spec(spec: &ChainSpec) -> Result { + spec.build_consensus().map_err(|err| { + eprintln!("chainspec error: {err}"); + ExitCode::Config + }) +} diff --git a/ckb-bin/src/setup_guard.rs b/ckb-bin/src/setup_guard.rs index 9fbe80de5a..c02d050e23 100644 --- a/ckb-bin/src/setup_guard.rs +++ b/ckb-bin/src/setup_guard.rs @@ -1,9 +1,11 @@ -use ckb_app_config::{ExitCode, Setup}; +use ckb_app_config::ExitCode; use ckb_async_runtime::Handle; use ckb_build_info::Version; use ckb_logger_service::{self, LoggerInitGuard}; use ckb_metrics_service::{self, Guard as MetricsInitGuard}; +use crate::setup::Setup; + const CKB_LOG_ENV: &str = "CKB_LOG"; pub struct SetupGuard { diff --git a/ckb-bin/src/subcommand/init.rs b/ckb-bin/src/subcommand/init.rs index 2cdcc13b26..b8a72905f8 100644 --- a/ckb-bin/src/subcommand/init.rs +++ b/ckb-bin/src/subcommand/init.rs @@ -3,7 +3,7 @@ use std::io::{self, Read}; use crate::helper::prompt; use base64::Engine; -use ckb_app_config::{cli, AppConfig, ExitCode, InitArgs}; +use ckb_app_config::{AppConfig, ExitCode, InitArgs}; use ckb_chain_spec::ChainSpec; use ckb_jsonrpc_types::ScriptHashType; use ckb_resource::{ @@ -12,6 +12,8 @@ use ckb_resource::{ }; use ckb_types::{prelude::*, H256}; +use crate::cli; + const DEFAULT_LOCK_SCRIPT_HASH_TYPE: &str = "type"; const SECP256K1_BLAKE160_SIGHASH_ALL_ARG_LEN: usize = 20 * 2 + 2; // 42 = 20 x 2 + prefix 0x diff --git a/ckb-bin/src/subcommand/list_hashes.rs b/ckb-bin/src/subcommand/list_hashes.rs index 62e431c10b..b241d92eef 100644 --- a/ckb-bin/src/subcommand/list_hashes.rs +++ b/ckb-bin/src/subcommand/list_hashes.rs @@ -1,4 +1,4 @@ -use ckb_app_config::{cli, CKBAppConfig, ExitCode}; +use ckb_app_config::{CKBAppConfig, ExitCode}; use ckb_chain_spec::ChainSpec; use ckb_resource::{Resource, AVAILABLE_SPECS}; use ckb_types::{packed::CellOutput, prelude::*, H256}; @@ -7,6 +7,8 @@ use clap::ArgMatches; use serde::{Deserialize, Serialize}; use std::path::PathBuf; +use crate::cli; + #[derive(Clone, Debug, Serialize, Deserialize)] struct SystemCell { pub path: String, diff --git a/util/app-config/src/tests/bats_tests/ckb_run_replay.bats b/ckb-bin/src/tests/bats_tests/ckb_run_replay.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/ckb_run_replay.bats rename to ckb-bin/src/tests/bats_tests/ckb_run_replay.bats diff --git a/util/app-config/src/tests/bats_tests/cli.bats b/ckb-bin/src/tests/bats_tests/cli.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/cli.bats rename to ckb-bin/src/tests/bats_tests/cli.bats diff --git a/util/app-config/src/tests/bats_tests/cli_test.sh b/ckb-bin/src/tests/bats_tests/cli_test.sh similarity index 92% rename from util/app-config/src/tests/bats_tests/cli_test.sh rename to ckb-bin/src/tests/bats_tests/cli_test.sh index bd5fc1318c..d25f3c8cfc 100755 --- a/util/app-config/src/tests/bats_tests/cli_test.sh +++ b/ckb-bin/src/tests/bats_tests/cli_test.sh @@ -31,9 +31,9 @@ git_clone_repo_with_retry() { trap cleanup EXIT cp target/prod/ckb ${CKB_BATS_TESTBED} -cp util/app-config/src/tests/bats_tests/*.bats ${CKB_BATS_TESTBED} -cp -r util/app-config/src/tests/bats_tests/later_bats_job ${CKB_BATS_TESTBED} -cp util/app-config/src/tests/bats_tests/*.sh ${CKB_BATS_TESTBED} +cp ckb-bin/src/tests/bats_tests/*.bats ${CKB_BATS_TESTBED} +cp -r ckb-bin/src/tests/bats_tests/later_bats_job ${CKB_BATS_TESTBED} +cp ckb-bin/src/tests/bats_tests/*.sh ${CKB_BATS_TESTBED} if [ ! -d "/tmp/ckb_bats_assets/" ]; then git_clone_repo_with_retry "main" "https://github.com/nervosnetwork/ckb-assets" "/tmp/ckb_bats_assets" diff --git a/util/app-config/src/tests/bats_tests/export_import.bats b/ckb-bin/src/tests/bats_tests/export_import.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/export_import.bats rename to ckb-bin/src/tests/bats_tests/export_import.bats diff --git a/util/app-config/src/tests/bats_tests/graceful_shutdown.bats b/ckb-bin/src/tests/bats_tests/graceful_shutdown.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/graceful_shutdown.bats rename to ckb-bin/src/tests/bats_tests/graceful_shutdown.bats diff --git a/util/app-config/src/tests/bats_tests/init_reset.bats b/ckb-bin/src/tests/bats_tests/init_reset.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/init_reset.bats rename to ckb-bin/src/tests/bats_tests/init_reset.bats diff --git a/util/app-config/src/tests/bats_tests/later_bats_job/change_epoch.bats b/ckb-bin/src/tests/bats_tests/later_bats_job/change_epoch.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/later_bats_job/change_epoch.bats rename to ckb-bin/src/tests/bats_tests/later_bats_job/change_epoch.bats diff --git a/util/app-config/src/tests/bats_tests/load_notify_config.bats b/ckb-bin/src/tests/bats_tests/load_notify_config.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/load_notify_config.bats rename to ckb-bin/src/tests/bats_tests/load_notify_config.bats diff --git a/util/app-config/src/tests/bats_tests/peer_id.bats b/ckb-bin/src/tests/bats_tests/peer_id.bats similarity index 100% rename from util/app-config/src/tests/bats_tests/peer_id.bats rename to ckb-bin/src/tests/bats_tests/peer_id.bats diff --git a/util/app-config/src/tests/cli.rs b/ckb-bin/src/tests/cli.rs similarity index 100% rename from util/app-config/src/tests/cli.rs rename to ckb-bin/src/tests/cli.rs diff --git a/ckb-bin/src/tests/mod.rs b/ckb-bin/src/tests/mod.rs new file mode 100644 index 0000000000..26710c101c --- /dev/null +++ b/ckb-bin/src/tests/mod.rs @@ -0,0 +1 @@ +mod cli; diff --git a/db-migration/Cargo.toml b/db-migration/Cargo.toml index 643f612f1c..ece14638d7 100644 --- a/db-migration/Cargo.toml +++ b/db-migration/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-db-migration" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,19 +11,19 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-db = { path = "../db", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-db-schema = { path = "../db-schema", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } +ckb-db = { path = "../db", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-db-schema = { path = "../db-schema", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } once_cell = "1.8.0" indicatif = "0.16" console = ">=0.9.1, <1.0.0" [dev-dependencies] tempfile.workspace = true -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } [features] portable = ["ckb-db/portable"] diff --git a/db-schema/Cargo.toml b/db-schema/Cargo.toml index 4f9662c68b..0b8ed3a658 100644 --- a/db-schema/Cargo.toml +++ b/db-schema/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-db-schema" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/db/Cargo.toml b/db/Cargo.toml index aa2cd8d448..3cc82c6507 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-db" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,12 +9,12 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } libc = "0.2" rocksdb = { package = "ckb-rocksdb", version ="=0.21.1", features = ["snappy"], default-features = false } -ckb-db-schema = { path = "../db-schema", version = "= 0.118.0" } +ckb-db-schema = { path = "../db-schema", version = "= 0.119.0" } [dev-dependencies] tempfile.workspace = true diff --git a/deny.toml b/deny.toml index fabff48ef2..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,20 +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" -#"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. @@ -99,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 @@ -118,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, @@ -137,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] @@ -151,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`. @@ -178,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 @@ -215,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/devtools/doc/rpc-gen/Cargo.toml b/devtools/doc/rpc-gen/Cargo.toml index e8c39cce05..c123b21009 100644 --- a/devtools/doc/rpc-gen/Cargo.toml +++ b/devtools/doc/rpc-gen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-rpc-gen" -version = "0.118.0" +version = "0.119.0" edition = "2021" license = "MIT" authors = ["Nervos Core Dev "] @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-rpc ={ path = "../../../rpc", version = "= 0.118.0" } +ckb-rpc ={ path = "../../../rpc", version = "= 0.119.0" } schemars = { version = "0.8.19", package = "ckb_schemars" } serde_json = "~1.0" tera = "1" diff --git a/error/Cargo.toml b/error/Cargo.toml index 78d0b586f3..57c74af566 100644 --- a/error/Cargo.toml +++ b/error/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-error" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,5 +11,5 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] thiserror = "1.0.22" anyhow = "1.0.34" -ckb-occupied-capacity = { path = "../util/occupied-capacity", version = "= 0.118.0" } +ckb-occupied-capacity = { path = "../util/occupied-capacity", version = "= 0.119.0" } derive_more = { version = "0.99.0", default-features = false, features = ["display"] } diff --git a/freezer/Cargo.toml b/freezer/Cargo.toml index 546f6315b1..7919d09b70 100644 --- a/freezer/Cargo.toml +++ b/freezer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-freezer" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -10,11 +10,11 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-metrics = { path = "../util/metrics", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-metrics = { path = "../util/metrics", version = "= 0.119.0" } fs2 = "0.4.3" fail = "0.4" snap = "1" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 5a167e23a9..b0f6b71de0 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-miner" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,23 +9,23 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-hash = { path = "../util/hash", version = "= 0.118.0" } -ckb-pow = { path = "../pow", version = "= 0.118.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-hash = { path = "../util/hash", version = "= 0.119.0" } +ckb-pow = { path = "../pow", version = "= 0.119.0" } rand = "0.8" rand_distr = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } hyper = { version = "0.14", features = ["client", "http2", "http1", "server"] } hyper-tls = "0.5" futures = "0.3" lru = "0.7.1" -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } indicatif = "0.16" console = ">=0.9.1, <1.0.0" eaglesong = "0.1" diff --git a/network/Cargo.toml b/network/Cargo.toml index 372264d612..d9f7b984de 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-network" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -12,28 +12,28 @@ exclude = ["fuzz"] [dependencies] rand = "0.8" serde = { version = "1.0", features = ["derive"] } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-metrics = { path = "../util/metrics", version = "= 0.118.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-metrics = { path = "../util/metrics", version = "= 0.119.0" } tokio = { version = "1", features = ["sync", "macros"] } tokio-util = { version = "0.7", features = ["codec"] } futures = "0.3" -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } lazy_static = { version = "1.3.0", optional = true } bs58 = { version = "0.4.0", optional = true } sentry = { version = "0.26.0", optional = true } faster-hex = { version = "0.6", optional = true } -ckb-hash = { path = "../util/hash", version = "= 0.118.0" } +ckb-hash = { path = "../util/hash", version = "= 0.119.0" } secp256k1 = { version = "0.29", features = ["recovery"], optional = true } trust-dns-resolver = { version = "0.20", optional = true } snap = "1" -ckb-types = { path = "../util/types", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } ipnetwork = "0.18" serde_json = "1.0" bloom-filters = "0.1" -ckb-spawn = { path = "../util/spawn", version = "= 0.118.0" } +ckb-spawn = { path = "../util/spawn", version = "= 0.119.0" } socket2 = "0.5" bitflags = "1.0" @@ -60,7 +60,7 @@ criterion = "0.5" proptest = "1.0" num_cpus = "1.10" once_cell = "1.8.0" -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0", features = [ +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0", features = [ "enable_faketime", ] } diff --git a/network/fuzz/Cargo.toml b/network/fuzz/Cargo.toml index 70d14380f9..f3bcf062d3 100644 --- a/network/fuzz/Cargo.toml +++ b/network/fuzz/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-network-fuzz" -version = "0.118.0" +version = "0.119.0" publish = false edition = "2021" license = "MIT" diff --git a/notify/Cargo.toml b/notify/Cargo.toml index 93b466d322..3d13ae5830 100644 --- a/notify/Cargo.toml +++ b/notify/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-notify" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,11 +9,11 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } tokio = { version = "1", features = ["sync"] } [dev-dependencies] diff --git a/pow/Cargo.toml b/pow/Cargo.toml index a4e8befbd3..aa6860beb3 100644 --- a/pow/Cargo.toml +++ b/pow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-pow" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -10,8 +10,8 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] byteorder = "1.3.1" -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-hash = { path = "../util/hash", version = "= 0.118.0"} +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-hash = { path = "../util/hash", version = "= 0.119.0"} serde = { version = "1.0", features = ["derive"] } eaglesong = "0.1" log = "0.4" diff --git a/resource/Cargo.toml b/resource/Cargo.toml index 10fc0999b7..5b3e468fb7 100644 --- a/resource/Cargo.toml +++ b/resource/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-resource" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -13,13 +13,13 @@ repository = "https://github.com/nervosnetwork/ckb" phf = "0.8.0" includedir = "0.6.0" serde = { version = "1.0", features = ["derive"] } -ckb-types = { path = "../util/types", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } ckb-system-scripts = { version = "= 0.5.4" } [build-dependencies] includedir_codegen = "0.6.0" walkdir = "2.1.4" -ckb-types = { path = "../util/types", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } ckb-system-scripts = { version = "= 0.5.4" } [dev-dependencies] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index bba88ae1fa..2c7f8ae9d5 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-rpc" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,38 +9,38 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-network = { path = "../network", version = "= 0.118.0" } -ckb-notify = { path = "../notify", version = "= 0.118.0" } -ckb-shared = { path = "../shared", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-sync = { path = "../sync", version = "= 0.118.0" } -ckb-chain = { path = "../chain", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-logger-service = { path = "../util/logger-service", version = "= 0.118.0" } -ckb-network-alert = { path = "../util/network-alert", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-constant = { path = "../util/constant", version = "= 0.118.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } +ckb-notify = { path = "../notify", version = "= 0.119.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-sync = { path = "../sync", version = "= 0.119.0" } +ckb-chain = { path = "../chain", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-logger-service = { path = "../util/logger-service", version = "= 0.119.0" } +ckb-network-alert = { path = "../util/network-alert", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-constant = { path = "../util/constant", version = "= 0.119.0" } jsonrpc-core = "18.0" serde_json = "1.0" jsonrpc-utils = { version = "0.2.6", features = ["server", "macros", "axum"] } -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } -ckb-verification = { path = "../verification", version = "= 0.118.0" } -ckb-verification-traits = { path = "../verification/traits", version = "= 0.118.0" } -ckb-traits = { path = "../traits", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } -ckb-dao = { path = "../util/dao", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.118.0" } -ckb-tx-pool = { path = "../tx-pool", version = "= 0.118.0" } -ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.118.0" } -ckb-pow = { path = "../pow", version = "= 0.118.0" } -ckb-indexer = { path = "../util/indexer", version = "= 0.118.0" } -ckb-indexer-sync = { path = "../util/indexer-sync", version = "= 0.118.0" } -ckb-rich-indexer = { path = "../util/rich-indexer", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } +ckb-verification = { path = "../verification", version = "= 0.119.0" } +ckb-verification-traits = { path = "../verification/traits", version = "= 0.119.0" } +ckb-traits = { path = "../traits", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } +ckb-dao = { path = "../util/dao", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.119.0" } +ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0" } +ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.119.0" } +ckb-pow = { path = "../pow", version = "= 0.119.0" } +ckb-indexer = { path = "../util/indexer", version = "= 0.119.0" } +ckb-indexer-sync = { path = "../util/indexer-sync", version = "= 0.119.0" } +ckb-rich-indexer = { path = "../util/rich-indexer", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } itertools.workspace = true tokio = "1" async-trait = "0.1" @@ -49,14 +49,14 @@ tokio-util = { version = "0.7.3", features = ["codec"] } futures-util = { version = "0.3.21" } tower-http = { version = "0.3.5", features = ["timeout", "cors"] } async-stream = "0.3.3" -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } # 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"] } serde = { version = "1.0", features = ["derive"] } -ckb-shared = { path = "../shared", version = "= 0.118.0" } -ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.118.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } +ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0" } tempfile.workspace = true pretty_assertions = "1.3.0" -ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.118.0" } +ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0" } diff --git a/rpc/src/tests/fee_rate.rs b/rpc/src/tests/fee_rate.rs index e4d41ebbef..e805334dc1 100644 --- a/rpc/src/tests/fee_rate.rs +++ b/rpc/src/tests/fee_rate.rs @@ -54,13 +54,12 @@ fn test_fee_rate_statics() { total_uncles_count: 0, verified: None, - // first element in txs_fees is belong to cellbase - txs_fees: vec![ - Capacity::shannons(i * 1234), - Capacity::shannons(i * i * 100), - ], - // first element in cycles is belong to cellbase - cycles: Some(vec![0, i * 100]), + // txs_fees length is equal to block_ext.cycles length + // and txs_fees does not include cellbase + txs_fees: vec![Capacity::shannons(i * i * 100)], + // cycles does not include cellbase + cycles: Some(vec![i * 100]), + // txs_sizes length is equal to block_ext.txs_fees length + 1 // first element in txs_sizes is belong to cellbase txs_sizes: Some(vec![i * 5678, i * 100]), }; diff --git a/rpc/src/util/fee_rate.rs b/rpc/src/util/fee_rate.rs index 2cea14ba15..fbb1086001 100644 --- a/rpc/src/util/fee_rate.rs +++ b/rpc/src/util/fee_rate.rs @@ -83,20 +83,16 @@ where target = std::cmp::min(self.provider.max_target(), target); let mut fee_rates = self.provider.collect(target, |mut fee_rates, block_ext| { - if block_ext.txs_fees.len() > 1 - && block_ext.cycles.is_some() - && block_ext.txs_sizes.is_some() - { - // block_ext.txs_fees, cycles, txs_sizes length is same + let txs_sizes = block_ext.txs_sizes.expect("expect txs_size's length >= 1"); + if txs_sizes.len() > 1 && block_ext.cycles.is_some() && !block_ext.txs_fees.is_empty() { + // block_ext.txs_fees's length == block_ext.cycles's length + // block_ext.txs_fees's length + 1 == txs_sizes's length for (fee, cycles, size) in itertools::izip!( block_ext.txs_fees, block_ext.cycles.expect("checked"), - block_ext.txs_sizes.expect("checked") - ) - // skip cellbase (first element in the Vec) - .skip(1) - { - let weight = get_transaction_weight(size as usize, cycles); + txs_sizes.iter().skip(1) // skip cellbase (first element in the Vec) + ) { + let weight = get_transaction_weight(*size as usize, cycles); if weight > 0 { fee_rates.push(FeeRate::calculate(fee, weight).as_u64()); } diff --git a/script/Cargo.toml b/script/Cargo.toml index a92de9db0a..2d6a40d4cb 100644 --- a/script/Cargo.toml +++ b/script/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-script" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -18,26 +18,26 @@ logging = ["ckb-logger"] flatmemory = [] [dependencies] -ckb-traits = { path = "../traits", version = "= 0.118.0" } +ckb-traits = { path = "../traits", version = "= 0.119.0" } byteorder = "1.3.1" -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-hash = { path = "../util/hash", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-hash = { path = "../util/hash", version = "= 0.119.0" } ckb-vm = { version = "= 0.24.12", default-features = false } faster-hex = "0.6" -ckb-logger = { path = "../util/logger", version = "= 0.118.0", optional = true } +ckb-logger = { path = "../util/logger", version = "= 0.119.0", optional = true } serde = { version = "1.0", features = ["derive"] } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } tokio = { version = "1.35.0", features = ["rt-multi-thread"] } [dev-dependencies] proptest = "1.0" -ckb-db = { path = "../db", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.118.0" } +ckb-db = { path = "../db", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0" } tiny-keccak = { version = "2.0", features = ["sha3"] } -ckb-crypto = { path = "../util/crypto", version = "= 0.118.0" } -ckb-db-schema = { path = "../db-schema", version = "= 0.118.0" } +ckb-crypto = { path = "../util/crypto", version = "= 0.119.0" } +ckb-db-schema = { path = "../db-schema", version = "= 0.119.0" } tempfile.workspace = true rand = "0.8.4" daggy = "0.8.0" diff --git a/script/fuzz/Cargo.toml b/script/fuzz/Cargo.toml index 65e8eb45b2..9fbda9ea35 100644 --- a/script/fuzz/Cargo.toml +++ b/script/fuzz/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-script-fuzz" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -15,10 +15,10 @@ cargo-fuzz = true [dependencies] arbitrary = { version = "1", features = ["derive"] } libfuzzer-sys = { version="0.4.0", features=["arbitrary-derive"] } -ckb-traits = { path = "../../traits", version = "= 0.118.0" } -ckb-types = { path = "../../util/types", version = "= 0.118.0" } -ckb-script = { path = "../../script", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } +ckb-traits = { path = "../../traits", version = "= 0.119.0" } +ckb-types = { path = "../../util/types", version = "= 0.119.0" } +ckb-script = { path = "../../script", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } # Prevent this from interfering with workspaces [workspace] diff --git a/script/src/scheduler.rs b/script/src/scheduler.rs index 3c93c0ee82..358acda0e5 100644 --- a/script/src/scheduler.rs +++ b/script/src/scheduler.rs @@ -462,7 +462,11 @@ where ); } Message::InheritedFileDescriptor(vm_id, args) => { - let inherited_fd = self.inherited_fd[&vm_id].clone(); + let inherited_fd = if vm_id == ROOT_VM_ID { + Vec::new() + } else { + self.inherited_fd[&vm_id].clone() + }; let (_, machine) = self.ensure_get_instantiated(&vm_id)?; let FdArgs { buffer_addr, diff --git a/script/src/types.rs b/script/src/types.rs index 6a3900bafe..728cb7aa55 100644 --- a/script/src/types.rs +++ b/script/src/types.rs @@ -5,7 +5,7 @@ use ckb_types::{ }; use ckb_vm::{ machine::{VERSION0, VERSION1, VERSION2}, - ISA_A, ISA_B, ISA_IMC, ISA_MOP, + ISA_B, ISA_IMC, ISA_MOP, }; use serde::{Deserialize, Serialize}; use std::fmt; @@ -81,7 +81,7 @@ impl ScriptVersion { match self { Self::V0 => ISA_IMC, Self::V1 => ISA_IMC | ISA_B | ISA_MOP, - Self::V2 => ISA_IMC | ISA_A | ISA_B | ISA_MOP, + Self::V2 => ISA_IMC | ISA_B | ISA_MOP, } } diff --git a/script/src/verify/tests/ckb_latest/features_since_v2023.rs b/script/src/verify/tests/ckb_latest/features_since_v2023.rs index 4cb4fd8583..d5eb783ca0 100644 --- a/script/src/verify/tests/ckb_latest/features_since_v2023.rs +++ b/script/src/verify/tests/ckb_latest/features_since_v2023.rs @@ -1235,6 +1235,12 @@ fn check_spawn_index_out_of_bound() { assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); } +#[test] +fn check_root_inherited_fds() { + let result = simple_spawn_test("testdata/spawn_cases", &[19]); + assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); +} + #[test] fn check_spawn_cycles() { let script_version = SCRIPT_VERSION; @@ -1265,7 +1271,7 @@ fn check_spawn_cycles() { let result = verifier.verify_without_limit(script_version, &rtx); assert_eq!(result.is_ok(), script_version >= ScriptVersion::V2); if script_version >= ScriptVersion::V2 { - assert_eq!(result.unwrap(), 1524861); + assert_eq!(result.unwrap(), 1525087); } } diff --git a/script/testdata/Makefile b/script/testdata/Makefile index 9db92fd549..22ffd1d0bf 100644 --- a/script/testdata/Makefile +++ b/script/testdata/Makefile @@ -14,8 +14,9 @@ COMMON_CFLAGS := -O3 \ -I deps/ckb-c-stdlib/libc \ -I deps/ckb-c-stdlib/molecule \ -Wall -Werror \ - -fno-builtin -nostdinc -nostartfiles \ - -Wno-stringop-overflow + -fno-builtin -nostdinc -nostartfiles \ + -Wno-stringop-overflow \ + -Wno-array-bounds # enable ckb-c-stdlib's printf COMMON_CFLAGS += -DCKB_C_STDLIB_PRINTF -DCKB_C_STDLIB_PRINTF_BUFFER_SIZE=1024 diff --git a/script/testdata/spawn_callee_exec_caller b/script/testdata/spawn_callee_exec_caller index 671dd0acd2..e49d3caaef 100755 Binary files a/script/testdata/spawn_callee_exec_caller and b/script/testdata/spawn_callee_exec_caller differ diff --git a/script/testdata/spawn_callee_strcat b/script/testdata/spawn_callee_strcat index 8f5d76ed3b..d480d3acd5 100755 Binary files a/script/testdata/spawn_callee_strcat and b/script/testdata/spawn_callee_strcat differ diff --git a/script/testdata/spawn_callee_strcat.c b/script/testdata/spawn_callee_strcat.c index 56daa801d8..07e7c76ba9 100644 --- a/script/testdata/spawn_callee_strcat.c +++ b/script/testdata/spawn_callee_strcat.c @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { size_t content_size = (uint64_t)strlen(content); uint64_t fds[2] = {0}; uint64_t length = countof(fds); - err = ckb_inherited_file_descriptors(fds, &length); + err = ckb_inherited_fds(fds, &length); CHECK(err); CHECK2(length == 2, ErrorCommon); size_t content_size2 = content_size; diff --git a/script/testdata/spawn_caller_current_cycles b/script/testdata/spawn_caller_current_cycles index d4d464dd27..22c07bcc7c 100755 Binary files a/script/testdata/spawn_caller_current_cycles and b/script/testdata/spawn_caller_current_cycles differ diff --git a/script/testdata/spawn_caller_out_of_cycles b/script/testdata/spawn_caller_out_of_cycles index 158c256802..1ec80d63ea 100755 Binary files a/script/testdata/spawn_caller_out_of_cycles and b/script/testdata/spawn_caller_out_of_cycles differ diff --git a/script/testdata/spawn_caller_strcat b/script/testdata/spawn_caller_strcat index f56aafa13f..2c556fab73 100755 Binary files a/script/testdata/spawn_caller_strcat and b/script/testdata/spawn_caller_strcat differ diff --git a/script/testdata/spawn_caller_strcat_wrap b/script/testdata/spawn_caller_strcat_wrap index 10aa1fa266..cd8c70cb06 100755 Binary files a/script/testdata/spawn_caller_strcat_wrap and b/script/testdata/spawn_caller_strcat_wrap differ diff --git a/script/testdata/spawn_cases b/script/testdata/spawn_cases index 2742af8b3e..c4acb37967 100755 Binary files a/script/testdata/spawn_cases and b/script/testdata/spawn_cases differ diff --git a/script/testdata/spawn_cases.c b/script/testdata/spawn_cases.c index 1729bf0bea..171164df03 100644 --- a/script/testdata/spawn_cases.c +++ b/script/testdata/spawn_cases.c @@ -33,7 +33,7 @@ int child_simple_read_write() { int err = 0; uint64_t inherited_fds[2]; size_t inherited_fds_length = 2; - err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + err = ckb_inherited_fds(inherited_fds, &inherited_fds_length); // read for (size_t i = 0; i < 11; i++) { uint8_t block[7] = {0}; @@ -76,7 +76,7 @@ int child_write_dead_lock() { int err = 0; uint64_t inherited_fds[3] = {0}; size_t inherited_fds_length = 3; - err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + err = ckb_inherited_fds(inherited_fds, &inherited_fds_length); CHECK(err); uint8_t data[10]; size_t data_length = sizeof(data); @@ -174,7 +174,7 @@ int child_read_write_with_close() { int err = 0; uint64_t inherited_fds[2]; size_t inherited_fds_length = 2; - err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + err = ckb_inherited_fds(inherited_fds, &inherited_fds_length); CHECK(err); // read 100 bytes and close @@ -235,20 +235,20 @@ int child_inherited_fds() { // correct way to get fd length size_t fds_length = 0; - err = ckb_inherited_file_descriptors(0, &fds_length); + err = ckb_inherited_fds(0, &fds_length); CHECK2(fds_length == 10, -2); // get part of fds uint64_t fds[11] = {0}; fds_length = 1; - err = ckb_inherited_file_descriptors(fds, &fds_length); + err = ckb_inherited_fds(fds, &fds_length); CHECK(err); CHECK2(fds_length == 10, -2); CHECK2(fds[0] == 2, -2); // get all fds fds_length = 10; - err = ckb_inherited_file_descriptors(fds, &fds_length); + err = ckb_inherited_fds(fds, &fds_length); CHECK(err); CHECK2(fds_length == 10, -2); for (size_t i = 0; i < 10; i++) { @@ -298,7 +298,7 @@ int child_read_then_close() { int err = 0; uint64_t fds[2] = {0}; uint64_t fds_length = 2; - err = ckb_inherited_file_descriptors(fds, &fds_length); + err = ckb_inherited_fds(fds, &fds_length); CHECK(err); uint8_t data[8]; size_t data_len = sizeof(data); @@ -404,7 +404,7 @@ int child_write_closed_fd() { int err = 0; uint64_t inherited_fds[2]; size_t inherited_fds_length = 2; - err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + err = ckb_inherited_fds(inherited_fds, &inherited_fds_length); CHECK(err); uint8_t block[7] = {0}; @@ -459,7 +459,7 @@ int child_pid() { int err = 0; uint64_t fds[2] = {0}; uint64_t fds_length = 2; - err = ckb_inherited_file_descriptors(fds, &fds_length); + err = ckb_inherited_fds(fds, &fds_length); CHECK(err); // send pid @@ -491,7 +491,7 @@ int parent_spawn_length_out_of_bound(uint64_t* pid) { const char* argv[] = {"", 0}; spawn_args_t spgs = {.argc = 1, .argv = argv, .process_id = pid, .inherited_fds = NULL}; - uint64_t offset = 1024 * 15; + uint64_t offset = 1024 * 17; uint64_t length = 1024; uint64_t bounds = (offset << 32) + length; @@ -536,6 +536,17 @@ int parent_index_out_of_bound(uint64_t* pid) { return err; } +int parent_root_inherited_fds() { + uint64_t fds[2] = {0}; + uint64_t length = 2; + int err = ckb_inherited_fds(fds, &length); + CHECK(err); + CHECK2(length == 0, -1); + err = 0; +exit: + return err; +} + int parent_entry(int case_id) { int err = 0; uint64_t pid = 0; @@ -577,6 +588,8 @@ int parent_entry(int case_id) { return parent_invaild_index(&pid); } else if (case_id == 18) { return parent_index_out_of_bound(&pid); + } else if (case_id == 19) { + return parent_root_inherited_fds(); } else { CHECK2(false, -2); } diff --git a/script/testdata/spawn_configurable_callee b/script/testdata/spawn_configurable_callee index 20b1024ecd..df6ab63772 100755 Binary files a/script/testdata/spawn_configurable_callee and b/script/testdata/spawn_configurable_callee differ diff --git a/script/testdata/spawn_configurable_callee.c b/script/testdata/spawn_configurable_callee.c index 92b849b35b..019f304868 100644 --- a/script/testdata/spawn_configurable_callee.c +++ b/script/testdata/spawn_configurable_callee.c @@ -9,7 +9,7 @@ int main() { uint64_t fds[2] = {0}; uint64_t fds_len = countof(fds); - err = ckb_inherited_file_descriptors(fds, &fds_len); + err = ckb_inherited_fds(fds, &fds_len); CHECK(err); CHECK2(fds_len == 2, ErrorCommon); diff --git a/script/testdata/spawn_configurable_caller b/script/testdata/spawn_configurable_caller index f1620466f9..72c04e613c 100755 Binary files a/script/testdata/spawn_configurable_caller and b/script/testdata/spawn_configurable_caller differ diff --git a/script/testdata/spawn_cycles b/script/testdata/spawn_cycles index 77d40c54fe..83f88f4df0 100755 Binary files a/script/testdata/spawn_cycles and b/script/testdata/spawn_cycles differ diff --git a/script/testdata/spawn_cycles.c b/script/testdata/spawn_cycles.c index a338d73d4b..6b8dcec067 100644 --- a/script/testdata/spawn_cycles.c +++ b/script/testdata/spawn_cycles.c @@ -155,7 +155,7 @@ int main() { case 4: len = 2; toc = tic(); - err = ckb_inherited_file_descriptors(fds[cid][1], &len); + err = ckb_inherited_fds(fds[cid][1], &len); CHECK(err); toc = tic(); CHECK2(toc > cal_cycles_floor(1, 1, 0), ErrorCommon); diff --git a/script/testdata/spawn_dag b/script/testdata/spawn_dag index b88dedb7fd..10648d6abd 100755 Binary files a/script/testdata/spawn_dag and b/script/testdata/spawn_dag differ diff --git a/script/testdata/spawn_fuzzing b/script/testdata/spawn_fuzzing index 0c1602e09a..8110861896 100755 Binary files a/script/testdata/spawn_fuzzing and b/script/testdata/spawn_fuzzing differ diff --git a/script/testdata/spawn_fuzzing.c b/script/testdata/spawn_fuzzing.c index 7702717c0a..c93a31751b 100644 --- a/script/testdata/spawn_fuzzing.c +++ b/script/testdata/spawn_fuzzing.c @@ -97,7 +97,7 @@ int child_entry() { int err = 0; uint64_t inherited_fds[2]; size_t inherited_fds_length = 2; - err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + err = ckb_inherited_fds(inherited_fds, &inherited_fds_length); CHECK(err); random_read_write(inherited_fds, 0); diff --git a/script/testdata/spawn_huge_swap.c b/script/testdata/spawn_huge_swap.c index 2666857631..8376a45cc1 100644 --- a/script/testdata/spawn_huge_swap.c +++ b/script/testdata/spawn_huge_swap.c @@ -32,7 +32,7 @@ int main() { } else if (current_pid == 1) { uint64_t inherited_fds[3]; size_t fds_len = 3; - err = ckb_inherited_file_descriptors(inherited_fds, &fds_len); + err = ckb_inherited_fds(inherited_fds, &fds_len); CHECK(err); uint8_t buf[1] = {0}; while (true) { @@ -43,7 +43,7 @@ int main() { } else if (current_pid == 2) { uint64_t inherited_fds[3]; size_t fds_len = 3; - err = ckb_inherited_file_descriptors(inherited_fds, &fds_len); + err = ckb_inherited_fds(inherited_fds, &fds_len); CHECK(err); uint8_t buf[1] = {0}; while (true) { @@ -62,4 +62,4 @@ int main() { exit: return err; -} \ No newline at end of file +} diff --git a/script/testdata/spawn_io_cycles b/script/testdata/spawn_io_cycles index e77022ac8b..83a7aaea7c 100755 Binary files a/script/testdata/spawn_io_cycles and b/script/testdata/spawn_io_cycles differ diff --git a/script/testdata/spawn_io_cycles.c b/script/testdata/spawn_io_cycles.c index e58151f4d8..c250b3477f 100644 --- a/script/testdata/spawn_io_cycles.c +++ b/script/testdata/spawn_io_cycles.c @@ -42,7 +42,7 @@ int child(ScriptArgs* args, uint8_t* buffer) { int err = 0; uint64_t inherited_fds[2]; size_t inherited_fds_length = 2; - err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + err = ckb_inherited_fds(inherited_fds, &inherited_fds_length); CHECK(err); uint64_t buf_len = args->io_size; diff --git a/script/testdata/spawn_recursive b/script/testdata/spawn_recursive index 80d777b5be..500c26dd55 100755 Binary files a/script/testdata/spawn_recursive and b/script/testdata/spawn_recursive differ diff --git a/script/testdata/spawn_saturate_memory b/script/testdata/spawn_saturate_memory index 08e51f96c8..ef1cd12cd8 100755 Binary files a/script/testdata/spawn_saturate_memory and b/script/testdata/spawn_saturate_memory differ diff --git a/script/testdata/spawn_saturate_memory.c b/script/testdata/spawn_saturate_memory.c index de977b10db..545671ab23 100644 --- a/script/testdata/spawn_saturate_memory.c +++ b/script/testdata/spawn_saturate_memory.c @@ -21,7 +21,7 @@ int main(int argc, const char* argv[]) { dirty_all_pages(); uint64_t inherited_fds[2]; size_t inherited_fds_length = 2; - err = ckb_inherited_file_descriptors(inherited_fds, &inherited_fds_length); + err = ckb_inherited_fds(inherited_fds, &inherited_fds_length); uint64_t length = MAX_MEMORY; // Write a piece of data starting from address 0 with a size of 4M. // It should not consume any memory. diff --git a/script/testdata/spawn_times b/script/testdata/spawn_times index 0eed0c30ae..b6fe69fad9 100755 Binary files a/script/testdata/spawn_times and b/script/testdata/spawn_times differ diff --git a/shared/Cargo.toml b/shared/Cargo.toml index fd2b82ddbe..9d5c1810b1 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-shared" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,29 +9,29 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-db = { path = "../db", version = "= 0.118.0" } -ckb-proposal-table = { path = "../util/proposal-table", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-db = { path = "../db", version = "= 0.119.0" } +ckb-proposal-table = { path = "../util/proposal-table", version = "= 0.119.0" } arc-swap = "1.3" -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-snapshot = { path = "../util/snapshot", version = "= 0.118.0" } -ckb-tx-pool = { path = "../tx-pool", version = "= 0.118.0" } -ckb-verification = { path = "../verification", version = "= 0.118.0" } -ckb-notify = { path = "../notify", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-db-schema = { path = "../db-schema", version = "= 0.118.0" } -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } -ckb-constant = { path = "../util/constant", version = "= 0.118.0" } -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-migrate = { path = "../util/migrate", version = "= 0.118.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-snapshot = { path = "../util/snapshot", version = "= 0.119.0" } +ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0" } +ckb-verification = { path = "../verification", version = "= 0.119.0" } +ckb-notify = { path = "../notify", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-db-schema = { path = "../db-schema", version = "= 0.119.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } +ckb-constant = { path = "../util/constant", version = "= 0.119.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-migrate = { path = "../util/migrate", version = "= 0.119.0" } once_cell = "1.8.0" -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-metrics = { path = "../util/metrics", version = "= 0.118.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-metrics = { path = "../util/metrics", version = "= 0.119.0" } bitflags = "1.0" tokio = { version = "1", features = ["sync"] } tempfile.workspace = true @@ -39,7 +39,7 @@ sled = "0.34.7" dashmap = "4.0" [dev-dependencies] -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0", features = ["enable_faketime"] } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0", features = ["enable_faketime"] } [features] portable = ["ckb-db/portable", "ckb-store/portable", "ckb-tx-pool/portable", "ckb-migrate/portable"] diff --git a/spec/Cargo.toml b/spec/Cargo.toml index 1c31854070..d1aef9fb74 100644 --- a/spec/Cargo.toml +++ b/spec/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-chain-spec" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -12,18 +12,18 @@ repository = "https://github.com/nervosnetwork/ckb" serde = { version = "1.0", features = ["derive"] } toml = "0.5" cacache = { version = "12.0.0", default-features = false, features = ["tokio-runtime", "mmap"] } -ckb-constant = { path = "../util/constant", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-pow = { path = "../pow", version = "= 0.118.0" } -ckb-resource = { path = "../resource", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } -ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.118.0" } -ckb-rational = { path = "../util/rational", version = "= 0.118.0" } -ckb-crypto = { path = "../util/crypto", version = "= 0.118.0"} -ckb-hash = { path = "../util/hash", version = "= 0.118.0"} -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-traits = { path = "../traits", version = "= 0.118.0" } -ckb-logger = {path = "../util/logger", version = "= 0.118.0"} +ckb-constant = { path = "../util/constant", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-pow = { path = "../pow", version = "= 0.119.0" } +ckb-resource = { path = "../resource", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } +ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0" } +ckb-rational = { path = "../util/rational", version = "= 0.119.0" } +ckb-crypto = { path = "../util/crypto", version = "= 0.119.0"} +ckb-hash = { path = "../util/hash", version = "= 0.119.0"} +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-traits = { path = "../traits", version = "= 0.119.0" } +ckb-logger = {path = "../util/logger", version = "= 0.119.0"} [dev-dependencies] diff --git a/store/Cargo.toml b/store/Cargo.toml index 9bec72af3d..d01517c75b 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-store" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,16 +9,16 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-db = { path = "../db", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-db = { path = "../db", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } lru = "0.7.1" -ckb-traits = { path = "../traits", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-db-schema = { path = "../db-schema", version = "= 0.118.0" } -ckb-freezer = { path = "../freezer", version = "= 0.118.0" } +ckb-traits = { path = "../traits", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-db-schema = { path = "../db-schema", version = "= 0.119.0" } +ckb-freezer = { path = "../freezer", version = "= 0.119.0" } ckb-merkle-mountain-range = "0.5.2" [dev-dependencies] diff --git a/sync/Cargo.toml b/sync/Cargo.toml index c2ae3d2879..9a24513d0a 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-sync" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,51 +9,51 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-chain = { path = "../chain", version = "= 0.118.0" } -ckb-shared = { path = "../shared", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-network = { path = "../network", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-metrics = { path = "../util/metrics", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-verification = { path = "../verification", version = "= 0.118.0" } -ckb-verification-traits = { path = "../verification/traits", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-traits = { path = "../traits", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-tx-pool = { path = "../tx-pool", version = "= 0.118.0" } +ckb-chain = { path = "../chain", version = "= 0.119.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-metrics = { path = "../util/metrics", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-verification = { path = "../verification", version = "= 0.119.0" } +ckb-verification-traits = { path = "../verification/traits", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-traits = { path = "../traits", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-tx-pool = { path = "../tx-pool", version = "= 0.119.0" } sentry = { version = "0.26.0", optional = true } -ckb-constant = { path = "../util/constant", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } +ckb-constant = { path = "../util/constant", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } tokio = { version = "1", features = ["sync"] } lru = "0.7.1" futures = "0.3" governor = "0.3.1" tempfile.workspace = true -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } dashmap = "4.0" keyed_priority_queue = "0.3" itertools.workspace = true [dev-dependencies] -ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.118.0" } +ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0" } rand = "0.8" -ckb-dao = { path = "../util/dao", version = "= 0.118.0" } -ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.118.0" } -ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.118.0" } -ckb-chain = { path = "../chain", version = "= 0.118.0", features = [ +ckb-dao = { path = "../util/dao", version = "= 0.119.0" } +ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0" } +ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.119.0" } +ckb-chain = { path = "../chain", version = "= 0.119.0", features = [ "mock", ] } faux = "^0.1" once_cell = "1.8.0" -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0", features = [ +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0", features = [ "enable_faketime", ] } -ckb-proposal-table = { path = "../util/proposal-table", version = "= 0.118.0" } -ckb-logger-service = { path = "../util/logger-service", version = "= 0.118.0" } +ckb-proposal-table = { path = "../util/proposal-table", version = "= 0.119.0" } +ckb-logger-service = { path = "../util/logger-service", version = "= 0.119.0" } [features] default = [] diff --git a/test/Cargo.toml b/test/Cargo.toml index da12acfbb6..22561fca02 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-test" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,31 +11,31 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] clap = { version = "=3.2.21" } toml = "0.5.0" -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-network = { path = "../network", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-hash = { path = "../util/hash", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-crypto = { path = "../util/crypto", version = "= 0.118.0" } -ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.118.0" } -ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.118.0" } -ckb-resource = { path = "../resource", version = "= 0.118.0" } -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-logger-config = { path = "../util/logger-config", version = "= 0.118.0" } -ckb-logger-service = { path = "../util/logger-service", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } -ckb-constant = { path = "../util/constant", version = "= 0.118.0" } -ckb-db = { path = "../db", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-shared = { path = "../shared", version = "= 0.118.0" } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-hash = { path = "../util/hash", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-crypto = { path = "../util/crypto", version = "= 0.119.0" } +ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0" } +ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0" } +ckb-resource = { path = "../resource", version = "= 0.119.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-logger-config = { path = "../util/logger-config", version = "= 0.119.0" } +ckb-logger-service = { path = "../util/logger-service", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } +ckb-constant = { path = "../util/constant", version = "= 0.119.0" } +ckb-db = { path = "../db", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-shared = { path = "../shared", version = "= 0.119.0" } tempfile = "3" reqwest = { version = "=0.11.20", features = ["blocking", "json"] } rand = "0.8" -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } serde_json = "1.0" lazy_static = "1.4.0" byteorder = "1.3.1" diff --git a/traits/Cargo.toml b/traits/Cargo.toml index dc84072881..d161f0a717 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-traits" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,4 +9,4 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../util/types", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } diff --git a/tx-pool/Cargo.toml b/tx-pool/Cargo.toml index 3c1f5e8c6f..a784b58201 100644 --- a/tx-pool/Cargo.toml +++ b/tx-pool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-tx-pool" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,31 +11,31 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-logger = { path = "../util/logger", version = "= 0.118.0" } -ckb-verification = { path = "../verification", version = "= 0.118.0" } -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-logger = { path = "../util/logger", version = "= 0.119.0" } +ckb-verification = { path = "../verification", version = "= 0.119.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } lru = "0.7.1" num_cpus = "1.16.0" -ckb-dao = { path = "../util/dao", version = "= 0.118.0" } -ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.118.0" } -ckb-store = { path = "../store", version = "= 0.118.0" } -ckb-util = { path = "../util", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-snapshot = { path = "../util/snapshot", version = "= 0.118.0" } -ckb-metrics = {path = "../util/metrics", version = "= 0.118.0"} -ckb-error = { path = "../error", version = "= 0.118.0" } +ckb-dao = { path = "../util/dao", version = "= 0.119.0" } +ckb-reward-calculator = { path = "../util/reward-calculator", version = "= 0.119.0" } +ckb-store = { path = "../store", version = "= 0.119.0" } +ckb-util = { path = "../util", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-snapshot = { path = "../util/snapshot", version = "= 0.119.0" } +ckb-metrics = {path = "../util/metrics", version = "= 0.119.0"} +ckb-error = { path = "../error", version = "= 0.119.0" } tokio = { version = "1", features = ["sync", "process"] } -ckb-async-runtime = { path = "../util/runtime", version = "= 0.118.0" } -ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.118.0" } -ckb-app-config = { path = "../util/app-config", version = "= 0.118.0" } -ckb-network = { path = "../network", version = "= 0.118.0" } -ckb-channel = { path = "../util/channel", version = "= 0.118.0" } -ckb-traits = { path = "../traits", version = "= 0.118.0" } -ckb-db = { path = "../db", version = "= 0.118.0" } -ckb-script = { path = "../script", version = "= 0.118.0" } +ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0" } +ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0" } +ckb-app-config = { path = "../util/app-config", version = "= 0.119.0" } +ckb-network = { path = "../network", version = "= 0.119.0" } +ckb-channel = { path = "../util/channel", version = "= 0.119.0" } +ckb-traits = { path = "../traits", version = "= 0.119.0" } +ckb-db = { path = "../db", version = "= 0.119.0" } +ckb-script = { path = "../script", version = "= 0.119.0" } sentry = { version = "0.26.0", optional = true } serde_json = "1.0" rand = "0.8.4" @@ -47,8 +47,8 @@ tokio-util = "0.7.8" [dev-dependencies] tempfile.workspace = true -ckb-hash = { path = "../util/hash", version = "= 0.118.0" } -ckb-systemtime = {path = "../util/systemtime", version = "= 0.118.0", features = ["enable_faketime"]} +ckb-hash = { path = "../util/hash", version = "= 0.119.0" } +ckb-systemtime = {path = "../util/systemtime", version = "= 0.119.0", features = ["enable_faketime"]} [features] default = [] diff --git a/tx-pool/src/component/orphan.rs b/tx-pool/src/component/orphan.rs index d73132bc81..ee92918bae 100644 --- a/tx-pool/src/component/orphan.rs +++ b/tx-pool/src/component/orphan.rs @@ -75,9 +75,13 @@ impl OrphanPool { self.entries.remove(id).map(|entry| { debug!("remove orphan tx {}", entry.tx.hash()); for out_point in entry.tx.input_pts_iter() { - self.by_out_point - .get_mut(&out_point) - .map(|set| set.remove(id)); + if let Some(ids_set) = self.by_out_point.get_mut(&out_point) { + ids_set.remove(id); + + if ids_set.is_empty() { + self.by_out_point.remove(&out_point); + } + } } entry }) diff --git a/util/Cargo.toml b/util/Cargo.toml index e7927a060d..3d9c2c6dc8 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-util" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -15,7 +15,7 @@ regex = "1.1.6" once_cell = "1.8.0" [dev-dependencies] -ckb-fixed-hash = { path = "fixed-hash", version = "= 0.118.0" } +ckb-fixed-hash = { path = "fixed-hash", version = "= 0.119.0" } [features] deadlock_detection = ["parking_lot/deadlock_detection"] diff --git a/util/app-config/Cargo.toml b/util/app-config/Cargo.toml index a554f4c610..2c828850a4 100644 --- a/util/app-config/Cargo.toml +++ b/util/app-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-app-config" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,27 +9,24 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -clap = { version = "=4.4", features = ["string", "wrap_help"] } serde = { version = "1.0", features = ["derive"] } -serde_plain = "0.3.0" serde_json = "1.0" toml = "0.5" path-clean = "0.1.0" -ckb-logger = { path = "../../util/logger", version = "= 0.118.0" } -ckb-logger-config = { path = "../../util/logger-config", version = "= 0.118.0" } -ckb-metrics-config = { path = "../../util/metrics-config", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } -ckb-pow = { path = "../../pow", version = "= 0.118.0" } -ckb-resource = { path = "../../resource", version = "= 0.118.0" } -ckb-build-info = { path = "../build-info", version = "= 0.118.0" } -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-constant = { path = "../constant", version = "= 0.118.0" } +ckb-logger = { path = "../../util/logger", version = "= 0.119.0" } +ckb-logger-config = { path = "../../util/logger-config", version = "= 0.119.0" } +ckb-metrics-config = { path = "../../util/metrics-config", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } +ckb-pow = { path = "../../pow", version = "= 0.119.0" } +ckb-resource = { path = "../../resource", version = "= 0.119.0" } +ckb-build-info = { path = "../build-info", version = "= 0.119.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } 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 } -ckb-systemtime = { path = "../systemtime", version = "= 0.118.0" } +ckb-systemtime = { path = "../systemtime", version = "= 0.119.0" } url = { version = "2.2.2", features = ["serde"] } ubyte = { version = "0.10", features = ["serde"] } @@ -38,6 +35,6 @@ with_sentry = ["sentry"] [dev-dependencies] tempfile.workspace = true -ckb-systemtime = { path = "../systemtime", version = "= 0.118.0", features = [ +ckb-systemtime = { path = "../systemtime", version = "= 0.119.0", features = [ "enable_faketime", ] } diff --git a/util/app-config/src/cli.rs b/util/app-config/src/cli.rs index 4a31dd93a8..59df6d15a0 100644 --- a/util/app-config/src/cli.rs +++ b/util/app-config/src/cli.rs @@ -1,658 +1,10 @@ //! CKB command line arguments parser. -use ckb_build_info::Version; -use ckb_resource::{AVAILABLE_SPECS, DEFAULT_P2P_PORT, DEFAULT_RPC_PORT, DEFAULT_SPEC}; -use clap::{Arg, ArgGroup, ArgMatches, Command}; /// binary file name(ckb) pub const BIN_NAME: &str = "ckb"; - -/// Subcommand `run`. -pub const CMD_RUN: &str = "run"; /// Subcommand `miner`. pub const CMD_MINER: &str = "miner"; -/// Subcommand `export`. -pub const CMD_EXPORT: &str = "export"; -/// Subcommand `import`. -pub const CMD_IMPORT: &str = "import"; -/// Subcommand `init`. -pub const CMD_INIT: &str = "init"; -/// Subcommand `replay`. -pub const CMD_REPLAY: &str = "replay"; -/// Subcommand `stats`. -pub const CMD_STATS: &str = "stats"; -/// Subcommand `list-hashes`. -pub const CMD_LIST_HASHES: &str = "list-hashes"; /// Subcommand `reset-data`. pub const CMD_RESET_DATA: &str = "reset-data"; -/// Subcommand `peer-id`. -pub const CMD_PEERID: &str = "peer-id"; -/// Subcommand `gen`. -pub const CMD_GEN_SECRET: &str = "gen"; -/// Subcommand `from-secret`. -pub const CMD_FROM_SECRET: &str = "from-secret"; -/// Subcommand `migrate`. -pub const CMD_MIGRATE: &str = "migrate"; -/// Subcommand `daemon` -pub const CMD_DAEMON: &str = "daemon"; -/// Command line argument `--config-dir`. -pub const ARG_CONFIG_DIR: &str = "config-dir"; -/// Command line argument `--format`. -pub const ARG_FORMAT: &str = "format"; -/// Command line argument `--target`. -pub const ARG_TARGET: &str = "target"; -/// Command line argument `--source`. -pub const ARG_SOURCE: &str = "source"; -/// Command line argument `--data`. -pub const ARG_DATA: &str = "data"; -/// Command line argument `--list-chains`. -pub const ARG_LIST_CHAINS: &str = "list-chains"; -/// Command line argument `--interactive`. -pub const ARG_INTERACTIVE: &str = "interactive"; -/// Command line argument `--chain`. -pub const ARG_CHAIN: &str = "chain"; -/// Command line argument `--import-spec`. -pub const ARG_IMPORT_SPEC: &str = "import-spec"; -/// The argument for the genesis message. -pub const ARG_GENESIS_MESSAGE: &str = "genesis-message"; -/// Command line argument `--p2p-port`. -pub const ARG_P2P_PORT: &str = "p2p-port"; -/// Command line argument `--rpc-port`. -pub const ARG_RPC_PORT: &str = "rpc-port"; -/// Command line argument `--force`. -pub const ARG_FORCE: &str = "force"; -/// Command line argument `--include-background`. -pub const ARG_INCLUDE_BACKGROUND: &str = "include-background"; -/// Command line argument `--log-to`. -pub const ARG_LOG_TO: &str = "log-to"; -/// Command line argument `--bundled`. -pub const ARG_BUNDLED: &str = "bundled"; -/// Command line argument `--ba-code-hash`. -pub const ARG_BA_CODE_HASH: &str = "ba-code-hash"; -/// Command line argument `--ba-arg`. -pub const ARG_BA_ARG: &str = "ba-arg"; -/// Command line argument `--ba-hash-type`. -pub const ARG_BA_HASH_TYPE: &str = "ba-hash-type"; -/// Command line argument `--ba-message`. -pub const ARG_BA_MESSAGE: &str = "ba-message"; -/// Command line argument `--ba-advanced`. -pub const ARG_BA_ADVANCED: &str = "ba-advanced"; -/// Command line argument `--daemon` -pub const ARG_DAEMON: &str = "daemon"; -/// Command line argument `--indexer`. -pub const ARG_INDEXER: &str = "indexer"; -/// Command line argument `--rich-indexer`. -pub const ARG_RICH_INDEXER: &str = "rich-indexer"; -/// Command line argument `--from`. -pub const ARG_FROM: &str = "from"; -/// Command line argument `--to`. -pub const ARG_TO: &str = "to"; -/// Command line argument `--all`. -pub const ARG_ALL: &str = "all"; -/// Command line argument `--limit`. -pub const ARG_LIMIT: &str = "limit"; -/// Command line argument `--database`. -pub const ARG_DATABASE: &str = "database"; -/// Command line argument `--network`. -pub const ARG_NETWORK: &str = "network"; -/// Command line argument `--network-peer-store`. -pub const ARG_NETWORK_PEER_STORE: &str = "network-peer-store"; -/// Command line argument `--network-secret-key`. -pub const ARG_NETWORK_SECRET_KEY: &str = "network-secret-key"; -/// Command line argument `--logs`. -pub const ARG_LOGS: &str = "logs"; -/// Command line argument `--tmp-target`. -pub const ARG_TMP_TARGET: &str = "tmp-target"; -/// Command line argument `--secret-path`. -pub const ARG_SECRET_PATH: &str = "secret-path"; -/// Command line argument `--profile`. -pub const ARG_PROFILE: &str = "profile"; -/// Command line argument `--sanity-check`. -pub const ARG_SANITY_CHECK: &str = "sanity-check"; -/// Command line argument `--full-verification`. -pub const ARG_FULL_VERIFICATION: &str = "full-verification"; -/// Command line argument `--skip-spec-check`. -pub const ARG_SKIP_CHAIN_SPEC_CHECK: &str = "skip-spec-check"; -/// Present `overwrite-spec` arg to force overriding the chain spec in the database with the present configured chain spec -pub const ARG_OVERWRITE_CHAIN_SPEC: &str = "overwrite-spec"; -/// Command line argument `--assume-valid-target`. -pub const ARG_ASSUME_VALID_TARGET: &str = "assume-valid-target"; -/// Command line argument `--check`. -pub const ARG_MIGRATE_CHECK: &str = "check"; -/// Command line argument `daemon --check` -pub const ARG_DAEMON_CHECK: &str = "check"; -/// Command line argument `daemon --stop` -pub const ARG_DAEMON_STOP: &str = "stop"; - -/// Command line arguments group `ba` for block assembler. -const GROUP_BA: &str = "ba"; - -/// return root clap Command -pub fn basic_app() -> Command { - let command = Command::new(BIN_NAME) - .author("Nervos Core Dev ") - .about("Nervos CKB - The Common Knowledge Base") - .subcommand_required(true) - .arg_required_else_help(true) - .term_width(110) - .arg( - Arg::new(ARG_CONFIG_DIR) - .global(true) - .short('C') - .value_name("path") - .action(clap::ArgAction::Set) - .help( - "Run as if CKB was started in , instead of the current working directory.", - ), - ) - .subcommand(run()) - .subcommand(miner()) - .subcommand(export()) - .subcommand(import()) - .subcommand(list_hashes()) - .subcommand(init()) - .subcommand(replay()) - .subcommand(stats()) - .subcommand(reset_data()) - .subcommand(peer_id()) - .subcommand(migrate()); - - #[cfg(not(target_os = "windows"))] - let command = command.subcommand(daemon()); - - command -} - -/// Parse the command line arguments by supplying the version information. -/// -/// The version is used to generate the help message and output for `--version`. -pub fn get_bin_name_and_matches(version: &Version) -> (String, ArgMatches) { - let bin_name = std::env::args() - .next() - .unwrap_or_else(|| BIN_NAME.to_owned()); - let matches = basic_app() - .version(version.short()) - .long_version(version.long()) - .get_matches(); - (bin_name, matches) -} - -fn run() -> Command { - let command = Command::new(CMD_RUN) - .about("Run CKB node") - .arg( - Arg::new(ARG_BA_ADVANCED) - .long(ARG_BA_ADVANCED) - .action(clap::ArgAction::SetTrue) - .help("Allow any block assembler code hash and args"), - ) - .arg( - Arg::new(ARG_SKIP_CHAIN_SPEC_CHECK) - .long(ARG_SKIP_CHAIN_SPEC_CHECK) - .action(clap::ArgAction::SetTrue) - .help("Skip checking the chain spec with the hash stored in the database"), - ).arg( - Arg::new(ARG_OVERWRITE_CHAIN_SPEC) - .long(ARG_OVERWRITE_CHAIN_SPEC) - .action(clap::ArgAction::SetTrue) - .help("Overwrite the chain spec in the database with the present configured chain spec") - ).arg( - Arg::new(ARG_ASSUME_VALID_TARGET) - .long(ARG_ASSUME_VALID_TARGET) - .action(clap::ArgAction::Set) - .value_parser(is_h256) - .help(format!("This parameter specifies the hash of a block. \ -When the height does not reach this block's height, script execution will be disabled, \ -meaning it will skip the verification of the script content. \n\n\ -Please note that when this option is enabled, the header will be synchronized to \ -the highest block currently found. During this period, if the assume valid target is found, \ -the block download starts; \ -If the assume valid target is either absent or has a timestamp within 24 hours of the current time, \ -the target considered invalid, and the block download proceeds with full verification. \n\n\n\ -default(MainNet): {}\n -default(TestNet): {}\n\n -You can explicitly set the value to 0x0000000000000000000000000000000000000000000000000000000000000000 \ -to disable the default behavior and execute full verification for all blocks, \ -", - ckb_constant::default_assume_valid_target::mainnet::DEFAULT_ASSUME_VALID_TARGET, - ckb_constant::default_assume_valid_target::testnet::DEFAULT_ASSUME_VALID_TARGET)) - ).arg( - Arg::new(ARG_INDEXER) - .long(ARG_INDEXER) - .action(clap::ArgAction::SetTrue) - .help("Start the built-in indexer service"), - ) - .arg( - Arg::new(ARG_RICH_INDEXER) - .long(ARG_RICH_INDEXER) - .action(clap::ArgAction::SetTrue) - .help("Start the built-in rich-indexer service"), - ); - - #[cfg(not(target_os = "windows"))] - let command = command.arg( - Arg::new(ARG_DAEMON) - .long(ARG_DAEMON) - .action(clap::ArgAction::SetTrue) - .help( - "Starts ckb as a daemon, \ - which will run in the background and output logs to the specified log file", - ), - ); - command -} - -fn miner() -> Command { - Command::new(CMD_MINER).about("Runs ckb miner").arg( - Arg::new(ARG_LIMIT) - .short('l') - .long(ARG_LIMIT) - .action(clap::ArgAction::Set) - .value_parser(clap::value_parser!(u128)) - .default_value("0") - .help( - "Exit after finding this specific number of nonces; \ - 0 means the miner will never exit. [default: 0]", - ), - ) -} - -fn reset_data() -> Command { - Command::new(CMD_RESET_DATA) - .about( - "Truncate the database directory\n\ - Example:\n\ - ckb reset-data --force --database", - ) - .arg( - Arg::new(ARG_FORCE) - .short('f') - .long(ARG_FORCE) - .action(clap::ArgAction::SetTrue) - .help("Delete data without interactive prompt"), - ) - .arg( - Arg::new(ARG_ALL) - .long(ARG_ALL) - .action(clap::ArgAction::SetTrue) - .help("Delete the whole data directory"), - ) - .arg( - Arg::new(ARG_DATABASE) - .long(ARG_DATABASE) - .action(clap::ArgAction::SetTrue) - .help("Delete only `data/db`"), - ) - .arg( - Arg::new(ARG_INDEXER) - .long(ARG_INDEXER) - .action(clap::ArgAction::SetTrue) - .help("Delete only `data/indexer/store`"), - ) - .arg( - Arg::new(ARG_RICH_INDEXER) - .long(ARG_RICH_INDEXER) - .action(clap::ArgAction::SetTrue) - .help("Delete only `data/indexer/sqlite`"), - ) - .arg( - Arg::new(ARG_NETWORK) - .long(ARG_NETWORK) - .action(clap::ArgAction::SetTrue) - .help("Delete both peer store and secret key"), - ) - .arg( - Arg::new(ARG_NETWORK_PEER_STORE) - .long(ARG_NETWORK_PEER_STORE) - .action(clap::ArgAction::SetTrue) - .help("Delete only `data/network/peer_store`"), - ) - .arg( - Arg::new(ARG_NETWORK_SECRET_KEY) - .long(ARG_NETWORK_SECRET_KEY) - .action(clap::ArgAction::SetTrue) - .help("Delete only `data/network/secret_key`"), - ) - .arg( - Arg::new(ARG_LOGS) - .long(ARG_LOGS) - .action(clap::ArgAction::SetTrue) - .help("Delete only `data/logs`"), - ) -} - -pub(crate) fn stats() -> Command { - Command::new(CMD_STATS) - .about( - "Chain stats\n\ - Example:\n\ - ckb -C stats --from 1 --to 500", - ) - .arg( - Arg::new(ARG_FROM) - .long(ARG_FROM) - .value_parser(clap::value_parser!(u64)) - .action(clap::ArgAction::Set) - .help("Specify from block number"), - ) - .arg( - Arg::new(ARG_TO) - .long(ARG_TO) - .value_parser(clap::value_parser!(u64)) - .action(clap::ArgAction::Set) - .help("Specify to block number"), - ) -} - -fn replay() -> Command { - Command::new(CMD_REPLAY) - .about("Replay CKB process block") - .override_help(" - --tmp-target --profile 1 10,\n - --tmp-target --sanity-check,\n - ") - .arg(Arg::new(ARG_TMP_TARGET).long(ARG_TMP_TARGET).value_parser(clap::builder::PathBufValueParser::new()).action(clap::ArgAction::Set).required(true).help( - "Specify a target path. The profile command makes a temporary directory within the specified target path. This temporary directory will be automatically deleted when the command completes.", - )) - .arg(Arg::new(ARG_PROFILE).long(ARG_PROFILE).action(clap::ArgAction::SetTrue).help( - "Enable profile", - )) - .arg( - Arg::new(ARG_FROM) - .value_parser(clap::value_parser!(u64)) - .help("Specify profile from block number"), - ) - .arg( - Arg::new(ARG_TO) - .value_parser(clap::value_parser!(u64)) - .help("Specify profile to block number"), - ) - .arg( - Arg::new(ARG_SANITY_CHECK).long(ARG_SANITY_CHECK).action(clap::ArgAction::SetTrue).help("Enable sanity check") - ) - .arg( - Arg::new(ARG_FULL_VERIFICATION).long(ARG_FULL_VERIFICATION).action(clap::ArgAction::SetTrue).help("Enable sanity check") - ) - .group( - ArgGroup::new("mode") - .args([ARG_PROFILE, ARG_SANITY_CHECK]) - .required(true) - ) -} - -fn export() -> Command { - Command::new(CMD_EXPORT).about("Export CKB data").arg( - Arg::new(ARG_TARGET) - .short('t') - .long(ARG_TARGET) - .value_name("path") - .value_parser(clap::builder::PathBufValueParser::new()) - .required(true) - .help("Specify the export target path"), - ) -} - -fn import() -> Command { - Command::new(CMD_IMPORT).about("Import CKB data").arg( - Arg::new(ARG_SOURCE) - .index(1) - .value_name("path") - .value_parser(clap::builder::PathBufValueParser::new()) - .required(true) - .help("Specify the exported data path"), - ) -} - -fn migrate() -> Command { - Command::new(CMD_MIGRATE) - .about("Run CKB migration") - .arg( - Arg::new(ARG_MIGRATE_CHECK) - .long(ARG_MIGRATE_CHECK) - .action(clap::ArgAction::SetTrue) - .help( - "Perform database version check without migrating. \ - If migration is in need, ExitCode(0) is returned; \ - otherwise ExitCode(64) is returned", - ), - ) - .arg( - Arg::new(ARG_FORCE) - .long(ARG_FORCE) - .action(clap::ArgAction::SetTrue) - .conflicts_with(ARG_MIGRATE_CHECK) - .help("Migrate without interactive prompt"), - ) - .arg( - Arg::new(ARG_INCLUDE_BACKGROUND) - .long(ARG_INCLUDE_BACKGROUND) - .action(clap::ArgAction::SetTrue) - .help("Whether include background migrations"), - ) -} - -#[cfg(not(target_os = "windows"))] -fn daemon() -> Command { - Command::new(CMD_DAEMON) - .about("Runs ckb daemon command") - .arg( - Arg::new(ARG_DAEMON_CHECK) - .long(ARG_DAEMON_CHECK) - .action(clap::ArgAction::SetTrue) - .help("Check the daemon status"), - ) - .arg( - Arg::new(ARG_DAEMON_STOP) - .long(ARG_DAEMON_STOP) - .action(clap::ArgAction::SetTrue) - .conflicts_with(ARG_DAEMON_CHECK) - .help("Stop the daemon process, both the miner and the node"), - ) -} - -fn list_hashes() -> Command { - Command::new(CMD_LIST_HASHES) - .about("List well known hashes") - .arg( - Arg::new(ARG_BUNDLED) - .short('b') - .long(ARG_BUNDLED) - .action(clap::ArgAction::SetTrue) - .help( - "List hashes of the bundled chain specs, instead of the current effective ones.", - ), - ) - .arg( - Arg::new(ARG_FORMAT) - .short('f') - .long(ARG_FORMAT) - .value_parser(["json", "toml"]) - .default_value("toml") - .help("Set the format of the printed hashes"), - ) -} - -fn init() -> Command { - Command::new(CMD_INIT) - .about("Create a CKB directory or re-initialize an existing one") - .arg( - Arg::new(ARG_INTERACTIVE) - .short('i') - .long(ARG_INTERACTIVE) - .action(clap::ArgAction::SetTrue) - .help("Interactive mode"), - ) - .arg( - Arg::new(ARG_LIST_CHAINS) - .short('l') - .long(ARG_LIST_CHAINS) - .action(clap::ArgAction::SetTrue) - .help("List available options for --chain"), - ) - .arg( - Arg::new(ARG_CHAIN) - .short('c') - .long(ARG_CHAIN) - .value_parser( - AVAILABLE_SPECS - .iter() - .map(|v| v.to_string()) - .collect::>(), - ) - .default_value(DEFAULT_SPEC) - .help("Initialize CKB directory for "), - ) - .arg( - Arg::new(ARG_IMPORT_SPEC) - .long(ARG_IMPORT_SPEC) - .action(clap::ArgAction::Set) - .help( - "Use the specified file as the chain spec. Specially, \ - The dash \"-\" denotes importing the spec from stdin encoded in base64", - ), - ) - .arg( - Arg::new(ARG_LOG_TO) - .long(ARG_LOG_TO) - .value_parser(["file", "stdout", "both"]) - .default_value("both") - .help("Configure where the logs should be printed"), - ) - .arg( - Arg::new(ARG_FORCE) - .short('f') - .long(ARG_FORCE) - .action(clap::ArgAction::SetTrue) - .help("Enforce overwriting existing files"), - ) - .arg( - Arg::new(ARG_RPC_PORT) - .long(ARG_RPC_PORT) - .default_value(DEFAULT_RPC_PORT) - .help("Replace CKB RPC port in the created config file"), - ) - .arg( - Arg::new(ARG_P2P_PORT) - .long(ARG_P2P_PORT) - .default_value(DEFAULT_P2P_PORT) - .help("Replace CKB P2P port in the created config file"), - ) - .arg( - Arg::new(ARG_BA_CODE_HASH) - .long(ARG_BA_CODE_HASH) - .value_name("code_hash") - .value_parser(is_h256) - .action(clap::ArgAction::Set) - .help( - "Set code_hash in [block_assembler] \ - [default: secp256k1 if --ba-arg is present]", - ), - ) - .arg( - Arg::new(ARG_BA_ARG) - .long(ARG_BA_ARG) - .value_name("arg") - .action(clap::ArgAction::Append) - .value_parser(is_hex) - .help("Set args in [block_assembler]"), - ) - .arg( - Arg::new(ARG_BA_HASH_TYPE) - .long(ARG_BA_HASH_TYPE) - .value_name("hash_type") - .action(clap::ArgAction::Set) - .value_parser(["data", "type", "data1"]) - .default_value("type") - .help("Set hash type in [block_assembler]"), - ) - .group( - ArgGroup::new(GROUP_BA) - .args([ARG_BA_CODE_HASH, ARG_BA_ARG]) - .multiple(true), - ) - .arg( - Arg::new(ARG_BA_MESSAGE) - .long(ARG_BA_MESSAGE) - .value_name("message") - .value_parser(is_hex) - .requires(GROUP_BA) - .help("Set message in [block_assembler]"), - ) - .arg(Arg::new("export-specs").long("export-specs").hide(true)) - .arg(Arg::new("list-specs").long("list-specs").hide(true)) - .arg( - Arg::new("spec") - .short('s') - .long("spec") - .action(clap::ArgAction::Set) - .hide(true), - ) - .arg( - Arg::new(ARG_GENESIS_MESSAGE) - .long(ARG_GENESIS_MESSAGE) - .value_name(ARG_GENESIS_MESSAGE) - .action(clap::ArgAction::Set) - .help( - "Specify a string as the genesis message. \ - This only works for dev chains. \ - If no message is provided, use the current timestamp.", - ), - ) -} - -fn peer_id() -> Command { - Command::new(CMD_PEERID) - .about("About peer id, base on Secp256k1") - .subcommand_required(true) - .subcommand( - Command::new(CMD_FROM_SECRET) - .about("Generate peer id from secret file") - .arg( - Arg::new(ARG_SECRET_PATH) - .action(clap::ArgAction::Set) - .long(ARG_SECRET_PATH) - .required(true) - .help("Generate peer id from secret file path"), - ), - ) - .subcommand( - Command::new(CMD_GEN_SECRET) - .about("Generate random key to file") - .arg( - Arg::new(ARG_SECRET_PATH) - .long(ARG_SECRET_PATH) - .required(true) - .action(clap::ArgAction::Set) - .help("Generate peer id to file path"), - ), - ) -} - -fn is_hex(hex: &str) -> Result { - let tmp = hex.as_bytes(); - if tmp.len() < 2 { - Err("Must be a 0x-prefixed hexadecimal string".to_string()) - } else if tmp.len() & 1 != 0 { - Err("Hexadecimal strings must be of even length".to_string()) - } else if tmp[..2] == b"0x"[..] { - for byte in &tmp[2..] { - match byte { - b'A'..=b'F' | b'a'..=b'f' | b'0'..=b'9' => continue, - invalid_char => { - return Err(format!("Hex has invalid char: {invalid_char}")); - } - } - } - - Ok(hex.to_string()) - } else { - Err("Must 0x-prefixed hexadecimal string".to_string()) - } -} - -fn is_h256(hex: &str) -> Result { - if hex.len() != 66 { - Err("Must be 0x-prefixed hexadecimal string and string length is 66".to_owned()) - } else { - is_hex(hex) - } -} +/// Subcommand `run`. +pub const CMD_RUN: &str = "run"; diff --git a/util/app-config/src/configs/mod.rs b/util/app-config/src/configs/mod.rs index 95b0c79508..7bcf193128 100644 --- a/util/app-config/src/configs/mod.rs +++ b/util/app-config/src/configs/mod.rs @@ -28,4 +28,4 @@ pub use rpc::{Config as RpcConfig, Module as RpcModule}; pub use store::Config as StoreConfig; pub use tx_pool::{BlockAssemblerConfig, TxPoolConfig}; -pub(crate) use network::{generate_random_key, read_secret_key, write_secret_to_file}; +pub use network::{generate_random_key, read_secret_key, write_secret_to_file}; diff --git a/util/app-config/src/configs/network.rs b/util/app-config/src/configs/network.rs index 42106c6601..912aca0d8f 100644 --- a/util/app-config/src/configs/network.rs +++ b/util/app-config/src/configs/network.rs @@ -167,7 +167,8 @@ pub fn default_support_all_protocols() -> Vec { ] } -pub(crate) fn generate_random_key() -> [u8; 32] { +/// Generate random secp256k1 key +pub fn generate_random_key() -> [u8; 32] { loop { let mut key: [u8; 32] = [0; 32]; rand::thread_rng().fill(&mut key); @@ -177,7 +178,8 @@ pub(crate) fn generate_random_key() -> [u8; 32] { } } -pub(crate) fn write_secret_to_file(secret: &[u8], path: PathBuf) -> Result<(), Error> { +/// Secret key storage +pub fn write_secret_to_file(secret: &[u8], path: PathBuf) -> Result<(), Error> { fs::OpenOptions::new() .create(true) .write(true) @@ -198,7 +200,8 @@ pub(crate) fn write_secret_to_file(secret: &[u8], path: PathBuf) -> Result<(), E }) } -pub(crate) fn read_secret_key(path: PathBuf) -> Result, Error> { +/// Load secret key from path +pub fn read_secret_key(path: PathBuf) -> Result, Error> { let mut file = match fs::File::open(path.clone()) { Ok(file) => file, Err(_) => return Ok(None), diff --git a/util/app-config/src/exit_code.rs b/util/app-config/src/exit_code.rs index a55e845c77..6b5230886b 100644 --- a/util/app-config/src/exit_code.rs +++ b/util/app-config/src/exit_code.rs @@ -41,10 +41,3 @@ impl From for ExitCode { ExitCode::Config } } - -impl From for ExitCode { - fn from(err: clap::Error) -> ExitCode { - eprintln!("Args Error: {err:?}"); - ExitCode::Cli - } -} diff --git a/util/app-config/src/lib.rs b/util/app-config/src/lib.rs index 02110816aa..b4d3daad03 100644 --- a/util/app-config/src/lib.rs +++ b/util/app-config/src/lib.rs @@ -15,476 +15,12 @@ pub use app_config::{ AppConfig, CKBAppConfig, ChainConfig, LogConfig, MetricsConfig, MinerAppConfig, }; pub use args::{ - DaemonArgs, ExportArgs, ImportArgs, InitArgs, MigrateArgs, MinerArgs, PeerIDArgs, ReplayArgs, - ResetDataArgs, RunArgs, StatsArgs, + CustomizeSpec, DaemonArgs, ExportArgs, ImportArgs, InitArgs, MigrateArgs, MinerArgs, + PeerIDArgs, ReplayArgs, ResetDataArgs, RunArgs, StatsArgs, }; -use ckb_logger::info; + pub use configs::*; pub use exit_code::ExitCode; #[cfg(feature = "with_sentry")] pub use sentry_config::SentryConfig; pub use url::Url; - -use ckb_chain_spec::{consensus::Consensus, ChainSpec}; -use ckb_jsonrpc_types::ScriptHashType; -use ckb_types::{u256, H256, U256}; -use clap::ArgMatches; -use std::{path::PathBuf, str::FromStr}; - -// 500_000 total difficulty -const MIN_CHAIN_WORK_500K: U256 = u256!("0x3314412053c82802a7"); - -/// A struct including all the information to start the ckb process. -pub struct Setup { - /// Subcommand name. - /// - /// For example, this is set to `run` when ckb is executed with `ckb run`. - pub subcommand_name: String, - /// The config file for the current subcommand. - pub config: AppConfig, - /// Whether sentry is enabled. - #[cfg(feature = "with_sentry")] - pub is_sentry_enabled: bool, -} - -impl Setup { - /// Boots the ckb process by parsing the command line arguments and loading the config file. - pub fn from_matches( - bin_name: String, - subcommand_name: &str, - matches: &ArgMatches, - ) -> Result { - let root_dir = Self::root_dir_from_matches(matches)?; - let mut config = AppConfig::load_for_subcommand(root_dir, subcommand_name)?; - config.set_bin_name(bin_name); - #[cfg(feature = "with_sentry")] - let is_sentry_enabled = is_daemon(subcommand_name) && config.sentry().is_enabled(); - - Ok(Setup { - subcommand_name: subcommand_name.to_string(), - config, - #[cfg(feature = "with_sentry")] - is_sentry_enabled, - }) - } - - /// Executes `ckb run`. - pub fn run(self, matches: &ArgMatches) -> Result { - let consensus = self.consensus()?; - let chain_spec_hash = self.chain_spec()?.hash; - let mut config = self.config.into_ckb()?; - - let mainnet_genesis = ckb_chain_spec::ChainSpec::load_from( - &ckb_resource::Resource::bundled("specs/mainnet.toml".to_string()), - ) - .expect("load mainnet spec fail") - .build_genesis() - .expect("build mainnet genesis fail"); - config.network.sync.min_chain_work = - if consensus.genesis_block.hash() == mainnet_genesis.hash() { - MIN_CHAIN_WORK_500K - } else { - u256!("0x0") - }; - - let arg_assume_valid_target = matches.get_one::(cli::ARG_ASSUME_VALID_TARGET); - - config.network.sync.assume_valid_target = - arg_assume_valid_target.and_then(|s| H256::from_str(&s[2..]).ok()); - if config.network.sync.assume_valid_target.is_none() { - config.network.sync.assume_valid_target = match consensus.id.as_str() { - ckb_constant::hardfork::mainnet::CHAIN_SPEC_NAME => Some( - H256::from_str(&ckb_constant::default_assume_valid_target::mainnet::DEFAULT_ASSUME_VALID_TARGET[2..]) - .expect("default assume_valid_target for mainnet must be valid"), - ), - ckb_constant::hardfork::testnet::CHAIN_SPEC_NAME => Some( - H256::from_str(&ckb_constant::default_assume_valid_target::testnet::DEFAULT_ASSUME_VALID_TARGET[2..]) - .expect("default assume_valid_target for testnet must be valid"), - ), - _ => None, - }; - } - - if let Some(ref assume_valid_target) = config.network.sync.assume_valid_target { - if assume_valid_target - == &H256::from_slice(&[0; 32]).expect("must parse Zero h256 successful") - { - info!("Disable assume valid target since assume_valid_target is zero"); - config.network.sync.assume_valid_target = None - } else { - info!("assume_valid_target set to 0x{}", assume_valid_target); - } - } - - Ok(RunArgs { - config, - consensus, - block_assembler_advanced: matches.get_flag(cli::ARG_BA_ADVANCED), - skip_chain_spec_check: matches.get_flag(cli::ARG_SKIP_CHAIN_SPEC_CHECK), - overwrite_chain_spec: matches.get_flag(cli::ARG_OVERWRITE_CHAIN_SPEC), - chain_spec_hash, - indexer: matches.get_flag(cli::ARG_INDEXER), - rich_indexer: matches.get_flag(cli::ARG_RICH_INDEXER), - #[cfg(not(target_os = "windows"))] - daemon: matches.get_flag(cli::ARG_DAEMON), - }) - } - - /// `migrate` subcommand has one `flags` arg, trigger this arg with "--check" - pub fn migrate(self, matches: &ArgMatches) -> Result { - let consensus = self.consensus()?; - let config = self.config.into_ckb()?; - let check = matches.get_flag(cli::ARG_MIGRATE_CHECK); - let force = matches.get_flag(cli::ARG_FORCE); - let include_background = matches.get_flag(cli::ARG_INCLUDE_BACKGROUND); - - Ok(MigrateArgs { - config, - consensus, - check, - force, - include_background, - }) - } - - /// Executes `ckb miner`. - pub fn miner(self, matches: &ArgMatches) -> Result { - let spec = self.chain_spec()?; - let memory_tracker = self.config.memory_tracker().to_owned(); - let config = self.config.into_miner()?; - let pow_engine = spec.pow_engine(); - let limit = *matches - .get_one::(cli::ARG_LIMIT) - .expect("has default value"); - - Ok(MinerArgs { - pow_engine, - config: config.miner, - memory_tracker, - limit, - }) - } - - /// Executes `ckb replay`. - pub fn replay(self, matches: &ArgMatches) -> Result { - let consensus = self.consensus()?; - let config = self.config.into_ckb()?; - let tmp_target = matches - .get_one::(cli::ARG_TMP_TARGET) - .ok_or_else(|| { - eprintln!("Args Error: {:?} no found", cli::ARG_TMP_TARGET); - ExitCode::Cli - })? - .clone(); - let profile = if matches.get_flag(cli::ARG_PROFILE) { - let from = matches.get_one::(cli::ARG_FROM).cloned(); - let to = matches.get_one::(cli::ARG_TO).cloned(); - Some((from, to)) - } else { - None - }; - let sanity_check = matches.get_flag(cli::ARG_SANITY_CHECK); - let full_verification = matches.get_flag(cli::ARG_FULL_VERIFICATION); - Ok(ReplayArgs { - config, - consensus, - tmp_target, - profile, - sanity_check, - full_verification, - }) - } - - /// Executes `ckb stats`. - pub fn stats(self, matches: &ArgMatches) -> Result { - let consensus = self.consensus()?; - let config = self.config.into_ckb()?; - - let from = matches.get_one::(cli::ARG_FROM).cloned(); - let to = matches.get_one::(cli::ARG_TO).cloned(); - - Ok(StatsArgs { - config, - consensus, - from, - to, - }) - } - - /// Executes `ckb import`. - pub fn import(self, matches: &ArgMatches) -> Result { - let consensus = self.consensus()?; - let config = self.config.into_ckb()?; - let source = matches - .get_one::(cli::ARG_SOURCE) - .ok_or_else(|| { - eprintln!("Args Error: {:?} no found", cli::ARG_SOURCE); - ExitCode::Cli - })? - .clone(); - - Ok(ImportArgs { - config, - consensus, - source, - }) - } - - /// Executes `ckb export`. - pub fn export(self, matches: &ArgMatches) -> Result { - let consensus = self.consensus()?; - let config = self.config.into_ckb()?; - let target = matches - .get_one::(cli::ARG_TARGET) - .ok_or_else(|| { - eprintln!("Args Error: {:?} no found", cli::ARG_TARGET); - ExitCode::Cli - })? - .clone(); - - Ok(ExportArgs { - config, - consensus, - target, - }) - } - - /// Executes `ckb daemon`. - pub fn daemon(self, matches: &ArgMatches) -> Result { - let check = matches.get_flag(cli::ARG_DAEMON_CHECK); - let stop = matches.get_flag(cli::ARG_DAEMON_STOP); - let pid_file = Setup::daemon_pid_file_path(matches)?; - Ok(DaemonArgs { - check, - stop, - pid_file, - }) - } - - /// Executes `ckb init`. - pub fn init(matches: &ArgMatches) -> Result { - if matches.contains_id("list-specs") { - eprintln!( - "Deprecated: Option `--list-specs` is deprecated, use `--list-chains` instead" - ); - } - if matches.contains_id("spec") { - eprintln!("Deprecated: Option `--spec` is deprecated, use `--chain` instead"); - } - if matches.contains_id("export-specs") { - eprintln!("Deprecated: Option `--export-specs` is deprecated"); - } - - let root_dir = Self::root_dir_from_matches(matches)?; - let list_chains = - matches.get_flag(cli::ARG_LIST_CHAINS) || matches.contains_id("list-specs"); - let interactive = matches.get_flag(cli::ARG_INTERACTIVE); - let force = matches.get_flag(cli::ARG_FORCE); - let chain = if !matches.contains_id("spec") { - matches - .get_one::(cli::ARG_CHAIN) - .expect("has default value") - .to_string() - } else { - matches.get_one::("spec").unwrap().to_string() - }; - let rpc_port = matches - .get_one::(cli::ARG_RPC_PORT) - .expect("has default value") - .to_string(); - let p2p_port = matches - .get_one::(cli::ARG_P2P_PORT) - .expect("has default value") - .to_string(); - let (log_to_file, log_to_stdout) = match matches - .get_one::(cli::ARG_LOG_TO) - .map(|s| s.as_str()) - { - Some("file") => (true, false), - Some("stdout") => (false, true), - Some("both") => (true, true), - _ => unreachable!(), - }; - - let block_assembler_code_hash = matches.get_one::(cli::ARG_BA_CODE_HASH).cloned(); - let block_assembler_args: Vec<_> = matches - .get_many::(cli::ARG_BA_ARG) - .unwrap_or_default() - .map(|a| a.to_owned()) - .collect(); - let block_assembler_hash_type = matches - .get_one::(cli::ARG_BA_HASH_TYPE) - .and_then(|hash_type| serde_plain::from_str::(hash_type).ok()) - .expect("has default value"); - let block_assembler_message = matches.get_one::(cli::ARG_BA_MESSAGE).cloned(); - - let import_spec = matches.get_one::(cli::ARG_IMPORT_SPEC).cloned(); - - let customize_spec = { - let genesis_message = matches.get_one::(cli::ARG_GENESIS_MESSAGE).cloned(); - args::CustomizeSpec { genesis_message } - }; - - Ok(InitArgs { - interactive, - root_dir, - chain, - rpc_port, - p2p_port, - list_chains, - force, - log_to_file, - log_to_stdout, - block_assembler_code_hash, - block_assembler_args, - block_assembler_hash_type, - block_assembler_message, - import_spec, - customize_spec, - }) - } - - /// Executes `ckb reset-data`. - pub fn reset_data(self, matches: &ArgMatches) -> Result { - let config = self.config.into_ckb()?; - let data_dir = config.data_dir; - let db_path = config.db.path; - let indexer_path = config.indexer.store; - let rich_indexer_path = config - .indexer - .rich_indexer - .store - .parent() - .expect("rich-indexer store path should have parent dir") - .to_path_buf(); - let network_config = config.network; - let network_dir = network_config.path.clone(); - let network_peer_store_path = network_config.peer_store_path(); - let network_secret_key_path = network_config.secret_key_path(); - let logs_dir = Some(config.logger.log_dir); - - let force = matches.get_flag(cli::ARG_FORCE); - let all = matches.get_flag(cli::ARG_ALL); - let database = matches.get_flag(cli::ARG_DATABASE); - let indexer = matches.get_flag(cli::ARG_INDEXER); - let rich_indexer = matches.get_flag(cli::ARG_RICH_INDEXER); - let network = matches.get_flag(cli::ARG_NETWORK); - let network_peer_store = matches.get_flag(cli::ARG_NETWORK_PEER_STORE); - let network_secret_key = matches.get_flag(cli::ARG_NETWORK_SECRET_KEY); - let logs = matches.get_flag(cli::ARG_LOGS); - - Ok(ResetDataArgs { - force, - all, - database, - indexer, - rich_indexer, - network, - network_peer_store, - network_secret_key, - logs, - data_dir, - db_path, - indexer_path, - rich_indexer_path, - network_dir, - network_peer_store_path, - network_secret_key_path, - logs_dir, - }) - } - - /// Resolves the root directory for ckb from the command line arguments. - pub fn root_dir_from_matches(matches: &ArgMatches) -> Result { - let config_dir = match matches.get_one::(cli::ARG_CONFIG_DIR) { - Some(arg_config_dir) => PathBuf::from(arg_config_dir), - None => ::std::env::current_dir()?, - }; - std::fs::create_dir_all(&config_dir)?; - Ok(config_dir) - } - - /// Resolves the pid file path for ckb from the command line arguments. - pub fn daemon_pid_file_path(matches: &ArgMatches) -> Result { - let root_dir = Self::root_dir_from_matches(matches)?; - Ok(root_dir.join("data/daemon/ckb-run.pid")) - } - - /// Loads the chain spec. - #[cfg(feature = "with_sentry")] - fn chain_spec(&self) -> Result { - let result = self.config.chain_spec(); - if let Ok(spec) = &result { - if self.is_sentry_enabled { - sentry::configure_scope(|scope| { - scope.set_tag("spec.name", &spec.name); - scope.set_tag("spec.pow", &spec.pow); - }); - } - } - - result - } - - #[cfg(not(feature = "with_sentry"))] - fn chain_spec(&self) -> Result { - self.config.chain_spec() - } - - /// Gets the consensus. - #[cfg(feature = "with_sentry")] - pub fn consensus(&self) -> Result { - let result = consensus_from_spec(&self.chain_spec()?); - - if let Ok(consensus) = &result { - if self.is_sentry_enabled { - sentry::configure_scope(|scope| { - scope.set_tag("genesis", consensus.genesis_hash()); - }); - } - } - - result - } - - /// Gets the consensus. - #[cfg(not(feature = "with_sentry"))] - pub fn consensus(&self) -> Result { - consensus_from_spec(&self.chain_spec()?) - } - - /// Gets the network peer id by reading the network secret key. - pub fn peer_id(matches: &ArgMatches) -> Result { - let path = matches - .get_one::(cli::ARG_SECRET_PATH) - .expect("required on command line"); - match read_secret_key(path.into()) { - Ok(Some(key)) => Ok(PeerIDArgs { - peer_id: key.peer_id(), - }), - Err(_) => Err(ExitCode::Failure), - Ok(None) => Err(ExitCode::IO), - } - } - - /// Generates the network secret key. - pub fn gen(matches: &ArgMatches) -> Result<(), ExitCode> { - let path = matches - .get_one::(cli::ARG_SECRET_PATH) - .expect("required on command line"); - configs::write_secret_to_file(&configs::generate_random_key(), path.into()) - .map_err(|_| ExitCode::IO) - } -} - -#[cfg(feature = "with_sentry")] -fn is_daemon(subcommand_name: &str) -> bool { - matches!(subcommand_name, cli::CMD_RUN | cli::CMD_MINER) -} - -fn consensus_from_spec(spec: &ChainSpec) -> Result { - spec.build_consensus().map_err(|err| { - eprintln!("chainspec error: {err}"); - ExitCode::Config - }) -} diff --git a/util/app-config/src/tests/mod.rs b/util/app-config/src/tests/mod.rs index 2f08a20f0b..08e5df8f17 100644 --- a/util/app-config/src/tests/mod.rs +++ b/util/app-config/src/tests/mod.rs @@ -1,3 +1,2 @@ mod app_config; -mod cli; mod legacy; diff --git a/util/build-info/Cargo.toml b/util/build-info/Cargo.toml index 70859dc355..f553ba4117 100644 --- a/util/build-info/Cargo.toml +++ b/util/build-info/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-build-info" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/util/chain-iter/Cargo.toml b/util/chain-iter/Cargo.toml index cb9228a8c4..7d4cc06edb 100644 --- a/util/chain-iter/Cargo.toml +++ b/util/chain-iter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-chain-iter" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,5 +11,5 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } diff --git a/util/channel/Cargo.toml b/util/channel/Cargo.toml index dccd4bbcb7..0cfca2dc15 100644 --- a/util/channel/Cargo.toml +++ b/util/channel/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-channel" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/util/constant/Cargo.toml b/util/constant/Cargo.toml index a17d3c7634..84f63dec5a 100644 --- a/util/constant/Cargo.toml +++ b/util/constant/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-constant" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/util/constant/src/default_assume_valid_target.rs b/util/constant/src/default_assume_valid_target.rs index b139d70ab9..b3638c3ee4 100644 --- a/util/constant/src/default_assume_valid_target.rs +++ b/util/constant/src/default_assume_valid_target.rs @@ -9,12 +9,12 @@ pub mod mainnet { /// /// Need to update when CKB's new release /// in mainnet: the 60 days ago block is: - /// height: 13266076 - /// hash: 0xd07c7f0fcea6e2a20a51dabbf0caae7ebff49723bcd8bac81a8b8c021a546a32 - /// date: Wed Jun 19 02:31:36 AM UTC 2024 - /// you can view this block in https://explorer.nervos.org/block/0xd07c7f0fcea6e2a20a51dabbf0caae7ebff49723bcd8bac81a8b8c021a546a32 + /// height: 13735790 + /// hash: 0x1dc6ebf09bf066b6d4c6b9bf1ded8e4c692c55b14f98bff231a4cb26720412cd + /// date: Sun Aug 11 07:55:39 AM CST 2024 + /// you can view this block in https://explorer.nervos.org/block/0x1dc6ebf09bf066b6d4c6b9bf1ded8e4c692c55b14f98bff231a4cb26720412cd pub const DEFAULT_ASSUME_VALID_TARGET: &str = - "0xd07c7f0fcea6e2a20a51dabbf0caae7ebff49723bcd8bac81a8b8c021a546a32"; + "0x1dc6ebf09bf066b6d4c6b9bf1ded8e4c692c55b14f98bff231a4cb26720412cd"; } /// sync config related to testnet pub mod testnet { @@ -22,10 +22,10 @@ pub mod testnet { /// /// Need to update when CKB's new release /// in testnet: the 60 days ago block is: - /// height: 13632642 - /// hash: 0xab6f81474ccbc1cdd5f42cda7029a6f6e52fc242c3487861e8abb62b6a6ea8a9 - /// date: Wed Jun 19 02:32:01 AM UTC 2024 - /// you can view this block in https://pudge.explorer.nervos.org/block/0xab6f81474ccbc1cdd5f42cda7029a6f6e52fc242c3487861e8abb62b6a6ea8a9 + /// height: 14203467 + /// hash: 0xa13450d53528d80fb5886f35386cf0119eea74cc63092c1138c38971416fe445 + /// date: Sun Aug 11 07:56:19 AM CST 2024 + /// you can view this block in https://pudge.explorer.nervos.org/block/0xa13450d53528d80fb5886f35386cf0119eea74cc63092c1138c38971416fe445 pub const DEFAULT_ASSUME_VALID_TARGET: &str = - "0xab6f81474ccbc1cdd5f42cda7029a6f6e52fc242c3487861e8abb62b6a6ea8a9"; + "0xa13450d53528d80fb5886f35386cf0119eea74cc63092c1138c38971416fe445"; } diff --git a/util/constant/src/hardfork/testnet.rs b/util/constant/src/hardfork/testnet.rs index 6f2b061368..477129817c 100644 --- a/util/constant/src/hardfork/testnet.rs +++ b/util/constant/src/hardfork/testnet.rs @@ -7,5 +7,8 @@ pub const RFC0028_RFC0032_RFC0033_RFC0034_START_EPOCH: u64 = 3113; // pub const CKB2021_START_EPOCH: u64 = 3113; pub const CKB2021_START_EPOCH: u64 = 0; -/// hardcode ckb2023 epoch -pub const CKB2023_START_EPOCH: u64 = u64::MAX; +/// 2024-10-25 05:43 utc +/// | hash | number | timestamp | epoch | +/// | 0xa229cd72240f6ef238681e21d1e6884b825afce07e2394308411facfb3cd64c2 | 14,691,304 | 1727243008225 | 9510 (1800/1800)| +/// 1727243008225 + 180 * (4 * 60 * 60 * 1000) = 1729835008225 2024-10-25 05:43 utc +pub const CKB2023_START_EPOCH: u64 = 9690; diff --git a/util/crypto/Cargo.toml b/util/crypto/Cargo.toml index 30e1432798..8230bcc669 100644 --- a/util/crypto/Cargo.toml +++ b/util/crypto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-crypto" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.118.0" } +ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.119.0" } lazy_static = "1.3" secp256k1 = { version = "0.29", features = ["recovery"], optional = true } thiserror = "1.0.22" diff --git a/util/dao/Cargo.toml b/util/dao/Cargo.toml index 5f00097eec..ee001933dc 100644 --- a/util/dao/Cargo.toml +++ b/util/dao/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-dao" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -10,13 +10,13 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] byteorder = "1.3.1" -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-dao-utils = { path = "./utils", version = "= 0.118.0" } -ckb-traits = { path = "../../traits", version = "= 0.118.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-dao-utils = { path = "./utils", version = "= 0.119.0" } +ckb-traits = { path = "../../traits", version = "= 0.119.0" } [dev-dependencies] -ckb-db = { path = "../../db", version = "= 0.118.0" } -ckb-db-schema = { path = "../../db-schema", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } +ckb-db = { path = "../../db", version = "= 0.119.0" } +ckb-db-schema = { path = "../../db-schema", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } tempfile.workspace = true diff --git a/util/dao/utils/Cargo.toml b/util/dao/utils/Cargo.toml index ebae544927..e1645eec66 100644 --- a/util/dao/utils/Cargo.toml +++ b/util/dao/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-dao-utils" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -10,5 +10,5 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] byteorder = "1.3.1" -ckb-types = { path = "../../types", version = "= 0.118.0" } -ckb-error = { path = "../../../error", version = "= 0.118.0" } +ckb-types = { path = "../../types", version = "= 0.119.0" } +ckb-error = { path = "../../../error", version = "= 0.119.0" } diff --git a/util/fixed-hash/Cargo.toml b/util/fixed-hash/Cargo.toml index 8f43fe93b6..e76e616da2 100644 --- a/util/fixed-hash/Cargo.toml +++ b/util/fixed-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-fixed-hash" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" @@ -9,5 +9,5 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-fixed-hash-core = { path = "core", version = "= 0.118.0" } -ckb-fixed-hash-macros = { path = "macros", version = "= 0.118.0" } +ckb-fixed-hash-core = { path = "core", version = "= 0.119.0" } +ckb-fixed-hash-macros = { path = "macros", version = "= 0.119.0" } diff --git a/util/fixed-hash/core/Cargo.toml b/util/fixed-hash/core/Cargo.toml index 8afc15a70f..2570a25017 100644 --- a/util/fixed-hash/core/Cargo.toml +++ b/util/fixed-hash/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-fixed-hash-core" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" diff --git a/util/fixed-hash/macros/Cargo.toml b/util/fixed-hash/macros/Cargo.toml index 7c46f3acfc..084b4d2f66 100644 --- a/util/fixed-hash/macros/Cargo.toml +++ b/util/fixed-hash/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-fixed-hash-macros" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" @@ -12,7 +12,7 @@ repository = "https://github.com/nervosnetwork/ckb" proc-macro = true [dependencies] -ckb-fixed-hash-core = { path = "../core", version = "= 0.118.0" } +ckb-fixed-hash-core = { path = "../core", version = "= 0.119.0" } quote = "1.0" syn = "1.0" proc-macro2 = "1.0" diff --git a/util/gen-types/Cargo.toml b/util/gen-types/Cargo.toml index cd8e863670..c75927b9f6 100644 --- a/util/gen-types/Cargo.toml +++ b/util/gen-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-gen-types" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dev-dependencies] -ckb-hash = { path = "../hash", version = "= 0.118.0" } +ckb-hash = { path = "../hash", version = "= 0.119.0" } [features] default = ["std"] @@ -32,10 +32,10 @@ std = [ [dependencies] cfg-if = "1.0" molecule = { version = "0.8", default-features = false } -ckb-hash = { path = "../hash", version = "= 0.118.0", default-features = false, optional = true } -ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.118.0", optional = true } -ckb-error = { path = "../../error", version = "= 0.118.0", optional = true } -ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.118.0", optional = true } +ckb-hash = { path = "../hash", version = "= 0.119.0", default-features = false, optional = true } +ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.119.0", optional = true } +ckb-error = { path = "../../error", version = "= 0.119.0", optional = true } +ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.119.0", optional = true } numext-fixed-uint = { version = "0.1", features = [ "support_rand", "support_heapsize", diff --git a/util/hash/Cargo.toml b/util/hash/Cargo.toml index ed0ba30baa..f0ce78bd06 100644 --- a/util/hash/Cargo.toml +++ b/util/hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-hash" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/util/indexer-sync/Cargo.toml b/util/indexer-sync/Cargo.toml index 2301ef0f0d..e442141025 100644 --- a/util/indexer-sync/Cargo.toml +++ b/util/indexer-sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-indexer-sync" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,15 +11,15 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-app-config = { path = "../app-config", version = "= 0.118.0" } -ckb-async-runtime = { path = "../runtime", version = "= 0.118.0" } -ckb-db-schema = { path = "../../db-schema", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-notify = { path = "../../notify", version = "= 0.118.0" } -ckb-stop-handler = { path = "../stop-handler", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } -ckb-types = { path = "../types", version = "= 0.118.0" } +ckb-app-config = { path = "../app-config", version = "= 0.119.0" } +ckb-async-runtime = { path = "../runtime", version = "= 0.119.0" } +ckb-db-schema = { path = "../../db-schema", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-notify = { path = "../../notify", version = "= 0.119.0" } +ckb-stop-handler = { path = "../stop-handler", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } numext-fixed-uint = "0.1" rhai = { version = "1.16.0", features = ["no_function", "no_float", "no_module", "sync"]} rocksdb = { package = "ckb-rocksdb", version ="=0.21.1", features = ["snappy"], default-features = false } diff --git a/util/indexer/Cargo.toml b/util/indexer/Cargo.toml index 0dc7cb657f..65c5582f46 100644 --- a/util/indexer/Cargo.toml +++ b/util/indexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-indexer" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,12 +11,12 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } -ckb-app-config = { path = "../app-config", version = "= 0.118.0" } -ckb-notify = { path = "../../notify", version = "= 0.118.0" } -ckb-async-runtime = { path = "../runtime", version = "= 0.118.0" } -ckb-indexer-sync = { path = "../indexer-sync", version = "= 0.118.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } +ckb-app-config = { path = "../app-config", version = "= 0.119.0" } +ckb-notify = { path = "../../notify", version = "= 0.119.0" } +ckb-async-runtime = { path = "../runtime", version = "= 0.119.0" } +ckb-indexer-sync = { path = "../indexer-sync", version = "= 0.119.0" } rocksdb = { package = "ckb-rocksdb", version ="=0.21.1", features = ["snappy"], default-features = false } memchr = "2.7" diff --git a/util/instrument/Cargo.toml b/util/instrument/Cargo.toml index acfc0c7e0b..baf4e0de0a 100644 --- a/util/instrument/Cargo.toml +++ b/util/instrument/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-instrument" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,11 +9,11 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-chain = { path = "../../chain", version = "= 0.118.0" } -ckb-chain-iter = { path = "../chain-iter", version = "= 0.118.0" } -ckb-shared = { path = "../../shared", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-chain = { path = "../../chain", version = "= 0.119.0" } +ckb-chain-iter = { path = "../chain-iter", version = "= 0.119.0" } +ckb-shared = { path = "../../shared", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } serde_json = "1.0" indicatif = { version = "0.16", optional = true } diff --git a/util/jsonrpc-types/Cargo.toml b/util/jsonrpc-types/Cargo.toml index 352b545973..9fb4f7945e 100644 --- a/util/jsonrpc-types/Cargo.toml +++ b/util/jsonrpc-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-jsonrpc-types" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../types", version = "= 0.118.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" faster-hex = "0.6" diff --git a/util/launcher/Cargo.toml b/util/launcher/Cargo.toml index b6d4a14d8c..b12873d13c 100644 --- a/util/launcher/Cargo.toml +++ b/util/launcher/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-launcher" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,28 +11,32 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } -ckb-app-config = { path = "../app-config", version = "= 0.118.0" } -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-build-info = { path = "../build-info", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } -ckb-chain = { path = "../../chain", version = "= 0.118.0" } -ckb-shared = { path = "../../shared", version = "= 0.118.0" } -ckb-network = { path = "../../network", version = "= 0.118.0" } -ckb-rpc = { path = "../../rpc", version = "= 0.118.0" } -ckb-resource = { path = "../../resource", version = "= 0.118.0" } -ckb-network-alert = { path = "../network-alert", version = "= 0.118.0" } -ckb-sync = { path = "../../sync", version = "= 0.118.0" } -ckb-verification = { path = "../../verification", version = "= 0.118.0" } -ckb-verification-traits = { path = "../../verification/traits", version = "= 0.118.0" } -ckb-async-runtime = { path = "../runtime", version = "= 0.118.0" } -ckb-channel = { path = "../channel", version = "= 0.118.0" } -ckb-tx-pool = { path = "../../tx-pool", version = "= 0.118.0" } -ckb-light-client-protocol-server = { path = "../light-client-protocol-server", version = "= 0.118.0" } -ckb-block-filter = { path = "../../block-filter", version = "= 0.118.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } +ckb-app-config = { path = "../app-config", version = "= 0.119.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-build-info = { path = "../build-info", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } +ckb-chain = { path = "../../chain", version = "= 0.119.0" } +ckb-shared = { path = "../../shared", version = "= 0.119.0" } +ckb-network = { path = "../../network", version = "= 0.119.0" } +ckb-rpc = { path = "../../rpc", version = "= 0.119.0" } +ckb-resource = { path = "../../resource", version = "= 0.119.0" } +ckb-network-alert = { path = "../network-alert", version = "= 0.119.0" } +ckb-sync = { path = "../../sync", version = "= 0.119.0" } +ckb-verification = { path = "../../verification", version = "= 0.119.0" } +ckb-verification-traits = { path = "../../verification/traits", version = "= 0.119.0" } +ckb-async-runtime = { path = "../runtime", version = "= 0.119.0" } +ckb-channel = { path = "../channel", version = "= 0.119.0" } +ckb-tx-pool = { path = "../../tx-pool", version = "= 0.119.0" } +ckb-light-client-protocol-server = { path = "../light-client-protocol-server", version = "= 0.119.0" } +ckb-block-filter = { path = "../../block-filter", version = "= 0.119.0" } [features] -with_sentry = ["ckb-sync/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry"] +with_sentry = [ + "ckb-sync/with_sentry", + "ckb-network/with_sentry", + "ckb-app-config/with_sentry" +] portable = ["ckb-shared/portable"] march-native = ["ckb-shared/march-native"] diff --git a/util/launcher/src/lib.rs b/util/launcher/src/lib.rs index 1598953e25..2c21a3291d 100644 --- a/util/launcher/src/lib.rs +++ b/util/launcher/src/lib.rs @@ -21,9 +21,8 @@ use ckb_network::{ use ckb_network_alert::alert_relayer::AlertRelayer; use ckb_resource::Resource; use ckb_rpc::{RpcServer, ServiceBuilder}; -use ckb_shared::{ChainServicesBuilder, Shared}; - use ckb_shared::shared_builder::{SharedBuilder, SharedPackage}; +use ckb_shared::{ChainServicesBuilder, Shared}; use ckb_store::ChainDB; use ckb_sync::{BlockFilter, NetTimeProtocol, Relayer, SyncShared, Synchronizer}; use ckb_tx_pool::service::TxVerificationResult; diff --git a/util/light-client-protocol-server/Cargo.toml b/util/light-client-protocol-server/Cargo.toml index 74e047295e..2fc2e73f36 100644 --- a/util/light-client-protocol-server/Cargo.toml +++ b/util/light-client-protocol-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-light-client-protocol-server" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,22 +9,22 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-network = { path = "../../network", version = "= 0.118.0" } -ckb-shared = { path = "../../shared", version = "= 0.118.0" } -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } +ckb-network = { path = "../../network", version = "= 0.119.0" } +ckb-shared = { path = "../../shared", version = "= 0.119.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } ckb-merkle-mountain-range = "0.5.2" -ckb-systemtime = {path = "../systemtime", version = "= 0.118.0"} +ckb-systemtime = {path = "../systemtime", version = "= 0.119.0"} [dev-dependencies] -ckb-chain = { path = "../../chain", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-tx-pool = { path = "../../tx-pool", version = "= 0.118.0" } -ckb-app-config = { path = "../app-config", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } -ckb-dao-utils = { path = "../dao/utils", version = "= 0.118.0" } -ckb-test-chain-utils = { path = "../test-chain-utils", version = "= 0.118.0" } +ckb-chain = { path = "../../chain", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-tx-pool = { path = "../../tx-pool", version = "= 0.119.0" } +ckb-app-config = { path = "../app-config", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } +ckb-dao-utils = { path = "../dao/utils", version = "= 0.119.0" } +ckb-test-chain-utils = { path = "../test-chain-utils", version = "= 0.119.0" } tempfile.workspace = true -ckb-systemtime = {path = "../systemtime", version = "= 0.118.0", features = ["enable_faketime"]} +ckb-systemtime = {path = "../systemtime", version = "= 0.119.0", features = ["enable_faketime"]} tokio = "1.20" diff --git a/util/logger-config/Cargo.toml b/util/logger-config/Cargo.toml index 36d21a3470..e858ad039c 100644 --- a/util/logger-config/Cargo.toml +++ b/util/logger-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-logger-config" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" diff --git a/util/logger-service/Cargo.toml b/util/logger-service/Cargo.toml index 00cf9cbbc4..9e053355ad 100644 --- a/util/logger-service/Cargo.toml +++ b/util/logger-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-logger-service" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" @@ -9,9 +9,9 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-util = { path = "..", version = "= 0.118.0" } -ckb-logger-config = { path = "../logger-config", version = "= 0.118.0" } -ckb-channel = { path = "../channel", version = "= 0.118.0" } +ckb-util = { path = "..", version = "= 0.119.0" } +ckb-logger-config = { path = "../logger-config", version = "= 0.119.0" } +ckb-channel = { path = "../channel", version = "= 0.119.0" } yansi = "0.5" log = "0.4" env_logger = "0.10" @@ -22,7 +22,7 @@ sentry = { version = "0.26.0", optional = true, features = ["log"] } time = { version = "0.3.11", features = ["formatting"] } [dev-dependencies] -ckb-logger = { path = "../logger", version = "= 0.118.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } tempfile.workspace = true [features] diff --git a/util/logger/Cargo.toml b/util/logger/Cargo.toml index 43722dd221..4d5739620e 100644 --- a/util/logger/Cargo.toml +++ b/util/logger/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-logger" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" diff --git a/util/memory-tracker/Cargo.toml b/util/memory-tracker/Cargo.toml index a2ac1f1ca5..ed8fd3354c 100644 --- a/util/memory-tracker/Cargo.toml +++ b/util/memory-tracker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-memory-tracker" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,9 +9,9 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-metrics = { path = "../metrics", version = "= 0.118.0" } -ckb-db = { path = "../../db", version = "= 0.118.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-metrics = { path = "../metrics", version = "= 0.119.0" } +ckb-db = { path = "../../db", version = "= 0.119.0" } [target.'cfg(all(not(target_env = "msvc"), not(target_os="macos")))'.dependencies] jemalloc-ctl = { package = "tikv-jemalloc-ctl", version = "0.5.0" } diff --git a/util/metrics-config/Cargo.toml b/util/metrics-config/Cargo.toml index 97e53c2fe7..64bf0dae81 100644 --- a/util/metrics-config/Cargo.toml +++ b/util/metrics-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-metrics-config" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" diff --git a/util/metrics-service/Cargo.toml b/util/metrics-service/Cargo.toml index 63bb589128..99c5910114 100644 --- a/util/metrics-service/Cargo.toml +++ b/util/metrics-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-metrics-service" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" @@ -9,11 +9,11 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-metrics-config = { path = "../metrics-config", version = "= 0.118.0" } -ckb-metrics = { path = "../metrics", version = "= 0.118.0" } -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-async-runtime = { path = "../runtime", version = "= 0.118.0" } -ckb-util = { path = "..", version = "= 0.118.0" } +ckb-metrics-config = { path = "../metrics-config", version = "= 0.119.0" } +ckb-metrics = { path = "../metrics", version = "= 0.119.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-async-runtime = { path = "../runtime", version = "= 0.119.0" } +ckb-util = { path = "..", version = "= 0.119.0" } prometheus = "0.13.3" hyper = { version = "0.14", features = ["http1", "tcp", "server"] } -ckb-stop-handler = { path = "../stop-handler", version = "= 0.118.0" } +ckb-stop-handler = { path = "../stop-handler", version = "= 0.119.0" } diff --git a/util/metrics/Cargo.toml b/util/metrics/Cargo.toml index ac9589871a..59636f4a94 100644 --- a/util/metrics/Cargo.toml +++ b/util/metrics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-metrics" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" diff --git a/util/migrate/Cargo.toml b/util/migrate/Cargo.toml index b2d208904a..f4f1662066 100644 --- a/util/migrate/Cargo.toml +++ b/util/migrate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-migrate" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,21 +11,21 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-migration-template = { path = "migration-template", version = "= 0.118.0" } -ckb-db = { path = "../../db", version = "= 0.118.0" } -ckb-error = { path = "../../error", version = "= 0.118.0" } -ckb-db-schema = { path = "../../db-schema", version = "= 0.118.0" } -ckb-db-migration = { path = "../../db-migration", version = "= 0.118.0" } -ckb-app-config = { path = "../app-config", version = "= 0.118.0" } -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-hash = { path = "../hash", version = "= 0.118.0" } +ckb-migration-template = { path = "migration-template", version = "= 0.119.0" } +ckb-db = { path = "../../db", version = "= 0.119.0" } +ckb-error = { path = "../../error", version = "= 0.119.0" } +ckb-db-schema = { path = "../../db-schema", version = "= 0.119.0" } +ckb-db-migration = { path = "../../db-migration", version = "= 0.119.0" } +ckb-app-config = { path = "../app-config", version = "= 0.119.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-hash = { path = "../hash", version = "= 0.119.0" } tempfile.workspace = true num_cpus = "1.10" [dev-dependencies] -ckb-systemtime = {path = "../systemtime", version = "= 0.118.0", features = ["enable_faketime"] } +ckb-systemtime = {path = "../systemtime", version = "= 0.119.0", features = ["enable_faketime"] } [features] portable = ["ckb-db/portable", "ckb-db-migration/portable"] diff --git a/util/migrate/migration-template/Cargo.toml b/util/migrate/migration-template/Cargo.toml index 2d99eefc4e..8a4ff7a697 100644 --- a/util/migrate/migration-template/Cargo.toml +++ b/util/migrate/migration-template/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-migration-template" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" diff --git a/util/multisig/Cargo.toml b/util/multisig/Cargo.toml index ad2dce7e72..ee03001c75 100644 --- a/util/multisig/Cargo.toml +++ b/util/multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-multisig" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,9 +9,9 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-error = { path = "../../error", version = "= 0.118.0" } -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-crypto = { path = "../crypto", version = "= 0.118.0" } +ckb-error = { path = "../../error", version = "= 0.119.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-crypto = { path = "../crypto", version = "= 0.119.0" } [dev-dependencies] rand = "0.8" diff --git a/util/network-alert/Cargo.toml b/util/network-alert/Cargo.toml index d1a69aaae2..7ac0ad12c3 100644 --- a/util/network-alert/Cargo.toml +++ b/util/network-alert/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-network-alert" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,23 +9,23 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-multisig = { path = "../multisig", version = "= 0.118.0" } -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-util = { path = "..", version = "= 0.118.0" } -ckb-network = { path = "../../network", version = "= 0.118.0" } -ckb-notify = { path = "../../notify", version = "= 0.118.0"} -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } -ckb-logger = { path = "../logger", version = "= 0.118.0"} -ckb-app-config = { path = "../app-config", version = "= 0.118.0" } -ckb-error = { path = "../../error", version = "= 0.118.0" } -ckb-systemtime = { path = "../systemtime", version = "= 0.118.0" } +ckb-multisig = { path = "../multisig", version = "= 0.119.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-util = { path = "..", version = "= 0.119.0" } +ckb-network = { path = "../../network", version = "= 0.119.0" } +ckb-notify = { path = "../../notify", version = "= 0.119.0"} +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0"} +ckb-app-config = { path = "../app-config", version = "= 0.119.0" } +ckb-error = { path = "../../error", version = "= 0.119.0" } +ckb-systemtime = { path = "../systemtime", version = "= 0.119.0" } lru = "0.7.1" semver = "1.0" [dev-dependencies] -ckb-crypto = { path = "../crypto", version = "= 0.118.0" } -ckb-async-runtime = { path = "../runtime", version = "= 0.118.0" } +ckb-crypto = { path = "../crypto", version = "= 0.119.0" } +ckb-async-runtime = { path = "../runtime", version = "= 0.119.0" } once_cell = "1.8.0" -ckb-systemtime = {path = "../systemtime", version = "= 0.118.0", features = ["enable_faketime"]} +ckb-systemtime = {path = "../systemtime", version = "= 0.119.0", features = ["enable_faketime"]} faster-hex = "0.6" serde_json = "1.0" diff --git a/util/occupied-capacity/Cargo.toml b/util/occupied-capacity/Cargo.toml index 0dd271b963..ecdc8676a0 100644 --- a/util/occupied-capacity/Cargo.toml +++ b/util/occupied-capacity/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-occupied-capacity" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,5 +9,5 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-occupied-capacity-macros = { path = "macros", version = "= 0.118.0" } -ckb-occupied-capacity-core = { path = "core", version = "= 0.118.0" } +ckb-occupied-capacity-macros = { path = "macros", version = "= 0.119.0" } +ckb-occupied-capacity-core = { path = "core", version = "= 0.119.0" } diff --git a/util/occupied-capacity/core/Cargo.toml b/util/occupied-capacity/core/Cargo.toml index d51fdadd0a..20a353d885 100644 --- a/util/occupied-capacity/core/Cargo.toml +++ b/util/occupied-capacity/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-occupied-capacity-core" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/util/occupied-capacity/macros/Cargo.toml b/util/occupied-capacity/macros/Cargo.toml index 7ca7d79132..35ff07a2d4 100644 --- a/util/occupied-capacity/macros/Cargo.toml +++ b/util/occupied-capacity/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-occupied-capacity-macros" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -14,4 +14,4 @@ proc-macro = true [dependencies] quote = "1.0" syn = "1.0" -ckb-occupied-capacity-core = { path = "../core", version = "= 0.118.0" } +ckb-occupied-capacity-core = { path = "../core", version = "= 0.119.0" } diff --git a/util/proposal-table/Cargo.toml b/util/proposal-table/Cargo.toml index 9bdfd5e5aa..af18d1f726 100644 --- a/util/proposal-table/Cargo.toml +++ b/util/proposal-table/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-proposal-table" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -10,6 +10,6 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-types = { path = "../types", version = "= 0.118.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } diff --git a/util/rational/Cargo.toml b/util/rational/Cargo.toml index ac202ce0f7..a2a2d7e04d 100644 --- a/util/rational/Cargo.toml +++ b/util/rational/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-rational" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/util/reward-calculator/Cargo.toml b/util/reward-calculator/Cargo.toml index 6e20236c87..145b7af7f7 100644 --- a/util/reward-calculator/Cargo.toml +++ b/util/reward-calculator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-reward-calculator" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,15 +9,15 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } -ckb-dao = { path = "../dao", version = "= 0.118.0" } -ckb-dao-utils = { path = "../dao/utils", version = "= 0.118.0" } -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-chain-spec = {path = "../../spec", version = "= 0.118.0"} +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } +ckb-dao = { path = "../dao", version = "= 0.119.0" } +ckb-dao-utils = { path = "../dao/utils", version = "= 0.119.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-chain-spec = {path = "../../spec", version = "= 0.119.0"} [dev-dependencies] -ckb-db = { path = "../../db", version = "= 0.118.0" } -ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.118.0" } -ckb-db-schema = { path = "../../db-schema", version = "= 0.118.0" } +ckb-db = { path = "../../db", version = "= 0.119.0" } +ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.119.0" } +ckb-db-schema = { path = "../../db-schema", version = "= 0.119.0" } tempfile.workspace = true diff --git a/util/rich-indexer/Cargo.toml b/util/rich-indexer/Cargo.toml index d8200634c2..fccee2179b 100644 --- a/util/rich-indexer/Cargo.toml +++ b/util/rich-indexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-rich-indexer" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -12,18 +12,25 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] anyhow = "1.0.34" -ckb-app-config = { path = "../app-config", version = "= 0.118.0" } -ckb-async-runtime = { path = "../runtime", version = "= 0.118.0" } -ckb-indexer-sync = { path = "../indexer-sync", version = "= 0.118.0" } -ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.118.0" } -ckb-notify = { path = "../../notify", version = "= 0.118.0" } -ckb-types = { path = "../types", version = "= 0.118.0" } +ckb-app-config = { path = "../app-config", version = "= 0.119.0" } +ckb-async-runtime = { path = "../runtime", version = "= 0.119.0" } +ckb-indexer-sync = { path = "../indexer-sync", version = "= 0.119.0" } +ckb-jsonrpc-types = { path = "../jsonrpc-types", version = "= 0.119.0" } +ckb-notify = { path = "../../notify", version = "= 0.119.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } futures = "0.3" 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.workspace = true [dev-dependencies] hex = "0.4" diff --git a/util/rich-indexer/resources/create_postgres_index.sql b/util/rich-indexer/resources/create_postgres_index.sql index dc26cf048b..9f7e4a559e 100644 --- a/util/rich-indexer/resources/create_postgres_index.sql +++ b/util/rich-indexer/resources/create_postgres_index.sql @@ -1,15 +1,15 @@ -CREATE INDEX "index_block_table_block_hash" ON "block" ("block_hash"); +CREATE INDEX IF NOT EXISTS "index_block_table_block_hash" ON "block" ("block_hash"); -CREATE INDEX "index_block_association_proposal_table_block_id" ON "block_association_proposal" ("block_id"); -CREATE INDEX "index_block_association_uncle_table_block_id" ON "block_association_uncle" ("block_id"); +CREATE INDEX IF NOT EXISTS "index_block_association_proposal_table_block_id" ON "block_association_proposal" ("block_id"); +CREATE INDEX IF NOT EXISTS "index_block_association_uncle_table_block_id" ON "block_association_uncle" ("block_id"); -CREATE INDEX "index_tx_table_tx_hash" ON "ckb_transaction" ("tx_hash"); -CREATE INDEX "index_tx_table_block_id" ON "ckb_transaction" ("block_id"); -CREATE INDEX "index_tx_association_header_dep_table_tx_id" ON "tx_association_header_dep" ("tx_id"); -CREATE INDEX "index_tx_association_cell_dep_table_tx_id" ON "tx_association_cell_dep" ("tx_id"); +CREATE INDEX IF NOT EXISTS "index_tx_table_tx_hash" ON "ckb_transaction" ("tx_hash"); +CREATE INDEX IF NOT EXISTS "index_tx_table_block_id" ON "ckb_transaction" ("block_id"); +CREATE INDEX IF NOT EXISTS "index_tx_association_header_dep_table_tx_id" ON "tx_association_header_dep" ("tx_id"); +CREATE INDEX IF NOT EXISTS "index_tx_association_cell_dep_table_tx_id" ON "tx_association_cell_dep" ("tx_id"); -CREATE INDEX "idx_output_table_tx_id_output_index" ON "output" ("tx_id", "output_index"); -CREATE INDEX "idx_output_table_lock_script_id" ON "output" ("lock_script_id"); -CREATE INDEX "idx_output_table_type_script_id" ON "output" ("type_script_id"); +CREATE INDEX IF NOT EXISTS "idx_output_table_tx_id_output_index" ON "output" ("tx_id", "output_index"); +CREATE INDEX IF NOT EXISTS "idx_output_table_lock_script_id" ON "output" ("lock_script_id"); +CREATE INDEX IF NOT EXISTS "idx_output_table_type_script_id" ON "output" ("type_script_id"); -CREATE INDEX "idx_input_table_consumed_tx_id" ON "input" ("consumed_tx_id"); \ No newline at end of file +CREATE INDEX IF NOT EXISTS "idx_input_table_consumed_tx_id" ON "input" ("consumed_tx_id"); diff --git a/util/rich-indexer/resources/create_postgres_table.sql b/util/rich-indexer/resources/create_postgres_table.sql index f743425a06..8a86b977ca 100644 --- a/util/rich-indexer/resources/create_postgres_table.sql +++ b/util/rich-indexer/resources/create_postgres_table.sql @@ -1,4 +1,4 @@ -CREATE TABLE block( +CREATE TABLE IF NOT EXISTS block( id BIGSERIAL PRIMARY KEY, block_hash BYTEA NOT NULL, block_number BIGINT NOT NULL, @@ -15,19 +15,19 @@ CREATE TABLE block( extension BYTEA ); -CREATE TABLE block_association_proposal( +CREATE TABLE IF NOT EXISTS block_association_proposal( id BIGSERIAL, block_id BIGINT NOT NULL, proposal BYTEA NOT NULL ); -CREATE TABLE block_association_uncle( +CREATE TABLE IF NOT EXISTS block_association_uncle( id BIGSERIAL, block_id BIGINT NOT NULL, uncle_id BIGINT NOT NULL ); -CREATE TABLE ckb_transaction( +CREATE TABLE IF NOT EXISTS ckb_transaction( id BIGSERIAL PRIMARY KEY, tx_hash BYTEA NOT NULL, version BYTEA NOT NULL, @@ -38,20 +38,20 @@ CREATE TABLE ckb_transaction( tx_index INTEGER NOT NULL ); -CREATE TABLE tx_association_header_dep( +CREATE TABLE IF NOT EXISTS tx_association_header_dep( id BIGSERIAL, tx_id BIGINT NOT NULL, block_id BIGINT NOT NULL ); -CREATE TABLE tx_association_cell_dep( +CREATE TABLE IF NOT EXISTS tx_association_cell_dep( id BIGSERIAL, tx_id BIGINT NOT NULL, output_id BIGINT NOT NULL, dep_type SMALLINT NOT NULL ); -CREATE TABLE output( +CREATE TABLE IF NOT EXISTS output( id BIGSERIAL PRIMARY KEY, tx_id BIGINT NOT NULL, output_index INTEGER NOT NULL, @@ -61,14 +61,14 @@ CREATE TABLE output( data BYTEA ); -CREATE TABLE input( +CREATE TABLE IF NOT EXISTS input( output_id BIGINT PRIMARY KEY, since BYTEA NOT NULL, consumed_tx_id BIGINT NOT NULL, input_index INTEGER NOT NULL ); -CREATE TABLE script( +CREATE TABLE IF NOT EXISTS script( id BIGSERIAL PRIMARY KEY, code_hash BYTEA NOT NULL, hash_type SMALLINT NOT NULL, diff --git a/util/rich-indexer/resources/create_sqlite_index.sql b/util/rich-indexer/resources/create_sqlite_index.sql index 4cb6128b29..9f7e4a559e 100644 --- a/util/rich-indexer/resources/create_sqlite_index.sql +++ b/util/rich-indexer/resources/create_sqlite_index.sql @@ -1,15 +1,15 @@ -CREATE INDEX "index_block_table_block_hash" ON "block" ("block_hash"); +CREATE INDEX IF NOT EXISTS "index_block_table_block_hash" ON "block" ("block_hash"); -CREATE INDEX "index_block_association_proposal_table_block_id" ON "block_association_proposal" ("block_id"); -CREATE INDEX "index_block_association_uncle_table_block_id" ON "block_association_uncle" ("block_id"); +CREATE INDEX IF NOT EXISTS "index_block_association_proposal_table_block_id" ON "block_association_proposal" ("block_id"); +CREATE INDEX IF NOT EXISTS "index_block_association_uncle_table_block_id" ON "block_association_uncle" ("block_id"); -CREATE INDEX "index_tx_table_tx_hash" ON "ckb_transaction" ("tx_hash"); -CREATE INDEX "index_tx_table_block_id" ON "ckb_transaction" ("block_id"); -CREATE INDEX "index_tx_association_header_dep_table_tx_id" ON "tx_association_header_dep" ("tx_id"); -CREATE INDEX "index_tx_association_cell_dep_table_tx_id" ON "tx_association_cell_dep" ("tx_id"); +CREATE INDEX IF NOT EXISTS "index_tx_table_tx_hash" ON "ckb_transaction" ("tx_hash"); +CREATE INDEX IF NOT EXISTS "index_tx_table_block_id" ON "ckb_transaction" ("block_id"); +CREATE INDEX IF NOT EXISTS "index_tx_association_header_dep_table_tx_id" ON "tx_association_header_dep" ("tx_id"); +CREATE INDEX IF NOT EXISTS "index_tx_association_cell_dep_table_tx_id" ON "tx_association_cell_dep" ("tx_id"); -CREATE INDEX "idx_output_table_tx_id_output_index" ON "output" ("tx_id", "output_index"); -CREATE INDEX "idx_output_table_lock_script_id" ON "output" ("lock_script_id"); -CREATE INDEX "idx_output_table_type_script_id" ON "output" ("type_script_id"); +CREATE INDEX IF NOT EXISTS "idx_output_table_tx_id_output_index" ON "output" ("tx_id", "output_index"); +CREATE INDEX IF NOT EXISTS "idx_output_table_lock_script_id" ON "output" ("lock_script_id"); +CREATE INDEX IF NOT EXISTS "idx_output_table_type_script_id" ON "output" ("type_script_id"); -CREATE INDEX "idx_input_table_consumed_tx_id" ON "input" ("consumed_tx_id"); +CREATE INDEX IF NOT EXISTS "idx_input_table_consumed_tx_id" ON "input" ("consumed_tx_id"); diff --git a/util/rich-indexer/resources/create_sqlite_table.sql b/util/rich-indexer/resources/create_sqlite_table.sql index ca85b20e5e..98026eab7c 100644 --- a/util/rich-indexer/resources/create_sqlite_table.sql +++ b/util/rich-indexer/resources/create_sqlite_table.sql @@ -1,4 +1,4 @@ -CREATE TABLE block( +CREATE TABLE IF NOT EXISTS block( id INTEGER PRIMARY KEY, block_hash BLOB NOT NULL, block_number INTEGER NOT NULL, @@ -15,19 +15,19 @@ CREATE TABLE block( extension BLOB ); -CREATE TABLE block_association_proposal( +CREATE TABLE IF NOT EXISTS block_association_proposal( id INTEGER PRIMARY KEY, block_id INTEGER NOT NULL, proposal BLOB NOT NULL ); -CREATE TABLE block_association_uncle( +CREATE TABLE IF NOT EXISTS block_association_uncle( id INTEGER PRIMARY KEY, block_id INTEGER NOT NULL, uncle_id INTEGER NOT NULL ); -CREATE TABLE ckb_transaction( +CREATE TABLE IF NOT EXISTS ckb_transaction( id INTEGER PRIMARY KEY, tx_hash BLOB NOT NULL, version BLOB NOT NULL, @@ -38,20 +38,20 @@ CREATE TABLE ckb_transaction( tx_index INTEGER NOT NULL ); -CREATE TABLE tx_association_header_dep( +CREATE TABLE IF NOT EXISTS tx_association_header_dep( id INTEGER PRIMARY KEY, tx_id INTEGER NOT NULL, block_id INTEGER NOT NULL ); -CREATE TABLE tx_association_cell_dep( +CREATE TABLE IF NOT EXISTS tx_association_cell_dep( id INTEGER PRIMARY KEY, tx_id INTEGER NOT NULL, output_id INTEGER NOT NULL, dep_type INTEGER NOT NULL ); -CREATE TABLE output( +CREATE TABLE IF NOT EXISTS output( id INTEGER PRIMARY KEY, tx_id INTEGER NOT NULL, output_index INTEGER NOT NULL, @@ -61,14 +61,14 @@ CREATE TABLE output( data BLOB ); -CREATE TABLE input( +CREATE TABLE IF NOT EXISTS input( output_id INTEGER PRIMARY KEY, since BLOB NOT NULL, consumed_tx_id INTEGER NOT NULL, input_index INTEGER NOT NULL ); -CREATE TABLE script( +CREATE TABLE IF NOT EXISTS script( id INTEGER PRIMARY KEY, code_hash BLOB NOT NULL, hash_type INTEGER NOT NULL, diff --git a/util/rich-indexer/resources/migrations/20240603_add_is_spent_to_output.sql b/util/rich-indexer/resources/migrations/20240603_add_is_spent_to_output.sql new file mode 100644 index 0000000000..a7cd72d02c --- /dev/null +++ b/util/rich-indexer/resources/migrations/20240603_add_is_spent_to_output.sql @@ -0,0 +1,9 @@ +-- 20240630_add_is_spent_to_output.sql + +ALTER TABLE output +ADD COLUMN is_spent INTEGER DEFAULT 0; + +UPDATE output +SET is_spent = 1 +FROM input +WHERE input.output_id = output.id; diff --git a/util/rich-indexer/src/indexer/insert.rs b/util/rich-indexer/src/indexer/insert.rs index 9c8831b347..54ebf61869 100644 --- a/util/rich-indexer/src/indexer/insert.rs +++ b/util/rich-indexer/src/indexer/insert.rs @@ -400,6 +400,32 @@ pub(crate) async fn bulk_insert_tx_association_cell_dep_table( .await } +pub(crate) async fn spend_cell( + out_point: &OutPoint, + tx: &mut Transaction<'_, Any>, +) -> Result { + let output_tx_hash = out_point.tx_hash().raw_data().to_vec(); + let output_index: u32 = out_point.index().unpack(); + + let updated_rows = sqlx::query( + r#" + UPDATE output + SET is_spent = 1 + WHERE + tx_id = (SELECT ckb_transaction.id FROM ckb_transaction WHERE tx_hash = $1) + AND output_index = $2 + "#, + ) + .bind(output_tx_hash) + .bind(output_index as i32) + .execute(tx.as_mut()) + .await + .map_err(|err| Error::DB(err.to_string()))? + .rows_affected(); + + Ok(updated_rows > 0) +} + pub(crate) async fn query_output_cell( out_point: &OutPoint, tx: &mut Transaction<'_, Any>, @@ -432,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()))?; @@ -458,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"))) @@ -482,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"))) @@ -502,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"))) @@ -640,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()))?; } @@ -669,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/mod.rs b/util/rich-indexer/src/indexer/mod.rs index 32c395f775..a92d2bfb74 100644 --- a/util/rich-indexer/src/indexer/mod.rs +++ b/util/rich-indexer/src/indexer/mod.rs @@ -201,6 +201,9 @@ impl AsyncRichIndexer { if tx_index != 0 { for (input_index, input) in tx_view.inputs().into_iter().enumerate() { let out_point = input.previous_output(); + if !spend_cell(&out_point, tx).await? { + break; + } if self.custom_filters.is_cell_filter_enabled() { if let Some((output_id, output, output_data)) = query_output_cell(&out_point, tx).await? diff --git a/util/rich-indexer/src/indexer/remove.rs b/util/rich-indexer/src/indexer/remove.rs index 56114f4c32..5b4d2266d1 100644 --- a/util/rich-indexer/src/indexer/remove.rs +++ b/util/rich-indexer/src/indexer/remove.rs @@ -14,6 +14,9 @@ pub(crate) async fn rollback_block(tx: &mut Transaction<'_, Any>) -> Result<(), let tx_id_list = query_tx_id_list_by_block_id(block_id, tx).await?; let output_lock_type_list = query_outputs_by_tx_id_list(&tx_id_list, tx).await?; + // update spent cells + reset_spent_cells(&tx_id_list, tx).await?; + // remove transactions, associations, inputs, output remove_batch_by_blobs("ckb_transaction", "id", &tx_id_list, tx).await?; remove_batch_by_blobs("tx_association_cell_dep", "tx_id", &tx_id_list, tx).await?; @@ -73,7 +76,29 @@ async fn remove_batch_by_blobs( // execute query - .execute(tx) + .execute(tx.as_mut()) + .await + .map_err(|err| Error::DB(err.to_string()))?; + + Ok(()) +} + +async fn reset_spent_cells(tx_id_list: &[i64], tx: &mut Transaction<'_, Any>) -> Result<(), Error> { + let query = SqlBuilder::update_table("output") + .set("is_spent", 0) + .and_where_in_query( + "id", + SqlBuilder::select_from("input") + .field("output_id") + .and_where_in("consumed_tx_id", tx_id_list) + .query() + .map_err(|err| Error::DB(err.to_string()))?, + ) + .sql() + .map_err(|err| Error::DB(err.to_string()))?; + + sqlx::query(&query) + .execute(tx.as_mut()) .await .map_err(|err| Error::DB(err.to_string()))?; @@ -92,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())) @@ -106,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())) @@ -125,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() @@ -160,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| { @@ -190,10 +215,14 @@ 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()))?; + if row_lock.get::(0) == 1 { + return Ok(true); + } + let row_type = sqlx::query( r#" SELECT EXISTS ( @@ -204,11 +233,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_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_cells.rs b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells.rs index 100a5eaca0..fdd501ecc2 100644 --- a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells.rs +++ b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells.rs @@ -104,9 +104,7 @@ impl AsyncRichIndexerHandle { .join(name!("script";"lock_script")) .on("output.lock_script_id = lock_script.id"), } - .join("input") - .on("output.id = input.output_id") - .and_where("input.output_id IS NULL"); // live cells + .and_where("output.is_spent = 0"); // live cells // filter cells in pool let mut dead_cells = Vec::new(); diff --git a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs index 5a14d90592..5c5aee71fe 100644 --- a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs +++ b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_cells_capacity.rs @@ -51,27 +51,25 @@ impl AsyncRichIndexerHandle { .join("ckb_transaction") .on("output.tx_id = ckb_transaction.id"); } - query_builder - .left() - .join("input") - .on("output.id = input.output_id"); if let Some(ref filter) = search_key.filter { if filter.script.is_some() || filter.script_len_range.is_some() { match search_key.script_type { IndexerScriptType::Lock => { query_builder + .left() .join(name!("script";"type_script")) .on("output.type_script_id = type_script.id"); } IndexerScriptType::Type => { query_builder + .left() .join(name!("script";"lock_script")) .on("output.lock_script_id = lock_script.id"); } } } } - query_builder.and_where("input.output_id IS NULL"); // live cells + query_builder.and_where("output.is_spent = 0"); // live cells // filter cells in pool let mut dead_cells = Vec::new(); 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 d9caa7f6fe..1855997983 100644 --- a/util/rich-indexer/src/store.rs +++ b/util/rich-indexer/src/store.rs @@ -1,25 +1,29 @@ use anyhow::{anyhow, Result}; 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, 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; -use std::fs::OpenOptions; +use std::fs::{self, OpenOptions}; use std::marker::{Send, Unpin}; 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"); const SQL_POSTGRES_CREATE_INDEX: &str = include_str!("../resources/create_postgres_index.sql"); +static MIGRATIONS_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/resources/migrations"); #[derive(Clone, Default)] pub struct SQLXPool { @@ -36,54 +40,69 @@ impl Debug for SQLXPool { } impl SQLXPool { - pub fn new() -> Self { - SQLXPool { - pool: Arc::new(OnceCell::new()), - db_driver: DBDriver::default(), - } - } - 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)); - match db_config.db_type { + 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); + create_sqlite(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 - .set(pool) + .set(pool.clone()) .map_err(|_| anyhow!("set pool failed!"))?; - if require_init { - self.create_tables_for_sqlite().await?; - } + self.create_tables_for_sqlite().await?; + self.db_driver = DBDriver::Sqlite; - Ok(()) + pool } DBDriver::Postgres => { - let require_init = self.is_postgres_require_init(db_config).await?; + self.postgres_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 - .set(pool) + .set(pool.clone()) .map_err(|_| anyhow!("set pool failed"))?; - if require_init { - self.create_tables_for_postgres().await?; - } + + self.create_tables_for_postgres().await?; + self.db_driver = DBDriver::Postgres; - Ok(()) + pool } + }; + + // Run migrations + log::info!("Running migrations..."); + let temp_dir = tempdir()?; + for file in MIGRATIONS_DIR.files() { + log::info!("Found migration file: {:?}", file.path()); + let file_path = temp_dir.path().join(file.path()); + if let Some(parent) = file_path.parent() { + fs::create_dir_all(parent)?; + } + fs::write(&file_path, file.contents())?; } + let migrator = Migrator::new(temp_dir.path()).await?; + migrator.run(&pool).await?; + log::info!("Migrations are done."); + + Ok(()) } pub async fn fetch_count(&self, table_name: &str) -> Result { @@ -187,32 +206,27 @@ impl SQLXPool { Ok(()) } - pub async fn is_postgres_require_init( - &mut self, - db_config: &RichIndexerConfig, - ) -> Result { + pub async fn postgres_init(&mut self, db_config: &RichIndexerConfig) -> Result<()> { // Connect to the "postgres" database first 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?; - // Check if database exists let query = SQLXPool::new_query(r#"SELECT EXISTS (SELECT FROM pg_database WHERE datname = $1)"#) .bind(db_config.db_name.as_str()); let row = query.fetch_one(&pool).await?; - // If database does not exist, create it if !row.get::(0) { let query = format!(r#"CREATE DATABASE "{}""#, db_config.db_name); SQLXPool::new_query(&query).execute(&pool).await?; - Ok(true) + Ok(()) } else { - Ok(false) + Ok(()) } } } @@ -234,10 +248,10 @@ fn build_url_for_postgres(db_config: &RichIndexerConfig) -> String { + db_config.db_name.as_str() } -fn is_sqlite_require_init(db_config: &RichIndexerConfig) -> bool { +fn create_sqlite(db_config: &RichIndexerConfig) { // for test if db_config.store == Into::::into(MEMORY_DB) { - return true; + return; } if !db_config.store.exists() { @@ -249,8 +263,5 @@ fn is_sqlite_require_init(db_config: &RichIndexerConfig) -> bool { .create(true) .open(&db_config.store) .expect("Create db file"); - return true; } - - false } 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 { diff --git a/util/runtime/Cargo.toml b/util/runtime/Cargo.toml index c8907f58f3..b546956fd0 100644 --- a/util/runtime/Cargo.toml +++ b/util/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-async-runtime" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -10,5 +10,5 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] tokio = { version = "1", features = ["full"] } -ckb-logger = { path = "../logger", version = "= 0.118.0" } -ckb-spawn = { path = "../spawn", version = "= 0.118.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } +ckb-spawn = { path = "../spawn", version = "= 0.119.0" } diff --git a/util/snapshot/Cargo.toml b/util/snapshot/Cargo.toml index 57aaa1b923..1e0b7dcd71 100644 --- a/util/snapshot/Cargo.toml +++ b/util/snapshot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-snapshot" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -11,15 +11,15 @@ repository = "https://github.com/nervosnetwork/ckb" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = { path = "../types", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } -ckb-db = { path = "../../db", version = "= 0.118.0" } -ckb-traits = { path = "../../traits", version = "= 0.118.0" } -ckb-proposal-table = { path = "../proposal-table", version = "= 0.118.0" } +ckb-types = { path = "../types", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } +ckb-db = { path = "../../db", version = "= 0.119.0" } +ckb-traits = { path = "../../traits", version = "= 0.119.0" } +ckb-proposal-table = { path = "../proposal-table", version = "= 0.119.0" } arc-swap = "1.3" -ckb-db-schema = { path = "../../db-schema", version = "= 0.118.0" } -ckb-freezer = { path = "../../freezer", version = "= 0.118.0" } +ckb-db-schema = { path = "../../db-schema", version = "= 0.119.0" } +ckb-freezer = { path = "../../freezer", version = "= 0.119.0" } ckb-merkle-mountain-range = "0.5.2" [features] diff --git a/util/spawn/Cargo.toml b/util/spawn/Cargo.toml index 98da0f75e7..df9ff68e5c 100644 --- a/util/spawn/Cargo.toml +++ b/util/spawn/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-spawn" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" diff --git a/util/stop-handler/Cargo.toml b/util/stop-handler/Cargo.toml index 6628d3e996..53170cdddf 100644 --- a/util/stop-handler/Cargo.toml +++ b/util/stop-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-stop-handler" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,12 +9,12 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-logger = { path = "../logger", version = "= 0.118.0" } +ckb-logger = { path = "../logger", version = "= 0.119.0" } tokio = { version = "1", features = ["sync", "rt-multi-thread"] } -ckb-channel = { path = "../channel", version = "= 0.118.0" } -ckb-util = { path = "..", version = "= 0.118.0" } +ckb-channel = { path = "../channel", version = "= 0.119.0" } +ckb-util = { path = "..", version = "= 0.119.0" } once_cell = "1.8.0" -ckb-async-runtime = { path = "../runtime", version = "= 0.118.0" } +ckb-async-runtime = { path = "../runtime", version = "= 0.119.0" } tokio-util = "0.7.8" diff --git a/util/systemtime/Cargo.toml b/util/systemtime/Cargo.toml index a996f77018..51b574e229 100644 --- a/util/systemtime/Cargo.toml +++ b/util/systemtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-systemtime" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos "] edition = "2021" diff --git a/util/test-chain-utils/Cargo.toml b/util/test-chain-utils/Cargo.toml index 5311421265..9158a4e712 100644 --- a/util/test-chain-utils/Cargo.toml +++ b/util/test-chain-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-test-chain-utils" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -9,19 +9,19 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = {path = "../types", version = "= 0.118.0"} -ckb-db = { path = "../../db", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-dao-utils = { path = "../dao/utils", version = "= 0.118.0" } -ckb-dao = { path = "../dao", version = "= 0.118.0" } -ckb-traits = { path = "../../traits", version = "= 0.118.0" } +ckb-types = {path = "../types", version = "= 0.119.0"} +ckb-db = { path = "../../db", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-dao-utils = { path = "../dao/utils", version = "= 0.119.0" } +ckb-dao = { path = "../dao", version = "= 0.119.0" } +ckb-traits = { path = "../../traits", version = "= 0.119.0" } lazy_static = "1.3.0" -ckb-systemtime = { path = "../systemtime", version = "= 0.118.0" } -ckb-resource = { path = "../../resource", version = "= 0.118.0" } -ckb-db-schema = { path = "../../db-schema", version = "= 0.118.0" } -ckb-util = { path = "..", version = "= 0.118.0" } +ckb-systemtime = { path = "../systemtime", version = "= 0.119.0" } +ckb-resource = { path = "../../resource", version = "= 0.119.0" } +ckb-db-schema = { path = "../../db-schema", version = "= 0.119.0" } +ckb-util = { path = "..", version = "= 0.119.0" } tempfile.workspace = true [dev-dependencies] -ckb-systemtime = { path = "../systemtime", version = "= 0.118.0", features = ["enable_faketime"] } +ckb-systemtime = { path = "../systemtime", version = "= 0.119.0", features = ["enable_faketime"] } diff --git a/util/types/Cargo.toml b/util/types/Cargo.toml index 83f07751f9..7eb1d31281 100644 --- a/util/types/Cargo.toml +++ b/util/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-types" -version = "0.118.0" +version = "0.119.0" authors = ["Nervos Core Dev "] edition = "2021" license = "MIT" @@ -10,7 +10,7 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] molecule = "0.8" -ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.118.0" } +ckb-fixed-hash = { path = "../fixed-hash", version = "= 0.119.0" } numext-fixed-uint = { version = "0.1", features = [ "support_rand", "support_heapsize", @@ -18,14 +18,14 @@ numext-fixed-uint = { version = "0.1", features = [ ] } bytes = { version = "1", features = ["serde"] } merkle-cbt = "0.3" -ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.118.0" } -ckb-hash = { path = "../hash", version = "= 0.118.0" } -ckb-channel = { path = "../channel", version = "= 0.118.0" } -ckb-constant = { path = "../constant", version = "= 0.118.0" } -ckb-gen-types = { path = "../gen-types", version = "= 0.118.0" } +ckb-occupied-capacity = { path = "../occupied-capacity", version = "= 0.119.0" } +ckb-hash = { path = "../hash", version = "= 0.119.0" } +ckb-channel = { path = "../channel", version = "= 0.119.0" } +ckb-constant = { path = "../constant", version = "= 0.119.0" } +ckb-gen-types = { path = "../gen-types", version = "= 0.119.0" } bit-vec = "0.6.3" -ckb-error = { path = "../../error", version = "= 0.118.0" } -ckb-rational = { path = "../rational", version = "= 0.118.0" } +ckb-error = { path = "../../error", version = "= 0.119.0" } +ckb-rational = { path = "../rational", version = "= 0.119.0" } once_cell = "1.8.0" derive_more = { version = "0.99.0", default-features = false, features = [ "display", diff --git a/util/types/src/core/extras.rs b/util/types/src/core/extras.rs index d42eb66ce6..a7261a2fb5 100644 --- a/util/types/src/core/extras.rs +++ b/util/types/src/core/extras.rs @@ -10,7 +10,15 @@ use std::fmt; use std::num::ParseIntError; use std::str::FromStr; -/// TODO(doc): @quake +/// Represents a block's additional information. +/// +/// It is crucial to ensure that `txs_sizes` has one more element than `txs_fees`, and that `cycles` has the same length as `txs_fees`. +/// +/// `BlockTxsVerifier::verify()` skips the first transaction (the cellbase) in the block. Therefore, `txs_sizes` must have a length equal to `txs_fees` length + 1. +/// +/// Refer to: https://github.com/nervosnetwork/ckb/blob/44afc93cd88a1b52351831dce788d3023c52f37e/verification/contextual/src/contextual_block_verifier.rs#L455 +/// +/// Additionally, the `get_fee_rate_statistics` RPC function requires accurate `txs_sizes` and `txs_fees` data from `BlockExt`. #[derive(Clone, PartialEq, Default, Debug, Eq)] pub struct BlockExt { /// TODO(doc): @quake @@ -21,11 +29,14 @@ pub struct BlockExt { pub total_uncles_count: u64, /// TODO(doc): @quake pub verified: Option, - /// TODO(doc): @quake + /// Transaction fees for each transaction except the cellbase. + /// The length of `txs_fees` is equal to the length of `cycles`. pub txs_fees: Vec, - /// block txs consumed cycles + /// Execution cycles for each transaction except the cellbase. + /// The length of `cycles` is equal to the length of `txs_fees`. pub cycles: Option>, - /// block txs serialized sizes + /// Sizes of each transaction including the cellbase. + /// The length of `txs_sizes` is `txs_fees` length + 1. pub txs_sizes: Option>, } diff --git a/verification/Cargo.toml b/verification/Cargo.toml index 644463a023..5a4d82e2cc 100644 --- a/verification/Cargo.toml +++ b/verification/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-verification" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,21 +9,21 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../util/types", version = "= 0.118.0" } -ckb-script = { path = "../script", version = "= 0.118.0" } -ckb-pow = { path = "../pow", version = "= 0.118.0" } -ckb-systemtime = { path = "../util/systemtime", version = "= 0.118.0" } +ckb-types = { path = "../util/types", version = "= 0.119.0" } +ckb-script = { path = "../script", version = "= 0.119.0" } +ckb-pow = { path = "../pow", version = "= 0.119.0" } +ckb-systemtime = { path = "../util/systemtime", version = "= 0.119.0" } lru = "0.7.1" -ckb-traits = { path = "../traits", version = "= 0.118.0" } -ckb-chain-spec = { path = "../spec", version = "= 0.118.0" } -ckb-dao = { path = "../util/dao", version = "= 0.118.0" } -ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.118.0" } -ckb-error = { path = "../error", version = "= 0.118.0" } +ckb-traits = { path = "../traits", version = "= 0.119.0" } +ckb-chain-spec = { path = "../spec", version = "= 0.119.0" } +ckb-dao = { path = "../util/dao", version = "= 0.119.0" } +ckb-dao-utils = { path = "../util/dao/utils", version = "= 0.119.0" } +ckb-error = { path = "../error", version = "= 0.119.0" } derive_more = { version = "0.99.0", default-features=false, features = ["display"] } -ckb-verification-traits = { path = "./traits", version = "= 0.118.0" } +ckb-verification-traits = { path = "./traits", version = "= 0.119.0" } tokio = { version = "1", features = ["sync", "process"] } [dev-dependencies] -ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.118.0" } -ckb-resource = { path = "../resource", version = "= 0.118.0" } -ckb-systemtime = {path = "../util/systemtime", version = "= 0.118.0", features=["enable_faketime"]} +ckb-test-chain-utils = { path = "../util/test-chain-utils", version = "= 0.119.0" } +ckb-resource = { path = "../resource", version = "= 0.119.0" } +ckb-systemtime = {path = "../util/systemtime", version = "= 0.119.0", features=["enable_faketime"]} diff --git a/verification/contextual/Cargo.toml b/verification/contextual/Cargo.toml index 5b7a8a67b5..606ad319f9 100644 --- a/verification/contextual/Cargo.toml +++ b/verification/contextual/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-verification-contextual" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -9,28 +9,28 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -ckb-types = { path = "../../util/types", version = "= 0.118.0" } -ckb-store = { path = "../../store", version = "= 0.118.0" } -ckb-systemtime = { path = "../../util/systemtime", version = "= 0.118.0" } +ckb-types = { path = "../../util/types", version = "= 0.119.0" } +ckb-store = { path = "../../store", version = "= 0.119.0" } +ckb-systemtime = { path = "../../util/systemtime", version = "= 0.119.0" } rayon = "1.0" -ckb-traits = { path = "../../traits", version = "= 0.118.0" } -ckb-chain-spec = { path = "../../spec", version = "= 0.118.0" } -ckb-dao = { path = "../../util/dao", version = "= 0.118.0" } -ckb-dao-utils = { path = "../../util/dao/utils", version = "= 0.118.0" } -ckb-logger = { path = "../../util/logger", version = "= 0.118.0" } -ckb-reward-calculator = { path = "../../util/reward-calculator", version = "= 0.118.0" } -ckb-error = { path = "../../error", version = "= 0.118.0" } +ckb-traits = { path = "../../traits", version = "= 0.119.0" } +ckb-chain-spec = { path = "../../spec", version = "= 0.119.0" } +ckb-dao = { path = "../../util/dao", version = "= 0.119.0" } +ckb-dao-utils = { path = "../../util/dao/utils", version = "= 0.119.0" } +ckb-logger = { path = "../../util/logger", version = "= 0.119.0" } +ckb-reward-calculator = { path = "../../util/reward-calculator", version = "= 0.119.0" } +ckb-error = { path = "../../error", version = "= 0.119.0" } tokio = { version = "1", features = ["sync", "rt-multi-thread"] } -ckb-async-runtime = { path = "../../util/runtime", version = "= 0.118.0" } -ckb-verification-traits = { path = "../traits", version = "= 0.118.0" } -ckb-verification = { path = "..", version = "= 0.118.0" } +ckb-async-runtime = { path = "../../util/runtime", version = "= 0.119.0" } +ckb-verification-traits = { path = "../traits", version = "= 0.119.0" } +ckb-verification = { path = "..", version = "= 0.119.0" } ckb-merkle-mountain-range = "0.5.2" [dev-dependencies] -ckb-chain = { path = "../../chain", version = "= 0.118.0" } -ckb-shared = { path = "../../shared", version = "= 0.118.0" } -ckb-test-chain-utils = { path = "../../util/test-chain-utils", version = "= 0.118.0" } -ckb-systemtime = { path = "../../util/systemtime", version = "= 0.118.0", features = [ +ckb-chain = { path = "../../chain", version = "= 0.119.0" } +ckb-shared = { path = "../../shared", version = "= 0.119.0" } +ckb-test-chain-utils = { path = "../../util/test-chain-utils", version = "= 0.119.0" } +ckb-systemtime = { path = "../../util/systemtime", version = "= 0.119.0", features = [ "enable_faketime", ] } rand = "0.8" diff --git a/verification/traits/Cargo.toml b/verification/traits/Cargo.toml index 3488b8a64b..bbcf15e6ec 100644 --- a/verification/traits/Cargo.toml +++ b/verification/traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-verification-traits" -version = "0.118.0" +version = "0.119.0" license = "MIT" authors = ["Nervos Core Dev "] edition = "2021" @@ -10,4 +10,4 @@ repository = "https://github.com/nervosnetwork/ckb" [dependencies] bitflags = "1.0" -ckb-error = { path = "../../error", version = "= 0.118.0" } +ckb-error = { path = "../../error", version = "= 0.119.0" }