Skip to content

Commit 3972fa7

Browse files
committed
ref: move ParseError to lib.rs
1 parent 23594a4 commit 3972fa7

6 files changed

Lines changed: 40 additions & 37 deletions

File tree

‎state-reconstruct-fetcher/src/blob_http_client.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::Deserialize;
22
use tokio::time::{sleep, Duration};
33

4-
use crate::types::ParseError;
4+
use crate::ParseError;
55

66
/// `MAX_RETRIES` is the maximum number of retries on failed blob retrieval.
77
const MAX_RETRIES: u8 = 5;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,40 @@
11
#![feature(array_chunks)]
22
#![feature(iter_next_chunk)]
3+
use thiserror::Error;
4+
35
pub mod blob_http_client;
46
pub mod constants;
57
pub mod database;
68
pub mod l1_fetcher;
79
pub mod metrics;
810
pub mod parser;
911
pub mod types;
12+
13+
#[allow(clippy::enum_variant_names)]
14+
#[derive(Error, Debug)]
15+
pub enum ParseError {
16+
#[error("invalid Calldata: {0}")]
17+
InvalidCalldata(String),
18+
19+
#[error("invalid StoredBlockInfo: {0}")]
20+
InvalidStoredBlockInfo(String),
21+
22+
#[error("invalid CommitBlockInfo: {0}")]
23+
InvalidCommitBlockInfo(String),
24+
25+
#[allow(dead_code)]
26+
#[error("invalid compressed bytecode: {0}")]
27+
InvalidCompressedByteCode(String),
28+
29+
#[error("invalid compressed value: {0}")]
30+
InvalidCompressedValue(String),
31+
32+
#[error("invalid pubdata source: {0}")]
33+
InvalidPubdataSource(String),
34+
35+
#[error("blob storage error: {0}")]
36+
BlobStorageError(String),
37+
38+
#[error("blob format error: {0}")]
39+
BlobFormatError(String, String),
40+
}

‎state-reconstruct-fetcher/src/parser/calldata_tokens.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use ethers::{
33
types::U256,
44
};
55

6-
use crate::types::ParseError;
6+
use crate::ParseError;
77

88
pub struct CalldataToken {
99
pub new_blocks_data: NewBlocksDataToken,

‎state-reconstruct-fetcher/src/parser/mod.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use crate::{
1919
constants::ethereum::{BLOB_BLOCK, BOOJUM_BLOCK},
2020
l1_fetcher::{Contracts, LONG_POLLING_INTERVAL_S},
2121
metrics::L1Metrics,
22-
types::{v1::V1, v2::V2, CommitBlock, ParseError},
22+
types::{v1::V1, v2::V2, CommitBlock},
23+
ParseError,
2324
};
2425

2526
// TODO: Should use the real types format instead.

‎state-reconstruct-fetcher/src/types/common.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! A collection of functions that get reused throughout format versions.
22
use ethers::{abi, types::U256};
33

4-
use super::{L2ToL1Pubdata, PackingType, ParseError};
5-
use crate::constants::zksync::{
6-
L2_TO_L1_LOG_SERIALIZE_SIZE, LENGTH_BITS_OFFSET, OPERATION_BITMASK,
4+
use super::{L2ToL1Pubdata, PackingType};
5+
use crate::{
6+
constants::zksync::{L2_TO_L1_LOG_SERIALIZE_SIZE, LENGTH_BITS_OFFSET, OPERATION_BITMASK},
7+
ParseError,
78
};
89

910
pub struct ExtractedToken {

‎state-reconstruct-fetcher/src/types/mod.rs‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,16 @@ use ethers::{abi, types::U256};
22
use indexmap::IndexMap;
33
use serde::{Deserialize, Serialize};
44
use serde_json_any_key::any_key_map;
5-
use thiserror::Error;
65

76
use self::{v1::V1, v2::V2, v3::V3};
8-
use crate::blob_http_client::BlobHttpClient;
7+
use crate::{blob_http_client::BlobHttpClient, ParseError};
98

109
// NOTE: We should probably make these more human-readable.
1110
pub mod common;
1211
pub mod v1;
1312
pub mod v2;
1413
pub mod v3;
1514

16-
#[allow(clippy::enum_variant_names)]
17-
#[derive(Error, Debug)]
18-
pub enum ParseError {
19-
#[error("invalid Calldata: {0}")]
20-
InvalidCalldata(String),
21-
22-
#[error("invalid StoredBlockInfo: {0}")]
23-
InvalidStoredBlockInfo(String),
24-
25-
#[error("invalid CommitBlockInfo: {0}")]
26-
InvalidCommitBlockInfo(String),
27-
28-
#[allow(dead_code)]
29-
#[error("invalid compressed bytecode: {0}")]
30-
InvalidCompressedByteCode(String),
31-
32-
#[error("invalid compressed value: {0}")]
33-
InvalidCompressedValue(String),
34-
35-
#[error("invalid pubdata source: {0}")]
36-
InvalidPubdataSource(String),
37-
38-
#[error("blob storage error: {0}")]
39-
BlobStorageError(String),
40-
41-
#[error("blob format error: {0}")]
42-
BlobFormatError(String, String),
43-
}
44-
4515
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
4616
pub enum PackingType {
4717
Add(U256),

0 commit comments

Comments
 (0)