From b5ef88b68cb69205cefdf0fc0d7e4ec31a802088 Mon Sep 17 00:00:00 2001 From: mohanson Date: Fri, 20 Sep 2024 10:31:34 +0800 Subject: [PATCH] Preserve most of the directory structure --- .github/workflows/develop-rust.yml | 23 ---------- .../{develop-clang.yml => develop.yml} | 4 +- .github/workflows/release.yml | 1 + Cargo.toml | 10 ++-- Cross.toml | 5 -- Makefile | 6 +-- build.rs | 2 +- capsule.toml | 35 -------------- contracts/Cargo.lock | 46 +++++++++++++++---- contracts/Cross.toml | 5 -- contracts/ckb-std-tests/Cargo.toml | 6 +-- contracts/exec-callee/Cargo.toml | 2 +- .../exec-callee/exec-callee-dbg/Cargo.lock | 42 ++++++++++++++--- .../exec-callee/exec-callee-dbg/Cargo.toml | 4 +- contracts/exec-caller-by-code-hash/Cargo.toml | 2 +- contracts/exec-caller/Cargo.toml | 2 +- contracts/spawn-callee/Cargo.toml | 2 +- .../spawn-caller-by-code-hash/Cargo.toml | 2 +- contracts/spawn-caller/Cargo.toml | 2 +- test/Makefile | 3 +- test/src/contract.rs | 2 +- test/src/exec.rs | 8 ++-- 22 files changed, 103 insertions(+), 111 deletions(-) delete mode 100644 .github/workflows/develop-rust.yml rename .github/workflows/{develop-clang.yml => develop.yml} (73%) delete mode 100644 Cross.toml delete mode 100644 capsule.toml delete mode 100644 contracts/Cross.toml diff --git a/.github/workflows/develop-rust.yml b/.github/workflows/develop-rust.yml deleted file mode 100644 index 3383503..0000000 --- a/.github/workflows/develop-rust.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Develop Rust - -on: - pull_request: - push: - -jobs: - develop: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Deps - run: | - rustup target add riscv64imac-unknown-none-elf - cargo install cross --git https://github.com/cross-rs/cross --rev=6982b6c - cargo install ckb-capsule --git https://github.com/nervosnetwork/capsule --rev 5c1b2ce - - name: Test - run: | - cargo build --target=riscv64imac-unknown-none-elf --no-default-features --features=ckb-types,allocator - cross check --examples - make test diff --git a/.github/workflows/develop-clang.yml b/.github/workflows/develop.yml similarity index 73% rename from .github/workflows/develop-clang.yml rename to .github/workflows/develop.yml index aeeb876..f891c50 100644 --- a/.github/workflows/develop-clang.yml +++ b/.github/workflows/develop.yml @@ -14,7 +14,7 @@ jobs: - name: Deps run: | rustup target add riscv64imac-unknown-none-elf - wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 16 && rm llvm.sh + wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18 && rm llvm.sh - name: Test run: | - cargo build --verbose --target=riscv64imac-unknown-none-elf --features=build-with-clang + cargo build --target=riscv64imac-unknown-none-elf --features=build-with-clang diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63855cf..a3361a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,7 @@ jobs: - name: Deps run: | rustup target add riscv64imac-unknown-none-elf + wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18 && rm llvm.sh - name: Push run: | cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 845eec2..6a5ba67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,11 +31,11 @@ log = ["dep:log", "dummy-atomic"] cc = "1.0" [dependencies] -ckb-types = { package = "ckb-gen-types", version = "0.116", default-features = false, optional = true } -buddy-alloc = { version = "0.5.0", optional = true } -ckb-x64-simulator = { version = "0.9.1", optional = true } -gcd = "2.3.0" -log = { version = "0.4.21", optional = true, default-features = false } +ckb-types = { package = "ckb-gen-types", version = "0.118", default-features = false, optional = true } +buddy-alloc = { version = "0.5", optional = true } +ckb-x64-simulator = { version = "0.9", optional = true } +gcd = "2.3" +log = { version = "0.4", optional = true, default-features = false } [workspace] exclude = ["test"] diff --git a/Cross.toml b/Cross.toml deleted file mode 100644 index 278f31b..0000000 --- a/Cross.toml +++ /dev/null @@ -1,5 +0,0 @@ -[build] -default-target = "riscv64imac-unknown-none-elf" - -[target.riscv64imac-unknown-none-elf] -image = "nervos/ckb-riscv-gnu-toolchain:focal-20230214" diff --git a/Makefile b/Makefile index 61dfd41..8e67093 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,12 @@ CC := riscv64-unknown-elf-gcc default: integration publish-crate: - cross publish -p ckb-std + cargo publish -p ckb-std publish: publish-crate clean: - cross clean && make -C test clean + cargo clean && make -C test clean test-shared-lib: make -C test/shared-lib all-via-docker @@ -20,6 +20,6 @@ test: make -C test test check: - cross check --target ${TARGET} --examples + cargo check --target ${TARGET} --examples .PHONY: test check diff --git a/build.rs b/build.rs index 28a8bb4..260e7ac 100644 --- a/build.rs +++ b/build.rs @@ -48,7 +48,7 @@ fn setup_compiler_flags(build: &mut cc::Build) { let clang = match std::env::var_os("CLANG") { Some(val) => val, - None => "clang-16".into(), + None => "clang-18".into(), }; if cfg!(feature = "build-with-clang") { diff --git a/capsule.toml b/capsule.toml deleted file mode 100644 index 686c0bc..0000000 --- a/capsule.toml +++ /dev/null @@ -1,35 +0,0 @@ -# capsule version -version = "0.10.0" -# path of deployment config file -deployment = "deployment.toml" - -[rust] -workspace_dir = "contracts" - -[[contracts]] -name = "ckb-std-tests" -template_type = "Rust" - -[[contracts]] -name = "exec-callee" -template_type = "Rust" - -[[contracts]] -name = "exec-caller" -template_type = "Rust" - -[[contracts]] -name = "exec-caller-by-code-hash" -template_type = "Rust" - -[[contracts]] -name = "spawn-caller" -template_type = "Rust" - -[[contracts]] -name = "spawn-caller-by-code-hash" -template_type = "Rust" - -[[contracts]] -name = "spawn-callee" -template_type = "Rust" diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 2cece48..62d48ec 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -38,9 +38,9 @@ checksum = "1f0d2da64a6a895d5a7e0724882825d50f83c13396b1b9f1878e19a024bab395" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -130,12 +130,23 @@ dependencies = [ "cfg-if", "ckb-error", "ckb-fixed-hash", - "ckb-hash", + "ckb-hash 0.116.1", "ckb-occupied-capacity", - "molecule", + "molecule 0.7.5", "numext-fixed-uint", ] +[[package]] +name = "ckb-gen-types" +version = "0.118.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7891f62f4ae4f018bfde91a46178c78491a1dfee740a20b994003a23f10af" +dependencies = [ + "cfg-if", + "ckb-hash 0.118.0", + "molecule 0.8.0", +] + [[package]] name = "ckb-hash" version = "0.116.1" @@ -146,6 +157,15 @@ dependencies = [ "blake2b-rs", ] +[[package]] +name = "ckb-hash" +version = "0.118.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96b7aec74956ae5e79d0fc68e5903dc2b133c2c64644514485bbc9feb5367eb" +dependencies = [ + "blake2b-ref", +] + [[package]] name = "ckb-jsonrpc-types" version = "0.116.1" @@ -226,7 +246,7 @@ version = "0.15.3" dependencies = [ "buddy-alloc", "cc", - "ckb-gen-types", + "ckb-gen-types 0.118.0", "ckb-x64-simulator", "gcd", "log", @@ -263,15 +283,15 @@ dependencies = [ "ckb-constant", "ckb-error", "ckb-fixed-hash", - "ckb-gen-types", - "ckb-hash", + "ckb-gen-types 0.116.1", + "ckb-hash 0.116.1", "ckb-merkle-mountain-range", "ckb-occupied-capacity", "ckb-rational", "derive_more", "golomb-coded-set", "merkle-cbt", - "molecule", + "molecule 0.7.5", "numext-fixed-uint", "once_cell", "paste", @@ -473,6 +493,16 @@ dependencies = [ "faster-hex", ] +[[package]] +name = "molecule" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6efe1c7efcd0bdf4ca590e104bcb13087d9968956ae4ae98e92fb8c1da0f3730" +dependencies = [ + "bytes", + "cfg-if", +] + [[package]] name = "numext-constructor" version = "0.1.6" diff --git a/contracts/Cross.toml b/contracts/Cross.toml deleted file mode 100644 index 278f31b..0000000 --- a/contracts/Cross.toml +++ /dev/null @@ -1,5 +0,0 @@ -[build] -default-target = "riscv64imac-unknown-none-elf" - -[target.riscv64imac-unknown-none-elf] -image = "nervos/ckb-riscv-gnu-toolchain:focal-20230214" diff --git a/contracts/ckb-std-tests/Cargo.toml b/contracts/ckb-std-tests/Cargo.toml index fd571ec..b04a8b1 100644 --- a/contracts/ckb-std-tests/Cargo.toml +++ b/contracts/ckb-std-tests/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] -ckb-std = { path = "../../", features = [ "dlopen-c", "dummy-atomic", "log"] } +ckb-std = { path = "../../", features = ["build-with-clang", "dlopen-c", "dummy-atomic", "log"] } blake2b-ref = { version = "0.3", default-features = false } -bytes = { version = "1.6.0", default-features = false } -log = { version = "0.4.17", default-features = false } +bytes = { version = "1.7", default-features = false } +log = { version = "0.4", default-features = false } diff --git a/contracts/exec-callee/Cargo.toml b/contracts/exec-callee/Cargo.toml index a6fc783..fb28d90 100644 --- a/contracts/exec-callee/Cargo.toml +++ b/contracts/exec-callee/Cargo.toml @@ -9,4 +9,4 @@ edition = "2018" native-simulator = ["ckb-std/native-simulator"] [dependencies] -ckb-std = { path = "../../" } +ckb-std = { path = "../../", features=["build-with-clang"] } diff --git a/contracts/exec-callee/exec-callee-dbg/Cargo.lock b/contracts/exec-callee/exec-callee-dbg/Cargo.lock index c59d481..70c1b7e 100644 --- a/contracts/exec-callee/exec-callee-dbg/Cargo.lock +++ b/contracts/exec-callee/exec-callee-dbg/Cargo.lock @@ -127,12 +127,23 @@ dependencies = [ "cfg-if", "ckb-error", "ckb-fixed-hash", - "ckb-hash", + "ckb-hash 0.116.1", "ckb-occupied-capacity", - "molecule", + "molecule 0.7.5", "numext-fixed-uint", ] +[[package]] +name = "ckb-gen-types" +version = "0.118.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7891f62f4ae4f018bfde91a46178c78491a1dfee740a20b994003a23f10af" +dependencies = [ + "cfg-if", + "ckb-hash 0.118.0", + "molecule 0.8.0", +] + [[package]] name = "ckb-hash" version = "0.116.1" @@ -143,6 +154,15 @@ dependencies = [ "blake2b-rs", ] +[[package]] +name = "ckb-hash" +version = "0.118.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96b7aec74956ae5e79d0fc68e5903dc2b133c2c64644514485bbc9feb5367eb" +dependencies = [ + "blake2b-ref", +] + [[package]] name = "ckb-jsonrpc-types" version = "0.116.1" @@ -223,7 +243,7 @@ version = "0.15.3" dependencies = [ "buddy-alloc", "cc", - "ckb-gen-types", + "ckb-gen-types 0.118.0", "ckb-x64-simulator", "gcd", ] @@ -249,15 +269,15 @@ dependencies = [ "ckb-constant", "ckb-error", "ckb-fixed-hash", - "ckb-gen-types", - "ckb-hash", + "ckb-gen-types 0.116.1", + "ckb-hash 0.116.1", "ckb-merkle-mountain-range", "ckb-occupied-capacity", "ckb-rational", "derive_more", "golomb-coded-set", "merkle-cbt", - "molecule", + "molecule 0.7.5", "numext-fixed-uint", "once_cell", "paste", @@ -447,6 +467,16 @@ dependencies = [ "faster-hex", ] +[[package]] +name = "molecule" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6efe1c7efcd0bdf4ca590e104bcb13087d9968956ae4ae98e92fb8c1da0f3730" +dependencies = [ + "bytes", + "cfg-if", +] + [[package]] name = "numext-constructor" version = "0.1.6" diff --git a/contracts/exec-callee/exec-callee-dbg/Cargo.toml b/contracts/exec-callee/exec-callee-dbg/Cargo.toml index a644a8e..cd99ece 100644 --- a/contracts/exec-callee/exec-callee-dbg/Cargo.toml +++ b/contracts/exec-callee/exec-callee-dbg/Cargo.toml @@ -6,9 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] exec-callee = { path = "../", features = ["native-simulator"] } -ckb-std = { path = "../../../", features = ["native-simulator"] } +ckb-std = { path = "../../../", features = ["build-with-clang", "native-simulator"] } [lib] crate-type = ["cdylib"] -[workspace] \ No newline at end of file +[workspace] diff --git a/contracts/exec-caller-by-code-hash/Cargo.toml b/contracts/exec-caller-by-code-hash/Cargo.toml index 69f6076..37a9d5c 100644 --- a/contracts/exec-caller-by-code-hash/Cargo.toml +++ b/contracts/exec-caller-by-code-hash/Cargo.toml @@ -6,4 +6,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-std = { path = "../../" } +ckb-std = { path = "../../", features=["build-with-clang", "dummy-atomic"] } diff --git a/contracts/exec-caller/Cargo.toml b/contracts/exec-caller/Cargo.toml index 803ede9..9a81348 100644 --- a/contracts/exec-caller/Cargo.toml +++ b/contracts/exec-caller/Cargo.toml @@ -6,4 +6,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-std = { path = "../../" } +ckb-std = { path = "../../", features=["build-with-clang", "dummy-atomic"] } diff --git a/contracts/spawn-callee/Cargo.toml b/contracts/spawn-callee/Cargo.toml index 60d771e..2853bc2 100644 --- a/contracts/spawn-callee/Cargo.toml +++ b/contracts/spawn-callee/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-std = { path = "../../" } +ckb-std = { path = "../../", features=["build-with-clang", "dummy-atomic"] } diff --git a/contracts/spawn-caller-by-code-hash/Cargo.toml b/contracts/spawn-caller-by-code-hash/Cargo.toml index cf5b834..29c30c6 100644 --- a/contracts/spawn-caller-by-code-hash/Cargo.toml +++ b/contracts/spawn-caller-by-code-hash/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-std = { path = "../../" } +ckb-std = { path = "../../", features=["build-with-clang", "dummy-atomic"] } diff --git a/contracts/spawn-caller/Cargo.toml b/contracts/spawn-caller/Cargo.toml index af1c69b..375ab0a 100644 --- a/contracts/spawn-caller/Cargo.toml +++ b/contracts/spawn-caller/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-std = { path = "../../" } +ckb-std = { path = "../../", features=["build-with-clang", "dummy-atomic"] } diff --git a/test/Makefile b/test/Makefile index 848af04..6d98db8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,8 +6,7 @@ test: build build: make -C shared-lib all-via-docker - cd .. && capsule build - cd .. && RUSTFLAGS="-C target-feature=-a" capsule build -n ckb-std-tests + cd ../contracts && RUSTFLAGS="-C target-feature=-a" cargo build --target riscv64imac-unknown-none-elf clean: rm -rf ../build diff --git a/test/src/contract.rs b/test/src/contract.rs index 7d34601..a7bbd2c 100644 --- a/test/src/contract.rs +++ b/test/src/contract.rs @@ -14,7 +14,7 @@ fn it_works() { let mut context = Context::default(); let contract_bin = { let mut buf = Vec::new(); - File::open("../build/debug/ckb-std-tests") + File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/ckb-std-tests") .unwrap() .read_to_end(&mut buf) .expect("read code"); diff --git a/test/src/exec.rs b/test/src/exec.rs index 3e181a9..3844d19 100644 --- a/test/src/exec.rs +++ b/test/src/exec.rs @@ -21,7 +21,7 @@ fn test_exec_by_index() { let mut context = Context::default(); let caller_bin = { let mut buf = Vec::new(); - File::open("../build/debug/exec-caller") + File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/exec-caller") .unwrap() .read_to_end(&mut buf) .expect("read code"); @@ -30,7 +30,7 @@ fn test_exec_by_index() { let caller_out_point = context.deploy_cell(caller_bin); let callee_bin = { let mut buf = Vec::new(); - File::open("../build/debug/exec-callee") + File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/exec-callee") .unwrap() .read_to_end(&mut buf) .expect("read code"); @@ -84,7 +84,7 @@ fn test_exec_by_code_hash() { let mut context = Context::default(); let caller_bin = { let mut buf = Vec::new(); - File::open("../build/debug/exec-caller-by-code-hash") + File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/exec-caller-by-code-hash") .unwrap() .read_to_end(&mut buf) .expect("read code"); @@ -93,7 +93,7 @@ fn test_exec_by_code_hash() { let caller_out_point = context.deploy_cell(caller_bin); let callee_bin = { let mut buf = Vec::new(); - File::open("../build/debug/exec-callee") + File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/exec-callee") .unwrap() .read_to_end(&mut buf) .expect("read code");