-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from TheWaWaR/add-ckb2021-syscalls
feat: add ckb2021 syscalls: vm_version, current_cycles, exec
- Loading branch information
Showing
19 changed files
with
435 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![no_std] | ||
#![no_main] | ||
#![feature(asm)] | ||
#![feature(lang_items)] | ||
#![feature(alloc_error_handler)] | ||
#![feature(panic_info_message)] | ||
|
||
use ckb_std::{ | ||
cstr_core::{cstr, CStr}, | ||
default_alloc, entry, | ||
}; | ||
|
||
use core::slice::from_raw_parts; | ||
|
||
#[no_mangle] | ||
pub fn main(argc: u64, argv: *const *const u8) -> i8 { | ||
let args = unsafe { from_raw_parts(argv, argc as usize) }; | ||
let arg1 = unsafe { CStr::from_ptr(args[0]) }; | ||
let arg2 = unsafe { CStr::from_ptr(args[1]) }; | ||
assert_eq!(argc, 2); | ||
assert_eq!(arg1, cstr!("Hello World")); | ||
assert_eq!(arg2, cstr!("你好")); | ||
0 | ||
} | ||
|
||
entry!(main); | ||
default_alloc!(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![no_std] | ||
#![no_main] | ||
#![feature(asm)] | ||
#![feature(lang_items)] | ||
#![feature(alloc_error_handler)] | ||
#![feature(panic_info_message)] | ||
|
||
use ckb_std::{ckb_constants::*, cstr_core::cstr, default_alloc, entry, syscalls}; | ||
|
||
#[no_mangle] | ||
pub fn main() -> i8 { | ||
let arg1 = cstr!("Hello World"); | ||
let arg2 = cstr!("你好"); | ||
let ret = syscalls::exec(0, Source::CellDep, 0, 0, &[arg1, arg2][..]); | ||
panic!("exec failed: {}", ret); | ||
} | ||
|
||
entry!(main); | ||
default_alloc!(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#![no_std] | ||
#![no_main] | ||
#![feature(asm)] | ||
#![feature(lang_items)] | ||
#![feature(alloc_error_handler)] | ||
#![feature(panic_info_message)] | ||
|
||
use ckb_std::{ckb_types::core::ScriptHashType, cstr_core::cstr, default_alloc, entry, high_level}; | ||
|
||
#[no_mangle] | ||
pub fn main() -> i8 { | ||
let arg1 = cstr!("Hello World"); | ||
let arg2 = cstr!("你好"); | ||
// $ ckb-cli util blake2b --binary-path target/riscv64imac-unknown-none-elf/debug/exec-callee | ||
// 0x6c704a9d5084cd52ff3a0be1f785b5f0fb9663092f8083bef7fc3f547758cb5a | ||
let code_hash = [ | ||
0x6c, 0x70, 0x4a, 0x9d, 0x50, 0x84, 0xcd, 0x52, 0xff, 0x3a, 0x0b, 0xe1, 0xf7, 0x85, 0xb5, | ||
0xf0, 0xfb, 0x96, 0x63, 0x09, 0x2f, 0x80, 0x83, 0xbe, 0xf7, 0xfc, 0x3f, 0x54, 0x77, 0x58, | ||
0xcb, 0x5a, | ||
]; | ||
let ret = high_level::exec_cell( | ||
&code_hash[..], | ||
ScriptHashType::Data1, | ||
0, | ||
0, | ||
&[arg1, arg2][..], | ||
) | ||
.unwrap(); | ||
panic!("exec failed: {}", ret); | ||
} | ||
|
||
entry!(main); | ||
default_alloc!(); |
Oops, something went wrong.