From 23f8e89de507485b4fdeb5f24706210e25e759ae Mon Sep 17 00:00:00 2001 From: joii Date: Fri, 12 Jul 2024 22:37:21 +0800 Subject: [PATCH 01/44] Support add debugger --- add-debugger/.gitignore | 2 + add-debugger/Cargo.toml | 14 + add-debugger/README.md | 7 + add-debugger/cargo-generate.toml | 6 + add-debugger/src/contract-lib.rs | 10 + add-debugger/src/lib.rs | 12 + cargo-generate.toml | 1 + workspace/Cargo.lock | 1359 ++++++++++++++++++++++++++++++ workspace/Makefile | 8 + workspace/scripts/add-debugger | 59 ++ 10 files changed, 1478 insertions(+) create mode 100644 add-debugger/.gitignore create mode 100644 add-debugger/Cargo.toml create mode 100644 add-debugger/README.md create mode 100644 add-debugger/cargo-generate.toml create mode 100644 add-debugger/src/contract-lib.rs create mode 100644 add-debugger/src/lib.rs create mode 100644 workspace/Cargo.lock create mode 100755 workspace/scripts/add-debugger diff --git a/add-debugger/.gitignore b/add-debugger/.gitignore new file mode 100644 index 0000000..c3dca1b --- /dev/null +++ b/add-debugger/.gitignore @@ -0,0 +1,2 @@ +/build +/target diff --git a/add-debugger/Cargo.toml b/add-debugger/Cargo.toml new file mode 100644 index 0000000..cd97760 --- /dev/null +++ b/add-debugger/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "{{project-name}}" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies] +{{contract_name}} = { path = "../", features = ["simulator"] } +ckb-std = { version = "0.15.1", features = ["simulator"] } + +[lib] +crate-type = ["cdylib"] + +[workspace] \ No newline at end of file diff --git a/add-debugger/README.md b/add-debugger/README.md new file mode 100644 index 0000000..0d68656 --- /dev/null +++ b/add-debugger/README.md @@ -0,0 +1,7 @@ +# {{project-name}} + +TODO: Write this readme + +*This contract was bootstrapped with [ckb-script-templates].* + +[ckb-script-templates]: https://github.com/cryptape/ckb-script-templates diff --git a/add-debugger/cargo-generate.toml b/add-debugger/cargo-generate.toml new file mode 100644 index 0000000..61ded01 --- /dev/null +++ b/add-debugger/cargo-generate.toml @@ -0,0 +1,6 @@ +[template] +cargo_generate_version = ">=0.16.0" + +[placeholders] +contract_name = { prompt = "contract name", type = "string" } +contract_crate_name = { prompt = "contract crate name", type = "string" } diff --git a/add-debugger/src/contract-lib.rs b/add-debugger/src/contract-lib.rs new file mode 100644 index 0000000..c56df99 --- /dev/null +++ b/add-debugger/src/contract-lib.rs @@ -0,0 +1,10 @@ +#![cfg_attr(not(feature = "simulator"), no_std)] + +// This file will be automatically placed in the contract file, and rename to lib.rs +// TODO +// Need to export main function. +// At the same time, you need to add a feature to the contract's Cargo.toml. +// simulator = ["ckb-std/simulator"] + +// #[cfg(feature = "simulator")] +// pub mod entry; diff --git a/add-debugger/src/lib.rs b/add-debugger/src/lib.rs new file mode 100644 index 0000000..f20e1f7 --- /dev/null +++ b/add-debugger/src/lib.rs @@ -0,0 +1,12 @@ +ckb_std::entry_simulator!(program_entry); +ckb_std::default_alloc!(); + +/// program entry +fn program_entry() -> i8 { + // Call main function and return error code + // match {{contract_crate_name}}::entry::main() { + // Ok(_) => 0, + // Err(err) => err as i8, + // } + 0 +} diff --git a/cargo-generate.toml b/cargo-generate.toml index 1e6c22a..bf2f03d 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -7,6 +7,7 @@ sub_templates = [ "contract", "atomics-contract", "stack-reorder-contract", + "add-debugger-contract" # Dependency crate templates "c-wrapper-crate", "x64-simulator-crate", diff --git a/workspace/Cargo.lock b/workspace/Cargo.lock new file mode 100644 index 0000000..1bf9232 --- /dev/null +++ b/workspace/Cargo.lock @@ -0,0 +1,1359 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "blake2b-ref" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "294d17c72e0ba59fad763caa112368d0672083779cdebbb97164f4bb4c1e339a" + +[[package]] +name = "blake2b-rs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89a8565807f21b913288968e391819e7f9b2f0f46c7b89549c051cccf3a2771" +dependencies = [ + "cc", + "cty", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +dependencies = [ + "serde", +] + +[[package]] +name = "cc" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907d8581360765417f8f2e0e7d602733bbed60156b4465b7617243689ef9b83d" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "ckb-always-success-script" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b3b72a38c9920a29990df12002c4d069a147c8782f0c211f8a01b2df8f42bfd" + +[[package]] +name = "ckb-chain-spec" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa9b89cadf419c220fa8e1c655af73540bbc010e8c0e177127644848a25830c2" +dependencies = [ + "ckb-constant", + "ckb-crypto", + "ckb-dao-utils", + "ckb-error", + "ckb-hash", + "ckb-jsonrpc-types", + "ckb-pow", + "ckb-rational", + "ckb-resource", + "ckb-traits", + "ckb-types", + "ckb-util", + "serde", + "toml", +] + +[[package]] +name = "ckb-channel" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82c904fe3e29474e4d09e8e2775a472456242f8faf18edeeb8c71502710daa38" +dependencies = [ + "crossbeam-channel", +] + +[[package]] +name = "ckb-constant" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d562e7156216f00c5bf55c8f4c86bc25f9ec0603fcfa6df9b66747462a031a" + +[[package]] +name = "ckb-crypto" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abac585cec6f1562e374d66b369c55a52357b33a632d30d2e45cbc455183b22d" +dependencies = [ + "ckb-fixed-hash", + "faster-hex", + "lazy_static", + "rand 0.7.3", + "secp256k1", + "thiserror", +] + +[[package]] +name = "ckb-dao" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c6b5b85ebe6e02bebcc1f1a4db28f1594e1a9e43e8922c05175459f798e844" +dependencies = [ + "byteorder", + "ckb-chain-spec", + "ckb-dao-utils", + "ckb-traits", + "ckb-types", +] + +[[package]] +name = "ckb-dao-utils" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff55485163b842c94061b755c9e6230d1a4bb092b6bc81d8387358911c750e70" +dependencies = [ + "byteorder", + "ckb-error", + "ckb-types", +] + +[[package]] +name = "ckb-error" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8418901ea0d15a8e26255bec0b71be5c59056858f51968894796f77f7eefa3e" +dependencies = [ + "anyhow", + "ckb-occupied-capacity", + "derive_more", + "thiserror", +] + +[[package]] +name = "ckb-fixed-hash" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1254aafda84e9abc85301e9e4c5b920c00a9bff0d42248fccf921b340ec5f13e" +dependencies = [ + "ckb-fixed-hash-core", + "ckb-fixed-hash-macros", +] + +[[package]] +name = "ckb-fixed-hash-core" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffc2850ac8b5643c65913185020de747b290b447d1ee1fd59a2cfdf1a7ceb4f" +dependencies = [ + "faster-hex", + "serde", + "thiserror", +] + +[[package]] +name = "ckb-fixed-hash-macros" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa5a19a7d18caa5a3a65e66506e28943e95696e286df44457a77692319de429" +dependencies = [ + "ckb-fixed-hash-core", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ckb-gen-types" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a12020d50dd3757cde0fdc88d3837b7a2ab503fe38bd11be86ddace11318c77" +dependencies = [ + "cfg-if", + "ckb-error", + "ckb-fixed-hash", + "ckb-hash", + "ckb-occupied-capacity", + "molecule", + "numext-fixed-uint", +] + +[[package]] +name = "ckb-hash" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25af660fc8746f7c756444e6aa47ede9a874206563b6a1ce1b230a5b86519392" +dependencies = [ + "blake2b-ref", + "blake2b-rs", +] + +[[package]] +name = "ckb-jsonrpc-types" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06798b5bacd7fd4125a34f1c9ebf45be59d50aff0ada003bb8b1c6634a447c73" +dependencies = [ + "ckb-types", + "faster-hex", + "serde", + "serde_json", +] + +[[package]] +name = "ckb-logger" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8d8de618d1dbc59ba9e6338a55d17f370f89aa009064dcbdd7eb0c8e8782fe" +dependencies = [ + "log", +] + +[[package]] +name = "ckb-merkle-mountain-range" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ccb671c5921be8a84686e6212ca184cb1d7c51cadcdbfcbd1cc3f042f5dfb8" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ckb-mock-tx-types" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accabfa378c927109844630e4c90e0d7e7e6d6a9174c232f194f490b09e4b757" +dependencies = [ + "ckb-jsonrpc-types", + "ckb-traits", + "ckb-types", + "serde", +] + +[[package]] +name = "ckb-occupied-capacity" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be7132362f12a0495b3b24218afb4e774f9dc0d9254173d2444ec4ac1447461e" +dependencies = [ + "ckb-occupied-capacity-core", + "ckb-occupied-capacity-macros", +] + +[[package]] +name = "ckb-occupied-capacity-core" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4ebe8725d6ee4feb9d376e9a600b2c78cc1dbde5aa754c9a47de871ab917635" +dependencies = [ + "serde", +] + +[[package]] +name = "ckb-occupied-capacity-macros" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201a21d35a377b76440ce12ca62b39e548d019a6330fbdcb40ac0f73fe976cb3" +dependencies = [ + "ckb-occupied-capacity-core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ckb-pow" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5895b4799fbb7e537ef0a778493b8f8678284c2bb20b476edce3f3375d1c4aa1" +dependencies = [ + "byteorder", + "ckb-hash", + "ckb-types", + "eaglesong", + "log", + "serde", +] + +[[package]] +name = "ckb-rational" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5134dae6f59b1c10457d2a5def081865407e756dd42dd4c7aaf5d6c6bc92b6d1" +dependencies = [ + "numext-fixed-uint", + "serde", +] + +[[package]] +name = "ckb-resource" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3c79b7c1586ca652d150b2cfdc5ec8594055659f04e30f832178a14313cfff4" +dependencies = [ + "ckb-system-scripts", + "ckb-types", + "includedir", + "includedir_codegen", + "phf", + "serde", + "walkdir", +] + +[[package]] +name = "ckb-script" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058cb8c72a706bfc95c9b90f7c0256abbc4f44e9c5cabcbf7d1d882df977e82b" +dependencies = [ + "byteorder", + "ckb-chain-spec", + "ckb-error", + "ckb-hash", + "ckb-logger", + "ckb-traits", + "ckb-types", + "ckb-vm", + "faster-hex", + "serde", +] + +[[package]] +name = "ckb-system-scripts" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa5c59063142de7a68cfad4449c6b3863563856219a2925dfb8c5f019ec2aa47" +dependencies = [ + "blake2b-rs", + "faster-hex", + "includedir", + "includedir_codegen", + "phf", +] + +[[package]] +name = "ckb-systemtime" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace369d09f2a4d5d0e0b97359cf34e3282a5a90171f685e8bbab1aa21e80cd54" + +[[package]] +name = "ckb-testtool" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed25ee2af0e899736bb95e4fd1dd4c89f03dd8ae0061ae708b83e405d394431" +dependencies = [ + "ckb-always-success-script", + "ckb-chain-spec", + "ckb-crypto", + "ckb-error", + "ckb-hash", + "ckb-jsonrpc-types", + "ckb-mock-tx-types", + "ckb-resource", + "ckb-script", + "ckb-traits", + "ckb-types", + "ckb-verification", + "lazy_static", + "rand 0.8.5", +] + +[[package]] +name = "ckb-traits" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3396b8f328bc76bdfd9bc14ddd984a07d08120cd4e661ba1dc23fecb3a7607a3" +dependencies = [ + "ckb-types", +] + +[[package]] +name = "ckb-types" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2df7c7410664bc917f1b663c574ec7c0e25711fe4f63eb0043c47c197afb0875" +dependencies = [ + "bit-vec", + "bytes", + "ckb-channel", + "ckb-constant", + "ckb-error", + "ckb-fixed-hash", + "ckb-gen-types", + "ckb-hash", + "ckb-merkle-mountain-range", + "ckb-occupied-capacity", + "ckb-rational", + "derive_more", + "golomb-coded-set", + "merkle-cbt", + "molecule", + "numext-fixed-uint", + "once_cell", + "paste", +] + +[[package]] +name = "ckb-util" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e6326a9adcfe1f4afa14f1a0da267e5718873e28cc271a5e03fc57ff02ce233" +dependencies = [ + "linked-hash-map", + "once_cell", + "parking_lot", + "regex", +] + +[[package]] +name = "ckb-verification" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d157e70aea7d47af07b96415c952a7d97810572c659f8da2e9ecb6f98a1c7c" +dependencies = [ + "ckb-chain-spec", + "ckb-dao", + "ckb-dao-utils", + "ckb-error", + "ckb-pow", + "ckb-script", + "ckb-systemtime", + "ckb-traits", + "ckb-types", + "ckb-verification-traits", + "derive_more", + "lru", +] + +[[package]] +name = "ckb-verification-traits" +version = "0.112.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43456c274b362c89a18388a95418f18adfebb3ab25950a09e267f00284e66fd" +dependencies = [ + "bitflags 1.3.2", + "ckb-error", +] + +[[package]] +name = "ckb-vm" +version = "0.24.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc004a826b9bc9319ffae0b8415690e1b5f1482266d55fbd43843aa40ddcd63" +dependencies = [ + "byteorder", + "bytes", + "cc", + "ckb-vm-definitions", + "derive_more", + "goblin 0.2.3", + "goblin 0.4.0", + "rand 0.7.3", + "scroll", + "serde", +] + +[[package]] +name = "ckb-vm-definitions" +version = "0.24.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4ced3ff9d79b53d93c106720f6c1f855694290e33581850e05c859500eee83f" +dependencies = [ + "paste", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.70", +] + +[[package]] +name = "eaglesong" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d978bd5d343e8ab9b5c0fc8d93ff9c602fdc96616ffff9c05ac7a155419b824" + +[[package]] +name = "faster-hex" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e2ce894d53b295cf97b05685aa077950ff3e8541af83217fc720a6437169f8" + +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "goblin" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d20fd25aa456527ce4f544271ae4fea65d2eda4a6561ea56f39fb3ee4f7e3884" +dependencies = [ + "log", + "plain", + "scroll", +] + +[[package]] +name = "goblin" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532a09cd3df2c6bbfc795fb0434bff8f22255d1d07328180e918a2e6ce122d4d" +dependencies = [ + "log", + "plain", + "scroll", +] + +[[package]] +name = "golomb-coded-set" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812f314a99fb5b7f0f9d0a8388539578f83f3aca6a65f588b8dbeefb731e2f98" +dependencies = [ + "siphasher", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "heapsize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" +dependencies = [ + "winapi", +] + +[[package]] +name = "includedir" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afd126bd778c00c43a9dc76d1609a0894bf4222088088b2217ccc0ce9e816db7" +dependencies = [ + "flate2", + "phf", +] + +[[package]] +name = "includedir_codegen" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ac1500c9780957c9808c4ec3b94002f35aab01483833f5a8bce7dfb243e3148" +dependencies = [ + "flate2", + "phf_codegen", + "walkdir", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +dependencies = [ + "serde", +] + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "lru" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "merkle-cbt" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171d2f700835121c3b04ccf0880882987a050fd5c7ae88148abf537d33dd3a56" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "molecule" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd9767ab5e5f2ea40f71ff4c8bdb633c50509052e093c2fdd0e390a749dfa3" +dependencies = [ + "bytes", + "cfg-if", + "faster-hex", +] + +[[package]] +name = "numext-constructor" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "621fe0f044729f810c6815cdd77e8f5e0cd803ce4f6a38380ebfc1322af98661" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "numext-fixed-uint" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c68c76f96d589d1009a666c5072f37f3114d682696505f2cf445f27766c7d70" +dependencies = [ + "numext-fixed-uint-core", + "numext-fixed-uint-hack", +] + +[[package]] +name = "numext-fixed-uint-core" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aab1d6457b97b49482f22a92f0f58a2f39bdd7f3b2f977eae67e8bc206aa980" +dependencies = [ + "heapsize", + "numext-constructor", + "rand 0.7.3", + "serde", + "thiserror", +] + +[[package]] +name = "numext-fixed-uint-hack" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200f8d55c36ec1b6a8cf810115be85d4814f045e0097dfd50033ba25adb4c9e" +dependencies = [ + "numext-fixed-uint-core", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "phf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +dependencies = [ + "phf_shared", + "rand 0.7.3", +] + +[[package]] +name = "phf_shared" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +dependencies = [ + "siphasher", +] + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "redox_syscall" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scroll" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "secp256k1" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tests" +version = "0.1.0" +dependencies = [ + "ckb-testtool", + "serde_json", +] + +[[package]] +name = "thiserror" +version = "1.0.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/workspace/Makefile b/workspace/Makefile index 43a6856..7113c23 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -119,6 +119,14 @@ generate: mv Cargo.toml.new Cargo.toml; \ fi +add-debugger: + @set -eu; \ + if [ "x$(CRATE)" = "x" ]; then \ + scripts/add-debugger _ $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + else \ + scripts/add-debugger $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + fi + prepare: rustup target add riscv64imac-unknown-none-elf diff --git a/workspace/scripts/add-debugger b/workspace/scripts/add-debugger new file mode 100755 index 0000000..b2e7a16 --- /dev/null +++ b/workspace/scripts/add-debugger @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# +# Add code for native debugging to existing onchain-script + +CONTRACT_NAME=$1 + +if [ "$CONTRACT_NAME" = "_" ]; then + directory="./contracts" + if [ ! -d "$directory" ]; then + echo "No available contract" + exit 1 + fi + + folders=($(ls -d $directory/*/)) + contracts=() + for i in "${!folders[@]}"; do + contract_name=$(echo "${folders[$i]}" | awk -F'/' '{print $(NF-1)}') + if [ ! -d "${folders[$i]}/${contract_name}-dbg" ]; then + contracts+=("${contract_name}") + fi + done + + + if [ ${#contracts[@]} -eq 0 ]; then + echo "No available contract" + exit 2 + fi + + echo "Select contracts:" + for i in "${!folders[@]}"; do + folder_name=$(echo "${folders[$i]}" | awk -F'/' '{print $(NF-1)}') + echo " $((i+1)): ${contracts[$i]}" + done + echo "Enter index:" + read contract_index + if [[ "$contract_index" =~ ^[1-9][0-9]*$ ]] && [ "$contract_index" -le "${#contracts[@]}" ]; then + CONTRACT_NAME="${contracts[$((contract_index-1))]}" + else + echo "Invalid input" + exit 3 + fi +else + if [ ! -d "contracts/$CONTRACT_NAME" ]; then + echo "Contract does not exist" + exit 4 + fi + if [ -d "contracts/$CONTRACT_NAME/$CONTRACT_NAME-dbg" ]; then + echo "Already exists, no need to create" + exit 5 + fi +fi + +CONTRACT_CRATE=$(echo "$CONTRACT_NAME" | tr '-' '_') + +cd contracts/$CONTRACT_NAME +cargo generate $2 $3 add-debugger -n $CONTRACT_NAME-dbg -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE +mv $CONTRACT_NAME-dbg/src/contract-lib.rs src/lib.rs +echo "Finally, you need to add a feature to the contract's Cargo.toml:" +echo "simulator = ["ckb-std/simulator"]" \ No newline at end of file From 1346f63295fb3bc738b83c320446e7e2ef359c27 Mon Sep 17 00:00:00 2001 From: joii Date: Mon, 15 Jul 2024 12:00:48 +0800 Subject: [PATCH 02/44] remove default_alloc --- add-debugger/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/add-debugger/src/lib.rs b/add-debugger/src/lib.rs index f20e1f7..f6341a5 100644 --- a/add-debugger/src/lib.rs +++ b/add-debugger/src/lib.rs @@ -1,5 +1,4 @@ ckb_std::entry_simulator!(program_entry); -ckb_std::default_alloc!(); /// program entry fn program_entry() -> i8 { From 1304d24b02cef06e103ff7fe0c5435514ea0f692 Mon Sep 17 00:00:00 2001 From: joii Date: Tue, 16 Jul 2024 17:21:05 +0800 Subject: [PATCH 03/44] Auto add feature simulator to contract --- add-debugger/src/contract-lib.rs | 4 ---- workspace/Makefile | 5 ++++- workspace/scripts/add-debugger | 9 ++++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/add-debugger/src/contract-lib.rs b/add-debugger/src/contract-lib.rs index c56df99..379fb35 100644 --- a/add-debugger/src/contract-lib.rs +++ b/add-debugger/src/contract-lib.rs @@ -1,10 +1,6 @@ #![cfg_attr(not(feature = "simulator"), no_std)] // This file will be automatically placed in the contract file, and rename to lib.rs -// TODO -// Need to export main function. -// At the same time, you need to add a feature to the contract's Cargo.toml. -// simulator = ["ckb-std/simulator"] // #[cfg(feature = "simulator")] // pub mod entry; diff --git a/workspace/Makefile b/workspace/Makefile index 7113c23..bbf94d8 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -117,7 +117,10 @@ generate: fi; \ sed '/@@INSERTION_POINT@@/s/$$/\n "$(DESTINATION)\/$(CRATE)",/' Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; \ - fi + fi; \ + if [ "$(ALSO_ADD_DEBUGGER)" = "true" ]; then \ + make -C ./ add-debugger; \ + fi; add-debugger: @set -eu; \ diff --git a/workspace/scripts/add-debugger b/workspace/scripts/add-debugger index b2e7a16..941e438 100755 --- a/workspace/scripts/add-debugger +++ b/workspace/scripts/add-debugger @@ -56,4 +56,11 @@ cd contracts/$CONTRACT_NAME cargo generate $2 $3 add-debugger -n $CONTRACT_NAME-dbg -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE mv $CONTRACT_NAME-dbg/src/contract-lib.rs src/lib.rs echo "Finally, you need to add a feature to the contract's Cargo.toml:" -echo "simulator = ["ckb-std/simulator"]" \ No newline at end of file +echo "simulator = ["ckb-std/simulator"]" + +FILE="Cargo.toml" +if grep -q "\[features\]" "$FILE"; then + sed -i '/\[features\]/a\simulator = ["ckb-std/simulator"]' "$FILE" +else + echo -e "\n[features]\nsimulator = [\"ckb-std/simulator\"]" >> "$FILE" +fi From dce5deff28276e3e43d3ba9a10b72c86794b6e7e Mon Sep 17 00:00:00 2001 From: joii Date: Wed, 17 Jul 2024 11:16:20 +0800 Subject: [PATCH 04/44] Optimize the process of adding simulator --- add-debugger/src/contract-lib.rs | 10 +++++----- add-debugger/src/lib.rs | 12 +----------- contract/Makefile | 3 +++ contract/src/main.rs | 10 +++++----- workspace/Makefile | 12 ++++++++++++ 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/add-debugger/src/contract-lib.rs b/add-debugger/src/contract-lib.rs index 379fb35..71100fb 100644 --- a/add-debugger/src/contract-lib.rs +++ b/add-debugger/src/contract-lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(feature = "simulator"), no_std)] - -// This file will be automatically placed in the contract file, and rename to lib.rs - -// #[cfg(feature = "simulator")] -// pub mod entry; +#![allow(special_module_name)] +#[cfg(feature = "simulator")] +mod main; +#[cfg(feature = "simulator")] +pub use main::program_entry; diff --git a/add-debugger/src/lib.rs b/add-debugger/src/lib.rs index f6341a5..f5cdf3b 100644 --- a/add-debugger/src/lib.rs +++ b/add-debugger/src/lib.rs @@ -1,11 +1 @@ -ckb_std::entry_simulator!(program_entry); - -/// program entry -fn program_entry() -> i8 { - // Call main function and return error code - // match {{contract_crate_name}}::entry::main() { - // Ok(_) => 0, - // Err(err) => err as i8, - // } - 0 -} +ckb_std::entry_simulator!({{contract_crate_name}}::program_entry); diff --git a/contract/Makefile b/contract/Makefile index b8bc7f6..60a2a4c 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -44,6 +44,9 @@ build: done \ fi +build-simulator: + cd {{project-name}}-dbg && cargo build $(MODE_ARGS) && cp target/$(MODE)/*_dbg.* $(TOP)/$(BUILD_DIR) + # test, check, clippy and fmt here are provided for completeness, # there is nothing wrong invoking cargo directly instead of make. test: diff --git a/contract/src/main.rs b/contract/src/main.rs index 4ccf592..8cb9ddf 100644 --- a/contract/src/main.rs +++ b/contract/src/main.rs @@ -1,14 +1,14 @@ -#![no_std] -#![cfg_attr(not(test), no_main)] +#![cfg_attr(not(feature = "simulator"), no_std)] +#![cfg_attr(not(any(feature = "simulator", test)), no_main)] #[cfg(test)] extern crate alloc; -#[cfg(not(test))] +#[cfg(not(any(feature = "simulator", test)))] use ckb_std::default_alloc; -#[cfg(not(test))] +#[cfg(not(any(feature = "simulator", test)))] ckb_std::entry!(program_entry); -#[cfg(not(test))] +#[cfg(not(any(feature = "simulator", test)))] default_alloc!(); pub fn program_entry() -> i8 { diff --git a/workspace/Makefile b/workspace/Makefile index bbf94d8..70890e0 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -55,6 +55,17 @@ build: $(MAKE) -e -C contracts/$(CONTRACT) build; \ fi +build-simulator: + mkdir -p $(BUILD_DIR) + @set -eu; \ + if [ "x$(CONTRACT)" = "x" ]; then \ + for contract in $(wildcard contracts/*); do \ + $(MAKE) -e -C $$contract build-simulator; \ + done; \ + else \ + $(MAKE) -e -C contracts/$(CONTRACT) build-simulator; \ + fi + # Run a single make task for a specific contract. For example: # # make run CONTRACT=stack-reorder TASK=adjust_stack_size STACK_SIZE=0x200000 @@ -95,6 +106,7 @@ TEMPLATE_REPO := https://github.com/cryptape/ckb-script-templates CRATE := TEMPLATE := contract DESTINATION := contracts +ALSO_ADD_DEBUGGER := true generate: @set -eu; \ if [ "x$(CRATE)" = "x" ]; then \ From c77a4f3ebe10cb4c473198a1b400184bcc174004 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Wed, 17 Jul 2024 17:59:32 +0800 Subject: [PATCH 05/44] Add load_binary_dbg and support native simulator debug --- contract/Makefile | 2 +- workspace/tests/src/lib.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contract/Makefile b/contract/Makefile index 60a2a4c..b6c62ef 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -45,7 +45,7 @@ build: fi build-simulator: - cd {{project-name}}-dbg && cargo build $(MODE_ARGS) && cp target/$(MODE)/*_dbg.* $(TOP)/$(BUILD_DIR) + cd {{project-name}}-dbg && cargo build && cp target/debug/*_dbg.* $(TOP)/$(BUILD_DIR) # test, check, clippy and fmt here are provided for completeness, # there is nothing wrong invoking cargo directly instead of make. diff --git a/workspace/tests/src/lib.rs b/workspace/tests/src/lib.rs index 53fb2ab..60c4e4d 100644 --- a/workspace/tests/src/lib.rs +++ b/workspace/tests/src/lib.rs @@ -88,6 +88,17 @@ impl Loader { } result.unwrap().into() } + + pub fn load_binary_dbg( + &self, + context: &mut ckb_testtool::context::Context, + name: &str, + ) -> Bytes { + let mut path = self.0.clone(); + path.push(name); + + context.load_binary(path) + } } // This helper method runs Context::verify_tx, but in case error happens, From 6bbadcdf14733ff58fde81ccbf974cebedae5758 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Wed, 17 Jul 2024 18:49:30 +0800 Subject: [PATCH 06/44] Fix error --- cargo-generate.toml | 2 +- workspace/Makefile | 2 +- workspace/scripts/add-debugger | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cargo-generate.toml b/cargo-generate.toml index bf2f03d..3451388 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -7,7 +7,7 @@ sub_templates = [ "contract", "atomics-contract", "stack-reorder-contract", - "add-debugger-contract" + "add-debugger", # Dependency crate templates "c-wrapper-crate", "x64-simulator-crate", diff --git a/workspace/Makefile b/workspace/Makefile index 70890e0..0e79382 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -130,7 +130,7 @@ generate: sed '/@@INSERTION_POINT@@/s/$$/\n "$(DESTINATION)\/$(CRATE)",/' Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; \ fi; \ - if [ "$(ALSO_ADD_DEBUGGER)" = "true" ]; then \ + if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ make -C ./ add-debugger; \ fi; diff --git a/workspace/scripts/add-debugger b/workspace/scripts/add-debugger index 941e438..1eb95a7 100755 --- a/workspace/scripts/add-debugger +++ b/workspace/scripts/add-debugger @@ -52,8 +52,8 @@ fi CONTRACT_CRATE=$(echo "$CONTRACT_NAME" | tr '-' '_') +cargo generate $2 $3 add-debugger -n $CONTRACT_NAME-dbg --destination contracts/$CONTRACT_NAME -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE cd contracts/$CONTRACT_NAME -cargo generate $2 $3 add-debugger -n $CONTRACT_NAME-dbg -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE mv $CONTRACT_NAME-dbg/src/contract-lib.rs src/lib.rs echo "Finally, you need to add a feature to the contract's Cargo.toml:" echo "simulator = ["ckb-std/simulator"]" From 7a7e7cc21673cbc1db31db78cdd3d48695701ed8 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Thu, 18 Jul 2024 11:11:37 +0800 Subject: [PATCH 07/44] revert tests/lib.rs --- workspace/tests/src/lib.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/workspace/tests/src/lib.rs b/workspace/tests/src/lib.rs index 60c4e4d..53fb2ab 100644 --- a/workspace/tests/src/lib.rs +++ b/workspace/tests/src/lib.rs @@ -88,17 +88,6 @@ impl Loader { } result.unwrap().into() } - - pub fn load_binary_dbg( - &self, - context: &mut ckb_testtool::context::Context, - name: &str, - ) -> Bytes { - let mut path = self.0.clone(); - path.push(name); - - context.load_binary(path) - } } // This helper method runs Context::verify_tx, but in case error happens, From b5697f663db089c81eba82bd42fb869baebfbc7d Mon Sep 17 00:00:00 2001 From: joii2020 Date: Thu, 18 Jul 2024 12:27:28 +0800 Subject: [PATCH 08/44] test add feature simulator --- workspace/tests/Cargo.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/workspace/tests/Cargo.toml b/workspace/tests/Cargo.toml index 35182ee..10b9aad 100644 --- a/workspace/tests/Cargo.toml +++ b/workspace/tests/Cargo.toml @@ -3,6 +3,10 @@ name = "tests" version = "0.1.0" edition = "2021" +[features] +# default = [ "simulator" ] +simulator = [ "ckb-testtool/simulator" ] + [dependencies] -ckb-testtool = "0.10.2" +ckb-testtool = "0.12.0" serde_json = "1.0" From c946ef2d7a2a9c788558d95308baa9f2407f8133 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Mon, 22 Jul 2024 15:47:32 +0800 Subject: [PATCH 09/44] Optimizing Makefile dependencies * build-simulator dependencies build * clean can clear *-dbg --- contract/Makefile | 4 ++++ workspace/Makefile | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contract/Makefile b/contract/Makefile index b6c62ef..b8963f4 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -73,6 +73,10 @@ cargo: clean: cargo clean + @set -eu; \ + if [ -d "{{project-name}}-dbg" ]; then \ + cd {{project-name}}-dbg && cargo clean; \ + fi prepare: rustup target add riscv64imac-unknown-none-elf diff --git a/workspace/Makefile b/workspace/Makefile index 0e79382..28aa673 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -55,7 +55,7 @@ build: $(MAKE) -e -C contracts/$(CONTRACT) build; \ fi -build-simulator: +build-simulator: build mkdir -p $(BUILD_DIR) @set -eu; \ if [ "x$(CONTRACT)" = "x" ]; then \ @@ -100,6 +100,13 @@ cargo: clean: rm -rf build cargo clean + @set -eu; \ + cd contracts; \ + for dir in * ; do \ + if [ -d $$dir/$$dir-dbg ]; then \ + (cd $$dir/$$dir-dbg && cargo clean); \ + fi \ + done TEMPLATE_TYPE := --git TEMPLATE_REPO := https://github.com/cryptape/ckb-script-templates From 756ddb264347484895f99c7bea7d6234275af8d9 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Mon, 29 Jul 2024 16:46:31 +0800 Subject: [PATCH 10/44] Fix some bugs in add-debugger --- contract/src/main.rs | 2 +- workspace/Makefile | 11 ++++++++--- workspace/scripts/add-debugger | 6 ++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/contract/src/main.rs b/contract/src/main.rs index 8cb9ddf..529347e 100644 --- a/contract/src/main.rs +++ b/contract/src/main.rs @@ -1,7 +1,7 @@ #![cfg_attr(not(feature = "simulator"), no_std)] #![cfg_attr(not(any(feature = "simulator", test)), no_main)] -#[cfg(test)] +#[cfg(any(feature = "simulator", test))] extern crate alloc; #[cfg(not(any(feature = "simulator", test)))] diff --git a/workspace/Makefile b/workspace/Makefile index 28aa673..1487398 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -126,6 +126,10 @@ generate: fi; \ sed "s,@@INSERTION_POINT@@,@@INSERTION_POINT@@\n \"$$GENERATED_DIR\"\,," Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; \ + if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ + echo "Generate native simulator debugger"; \ + scripts/add-debugger $${GENERATED_DIR#$(DESTINATION)/} $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + fi; \ else \ cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) $(TEMPLATE) \ --destination $(DESTINATION) \ @@ -136,9 +140,10 @@ generate: fi; \ sed '/@@INSERTION_POINT@@/s/$$/\n "$(DESTINATION)\/$(CRATE)",/' Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; \ - fi; \ - if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ - make -C ./ add-debugger; \ + if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ + echo "Generate native simulator debugger"; \ + scripts/add-debugger $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + fi; \ fi; add-debugger: diff --git a/workspace/scripts/add-debugger b/workspace/scripts/add-debugger index 1eb95a7..23439fb 100755 --- a/workspace/scripts/add-debugger +++ b/workspace/scripts/add-debugger @@ -1,13 +1,12 @@ #!/usr/bin/env bash # # Add code for native debugging to existing onchain-script - CONTRACT_NAME=$1 if [ "$CONTRACT_NAME" = "_" ]; then directory="./contracts" if [ ! -d "$directory" ]; then - echo "No available contract" + echo "No available contract a" exit 1 fi @@ -20,9 +19,8 @@ if [ "$CONTRACT_NAME" = "_" ]; then fi done - if [ ${#contracts[@]} -eq 0 ]; then - echo "No available contract" + echo "No available contract b" exit 2 fi From d45d74a12e7af42f69a4ac18d29fee45a19975fb Mon Sep 17 00:00:00 2001 From: joii2020 Date: Mon, 29 Jul 2024 17:46:34 +0800 Subject: [PATCH 11/44] ckb-testtool version update to 0.12.0 --- standalone-contract/Cargo.toml | 2 +- x64-simulator-crate/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/standalone-contract/Cargo.toml b/standalone-contract/Cargo.toml index d0d04ba..71ab239 100644 --- a/standalone-contract/Cargo.toml +++ b/standalone-contract/Cargo.toml @@ -7,5 +7,5 @@ edition = "2021" ckb-std = "0.15.1" [dev-dependencies] -ckb-testtool = "0.10.2" +ckb-testtool = "0.12.0" serde_json = "1.0" diff --git a/x64-simulator-crate/Cargo.toml b/x64-simulator-crate/Cargo.toml index 5ed4c08..2cf6061 100644 --- a/x64-simulator-crate/Cargo.toml +++ b/x64-simulator-crate/Cargo.toml @@ -12,7 +12,7 @@ version = "0.15.1" features = ["simulator"] [target.'cfg(all(target_arch = "x86_64", unix))'.dev-dependencies] -ckb-testtool = "0.10.2" +ckb-testtool = "0.12.0" rusty-fork = "0.3.0" rand = "0.8.5" serde_json = "1.0" From 41aa9e39ed3e6190ef18985373aab12d533a636f Mon Sep 17 00:00:00 2001 From: joii2020 Date: Mon, 29 Jul 2024 17:53:21 +0800 Subject: [PATCH 12/44] Some dependencies are replaced with those in git --- add-debugger/Cargo.toml | 7 ++++++- workspace/Cargo.toml | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/add-debugger/Cargo.toml b/add-debugger/Cargo.toml index cd97760..0382a87 100644 --- a/add-debugger/Cargo.toml +++ b/add-debugger/Cargo.toml @@ -11,4 +11,9 @@ ckb-std = { version = "0.15.1", features = ["simulator"] } [lib] crate-type = ["cdylib"] -[workspace] \ No newline at end of file +[workspace] + +# TODO: Will be deleted after release +[replace] +"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } +"ckb-x64-simulator:0.8.0" = { git = "https://github.com/joii2020/ckb-x64-simulator.git", branch = "main" } \ No newline at end of file diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index e8f337e..c6e23d7 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -12,3 +12,9 @@ members = [ overflow-checks = true strip = true codegen-units = 1 + +# TODO: Will be deleted after release +[replace] +"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } +"ckb-x64-simulator:0.8.0" = { git = "https://github.com/joii2020/ckb-x64-simulator.git", branch = "main" } +"ckb-testtool:0.12.0" = { git = "https://github.com/joii2020/ckb-testtool.git", branch = "main" } \ No newline at end of file From e903a59c634e1b53c3e3d5f3f50549e28a4f89fa Mon Sep 17 00:00:00 2001 From: joii2020 Date: Thu, 1 Aug 2024 15:13:28 +0800 Subject: [PATCH 13/44] Update ckb-testtool version --- add-debugger/Cargo.toml | 1 - standalone-contract/Cargo.toml | 2 +- workspace/Cargo.toml | 4 +--- workspace/tests/Cargo.toml | 2 +- x64-simulator-crate/Cargo.toml | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/add-debugger/Cargo.toml b/add-debugger/Cargo.toml index 0382a87..7d59095 100644 --- a/add-debugger/Cargo.toml +++ b/add-debugger/Cargo.toml @@ -16,4 +16,3 @@ crate-type = ["cdylib"] # TODO: Will be deleted after release [replace] "ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } -"ckb-x64-simulator:0.8.0" = { git = "https://github.com/joii2020/ckb-x64-simulator.git", branch = "main" } \ No newline at end of file diff --git a/standalone-contract/Cargo.toml b/standalone-contract/Cargo.toml index 71ab239..59d9be3 100644 --- a/standalone-contract/Cargo.toml +++ b/standalone-contract/Cargo.toml @@ -7,5 +7,5 @@ edition = "2021" ckb-std = "0.15.1" [dev-dependencies] -ckb-testtool = "0.12.0" +ckb-testtool = "0.13.0" serde_json = "1.0" diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index c6e23d7..9988f20 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -15,6 +15,4 @@ codegen-units = 1 # TODO: Will be deleted after release [replace] -"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } -"ckb-x64-simulator:0.8.0" = { git = "https://github.com/joii2020/ckb-x64-simulator.git", branch = "main" } -"ckb-testtool:0.12.0" = { git = "https://github.com/joii2020/ckb-testtool.git", branch = "main" } \ No newline at end of file +"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } \ No newline at end of file diff --git a/workspace/tests/Cargo.toml b/workspace/tests/Cargo.toml index 10b9aad..11df826 100644 --- a/workspace/tests/Cargo.toml +++ b/workspace/tests/Cargo.toml @@ -8,5 +8,5 @@ edition = "2021" simulator = [ "ckb-testtool/simulator" ] [dependencies] -ckb-testtool = "0.12.0" +ckb-testtool = "0.13.0" serde_json = "1.0" diff --git a/x64-simulator-crate/Cargo.toml b/x64-simulator-crate/Cargo.toml index 2cf6061..3ea3743 100644 --- a/x64-simulator-crate/Cargo.toml +++ b/x64-simulator-crate/Cargo.toml @@ -12,7 +12,7 @@ version = "0.15.1" features = ["simulator"] [target.'cfg(all(target_arch = "x86_64", unix))'.dev-dependencies] -ckb-testtool = "0.12.0" +ckb-testtool = "0.13.0" rusty-fork = "0.3.0" rand = "0.8.5" serde_json = "1.0" From 490b0c269df08e834a676e85ee8d2cb30abfb1b6 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Thu, 22 Aug 2024 17:07:02 +0800 Subject: [PATCH 14/44] Rename add-debugger to native-simulator --- cargo-generate.toml | 2 +- {add-debugger => native-simulator}/.gitignore | 0 {add-debugger => native-simulator}/Cargo.toml | 0 {add-debugger => native-simulator}/README.md | 0 .../cargo-generate.toml | 0 .../src/contract-lib.rs | 0 {add-debugger => native-simulator}/src/lib.rs | 0 workspace/Cargo.toml | 5 +++++ workspace/Makefile | 14 ++++++++------ .../{add-debugger => generate-native-simulator} | 2 +- 10 files changed, 15 insertions(+), 8 deletions(-) rename {add-debugger => native-simulator}/.gitignore (100%) rename {add-debugger => native-simulator}/Cargo.toml (100%) rename {add-debugger => native-simulator}/README.md (100%) rename {add-debugger => native-simulator}/cargo-generate.toml (100%) rename {add-debugger => native-simulator}/src/contract-lib.rs (100%) rename {add-debugger => native-simulator}/src/lib.rs (100%) rename workspace/scripts/{add-debugger => generate-native-simulator} (91%) diff --git a/cargo-generate.toml b/cargo-generate.toml index 3451388..bea6f12 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -7,7 +7,7 @@ sub_templates = [ "contract", "atomics-contract", "stack-reorder-contract", - "add-debugger", + "native-simulator", # Dependency crate templates "c-wrapper-crate", "x64-simulator-crate", diff --git a/add-debugger/.gitignore b/native-simulator/.gitignore similarity index 100% rename from add-debugger/.gitignore rename to native-simulator/.gitignore diff --git a/add-debugger/Cargo.toml b/native-simulator/Cargo.toml similarity index 100% rename from add-debugger/Cargo.toml rename to native-simulator/Cargo.toml diff --git a/add-debugger/README.md b/native-simulator/README.md similarity index 100% rename from add-debugger/README.md rename to native-simulator/README.md diff --git a/add-debugger/cargo-generate.toml b/native-simulator/cargo-generate.toml similarity index 100% rename from add-debugger/cargo-generate.toml rename to native-simulator/cargo-generate.toml diff --git a/add-debugger/src/contract-lib.rs b/native-simulator/src/contract-lib.rs similarity index 100% rename from add-debugger/src/contract-lib.rs rename to native-simulator/src/contract-lib.rs diff --git a/add-debugger/src/lib.rs b/native-simulator/src/lib.rs similarity index 100% rename from add-debugger/src/lib.rs rename to native-simulator/src/lib.rs diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index 9988f20..f1eb4bb 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -13,6 +13,11 @@ overflow-checks = true strip = true codegen-units = 1 +[profile.ckb-debug] +inherits = "release" +strip = false +debug = true + # TODO: Will be deleted after release [replace] "ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } \ No newline at end of file diff --git a/workspace/Makefile b/workspace/Makefile index 1487398..9a1a5e4 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -60,7 +60,9 @@ build-simulator: build @set -eu; \ if [ "x$(CONTRACT)" = "x" ]; then \ for contract in $(wildcard contracts/*); do \ - $(MAKE) -e -C $$contract build-simulator; \ + if [ -d "$$contract/`basename $$contract`-dbg" ]; then \ + $(MAKE) -e -C $$contract build-simulator; \ + fi; \ done; \ else \ $(MAKE) -e -C contracts/$(CONTRACT) build-simulator; \ @@ -128,7 +130,7 @@ generate: mv Cargo.toml.new Cargo.toml; \ if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ echo "Generate native simulator debugger"; \ - scripts/add-debugger $${GENERATED_DIR#$(DESTINATION)/} $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + scripts/generate-native-simulator $${GENERATED_DIR#$(DESTINATION)/} $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ fi; \ else \ cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) $(TEMPLATE) \ @@ -142,16 +144,16 @@ generate: mv Cargo.toml.new Cargo.toml; \ if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ echo "Generate native simulator debugger"; \ - scripts/add-debugger $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + scripts/generate-native-simulator $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ fi; \ fi; -add-debugger: +generate-native-simulator: @set -eu; \ if [ "x$(CRATE)" = "x" ]; then \ - scripts/add-debugger _ $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + scripts/generate-native-simulator _ $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ else \ - scripts/add-debugger $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + scripts/generate-native-simulator $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ fi prepare: diff --git a/workspace/scripts/add-debugger b/workspace/scripts/generate-native-simulator similarity index 91% rename from workspace/scripts/add-debugger rename to workspace/scripts/generate-native-simulator index 23439fb..31dce75 100755 --- a/workspace/scripts/add-debugger +++ b/workspace/scripts/generate-native-simulator @@ -50,7 +50,7 @@ fi CONTRACT_CRATE=$(echo "$CONTRACT_NAME" | tr '-' '_') -cargo generate $2 $3 add-debugger -n $CONTRACT_NAME-dbg --destination contracts/$CONTRACT_NAME -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE +cargo generate $2 $3 native-simulator -n $CONTRACT_NAME-dbg --destination contracts/$CONTRACT_NAME -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE cd contracts/$CONTRACT_NAME mv $CONTRACT_NAME-dbg/src/contract-lib.rs src/lib.rs echo "Finally, you need to add a feature to the contract's Cargo.toml:" From c283df94be5d589d2e040454bdcdd03cc0056f65 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Mon, 26 Aug 2024 09:35:25 +0800 Subject: [PATCH 15/44] Add doc: debugging contract --- workspace/docs/debugging_contract.md | 149 +++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 workspace/docs/debugging_contract.md diff --git a/workspace/docs/debugging_contract.md b/workspace/docs/debugging_contract.md new file mode 100644 index 0000000..f3bb6f2 --- /dev/null +++ b/workspace/docs/debugging_contract.md @@ -0,0 +1,149 @@ +Here's the polished version: + +# Debugging Contract + +## Native Simulator Debugging + +By running `make generate`, a Rust contract is created with a `-dbg` suffix in the contract directory. This project allows you to compile the contract as a native platform dynamic library. To build it, simply run `make build-simulator`. Afterward, you can insert breakpoints and debug the contract code by enabling the `simulator` feature of `ckb-testtool` in unit tests. + +## Debugging with ckb-debugger and VSCode + +An alternative debugging method is available using `ckb-debugger` (in this case, with VSCode). `ckb-debugger` operates as a `gdb server`, supporting both gdb and lldb-18. In VSCode, the [Native Debug](https://marketplace.visualstudio.com/items?itemName=webfreak.debug) extension supports remote gdb debugging, which you'll need for this setup. +* Note: Although CodeLLDB supports remote debugging, it does not work well here due to the use of lldb version 17. + +### Compilation + +By default, the compiled output lacks debug symbols due to size constraints, so you need to compile using the `profile.ckb-debug` profile. You'll also need to create a copy of the binary for gdb/llvm debugging and strip the symbols from the original file for `ckb-debugger` to run. + +```shell +make build MODE=ckb-debug CARGO_ARGS='--profile=ckb-debug' +cp build/ckb-debug/ build/ckb-debug/.debug +llvm-objcopy --strip-debug --strip-all build/ckb-debug/ +``` + +To configure `tasks.json` in VSCode (using `c1` from CI as an example): + +```json +{ + "label": "Build Debug", + "type": "shell", + "command": "make build MODE=ckb-debug CARGO_ARGS='--profile=ckb-debug' && cp build/ckb-debug/c1 build/ckb-debug/c1.debug && llvm-objcopy --strip-debug --strip-all build/ckb-debug/c1" +}, +``` + +#### Running ckb-debugger + +(You can skip this section if the contract you are debugging doesn’t require transaction information.) + +Typically, contracts need transaction data, which can be retrieved from unit tests. Add the following code before `context.verify_tx(&tx, MAX_CYCLES)` in your unit tests: + +```rust +let tx_data = context.dump_tx(&tx).expect("dump tx info"); +std::fs::write( + "tx.json", + serde_json::to_string_pretty(&tx_data).expect("json"), +) +.expect("write tx"); +``` + +Then, start `ckb-debugger` with: + +```shell +ckb-debugger \ + --bin=build/ckb-debug/c1 \ + --mode=gdb_gdbstub \ + --gdb-listen=0.0.0.0:8000 \ + --tx-file=tests/tx.json \ + -s=lock \ + -i=0 +``` +* The example uses port 8000; feel free to change it if necessary. +* Adjust `-s` and `-i` according to your contract's needs. + +You can configure `tasks.json` in VSCode to automatically start `ckb-debugger`: + +```json +{ + "label": "Debug c1", + "isBackground": true, + "type": "process", + "command": "ckb-debugger", + "args": [ + "--bin=build/ckb-debug/c1", + "--mode=gdb_gdbstub", + "--gdb-listen=0.0.0.0:8000", + "--tx-file=tests/tx.json", + "-s=lock", + "-i=0" + ], + "options": { + "cwd": "${workspaceRoot}" + }, +}, +``` +* The `isBackground` setting ensures the task runs in the background and doesn't terminate during debugging. + +Since `ckb-debugger` doesn’t exit automatically after debugging, you'll need to configure a task to stop it: + +```json +{ + "label": "stop-ckb-debugger", + "type": "shell", + "command": "killall ckb-debugger || true" +}, +``` + +#### GDB Debugging + +```shell +gdb build/ckb-debug/c1.debug +``` +Then connect to `ckb-debugger`'s gdb server: + +```shell +target remote 127.0.0.1:8000 +``` +Once connected, you can debug using standard GDB commands. + +#### LLDB Debugging + +* Ensure you are using lldb version 18 or later. + +```shell +lldb build/ckb-debugger/c1.debug +``` +Then connect to `ckb-debugger`'s gdb server (you can omit the local address and just use the port): + +```shell +gdb-remote 8000 +``` +After connecting, you can use standard LLDB commands to debug. + +#### VSCode Debugging + +* GDB must be installed. +* The Native Debug extension is required for debugging in VSCode. + +First, configure `tasks.json` as described above. Then, set up your `launch.json` for debugging: + +```json +{ + "name": "GDB", + "type": "gdb", + "request": "attach", + "executable": "build/ckb-debug/c1.debug", + "debugger_args": [], + "cwd": "${workspaceRoot}", + "remote": true, + "target": "127.0.0.1:8000", + "preLaunchTask": "Debug c1", + "postDebugTask": "stop-ckb-debugger" +} +``` +After launching the debugger, you can set breakpoints and inspect variables as usual. + +### Additional Notes + +* The Native Simulator method is more convenient and supports advanced debugging features, which may not be available with `ckb-debugger`. +* `ckb-debugger` provides a debugging environment closer to the contract's runtime environment, while the Native Simulator only emulates the online environment. +* `ckb-debugger` may perform poorly compared to the Native Simulator, especially on low-end computers. \ No newline at end of file From 9b983f179b87aaa6b5ede402d07a1a81d4829035 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Mon, 26 Aug 2024 10:11:08 +0800 Subject: [PATCH 16/44] Update docs --- workspace/docs/debugging_contract.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/workspace/docs/debugging_contract.md b/workspace/docs/debugging_contract.md index f3bb6f2..f17d553 100644 --- a/workspace/docs/debugging_contract.md +++ b/workspace/docs/debugging_contract.md @@ -1,5 +1,3 @@ -Here's the polished version: - # Debugging Contract ## Native Simulator Debugging From 5fc5cb656ab7001c0fd02e825d88530872e559ce Mon Sep 17 00:00:00 2001 From: joii2020 Date: Mon, 26 Aug 2024 17:40:05 +0800 Subject: [PATCH 17/44] Fix CI error --- stack-reorder-contract/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stack-reorder-contract/src/main.rs b/stack-reorder-contract/src/main.rs index 5c91eae..e66898f 100644 --- a/stack-reorder-contract/src/main.rs +++ b/stack-reorder-contract/src/main.rs @@ -12,15 +12,15 @@ ckb_std::entry!(program_entry); default_alloc!(); pub fn program_entry() -> i8 { - let mut x: u64; + let mut _x: u64; unsafe { core::arch::asm!( - "mv {x}, sp", - x = out(reg) x, + "mv {_x}, sp", + _x = out(reg) _x, ); } - ckb_std::debug!("Current SP is {:x}", x); + ckb_std::debug!("Current SP is {:x}", _x); 0 } From 295bf1017a9171b1fd9728333e83b6fccf0e2ad9 Mon Sep 17 00:00:00 2001 From: joii Date: Sat, 31 Aug 2024 17:26:54 +0800 Subject: [PATCH 18/44] Refactore: Native simulator debug project move to native-simulator --- contract/Makefile | 7 - native-simulator/Cargo.toml | 2 +- native-simulator/GlobalMakefile | 28 + workspace/Cargo.lock | 764 ++++++++++++++++---- workspace/Makefile | 22 - workspace/scripts/generate-native-simulator | 18 +- 6 files changed, 651 insertions(+), 190 deletions(-) create mode 100644 native-simulator/GlobalMakefile diff --git a/contract/Makefile b/contract/Makefile index b8963f4..b8bc7f6 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -44,9 +44,6 @@ build: done \ fi -build-simulator: - cd {{project-name}}-dbg && cargo build && cp target/debug/*_dbg.* $(TOP)/$(BUILD_DIR) - # test, check, clippy and fmt here are provided for completeness, # there is nothing wrong invoking cargo directly instead of make. test: @@ -73,10 +70,6 @@ cargo: clean: cargo clean - @set -eu; \ - if [ -d "{{project-name}}-dbg" ]; then \ - cd {{project-name}}-dbg && cargo clean; \ - fi prepare: rustup target add riscv64imac-unknown-none-elf diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index 7d59095..45a2b63 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -{{contract_name}} = { path = "../", features = ["simulator"] } +{{contract_name}} = { path = "../../contracts/{{contract_name}}", features = ["simulator"] } ckb-std = { version = "0.15.1", features = ["simulator"] } [lib] diff --git a/native-simulator/GlobalMakefile b/native-simulator/GlobalMakefile new file mode 100644 index 0000000..07be1a7 --- /dev/null +++ b/native-simulator/GlobalMakefile @@ -0,0 +1,28 @@ + +# This file is used by the parent directory. +# The current project can directly execute cargo build + +MODE := release +BUILD_DIR := ../build/$(MODE) + +build: + mkdir -p ../$(BUILD_DIR) + @set -eu; \ + if [ "x$(CONTRACT)" = "x" ]; then \ + for contract in $(wildcard ./*); do \ + if [ -f $$contract/Cargo.toml ]; then \ + cd $$contract && cargo build && cp target/debug/*_dbg.* ../$(BUILD_DIR); \ + fi; \ + done; \ + else \ + cd $(CONTRACT) && cargo build; \ + fi + +clean: + @set -eu; \ + rm -rf $(BUILD_DIR)/*_sim.*; \ + for contract in $(wildcard ./*); do \ + if [ -f $$contract/Cargo.toml ]; then \ + cd $$contract && cargo clean; \ + fi; \ + done; \ No newline at end of file diff --git a/workspace/Cargo.lock b/workspace/Cargo.lock index 1bf9232..fcdd43c 100644 --- a/workspace/Cargo.lock +++ b/workspace/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -19,15 +28,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - [[package]] name = "anyhow" version = "1.0.86" @@ -40,6 +40,27 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "bit-vec" version = "0.6.3" @@ -74,6 +95,15 @@ dependencies = [ "cty", ] +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "byteorder" version = "1.5.0" @@ -89,6 +119,33 @@ dependencies = [ "serde", ] +[[package]] +name = "cacache" +version = "12.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142316461ed3a3dfcba10417317472da5bfd0461e4d276bf7c07b330766d9490" +dependencies = [ + "digest", + "either", + "futures", + "hex", + "libc", + "memmap2", + "miette", + "reflink-copy", + "serde", + "serde_derive", + "serde_json", + "sha1", + "sha2", + "ssri", + "tempfile", + "thiserror", + "tokio", + "tokio-stream", + "walkdir", +] + [[package]] name = "cc" version = "1.1.1" @@ -109,46 +166,47 @@ checksum = "8b3b72a38c9920a29990df12002c4d069a147c8782f0c211f8a01b2df8f42bfd" [[package]] name = "ckb-chain-spec" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9b89cadf419c220fa8e1c655af73540bbc010e8c0e177127644848a25830c2" +checksum = "e955d55380bbd2ca883b4426fb1483e61f06fe65c8b377d5d4bceeb03ecf07bb" dependencies = [ + "cacache", "ckb-constant", "ckb-crypto", "ckb-dao-utils", "ckb-error", "ckb-hash", "ckb-jsonrpc-types", + "ckb-logger", "ckb-pow", "ckb-rational", "ckb-resource", "ckb-traits", "ckb-types", - "ckb-util", "serde", "toml", ] [[package]] name = "ckb-channel" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c904fe3e29474e4d09e8e2775a472456242f8faf18edeeb8c71502710daa38" +checksum = "853f561e90ff59d858dc87c1ac385fae948984859c874fd8d3bd1bbab335889d" dependencies = [ "crossbeam-channel", ] [[package]] name = "ckb-constant" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d562e7156216f00c5bf55c8f4c86bc25f9ec0603fcfa6df9b66747462a031a" +checksum = "5baf91b16a3b8360c85211dfdff3d2adc0a1f3ae571ea6b1637d55d6b227e312" [[package]] name = "ckb-crypto" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abac585cec6f1562e374d66b369c55a52357b33a632d30d2e45cbc455183b22d" +checksum = "5e2094270f5632808cbff1c37a37ffb9b3e79f7a99e78927fb228d8c343793eb" dependencies = [ "ckb-fixed-hash", "faster-hex", @@ -160,9 +218,9 @@ dependencies = [ [[package]] name = "ckb-dao" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c6b5b85ebe6e02bebcc1f1a4db28f1594e1a9e43e8922c05175459f798e844" +checksum = "26f006a8ef6c383e78727f0d684e87c73eb7610ced6b7eecfd4ca3b1edfc33b0" dependencies = [ "byteorder", "ckb-chain-spec", @@ -173,9 +231,9 @@ dependencies = [ [[package]] name = "ckb-dao-utils" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff55485163b842c94061b755c9e6230d1a4bb092b6bc81d8387358911c750e70" +checksum = "6eb3606c602a424098317bfde4b7d6427d4fe5dfe1a6d4ebc831ce0308508085" dependencies = [ "byteorder", "ckb-error", @@ -184,9 +242,9 @@ dependencies = [ [[package]] name = "ckb-error" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8418901ea0d15a8e26255bec0b71be5c59056858f51968894796f77f7eefa3e" +checksum = "01041f8a1d7eeaf85caca3547bb78d929d6a4d62774509d7eb438b6bc310ba30" dependencies = [ "anyhow", "ckb-occupied-capacity", @@ -196,9 +254,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1254aafda84e9abc85301e9e4c5b920c00a9bff0d42248fccf921b340ec5f13e" +checksum = "4a7491f18717b84827923935cc5adb1bcdf9c924e377b478d089f4694e7c779b" dependencies = [ "ckb-fixed-hash-core", "ckb-fixed-hash-macros", @@ -206,10 +264,11 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-core" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffc2850ac8b5643c65913185020de747b290b447d1ee1fd59a2cfdf1a7ceb4f" +checksum = "9509f63fedb9b6e42cfd0db47d3dc5acb6b029da546d5d4451d08afc44c70cf8" dependencies = [ + "ckb_schemars", "faster-hex", "serde", "thiserror", @@ -217,9 +276,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-macros" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa5a19a7d18caa5a3a65e66506e28943e95696e286df44457a77692319de429" +checksum = "fdd89533a5da746f50798752a46f5f084f110c849335be94baf506790ebee931" dependencies = [ "ckb-fixed-hash-core", "proc-macro2", @@ -229,9 +288,9 @@ dependencies = [ [[package]] name = "ckb-gen-types" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a12020d50dd3757cde0fdc88d3837b7a2ab503fe38bd11be86ddace11318c77" +checksum = "7a0f2d0f4224507a027d25d64824dd0dc8d367c8b5bead30289eaffe1381a7fb" dependencies = [ "cfg-if", "ckb-error", @@ -244,9 +303,9 @@ dependencies = [ [[package]] name = "ckb-hash" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25af660fc8746f7c756444e6aa47ede9a874206563b6a1ce1b230a5b86519392" +checksum = "d5754bc49cf76a7e8829fe6a7cf1eea1284cbca9777b521f072c76d6ae28d303" dependencies = [ "blake2b-ref", "blake2b-rs", @@ -254,11 +313,12 @@ dependencies = [ [[package]] name = "ckb-jsonrpc-types" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06798b5bacd7fd4125a34f1c9ebf45be59d50aff0ada003bb8b1c6634a447c73" +checksum = "ef7e123043ca3701cf05ba4c3699b34f3b179609109a4c8c3afa68922f722be7" dependencies = [ "ckb-types", + "ckb_schemars", "faster-hex", "serde", "serde_json", @@ -266,9 +326,9 @@ dependencies = [ [[package]] name = "ckb-logger" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8d8de618d1dbc59ba9e6338a55d17f370f89aa009064dcbdd7eb0c8e8782fe" +checksum = "59ebecd56c9acb453bdcb5c39e66b6b7f980bdf72b35515750bc295fa635287d" dependencies = [ "log", ] @@ -284,9 +344,9 @@ dependencies = [ [[package]] name = "ckb-mock-tx-types" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabfa378c927109844630e4c90e0d7e7e6d6a9174c232f194f490b09e4b757" +checksum = "b1ddfee88ad65ff6fd828695a78ec49be60888c58e631feb66d130008ce130d0" dependencies = [ "ckb-jsonrpc-types", "ckb-traits", @@ -296,9 +356,9 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be7132362f12a0495b3b24218afb4e774f9dc0d9254173d2444ec4ac1447461e" +checksum = "ee4aa07af7cec38d15cfe4c1ce150514fba5a4e78996bbbd098982106bee7d8d" dependencies = [ "ckb-occupied-capacity-core", "ckb-occupied-capacity-macros", @@ -306,18 +366,18 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-core" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4ebe8725d6ee4feb9d376e9a600b2c78cc1dbde5aa754c9a47de871ab917635" +checksum = "a63ed90996ba24ab26d5ac8ae22fd002a293f4a4e4526042e1adf84b1889e176" dependencies = [ "serde", ] [[package]] name = "ckb-occupied-capacity-macros" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201a21d35a377b76440ce12ca62b39e548d019a6330fbdcb40ac0f73fe976cb3" +checksum = "9a6aae3f1f8d194cd5bd4328c9c7281f0d7acc73976b2771576cdc06a9ed608f" dependencies = [ "ckb-occupied-capacity-core", "quote", @@ -326,9 +386,9 @@ dependencies = [ [[package]] name = "ckb-pow" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5895b4799fbb7e537ef0a778493b8f8678284c2bb20b476edce3f3375d1c4aa1" +checksum = "eb981de6e56107cd3e1660a9105bb07891277b21604946f70bf5097dd03690f7" dependencies = [ "byteorder", "ckb-hash", @@ -340,9 +400,9 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5134dae6f59b1c10457d2a5def081865407e756dd42dd4c7aaf5d6c6bc92b6d1" +checksum = "ed570e816c80fffdfafb58c7c895df8c08c64ba56ce79d824e5ff976dd1a7381" dependencies = [ "numext-fixed-uint", "serde", @@ -350,9 +410,9 @@ dependencies = [ [[package]] name = "ckb-resource" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3c79b7c1586ca652d150b2cfdc5ec8594055659f04e30f832178a14313cfff4" +checksum = "d482493fabf4ce3670277d7dbaa5811872379535031431dc6b19699722c7b846" dependencies = [ "ckb-system-scripts", "ckb-types", @@ -365,9 +425,9 @@ dependencies = [ [[package]] name = "ckb-script" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058cb8c72a706bfc95c9b90f7c0256abbc4f44e9c5cabcbf7d1d882df977e82b" +checksum = "a2d6528e95a0f93d4a39e569b1ffffd60cbb0a9ae8f1c96dd465e2576ad510a9" dependencies = [ "byteorder", "ckb-chain-spec", @@ -396,15 +456,15 @@ dependencies = [ [[package]] name = "ckb-systemtime" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace369d09f2a4d5d0e0b97359cf34e3282a5a90171f685e8bbab1aa21e80cd54" +checksum = "d4dc9b70fa7a9ecb0cf285cadab32139c58be9fee08b94e019b15d6b3f5296ef" [[package]] name = "ckb-testtool" -version = "0.10.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed25ee2af0e899736bb95e4fd1dd4c89f03dd8ae0061ae708b83e405d394431" +checksum = "3b635fc26720bc75d363b3f5159574a09b4cc0cc767b02f315ae3abf7333d41d" dependencies = [ "ckb-always-success-script", "ckb-chain-spec", @@ -418,24 +478,27 @@ dependencies = [ "ckb-traits", "ckb-types", "ckb-verification", + "faster-hex", "lazy_static", + "libloading", "rand 0.8.5", + "serde_json", ] [[package]] name = "ckb-traits" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3396b8f328bc76bdfd9bc14ddd984a07d08120cd4e661ba1dc23fecb3a7607a3" +checksum = "c528f704f3088ec2dd467d374920b64b2bbb9ed9c4e8e12931c069a99150d8bc" dependencies = [ "ckb-types", ] [[package]] name = "ckb-types" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2df7c7410664bc917f1b663c574ec7c0e25711fe4f63eb0043c47c197afb0875" +checksum = "9b05cc1c6aab0c40b323b233617b67860f9d679fac431a34d1f1b0853d700e9d" dependencies = [ "bit-vec", "bytes", @@ -457,23 +520,11 @@ dependencies = [ "paste", ] -[[package]] -name = "ckb-util" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e6326a9adcfe1f4afa14f1a0da267e5718873e28cc271a5e03fc57ff02ce233" -dependencies = [ - "linked-hash-map", - "once_cell", - "parking_lot", - "regex", -] - [[package]] name = "ckb-verification" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d157e70aea7d47af07b96415c952a7d97810572c659f8da2e9ecb6f98a1c7c" +checksum = "5688aaa9bd1f4a3b030ed45ef42d08d81dc46deb888591d3711dff738c3ffd34" dependencies = [ "ckb-chain-spec", "ckb-dao", @@ -491,9 +542,9 @@ dependencies = [ [[package]] name = "ckb-verification-traits" -version = "0.112.1" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d43456c274b362c89a18388a95418f18adfebb3ab25950a09e267f00284e66fd" +checksum = "4d21c510c2454f8d5d2f78ac97fe615b5d2ded718faa703824c5d4cc9645e8e7" dependencies = [ "bitflags 1.3.2", "ckb-error", @@ -501,9 +552,9 @@ dependencies = [ [[package]] name = "ckb-vm" -version = "0.24.6" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc004a826b9bc9319ffae0b8415690e1b5f1482266d55fbd43843aa40ddcd63" +checksum = "a2c3d68dc7f891e5555c7ebc054722b28ab005e51c5076f54c20d36002dc8e83" dependencies = [ "byteorder", "bytes", @@ -519,19 +570,52 @@ dependencies = [ [[package]] name = "ckb-vm-definitions" -version = "0.24.6" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ced3ff9d79b53d93c106720f6c1f855694290e33581850e05c859500eee83f" +checksum = "a2fdf9c8ee14409b2208d23b9ad88828242d7881153ddc04872b66d2e018a52f" dependencies = [ "paste", ] +[[package]] +name = "ckb_schemars" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21f99fca82a4eb8708e406e99246987b087ecc1e1babeece1a0b1d5238b1750" +dependencies = [ + "ckb_schemars_derive", + "dyn-clone", + "serde", + "serde_json", +] + +[[package]] +name = "ckb_schemars_derive" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c813b4fadbdd9f33b1cf02a1ddfa9537d955c8d2fbe150d1fc1684dbf78e73" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 1.0.109", +] + [[package]] name = "convert_case" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "cpufeatures" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.4.2" @@ -556,6 +640,16 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "cty" version = "0.2.2" @@ -575,18 +669,56 @@ dependencies = [ "syn 2.0.70", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "eaglesong" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d978bd5d343e8ab9b5c0fc8d93ff9c602fdc96616ffff9c05ac7a155419b824" +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "faster-hex" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51e2ce894d53b295cf97b05685aa077950ff3e8541af83217fc720a6437169f8" +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + [[package]] name = "flate2" version = "1.0.30" @@ -597,6 +729,105 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.1.16" @@ -619,6 +850,12 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + [[package]] name = "goblin" version = "0.2.3" @@ -668,6 +905,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "includedir" version = "0.6.0" @@ -708,23 +951,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "libloading" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ - "serde", + "cfg-if", + "windows-targets", ] [[package]] -name = "lock_api" -version = "0.4.12" +name = "linux-raw-sys" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" @@ -747,6 +987,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + [[package]] name = "merkle-cbt" version = "0.3.2" @@ -756,6 +1005,29 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "miette" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +dependencies = [ + "miette-derive", + "once_cell", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "miniz_oxide" version = "0.7.4" @@ -823,33 +1095,19 @@ dependencies = [ ] [[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "parking_lot" -version = "0.12.3" +name = "object" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ - "lock_api", - "parking_lot_core", + "memchr", ] [[package]] -name = "parking_lot_core" -version = "0.9.10" +name = "once_cell" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "paste" @@ -895,6 +1153,18 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "plain" version = "0.2.3" @@ -1007,50 +1277,42 @@ dependencies = [ ] [[package]] -name = "redox_syscall" -version = "0.5.2" +name = "reflink-copy" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +checksum = "dc31414597d1cd7fdd2422798b7652a6329dda0fe0219e6335a13d5bcaa9aeb6" dependencies = [ - "bitflags 2.6.0", + "cfg-if", + "rustix", + "windows", ] [[package]] -name = "regex" -version = "1.10.5" +name = "rustc-demangle" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] -name = "regex-automata" -version = "0.4.7" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "semver", ] [[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "rustc_version" -version = "0.4.0" +name = "rustix" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "semver", + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1068,12 +1330,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "scroll" version = "0.10.2" @@ -1138,6 +1394,17 @@ dependencies = [ "syn 2.0.70", ] +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "serde_json" version = "1.0.120" @@ -1149,6 +1416,39 @@ dependencies = [ "serde", ] +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -1156,10 +1456,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] -name = "smallvec" -version = "1.13.2" +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ssri" +version = "9.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "da7a2b3c2bc9693bcb40870c4e9b5bf0d79f9cb46273321bf855ec513e919082" +dependencies = [ + "base64", + "digest", + "hex", + "miette", + "serde", + "sha-1", + "sha2", + "thiserror", + "xxhash-rust", +] [[package]] name = "syn" @@ -1183,6 +1503,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "tests" version = "0.1.0" @@ -1211,6 +1544,40 @@ dependencies = [ "syn 2.0.70", ] +[[package]] +name = "tokio" +version = "1.39.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +dependencies = [ + "backtrace", + "bytes", + "pin-project-lite", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.11" @@ -1220,12 +1587,24 @@ dependencies = [ "serde", ] +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + [[package]] name = "version_check" version = "0.9.4" @@ -1276,7 +1655,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1285,6 +1664,70 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -1294,6 +1737,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.52.6" @@ -1357,3 +1809,9 @@ name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "xxhash-rust" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" diff --git a/workspace/Makefile b/workspace/Makefile index 9a1a5e4..5bad113 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -55,19 +55,6 @@ build: $(MAKE) -e -C contracts/$(CONTRACT) build; \ fi -build-simulator: build - mkdir -p $(BUILD_DIR) - @set -eu; \ - if [ "x$(CONTRACT)" = "x" ]; then \ - for contract in $(wildcard contracts/*); do \ - if [ -d "$$contract/`basename $$contract`-dbg" ]; then \ - $(MAKE) -e -C $$contract build-simulator; \ - fi; \ - done; \ - else \ - $(MAKE) -e -C contracts/$(CONTRACT) build-simulator; \ - fi - # Run a single make task for a specific contract. For example: # # make run CONTRACT=stack-reorder TASK=adjust_stack_size STACK_SIZE=0x200000 @@ -115,7 +102,6 @@ TEMPLATE_REPO := https://github.com/cryptape/ckb-script-templates CRATE := TEMPLATE := contract DESTINATION := contracts -ALSO_ADD_DEBUGGER := true generate: @set -eu; \ if [ "x$(CRATE)" = "x" ]; then \ @@ -128,10 +114,6 @@ generate: fi; \ sed "s,@@INSERTION_POINT@@,@@INSERTION_POINT@@\n \"$$GENERATED_DIR\"\,," Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; \ - if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ - echo "Generate native simulator debugger"; \ - scripts/generate-native-simulator $${GENERATED_DIR#$(DESTINATION)/} $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ - fi; \ else \ cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) $(TEMPLATE) \ --destination $(DESTINATION) \ @@ -142,10 +124,6 @@ generate: fi; \ sed '/@@INSERTION_POINT@@/s/$$/\n "$(DESTINATION)\/$(CRATE)",/' Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; \ - if [ "$(ALSO_ADD_DEBUGGER)" = "true" ] && [ "$(TEMPLATE)" = "contract" ]; then \ - echo "Generate native simulator debugger"; \ - scripts/generate-native-simulator $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ - fi; \ fi; generate-native-simulator: diff --git a/workspace/scripts/generate-native-simulator b/workspace/scripts/generate-native-simulator index 31dce75..cc68eb9 100755 --- a/workspace/scripts/generate-native-simulator +++ b/workspace/scripts/generate-native-simulator @@ -42,23 +42,27 @@ else echo "Contract does not exist" exit 4 fi - if [ -d "contracts/$CONTRACT_NAME/$CONTRACT_NAME-dbg" ]; then + if [ -d "native-simulators/$CONTRACT_NAME" ]; then echo "Already exists, no need to create" exit 5 fi fi CONTRACT_CRATE=$(echo "$CONTRACT_NAME" | tr '-' '_') +SIMULATOR_NAME=${CONTRACT_NAME}-sim -cargo generate $2 $3 native-simulator -n $CONTRACT_NAME-dbg --destination contracts/$CONTRACT_NAME -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE -cd contracts/$CONTRACT_NAME -mv $CONTRACT_NAME-dbg/src/contract-lib.rs src/lib.rs -echo "Finally, you need to add a feature to the contract's Cargo.toml:" -echo "simulator = ["ckb-std/simulator"]" +cargo generate $2 $3 native-simulator -n $SIMULATOR_NAME --destination native-simulators -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE +mv native-simulators/$SIMULATOR_NAME/src/contract-lib.rs contracts/$CONTRACT_NAME/src/lib.rs -FILE="Cargo.toml" +FILE=contracts/$CONTRACT_NAME/Cargo.toml if grep -q "\[features\]" "$FILE"; then sed -i '/\[features\]/a\simulator = ["ckb-std/simulator"]' "$FILE" else echo -e "\n[features]\nsimulator = [\"ckb-std/simulator\"]" >> "$FILE" fi + +if [ ! -d 'native-simulators/Makefile' ]; then + mv native-simulators/$SIMULATOR_NAME/GlobalMakefile native-simulators/Makefile +else + rm -f native-simulators/$SIMULATOR_NAME/GlobalMakefile +fi From a90a243e35da322dfcf630b7952b0544947ffbde Mon Sep 17 00:00:00 2001 From: joii Date: Mon, 2 Sep 2024 14:18:55 +0800 Subject: [PATCH 19/44] Delete unused code in workspace/Makefile --- workspace/Makefile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/workspace/Makefile b/workspace/Makefile index 5bad113..deb87a3 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -89,13 +89,6 @@ cargo: clean: rm -rf build cargo clean - @set -eu; \ - cd contracts; \ - for dir in * ; do \ - if [ -d $$dir/$$dir-dbg ]; then \ - (cd $$dir/$$dir-dbg && cargo clean); \ - fi \ - done TEMPLATE_TYPE := --git TEMPLATE_REPO := https://github.com/cryptape/ckb-script-templates From 997b5c22cadc202ec712fe47f853888af6e3bfb0 Mon Sep 17 00:00:00 2001 From: joii Date: Mon, 2 Sep 2024 15:25:54 +0800 Subject: [PATCH 20/44] Revert contract/src/main.rs --- contract/src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contract/src/main.rs b/contract/src/main.rs index 529347e..4ccf592 100644 --- a/contract/src/main.rs +++ b/contract/src/main.rs @@ -1,14 +1,14 @@ -#![cfg_attr(not(feature = "simulator"), no_std)] -#![cfg_attr(not(any(feature = "simulator", test)), no_main)] +#![no_std] +#![cfg_attr(not(test), no_main)] -#[cfg(any(feature = "simulator", test))] +#[cfg(test)] extern crate alloc; -#[cfg(not(any(feature = "simulator", test)))] +#[cfg(not(test))] use ckb_std::default_alloc; -#[cfg(not(any(feature = "simulator", test)))] +#[cfg(not(test))] ckb_std::entry!(program_entry); -#[cfg(not(any(feature = "simulator", test)))] +#[cfg(not(test))] default_alloc!(); pub fn program_entry() -> i8 { From 0d7e9132b02ab4a24a1d6f9aa227daee42f5d07c Mon Sep 17 00:00:00 2001 From: joii Date: Mon, 2 Sep 2024 15:49:18 +0800 Subject: [PATCH 21/44] Fix bug about generate native simulator --- native-simulator/GlobalMakefile | 4 ++-- workspace/scripts/generate-native-simulator | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/native-simulator/GlobalMakefile b/native-simulator/GlobalMakefile index 07be1a7..aef7d91 100644 --- a/native-simulator/GlobalMakefile +++ b/native-simulator/GlobalMakefile @@ -6,12 +6,12 @@ MODE := release BUILD_DIR := ../build/$(MODE) build: - mkdir -p ../$(BUILD_DIR) + mkdir -p $(BUILD_DIR) @set -eu; \ if [ "x$(CONTRACT)" = "x" ]; then \ for contract in $(wildcard ./*); do \ if [ -f $$contract/Cargo.toml ]; then \ - cd $$contract && cargo build && cp target/debug/*_dbg.* ../$(BUILD_DIR); \ + cd $$contract && cargo build && cp target/debug/*_sim.* ../$(BUILD_DIR)/; \ fi; \ done; \ else \ diff --git a/workspace/scripts/generate-native-simulator b/workspace/scripts/generate-native-simulator index cc68eb9..c84a72f 100755 --- a/workspace/scripts/generate-native-simulator +++ b/workspace/scripts/generate-native-simulator @@ -14,7 +14,7 @@ if [ "$CONTRACT_NAME" = "_" ]; then contracts=() for i in "${!folders[@]}"; do contract_name=$(echo "${folders[$i]}" | awk -F'/' '{print $(NF-1)}') - if [ ! -d "${folders[$i]}/${contract_name}-dbg" ]; then + if [ ! -d "${folders[$i]}/${contract_name}-sim" ]; then contracts+=("${contract_name}") fi done @@ -54,6 +54,13 @@ SIMULATOR_NAME=${CONTRACT_NAME}-sim cargo generate $2 $3 native-simulator -n $SIMULATOR_NAME --destination native-simulators -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE mv native-simulators/$SIMULATOR_NAME/src/contract-lib.rs contracts/$CONTRACT_NAME/src/lib.rs +if [ ! -d 'native-simulators/Makefile' ]; then + mv native-simulators/$SIMULATOR_NAME/GlobalMakefile native-simulators/Makefile +else + rm -f native-simulators/$SIMULATOR_NAME/GlobalMakefile +fi + +# Insert feature: simulator into Cargo.toml FILE=contracts/$CONTRACT_NAME/Cargo.toml if grep -q "\[features\]" "$FILE"; then sed -i '/\[features\]/a\simulator = ["ckb-std/simulator"]' "$FILE" @@ -61,8 +68,8 @@ else echo -e "\n[features]\nsimulator = [\"ckb-std/simulator\"]" >> "$FILE" fi -if [ ! -d 'native-simulators/Makefile' ]; then - mv native-simulators/$SIMULATOR_NAME/GlobalMakefile native-simulators/Makefile -else - rm -f native-simulators/$SIMULATOR_NAME/GlobalMakefile -fi +FILE=contracts/$CONTRACT_NAME/src/main.rs +sed -i 's/#!\[no_std\]/#!\[cfg_attr(not(feature = "simulator"), no_std)\]/' $FILE +sed -i 's/#!\[cfg_attr(not(test), no_main)\]/#!\[cfg_attr(not(any(feature = "simulator", test)), no_main)\]/' $FILE +sed -i 's/#\[cfg(test)\]/#\[cfg(any(feature = "simulator", test))\]/' $FILE +sed -i 's/#\[cfg(not(test))\]/#\[cfg(not(any(feature = "simulator", test)))\]/' $FILE From 00529262eeab5476f34b7cd6886f2989cd387417 Mon Sep 17 00:00:00 2001 From: joii Date: Mon, 2 Sep 2024 17:46:11 +0800 Subject: [PATCH 22/44] Remove documentation about debugging --- workspace/docs/debugging_contract.md | 147 --------------------------- 1 file changed, 147 deletions(-) delete mode 100644 workspace/docs/debugging_contract.md diff --git a/workspace/docs/debugging_contract.md b/workspace/docs/debugging_contract.md deleted file mode 100644 index f17d553..0000000 --- a/workspace/docs/debugging_contract.md +++ /dev/null @@ -1,147 +0,0 @@ -# Debugging Contract - -## Native Simulator Debugging - -By running `make generate`, a Rust contract is created with a `-dbg` suffix in the contract directory. This project allows you to compile the contract as a native platform dynamic library. To build it, simply run `make build-simulator`. Afterward, you can insert breakpoints and debug the contract code by enabling the `simulator` feature of `ckb-testtool` in unit tests. - -## Debugging with ckb-debugger and VSCode - -An alternative debugging method is available using `ckb-debugger` (in this case, with VSCode). `ckb-debugger` operates as a `gdb server`, supporting both gdb and lldb-18. In VSCode, the [Native Debug](https://marketplace.visualstudio.com/items?itemName=webfreak.debug) extension supports remote gdb debugging, which you'll need for this setup. -* Note: Although CodeLLDB supports remote debugging, it does not work well here due to the use of lldb version 17. - -### Compilation - -By default, the compiled output lacks debug symbols due to size constraints, so you need to compile using the `profile.ckb-debug` profile. You'll also need to create a copy of the binary for gdb/llvm debugging and strip the symbols from the original file for `ckb-debugger` to run. - -```shell -make build MODE=ckb-debug CARGO_ARGS='--profile=ckb-debug' -cp build/ckb-debug/ build/ckb-debug/.debug -llvm-objcopy --strip-debug --strip-all build/ckb-debug/ -``` - -To configure `tasks.json` in VSCode (using `c1` from CI as an example): - -```json -{ - "label": "Build Debug", - "type": "shell", - "command": "make build MODE=ckb-debug CARGO_ARGS='--profile=ckb-debug' && cp build/ckb-debug/c1 build/ckb-debug/c1.debug && llvm-objcopy --strip-debug --strip-all build/ckb-debug/c1" -}, -``` - -#### Running ckb-debugger - -(You can skip this section if the contract you are debugging doesn’t require transaction information.) - -Typically, contracts need transaction data, which can be retrieved from unit tests. Add the following code before `context.verify_tx(&tx, MAX_CYCLES)` in your unit tests: - -```rust -let tx_data = context.dump_tx(&tx).expect("dump tx info"); -std::fs::write( - "tx.json", - serde_json::to_string_pretty(&tx_data).expect("json"), -) -.expect("write tx"); -``` - -Then, start `ckb-debugger` with: - -```shell -ckb-debugger \ - --bin=build/ckb-debug/c1 \ - --mode=gdb_gdbstub \ - --gdb-listen=0.0.0.0:8000 \ - --tx-file=tests/tx.json \ - -s=lock \ - -i=0 -``` -* The example uses port 8000; feel free to change it if necessary. -* Adjust `-s` and `-i` according to your contract's needs. - -You can configure `tasks.json` in VSCode to automatically start `ckb-debugger`: - -```json -{ - "label": "Debug c1", - "isBackground": true, - "type": "process", - "command": "ckb-debugger", - "args": [ - "--bin=build/ckb-debug/c1", - "--mode=gdb_gdbstub", - "--gdb-listen=0.0.0.0:8000", - "--tx-file=tests/tx.json", - "-s=lock", - "-i=0" - ], - "options": { - "cwd": "${workspaceRoot}" - }, -}, -``` -* The `isBackground` setting ensures the task runs in the background and doesn't terminate during debugging. - -Since `ckb-debugger` doesn’t exit automatically after debugging, you'll need to configure a task to stop it: - -```json -{ - "label": "stop-ckb-debugger", - "type": "shell", - "command": "killall ckb-debugger || true" -}, -``` - -#### GDB Debugging - -```shell -gdb build/ckb-debug/c1.debug -``` -Then connect to `ckb-debugger`'s gdb server: - -```shell -target remote 127.0.0.1:8000 -``` -Once connected, you can debug using standard GDB commands. - -#### LLDB Debugging - -* Ensure you are using lldb version 18 or later. - -```shell -lldb build/ckb-debugger/c1.debug -``` -Then connect to `ckb-debugger`'s gdb server (you can omit the local address and just use the port): - -```shell -gdb-remote 8000 -``` -After connecting, you can use standard LLDB commands to debug. - -#### VSCode Debugging - -* GDB must be installed. -* The Native Debug extension is required for debugging in VSCode. - -First, configure `tasks.json` as described above. Then, set up your `launch.json` for debugging: - -```json -{ - "name": "GDB", - "type": "gdb", - "request": "attach", - "executable": "build/ckb-debug/c1.debug", - "debugger_args": [], - "cwd": "${workspaceRoot}", - "remote": true, - "target": "127.0.0.1:8000", - "preLaunchTask": "Debug c1", - "postDebugTask": "stop-ckb-debugger" -} -``` -After launching the debugger, you can set breakpoints and inspect variables as usual. - -### Additional Notes - -* The Native Simulator method is more convenient and supports advanced debugging features, which may not be available with `ckb-debugger`. -* `ckb-debugger` provides a debugging environment closer to the contract's runtime environment, while the Native Simulator only emulates the online environment. -* `ckb-debugger` may perform poorly compared to the Native Simulator, especially on low-end computers. \ No newline at end of file From ec8e3a1934f0afe749793d811cf50888d547e3ae Mon Sep 17 00:00:00 2001 From: joii Date: Wed, 4 Sep 2024 10:25:31 +0800 Subject: [PATCH 23/44] Allow warning (stack-reorder-contract) --- stack-reorder-contract/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stack-reorder-contract/src/main.rs b/stack-reorder-contract/src/main.rs index e66898f..d8c61ed 100644 --- a/stack-reorder-contract/src/main.rs +++ b/stack-reorder-contract/src/main.rs @@ -11,16 +11,17 @@ ckb_std::entry!(program_entry); #[cfg(not(test))] default_alloc!(); +#[allow(unused_variables, unused_assignments)] pub fn program_entry() -> i8 { - let mut _x: u64; + let mut x: u64; unsafe { core::arch::asm!( - "mv {_x}, sp", - _x = out(reg) _x, + "mv {x}, sp", + x = out(reg) x, ); } - ckb_std::debug!("Current SP is {:x}", _x); + ckb_std::debug!("Current SP is {:x}", x); 0 } From d556ad96b535e28f92c6b7aea046c9238ff96939 Mon Sep 17 00:00:00 2001 From: joii Date: Wed, 4 Sep 2024 17:10:19 +0800 Subject: [PATCH 24/44] Refactore generate native-simulator --- native-simulator/Cargo.toml | 6 -- native-simulator/GlobalMakefile | 28 -------- workspace/Makefile | 36 ++++++++-- workspace/scripts/generate-native-simulator | 75 --------------------- 4 files changed, 32 insertions(+), 113 deletions(-) delete mode 100644 native-simulator/GlobalMakefile delete mode 100755 workspace/scripts/generate-native-simulator diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index 45a2b63..e169267 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -10,9 +10,3 @@ ckb-std = { version = "0.15.1", features = ["simulator"] } [lib] crate-type = ["cdylib"] - -[workspace] - -# TODO: Will be deleted after release -[replace] -"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } diff --git a/native-simulator/GlobalMakefile b/native-simulator/GlobalMakefile deleted file mode 100644 index aef7d91..0000000 --- a/native-simulator/GlobalMakefile +++ /dev/null @@ -1,28 +0,0 @@ - -# This file is used by the parent directory. -# The current project can directly execute cargo build - -MODE := release -BUILD_DIR := ../build/$(MODE) - -build: - mkdir -p $(BUILD_DIR) - @set -eu; \ - if [ "x$(CONTRACT)" = "x" ]; then \ - for contract in $(wildcard ./*); do \ - if [ -f $$contract/Cargo.toml ]; then \ - cd $$contract && cargo build && cp target/debug/*_sim.* ../$(BUILD_DIR)/; \ - fi; \ - done; \ - else \ - cd $(CONTRACT) && cargo build; \ - fi - -clean: - @set -eu; \ - rm -rf $(BUILD_DIR)/*_sim.*; \ - for contract in $(wildcard ./*); do \ - if [ -f $$contract/Cargo.toml ]; then \ - cd $$contract && cargo clean; \ - fi; \ - done; \ No newline at end of file diff --git a/workspace/Makefile b/workspace/Makefile index deb87a3..6feeadd 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -55,6 +55,20 @@ build: $(MAKE) -e -C contracts/$(CONTRACT) build; \ fi +build-simulator: + @set -eu;\ + if [ ! -d native-simulators ] || [ -z "$$(ls -A native-simulators)" ]; then \ + echo "There is no native-simulator to compile."; \ + echo "If necessary, please use:"; \ + echo "make generate-native-simulator CRATE="; \ + else \ + mkdir -p $(BUILD_DIR); \ + for sim in $(wildcard native-simulators/*); do \ + cd $$sim && cargo build && cd ../..; \ + done; \ + cp target/debug/*_sim.* $(BUILD_DIR); \ + fi + # Run a single make task for a specific contract. For example: # # make run CONTRACT=stack-reorder TASK=adjust_stack_size STACK_SIZE=0x200000 @@ -121,11 +135,25 @@ generate: generate-native-simulator: @set -eu; \ - if [ "x$(CRATE)" = "x" ]; then \ - scripts/generate-native-simulator _ $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ + cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) native-simulator \ + -n $(CRATE)-sim \ + --destination native-simulators \ + -d contract_name=$(CRATE) \ + -d contract_crate_name=`echo "$(CRATE)" | tr '-' '_'`; \ + mv native-simulators/$(CRATE)-sim/src/contract-lib.rs contracts/$(CRATE)/src/lib.rs; \ + FILE=contracts/$(CRATE)/Cargo.toml; \ + if grep -q "\\[features\\]" "$$FILE"; then \ + sed -i '/\[features\]/a\\simulator = \[\"ckb-std/simulator\"\]' $$FILE; \ else \ - scripts/generate-native-simulator $(CRATE) $(TEMPLATE_TYPE) $(TEMPLATE_REPO); \ - fi + echo "\\n[features]\\nsimulator = [\"ckb-std/simulator\"]\\n" >> $$FILE ; \ + fi; \ + FILE=contracts/$(CRATE)/src/main.rs; \ + sed -i 's/#!\[no_std\]/#!\[cfg_attr(not(feature = "simulator"), no_std)\]/' $$FILE; \ + sed -i 's/#!\[cfg_attr(not(test), no_main)\]/#!\[cfg_attr(not(any(feature = "simulator", test)), no_main)\]/' $$FILE; \ + sed -i 's/#\[cfg(test)\]/#\[cfg(any(feature = "simulator", test))\]/' $$FILE; \ + sed -i 's/#\[cfg(not(test))\]/#\[cfg(not(any(feature = "simulator", test)))\]/' $$FILE; \ + sed '/@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \ + mv Cargo.toml.new Cargo.toml; prepare: rustup target add riscv64imac-unknown-none-elf diff --git a/workspace/scripts/generate-native-simulator b/workspace/scripts/generate-native-simulator deleted file mode 100755 index c84a72f..0000000 --- a/workspace/scripts/generate-native-simulator +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -# -# Add code for native debugging to existing onchain-script -CONTRACT_NAME=$1 - -if [ "$CONTRACT_NAME" = "_" ]; then - directory="./contracts" - if [ ! -d "$directory" ]; then - echo "No available contract a" - exit 1 - fi - - folders=($(ls -d $directory/*/)) - contracts=() - for i in "${!folders[@]}"; do - contract_name=$(echo "${folders[$i]}" | awk -F'/' '{print $(NF-1)}') - if [ ! -d "${folders[$i]}/${contract_name}-sim" ]; then - contracts+=("${contract_name}") - fi - done - - if [ ${#contracts[@]} -eq 0 ]; then - echo "No available contract b" - exit 2 - fi - - echo "Select contracts:" - for i in "${!folders[@]}"; do - folder_name=$(echo "${folders[$i]}" | awk -F'/' '{print $(NF-1)}') - echo " $((i+1)): ${contracts[$i]}" - done - echo "Enter index:" - read contract_index - if [[ "$contract_index" =~ ^[1-9][0-9]*$ ]] && [ "$contract_index" -le "${#contracts[@]}" ]; then - CONTRACT_NAME="${contracts[$((contract_index-1))]}" - else - echo "Invalid input" - exit 3 - fi -else - if [ ! -d "contracts/$CONTRACT_NAME" ]; then - echo "Contract does not exist" - exit 4 - fi - if [ -d "native-simulators/$CONTRACT_NAME" ]; then - echo "Already exists, no need to create" - exit 5 - fi -fi - -CONTRACT_CRATE=$(echo "$CONTRACT_NAME" | tr '-' '_') -SIMULATOR_NAME=${CONTRACT_NAME}-sim - -cargo generate $2 $3 native-simulator -n $SIMULATOR_NAME --destination native-simulators -d contract_name=$CONTRACT_NAME -d contract_crate_name=$CONTRACT_CRATE -mv native-simulators/$SIMULATOR_NAME/src/contract-lib.rs contracts/$CONTRACT_NAME/src/lib.rs - -if [ ! -d 'native-simulators/Makefile' ]; then - mv native-simulators/$SIMULATOR_NAME/GlobalMakefile native-simulators/Makefile -else - rm -f native-simulators/$SIMULATOR_NAME/GlobalMakefile -fi - -# Insert feature: simulator into Cargo.toml -FILE=contracts/$CONTRACT_NAME/Cargo.toml -if grep -q "\[features\]" "$FILE"; then - sed -i '/\[features\]/a\simulator = ["ckb-std/simulator"]' "$FILE" -else - echo -e "\n[features]\nsimulator = [\"ckb-std/simulator\"]" >> "$FILE" -fi - -FILE=contracts/$CONTRACT_NAME/src/main.rs -sed -i 's/#!\[no_std\]/#!\[cfg_attr(not(feature = "simulator"), no_std)\]/' $FILE -sed -i 's/#!\[cfg_attr(not(test), no_main)\]/#!\[cfg_attr(not(any(feature = "simulator", test)), no_main)\]/' $FILE -sed -i 's/#\[cfg(test)\]/#\[cfg(any(feature = "simulator", test))\]/' $FILE -sed -i 's/#\[cfg(not(test))\]/#\[cfg(not(any(feature = "simulator", test)))\]/' $FILE From 3228683d53e7478aa2dc2bd7ee24cefff402db49 Mon Sep 17 00:00:00 2001 From: joii Date: Wed, 4 Sep 2024 17:13:13 +0800 Subject: [PATCH 25/44] ckb-std lock specific version --- workspace/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index f1eb4bb..3ceddd6 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -20,4 +20,4 @@ debug = true # TODO: Will be deleted after release [replace] -"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", branch = "master" } \ No newline at end of file +"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", rev = "36942aa" } \ No newline at end of file From 0c25da100233fd5cd44d3575deec7c5f34ff6208 Mon Sep 17 00:00:00 2001 From: joii Date: Wed, 4 Sep 2024 17:24:35 +0800 Subject: [PATCH 26/44] Update the description about native simulator --- native-simulator/README.md | 5 ++++- native-simulator/cargo-generate.toml | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/native-simulator/README.md b/native-simulator/README.md index 0d68656..70287d9 100644 --- a/native-simulator/README.md +++ b/native-simulator/README.md @@ -2,6 +2,9 @@ TODO: Write this readme -*This contract was bootstrapped with [ckb-script-templates].* +*This template is used to provide native simulator for a particular contract, and is not designed to be used on its own.* + +*This project was bootstrapped with [ckb-script-templates].* + [ckb-script-templates]: https://github.com/cryptape/ckb-script-templates diff --git a/native-simulator/cargo-generate.toml b/native-simulator/cargo-generate.toml index 61ded01..f30095c 100644 --- a/native-simulator/cargo-generate.toml +++ b/native-simulator/cargo-generate.toml @@ -2,5 +2,5 @@ cargo_generate_version = ">=0.16.0" [placeholders] -contract_name = { prompt = "contract name", type = "string" } -contract_crate_name = { prompt = "contract crate name", type = "string" } +contract_name = { prompt = "The name of the corresponding contract", type = "string" } +contract_crate_name = { prompt = "The contract is used as the name of the module in the code. Generally, you need to replace - with _", type = "string" } From 6517a721f2461ad630c064c6b8b6faa0fed97b88 Mon Sep 17 00:00:00 2001 From: joii Date: Thu, 5 Sep 2024 11:34:34 +0800 Subject: [PATCH 27/44] Fix make check error when add native simulator --- native-simulator/src/contract-lib.rs | 1 + workspace/Makefile | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/native-simulator/src/contract-lib.rs b/native-simulator/src/contract-lib.rs index 71100fb..c371cd6 100644 --- a/native-simulator/src/contract-lib.rs +++ b/native-simulator/src/contract-lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(not(feature = "simulator"), no_std)] #![allow(special_module_name)] +#![allow(unused_attributes)] #[cfg(feature = "simulator")] mod main; #[cfg(feature = "simulator")] diff --git a/workspace/Makefile b/workspace/Makefile index 6feeadd..ba6b228 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -149,7 +149,6 @@ generate-native-simulator: fi; \ FILE=contracts/$(CRATE)/src/main.rs; \ sed -i 's/#!\[no_std\]/#!\[cfg_attr(not(feature = "simulator"), no_std)\]/' $$FILE; \ - sed -i 's/#!\[cfg_attr(not(test), no_main)\]/#!\[cfg_attr(not(any(feature = "simulator", test)), no_main)\]/' $$FILE; \ sed -i 's/#\[cfg(test)\]/#\[cfg(any(feature = "simulator", test))\]/' $$FILE; \ sed -i 's/#\[cfg(not(test))\]/#\[cfg(not(any(feature = "simulator", test)))\]/' $$FILE; \ sed '/@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \ From aa8a2f0cddf1386f4ff08a499b430ef9e9304568 Mon Sep 17 00:00:00 2001 From: joii Date: Thu, 5 Sep 2024 12:08:00 +0800 Subject: [PATCH 28/44] Add a comment about profile.ckb-debug --- workspace/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index 3ceddd6..ad0aa09 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -13,6 +13,7 @@ overflow-checks = true strip = true codegen-units = 1 +# This profile is used for debugging with ckb-debugger. [profile.ckb-debug] inherits = "release" strip = false From b98b2a389c09298f5b16fbe7da2d859d1588c130 Mon Sep 17 00:00:00 2001 From: joii Date: Thu, 5 Sep 2024 12:08:37 +0800 Subject: [PATCH 29/44] Delete the commented out code --- workspace/tests/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/workspace/tests/Cargo.toml b/workspace/tests/Cargo.toml index 11df826..c42ce93 100644 --- a/workspace/tests/Cargo.toml +++ b/workspace/tests/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" [features] -# default = [ "simulator" ] simulator = [ "ckb-testtool/simulator" ] [dependencies] From 8403fceb4ae0241b16c6d4cc01520d7b75a40670 Mon Sep 17 00:00:00 2001 From: joii Date: Thu, 5 Sep 2024 14:37:25 +0800 Subject: [PATCH 30/44] build-simulator merge to build --- workspace/Makefile | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/workspace/Makefile b/workspace/Makefile index ba6b228..99024d5 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -53,21 +53,10 @@ build: done; \ else \ $(MAKE) -e -C contracts/$(CONTRACT) build; \ - fi - -build-simulator: - @set -eu;\ - if [ ! -d native-simulators ] || [ -z "$$(ls -A native-simulators)" ]; then \ - echo "There is no native-simulator to compile."; \ - echo "If necessary, please use:"; \ - echo "make generate-native-simulator CRATE="; \ - else \ - mkdir -p $(BUILD_DIR); \ - for sim in $(wildcard native-simulators/*); do \ - cd $$sim && cargo build && cd ../..; \ - done; \ - cp target/debug/*_sim.* $(BUILD_DIR); \ - fi + fi; \ + for sim in $(wildcard native-simulators/*); do \ + cd $$sim && cargo build && cd ../..; \ + done; \ # Run a single make task for a specific contract. For example: # From d30d2e37a6975467c659b6440d556409745ce81c Mon Sep 17 00:00:00 2001 From: joii Date: Thu, 5 Sep 2024 17:11:59 +0800 Subject: [PATCH 31/44] The built contract has symbols and is deleted using objcopy --- contract/Makefile | 3 +++ workspace/Cargo.toml | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/contract/Makefile b/contract/Makefile index b8bc7f6..9b18274 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -19,6 +19,7 @@ MODE := release # we use a bash script with somes heuristics to find clang in current system. CLANG := $(shell $(TOP)/scripts/find_clang) AR := $(subst clang,llvm-ar,$(CLANG)) +OBJCOPY := $(subst clang,llvm-objcopy,$(CLANG)) # When this is set to some value, the generated binaries will be copied over BUILD_DIR := # Generated binaries to copy. By convention, a Rust crate's directory name will @@ -41,6 +42,8 @@ build: for binary in $(BINARIES); do \ echo "Copying binary $$binary to build directory"; \ cp $(TOP)/target/riscv64imac-unknown-none-elf/$(MODE)/$$binary $(TOP)/$(BUILD_DIR); \ + cp $(TOP)/$(BUILD_DIR)/$$binary $(TOP)/$(BUILD_DIR)/$$binary.debug; \ + $(OBJCOPY) --strip-debug --strip-all $(TOP)/$(BUILD_DIR)/$$binary; \ done \ fi diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index ad0aa09..70917c4 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -10,13 +10,8 @@ members = [ [profile.release] overflow-checks = true -strip = true -codegen-units = 1 - -# This profile is used for debugging with ckb-debugger. -[profile.ckb-debug] -inherits = "release" strip = false +codegen-units = 1 debug = true # TODO: Will be deleted after release From 30f44d6628a73ddf5cc38e555cb562293f1dbe1d Mon Sep 17 00:00:00 2001 From: joii Date: Thu, 5 Sep 2024 21:35:07 +0800 Subject: [PATCH 32/44] ckb-std update to 0.15.3 --- atomics-contract/Cargo.toml | 2 +- contract/Cargo.toml | 2 +- native-simulator/Cargo.toml | 2 +- stack-reorder-contract/Cargo.toml | 2 +- standalone-contract/Cargo.toml | 2 +- x64-simulator-crate/Cargo.toml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atomics-contract/Cargo.toml b/atomics-contract/Cargo.toml index 54cc9fe..3dc9f2c 100644 --- a/atomics-contract/Cargo.toml +++ b/atomics-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.1" +ckb-std = "0.15.3" log = { version = "0.4.20", default-features = false } [build-dependencies] diff --git a/contract/Cargo.toml b/contract/Cargo.toml index dc36fc8..608e397 100644 --- a/contract/Cargo.toml +++ b/contract/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.1" +ckb-std = "0.15.3" diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index e169267..5f5e980 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] {{contract_name}} = { path = "../../contracts/{{contract_name}}", features = ["simulator"] } -ckb-std = { version = "0.15.1", features = ["simulator"] } +ckb-std = { version = "0.15.3", features = ["simulator"] } [lib] crate-type = ["cdylib"] diff --git a/stack-reorder-contract/Cargo.toml b/stack-reorder-contract/Cargo.toml index 00d4025..30162f0 100644 --- a/stack-reorder-contract/Cargo.toml +++ b/stack-reorder-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.1" +ckb-std = "0.15.3" [build-dependencies] cc = "1.0" diff --git a/standalone-contract/Cargo.toml b/standalone-contract/Cargo.toml index 59d9be3..cea2d89 100644 --- a/standalone-contract/Cargo.toml +++ b/standalone-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.1" +ckb-std = "0.15.3" [dev-dependencies] ckb-testtool = "0.13.0" diff --git a/x64-simulator-crate/Cargo.toml b/x64-simulator-crate/Cargo.toml index 3ea3743..8c2b202 100644 --- a/x64-simulator-crate/Cargo.toml +++ b/x64-simulator-crate/Cargo.toml @@ -4,11 +4,11 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.1" +ckb-std = "0.15.3" # Supporting native tests powered by ckb-x64-simulator [target.'cfg(all(target_arch = "x86_64", unix))'.dependencies.ckb-std] -version = "0.15.1" +version = "0.15.3" features = ["simulator"] [target.'cfg(all(target_arch = "x86_64", unix))'.dev-dependencies] From 39da9513465a657d31e83b6aa5695c238e5dc1f9 Mon Sep 17 00:00:00 2001 From: joii Date: Fri, 6 Sep 2024 17:48:02 +0800 Subject: [PATCH 33/44] Contract add feature: native-simulator * Contracts support native-simulator by default. * native-simulator project no longer requires scripts to add code to contracts. * simulator renamed to native-simulator. --- contract/Cargo.toml | 3 +++ contract/src/lib.rs | 7 +++++++ contract/src/main.rs | 12 +++++------- native-simulator/Cargo.toml | 4 ++-- native-simulator/src/contract-lib.rs | 7 ------- workspace/Cargo.toml | 2 +- workspace/Makefile | 11 ----------- 7 files changed, 18 insertions(+), 28 deletions(-) create mode 100644 contract/src/lib.rs delete mode 100644 native-simulator/src/contract-lib.rs diff --git a/contract/Cargo.toml b/contract/Cargo.toml index 608e397..83cfe88 100644 --- a/contract/Cargo.toml +++ b/contract/Cargo.toml @@ -5,3 +5,6 @@ edition = "2021" [dependencies] ckb-std = "0.15.3" + +[features] +native-simulator = ["ckb-std/native-simulator"] diff --git a/contract/src/lib.rs b/contract/src/lib.rs new file mode 100644 index 0000000..7b58725 --- /dev/null +++ b/contract/src/lib.rs @@ -0,0 +1,7 @@ +#![cfg_attr(not(feature = "native-simulator"), no_std)] +#![allow(special_module_name)] +#![allow(unused_attributes)] +#[cfg(feature = "native-simulator")] +mod main; +#[cfg(feature = "native-simulator")] +pub use main::program_entry; diff --git a/contract/src/main.rs b/contract/src/main.rs index 4ccf592..f2911f0 100644 --- a/contract/src/main.rs +++ b/contract/src/main.rs @@ -1,15 +1,13 @@ -#![no_std] +#![cfg_attr(not(feature = "native-simulator"), no_std)] #![cfg_attr(not(test), no_main)] -#[cfg(test)] +#[cfg(any(feature = "native-simulator", test))] extern crate alloc; -#[cfg(not(test))] -use ckb_std::default_alloc; -#[cfg(not(test))] +#[cfg(not(any(feature = "native-simulator", test)))] ckb_std::entry!(program_entry); -#[cfg(not(test))] -default_alloc!(); +#[cfg(not(any(feature = "native-simulator", test)))] +ckb_std::default_alloc!(); pub fn program_entry() -> i8 { ckb_std::debug!("This is a sample contract!"); diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index 5f5e980..3516474 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -{{contract_name}} = { path = "../../contracts/{{contract_name}}", features = ["simulator"] } -ckb-std = { version = "0.15.3", features = ["simulator"] } +{{contract_name}} = { path = "../../contracts/{{contract_name}}", features = ["native-simulator"] } +ckb-std = { version = "0.15.3", features = ["native-simulator"] } [lib] crate-type = ["cdylib"] diff --git a/native-simulator/src/contract-lib.rs b/native-simulator/src/contract-lib.rs deleted file mode 100644 index c371cd6..0000000 --- a/native-simulator/src/contract-lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![cfg_attr(not(feature = "simulator"), no_std)] -#![allow(special_module_name)] -#![allow(unused_attributes)] -#[cfg(feature = "simulator")] -mod main; -#[cfg(feature = "simulator")] -pub use main::program_entry; diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index 70917c4..dc31dd9 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -16,4 +16,4 @@ debug = true # TODO: Will be deleted after release [replace] -"ckb-std:0.15.3" = { git = "https://github.com/nervosnetwork/ckb-std.git", rev = "36942aa" } \ No newline at end of file +"ckb-std:0.15.3" = { git = "https://github.com/joii2020/ckb-std.git", rev = "76f1ac3" } \ No newline at end of file diff --git a/workspace/Makefile b/workspace/Makefile index 99024d5..6cac3bc 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -129,17 +129,6 @@ generate-native-simulator: --destination native-simulators \ -d contract_name=$(CRATE) \ -d contract_crate_name=`echo "$(CRATE)" | tr '-' '_'`; \ - mv native-simulators/$(CRATE)-sim/src/contract-lib.rs contracts/$(CRATE)/src/lib.rs; \ - FILE=contracts/$(CRATE)/Cargo.toml; \ - if grep -q "\\[features\\]" "$$FILE"; then \ - sed -i '/\[features\]/a\\simulator = \[\"ckb-std/simulator\"\]' $$FILE; \ - else \ - echo "\\n[features]\\nsimulator = [\"ckb-std/simulator\"]\\n" >> $$FILE ; \ - fi; \ - FILE=contracts/$(CRATE)/src/main.rs; \ - sed -i 's/#!\[no_std\]/#!\[cfg_attr(not(feature = "simulator"), no_std)\]/' $$FILE; \ - sed -i 's/#\[cfg(test)\]/#\[cfg(any(feature = "simulator", test))\]/' $$FILE; \ - sed -i 's/#\[cfg(not(test))\]/#\[cfg(not(any(feature = "simulator", test)))\]/' $$FILE; \ sed '/@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; From e19c9b3ca304e192d09354055b8fa7b6c6654ce5 Mon Sep 17 00:00:00 2001 From: joii Date: Sun, 8 Sep 2024 15:42:31 +0800 Subject: [PATCH 34/44] Fix error: x64-simulator-crate simulator rename to native-simulator --- x64-simulator-crate/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x64-simulator-crate/Cargo.toml b/x64-simulator-crate/Cargo.toml index 8c2b202..011dbc5 100644 --- a/x64-simulator-crate/Cargo.toml +++ b/x64-simulator-crate/Cargo.toml @@ -9,7 +9,7 @@ ckb-std = "0.15.3" # Supporting native tests powered by ckb-x64-simulator [target.'cfg(all(target_arch = "x86_64", unix))'.dependencies.ckb-std] version = "0.15.3" -features = ["simulator"] +features = ["native-simulator"] [target.'cfg(all(target_arch = "x86_64", unix))'.dev-dependencies] ckb-testtool = "0.13.0" From 09fdcde7105656dad91086d8093e84098aafc0c7 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Wed, 11 Sep 2024 14:15:45 +0800 Subject: [PATCH 35/44] Optiomization workspace/Makefile build --- workspace/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/workspace/Makefile b/workspace/Makefile index 6cac3bc..96fd8fe 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -51,12 +51,13 @@ build: for crate in $(wildcard crates/*); do \ cargo build -p $$(basename $$crate) $(MODE_ARGS) $(CARGO_ARGS); \ done; \ + for sim in $(wildcard native-simulators/*); do \ + cargo build -p $$(basename $$sim) $(CARGO_ARGS); \ + done; \ else \ $(MAKE) -e -C contracts/$(CONTRACT) build; \ - fi; \ - for sim in $(wildcard native-simulators/*); do \ - cd $$sim && cargo build && cd ../..; \ - done; \ + cargo build -p $(CONTRACT)-sim; \ + fi; # Run a single make task for a specific contract. For example: # From 1ff8ac9be5ce7b9c2c9f74128b765db8e6fa6fed Mon Sep 17 00:00:00 2001 From: joii2020 Date: Wed, 11 Sep 2024 15:28:08 +0800 Subject: [PATCH 36/44] Using Liquid to process templates --- native-simulator/Cargo.toml | 2 +- native-simulator/cargo-generate.toml | 4 ---- native-simulator/src/lib.rs | 2 +- workspace/Makefile | 4 +--- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index 3516474..39562b8 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -{{contract_name}} = { path = "../../contracts/{{contract_name}}", features = ["native-simulator"] } +{{project-name | remove: "-sim"}} = { path = "../../contracts/{{project-name | remove: "-sim"}}", features = ["native-simulator"] } ckb-std = { version = "0.15.3", features = ["native-simulator"] } [lib] diff --git a/native-simulator/cargo-generate.toml b/native-simulator/cargo-generate.toml index f30095c..2113d4d 100644 --- a/native-simulator/cargo-generate.toml +++ b/native-simulator/cargo-generate.toml @@ -1,6 +1,2 @@ [template] cargo_generate_version = ">=0.16.0" - -[placeholders] -contract_name = { prompt = "The name of the corresponding contract", type = "string" } -contract_crate_name = { prompt = "The contract is used as the name of the module in the code. Generally, you need to replace - with _", type = "string" } diff --git a/native-simulator/src/lib.rs b/native-simulator/src/lib.rs index f5cdf3b..edb1a75 100644 --- a/native-simulator/src/lib.rs +++ b/native-simulator/src/lib.rs @@ -1 +1 @@ -ckb_std::entry_simulator!({{contract_crate_name}}::program_entry); +ckb_std::entry_simulator!({{project-name | remove: "-sim" | replace: "-", "_"}}::program_entry); diff --git a/workspace/Makefile b/workspace/Makefile index 96fd8fe..4da1953 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -127,9 +127,7 @@ generate-native-simulator: @set -eu; \ cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) native-simulator \ -n $(CRATE)-sim \ - --destination native-simulators \ - -d contract_name=$(CRATE) \ - -d contract_crate_name=`echo "$(CRATE)" | tr '-' '_'`; \ + --destination native-simulators; \ sed '/@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \ mv Cargo.toml.new Cargo.toml; From d81d8d0efa10e6e2e27c0da2992284186a5a4a63 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Tue, 24 Sep 2024 14:36:45 +0800 Subject: [PATCH 37/44] Optimize cargo-generate rules --- native-simulator/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index 39562b8..686f8f4 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -{{project-name | remove: "-sim"}} = { path = "../../contracts/{{project-name | remove: "-sim"}}", features = ["native-simulator"] } +{{project-name | append: "@@SIMULATOR_PLACEHOLDER@@" | remove: "-sim@@SIMULATOR_PLACEHOLDER@@"}} = { path = "../../contracts/{{project-name | append: "@@SIMULATOR_PLACEHOLDER@@" | remove: "-sim@@SIMULATOR_PLACEHOLDER@@"}}", features = ["native-simulator"] } ckb-std = { version = "0.15.3", features = ["native-simulator"] } [lib] From a0a0d4e4d9ee89a0e5f91b6d1065a604476dff68 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Tue, 24 Sep 2024 15:05:19 +0800 Subject: [PATCH 38/44] Optimize cargo-generate rules in native-simulator lib.rs --- native-simulator/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native-simulator/src/lib.rs b/native-simulator/src/lib.rs index edb1a75..26128b7 100644 --- a/native-simulator/src/lib.rs +++ b/native-simulator/src/lib.rs @@ -1 +1 @@ -ckb_std::entry_simulator!({{project-name | remove: "-sim" | replace: "-", "_"}}::program_entry); +ckb_std::entry_simulator!({{project-name | append: "@@SIMULATOR_PLACEHOLDER@@" | remove: "-sim@@SIMULATOR_PLACEHOLDER@@" | replace: "-", "_"}}::program_entry); From 3215d67e15d825dda648c23c0efcf8cc06924283 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Tue, 24 Sep 2024 15:53:49 +0800 Subject: [PATCH 39/44] Update ckb-std rev --- workspace/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index dc31dd9..fe92717 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -16,4 +16,4 @@ debug = true # TODO: Will be deleted after release [replace] -"ckb-std:0.15.3" = { git = "https://github.com/joii2020/ckb-std.git", rev = "76f1ac3" } \ No newline at end of file +"ckb-std:0.15.3" = { git = "https://github.com/joii2020/ckb-std.git", rev = "d90a4f974a0c8561b6259424a173e22cc86e1ae5" } \ No newline at end of file From 2ea07342c50511e3e4df2b6979d6b5fe2789d476 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Fri, 1 Nov 2024 11:22:08 +0800 Subject: [PATCH 40/44] Update dependencies: ckb-std and ckb-testtool --- atomics-contract/Cargo.toml | 2 +- contract/Cargo.toml | 2 +- contract/src/main.rs | 2 +- native-simulator/Cargo.toml | 2 +- stack-reorder-contract/Cargo.toml | 2 +- standalone-contract/Cargo.toml | 4 ++-- workspace/Cargo.toml | 4 ---- workspace/tests/Cargo.toml | 4 ++-- x64-simulator-crate/Cargo.toml | 6 +++--- 9 files changed, 12 insertions(+), 16 deletions(-) diff --git a/atomics-contract/Cargo.toml b/atomics-contract/Cargo.toml index 3dc9f2c..95415ce 100644 --- a/atomics-contract/Cargo.toml +++ b/atomics-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.3" +ckb-std = { version = "0.16.1", default-features = false, features = ["allocator", "calc-hash", "ckb-types", "libc"] } log = { version = "0.4.20", default-features = false } [build-dependencies] diff --git a/contract/Cargo.toml b/contract/Cargo.toml index 83cfe88..ad6d36e 100644 --- a/contract/Cargo.toml +++ b/contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.3" +ckb-std = "0.16.1" [features] native-simulator = ["ckb-std/native-simulator"] diff --git a/contract/src/main.rs b/contract/src/main.rs index f2911f0..dedabe3 100644 --- a/contract/src/main.rs +++ b/contract/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(not(feature = "native-simulator"), no_std)] +#![cfg_attr(not(any(feature = "native-simulator", test)), no_std)] #![cfg_attr(not(test), no_main)] #[cfg(any(feature = "native-simulator", test))] diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index 686f8f4..4a18412 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] {{project-name | append: "@@SIMULATOR_PLACEHOLDER@@" | remove: "-sim@@SIMULATOR_PLACEHOLDER@@"}} = { path = "../../contracts/{{project-name | append: "@@SIMULATOR_PLACEHOLDER@@" | remove: "-sim@@SIMULATOR_PLACEHOLDER@@"}}", features = ["native-simulator"] } -ckb-std = { version = "0.15.3", features = ["native-simulator"] } +ckb-std = { version = "0.16.1", features = ["native-simulator"] } [lib] crate-type = ["cdylib"] diff --git a/stack-reorder-contract/Cargo.toml b/stack-reorder-contract/Cargo.toml index 30162f0..288a2dd 100644 --- a/stack-reorder-contract/Cargo.toml +++ b/stack-reorder-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.3" +ckb-std = "0.16.1" [build-dependencies] cc = "1.0" diff --git a/standalone-contract/Cargo.toml b/standalone-contract/Cargo.toml index cea2d89..03818a3 100644 --- a/standalone-contract/Cargo.toml +++ b/standalone-contract/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.3" +ckb-std = "0.16.1" [dev-dependencies] -ckb-testtool = "0.13.0" +ckb-testtool = "0.14.0" serde_json = "1.0" diff --git a/workspace/Cargo.toml b/workspace/Cargo.toml index fe92717..c64b8c8 100644 --- a/workspace/Cargo.toml +++ b/workspace/Cargo.toml @@ -13,7 +13,3 @@ overflow-checks = true strip = false codegen-units = 1 debug = true - -# TODO: Will be deleted after release -[replace] -"ckb-std:0.15.3" = { git = "https://github.com/joii2020/ckb-std.git", rev = "d90a4f974a0c8561b6259424a173e22cc86e1ae5" } \ No newline at end of file diff --git a/workspace/tests/Cargo.toml b/workspace/tests/Cargo.toml index c42ce93..c749f2d 100644 --- a/workspace/tests/Cargo.toml +++ b/workspace/tests/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [features] -simulator = [ "ckb-testtool/simulator" ] +native-simulator = [ "ckb-testtool/native-simulator" ] [dependencies] -ckb-testtool = "0.13.0" +ckb-testtool = "0.14.0" serde_json = "1.0" diff --git a/x64-simulator-crate/Cargo.toml b/x64-simulator-crate/Cargo.toml index 011dbc5..11c50f2 100644 --- a/x64-simulator-crate/Cargo.toml +++ b/x64-simulator-crate/Cargo.toml @@ -4,15 +4,15 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.15.3" +ckb-std = "0.16.1" # Supporting native tests powered by ckb-x64-simulator [target.'cfg(all(target_arch = "x86_64", unix))'.dependencies.ckb-std] -version = "0.15.3" +version = "0.16.1" features = ["native-simulator"] [target.'cfg(all(target_arch = "x86_64", unix))'.dev-dependencies] -ckb-testtool = "0.13.0" +ckb-testtool = "0.14.0" rusty-fork = "0.3.0" rand = "0.8.5" serde_json = "1.0" From ab116fa4928bd532175c9724905b430a3ce43aa5 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Fri, 1 Nov 2024 11:41:29 +0800 Subject: [PATCH 41/44] Fix CI --- atomics-contract/src/main.rs | 2 +- stack-reorder-contract/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atomics-contract/src/main.rs b/atomics-contract/src/main.rs index 7a2e3cc..92b99e2 100644 --- a/atomics-contract/src/main.rs +++ b/atomics-contract/src/main.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_main)] #[cfg(test)] diff --git a/stack-reorder-contract/src/main.rs b/stack-reorder-contract/src/main.rs index d8c61ed..93a65a6 100644 --- a/stack-reorder-contract/src/main.rs +++ b/stack-reorder-contract/src/main.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_main)] #[cfg(test)] From 8e8a9d9490617e20525abf8fa66210d88410c9cd Mon Sep 17 00:00:00 2001 From: joii2020 Date: Fri, 1 Nov 2024 13:08:20 +0800 Subject: [PATCH 42/44] Fix CI: on Makfile about CUSTOM_RUSTFLAGS --- atomics-contract/Makefile | 2 +- contract/Makefile | 2 +- stack-reorder-contract/Makefile | 2 +- standalone-contract/Makefile | 2 +- workspace/Makefile | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/atomics-contract/Makefile b/atomics-contract/Makefile index b8bc7f6..652152d 100644 --- a/atomics-contract/Makefile +++ b/atomics-contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := --cfg debug_assertions +CUSTOM_RUSTFLAGS := -C debug_assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) diff --git a/contract/Makefile b/contract/Makefile index 9b18274..e2cffce 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := --cfg debug_assertions +CUSTOM_RUSTFLAGS := -C debug_assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) diff --git a/stack-reorder-contract/Makefile b/stack-reorder-contract/Makefile index 6510f51..ca8d080 100644 --- a/stack-reorder-contract/Makefile +++ b/stack-reorder-contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := --cfg debug_assertions +CUSTOM_RUSTFLAGS := -C debug_assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) \ diff --git a/standalone-contract/Makefile b/standalone-contract/Makefile index 8914ed0..975ff47 100644 --- a/standalone-contract/Makefile +++ b/standalone-contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := --cfg debug_assertions +CUSTOM_RUSTFLAGS := -C debug_assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) diff --git a/workspace/Makefile b/workspace/Makefile index 4da1953..8976850 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := --cfg debug_assertions +CUSTOM_RUSTFLAGS := -C debug_assertions # Additional cargo args to append here. For example, one can use # make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to # stdout in unit tests From 9db520e7735133cc12c459df800015b5c12feb63 Mon Sep 17 00:00:00 2001 From: joii2020 Date: Fri, 1 Nov 2024 14:59:20 +0800 Subject: [PATCH 43/44] Update ckb-std to 0.16.3 --- atomics-contract/Cargo.toml | 2 +- contract/Cargo.toml | 2 +- native-simulator/Cargo.toml | 2 +- stack-reorder-contract/Cargo.toml | 2 +- standalone-contract/Cargo.toml | 2 +- x64-simulator-crate/Cargo.toml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atomics-contract/Cargo.toml b/atomics-contract/Cargo.toml index 95415ce..8df89c6 100644 --- a/atomics-contract/Cargo.toml +++ b/atomics-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = { version = "0.16.1", default-features = false, features = ["allocator", "calc-hash", "ckb-types", "libc"] } +ckb-std = { version = "0.16.3", default-features = false, features = ["allocator", "calc-hash", "ckb-types", "libc"] } log = { version = "0.4.20", default-features = false } [build-dependencies] diff --git a/contract/Cargo.toml b/contract/Cargo.toml index ad6d36e..e9beb3d 100644 --- a/contract/Cargo.toml +++ b/contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.16.1" +ckb-std = "0.16.3" [features] native-simulator = ["ckb-std/native-simulator"] diff --git a/native-simulator/Cargo.toml b/native-simulator/Cargo.toml index 4a18412..75d3751 100644 --- a/native-simulator/Cargo.toml +++ b/native-simulator/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] {{project-name | append: "@@SIMULATOR_PLACEHOLDER@@" | remove: "-sim@@SIMULATOR_PLACEHOLDER@@"}} = { path = "../../contracts/{{project-name | append: "@@SIMULATOR_PLACEHOLDER@@" | remove: "-sim@@SIMULATOR_PLACEHOLDER@@"}}", features = ["native-simulator"] } -ckb-std = { version = "0.16.1", features = ["native-simulator"] } +ckb-std = { version = "0.16.3", features = ["native-simulator"] } [lib] crate-type = ["cdylib"] diff --git a/stack-reorder-contract/Cargo.toml b/stack-reorder-contract/Cargo.toml index 288a2dd..3e8da71 100644 --- a/stack-reorder-contract/Cargo.toml +++ b/stack-reorder-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.16.1" +ckb-std = "0.16.3" [build-dependencies] cc = "1.0" diff --git a/standalone-contract/Cargo.toml b/standalone-contract/Cargo.toml index 03818a3..41c130e 100644 --- a/standalone-contract/Cargo.toml +++ b/standalone-contract/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.16.1" +ckb-std = "0.16.3" [dev-dependencies] ckb-testtool = "0.14.0" diff --git a/x64-simulator-crate/Cargo.toml b/x64-simulator-crate/Cargo.toml index 11c50f2..81c85a5 100644 --- a/x64-simulator-crate/Cargo.toml +++ b/x64-simulator-crate/Cargo.toml @@ -4,11 +4,11 @@ version = "0.1.0" edition = "2021" [dependencies] -ckb-std = "0.16.1" +ckb-std = "0.16.3" # Supporting native tests powered by ckb-x64-simulator [target.'cfg(all(target_arch = "x86_64", unix))'.dependencies.ckb-std] -version = "0.16.1" +version = "0.16.3" features = ["native-simulator"] [target.'cfg(all(target_arch = "x86_64", unix))'.dev-dependencies] From b6d79b949500db95ff691b17023197e29f464dda Mon Sep 17 00:00:00 2001 From: joii2020 Date: Fri, 1 Nov 2024 18:21:31 +0800 Subject: [PATCH 44/44] Typos: Makefile CUSTOM_RUSTFLAGS --- atomics-contract/Makefile | 2 +- contract/Makefile | 2 +- stack-reorder-contract/Makefile | 2 +- standalone-contract/Makefile | 2 +- workspace/Makefile | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/atomics-contract/Makefile b/atomics-contract/Makefile index 652152d..1a019fd 100644 --- a/atomics-contract/Makefile +++ b/atomics-contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := -C debug_assertions +CUSTOM_RUSTFLAGS := -C debug-assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) diff --git a/contract/Makefile b/contract/Makefile index e2cffce..7e88d6e 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := -C debug_assertions +CUSTOM_RUSTFLAGS := -C debug-assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) diff --git a/stack-reorder-contract/Makefile b/stack-reorder-contract/Makefile index ca8d080..af810f9 100644 --- a/stack-reorder-contract/Makefile +++ b/stack-reorder-contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := -C debug_assertions +CUSTOM_RUSTFLAGS := -C debug-assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) \ diff --git a/standalone-contract/Makefile b/standalone-contract/Makefile index 975ff47..9ad825d 100644 --- a/standalone-contract/Makefile +++ b/standalone-contract/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := -C debug_assertions +CUSTOM_RUSTFLAGS := -C debug-assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) diff --git a/workspace/Makefile b/workspace/Makefile index 8976850..ebb24a6 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -6,7 +6,7 @@ TOP := $(cur_dir) # RUSTFLAGS that are likely to be tweaked by developers. For example, # while we enable debug logs by default here, some might want to strip them # for minimal code size / consumed cycles. -CUSTOM_RUSTFLAGS := -C debug_assertions +CUSTOM_RUSTFLAGS := -C debug-assertions # Additional cargo args to append here. For example, one can use # make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to # stdout in unit tests