Skip to content

Add tikv-jemallocator and crates-io patches for ckb-vm asm mode on rv64gc - #13

Draft
gpBlockchain with Copilot wants to merge 6 commits into
mainfrom
copilot/copilotupdate-ckb-vm-dependencies
Draft

Add tikv-jemallocator and crates-io patches for ckb-vm asm mode on rv64gc#13
gpBlockchain with Copilot wants to merge 6 commits into
mainfrom
copilot/copilotupdate-ckb-vm-dependencies

Conversation

Copilot AI commented Feb 25, 2026

Copy link
Copy Markdown

Running tests under qemu-riscv64-static fails with memory allocation of 4 bytes failed due to the system allocator's interaction with QEMU user-mode emulation. Additionally, the [patch.crates-io] entries in ckb-testtool's Cargo.toml don't propagate (Cargo only applies patches from the workspace root), so ckb-vm was resolving to the crates.io version without rv64gc asm support.

Changes

  • Cargo.toml: Add tikv-jemallocator = "0.6" as dev-dependency; add [patch.crates-io] mirroring ckb-testtool's patches for ckb-vm/ckb-vm-definitions (mohanson-fork asm_rv64im) and all ckb-* crates (gpBlockchain fork)
  • src/main.rs: Use jemalloc as global allocator in test mode:
    #[cfg(test)]
    #[global_allocator]
    static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
  • src/main.rs: Fix ScriptHashType/Script imports (moved from ckb_std to ckb_testtool) and disambiguate Pack::<Uint64>::pack() calls required by new ckb-gen-types 1.x
  • rust-toolchain.toml: Bump to 1.92.0 (MSRV of patched deps)
  • CI workflows: Update toolchain to 1.92.0; add .github/workflows/riscv64-test.yml with qemu-riscv64 cross-test job using --release and setarch linux64 --addr-no-randomize

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Update ckb-testtool dependency in Cargo.toml and demo/tests/Cargo.toml
  to use https://github.com/gpBlockchain/ckb-testtool.git branch
  copilot/update-ckb-vm-dependencies
- Update rust-toolchain from 1.84.0 to 1.85.0 (required for edition 2024)
- Fix compilation errors from new ckb-testtool API (ScriptHashType import,
  Pack type disambiguation for Uint64)
- Add .github/workflows/riscv64-test.yml CI workflow using qemu-riscv64
- Add .gitignore for target directory

Co-authored-by: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com>
Copilot AI changed the title [WIP] Update ckb-testtool repository to new GitHub URL Update ckb-testtool to gpBlockchain fork and add riscv64gc qemu CI Feb 25, 2026
Copilot AI requested a review from gpBlockchain February 25, 2026 02:04
Debug-mode test binaries are too large for QEMU user-mode emulation's
default address space, causing 'memory allocation of 24 bytes failed'.
Building with --release produces smaller, optimized binaries that fit
within QEMU's limits, matching the approach used in ckb-vm PR #502.

Co-authored-by: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com>
Cargo patches only apply at the top-level manifest. The patches in
ckb-testtool's Cargo.toml were not propagating, so ckb-vm 0.24.14 from
crates.io (no rv64gc asm support) was being resolved instead of the
mohanson-fork/ckb-vm asm_rv64im branch.

Changes:
- Add [patch.crates-io] section to root Cargo.toml, mirroring the
  patches from ckb-testtool (ckb-vm, ckb-vm-definitions, and all
  ckb-* crates from gpBlockchain/ckb fork)
- Bump Rust toolchain to 1.92.0 (required by patched dependencies)
- Update CI workflows to use Rust 1.92.0

Co-authored-by: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com>
Copilot AI changed the title Update ckb-testtool to gpBlockchain fork and add riscv64gc qemu CI Enable ckb-vm ASM mode on rv64gc via crates-io patches and toolchain bump Feb 25, 2026
The test binary under qemu-riscv64-static fails with "memory allocation
of 4 bytes failed" because host ASLR fragments the virtual address space,
causing QEMU's guest mmap/brk syscall translations to fail.

Wrap the QEMU runner with `setarch linux64 --addr-no-randomize` to
disable Address Space Layout Randomization. This gives QEMU a more
contiguous, deterministic address space layout so the guest binary's
memory allocations can succeed.

Co-authored-by: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com>
Copilot AI changed the title Enable ckb-vm ASM mode on rv64gc via crates-io patches and toolchain bump Update ckb-testtool to asm_rv64im fork, add RISC-V 64 QEMU CI Feb 25, 2026
Use jemalloc as the global allocator in test mode to work around memory
allocation failures when running under QEMU riscv64 user-mode emulation.

Co-authored-by: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com>
Copilot AI changed the title Update ckb-testtool to asm_rv64im fork, add RISC-V 64 QEMU CI Add tikv-jemallocator and crates-io patches for ckb-vm asm mode on rv64gc Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants