From 8699c9dfee9d75c39e590e87c3640b8357f2fbc6 Mon Sep 17 00:00:00 2001 From: Linfeng Qian Date: Mon, 8 Aug 2022 10:26:11 +0800 Subject: [PATCH] chore: update ckb to v0.104.0 --- Cargo.toml | 10 +++++----- src/lib.rs | 15 +++------------ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5524469..ae9002c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "ckb-x64-simulator" description = "A simulator that allows running CKB smart contracts on x64 environment for tooling benefits" -version = "0.6.1" +version = "0.7.0" license = "MIT" authors = ["Nervos Core Dev "] -edition = "2018" +edition = "2021" build = "build.rs" [lib] @@ -13,9 +13,9 @@ crate-type = ["lib", "staticlib", "cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-mock-tx-types = "0.1.0" -ckb-types = "0.100.0" -faster-hex = "0.6" +ckb-mock-tx-types = "0.4.0" +ckb-types = "0.104.0" +faster-hex = "0.6.1" lazy_static = "1.4" serde = "1.0" serde_derive = "1.0" diff --git a/src/lib.rs b/src/lib.rs index fef4a21..1898d12 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,10 +86,7 @@ pub extern "C" fn ckb_exec_cell( argv: *const *const u8, ) -> c_int { assert_vm_version(); - let code_hash = unsafe { - let ptr = code_hash.as_ref().expect("casting pointer"); - std::slice::from_raw_parts(ptr, 32) - }; + let code_hash = unsafe { std::slice::from_raw_parts(code_hash, 32) }; let mut buffer = vec![]; buffer.extend_from_slice(code_hash); buffer.push(hash_type); @@ -357,10 +354,7 @@ pub extern "C" fn ckb_dlopen2( handle: *mut *mut c_void, consumed_size: *mut u64, ) -> c_int { - let dep_cell_hash = unsafe { - let ptr = dep_cell_hash.as_ref().expect("casting pointer"); - std::slice::from_raw_parts(ptr, 32) - }; + let dep_cell_hash = unsafe { std::slice::from_raw_parts(dep_cell_hash, 32) }; let mut buffer = vec![]; buffer.extend_from_slice(dep_cell_hash); buffer.push(hash_type); @@ -642,10 +636,7 @@ fn fetch_current_script() -> Script { fn store_data(ptr: *mut c_void, len: *mut u64, offset: u64, data: &[u8]) { let size_ptr = unsafe { len.as_mut().expect("casting pointer") }; let size = *size_ptr; - let buffer = unsafe { - let ptr = (ptr as *mut u8).as_mut().expect("casting pointer"); - std::slice::from_raw_parts_mut(ptr, size as usize) - }; + let buffer = unsafe { std::slice::from_raw_parts_mut(ptr as *mut u8, size as usize) }; let data_len = data.len() as u64; let offset = std::cmp::min(data_len, offset); let full_size = data_len - offset;