fix: decode traces as UTF-8 string (#432)

decode traces as UTF-8 string
This commit is contained in:
Péter Garamvölgyi 2023-08-03 13:21:30 +02:00 committed by GitHub
parent ef67ff8bbb
commit 42e17229d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -24,7 +24,7 @@ import (
const (
VersionMajor = 4 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 12 // Patch version component of the current release
VersionPatch = 13 // Patch version component of the current release
VersionMeta = "sepolia" // Version metadata to append to the version string
)

View file

@ -60,6 +60,10 @@ pub mod checker {
pub unsafe extern "C" fn apply_tx(id: u64, tx_traces: *const c_char) -> *const c_char {
let result = panic::catch_unwind(|| {
let tx_traces_vec = c_char_to_vec(tx_traces);
let traces_str = String::from_utf8(tx_traces_vec).expect("cannot decode trace as UTF-8 in apply_tx");
log::debug!("ccc apply_tx raw input, id: {:?}, tx_traces: {:?}", id, traces_str);
let traces = serde_json::from_slice::<BlockTrace>(&tx_traces_vec)
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize tx_traces"));
if traces.transactions.len() != 1 {
@ -114,6 +118,10 @@ pub mod checker {
pub unsafe extern "C" fn apply_block(id: u64, block_trace: *const c_char) -> *const c_char {
let result = panic::catch_unwind(|| {
let block_trace = c_char_to_vec(block_trace);
let traces_str = String::from_utf8(block_trace).expect("cannot decode trace as UTF-8 in apply_block");
log::debug!("ccc apply_block raw input, id: {:?}, block_trace: {:?}", id, traces_str);
let traces = serde_json::from_slice::<BlockTrace>(&block_trace)
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize block_trace"));
CHECKERS