Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit b1d78bf

Browse files
authored
[fix] move from_json_file back to prover crate (#1350)
* move from_json_file back to prover crate * fix test
1 parent 5b58085 commit b1d78bf

File tree

7 files changed

+29
-35
lines changed

7 files changed

+29
-35
lines changed

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eth-types/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ halo2curves.workspace = true
1212
log.workspace = true
1313
regex.workspace = true
1414
serde.workspace = true
15-
serde_json = { workspace = true, features = ["unbounded_depth"] }
16-
serde_stacker.workspace = true
15+
serde_json.workspace = true
1716
serde_with = "1.12"
1817
uint = "0.9.1"
1918
itertools.workspace = true

eth-types/src/l2_types.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,3 @@ pub struct AccountTrace {
536536
#[serde(rename = "codeSize")]
537537
pub code_size: u64,
538538
}
539-
540-
#[ignore]
541-
#[test]
542-
fn test_block_trace_convert() {
543-
let trace_v1: BlockTrace =
544-
crate::utils::from_json_file("src/testdata/trace_v1_5224657.json").expect("should load");
545-
let trace_v2: BlockTraceV2 = trace_v1.into();
546-
let mut fd = std::fs::File::create("src/testdata/trace_v2_5224657.json").unwrap();
547-
serde_json::to_writer_pretty(&mut fd, &trace_v2).unwrap();
548-
// then we can use this command to compare the traces:
549-
// vimdiff <(jq -S "del(.executionResults)|del(.txStorageTraces)" src/testdata/trace_v1_5224657.json) <(jq -S . src/testdata/trace_v2_5224657.json)
550-
}

eth-types/src/utils.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
use crate::Address;
44
use revm_precompile::Precompiles;
55

6-
mod io;
7-
pub use io::*;
86
mod codehash;
97
pub use codehash::*;
108

eth-types/src/utils/io.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

prover/src/io.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ use std::{
1212
path::{Path, PathBuf},
1313
};
1414

15+
pub fn from_json_file<'de, P: serde::Deserialize<'de>>(file_path: &str) -> anyhow::Result<P> {
16+
if !Path::new(&file_path).exists() {
17+
anyhow::bail!("File {file_path} doesn't exist");
18+
}
19+
20+
let fd = File::open(file_path)?;
21+
let mut deserializer = serde_json::Deserializer::from_reader(fd);
22+
deserializer.disable_recursion_limit();
23+
let deserializer = serde_stacker::Deserializer::new(&mut deserializer);
24+
25+
Ok(serde::Deserialize::deserialize(deserializer)?)
26+
}
27+
1528
pub fn serialize_fr(f: &Fr) -> Vec<u8> {
1629
f.to_bytes().to_vec()
1730
}
@@ -127,3 +140,15 @@ pub fn load_instances(buf: &[u8]) -> Vec<Vec<Vec<Fr>>> {
127140
})
128141
.collect()
129142
}
143+
144+
#[ignore]
145+
#[test]
146+
fn test_block_trace_convert() {
147+
let trace_v1: eth_types::l2_types::BlockTrace =
148+
from_json_file("src/testdata/trace_v1_5224657.json").expect("should load");
149+
let trace_v2: eth_types::l2_types::BlockTraceV2 = trace_v1.into();
150+
let mut fd = std::fs::File::create("src/testdata/trace_v2_5224657.json").unwrap();
151+
serde_json::to_writer_pretty(&mut fd, &trace_v2).unwrap();
152+
// then we can use this command to compare the traces:
153+
// vimdiff <(jq -S "del(.executionResults)|del(.txStorageTraces)" src/testdata/trace_v1_5224657.json) <(jq -S . src/testdata/trace_v2_5224657.json)
154+
}

prover/src/proof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn dump_vk(dir: &str, filename: &str, raw_vk: &[u8]) {
113113

114114
pub fn from_json_file<'de, P: serde::Deserialize<'de>>(dir: &str, filename: &str) -> Result<P> {
115115
let file_path = dump_proof_path(dir, filename);
116-
Ok(eth_types::utils::from_json_file(&file_path)?)
116+
crate::io::from_json_file(&file_path)
117117
}
118118

119119
fn dump_proof_path(dir: &str, filename: &str) -> String {

0 commit comments

Comments
 (0)