mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 06:53:46 +00:00
fix: decode traces as UTF-8 string (#432)
decode traces as UTF-8 string
This commit is contained in:
parent
ef67ff8bbb
commit
42e17229d5
2 changed files with 9 additions and 1 deletions
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 4 // Major version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionMinor = 3 // Minor 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
|
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ pub mod checker {
|
||||||
pub unsafe extern "C" fn apply_tx(id: u64, tx_traces: *const c_char) -> *const c_char {
|
pub unsafe extern "C" fn apply_tx(id: u64, tx_traces: *const c_char) -> *const c_char {
|
||||||
let result = panic::catch_unwind(|| {
|
let result = panic::catch_unwind(|| {
|
||||||
let tx_traces_vec = c_char_to_vec(tx_traces);
|
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)
|
let traces = serde_json::from_slice::<BlockTrace>(&tx_traces_vec)
|
||||||
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize tx_traces"));
|
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize tx_traces"));
|
||||||
if traces.transactions.len() != 1 {
|
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 {
|
pub unsafe extern "C" fn apply_block(id: u64, block_trace: *const c_char) -> *const c_char {
|
||||||
let result = panic::catch_unwind(|| {
|
let result = panic::catch_unwind(|| {
|
||||||
let block_trace = c_char_to_vec(block_trace);
|
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)
|
let traces = serde_json::from_slice::<BlockTrace>(&block_trace)
|
||||||
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize block_trace"));
|
.unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize block_trace"));
|
||||||
CHECKERS
|
CHECKERS
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue