Skip to content

Commit

Permalink
feat(libzkp):unbounded depth serde json (#920)
Browse files Browse the repository at this point in the history
* feat: add transactions len metrics of block processer

* fix

* format

* chore: auto version bump [bot]

* remove unusd code

---------

Co-authored-by: georgehao <[email protected]>
  • Loading branch information
georgehao and georgehao authored Jul 24, 2024
1 parent f2af32d commit df3713e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion rollup/circuitcapacitychecker/libzkp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 14 additions & 9 deletions rollup/circuitcapacitychecker/libzkp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<BlockTrace>(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!(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
}
}

Expand Down
5 changes: 0 additions & 5 deletions rollup/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df3713e

Please sign in to comment.