Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omar/offchain : Fixed offchain_timestamp and offchain_sleep_until #13

Merged
merged 11 commits into from
Nov 19, 2021
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ deps/deps.jl
build/
target/
.idea/
*.devcontainer

## Core latex/pdflatex auxiliary files:
*.aux
Expand Down
1 change: 1 addition & 0 deletions test/runtimes/hostapi/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target/
.vscode
Binary file modified test/runtimes/hostapi/hostapi_runtime.compact.wasm
Binary file not shown.
17 changes: 9 additions & 8 deletions test/runtimes/hostapi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ extern "C" {
fn ext_offchain_timestamp_version_1() -> u64;
fn ext_offchain_sleep_until_version_1(key: u64);

// Default child stoage API
// Default child storage API
fn ext_default_child_storage_set_version_1(child: u64, key: u64, value: u64);
fn ext_default_child_storage_get_version_1(child: u64, key: u64) -> u64;
fn ext_default_child_storage_read_version_1(child: u64, key: u64, out: u64, offset: u32) -> u64;
fn ext_default_child_storage_read_version_1(child: u64, key: u64, out: u64, offset: u32)
-> u64;
fn ext_default_child_storage_clear_version_1(child: u64, key: u64);
fn ext_default_child_storage_storage_kill_version_1(child: u64);
fn ext_default_child_storage_storage_kill_version_2(child: u64, limit: u64) -> i32;
Expand Down Expand Up @@ -71,7 +72,7 @@ extern "C" {
// Trie API
fn ext_trie_blake2_256_root_version_1(data: u64) -> u32;
fn ext_trie_blake2_256_ordered_root_version_1(data: u64) -> u32;
fn ext_trie_blake2_256_verify_proof_version_1(a: u32, b: u64, c: u64, d:u64) -> u32;
fn ext_trie_blake2_256_verify_proof_version_1(a: u32, b: u64, c: u64, d: u64) -> u32;

// Offchain
fn ext_offchain_local_storage_clear_version_1(kind: u32, key: u64);
Expand Down Expand Up @@ -198,16 +199,16 @@ sp_core::wasm_export_functions! {
}

// OffChain API
fn rtm_ext_offchain_timestamp_version_1() -> Vec<u8> {
fn rtm_ext_offchain_timestamp_version_1() -> u64 {
unsafe {
let value = ext_offchain_timestamp_version_1();
from_mem(value)
value
}
}

fn rtm_ext_offchain_sleep_until_version_1(key: Vec<u8>) {
fn rtm_ext_offchain_sleep_until_version_1(key: u64) {
unsafe {
let _ = ext_offchain_sleep_until_version_1(key.as_re_ptr());
ext_offchain_sleep_until_version_1(key);
}
}

Expand Down Expand Up @@ -569,7 +570,7 @@ sp_core::wasm_export_functions! {
) as u32
}
}

fn rtm_ext_offchain_local_storage_clear_version_1(kind: [u8; 4], key: Vec<u8>) {
unsafe {
let _ = ext_offchain_local_storage_clear_version_1(
Expand Down