Skip to content

Commit

Permalink
use log crate
Browse files Browse the repository at this point in the history
  • Loading branch information
indirection42 committed Jun 18, 2024
1 parent 3a32660 commit 9571f77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions poc/extensions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ parity-scale-codec = { version = "3.6.12", default-features = false }
scale-info = { version = "2.6.0", default-features = false }
poc-executor = { path = "../executor", default-features = false }
impl-trait-for-tuples = "0.2.2"
log = "0.4.21"

[features]
default = ["std"]
Expand Down
11 changes: 5 additions & 6 deletions poc/extensions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ impl<E: ExtensionTuple, P: PermController> XcqExecutorContext for Context<E, P>
.read_memory_into_vec(call_ptr, call_len)
.map_err(|_| ExtensionError::PolkavmError)?;
#[cfg(feature = "std")]
println!(
log::trace!(
"(host call): extension_id: {}, call_bytes: {:?}",
extension_id, call_bytes
extension_id,
call_bytes
);
if !P::is_allowed(extension_id, &call_bytes, invoke_source) {
return Err(ExtensionError::PermissionError);
}
let res_bytes = E::dispatch(extension_id, &call_bytes)?;
#[cfg(feature = "std")]
println!("(host call): res_bytes: {:?}", res_bytes);
log::trace!("(host call): res_bytes: {:?}", res_bytes);
let res_bytes_len = res_bytes.len();
let res_ptr = caller.sbrk(res_bytes_len as u32).ok_or(ExtensionError::PolkavmError)?;
caller
Expand All @@ -82,7 +83,7 @@ impl<E: ExtensionTuple, P: PermController> XcqExecutorContext for Context<E, P>
};
let result = func_with_result();
#[cfg(feature = "std")]
println!("(host call): result: {:?}", result);
log::trace!("(host call): result: {:?}", result);
result.unwrap_or(0)
},
)
Expand Down Expand Up @@ -241,6 +242,4 @@ mod tests {
let res = executor.execute_method(guest, input).unwrap();
assert_eq!(res, vec![100u8, 0u8, 0u8, 0u8]);
}

// TODO: add success test
}

0 comments on commit 9571f77

Please sign in to comment.