From 3bc6c51251a04044f04e74833195f45e774a986a Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 1 Aug 2024 09:44:10 +0800 Subject: [PATCH 01/13] chore(ci): replace runner macos-11 with macos-12 --- .github/workflows/ci.yaml | 6 +++--- .github/workflows/package.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 51725d83..14f19377 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-11, windows-latest ] + os: [ ubuntu-latest, macos-12, windows-latest ] steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable @@ -39,7 +39,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-11 ] + os: [ ubuntu-latest, macos-12 ] steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@stable @@ -52,7 +52,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-11 ] + os: [ ubuntu-latest, macos-12 ] steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@stable diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index 9b56ba4c..d7e8642e 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -151,7 +151,7 @@ jobs: package-for-mac: name: package-for-mac - runs-on: macos-11 + runs-on: macos-12 steps: - uses: actions/checkout@v2 - name: Set Env From 4403cf2f4dd6bfc29a133b2fbf7af0211df3d695 Mon Sep 17 00:00:00 2001 From: xG0Ian <161547940+xG0Ian@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:23:10 +0800 Subject: [PATCH 02/13] fix: fix empty git commit version of cli --- .github/workflows/package.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index d7e8642e..0b892f8a 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -72,7 +72,7 @@ jobs: name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: - BUILDER_IMAGE: nervos/ckb-docker-builder:bionic-rust-1.71.1-openssl-3.1.3 + BUILDER_IMAGE: nervos/ckb-docker-builder:bionic-rust-1.75.0 REL_PKG: x86_64-unknown-linux-gnu.tar.gz package-for-linux-aarch64: @@ -146,7 +146,7 @@ jobs: name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: - BUILDER_IMAGE: nervos/ckb-docker-builder:centos-7-rust-1.71.1-openssl-3.1.3 + BUILDER_IMAGE: nervos/ckb-docker-builder:centos-7-rust-1.75.0 REL_PKG: x86_64-unknown-centos-gnu.tar.gz package-for-mac: From b784c2a7922ad75754274d24270bd96a9ea28d24 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Wed, 28 Aug 2024 15:47:17 +0800 Subject: [PATCH 03/13] Bump ckb dependencies to 0.118.0 Signed-off-by: Eval EXEC --- Cargo.lock | 113 +++++++++++++++++++------------------ Cargo.toml | 24 ++++---- Makefile | 2 +- ckb-signer/Cargo.toml | 8 +-- plugin-protocol/Cargo.toml | 4 +- rust-toolchain | 2 +- test/Cargo.toml | 8 +-- 7 files changed, 81 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2023660f..07f03904 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -472,15 +472,15 @@ dependencies = [ [[package]] name = "ckb-build-info" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b5fb6fdcd08f97e028afaa7ea6fad90f42c5b9fea30eb0a30f317345f3ad290" +checksum = "a61fdde886670b1da5948bd952996df6a113b733b8610e2833dd3d113d2fd9ec" [[package]] name = "ckb-chain-spec" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ffb29f6ab04123164b3595c7dc9b94c637483fe92d97395bfd8ef111c31b09" +checksum = "38fa470ac81179a066b3dd3e0d56e8fb9988aaddf5c2ae921cbc2ee6c60bbc56" dependencies = [ "cacache", "ckb-constant", @@ -501,9 +501,9 @@ dependencies = [ [[package]] name = "ckb-channel" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c229f77b57d68bdeafef6d7eea370ec7d03fa4493832cd9b4501cad6697c03" +checksum = "081350579a7d6cee3c7d3b82b3667860517e785269f8cd72b27ae472775d9c04" dependencies = [ "crossbeam-channel", ] @@ -584,15 +584,15 @@ dependencies = [ [[package]] name = "ckb-constant" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf660b69c25989be516a4c2c047555cb4584f33a565396a5f35fc46ef3f3e04d" +checksum = "fce0d46bfe7d555b60e7e1b589643bcd2d6a40e4cc0a04c5e9412dbb30c1f206" [[package]] name = "ckb-crypto" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7617bdf7797b9717eebcdb8bc4cb9c9ccc12f965a35090b319ed73c2eda36d" +checksum = "d2b268e177104ec7089656562adac06dd8209298873cb806fff76c1d3df16566" dependencies = [ "ckb-fixed-hash", "faster-hex", @@ -604,9 +604,9 @@ dependencies = [ [[package]] name = "ckb-dao-utils" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b4b523467ff9c7ccd06182779c2bbe4e580d4ac8e1dbb410a1120402163a94" +checksum = "1df36dfa384153423e777f3f40beeb5fbb42d5ba223d411d7850bf72e190428e" dependencies = [ "byteorder", "ckb-error", @@ -615,9 +615,9 @@ dependencies = [ [[package]] name = "ckb-error" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48b42e9c95f10c2b81af526df9014578440dbc0100b56959283a12795961fde2" +checksum = "e6726194aed3b38485270e64d3823b3fb5e9d7ce6ea2ea117106f97619272de5" dependencies = [ "anyhow", "ckb-occupied-capacity", @@ -627,9 +627,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a9d9d694bf53671361c828343ea50c3c7cdb66aaafb8e4dfa209d0a137a779" +checksum = "e497f03441f4622bc6d1d44db95ff47c37bec03ef2c8132ca19ac8005c70995f" dependencies = [ "ckb-fixed-hash-core", "ckb-fixed-hash-macros", @@ -637,9 +637,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-core" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "104486d82104a99080bd9c462529789fc5b31d791a592b8ec455f2163bf5a3d0" +checksum = "bb5f80c82b9b0498272f085b86824cfe0b76a2c04ee653a91f9ff362fd9b6f6c" dependencies = [ "ckb_schemars", "faster-hex", @@ -649,9 +649,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-macros" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d40a5aa1ea857fcab168743d4969e2ae73db381b2637b6a74fab745baba030" +checksum = "00ede2291016d17450e9d117fac6fb515629779e31ea452d5146a117cd12bf0f" dependencies = [ "ckb-fixed-hash-core", "proc-macro2", @@ -661,9 +661,9 @@ dependencies = [ [[package]] name = "ckb-gen-types" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b72a8f82b47ddcc49c68a1fbaf4e6b105c85747b44cdb9bb2d2b37e55e85e5e" +checksum = "e0a7891f62f4ae4f018bfde91a46178c78491a1dfee740a20b994003a23f10af" dependencies = [ "cfg-if 1.0.0", "ckb-error", @@ -676,9 +676,9 @@ dependencies = [ [[package]] name = "ckb-hash" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5231fff400578e6a6d9c9758138a6cfb190d1acbd28f1b5d40e7fcb13f133e9a" +checksum = "d96b7aec74956ae5e79d0fc68e5903dc2b133c2c64644514485bbc9feb5367eb" dependencies = [ "blake2b-ref", "blake2b-rs", @@ -686,9 +686,9 @@ dependencies = [ [[package]] name = "ckb-jsonrpc-types" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5176b756c8685d7ff9578d0e0e5f6714070c29f8ca924074188c1478ac57782f" +checksum = "44e622a66404770b52da9dfbc9b994f2b711ea2368ef23cc9b1c96ca38491ecf" dependencies = [ "ckb-types", "ckb_schemars", @@ -699,9 +699,9 @@ dependencies = [ [[package]] name = "ckb-logger" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f24db59d6f0994136a98371bc35f72ec912d40dd98921ec25968a3d549f656" +checksum = "c76af0252cd14e57fafac7c67282eedb9c7bbf40a529ed4eb1bb85067b767e7a" dependencies = [ "log", ] @@ -717,9 +717,9 @@ dependencies = [ [[package]] name = "ckb-mock-tx-types" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd1f3410f697e2a9eb95cc77f21a0340ca2074ebc2641c89fd99e8e1c2a0002" +checksum = "fd785084e7c3903cb49f0d2abb12c56880827cae14723cd4fed1bf3fa26a74db" dependencies = [ "ckb-jsonrpc-types", "ckb-traits", @@ -729,9 +729,9 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67df5d5ce8cef497295a1b31cf34536dcdfc16747de540e5c8bd76738f0da753" +checksum = "5e01910f17fcdb1850df67a5b340bbb98d18948eacb476fc85d9a7699294d7ab" dependencies = [ "ckb-occupied-capacity-core", "ckb-occupied-capacity-macros", @@ -739,18 +739,18 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-core" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ecbb7cd4e90f38e4726a1f0cd443463db9c29d348aa660368485cf9665d1ae" +checksum = "21ead5905cedba4acf082f88723c8f42a508bd28fd9c00e1dbf170049ef778b4" dependencies = [ "serde", ] [[package]] name = "ckb-occupied-capacity-macros" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f8b5144e5371c4f61aa2b9b6e668b6a7b5a6562c3c4b8874d414c14d48f9e7" +checksum = "893198354933ba8fa0a1d99c013c819a295f6ae30b1af89fc14e0b62d7afa024" dependencies = [ "ckb-occupied-capacity-core", "quote", @@ -759,9 +759,9 @@ dependencies = [ [[package]] name = "ckb-pow" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f7965a9f0c35ab68f71a008cd7186b4dea02bd8d17dc7263f927d005ee6a52" +checksum = "069c3db99adb9d350d186de8e02a43e77dff7be2a8b9b7cf61ba80a280e2dd00" dependencies = [ "byteorder", "ckb-hash", @@ -773,9 +773,9 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea12dfe40f80068b593a65d59484b7541444f10c629f78ceba20b1a0ef95f68d" +checksum = "7be813511d1c17a6bab8a7dcfbee6e086aa2bae3bb77cfd4a570abfb67af2c16" dependencies = [ "numext-fixed-uint", "serde", @@ -783,9 +783,9 @@ dependencies = [ [[package]] name = "ckb-resource" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdded224077d7ead2d76d376786e63a46d93f8e3cc54db9edebf32c51ba0ae31" +checksum = "d1e74f9bc4039a4cf6d579dc8b444b3d76780e51aab94daccdd5e6e58d01cc32" dependencies = [ "ckb-system-scripts", "ckb-types", @@ -798,9 +798,9 @@ dependencies = [ [[package]] name = "ckb-script" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa80e54fbaf4287121adb59b77b537d38b3a79c2a0a23613a464ab5830d76c9" +checksum = "f6b92a1f4f059f4680b08817dfb739a40356dcf4798b3cb8ae1f1d67218eb0fb" dependencies = [ "byteorder", "ckb-chain-spec", @@ -812,13 +812,14 @@ dependencies = [ "ckb-vm", "faster-hex", "serde", + "tokio", ] [[package]] name = "ckb-sdk" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "454dacfa54b511d07d05bbe5062b21389bc57d33b93e0f6848a850db09d82499" +checksum = "03ffec62a524764661f5e64349fceccee1a677197fcef625a5fb93efd1a31100" dependencies = [ "anyhow", "bech32 0.8.1", @@ -894,18 +895,18 @@ dependencies = [ [[package]] name = "ckb-traits" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510e8db7af6ed58c322449c23c62b50ff717ea6f9803a22cea1e11b4763f7fb4" +checksum = "b6500281355bbf7a235fb386b2883e8ffb8cb5bab8447bd86dd229148ec52704" dependencies = [ "ckb-types", ] [[package]] name = "ckb-types" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "764f9fa9be640bea12227d4b16db4ed595dd04e89a457d67db7c73cd632cdb8d" +checksum = "88f4ef54b7665440d1984489c580e8d540888496d7b9ff8d57262ac583ff97a4" dependencies = [ "bit-vec", "bytes 1.6.1", @@ -929,9 +930,9 @@ dependencies = [ [[package]] name = "ckb-util" -version = "0.117.0" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fa24bb50554532b42fddba5b83c5b0215a0aaacbe73a8724944fa70eebff6b" +checksum = "1611d9ce4a3bc9ba8f3635f7f0f1d5574b389ee8de49d7c684a306996798169a" dependencies = [ "linked-hash-map", "once_cell", @@ -941,9 +942,9 @@ dependencies = [ [[package]] name = "ckb-vm" -version = "0.24.9" +version = "0.24.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c3d68dc7f891e5555c7ebc054722b28ab005e51c5076f54c20d36002dc8e83" +checksum = "ddff96029d3298cb630e95f29d4b9a93384e938a0b75758684aa8794b53bdd1a" dependencies = [ "byteorder", "bytes 1.6.1", @@ -959,9 +960,9 @@ dependencies = [ [[package]] name = "ckb-vm-definitions" -version = "0.24.9" +version = "0.24.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2fdf9c8ee14409b2208d23b9ad88828242d7881153ddc04872b66d2e018a52f" +checksum = "c280bf1d589d23ab0358f58601c2187fc6be86a131644583ef72ea96a0a13ddd" dependencies = [ "paste", ] diff --git a/Cargo.toml b/Cargo.toml index 61174cd8..ac9e4d6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,17 +10,17 @@ edition = "2021" description = "ckb command line interface" [dependencies] -ckb-jsonrpc-types = "=0.117.0" -ckb-hash = "=0.117.0" -ckb-crypto = { version = "=0.117.0", features = ["secp"] } -ckb-build-info = "=0.117.0" -ckb-types = "=0.117.0" -ckb-util = "=0.117.0" -ckb-error = "=0.117.0" -ckb-script = "=0.117.0" -ckb-chain-spec = "=0.117.0" -ckb-sdk = { version = "3.3.0", features = ["native-tls-vendored"] } -ckb-mock-tx-types = "=0.117.0" +ckb-jsonrpc-types = "=0.118.0" +ckb-hash = "=0.118.0" +ckb-crypto = { version = "=0.118.0", features = ["secp"] } +ckb-build-info = "=0.118.0" +ckb-types = "=0.118.0" +ckb-util = "=0.118.0" +ckb-error = "=0.118.0" +ckb-script = "=0.118.0" +ckb-chain-spec = "=0.118.0" +ckb-sdk = { version = "3.4.0", features = ["native-tls-vendored"] } +ckb-mock-tx-types = "=0.118.0" ckb-signer = { path = "ckb-signer", version = "0.4.1" } plugin-protocol = { path = "plugin-protocol", package = "ckb-cli-plugin-protocol", version = "=1.3.1" } jsonrpc-core-client = "18" @@ -76,7 +76,7 @@ termion = "1.5" rand = "0.7" [build-dependencies] -ckb-build-info = "=0.117.0" +ckb-build-info = "=0.118.0" [workspace] members = ["ckb-signer", "plugin-protocol"] diff --git a/Makefile b/Makefile index a99ef2f3..7fa3a6d9 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ ci: fmt clippy test security-audit check-crates check-licenses git diff --exit-code Cargo.lock integration: - bash devtools/ci/integration.sh v0.116.0-rc2 + bash devtools/ci/integration.sh v0.118.0-rc2 prod: ## Build binary with release profile. cargo build --release diff --git a/ckb-signer/Cargo.toml b/ckb-signer/Cargo.toml index ee6354ea..53e3efcc 100644 --- a/ckb-signer/Cargo.toml +++ b/ckb-signer/Cargo.toml @@ -24,7 +24,7 @@ thiserror = "1.0.30" parking_lot = "0.11" anyhow = "1.0.63" -ckb-types = "=0.117.0" -ckb-hash = "=0.117.0" -ckb-crypto = { version = "=0.117.0", features = ["secp"] } -ckb-sdk = { version = "3.3.0", features = ["native-tls-vendored"] } +ckb-types = "=0.118.0" +ckb-hash = "=0.118.0" +ckb-crypto = { version = "=0.118.0", features = ["secp"] } +ckb-sdk = { version = "3.4.0", features = ["native-tls-vendored"] } diff --git a/plugin-protocol/Cargo.toml b/plugin-protocol/Cargo.toml index e310b8a5..739f2f6f 100644 --- a/plugin-protocol/Cargo.toml +++ b/plugin-protocol/Cargo.toml @@ -9,8 +9,8 @@ description = "ckb-cli plugin protocol" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = "=0.117.0" -ckb-jsonrpc-types = "=0.117.0" +ckb-types = "=0.118.0" +ckb-jsonrpc-types = "=0.118.0" serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0" serde_json = "1.0" diff --git a/rust-toolchain b/rust-toolchain index 68bc7ff2..7c7053aa 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.71.1 +1.75.0 diff --git a/test/Cargo.toml b/test/Cargo.toml index 2dad4a0f..e9c6c206 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -14,12 +14,12 @@ log = "0.4" env_logger = "0.6" toml = "0.5.0" serde_yaml = "0.8.9" -ckb-sdk = { version = "3.3.0", features = ["native-tls-vendored"] } +ckb-sdk = { version = "3.4.0", features = ["native-tls-vendored"] } serde_json = "1.0" -ckb-types = "=0.117.0" -ckb-jsonrpc-types = "=0.117.0" +ckb-types = "=0.118.0" +ckb-jsonrpc-types = "=0.118.0" ckb-app-config = "=0.114.0" -ckb-chain-spec = "=0.117.0" +ckb-chain-spec = "=0.118.0" regex = "1.1.6" faster-hex = "0.6" From 4f9761b976f5b844c5ffb203eed52919d8cc02cd Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Thu, 5 Sep 2024 14:51:21 +0800 Subject: [PATCH 04/13] Remove orphan_blocks_size from SyncState --- src/utils/rpc/types.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/utils/rpc/types.rs b/src/utils/rpc/types.rs index 4ebd7f51..6b53d04a 100644 --- a/src/utils/rpc/types.rs +++ b/src/utils/rpc/types.rs @@ -1528,7 +1528,6 @@ pub struct SyncState { pub best_known_block_number: BlockNumber, pub best_known_block_timestamp: Timestamp, pub orphan_blocks_count: Uint64, - pub orphan_blocks_size: Uint64, pub inflight_blocks_count: Uint64, /// Is ckb reached the assume_valid_target? If no assume_valid_target, this will be true. pub assume_valid_target_reached: bool, @@ -1553,7 +1552,6 @@ impl From for SyncState { best_known_block_number: json.best_known_block_number.into(), best_known_block_timestamp: json.best_known_block_timestamp.into(), orphan_blocks_count: json.orphan_blocks_count.value(), - orphan_blocks_size: json.orphan_blocks_size.value(), inflight_blocks_count: json.inflight_blocks_count.value(), assume_valid_target_reached: json.assume_valid_target_reached, assume_valid_target: json.assume_valid_target, From 87cc8e3090c3655c0dbdb2e3f946ba2821b85ef5 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Thu, 5 Sep 2024 14:53:35 +0800 Subject: [PATCH 05/13] MockTransactionHelper<'a>::verify loader to mut --- src/utils/mock_tx_helper.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/mock_tx_helper.rs b/src/utils/mock_tx_helper.rs index 73f4de7c..24835935 100644 --- a/src/utils/mock_tx_helper.rs +++ b/src/utils/mock_tx_helper.rs @@ -313,9 +313,9 @@ impl<'a> MockTransactionHelper<'a> { pub fn verify( &mut self, max_cycle: Cycle, - loader: L, + mut loader: L, ) -> Result { - let resource = Resource::from_both(self.mock_tx, loader)?; + let resource = Resource::from_both(self.mock_tx, &mut loader)?; let tx = self.mock_tx.core_transaction(); let rtx = { resolve_transaction(tx, &mut HashSet::new(), &resource, &resource) From b8bacdc91fbc9b69988328957720ceffed3f5945 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Thu, 5 Sep 2024 14:58:11 +0800 Subject: [PATCH 06/13] Apply cargo-clippy fix --- src/plugin/mod.rs | 2 +- src/subcommands/pubsub.rs | 10 +++++----- src/utils/mock_tx_helper.rs | 2 +- src/utils/rpc/mod.rs | 12 ++++-------- src/utils/rpc/types.rs | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index fca47edf..a1a74b4e 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -1,5 +1,5 @@ mod builtin; mod manager; -pub use manager::{IndexerHandler, KeyStoreHandler, PluginManager}; +pub use manager::{KeyStoreHandler, PluginManager}; pub use plugin_protocol::SignTarget; diff --git a/src/subcommands/pubsub.rs b/src/subcommands/pubsub.rs index 22acb9ee..2e964b99 100644 --- a/src/subcommands/pubsub.rs +++ b/src/subcommands/pubsub.rs @@ -90,7 +90,7 @@ impl CliSubCommand for PubSubCommand { let tcp: SocketAddr = SocketParser.from_matches(m, "tcp")?; let ret = block_on!( tcp, - vec!["new_tip_header"].iter(), + ["new_tip_header"].iter(), HeaderView, self.format, self.color @@ -101,7 +101,7 @@ impl CliSubCommand for PubSubCommand { let tcp: SocketAddr = SocketParser.from_matches(m, "tcp")?; let ret = block_on!( tcp, - vec!["new_tip_block"].iter(), + ["new_tip_block"].iter(), BlockView, self.format, self.color @@ -112,7 +112,7 @@ impl CliSubCommand for PubSubCommand { let tcp: SocketAddr = SocketParser.from_matches(m, "tcp")?; let ret = block_on!( tcp, - vec!["new_transaction"].iter(), + ["new_transaction"].iter(), PoolTransactionEntry, self.format, self.color @@ -123,7 +123,7 @@ impl CliSubCommand for PubSubCommand { let tcp: SocketAddr = SocketParser.from_matches(m, "tcp")?; let ret = block_on!( tcp, - vec!["proposed_transaction"].iter(), + ["proposed_transaction"].iter(), PoolTransactionEntry, self.format, self.color @@ -134,7 +134,7 @@ impl CliSubCommand for PubSubCommand { let tcp: SocketAddr = SocketParser.from_matches(m, "tcp")?; let ret = block_on!( tcp, - vec!["rejected_transaction"].iter(), + ["rejected_transaction"].iter(), (PoolTransactionEntry, PoolTransactionReject), self.format, self.color diff --git a/src/utils/mock_tx_helper.rs b/src/utils/mock_tx_helper.rs index 24835935..4ac7255a 100644 --- a/src/utils/mock_tx_helper.rs +++ b/src/utils/mock_tx_helper.rs @@ -236,7 +236,7 @@ impl<'a> MockTransactionHelper<'a> { H160::from_slice(&lock.args().raw_data()).expect("Convert to H160 failed"); input_group .entry(lock_arg) - .or_insert_with(Vec::new) + .or_default() .push(idx); } } diff --git a/src/utils/rpc/mod.rs b/src/utils/rpc/mod.rs index f7ecfa98..d135b58a 100644 --- a/src/utils/rpc/mod.rs +++ b/src/utils/rpc/mod.rs @@ -4,13 +4,9 @@ mod primitive; mod types; pub use client::{HttpRpcClient, RawHttpRpcClient}; -pub use primitive::{Capacity, EpochNumberWithFraction, Since, Timestamp}; +pub use primitive::{Timestamp}; pub use types::{ - parse_order, Alert, AlertMessage, BannedAddr, Block, BlockEconomicState, BlockIssuance, - BlockResponse, BlockView, Byte32, CellDep, CellInput, CellOutput, ChainInfo, DepType, - EpochView, Header, HeaderView, JsonBytes, LocalNode, MerkleProof, MinerReward, NodeAddress, - OutPoint, PackedBlockResponse, ProposalShortId, RemoteNode, Script, ScriptHashType, - Transaction, TransactionAndWitnessProof, TransactionProof, TransactionView, - TransactionWithStatus, TransactionWithStatusResponse, TxPoolInfo, TxStatus, Uint128, - UncleBlock, UncleBlockView, + parse_order, AlertMessage, BannedAddr, BlockEconomicState, BlockView, ChainInfo, + EpochView, HeaderView, JsonBytes, PackedBlockResponse, RemoteNode, TransactionProof, + TransactionWithStatus, }; diff --git a/src/utils/rpc/types.rs b/src/utils/rpc/types.rs index 6b53d04a..f2bfc3c3 100644 --- a/src/utils/rpc/types.rs +++ b/src/utils/rpc/types.rs @@ -1285,7 +1285,7 @@ impl From for DeploymentsInfo { // cell.rs // ========= -//// TODO: Make `cell::CellData` public +/// TODO: Make `cell::CellData` public // #[derive(Debug, Serialize, Deserialize)] // pub struct CellWithStatus { // pub cell: Option, From 59169ba09a2692c7c80586fc35e922feb86b3d9c Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Fri, 6 Sep 2024 11:51:11 +0800 Subject: [PATCH 07/13] Add NetworkType::Preview Signed-off-by: Eval EXEC --- src/utils/mock_tx_helper.rs | 5 +---- src/utils/rpc/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utils/mock_tx_helper.rs b/src/utils/mock_tx_helper.rs index 4ac7255a..5825cbb8 100644 --- a/src/utils/mock_tx_helper.rs +++ b/src/utils/mock_tx_helper.rs @@ -234,10 +234,7 @@ impl<'a> MockTransactionHelper<'a> { { let lock_arg = H160::from_slice(&lock.args().raw_data()).expect("Convert to H160 failed"); - input_group - .entry(lock_arg) - .or_default() - .push(idx); + input_group.entry(lock_arg).or_default().push(idx); } } diff --git a/src/utils/rpc/mod.rs b/src/utils/rpc/mod.rs index d135b58a..225758c3 100644 --- a/src/utils/rpc/mod.rs +++ b/src/utils/rpc/mod.rs @@ -4,9 +4,9 @@ mod primitive; mod types; pub use client::{HttpRpcClient, RawHttpRpcClient}; -pub use primitive::{Timestamp}; +pub use primitive::Timestamp; pub use types::{ - parse_order, AlertMessage, BannedAddr, BlockEconomicState, BlockView, ChainInfo, - EpochView, HeaderView, JsonBytes, PackedBlockResponse, RemoteNode, TransactionProof, + parse_order, AlertMessage, BannedAddr, BlockEconomicState, BlockView, ChainInfo, EpochView, + HeaderView, JsonBytes, PackedBlockResponse, RemoteNode, TransactionProof, TransactionWithStatus, }; From 676cd9281d0d394f53bcfddbfe82c50d2881c72b Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Wed, 11 Sep 2024 15:11:36 +0800 Subject: [PATCH 08/13] Add clear_tx_verify_queue subcommand Signed-off-by: Eval EXEC --- src/subcommands/rpc.rs | 13 +++++++++++++ src/utils/completer.rs | 17 ++++++++--------- src/utils/rpc/client.rs | 7 +++++++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/subcommands/rpc.rs b/src/subcommands/rpc.rs index e6455b28..8313160d 100644 --- a/src/subcommands/rpc.rs +++ b/src/subcommands/rpc.rs @@ -305,6 +305,7 @@ impl<'a> RpcSubCommand<'a> { .about("Hash of a transaction"), ), App::new("tx_pool_info").about("Get transaction pool information"), + App::new("clear_tx_verify_queue").about("Clear TxPool verify_queue"), App::new("test_tx_pool_accept") .about("Test if transaction can be accepted by Tx Pool") .arg( @@ -1095,6 +1096,18 @@ impl<'a> CliSubCommand for RpcSubCommand<'a> { Ok(Output::new_output(resp)) } } + ("clear_tx_verify_queue", Some(m)) => { + let is_raw_data = is_raw_data || m.is_present("raw-data"); + if is_raw_data { + self.raw_rpc_client + .clear_tx_verify_queue() + .map_err(|err| err.to_string())?; + Ok(Output::new_output(())) + } else { + let _ = self.rpc_client.clear_tx_verify_queue(); + Ok(Output::new_output(())) + } + } ("test_tx_pool_accept", Some(m)) => { let tx_file: PathBuf = FilePathParser::new(false).from_matches(m, "tx-file")?; diff --git a/src/utils/completer.rs b/src/utils/completer.rs index 51757e86..c31e2366 100644 --- a/src/utils/completer.rs +++ b/src/utils/completer.rs @@ -1,7 +1,6 @@ use std::borrow::Cow::{self, Owned}; use std::collections::HashSet; use std::iter; -use std::sync::Arc; use ansi_term::Colour::{Green, Red}; use rustyline::completion::{extract_word, Completer, FilenameCompleter, Pair}; @@ -31,7 +30,7 @@ static ESCAPE_CHAR: Option = None; #[derive(Helper)] pub struct CkbCompleter<'a> { - clap_app: Arc>, + clap_app: clap::App<'a>, completer: FilenameCompleter, validator: MatchingBracketValidator, } @@ -39,13 +38,13 @@ pub struct CkbCompleter<'a> { impl<'a> CkbCompleter<'a> { pub fn new(clap_app: clap::App<'a>) -> Self { CkbCompleter { - clap_app: Arc::new(clap_app), + clap_app, completer: FilenameCompleter::new(), validator: MatchingBracketValidator::new(), } } - pub fn get_completions(app: &Arc>, args: &[String]) -> Vec<(String, String)> { + pub fn get_completions(app: &clap::App<'a>, args: &[String]) -> Vec<(String, String)> { let args_set = args.iter().collect::>(); let switched_completions = |short: Option, long: Option<&str>, multiple: bool, required: bool| { @@ -95,18 +94,18 @@ impl<'a> CkbCompleter<'a> { } pub fn find_subcommand<'s, Iter: iter::Iterator>( - app: Arc>, + app: clap::App<'a>, mut prefix_names: iter::Peekable, - ) -> Option>> { + ) -> Option> { if let Some(name) = prefix_names.next() { for inner_app in app.get_subcommands().iter() { if inner_app.get_name() == name || inner_app.get_all_aliases().any(|alias| alias == name) { return if prefix_names.peek().is_none() { - Some(Arc::new(inner_app.to_owned())) + Some(inner_app.to_owned()) } else { - Self::find_subcommand(Arc::new(inner_app.to_owned()), prefix_names) + Self::find_subcommand(inner_app.to_owned(), prefix_names) }; } } @@ -132,7 +131,7 @@ impl<'a> Completer for CkbCompleter<'a> { let args = shell_words::split(&line[..pos]).unwrap(); let word_lower = word.to_lowercase(); let tmp_pair = Self::find_subcommand( - Arc::clone(&self.clap_app), + self.clap_app.to_owned(), args.iter().map(String::as_str).peekable(), ) .map(|current_app| Self::get_completions(¤t_app, &args)) diff --git a/src/utils/rpc/client.rs b/src/utils/rpc/client.rs index 7ac26222..bdd19f44 100644 --- a/src/utils/rpc/client.rs +++ b/src/utils/rpc/client.rs @@ -376,6 +376,13 @@ impl HttpRpcClient { .map(Into::into) .map_err(|err| err.to_string()) } + pub fn clear_tx_verify_queue(&mut self) -> Result<(), String> { + self.client + .clear_tx_verify_queue() + .map(Into::into) + .map_err(|err| err.to_string()) + } + pub fn test_tx_pool_accept( &mut self, tx: packed::Transaction, From 7bdba60c00951baa7b38bcb5da3bc35fbc5b6c0b Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Wed, 18 Sep 2024 14:53:35 +0800 Subject: [PATCH 09/13] Upgrade ckb-cli to 1.12.0 Signed-off-by: Eval EXEC --- Cargo.lock | 70 ++++++++++++++++-------------------------------------- Cargo.toml | 2 +- 2 files changed, 22 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07f03904..57ea7b30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,38 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aes-ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" -dependencies = [ - "aes-soft", - "aesni", - "cipher", - "ctr", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher", - "opaque-debug 0.3.1", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher", - "opaque-debug 0.3.1", -] - [[package]] name = "ahash" version = "0.7.8" @@ -277,7 +245,7 @@ dependencies = [ "byte-tools", "crypto-mac", "digest 0.8.1", - "opaque-debug 0.2.3", + "opaque-debug", ] [[package]] @@ -463,11 +431,12 @@ dependencies = [ [[package]] name = "cipher" -version = "0.2.5" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array 0.14.7", + "crypto-common", + "inout", ] [[package]] @@ -510,7 +479,7 @@ dependencies = [ [[package]] name = "ckb-cli" -version = "1.11.0" +version = "1.12.0" dependencies = [ "ansi_term", "anyhow", @@ -861,7 +830,6 @@ dependencies = [ name = "ckb-signer" version = "0.4.1" dependencies = [ - "aes-ctr", "anyhow", "bitcoin", "chrono", @@ -869,6 +837,7 @@ dependencies = [ "ckb-hash", "ckb-sdk", "ckb-types", + "ctr", "faster-hex", "parking_lot 0.11.2", "rand 0.7.3", @@ -1154,9 +1123,9 @@ dependencies = [ [[package]] name = "ctr" -version = "0.6.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ "cipher", ] @@ -1879,6 +1848,15 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "instant" version = "0.1.13" @@ -2374,12 +2352,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "openssl" version = "0.10.66" @@ -3312,7 +3284,7 @@ dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", - "opaque-debug 0.2.3", + "opaque-debug", ] [[package]] @@ -3346,7 +3318,7 @@ dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", - "opaque-debug 0.2.3", + "opaque-debug", ] [[package]] @@ -3370,7 +3342,7 @@ dependencies = [ "byte-tools", "digest 0.8.1", "keccak", - "opaque-debug 0.2.3", + "opaque-debug", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ac9e4d6a..97975a02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-cli" -version = "1.11.0" +version = "1.12.0" license = "MIT" authors = [ "Linfeng Qian ", From ed8cb2a9e4758004f1d3059dbaf77faa042a6371 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Wed, 18 Sep 2024 16:56:50 +0800 Subject: [PATCH 10/13] Fix security-audit --- Cargo.lock | 195 +++++++++++++++++++++-------------------- Cargo.toml | 4 +- Makefile | 2 +- deny.toml | 252 ++++++++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 321 insertions(+), 132 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57ea7b30..365b1305 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,38 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes-ctr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" +dependencies = [ + "aes-soft", + "aesni", + "cipher", + "ctr", +] + +[[package]] +name = "aes-soft" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +dependencies = [ + "cipher", + "opaque-debug 0.3.1", +] + +[[package]] +name = "aesni" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" +dependencies = [ + "cipher", + "opaque-debug 0.3.1", +] + [[package]] name = "ahash" version = "0.7.8" @@ -245,7 +277,7 @@ dependencies = [ "byte-tools", "crypto-mac", "digest 0.8.1", - "opaque-debug", + "opaque-debug 0.2.3", ] [[package]] @@ -431,12 +463,11 @@ dependencies = [ [[package]] name = "cipher" -version = "0.4.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "crypto-common", - "inout", + "generic-array 0.14.7", ] [[package]] @@ -830,6 +861,7 @@ dependencies = [ name = "ckb-signer" version = "0.4.1" dependencies = [ + "aes-ctr", "anyhow", "bitcoin", "chrono", @@ -837,7 +869,6 @@ dependencies = [ "ckb-hash", "ckb-sdk", "ckb-types", - "ctr", "faster-hex", "parking_lot 0.11.2", "rand 0.7.3", @@ -1001,6 +1032,15 @@ dependencies = [ "clap", ] +[[package]] +name = "clipboard-win" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" +dependencies = [ + "error-code", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -1123,9 +1163,9 @@ dependencies = [ [[package]] name = "ctr" -version = "0.9.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" dependencies = [ "cipher", ] @@ -1136,7 +1176,7 @@ version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" dependencies = [ - "nix 0.28.0", + "nix", "windows-sys 0.52.0", ] @@ -1215,28 +1255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" dependencies = [ "libc", - "redox_users 0.3.5", - "winapi 0.3.9", -] - -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if 1.0.0", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users 0.4.5", + "redox_users", "winapi 0.3.9", ] @@ -1326,6 +1345,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "error-code" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f" + [[package]] name = "fake-simd" version = "0.1.2" @@ -1344,6 +1369,17 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +[[package]] +name = "fd-lock" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" +dependencies = [ + "cfg-if 1.0.0", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "flate2" version = "1.0.30" @@ -1384,16 +1420,6 @@ dependencies = [ "percent-encoding 2.3.1", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -1683,6 +1709,15 @@ dependencies = [ "digest 0.8.1", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "http" version = "0.2.12" @@ -1848,15 +1883,6 @@ dependencies = [ "hashbrown 0.14.5", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "instant" version = "0.1.13" @@ -2058,16 +2084,6 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.6.0", - "libc", -] - [[package]] name = "linked-hash-map" version = "0.5.6" @@ -2236,18 +2252,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "nix" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cfg-if 1.0.0", - "libc", -] - [[package]] name = "nix" version = "0.28.0" @@ -2352,6 +2356,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + [[package]] name = "openssl" version = "0.10.66" @@ -2905,17 +2915,6 @@ dependencies = [ "rust-argon2", ] -[[package]] -name = "redox_users" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" -dependencies = [ - "getrandom 0.2.15", - "libredox", - "thiserror", -] - [[package]] name = "reflink-copy" version = "0.1.19" @@ -3058,35 +3057,35 @@ dependencies = [ [[package]] name = "rustyline" -version = "8.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e1b597fcd1eeb1d6b25b493538e5aa19629eb08932184b85fef931ba87e893" +checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "cfg-if 1.0.0", - "dirs-next", - "fs2", + "clipboard-win", + "fd-lock", + "home", "libc", "log", "memchr", - "nix 0.20.0", + "nix", "radix_trie", - "scopeguard", - "smallvec", "unicode-segmentation", "unicode-width", "utf8parse", - "winapi 0.3.9", + "windows-sys 0.52.0", ] [[package]] name = "rustyline-derive" -version = "0.4.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db9dfbf470021de34cfaf6983067f460ea19164934a7c2d4b92eec0968eb95f1" +checksum = "e5af959c8bf6af1aff6d2b463a57f71aae53d1332da58419e30ad8dc7011d951" dependencies = [ + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] @@ -3284,7 +3283,7 @@ dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", - "opaque-debug", + "opaque-debug 0.2.3", ] [[package]] @@ -3318,7 +3317,7 @@ dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", - "opaque-debug", + "opaque-debug 0.2.3", ] [[package]] @@ -3342,7 +3341,7 @@ dependencies = [ "byte-tools", "digest 0.8.1", "keccak", - "opaque-debug", + "opaque-debug 0.2.3", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 97975a02..dd965423 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,8 +47,8 @@ atty = "^0.2.10" anyhow = "1.0.63" console = "0.15.0" ctrlc = "3.2.3" -rustyline = "~8.0.0" -rustyline-derive = "0.4.0" +rustyline = "14.0.0" +rustyline-derive = "0.10.0" shell-words = "0.1.0" eaglesong = "0.1" regex = "1.1.6" diff --git a/Makefile b/Makefile index 7fa3a6d9..3179623b 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ prod: ## Build binary with release profile. cargo build --release security-audit: ## Use cargo-deny to audit Cargo.lock for crates with security vulnerabilities. - cargo deny check --hide-inclusion-graph --show-stats advisories sources + cargo deny check --hide-inclusion-graph --show-stats advisories sources -Wunmaintained check-crates: ## Use cargo-deny to check specific crates, detect and handle multiple versions of the same crate and wildcards version requirement. cargo deny check --hide-inclusion-graph --show-stats bans diff --git a/deny.toml b/deny.toml index d4ea1314..1a7fc0c5 100644 --- a/deny.toml +++ b/deny.toml @@ -1,46 +1,236 @@ +# This template contains all of the possible sections and their default values + +# Note that all fields that take a lint level have these possible values: +# * deny - An error will be produced and the check will fail +# * warn - A warning will be produced, but the check will not fail +# * allow - No warning or error will be produced, though in some cases a note +# will be + +# The values provided in this template are the default values that will be used +# when any section or field is not specified in your own configuration + +# Root options + +# The graph table configures how the dependency graph is constructed and thus +# which crates the checks are performed against +[graph] +# If 1 or more target triples (and optionally, target_features) are specified, +# only the specified targets will be checked when running `cargo deny check`. +# This means, if a particular package is only ever used as a target specific +# dependency, such as, for example, the `nix` crate only being used via the +# `target_family = "unix"` configuration, that only having windows targets in +# this list would mean the nix crate, as well as any of its exclusive +# 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"] }, +] +# 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 +# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate +# is pruned from the graph, all of its dependencies will also be pruned unless +# they are connected to another crate in the graph that hasn't been pruned, +# so it should be used with care. The identifiers are [Package ID Specifications] +# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) +#exclude = [] +# If true, metadata will be collected with `--all-features`. Note that this can't +# be toggled off if true, if you want to conditionally enable `--all-features` it +# is recommended to pass `--all-features` on the cmd line instead +all-features = false +# If true, metadata will be collected with `--no-default-features`. The same +# caveat with `all-features` applies +no-default-features = false +# If set, these feature will be enabled when collecting metadata. If `--features` +# is specified on the cmd line they will take precedence over this option. +#features = [] + +# The output table provides options for how/if diagnostics are outputted +[output] +# When outputting inclusion graphs in diagnostics that include features, this +# option can be used to specify the depth at which feature edges will be added. +# This option is included since the graphs can be quite large and the addition +# of features from the crate(s) to all of the graph roots can be far too verbose. +# This option can be overridden via `--feature-depth` on the cmd line +feature-depth = 1 + +# This section is considered when running `cargo deny check advisories` +# More documentation for the advisories section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] -vulnerability = "deny" -unmaintained = "warn" -yanked = "deny" -notice = "deny" +# The path where the advisory databases are cloned/fetched into +#db-path = "$CARGO_HOME/advisory-dbs" +# The url(s) of the advisory databases to use +#db-urls = ["https://github.com/rustsec/advisory-db"] +# A list of advisory IDs to ignore. Note that ignored advisories will still +# output a note when they are encountered. ignore = [ - # TODO Potential segfault in the time crate; waiting for the fix from upstream (chrono) - "RUSTSEC-2020-0071", - # TODO remove this when rustyline updated - "RUSTSEC-2021-0119" + "RUSTSEC-2021-0145" + #"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. +# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. +# See Git Authentication for more information about setting up git authentication. +#git-fetch-with-cli = true +# This section is considered when running `cargo deny check licenses` +# More documentation for the licenses section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html [licenses] -unlicensed = "deny" +# List of explicitly allowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. allow = [ - "Apache-2.0", - "BSD-2-Clause", - "BSD-3-Clause", - "CC0-1.0", - "ISC", - "MIT", - "MITNFA", - "Unicode-DFS-2016", - "BSL-1.0", -] -copyleft = "deny" -default = "deny" + #"MIT", + #"Apache-2.0", + #"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 +# canonical license text of a valid SPDX license file. +# [possible values: any between 0.0 and 1.0]. +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 = [ - { allow = ["MPL-2.0"], name = "colored", version = "*" }, + # Each entry is the crate and version constraint, and its specific allow + # list + #{ allow = ["Zlib"], crate = "adler32" }, ] -[[licenses.clarify]] -name = "ring" -version = "*" -expression = "MIT AND ISC AND OpenSSL" -license-files = [ - { path = "LICENSE", hash = 0xbd0eed23 } +# Some crates don't have (easily) machine readable licensing information, +# adding a clarification entry for it allows you to manually specify the +# licensing information +#[[licenses.clarify]] +# The package spec the clarification applies to +#crate = "ring" +# The SPDX expression for the license requirements of the crate +#expression = "MIT AND ISC AND OpenSSL" +# One or more files in the crate's source used as the "source of truth" for +# the license expression. If the contents match, the clarification will be used +# when running the license check, otherwise the clarification will be ignored +# 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 } +#] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +# To see how to mark a crate as unpublished (to the official registry), +# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. +ignore = false +# One or more private registries that you might publish crates to, if a crate +# is only published to private registries, and ignore is true, the crate will +# not have its license(s) checked +registries = [ + #"https://sekretz.com/registry ] +# This section is considered when running `cargo deny check bans`. +# More documentation about the 'bans' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html [bans] +# Lint level for when multiple versions of the same crate are detected multiple-versions = "warn" -wildcards = "deny" +# Lint level for when a crate version requirement is `*` +wildcards = "allow" +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" +# The default lint level for `default` features for crates that are members of +# the workspace that is being checked. This can be overridden by allowing/denying +# `default` on a crate-by-crate basis if desired. +workspace-default-features = "allow" +# The default lint level for `default` features for external crates that are not +# members of the workspace. This can be overridden by allowing/denying `default` +# on a crate-by-crate basis if desired. +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" }, +] +# 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"] }, +] + +# List of features to allow/deny +# Each entry the name of a crate and a version range. If version is +# not specified, all versions will be matched. +#[[bans.features]] +#crate = "reqwest" +# Features to not allow +#deny = ["json"] +# Features to allow +#allow = [ +# "rustls", +# "__rustls", +# "__tls", +# "hyper-rustls", +# "rustls", +# "rustls-pemfile", +# "rustls-tls-webpki-roots", +# "tokio-rustls", +# "webpki-roots", +#] +# If true, the allowed features must exactly match the enabled feature set. If +# this is set there is no point setting `deny` +#exact = true +# 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" }, +] +# 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 }, +] + +# This section is considered when running `cargo deny check sources`. +# More documentation about the 'sources' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html [sources] -unknown-registry = "deny" -unknown-git = "deny" +# Lint level for what to happen when a crate from a crate registry that is not +# in the allow list is encountered +unknown-registry = "warn" +# Lint level for what to happen when a crate from a git repository that is not +# in the allow list is encountered +unknown-git = "warn" +# List of URLs for allowed crate registries. Defaults to the crates.io index +# if not specified. If it is specified but empty, no registries are allowed. +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +# List of URLs for allowed Git repositories +allow-git = [] + +[sources.allow-org] +# github.com organizations to allow git sources for +github = [] +# gitlab.com organizations to allow git sources for +gitlab = [] +# bitbucket.org organizations to allow git sources for +bitbucket = [] From f1256626a8f5bd89128c6b01e199f6f379ebf6b7 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Wed, 18 Sep 2024 17:18:12 +0800 Subject: [PATCH 11/13] Update rustyline Signed-off-by: Eval EXEC --- .github/workflows/ci.yaml | 2 +- deny.toml | 10 ++++++++++ src/interactive.rs | 31 +++++++++++++++++-------------- src/utils/completer.rs | 14 +++++++------- test/src/spec/udt/mod.rs | 8 ++++---- 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 14f19377..accd3bab 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -71,7 +71,7 @@ jobs: strategy: matrix: checks: - - --hide-inclusion-graph --show-stats advisories sources + - --hide-inclusion-graph --show-stats advisories sources -Wunmaintained - --hide-inclusion-graph --show-stats bans - --hide-inclusion-graph --show-stats licenses steps: diff --git a/deny.toml b/deny.toml index 1a7fc0c5..f5f097a5 100644 --- a/deny.toml +++ b/deny.toml @@ -90,6 +90,16 @@ ignore = [ # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. allow = [ + "Apache-2.0", + "BSD-2-Clause", + "BSD-3-Clause", + "CC0-1.0", + "ISC", + "MIT", + "MITNFA", + "Unicode-DFS-2016", + "BSL-1.0", + "MPL-2.0" #"MIT", #"Apache-2.0", #"Apache-2.0 WITH LLVM-exception", diff --git a/src/interactive.rs b/src/interactive.rs index c99f3442..c91e6164 100644 --- a/src/interactive.rs +++ b/src/interactive.rs @@ -6,6 +6,7 @@ use ansi_term::Colour::Green; use regex::Regex; use rustyline::config::Configurer; use rustyline::error::ReadlineError; +use rustyline::history::FileHistory; use rustyline::{Cmd, CompletionType, Config, EditMode, Editor, KeyEvent}; use serde_json::json; @@ -100,19 +101,20 @@ impl InteractiveEnv { } }; - let rl_mode = |rl: &mut Editor, is_list: bool, is_emacs: bool| { - if is_list { - rl.set_completion_type(CompletionType::List) - } else { - rl.set_completion_type(CompletionType::Circular) - } + let rl_mode = + |rl: &mut Editor, is_list: bool, is_emacs: bool| { + if is_list { + rl.set_completion_type(CompletionType::List) + } else { + rl.set_completion_type(CompletionType::Circular) + } - if is_emacs { - rl.set_edit_mode(EditMode::Emacs) - } else { - rl.set_edit_mode(EditMode::Vi) - } - }; + if is_emacs { + rl.set_edit_mode(EditMode::Emacs) + } else { + rl.set_edit_mode(EditMode::Vi) + } + }; let mut plugin_sub_cmds = Vec::new(); let mut parser = self.parser.clone(); @@ -132,8 +134,9 @@ impl InteractiveEnv { let rl_config = Config::builder() .history_ignore_space(true) .max_history_size(1000) + .map_err(|err| err.to_string())? .build(); - let mut rl = Editor::with_config(rl_config); + let mut rl = Editor::with_config(rl_config).map_err(|err| err.to_string())?; let helper = CkbCompleter::new(parser.clone()); rl.set_helper(Some(helper)); rl.bind_sequence(KeyEvent::alt('n'), Cmd::HistorySearchForward); @@ -160,7 +163,7 @@ impl InteractiveEnv { eprintln!("{}", err); } } - rl.add_history_entry(line.as_str()); + let _ = rl.add_history_entry(line.as_str()); } Err(ReadlineError::Interrupted) => { println!("CTRL-C"); diff --git a/src/utils/completer.rs b/src/utils/completer.rs index c31e2366..7aad2628 100644 --- a/src/utils/completer.rs +++ b/src/utils/completer.rs @@ -12,18 +12,16 @@ use rustyline::{CompletionType, Context}; use rustyline_derive::Helper; #[cfg(unix)] -static DEFAULT_BREAK_CHARS: [u8; 18] = [ - b' ', b'\t', b'\n', b'"', b'\\', b'\'', b'`', b'@', b'$', b'>', b'<', b'=', b';', b'|', b'&', - b'{', b'(', b'\0', +static DEFAULT_BREAK_CHARS: [char; 18] = [ + ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$', '>', '<', '=', ';', '|', '&', '{', '(', '\0', ]; #[cfg(unix)] static ESCAPE_CHAR: Option = Some('\\'); // Remove \ to make file completion works on windows #[cfg(windows)] -static DEFAULT_BREAK_CHARS: [u8; 17] = [ - b' ', b'\t', b'\n', b'"', b'\'', b'`', b'@', b'$', b'>', b'<', b'=', b';', b'|', b'&', b'{', - b'(', b'\0', +static DEFAULT_BREAK_CHARS: [char; 17] = [ + ' ', '\t', '\n', '"', '\'', '`', '@', '$', '>', '<', '=', ';', '|', '&', '{', '(', '\0', ]; #[cfg(windows)] static ESCAPE_CHAR: Option = None; @@ -127,7 +125,9 @@ impl<'a> Completer for CkbCompleter<'a> { pos: usize, ctx: &Context, ) -> Result<(usize, Vec), ReadlineError> { - let (start, word) = extract_word(line, pos, ESCAPE_CHAR, &DEFAULT_BREAK_CHARS); + let (start, word) = extract_word(line, pos, ESCAPE_CHAR, |char| { + DEFAULT_BREAK_CHARS.contains(&char) + }); let args = shell_words::split(&line[..pos]).unwrap(); let word_lower = word.to_lowercase(); let tmp_pair = Self::find_subcommand( diff --git a/test/src/spec/udt/mod.rs b/test/src/spec/udt/mod.rs index 41a25bc1..6701e4f7 100644 --- a/test/src/spec/udt/mod.rs +++ b/test/src/spec/udt/mod.rs @@ -33,9 +33,9 @@ pub fn prepare(setup: &mut Setup, tmp_path: &str) { let owner_key = format!("{}/owner", tmp_path); let account1_key = format!("{}/account1", tmp_path); let account2_key = format!("{}/account2", tmp_path); - fs::write(&owner_key, OWNER_KEY).unwrap(); - fs::write(&account1_key, ACCOUNT1_KEY).unwrap(); - fs::write(&account2_key, ACCOUNT2_KEY).unwrap(); + fs::write(owner_key, OWNER_KEY).unwrap(); + fs::write(account1_key, ACCOUNT1_KEY).unwrap(); + fs::write(account2_key, ACCOUNT2_KEY).unwrap(); let acp_bin = format!("{}/acp", tmp_path); let cheque_bin = format!("{}/cheque", tmp_path); @@ -158,7 +158,7 @@ pub fn prepare(setup: &mut Setup, tmp_path: &str) { let cell_deps_path = format!("{}/cell_deps.json", tmp_path); fs::write( cell_deps_path, - &serde_json::to_string_pretty(&cell_deps).unwrap(), + serde_json::to_string_pretty(&cell_deps).unwrap(), ) .unwrap(); From e677022a13525fe96fb527c1c736fd22a935afca Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Thu, 19 Sep 2024 11:35:11 +0800 Subject: [PATCH 12/13] Integration Test: wait rpc ready before test logic Signed-off-by: Eval EXEC --- test/src/miner.rs | 14 ++++++++++++++ test/src/setup.rs | 2 +- test/src/spec/dao.rs | 24 +++++++++++++++--------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/test/src/miner.rs b/test/src/miner.rs index 03d51b11..1515a9a2 100644 --- a/test/src/miner.rs +++ b/test/src/miner.rs @@ -40,6 +40,20 @@ impl Miner { } } + pub fn wait_rpc_ready(&self) { + let header = self.rpc.lock().unwrap().get_tip_header(); + let now = std::time::Instant::now(); + while now.elapsed().as_secs() < 60 { + if header.is_ok() { + log::info!("rpc is ready"); + return; + } + log::info!("waiting rpc ready..."); + thread::sleep(Duration::from_secs(1)); + } + panic!("rpc not ready") + } + pub fn generate_block(&self) -> H256 { self.rpc .lock() diff --git a/test/src/setup.rs b/test/src/setup.rs index 3a2aaba3..64f78f84 100644 --- a/test/src/setup.rs +++ b/test/src/setup.rs @@ -58,7 +58,7 @@ impl Setup { let ckb_child_process = ckb_cmd .env("RUST_BACKTRACE", "full") .stdin(Stdio::null()) - .stdout(Stdio::null()) + .stdout(Stdio::inherit()) .stderr(Stdio::inherit()) .spawn() .expect("Run `ckb run` failed"); diff --git a/test/src/spec/dao.rs b/test/src/spec/dao.rs index 180802ee..70e6657a 100644 --- a/test/src/spec/dao.rs +++ b/test/src/spec/dao.rs @@ -9,8 +9,16 @@ const LOCK_PERIOD_EPOCHES: u64 = 180; pub struct DaoPrepareOne; +fn generate_lock_period_epochs(setup: &mut Setup) { + (0..LOCK_PERIOD_EPOCHES).for_each(|_i| { + setup.miner().generate_epochs(1, EPOCH_LENGTH); + }); +} + impl Spec for DaoPrepareOne { fn run(&self, setup: &mut Setup) { + setup.miner().wait_rpc_ready(); + let privkey_path = setup.miner().privkey_path().to_string(); assert_eq!(deposited_capacity(setup), 0); assert_eq!(prepared_capacity(setup), 0); @@ -37,9 +45,7 @@ impl Spec for DaoPrepareOne { assert!(output.contains("Immature")); // Drive the chain until since mature and then withdraw - setup - .miner() - .generate_epochs(LOCK_PERIOD_EPOCHES, EPOCH_LENGTH); + generate_lock_period_epochs(setup); let out_points = vec![new_out_point(prepare_tx_hash, 0)]; let _withdraw_tx_hash = withdraw(setup, &out_points); assert_eq!(deposited_capacity(setup), 0); @@ -61,6 +67,8 @@ pub struct DaoPrepareMultiple; impl Spec for DaoPrepareMultiple { fn run(&self, setup: &mut Setup) { + setup.miner().wait_rpc_ready(); + let privkey_path = setup.miner().privkey_path().to_string(); assert_eq!(deposited_capacity(setup), 0); assert_eq!(prepared_capacity(setup), 0); @@ -87,9 +95,7 @@ impl Spec for DaoPrepareMultiple { assert!(output.contains("Immature")); // Drive the chain until since mature and then withdraw - setup - .miner() - .generate_epochs(LOCK_PERIOD_EPOCHES, EPOCH_LENGTH); + generate_lock_period_epochs(setup); let out_points = (0..shannons.len()) .map(|i| new_out_point(&prepare_tx_hash, i)) .collect::>(); @@ -114,6 +120,8 @@ pub struct DaoWithdrawMultiple; impl Spec for DaoWithdrawMultiple { #[allow(clippy::needless_collect)] fn run(&self, setup: &mut Setup) { + setup.miner().wait_rpc_ready(); + assert_eq!(deposited_capacity(setup), 0); assert_eq!(prepared_capacity(setup), 0); @@ -133,9 +141,7 @@ impl Spec for DaoWithdrawMultiple { assert_eq!(prepared_capacity(setup), 40_010_336_948_502); // Drive the chain until since mature and then withdraw - setup - .miner() - .generate_epochs(LOCK_PERIOD_EPOCHES, EPOCH_LENGTH); + generate_lock_period_epochs(setup); let out_points = prepare_tx_hashes .into_iter() .map(|hash| new_out_point(hash, 0)) From 278c7bebba8098b7a3f51a4aeb38aedb5a13119d Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 20 Sep 2024 08:33:19 +0800 Subject: [PATCH 13/13] ci: upgrade actions in package.yaml --- .github/workflows/package.yaml | 466 ++++++++++++++++----------------- 1 file changed, 233 insertions(+), 233 deletions(-) diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index 0b892f8a..6241229d 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -11,7 +11,7 @@ concurrency: on: push: branches: - - 'pkg/*' + - "pkg/*" env: CARGO_TERM_COLOR: always @@ -24,7 +24,7 @@ jobs: outputs: upload_url: ${{ steps.create-release.outputs.upload_url }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set tag run: | export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` @@ -44,33 +44,33 @@ jobs: name: package-for-linux runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set Env - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV - - name: Build and package ckb-cli - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - GPG_SIGNER: ${{ secrets.GPG_SIGNER }} - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - docker run --rm -i -w /ckb-cli -v $(pwd):/ckb-cli $BUILDER_IMAGE make prod - gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg - gpg --import devtools/ci/signer.asc - devtools/ci/package.sh target/release/ckb-cli - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} - - name: upload-zip-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - - name: upload-asc-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + - uses: actions/checkout@v4 + - name: Set Env + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV + - name: Build and package ckb-cli + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + GPG_SIGNER: ${{ secrets.GPG_SIGNER }} + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + docker run --rm -i -w /ckb-cli -v $(pwd):/ckb-cli $BUILDER_IMAGE make prod + gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg + gpg --import devtools/ci/signer.asc + devtools/ci/package.sh target/release/ckb-cli + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} + - name: upload-zip-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + - name: upload-asc-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: BUILDER_IMAGE: nervos/ckb-docker-builder:bionic-rust-1.75.0 REL_PKG: x86_64-unknown-linux-gnu.tar.gz @@ -79,38 +79,38 @@ jobs: name: package-for-linux-aarch64 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set Env - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV - - name: Add rust target - run: rustup target add aarch64-unknown-linux-gnu - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gcc-multilib && sudo apt-get install -y build-essential clang gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - - name: Build and package ckb-cli (aarch64) - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - GPG_SIGNER: ${{ secrets.GPG_SIGNER }} - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - export TOP_DIR=$(pwd) - PKG_CONFIG_ALLOW_CROSS=1 CC=gcc CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc cargo build --target=aarch64-unknown-linux-gnu --release - gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg - gpg --import devtools/ci/signer.asc - devtools/ci/package.sh target/aarch64-unknown-linux-gnu/release/ckb-cli - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} - - name: upload-zip-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - - name: upload-asc-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + - uses: actions/checkout@v4 + - name: Set Env + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV + - name: Add rust target + run: rustup target add aarch64-unknown-linux-gnu + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y gcc-multilib && sudo apt-get install -y build-essential clang gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + - name: Build and package ckb-cli (aarch64) + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + GPG_SIGNER: ${{ secrets.GPG_SIGNER }} + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + export TOP_DIR=$(pwd) + PKG_CONFIG_ALLOW_CROSS=1 CC=gcc CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc cargo build --target=aarch64-unknown-linux-gnu --release + gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg + gpg --import devtools/ci/signer.asc + devtools/ci/package.sh target/aarch64-unknown-linux-gnu/release/ckb-cli + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} + - name: upload-zip-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + - name: upload-asc-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: REL_PKG: aarch64-unknown-linux-gnu.tar.gz @@ -118,33 +118,33 @@ jobs: name: package-for-centos runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set Env - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV - - name: Build and package ckb-cli - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - GPG_SIGNER: ${{ secrets.GPG_SIGNER }} - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - docker run --rm -i -w /ckb-cli -v $(pwd):/ckb-cli $BUILDER_IMAGE make prod - gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg - gpg --import devtools/ci/signer.asc - devtools/ci/package.sh target/release/ckb-cli - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} - - name: upload-zip-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - - name: upload-asc-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + - uses: actions/checkout@v4 + - name: Set Env + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV + - name: Build and package ckb-cli + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + GPG_SIGNER: ${{ secrets.GPG_SIGNER }} + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + docker run --rm -i -w /ckb-cli -v $(pwd):/ckb-cli $BUILDER_IMAGE make prod + gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg + gpg --import devtools/ci/signer.asc + devtools/ci/package.sh target/release/ckb-cli + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} + - name: upload-zip-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + - name: upload-asc-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: BUILDER_IMAGE: nervos/ckb-docker-builder:centos-7-rust-1.75.0 REL_PKG: x86_64-unknown-centos-gnu.tar.gz @@ -153,33 +153,33 @@ jobs: name: package-for-mac runs-on: macos-12 steps: - - uses: actions/checkout@v2 - - name: Set Env - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV - - name: Build and package ckb-cli - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - GPG_SIGNER: ${{ secrets.GPG_SIGNER }} - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - make prod - gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg - gpg --import devtools/ci/signer.asc - devtools/ci/package.sh target/release/ckb-cli - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} - - name: upload-zip-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - - name: upload-asc-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + - uses: actions/checkout@v4 + - name: Set Env + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV + - name: Build and package ckb-cli + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + GPG_SIGNER: ${{ secrets.GPG_SIGNER }} + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + make prod + gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg + gpg --import devtools/ci/signer.asc + devtools/ci/package.sh target/release/ckb-cli + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} + - name: upload-zip-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + - name: upload-asc-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: REL_PKG: x86_64-apple-darwin.zip @@ -187,50 +187,50 @@ jobs: name: package-for-mac-aarch64 runs-on: [self-hosted, macOS, ARM64] steps: - - name: Setup PATH - run: | - echo /opt/homebrew/bin >> $GITHUB_PATH - echo /opt/homebrew/sbin >> $GITHUB_PATH - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install Depedencies - run: | - if ! [ -d /opt/homebrew/opt/openssl@1.1 ]; then - brew install "openssl@1.1" - fi - if ! type -f gpg &> /dev/null; then - brew install gnupg - fi - if ! [ -f "$HOME/.cargo/bin/rustup" ]; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - fi + - name: Setup PATH + run: | + echo /opt/homebrew/bin >> $GITHUB_PATH + echo /opt/homebrew/sbin >> $GITHUB_PATH + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Install Depedencies + run: | + if ! [ -d /opt/homebrew/opt/openssl@1.1 ]; then + brew install "openssl@1.1" + fi + if ! type -f gpg &> /dev/null; then + brew install gnupg + fi + if ! [ -f "$HOME/.cargo/bin/rustup" ]; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + fi - - uses: actions/checkout@v2 - - name: Set Env - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV - - name: Build and package ckb-cli - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - GPG_SIGNER: ${{ secrets.GPG_SIGNER }} - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - make prod - gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg - gpg --import devtools/ci/signer.asc - devtools/ci/package.sh target/release/ckb-cli - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} - mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} - - name: upload-zip-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - - name: upload-asc-file - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + - uses: actions/checkout@v4 + - name: Set Env + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV + - name: Build and package ckb-cli + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + GPG_SIGNER: ${{ secrets.GPG_SIGNER }} + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + make prod + gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output devtools/ci/signer.asc devtools/ci/signer.asc.gpg + gpg --import devtools/ci/signer.asc + devtools/ci/package.sh target/release/ckb-cli + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} ${{ github.workspace }} + mv ${{ github.workspace }}/releases/ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc ${{ github.workspace }} + - name: upload-zip-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + - name: upload-asc-file + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: REL_PKG: aarch64-apple-darwin.zip @@ -238,51 +238,51 @@ jobs: name: package-for-windows runs-on: windows-2019 steps: - - name: Install Dependencies - run: | - iwr -useb get.scoop.sh -outfile 'install-scoop.ps1' - .\install-scoop.ps1 -RunAsAdmin - echo "LIBCLANG_PATH=$($HOME)/scoop/apps/llvm/current/bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - scoop install llvm yasm + - name: Install Dependencies + run: | + iwr -useb get.scoop.sh -outfile 'install-scoop.ps1' + .\install-scoop.ps1 -RunAsAdmin + echo "LIBCLANG_PATH=$($HOME)/scoop/apps/llvm/current/bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + scoop install llvm yasm - echo ("GIT_TAG_NAME=" + $env:GITHUB_REF.replace('refs/heads/pkg/', '')) >> $env:GITHUB_ENV - echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "LIBCLANG_PATH=$env:USERPROFILE\scoop\apps\llvm\current\bin" >> $env:GITHUB_ENV - - uses: actions/checkout@v2 - - name: Build - run: | - make prod - - name: Prepare archive - run: | - $env:GIT_TAG_NAME=($env:GITHUB_REF -split '/')[3] - mkdir ckb-cli_$($env:GIT_TAG_NAME)_x86_64-pc-windows-msvc - cp -r target/release/ckb-cli.exe,README.md,CHANGELOG.md,COPYING ckb-cli_$($env:GIT_TAG_NAME)_x86_64-pc-windows-msvc - - name: Archive Files - run: | - $env:GIT_TAG_NAME=($env:GITHUB_REF -split '/')[3] - Compress-Archive -Path ckb-cli_$($env:GIT_TAG_NAME)_x86_64-pc-windows-msvc -DestinationPath ckb-cli_$($env:GIT_TAG_NAME)_$($env:REL_PKG) - - name: Sign Archive - env: - LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - GPG_SIGNER: ${{ secrets.GPG_SIGNER }} - run: | - $CYGPWD = cygpath -u (Get-Location) - gpg --quiet --batch --yes --decrypt --passphrase="$env:LARGE_SECRET_PASSPHRASE" --output "$CYGPWD/devtools/ci/signer.asc" "$CYGPWD/devtools/ci/signer.asc.gpg" - gpg --import "$CYGPWD/devtools/ci/signer.asc" - $env:GIT_TAG_NAME=($env:GITHUB_REF -split '/')[3] - gpg -u "$env:GPG_SIGNER" -ab "$CYGPWD/ckb-cli_$($env:GIT_TAG_NAME)_$($env:REL_PKG)" - - name: upload-artifact - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} - - name: upload-artifact - uses: actions/upload-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc - path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + echo ("GIT_TAG_NAME=" + $env:GITHUB_REF.replace('refs/heads/pkg/', '')) >> $env:GITHUB_ENV + echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "LIBCLANG_PATH=$env:USERPROFILE\scoop\apps\llvm\current\bin" >> $env:GITHUB_ENV + - uses: actions/checkout@v4 + - name: Build + run: | + make prod + - name: Prepare archive + run: | + $env:GIT_TAG_NAME=($env:GITHUB_REF -split '/')[3] + mkdir ckb-cli_$($env:GIT_TAG_NAME)_x86_64-pc-windows-msvc + cp -r target/release/ckb-cli.exe,README.md,CHANGELOG.md,COPYING ckb-cli_$($env:GIT_TAG_NAME)_x86_64-pc-windows-msvc + - name: Archive Files + run: | + $env:GIT_TAG_NAME=($env:GITHUB_REF -split '/')[3] + Compress-Archive -Path ckb-cli_$($env:GIT_TAG_NAME)_x86_64-pc-windows-msvc -DestinationPath ckb-cli_$($env:GIT_TAG_NAME)_$($env:REL_PKG) + - name: Sign Archive + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + GPG_SIGNER: ${{ secrets.GPG_SIGNER }} + run: | + $CYGPWD = cygpath -u (Get-Location) + gpg --quiet --batch --yes --decrypt --passphrase="$env:LARGE_SECRET_PASSPHRASE" --output "$CYGPWD/devtools/ci/signer.asc" "$CYGPWD/devtools/ci/signer.asc.gpg" + gpg --import "$CYGPWD/devtools/ci/signer.asc" + $env:GIT_TAG_NAME=($env:GITHUB_REF -split '/')[3] + gpg -u "$env:GPG_SIGNER" -ab "$CYGPWD/ckb-cli_$($env:GIT_TAG_NAME)_$($env:REL_PKG)" + - name: upload-artifact + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }} + - name: upload-artifact + uses: actions/upload-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc + path: ckb-cli_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc env: REL_PKG: x86_64-pc-windows-msvc.zip @@ -307,34 +307,34 @@ jobs: - package-for-windows - package-for-centos steps: - - uses: actions/checkout@v2 - - name: Set tag - run: | - export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` - echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV - - name: Prepare - Download tar - uses: actions/download-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }} - - name: Prepare - Download asc - uses: actions/download-artifact@v2 - with: - name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }}.asc - - name: Upload tar assets - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }} - asset_path: ${{ github.workspace }}/ckb-cli_${{env.GIT_TAG_NAME }}_${{ matrix.REL_PKG }} - asset_content_type: application/octet-stream - - name: Upload asc assets - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }}.asc - asset_path: ${{ github.workspace }}/ckb-cli_${{env.GIT_TAG_NAME }}_${{ matrix.REL_PKG }}.asc - asset_content_type: application/octet-stream + - uses: actions/checkout@v4 + - name: Set tag + run: | + export GIT_TAG_NAME=` echo ${{ github.ref }} | awk -F '/' '{print $4}' ` + echo "GIT_TAG_NAME=$GIT_TAG_NAME" >> $GITHUB_ENV + - name: Prepare - Download tar + uses: actions/download-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }} + - name: Prepare - Download asc + uses: actions/download-artifact@v4 + with: + name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }}.asc + - name: Upload tar assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }} + asset_path: ${{ github.workspace }}/ckb-cli_${{env.GIT_TAG_NAME }}_${{ matrix.REL_PKG }} + asset_content_type: application/octet-stream + - name: Upload asc assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_name: ckb-cli_${{env.GIT_TAG_NAME}}_${{ matrix.REL_PKG }}.asc + asset_path: ${{ github.workspace }}/ckb-cli_${{env.GIT_TAG_NAME }}_${{ matrix.REL_PKG }}.asc + asset_content_type: application/octet-stream