From df3713e840d71123d6b2fc99d2119533ebcc83bd Mon Sep 17 00:00:00 2001 From: georgehao Date: Wed, 24 Jul 2024 11:59:30 +0800 Subject: [PATCH] feat(libzkp):unbounded depth serde json (#920) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add transactions len metrics of block processer * fix * format * chore: auto version bump [bot] * remove unusd code --------- Co-authored-by: georgehao --- params/version.go | 2 +- .../circuitcapacitychecker/libzkp/Cargo.toml | 2 +- .../circuitcapacitychecker/libzkp/src/lib.rs | 23 +++++++++++-------- rollup/pipeline/pipeline.go | 5 ---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/params/version.go b/params/version.go index be2da23ea07c..1bce01730853 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 5 // Minor version component of the current release - VersionPatch = 16 // Patch version component of the current release + VersionPatch = 17 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) diff --git a/rollup/circuitcapacitychecker/libzkp/Cargo.toml b/rollup/circuitcapacitychecker/libzkp/Cargo.toml index f894b37609ea..dbc8a30e8581 100644 --- a/rollup/circuitcapacitychecker/libzkp/Cargo.toml +++ b/rollup/circuitcapacitychecker/libzkp/Cargo.toml @@ -33,7 +33,7 @@ log = "0.4" once_cell = "1.19" serde = "1.0" serde_derive = "1.0" -serde_json = "1.0.66" +serde_json = { version = "1.0.66", features = ["unbounded_depth"] } [profile.test] opt-level = 3 diff --git a/rollup/circuitcapacitychecker/libzkp/src/lib.rs b/rollup/circuitcapacitychecker/libzkp/src/lib.rs index b3f7fddc8807..472128a63324 100644 --- a/rollup/circuitcapacitychecker/libzkp/src/lib.rs +++ b/rollup/circuitcapacitychecker/libzkp/src/lib.rs @@ -12,6 +12,8 @@ pub mod checker { use std::panic; use std::ptr::null; use std::ffi::CStr; + use serde::Deserialize as Deserializea; + use serde_json::Deserializer; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CommonResult { @@ -48,7 +50,10 @@ pub mod checker { #[no_mangle] pub unsafe extern "C" fn parse_json_to_rust_trace(trace_json_ptr: *const c_char) -> *mut BlockTrace { let trace_json_cstr = unsafe { CStr::from_ptr(trace_json_ptr) }; - let trace = serde_json::from_slice::(trace_json_cstr.to_bytes()); + let trace_json_bytes = trace_json_cstr.to_bytes(); + let mut deserializer = Deserializer::from_slice(trace_json_bytes); + deserializer.disable_recursion_limit(); + let trace = BlockTrace::deserialize(&mut deserializer); match trace { Err(e) => { log::warn!( @@ -233,10 +238,10 @@ pub mod checker { ))? .get_tx_num() as u64) }) - .map_or_else( - |e| bail!("circuit capacity checker (id: {id}) error in get_tx_num: {e:?}"), - |result| result, - ) + .map_or_else( + |e| bail!("circuit capacity checker (id: {id}) error in get_tx_num: {e:?}"), + |result| result, + ) } /// # Safety @@ -267,10 +272,10 @@ pub mod checker { .set_light_mode(light_mode); Ok(()) }) - .map_or_else( - |e| bail!("circuit capacity checker (id: {id}) error in set_light_mode: {e:?}"), - |result| result, - ) + .map_or_else( + |e| bail!("circuit capacity checker (id: {id}) error in set_light_mode: {e:?}"), + |result| result, + ) } } diff --git a/rollup/pipeline/pipeline.go b/rollup/pipeline/pipeline.go index b2d5beb43d89..e4467862def8 100644 --- a/rollup/pipeline/pipeline.go +++ b/rollup/pipeline/pipeline.go @@ -143,11 +143,6 @@ func (p *Pipeline) TryPushTxns(txs types.OrderedTransactionSet, onFailingTxn fun break } - if p.txs.Len() == 0 && tx.Hash() == common.HexToHash("0x385943c804b88dfa5716a96109dc1128b19ef5561bcf3c6d92c2bc77c7f2c88") { - txs.Shift() - continue - } - result, err := p.TryPushTxn(tx) if result != nil { return result