zksync_error/error/
definitions.rs

1//
2// AUTOGENERATED BASED ON A SET OF JSON FILES, DO NOT EDIT MANUALLY
3//
4#![allow(unused)]
5#![allow(clippy::useless_format)]
6#![allow(non_camel_case_types)]
7#[cfg(feature = "runtime_documentation")]
8use crate::documentation::Documented;
9use crate::error::domains::*;
10use crate::error::CustomErrorMessage;
11use crate::error::ICustomError as _;
12use crate::error::IError as _;
13use crate::error::NamedError;
14#[cfg(not(feature = "std"))]
15use alloc::{borrow::ToOwned, boxed::Box, format, string::String, vec::Vec};
16use core::fmt;
17use strum_macros::AsRefStr;
18use strum_macros::EnumDiscriminants;
19use strum_macros::FromRepr;
20#[doc = ""]
21#[doc = ""]
22#[doc = "Domain: AnvilZKsync"]
23#[repr(u32)]
24#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
25#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
26#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
27#[strum_discriminants(name(AnvilEnvironmentCode))]
28#[strum_discriminants(vis(pub))]
29#[strum_discriminants(derive(AsRefStr, FromRepr))]
30#[non_exhaustive]
31pub enum AnvilEnvironment {
32    #[doc = "# Summary "]
33    #[doc = "Invalid command line arguments provided."]
34    #[doc = ""]
35    #[doc = "# Description"]
36    #[doc = "There are missing or invalid command line arguments, or an invalid combination of arguments is provided."]
37    InvalidArguments {
38        details: String,
39        arguments: String,
40    } = 1u32,
41    #[doc = "# Summary "]
42    #[doc = "Failed to start the server and bind it to the requested host and port."]
43    #[doc = ""]
44    #[doc = "# Description"]
45    #[doc = "Anvil-zksync starts the server and listens to requests on a specified host and port, 0.0.0.0:8011 by default. They are configurable using `--host` and `--port` command line arguments."]
46    #[doc = ""]
47    #[doc = "The host and port used by anvil-zksync are also displayed when you start anvil-zksync:"]
48    #[doc = ""]
49    #[doc = "```text"]
50    #[doc = "========================================"]
51    #[doc = "Listening on 0.0.0.0:8011"]
52    #[doc = "========================================"]
53    #[doc = "```"]
54    #[doc = ""]
55    #[doc = "This error indicates that listening on the specified host and port failed."]
56    ServerStartupFailed {
57        host_requested: String,
58        port_requested: u32,
59        details: String,
60    } = 2u32,
61    #[doc = "# Summary "]
62    #[doc = "Unable to access log file."]
63    #[doc = ""]
64    #[doc = "# Description"]
65    #[doc = "Anvil-zksync was unable to open log file for writing."]
66    #[doc = "By default, the log file is searched for at `./anvil-zksync.log`."]
67    #[doc = "You may provide this path explicitly through the CLI argument `--log-file-path`."]
68    LogFileAccessFailed {
69        log_file_path: String,
70        wrapped_error: String,
71    } = 10u32,
72    #[doc = "# Summary "]
73    #[doc = "Unable to append to log file. Details: {wrapped_error}"]
74    #[doc = ""]
75    #[doc = "# Description"]
76    #[doc = "Anvil-zksync was unable to write logs to the selected file."]
77    #[doc = "By default, the log file is searched for at `./anvil-zksync.log`."]
78    #[doc = "You may provide this path explicitly through the CLI argument `--log-file-path`."]
79    LogFileWriteFailed {
80        log_filename: String,
81        wrapped_error: String,
82    } = 11u32,
83    GenericError {
84        message: String,
85    } = 0u32,
86}
87impl core::error::Error for AnvilEnvironment {}
88impl NamedError for AnvilEnvironment {
89    fn get_error_name(&self) -> String {
90        self.as_ref().to_owned()
91    }
92}
93impl NamedError for AnvilEnvironmentCode {
94    fn get_error_name(&self) -> String {
95        self.as_ref().to_owned()
96    }
97}
98impl From<AnvilEnvironment> for crate::ZksyncError {
99    fn from(val: AnvilEnvironment) -> Self {
100        val.to_unified()
101    }
102}
103impl fmt::Display for AnvilEnvironment {
104    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
105        f.write_str(&self.get_message())
106    }
107}
108#[cfg(feature = "runtime_documentation")]
109impl Documented for AnvilEnvironment {
110    type Documentation = &'static zksync_error_description::ErrorDocumentation;
111    fn get_documentation(
112        &self,
113    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
114        self.to_unified().get_identifier().get_documentation()
115    }
116}
117#[cfg(feature = "use_anyhow")]
118impl From<anyhow::Error> for AnvilEnvironment {
119    fn from(value: anyhow::Error) -> Self {
120        let message = format!("{value:#?}");
121        AnvilEnvironment::GenericError { message }
122    }
123}
124#[cfg(feature = "packed_errors")]
125impl From<AnvilEnvironment> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
126    fn from(value: AnvilEnvironment) -> Self {
127        crate::packed::pack(value)
128    }
129}
130#[cfg(feature = "serialized_errors")]
131impl From<AnvilEnvironment> for crate::serialized::SerializedError {
132    fn from(value: AnvilEnvironment) -> Self {
133        let packed = crate::packed::pack(value);
134        crate::serialized::serialize(packed).expect("Internal serialization error.")
135    }
136}
137impl CustomErrorMessage for AnvilEnvironment {
138    fn get_message(&self) -> String {
139        match self {
140            AnvilEnvironment::InvalidArguments { details, arguments } => {
141                format!("[anvil_zksync-env-1] Invalid arguments: {details}.")
142            }
143            AnvilEnvironment::ServerStartupFailed {
144                host_requested,
145                port_requested,
146                details,
147            } => {
148                format ! ("[anvil_zksync-env-2] Failed to start server at {host_requested}:{port_requested}: {details}.")
149            }
150            AnvilEnvironment::LogFileAccessFailed {
151                log_file_path,
152                wrapped_error,
153            } => {
154                format ! ("[anvil_zksync-env-10] Unable to access log file: {log_file_path}. Details: {wrapped_error}")
155            }
156            AnvilEnvironment::LogFileWriteFailed {
157                log_filename,
158                wrapped_error,
159            } => {
160                format ! ("[anvil_zksync-env-11] Unable to append more lines to the log file `{log_filename}`: {wrapped_error}")
161            }
162            AnvilEnvironment::GenericError { message } => {
163                format!("[anvil_zksync-env-0] Generic error: {message}")
164            }
165        }
166    }
167}
168#[doc = ""]
169#[doc = ""]
170#[doc = "Domain: AnvilZKsync"]
171#[repr(u32)]
172#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
173#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
174#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
175#[strum_discriminants(name(AnvilGenericCode))]
176#[strum_discriminants(vis(pub))]
177#[strum_discriminants(derive(AsRefStr, FromRepr))]
178#[non_exhaustive]
179pub enum AnvilGeneric {
180    GenericError { message: String } = 0u32,
181}
182impl core::error::Error for AnvilGeneric {}
183impl NamedError for AnvilGeneric {
184    fn get_error_name(&self) -> String {
185        self.as_ref().to_owned()
186    }
187}
188impl NamedError for AnvilGenericCode {
189    fn get_error_name(&self) -> String {
190        self.as_ref().to_owned()
191    }
192}
193impl From<AnvilGeneric> for crate::ZksyncError {
194    fn from(val: AnvilGeneric) -> Self {
195        val.to_unified()
196    }
197}
198impl fmt::Display for AnvilGeneric {
199    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
200        f.write_str(&self.get_message())
201    }
202}
203#[cfg(feature = "runtime_documentation")]
204impl Documented for AnvilGeneric {
205    type Documentation = &'static zksync_error_description::ErrorDocumentation;
206    fn get_documentation(
207        &self,
208    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
209        self.to_unified().get_identifier().get_documentation()
210    }
211}
212#[cfg(feature = "use_anyhow")]
213impl From<anyhow::Error> for AnvilGeneric {
214    fn from(value: anyhow::Error) -> Self {
215        let message = format!("{value:#?}");
216        AnvilGeneric::GenericError { message }
217    }
218}
219#[cfg(feature = "packed_errors")]
220impl From<AnvilGeneric> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
221    fn from(value: AnvilGeneric) -> Self {
222        crate::packed::pack(value)
223    }
224}
225#[cfg(feature = "serialized_errors")]
226impl From<AnvilGeneric> for crate::serialized::SerializedError {
227    fn from(value: AnvilGeneric) -> Self {
228        let packed = crate::packed::pack(value);
229        crate::serialized::serialize(packed).expect("Internal serialization error.")
230    }
231}
232impl CustomErrorMessage for AnvilGeneric {
233    fn get_message(&self) -> String {
234        match self {
235            AnvilGeneric::GenericError { message } => {
236                format!("[anvil_zksync-gen-0] Generic error: {message}")
237            }
238        }
239    }
240}
241#[doc = ""]
242#[doc = ""]
243#[doc = "Domain: AnvilZKsync"]
244#[repr(u32)]
245#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
246#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
247#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
248#[strum_discriminants(name(AnvilNodeCode))]
249#[strum_discriminants(vis(pub))]
250#[strum_discriminants(derive(AsRefStr, FromRepr))]
251#[non_exhaustive]
252pub enum AnvilNode {
253    #[doc = "# Summary "]
254    #[doc = "Transaction execution reverted and gas was burned."]
255    #[doc = ""]
256    #[doc = "# Description"]
257    #[doc = "This error occurs when a transaction execution is reverted due to an error in the anvil-zksync virtual machine execution and all gas is burned."]
258    #[doc = "This is a wrapper error that contains a more specific error inside it."]
259    #[doc = ""]
260    #[doc = "The VM may fail for various reasons including:"]
261    #[doc = "- Account validation failures (signature issues, nonce mismatches)"]
262    #[doc = "- Paymaster-related errors (when testing account abstraction features)"]
263    #[doc = "- Gas limit exceedance"]
264    #[doc = "- Storage access limitations"]
265    #[doc = "- Contract execution failures"]
266    #[doc = ""]
267    #[doc = "When using anvil-zksync for testing, these failures are valuable signals that help you identify issues with your contracts or transactions before deploying to the real ZKSync network."]
268    TransactionHalt {
269        inner: Box<Halt>,
270        transaction_hash: Box<zksync_basic_types::H256>,
271    } = 1u32,
272    #[doc = "# Summary "]
273    #[doc = "Transaction validation failed in anvil-zksync."]
274    #[doc = ""]
275    #[doc = "# Description"]
276    #[doc = "This error occurs when a transaction validation is failed and it is not executed."]
277    #[doc = "This is a wrapper error that contains a more specific validation error inside it, which provides details about the cause of failure."]
278    #[doc = ""]
279    #[doc = "The validation may fail for various reasons including:"]
280    #[doc = "- Gas limit exceedance"]
281    #[doc = "- Invalid gas limit value"]
282    #[doc = "- maxFeePerGas exceeding maxPriorityFeePerGas, and so on."]
283    #[doc = ""]
284    #[doc = "When using anvil-zksync for testing, these errors are valuable signals that help you identify issues with your contracts or transactions before deploying to the real ZKSync network."]
285    TransactionValidationFailed {
286        inner: Box<TransactionValidation>,
287        transaction_hash: Box<zksync_basic_types::H256>,
288    } = 10u32,
289    #[doc = "# Summary "]
290    #[doc = "Transaction gas estimation failed in anvil-zksync."]
291    #[doc = ""]
292    #[doc = "# Description"]
293    #[doc = "This error occurs when a gas estimation for transaction failed."]
294    #[doc = "This is a wrapper error that contains a more specific gas estimation error inside it, which provides details about the cause of failure."]
295    TransactionGasEstimationFailed {
296        inner: Box<GasEstimation>,
297        transaction_data: Vec<u8>,
298    } = 11u32,
299    #[doc = "# Summary "]
300    #[doc = "Requested block timestamp is earlier than the current timestamp."]
301    #[doc = ""]
302    #[doc = "# Description"]
303    #[doc = "This error occurs when attempting to set a future block timestamp to a value that is earlier than the timestamp of the most recently mined block."]
304    #[doc = ""]
305    #[doc = "In anvil-zksync, block timestamps must always increase monotonically. This simulates the behavior of real blockchain networks where time only moves forward. Each new block must have a timestamp greater than its predecessor."]
306    #[doc = ""]
307    #[doc = "Anvil-zksync provides methods to manipulate time for testing purposes (like `evm_increaseTime` and `evm_setNextBlockTimestamp`), but these can only move time forward, never backward."]
308    #[doc = ""]
309    #[doc = "Block timestamps in anvil-zksync are used by:"]
310    #[doc = "- Smart contracts that rely on `block.timestamp` for time-dependent logic"]
311    #[doc = "- System contracts that need to track event timing"]
312    #[doc = "- Time-locked functionality in DeFi applications and governance protocols"]
313    #[doc = ""]
314    #[doc = "When testing contracts that have time-dependent logic, it's important to ensure that any manipulated timestamps move forward in time, not backward."]
315    TimestampBackwardsError {
316        timestamp_requested: u64,
317        timestamp_now: u64,
318    } = 20u32,
319    #[doc = "# Summary "]
320    #[doc = "Failed to serialize transaction request into a valid transaction."]
321    #[doc = ""]
322    #[doc = "# Description"]
323    #[doc = "This error occurs when anvil-zksync is unable to convert a transaction request into a properly formatted transaction object."]
324    #[doc = "This typically happens during transaction creation or gas estimation when the request contains invalid or incompatible parameters."]
325    SerializationError {
326        transaction_type: String,
327        from: Box<zksync_basic_types::H256>,
328        to: Box<zksync_basic_types::H256>,
329        reason: String,
330    } = 30u32,
331    GenericError {
332        message: String,
333    } = 0u32,
334}
335impl core::error::Error for AnvilNode {}
336impl NamedError for AnvilNode {
337    fn get_error_name(&self) -> String {
338        self.as_ref().to_owned()
339    }
340}
341impl NamedError for AnvilNodeCode {
342    fn get_error_name(&self) -> String {
343        self.as_ref().to_owned()
344    }
345}
346impl From<AnvilNode> for crate::ZksyncError {
347    fn from(val: AnvilNode) -> Self {
348        val.to_unified()
349    }
350}
351impl fmt::Display for AnvilNode {
352    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
353        f.write_str(&self.get_message())
354    }
355}
356#[cfg(feature = "runtime_documentation")]
357impl Documented for AnvilNode {
358    type Documentation = &'static zksync_error_description::ErrorDocumentation;
359    fn get_documentation(
360        &self,
361    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
362        self.to_unified().get_identifier().get_documentation()
363    }
364}
365#[cfg(feature = "use_anyhow")]
366impl From<anyhow::Error> for AnvilNode {
367    fn from(value: anyhow::Error) -> Self {
368        let message = format!("{value:#?}");
369        AnvilNode::GenericError { message }
370    }
371}
372#[cfg(feature = "packed_errors")]
373impl From<AnvilNode> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
374    fn from(value: AnvilNode) -> Self {
375        crate::packed::pack(value)
376    }
377}
378#[cfg(feature = "serialized_errors")]
379impl From<AnvilNode> for crate::serialized::SerializedError {
380    fn from(value: AnvilNode) -> Self {
381        let packed = crate::packed::pack(value);
382        crate::serialized::serialize(packed).expect("Internal serialization error.")
383    }
384}
385impl CustomErrorMessage for AnvilNode {
386    fn get_message(&self) -> String {
387        match self {
388            AnvilNode::TransactionHalt {
389                inner,
390                transaction_hash,
391            } => {
392                format ! ("[anvil_zksync-node-1] Transaction {transaction_hash} execution reverted and gas was burned:\n{inner}")
393            }
394            AnvilNode::TransactionValidationFailed {
395                inner,
396                transaction_hash,
397            } => {
398                format ! ("[anvil_zksync-node-10] Transaction {transaction_hash}: validation failed:\n{inner}")
399            }
400            AnvilNode::TransactionGasEstimationFailed {
401                inner,
402                transaction_data,
403            } => {
404                format!("[anvil_zksync-node-11] Gas estimation failed:\n{inner}")
405            }
406            AnvilNode::TimestampBackwardsError {
407                timestamp_requested,
408                timestamp_now,
409            } => {
410                format ! ("[anvil_zksync-node-20] Failed to force the next timestamp to value {timestamp_requested}. It should be greater than the last timestamp {timestamp_now}.")
411            }
412            AnvilNode::SerializationError {
413                transaction_type,
414                from,
415                to,
416                reason,
417            } => {
418                format ! ("[anvil_zksync-node-30] Failed to parse a {transaction_type} transaction from request (from={from}, to={to}): {reason}.")
419            }
420            AnvilNode::GenericError { message } => {
421                format!("[anvil_zksync-node-0] Generic error: {message}")
422            }
423        }
424    }
425}
426#[doc = ""]
427#[doc = ""]
428#[doc = "Domain: AnvilZKsync"]
429#[repr(u32)]
430#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
431#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
432#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
433#[strum_discriminants(name(GasEstimationCode))]
434#[strum_discriminants(vis(pub))]
435#[strum_discriminants(derive(AsRefStr, FromRepr))]
436#[non_exhaustive]
437pub enum GasEstimation {
438    #[doc = "# Summary "]
439    #[doc = "Transaction exceeds the limit for published pubdata."]
440    #[doc = ""]
441    #[doc = "# Description"]
442    #[doc = "This error occurs when a transaction attempts to publish more pubdata than is allowed in a batch. Each transaction has a limit on how much pubdata it can publish to maintain network efficiency and prevent abuse."]
443    ExceedsLimitForPublishedPubdata {
444        pubdata_published: u32,
445        pubdata_limit: u32,
446    } = 1u32,
447    #[doc = "# Summary "]
448    #[doc = "Transaction gas estimation exceeds the block gas limit."]
449    #[doc = ""]
450    #[doc = "# Description"]
451    #[doc = "This error occurs when the total gas required for a transaction exceeds the maximum allowed for a block."]
452    #[doc = "The total gas is calculated by summing three components: the gas needed for publishing pubdata, the fixed overhead costs,"]
453    #[doc = "and the estimated gas for the transaction body itself. When this sum overflows or exceeds the block limit, this error is thrown."]
454    ExceedsBlockGasLimit {
455        overhead: u64,
456        gas_for_pubdata: u64,
457        estimated_body_cost: u64,
458    } = 2u32,
459    #[doc = "# Summary "]
460    #[doc = "Transaction execution reverts and burns all gas while estimating required gas in anvil-zksync."]
461    #[doc = ""]
462    #[doc = "# Description"]
463    #[doc = "This error occurs when anvil-zksync is trying to estimate gas required to run this transaction "]
464    #[doc = "but the estimation fails because the transaction reverts and burns all gas."]
465    #[doc = ""]
466    #[doc = "Before estimating gas, anvil-zksync first runs the transaction with maximum gas possible."]
467    #[doc = "If the first run was successful, anvil-zksync proceeds with the estimation"]
468    #[doc = "The estimation algorithm looks for a minimum gas value that makes the transaction succeed."]
469    #[doc = "This works if the transaction fails for all lower gas values and succeeds for all higher gas values."]
470    #[doc = "Some valid, but exotic transactions, resist estimation."]
471    #[doc = "Typically they depend on specific gas values, for example, they fail if `gasleft()` returned a value in a specific range."]
472    TransactionHalt {
473        inner: Box<Halt>,
474    } = 10u32,
475    #[doc = "# Summary "]
476    #[doc = "Transaction execution reverted while estimating required gas in anvil-zksync."]
477    #[doc = ""]
478    #[doc = "# Description"]
479    #[doc = "This error occurs when anvil-zksync is trying to estimate gas required to run this transaction "]
480    #[doc = "but the estimation fails because the transaction is reverted."]
481    #[doc = ""]
482    #[doc = "Before estimating gas, anvil-zksync first runs the transaction with maximum gas possible."]
483    #[doc = "If the first run was successful, anvil-zksync proceeds with the estimation"]
484    #[doc = "The estimation algorithm looks for a minimum gas value that makes the transaction succeed."]
485    #[doc = "This works if the transaction fails for all lower gas values and succeeds for all higher gas values."]
486    #[doc = "Some valid, but exotic transactions, resist estimation."]
487    #[doc = "Typically they depend on specific gas values, for example, they revert if `gasleft()` returned a value in a specific range."]
488    TransactionRevert {
489        inner: Box<Revert>,
490        data: Vec<u8>,
491    } = 11u32,
492    #[doc = "# Summary "]
493    #[doc = "An attempt to run the transaction with maximum gas resulted in reverting the transaction and burning all gas."]
494    #[doc = ""]
495    #[doc = "# Description"]
496    #[doc = "Before estimating gas, anvil-zksync first runs the transaction with maximum gas possible."]
497    #[doc = "This error occurs when this initial run results in a revert and burns all gas, suggesting that "]
498    #[doc = "no amount of gas will make this transaction executable."]
499    #[doc = ""]
500    #[doc = "There might be valid, but exotic transactions that fail when run with maximum gas provided,"]
501    #[doc = "but these are rare. Typically they depend on specific gas values."]
502    #[doc = "Usually, this error indicates either an unconditional revert or excessive gas consumption."]
503    TransactionAlwaysHalts {
504        inner: Box<Halt>,
505    } = 20u32,
506    #[doc = "# Summary "]
507    #[doc = "An attempt to run the transaction with maximum gas resulted in reverting the transaction and returning unspent gas."]
508    #[doc = ""]
509    #[doc = "# Description"]
510    #[doc = "Before estimating gas, anvil-zksync first runs the transaction with maximum gas possible."]
511    #[doc = "This error occurs when this initial run results in a revert and returns unspent gas, suggesting that "]
512    #[doc = "no amount of gas will make this transaction executable."]
513    #[doc = ""]
514    #[doc = "There might be valid, but exotic transactions that fail when run with maximum gas provided,"]
515    #[doc = "but these are rare. Typically they depend on specific gas values."]
516    #[doc = "Usually, this error indicates either an unconditional revert or excessive gas consumption."]
517    TransactionAlwaysReverts {
518        inner: Box<Revert>,
519        data: Vec<u8>,
520    } = 21u32,
521    GenericError {
522        message: String,
523    } = 0u32,
524}
525impl core::error::Error for GasEstimation {}
526impl NamedError for GasEstimation {
527    fn get_error_name(&self) -> String {
528        self.as_ref().to_owned()
529    }
530}
531impl NamedError for GasEstimationCode {
532    fn get_error_name(&self) -> String {
533        self.as_ref().to_owned()
534    }
535}
536impl From<GasEstimation> for crate::ZksyncError {
537    fn from(val: GasEstimation) -> Self {
538        val.to_unified()
539    }
540}
541impl fmt::Display for GasEstimation {
542    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
543        f.write_str(&self.get_message())
544    }
545}
546#[cfg(feature = "runtime_documentation")]
547impl Documented for GasEstimation {
548    type Documentation = &'static zksync_error_description::ErrorDocumentation;
549    fn get_documentation(
550        &self,
551    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
552        self.to_unified().get_identifier().get_documentation()
553    }
554}
555#[cfg(feature = "use_anyhow")]
556impl From<anyhow::Error> for GasEstimation {
557    fn from(value: anyhow::Error) -> Self {
558        let message = format!("{value:#?}");
559        GasEstimation::GenericError { message }
560    }
561}
562#[cfg(feature = "packed_errors")]
563impl From<GasEstimation> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
564    fn from(value: GasEstimation) -> Self {
565        crate::packed::pack(value)
566    }
567}
568#[cfg(feature = "serialized_errors")]
569impl From<GasEstimation> for crate::serialized::SerializedError {
570    fn from(value: GasEstimation) -> Self {
571        let packed = crate::packed::pack(value);
572        crate::serialized::serialize(packed).expect("Internal serialization error.")
573    }
574}
575impl CustomErrorMessage for GasEstimation {
576    fn get_message(&self) -> String {
577        match self {
578            GasEstimation::ExceedsLimitForPublishedPubdata {
579                pubdata_published,
580                pubdata_limit,
581            } => {
582                format ! ("[anvil_zksync-gas_estim-1] Transaction has published {pubdata_published} bytes which exceeds limit for published pubdata ({pubdata_limit}).")
583            }
584            GasEstimation::ExceedsBlockGasLimit {
585                overhead,
586                gas_for_pubdata,
587                estimated_body_cost,
588            } => {
589                format ! ("[anvil_zksync-gas_estim-2] Estimating full gas limit overflows while adding up additional gas ({gas_for_pubdata}), overhead ({overhead}), and estimated transaction body gas cost ({estimated_body_cost}).")
590            }
591            GasEstimation::TransactionHalt { inner } => {
592                format ! ("[anvil_zksync-gas_estim-10] Gas estimation failed because the transaction exhibits exotic gas behavior and reverts, burning all gas: {inner}")
593            }
594            GasEstimation::TransactionRevert { inner, data } => {
595                format ! ("[anvil_zksync-gas_estim-11] Gas estimation failed because the transaction exhibits exotic gas behavior and reverts, returning unspent gas: {inner}")
596            }
597            GasEstimation::TransactionAlwaysHalts { inner } => {
598                format ! ("[anvil_zksync-gas_estim-20] Gas estimation is impossible: execution reverted when the transaction is executed with maximum gas. Unspent gas is burned. \n{inner}")
599            }
600            GasEstimation::TransactionAlwaysReverts { inner, data } => {
601                format ! ("[anvil_zksync-gas_estim-21] Gas estimation is impossible: execution reverted when the transaction is executed with maximum gas. Unspent gas is returned. \n{inner}")
602            }
603            GasEstimation::GenericError { message } => {
604                format!("[anvil_zksync-gas_estim-0] Generic error: {message}")
605            }
606        }
607    }
608}
609#[doc = ""]
610#[doc = ""]
611#[doc = "Domain: AnvilZKsync"]
612#[repr(u32)]
613#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
614#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
615#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
616#[strum_discriminants(name(HaltCode))]
617#[strum_discriminants(vis(pub))]
618#[strum_discriminants(derive(AsRefStr, FromRepr))]
619#[non_exhaustive]
620pub enum Halt {
621    #[doc = "# Summary "]
622    #[doc = "Account validation failed during execution."]
623    #[doc = ""]
624    #[doc = "# Description"]
625    #[doc = "This error occurs when the account validation step fails during the verification and execution of a transaction."]
626    ValidationFailed {
627        msg: String,
628        data: String,
629    } = 1u32,
630    #[doc = "# Summary "]
631    #[doc = "Paymaster validation failed."]
632    #[doc = ""]
633    #[doc = "# Description"]
634    #[doc = "This error is emitted when the paymaster validation process fails during transaction execution."]
635    PaymasterValidationFailed {
636        msg: String,
637        data: String,
638    } = 2u32,
639    #[doc = "# Summary "]
640    #[doc = "Pre-paymaster preparation step failed."]
641    #[doc = ""]
642    #[doc = "# Description"]
643    #[doc = "This error occurs during pre-transaction paymaster preparation if the paymaster input is too short (less than 4 bytes) or its selector is unsupported."]
644    PrePaymasterPreparationFailed {
645        msg: String,
646        data: String,
647    } = 3u32,
648    #[doc = "# Summary "]
649    #[doc = "Payment for the transaction failed."]
650    #[doc = ""]
651    #[doc = "# Description"]
652    #[doc = "This error is emitted when the system fails to deduct the required fees for executing the transaction."]
653    PayForTxFailed {
654        msg: String,
655        data: String,
656    } = 4u32,
657    #[doc = "# Summary "]
658    #[doc = "Failed to register factory dependencies for L1 transactions."]
659    #[doc = ""]
660    #[doc = "# Description"]
661    #[doc = "This error occurs when the system is unable to mark the factory dependencies for an L1 transaction in the known code storage. For L1 transactions, factory dependencies must be recorded as known to ensure that all required code components are available. A failure here may indicate that the dependency data is missing or malformed."]
662    FailedToMarkFactoryDependencies {
663        msg: String,
664        data: String,
665    } = 5u32,
666    #[doc = "# Summary "]
667    #[doc = "Transaction fee deduction failed."]
668    #[doc = ""]
669    #[doc = "# Description"]
670    #[doc = "This error is raised when the funds transferred to the bootloader are insufficient compared to the required fee (calculated as gasLimit * gasPrice). This may occur when the payer (account or paymaster) does not send enough ETH or when fee parameters are misconfigured."]
671    FailedToChargeFee {
672        msg: String,
673        data: String,
674    } = 6u32,
675    #[doc = "# Summary "]
676    #[doc = "The sender address is not a valid account."]
677    #[doc = ""]
678    #[doc = "# Description"]
679    #[doc = "This error occurs when a transaction is attempted from an address that has not been deployed as an account, meaning the `from` address is just a contract."]
680    FromIsNotAnAccount = 7u32,
681    #[doc = "# Summary "]
682    #[doc = "An inner transaction error occurred."]
683    #[doc = ""]
684    #[doc = "# Description"]
685    #[doc = "Transaction reverted due to a contract call that failed during execution."]
686    InnerTxError = 8u32,
687    #[doc = "# Summary "]
688    #[doc = "An unknown error occurred."]
689    #[doc = ""]
690    #[doc = "# Description"]
691    #[doc = "This error is emitted when the system encounters an unspecified reason for reverting and burning all gas."]
692    Unknown {
693        msg: String,
694        data: String,
695    } = 9u32,
696    #[doc = "# Summary "]
697    #[doc = "The bootloader encountered an unexpected state."]
698    #[doc = ""]
699    #[doc = "# Description"]
700    #[doc = "This error can be triggered by various bootloader anomalies such as mismatched fee parameters (e.g., baseFee greater than maxFeePerGas), unaccepted pubdata price, failed system calls (like L1 messenger or System Context), or internal assertion failures."]
701    UnexpectedVMBehavior {
702        problem: String,
703    } = 10u32,
704    #[doc = "# Summary "]
705    #[doc = "The bootloader has run out of gas."]
706    #[doc = ""]
707    #[doc = "# Description"]
708    #[doc = "This error occurs when the bootloader does not have enough gas to continue executing the transaction."]
709    BootloaderOutOfGas = 11u32,
710    #[doc = "# Summary "]
711    #[doc = "The validation step ran out of gas."]
712    #[doc = ""]
713    #[doc = "# Description"]
714    #[doc = "Validation step of transaction execution exceeds the allocated gas limit."]
715    ValidationOutOfGas = 12u32,
716    #[doc = "# Summary "]
717    #[doc = "The transaction's gas limit is excessively high."]
718    #[doc = ""]
719    #[doc = "# Description"]
720    #[doc = "This error occurs when the gas limit set for the transaction is too large for the server to handle."]
721    TooBigGasLimit = 13u32,
722    #[doc = "# Summary "]
723    #[doc = "Insufficient gas for the bootloader to continue the transaction."]
724    #[doc = ""]
725    #[doc = "# Description"]
726    #[doc = "The bootloader checks if it can supply the requested gas plus overhead. If the remaining gas is below this threshold, it reverts."]
727    NotEnoughGasProvided = 14u32,
728    #[doc = "# Summary "]
729    #[doc = "The transaction exceeded the allowed number of storage invocations."]
730    #[doc = ""]
731    #[doc = "# Description"]
732    #[doc = "This error occurs when the transaction makes too many missing invocations to memory, surpassing the allowed limit."]
733    MissingInvocationLimitReached = 15u32,
734    #[doc = "# Summary "]
735    #[doc = "Unable to set L2 block information."]
736    #[doc = ""]
737    #[doc = "# Description"]
738    #[doc = "System failed to set the necessary information for the L2 block during execution."]
739    FailedToSetL2Block {
740        msg: String,
741    } = 16u32,
742    #[doc = "# Summary "]
743    #[doc = "Unable to append the transaction hash to the ongoing L2 block."]
744    #[doc = ""]
745    #[doc = "# Description"]
746    #[doc = "The system context call to record this transaction in the current L2 block failed."]
747    FailedToAppendTransactionToL2Block {
748        msg: String,
749    } = 17u32,
750    #[doc = "# Summary "]
751    #[doc = "The virtual machine encountered a panic."]
752    #[doc = ""]
753    #[doc = "# Description"]
754    #[doc = "VM experiences a critical failure and panic during transaction execution."]
755    VMPanic = 18u32,
756    #[doc = "# Summary "]
757    #[doc = "Tracer aborted the transaction execution."]
758    #[doc = ""]
759    #[doc = "# Description"]
760    #[doc = "Custom tracer used during transaction execution decides to abort the process, typically due to specific conditions being met."]
761    TracerCustom {
762        msg: String,
763    } = 19u32,
764    #[doc = "# Summary "]
765    #[doc = "Unable to publish compressed bytecodes."]
766    #[doc = ""]
767    #[doc = "# Description"]
768    #[doc = "Emitted when the system fails to publish the compressed bytecodes during execution."]
769    FailedToPublishCompressedBytecodes = 20u32,
770    #[doc = "# Summary "]
771    #[doc = "Block timestamp assertion failed during the transaction."]
772    #[doc = ""]
773    #[doc = "# Description"]
774    #[doc = "This error often occurs if the transaction's timestamp is behind the last known block or conflicts with expected chronological order."]
775    FailedBlockTimestampAssertion = 21u32,
776    GenericError {
777        message: String,
778    } = 0u32,
779}
780impl core::error::Error for Halt {}
781impl NamedError for Halt {
782    fn get_error_name(&self) -> String {
783        self.as_ref().to_owned()
784    }
785}
786impl NamedError for HaltCode {
787    fn get_error_name(&self) -> String {
788        self.as_ref().to_owned()
789    }
790}
791impl From<Halt> for crate::ZksyncError {
792    fn from(val: Halt) -> Self {
793        val.to_unified()
794    }
795}
796impl fmt::Display for Halt {
797    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
798        f.write_str(&self.get_message())
799    }
800}
801#[cfg(feature = "runtime_documentation")]
802impl Documented for Halt {
803    type Documentation = &'static zksync_error_description::ErrorDocumentation;
804    fn get_documentation(
805        &self,
806    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
807        self.to_unified().get_identifier().get_documentation()
808    }
809}
810#[cfg(feature = "use_anyhow")]
811impl From<anyhow::Error> for Halt {
812    fn from(value: anyhow::Error) -> Self {
813        let message = format!("{value:#?}");
814        Halt::GenericError { message }
815    }
816}
817#[cfg(feature = "packed_errors")]
818impl From<Halt> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
819    fn from(value: Halt) -> Self {
820        crate::packed::pack(value)
821    }
822}
823#[cfg(feature = "serialized_errors")]
824impl From<Halt> for crate::serialized::SerializedError {
825    fn from(value: Halt) -> Self {
826        let packed = crate::packed::pack(value);
827        crate::serialized::serialize(packed).expect("Internal serialization error.")
828    }
829}
830impl CustomErrorMessage for Halt {
831    fn get_message(&self) -> String {
832        match self {
833            Halt::ValidationFailed { msg, data } => {
834                format!("[anvil_zksync-halt-1] Account validation error: {msg}: {data}")
835            }
836            Halt::PaymasterValidationFailed { msg, data } => {
837                format!("[anvil_zksync-halt-2] Paymaster validation error: {msg}: {data}.")
838            }
839            Halt::PrePaymasterPreparationFailed { msg, data } => {
840                format!("[anvil_zksync-halt-3] Pre-paymaster preparation error: {msg}: {data}")
841            }
842            Halt::PayForTxFailed { msg, data } => {
843                format!("[anvil_zksync-halt-4] Failed to pay for the transaction: {msg}: {data}")
844            }
845            Halt::FailedToMarkFactoryDependencies { msg, data } => {
846                format!("[anvil_zksync-halt-5] Failed to mark factory dependencies: {msg}: {data}")
847            }
848            Halt::FailedToChargeFee { msg, data } => {
849                format!("[anvil_zksync-halt-6] Failed to charge fee: {msg}: {data}")
850            }
851            Halt::FromIsNotAnAccount => {
852                format!("[anvil_zksync-halt-7] Sender is not an account")
853            }
854            Halt::InnerTxError => {
855                format!("[anvil_zksync-halt-8] Bootloader-based tx failed")
856            }
857            Halt::Unknown { msg, data } => {
858                format!("[anvil_zksync-halt-9] Unknown reason: {msg}: {data}")
859            }
860            Halt::UnexpectedVMBehavior { problem } => {
861                format ! ("[anvil_zksync-halt-10] Virtual machine entered unexpected state. Error description: {problem}")
862            }
863            Halt::BootloaderOutOfGas => {
864                format!("[anvil_zksync-halt-11] Bootloader out of gas")
865            }
866            Halt::ValidationOutOfGas => {
867                format!("[anvil_zksync-halt-12] Validation run out of gas")
868            }
869            Halt::TooBigGasLimit => {
870                format ! ("[anvil_zksync-halt-13] Transaction has a too big ergs limit and will not be executed by the server")
871            }
872            Halt::NotEnoughGasProvided => {
873                format ! ("[anvil_zksync-halt-14] Bootloader does not have enough gas to proceed with the transaction.")
874            }
875            Halt::MissingInvocationLimitReached => {
876                format!("[anvil_zksync-halt-15] Transaction produced too much storage accesses.")
877            }
878            Halt::FailedToSetL2Block { msg } => {
879                format!(
880                    "[anvil_zksync-halt-16] Failed to set information about the L2 block: {msg}"
881                )
882            }
883            Halt::FailedToAppendTransactionToL2Block { msg } => {
884                format ! ("[anvil_zksync-halt-17] Failed to append the transaction to the current L2 block: {msg}")
885            }
886            Halt::VMPanic => {
887                format!("[anvil_zksync-halt-18] VM panicked")
888            }
889            Halt::TracerCustom { msg } => {
890                format!("[anvil_zksync-halt-19] Tracer aborted execution: {msg}")
891            }
892            Halt::FailedToPublishCompressedBytecodes => {
893                format!("[anvil_zksync-halt-20] Failed to publish compressed bytecodes")
894            }
895            Halt::FailedBlockTimestampAssertion => {
896                format!("[anvil_zksync-halt-21] Transaction failed `block.timestamp` assertion")
897            }
898            Halt::GenericError { message } => {
899                format!("[anvil_zksync-halt-0] Generic error: {message}")
900            }
901        }
902    }
903}
904#[doc = ""]
905#[doc = ""]
906#[doc = "Domain: AnvilZKsync"]
907#[repr(u32)]
908#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
909#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
910#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
911#[strum_discriminants(name(RevertCode))]
912#[strum_discriminants(vis(pub))]
913#[strum_discriminants(derive(AsRefStr, FromRepr))]
914#[non_exhaustive]
915pub enum Revert {
916    #[doc = "# Summary "]
917    #[doc = "Execution reverted due to a failure."]
918    #[doc = ""]
919    #[doc = "# Description"]
920    #[doc = "This error indicates that the transaction execution was reverted."]
921    General {
922        msg: String,
923        data: Vec<u8>,
924    } = 1u32,
925    #[doc = "# Summary "]
926    #[doc = "An inner transaction error occurred."]
927    #[doc = ""]
928    #[doc = "# Description"]
929    #[doc = "This error is emitted when an inner transaction within the VM fails, typically related to bootloader execution."]
930    InnerTxError = 2u32,
931    #[doc = "# Summary "]
932    #[doc = "A generic VM error."]
933    #[doc = ""]
934    #[doc = "# Description"]
935    #[doc = "This error indicates a generic failure within the VM, without specific details."]
936    VmError = 3u32,
937    #[doc = "# Summary "]
938    #[doc = "An unknown VM revert reason was encountered."]
939    #[doc = ""]
940    #[doc = "# Description"]
941    #[doc = "This error is emitted when the VM encounters a revert reason that is not recognized."]
942    #[doc = "In most cases, this error may also indicate that the transaction exhausted all the gas allocated for its execution."]
943    Unknown {
944        function_selector: String,
945        data: String,
946    } = 4u32,
947    GenericError {
948        message: String,
949    } = 0u32,
950}
951impl core::error::Error for Revert {}
952impl NamedError for Revert {
953    fn get_error_name(&self) -> String {
954        self.as_ref().to_owned()
955    }
956}
957impl NamedError for RevertCode {
958    fn get_error_name(&self) -> String {
959        self.as_ref().to_owned()
960    }
961}
962impl From<Revert> for crate::ZksyncError {
963    fn from(val: Revert) -> Self {
964        val.to_unified()
965    }
966}
967impl fmt::Display for Revert {
968    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
969        f.write_str(&self.get_message())
970    }
971}
972#[cfg(feature = "runtime_documentation")]
973impl Documented for Revert {
974    type Documentation = &'static zksync_error_description::ErrorDocumentation;
975    fn get_documentation(
976        &self,
977    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
978        self.to_unified().get_identifier().get_documentation()
979    }
980}
981#[cfg(feature = "use_anyhow")]
982impl From<anyhow::Error> for Revert {
983    fn from(value: anyhow::Error) -> Self {
984        let message = format!("{value:#?}");
985        Revert::GenericError { message }
986    }
987}
988#[cfg(feature = "packed_errors")]
989impl From<Revert> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
990    fn from(value: Revert) -> Self {
991        crate::packed::pack(value)
992    }
993}
994#[cfg(feature = "serialized_errors")]
995impl From<Revert> for crate::serialized::SerializedError {
996    fn from(value: Revert) -> Self {
997        let packed = crate::packed::pack(value);
998        crate::serialized::serialize(packed).expect("Internal serialization error.")
999    }
1000}
1001impl CustomErrorMessage for Revert {
1002    fn get_message(&self) -> String {
1003        match self {
1004            Revert::General { msg, data } => {
1005                format!("[anvil_zksync-revert-1] Execution reverted with message: {msg}")
1006            }
1007            Revert::InnerTxError => {
1008                format!("[anvil_zksync-revert-2] Bootloader-based transaction failed.")
1009            }
1010            Revert::VmError => {
1011                format!("[anvil_zksync-revert-3] VM Error")
1012            }
1013            Revert::Unknown {
1014                function_selector,
1015                data,
1016            } => {
1017                format ! ("[anvil_zksync-revert-4] Unknown VM revert reason: function_selector={function_selector}, data={data}")
1018            }
1019            Revert::GenericError { message } => {
1020                format!("[anvil_zksync-revert-0] Generic error: {message}")
1021            }
1022        }
1023    }
1024}
1025#[doc = ""]
1026#[doc = ""]
1027#[doc = "Domain: AnvilZKsync"]
1028#[repr(u32)]
1029#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1030#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1031#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1032#[strum_discriminants(name(StateLoaderCode))]
1033#[strum_discriminants(vis(pub))]
1034#[strum_discriminants(derive(AsRefStr, FromRepr))]
1035#[non_exhaustive]
1036pub enum StateLoader {
1037    #[doc = "# Summary "]
1038    #[doc = "It is not allowed to load a state overriding the existing node state."]
1039    #[doc = ""]
1040    #[doc = "# Description"]
1041    #[doc = "It is not allowed to load a state overriding the existing node state. If you have a use case for that, please create an issue."]
1042    LoadingStateOverExistingState = 1u32,
1043    #[doc = "# Summary "]
1044    #[doc = "Attempt to load a state with no blocks"]
1045    #[doc = ""]
1046    #[doc = "# Description"]
1047    #[doc = "It is not allowed to load a state without any blocks in it."]
1048    LoadEmptyState = 2u32,
1049    #[doc = "# Summary "]
1050    #[doc = ""]
1051    #[doc = ""]
1052    #[doc = "# Description"]
1053    #[doc = "Failed to decompress the state."]
1054    StateDecompression {
1055        details: String,
1056    } = 3u32,
1057    #[doc = "# Summary "]
1058    #[doc = ""]
1059    #[doc = ""]
1060    #[doc = "# Description"]
1061    #[doc = "Failed to deserialize the state file."]
1062    StateDeserialization {
1063        details: String,
1064    } = 4u32,
1065    #[doc = "# Summary "]
1066    #[doc = ""]
1067    #[doc = ""]
1068    #[doc = "# Description"]
1069    #[doc = "The version of the state file is not recognized."]
1070    UnknownStateVersion {
1071        version: u32,
1072    } = 5u32,
1073    #[doc = "# Summary "]
1074    #[doc = ""]
1075    #[doc = ""]
1076    #[doc = "# Description"]
1077    #[doc = "Failed to access the state file."]
1078    StateFileAccess {
1079        path: String,
1080        reason: String,
1081    } = 6u32,
1082    GenericError {
1083        message: String,
1084    } = 0u32,
1085}
1086impl core::error::Error for StateLoader {}
1087impl NamedError for StateLoader {
1088    fn get_error_name(&self) -> String {
1089        self.as_ref().to_owned()
1090    }
1091}
1092impl NamedError for StateLoaderCode {
1093    fn get_error_name(&self) -> String {
1094        self.as_ref().to_owned()
1095    }
1096}
1097impl From<StateLoader> for crate::ZksyncError {
1098    fn from(val: StateLoader) -> Self {
1099        val.to_unified()
1100    }
1101}
1102impl fmt::Display for StateLoader {
1103    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1104        f.write_str(&self.get_message())
1105    }
1106}
1107#[cfg(feature = "runtime_documentation")]
1108impl Documented for StateLoader {
1109    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1110    fn get_documentation(
1111        &self,
1112    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1113        self.to_unified().get_identifier().get_documentation()
1114    }
1115}
1116#[cfg(feature = "use_anyhow")]
1117impl From<anyhow::Error> for StateLoader {
1118    fn from(value: anyhow::Error) -> Self {
1119        let message = format!("{value:#?}");
1120        StateLoader::GenericError { message }
1121    }
1122}
1123#[cfg(feature = "packed_errors")]
1124impl From<StateLoader> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1125    fn from(value: StateLoader) -> Self {
1126        crate::packed::pack(value)
1127    }
1128}
1129#[cfg(feature = "serialized_errors")]
1130impl From<StateLoader> for crate::serialized::SerializedError {
1131    fn from(value: StateLoader) -> Self {
1132        let packed = crate::packed::pack(value);
1133        crate::serialized::serialize(packed).expect("Internal serialization error.")
1134    }
1135}
1136impl CustomErrorMessage for StateLoader {
1137    fn get_message(&self) -> String {
1138        match self {
1139            StateLoader::LoadingStateOverExistingState => {
1140                format ! ("[anvil_zksync-state-1] Loading state into a node with existing state is not allowed.")
1141            }
1142            StateLoader::LoadEmptyState => {
1143                format!("[anvil_zksync-state-2] Loading a state without blocks is not allowed.")
1144            }
1145            StateLoader::StateDecompression { details } => {
1146                format!("[anvil_zksync-state-3] Failed to decompress state: {details}.")
1147            }
1148            StateLoader::StateDeserialization { details } => {
1149                format!("[anvil_zksync-state-4] Failed to deserialize state: {details}")
1150            }
1151            StateLoader::UnknownStateVersion { version } => {
1152                format!("[anvil_zksync-state-5] Unknown version of the state: {version}.")
1153            }
1154            StateLoader::StateFileAccess { path, reason } => {
1155                format ! ("[anvil_zksync-state-6] Error while accessing the state located at `{path}`: {reason}.")
1156            }
1157            StateLoader::GenericError { message } => {
1158                format!("[anvil_zksync-state-0] Generic error: {message}")
1159            }
1160        }
1161    }
1162}
1163#[doc = ""]
1164#[doc = ""]
1165#[doc = "Domain: AnvilZKsync"]
1166#[repr(u32)]
1167#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1168#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1169#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1170#[strum_discriminants(name(TransactionValidationCode))]
1171#[strum_discriminants(vis(pub))]
1172#[strum_discriminants(derive(AsRefStr, FromRepr))]
1173#[non_exhaustive]
1174pub enum TransactionValidation {
1175    #[doc = "# Summary "]
1176    #[doc = "Transaction validation failed due to excessive gas limit -- did you provide invalid gas limit?"]
1177    #[doc = ""]
1178    #[doc = "# Description"]
1179    #[doc = "This error occurs when a transaction's gas limit exceeds the maximum allowed gas allowed by ZKsync protocol."]
1180    #[doc = "As of protocol version 27, the gas is limited to 2^50"]
1181    #[doc = "Note: When anvil-zksync is in forking mode, it lock-in and uses gas price at the forked block"]
1182    InvalidGasLimit {
1183        tx_gas_limit: Box<zksync_basic_types::U256>,
1184        max_gas: Box<zksync_basic_types::U256>,
1185    } = 1u32,
1186    #[doc = "# Summary "]
1187    #[doc = "Transaction validation failed due to excessive gas per pubdata limit."]
1188    #[doc = ""]
1189    #[doc = "# Description"]
1190    #[doc = "This error occurs when a transaction's gas per pubdata limit exceeds the maximum allowed gas allowed by ZKsync protocol."]
1191    #[doc = "As of protocol version 27, the gas is limited to 2^50"]
1192    #[doc = "Note: When anvil-zksync is in forking mode, it lock-in and uses gas price at the forked block"]
1193    GasPerPubdataLimit {
1194        tx_gas_per_pubdata_limit: Box<zksync_basic_types::U256>,
1195        max_gas: Box<zksync_basic_types::U256>,
1196    } = 2u32,
1197    #[doc = "# Summary "]
1198    #[doc = "Transaction's maxFeePerGas is lower than the current gas price in anvil-zksync."]
1199    #[doc = ""]
1200    #[doc = "# Description"]
1201    #[doc = "This error occurs when the maximum fee per gas specified in the transaction is lower than the current gas price set in the anvil-zksync node."]
1202    #[doc = "To be considered valid, transactions must specify a maxFeePerGas that is greater or equal to the current gas price"]
1203    #[doc = ""]
1204    #[doc = "In anvil-zksync, the gas price can be configured when starting the node using `--l1-gas-price` argument or can be modified dynamically. By default, the node simulates a gas price model similar to the real ZKSync network, including:"]
1205    #[doc = "1. A base computation fee (similar to Ethereum's base fee)"]
1206    #[doc = "2. A simulated pubdata posting fee"]
1207    #[doc = ""]
1208    #[doc = "Even though anvil-zksync is a testing environment, it enforces these gas price validations to ensure that your tests accurately reflect how transactions would behave on the actual ZKSync network."]
1209    #[doc = "Note: When anvil-zksync is in forking mode, it lock-in and uses gas price at the forked block"]
1210    MaxFeePerGasTooLow {
1211        max_fee_per_gas: Box<zksync_basic_types::U256>,
1212        l2_gas_price: Box<zksync_basic_types::U256>,
1213    } = 3u32,
1214    #[doc = "# Summary "]
1215    #[doc = "Transaction's maxPriorityFeePerGas exceeds maxFeePerGas."]
1216    #[doc = ""]
1217    #[doc = "# Description"]
1218    #[doc = "This error occurs when a transaction's maximum priority fee per gas is greater than its maximum fee per gas in anvil-zksync."]
1219    #[doc = "In ZKSync, the field `maxPriorityFeePerGas` is ignored, as ZKsync doesn’t have a concept of priority fees."]
1220    #[doc = "Instead, `maxFeePerGas` is utilized and includes the base fees."]
1221    #[doc = "However, certain transaction types like EIP-1559 or EIP-712 may contain field `maxPriorityFeePerGas`, which should be less or equal to the field `maxFeePerGas`."]
1222    MaxPriorityFeeGreaterThanMaxFee {
1223        max_fee_per_gas: Box<zksync_basic_types::U256>,
1224        max_priority_fee_per_gas: Box<zksync_basic_types::U256>,
1225    } = 4u32,
1226    GenericError {
1227        message: String,
1228    } = 0u32,
1229}
1230impl core::error::Error for TransactionValidation {}
1231impl NamedError for TransactionValidation {
1232    fn get_error_name(&self) -> String {
1233        self.as_ref().to_owned()
1234    }
1235}
1236impl NamedError for TransactionValidationCode {
1237    fn get_error_name(&self) -> String {
1238        self.as_ref().to_owned()
1239    }
1240}
1241impl From<TransactionValidation> for crate::ZksyncError {
1242    fn from(val: TransactionValidation) -> Self {
1243        val.to_unified()
1244    }
1245}
1246impl fmt::Display for TransactionValidation {
1247    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1248        f.write_str(&self.get_message())
1249    }
1250}
1251#[cfg(feature = "runtime_documentation")]
1252impl Documented for TransactionValidation {
1253    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1254    fn get_documentation(
1255        &self,
1256    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1257        self.to_unified().get_identifier().get_documentation()
1258    }
1259}
1260#[cfg(feature = "use_anyhow")]
1261impl From<anyhow::Error> for TransactionValidation {
1262    fn from(value: anyhow::Error) -> Self {
1263        let message = format!("{value:#?}");
1264        TransactionValidation::GenericError { message }
1265    }
1266}
1267#[cfg(feature = "packed_errors")]
1268impl From<TransactionValidation>
1269    for crate::packed::PackedError<crate::error::domains::ZksyncError>
1270{
1271    fn from(value: TransactionValidation) -> Self {
1272        crate::packed::pack(value)
1273    }
1274}
1275#[cfg(feature = "serialized_errors")]
1276impl From<TransactionValidation> for crate::serialized::SerializedError {
1277    fn from(value: TransactionValidation) -> Self {
1278        let packed = crate::packed::pack(value);
1279        crate::serialized::serialize(packed).expect("Internal serialization error.")
1280    }
1281}
1282impl CustomErrorMessage for TransactionValidation {
1283    fn get_message(&self) -> String {
1284        match self {
1285            TransactionValidation::InvalidGasLimit {
1286                tx_gas_limit,
1287                max_gas,
1288            } => {
1289                format ! ("[anvil_zksync-tx_invalid-1] Gas limit for transaction is {tx_gas_limit} which exceeds maximum allowed gas {max_gas}")
1290            }
1291            TransactionValidation::GasPerPubdataLimit {
1292                tx_gas_per_pubdata_limit,
1293                max_gas,
1294            } => {
1295                format ! ("[anvil_zksync-tx_invalid-2] Gas per pubdata limit is {tx_gas_per_pubdata_limit} which exceeds maximum allowed gas {max_gas}")
1296            }
1297            TransactionValidation::MaxFeePerGasTooLow {
1298                max_fee_per_gas,
1299                l2_gas_price,
1300            } => {
1301                format ! ("[anvil_zksync-tx_invalid-3] Max fee per gas: {max_fee_per_gas}, current L2 gas price {l2_gas_price} is too expensive.")
1302            }
1303            TransactionValidation::MaxPriorityFeeGreaterThanMaxFee {
1304                max_fee_per_gas,
1305                max_priority_fee_per_gas,
1306            } => {
1307                format ! ("[anvil_zksync-tx_invalid-4] maxPriorityFeePerGas={max_priority_fee_per_gas} exceeds the limit value maxFeePerGas={max_fee_per_gas}")
1308            }
1309            TransactionValidation::GenericError { message } => {
1310                format!("[anvil_zksync-tx_invalid-0] Generic error: {message}")
1311            }
1312        }
1313    }
1314}
1315#[doc = "Errors originating in the compiler backend for Ethereum VM (EVM)."]
1316#[doc = ""]
1317#[doc = "Domain: Compiler"]
1318#[repr(u32)]
1319#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1320#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1321#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1322#[strum_discriminants(name(LLVM_EVMCode))]
1323#[strum_discriminants(vis(pub))]
1324#[strum_discriminants(derive(AsRefStr, FromRepr))]
1325#[non_exhaustive]
1326pub enum LLVM_EVM {
1327    GenericError { message: String } = 0u32,
1328}
1329impl core::error::Error for LLVM_EVM {}
1330impl NamedError for LLVM_EVM {
1331    fn get_error_name(&self) -> String {
1332        self.as_ref().to_owned()
1333    }
1334}
1335impl NamedError for LLVM_EVMCode {
1336    fn get_error_name(&self) -> String {
1337        self.as_ref().to_owned()
1338    }
1339}
1340impl From<LLVM_EVM> for crate::ZksyncError {
1341    fn from(val: LLVM_EVM) -> Self {
1342        val.to_unified()
1343    }
1344}
1345impl fmt::Display for LLVM_EVM {
1346    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1347        f.write_str(&self.get_message())
1348    }
1349}
1350#[cfg(feature = "runtime_documentation")]
1351impl Documented for LLVM_EVM {
1352    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1353    fn get_documentation(
1354        &self,
1355    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1356        self.to_unified().get_identifier().get_documentation()
1357    }
1358}
1359#[cfg(feature = "use_anyhow")]
1360impl From<anyhow::Error> for LLVM_EVM {
1361    fn from(value: anyhow::Error) -> Self {
1362        let message = format!("{value:#?}");
1363        LLVM_EVM::GenericError { message }
1364    }
1365}
1366#[cfg(feature = "packed_errors")]
1367impl From<LLVM_EVM> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1368    fn from(value: LLVM_EVM) -> Self {
1369        crate::packed::pack(value)
1370    }
1371}
1372#[cfg(feature = "serialized_errors")]
1373impl From<LLVM_EVM> for crate::serialized::SerializedError {
1374    fn from(value: LLVM_EVM) -> Self {
1375        let packed = crate::packed::pack(value);
1376        crate::serialized::serialize(packed).expect("Internal serialization error.")
1377    }
1378}
1379impl CustomErrorMessage for LLVM_EVM {
1380    fn get_message(&self) -> String {
1381        match self {
1382            LLVM_EVM::GenericError { message } => {
1383                format!("[compiler-llvm+evm-0] Generic error: {message}")
1384            }
1385        }
1386    }
1387}
1388#[doc = "Errors originating in the compiler backend for EraVM."]
1389#[doc = ""]
1390#[doc = "Domain: Compiler"]
1391#[repr(u32)]
1392#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1393#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1394#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1395#[strum_discriminants(name(LLVM_EraCode))]
1396#[strum_discriminants(vis(pub))]
1397#[strum_discriminants(derive(AsRefStr, FromRepr))]
1398#[non_exhaustive]
1399pub enum LLVM_Era {
1400    GenericError { message: String } = 0u32,
1401}
1402impl core::error::Error for LLVM_Era {}
1403impl NamedError for LLVM_Era {
1404    fn get_error_name(&self) -> String {
1405        self.as_ref().to_owned()
1406    }
1407}
1408impl NamedError for LLVM_EraCode {
1409    fn get_error_name(&self) -> String {
1410        self.as_ref().to_owned()
1411    }
1412}
1413impl From<LLVM_Era> for crate::ZksyncError {
1414    fn from(val: LLVM_Era) -> Self {
1415        val.to_unified()
1416    }
1417}
1418impl fmt::Display for LLVM_Era {
1419    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1420        f.write_str(&self.get_message())
1421    }
1422}
1423#[cfg(feature = "runtime_documentation")]
1424impl Documented for LLVM_Era {
1425    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1426    fn get_documentation(
1427        &self,
1428    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1429        self.to_unified().get_identifier().get_documentation()
1430    }
1431}
1432#[cfg(feature = "use_anyhow")]
1433impl From<anyhow::Error> for LLVM_Era {
1434    fn from(value: anyhow::Error) -> Self {
1435        let message = format!("{value:#?}");
1436        LLVM_Era::GenericError { message }
1437    }
1438}
1439#[cfg(feature = "packed_errors")]
1440impl From<LLVM_Era> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1441    fn from(value: LLVM_Era) -> Self {
1442        crate::packed::pack(value)
1443    }
1444}
1445#[cfg(feature = "serialized_errors")]
1446impl From<LLVM_Era> for crate::serialized::SerializedError {
1447    fn from(value: LLVM_Era) -> Self {
1448        let packed = crate::packed::pack(value);
1449        crate::serialized::serialize(packed).expect("Internal serialization error.")
1450    }
1451}
1452impl CustomErrorMessage for LLVM_Era {
1453    fn get_message(&self) -> String {
1454        match self {
1455            LLVM_Era::GenericError { message } => {
1456                format!("[compiler-llvm+era-0] Generic error: {message}")
1457            }
1458        }
1459    }
1460}
1461#[doc = "Errors originating in the official Solidity compiler."]
1462#[doc = ""]
1463#[doc = "Domain: Compiler"]
1464#[repr(u32)]
1465#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1466#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1467#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1468#[strum_discriminants(name(SolcCode))]
1469#[strum_discriminants(vis(pub))]
1470#[strum_discriminants(derive(AsRefStr, FromRepr))]
1471#[non_exhaustive]
1472pub enum Solc {
1473    GenericError { message: String } = 0u32,
1474}
1475impl core::error::Error for Solc {}
1476impl NamedError for Solc {
1477    fn get_error_name(&self) -> String {
1478        self.as_ref().to_owned()
1479    }
1480}
1481impl NamedError for SolcCode {
1482    fn get_error_name(&self) -> String {
1483        self.as_ref().to_owned()
1484    }
1485}
1486impl From<Solc> for crate::ZksyncError {
1487    fn from(val: Solc) -> Self {
1488        val.to_unified()
1489    }
1490}
1491impl fmt::Display for Solc {
1492    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1493        f.write_str(&self.get_message())
1494    }
1495}
1496#[cfg(feature = "runtime_documentation")]
1497impl Documented for Solc {
1498    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1499    fn get_documentation(
1500        &self,
1501    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1502        self.to_unified().get_identifier().get_documentation()
1503    }
1504}
1505#[cfg(feature = "use_anyhow")]
1506impl From<anyhow::Error> for Solc {
1507    fn from(value: anyhow::Error) -> Self {
1508        let message = format!("{value:#?}");
1509        Solc::GenericError { message }
1510    }
1511}
1512#[cfg(feature = "packed_errors")]
1513impl From<Solc> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1514    fn from(value: Solc) -> Self {
1515        crate::packed::pack(value)
1516    }
1517}
1518#[cfg(feature = "serialized_errors")]
1519impl From<Solc> for crate::serialized::SerializedError {
1520    fn from(value: Solc) -> Self {
1521        let packed = crate::packed::pack(value);
1522        crate::serialized::serialize(packed).expect("Internal serialization error.")
1523    }
1524}
1525impl CustomErrorMessage for Solc {
1526    fn get_message(&self) -> String {
1527        match self {
1528            Solc::GenericError { message } => {
1529                format!("[compiler-solc-0] Generic error: {message}")
1530            }
1531        }
1532    }
1533}
1534#[doc = "Errors originating in the ZKsync fork of Solidity compiler."]
1535#[doc = ""]
1536#[doc = "Domain: Compiler"]
1537#[repr(u32)]
1538#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1539#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1540#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1541#[strum_discriminants(name(SolcForkCode))]
1542#[strum_discriminants(vis(pub))]
1543#[strum_discriminants(derive(AsRefStr, FromRepr))]
1544#[non_exhaustive]
1545pub enum SolcFork {
1546    GenericError { message: String } = 0u32,
1547}
1548impl core::error::Error for SolcFork {}
1549impl NamedError for SolcFork {
1550    fn get_error_name(&self) -> String {
1551        self.as_ref().to_owned()
1552    }
1553}
1554impl NamedError for SolcForkCode {
1555    fn get_error_name(&self) -> String {
1556        self.as_ref().to_owned()
1557    }
1558}
1559impl From<SolcFork> for crate::ZksyncError {
1560    fn from(val: SolcFork) -> Self {
1561        val.to_unified()
1562    }
1563}
1564impl fmt::Display for SolcFork {
1565    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1566        f.write_str(&self.get_message())
1567    }
1568}
1569#[cfg(feature = "runtime_documentation")]
1570impl Documented for SolcFork {
1571    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1572    fn get_documentation(
1573        &self,
1574    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1575        self.to_unified().get_identifier().get_documentation()
1576    }
1577}
1578#[cfg(feature = "use_anyhow")]
1579impl From<anyhow::Error> for SolcFork {
1580    fn from(value: anyhow::Error) -> Self {
1581        let message = format!("{value:#?}");
1582        SolcFork::GenericError { message }
1583    }
1584}
1585#[cfg(feature = "packed_errors")]
1586impl From<SolcFork> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1587    fn from(value: SolcFork) -> Self {
1588        crate::packed::pack(value)
1589    }
1590}
1591#[cfg(feature = "serialized_errors")]
1592impl From<SolcFork> for crate::serialized::SerializedError {
1593    fn from(value: SolcFork) -> Self {
1594        let packed = crate::packed::pack(value);
1595        crate::serialized::serialize(packed).expect("Internal serialization error.")
1596    }
1597}
1598impl CustomErrorMessage for SolcFork {
1599    fn get_message(&self) -> String {
1600        match self {
1601            SolcFork::GenericError { message } => {
1602                format!("[compiler-solc+fork-0] Generic error: {message}")
1603            }
1604        }
1605    }
1606}
1607#[doc = "Errors originating in the ZKsync Solidity compiler for EraVM and EVM."]
1608#[doc = ""]
1609#[doc = "Domain: Compiler"]
1610#[repr(u32)]
1611#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1612#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1613#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1614#[strum_discriminants(name(ZksolcCode))]
1615#[strum_discriminants(vis(pub))]
1616#[strum_discriminants(derive(AsRefStr, FromRepr))]
1617#[non_exhaustive]
1618pub enum Zksolc {
1619    GenericError { message: String } = 0u32,
1620}
1621impl core::error::Error for Zksolc {}
1622impl NamedError for Zksolc {
1623    fn get_error_name(&self) -> String {
1624        self.as_ref().to_owned()
1625    }
1626}
1627impl NamedError for ZksolcCode {
1628    fn get_error_name(&self) -> String {
1629        self.as_ref().to_owned()
1630    }
1631}
1632impl From<Zksolc> for crate::ZksyncError {
1633    fn from(val: Zksolc) -> Self {
1634        val.to_unified()
1635    }
1636}
1637impl fmt::Display for Zksolc {
1638    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1639        f.write_str(&self.get_message())
1640    }
1641}
1642#[cfg(feature = "runtime_documentation")]
1643impl Documented for Zksolc {
1644    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1645    fn get_documentation(
1646        &self,
1647    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1648        self.to_unified().get_identifier().get_documentation()
1649    }
1650}
1651#[cfg(feature = "use_anyhow")]
1652impl From<anyhow::Error> for Zksolc {
1653    fn from(value: anyhow::Error) -> Self {
1654        let message = format!("{value:#?}");
1655        Zksolc::GenericError { message }
1656    }
1657}
1658#[cfg(feature = "packed_errors")]
1659impl From<Zksolc> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1660    fn from(value: Zksolc) -> Self {
1661        crate::packed::pack(value)
1662    }
1663}
1664#[cfg(feature = "serialized_errors")]
1665impl From<Zksolc> for crate::serialized::SerializedError {
1666    fn from(value: Zksolc) -> Self {
1667        let packed = crate::packed::pack(value);
1668        crate::serialized::serialize(packed).expect("Internal serialization error.")
1669    }
1670}
1671impl CustomErrorMessage for Zksolc {
1672    fn get_message(&self) -> String {
1673        match self {
1674            Zksolc::GenericError { message } => {
1675                format!("[compiler-zksolc-0] Generic error: {message}")
1676            }
1677        }
1678    }
1679}
1680#[doc = "Errors originating in the ZKsync Vyper compiler for EraVM."]
1681#[doc = ""]
1682#[doc = "Domain: Compiler"]
1683#[repr(u32)]
1684#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1685#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1686#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1687#[strum_discriminants(name(ZkvyperCode))]
1688#[strum_discriminants(vis(pub))]
1689#[strum_discriminants(derive(AsRefStr, FromRepr))]
1690#[non_exhaustive]
1691pub enum Zkvyper {
1692    GenericError { message: String } = 0u32,
1693}
1694impl core::error::Error for Zkvyper {}
1695impl NamedError for Zkvyper {
1696    fn get_error_name(&self) -> String {
1697        self.as_ref().to_owned()
1698    }
1699}
1700impl NamedError for ZkvyperCode {
1701    fn get_error_name(&self) -> String {
1702        self.as_ref().to_owned()
1703    }
1704}
1705impl From<Zkvyper> for crate::ZksyncError {
1706    fn from(val: Zkvyper) -> Self {
1707        val.to_unified()
1708    }
1709}
1710impl fmt::Display for Zkvyper {
1711    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1712        f.write_str(&self.get_message())
1713    }
1714}
1715#[cfg(feature = "runtime_documentation")]
1716impl Documented for Zkvyper {
1717    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1718    fn get_documentation(
1719        &self,
1720    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1721        self.to_unified().get_identifier().get_documentation()
1722    }
1723}
1724#[cfg(feature = "use_anyhow")]
1725impl From<anyhow::Error> for Zkvyper {
1726    fn from(value: anyhow::Error) -> Self {
1727        let message = format!("{value:#?}");
1728        Zkvyper::GenericError { message }
1729    }
1730}
1731#[cfg(feature = "packed_errors")]
1732impl From<Zkvyper> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1733    fn from(value: Zkvyper) -> Self {
1734        crate::packed::pack(value)
1735    }
1736}
1737#[cfg(feature = "serialized_errors")]
1738impl From<Zkvyper> for crate::serialized::SerializedError {
1739    fn from(value: Zkvyper) -> Self {
1740        let packed = crate::packed::pack(value);
1741        crate::serialized::serialize(packed).expect("Internal serialization error.")
1742    }
1743}
1744impl CustomErrorMessage for Zkvyper {
1745    fn get_message(&self) -> String {
1746        match self {
1747            Zkvyper::GenericError { message } => {
1748                format!("[compiler-zkvyper-0] Generic error: {message}")
1749            }
1750        }
1751    }
1752}
1753#[doc = "Errors originating in the web3 API."]
1754#[doc = ""]
1755#[doc = "Domain: Core"]
1756#[repr(u32)]
1757#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1758#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1759#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1760#[strum_discriminants(name(APICode))]
1761#[strum_discriminants(vis(pub))]
1762#[strum_discriminants(derive(AsRefStr, FromRepr))]
1763#[non_exhaustive]
1764pub enum API {
1765    GenericError { message: String } = 0u32,
1766}
1767impl core::error::Error for API {}
1768impl NamedError for API {
1769    fn get_error_name(&self) -> String {
1770        self.as_ref().to_owned()
1771    }
1772}
1773impl NamedError for APICode {
1774    fn get_error_name(&self) -> String {
1775        self.as_ref().to_owned()
1776    }
1777}
1778impl From<API> for crate::ZksyncError {
1779    fn from(val: API) -> Self {
1780        val.to_unified()
1781    }
1782}
1783impl fmt::Display for API {
1784    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1785        f.write_str(&self.get_message())
1786    }
1787}
1788#[cfg(feature = "runtime_documentation")]
1789impl Documented for API {
1790    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1791    fn get_documentation(
1792        &self,
1793    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1794        self.to_unified().get_identifier().get_documentation()
1795    }
1796}
1797#[cfg(feature = "use_anyhow")]
1798impl From<anyhow::Error> for API {
1799    fn from(value: anyhow::Error) -> Self {
1800        let message = format!("{value:#?}");
1801        API::GenericError { message }
1802    }
1803}
1804#[cfg(feature = "packed_errors")]
1805impl From<API> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1806    fn from(value: API) -> Self {
1807        crate::packed::pack(value)
1808    }
1809}
1810#[cfg(feature = "serialized_errors")]
1811impl From<API> for crate::serialized::SerializedError {
1812    fn from(value: API) -> Self {
1813        let packed = crate::packed::pack(value);
1814        crate::serialized::serialize(packed).expect("Internal serialization error.")
1815    }
1816}
1817impl CustomErrorMessage for API {
1818    fn get_message(&self) -> String {
1819        match self {
1820            API::GenericError { message } => {
1821                format!("[core-api-0] Generic error: {message}")
1822            }
1823        }
1824    }
1825}
1826#[doc = "Errors in EraVM virtual machine executing contracts."]
1827#[doc = ""]
1828#[doc = "Domain: Core"]
1829#[repr(u32)]
1830#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1831#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1832#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1833#[strum_discriminants(name(EraVMCode))]
1834#[strum_discriminants(vis(pub))]
1835#[strum_discriminants(derive(AsRefStr, FromRepr))]
1836#[non_exhaustive]
1837pub enum EraVM {
1838    GenericError { message: String } = 0u32,
1839}
1840impl core::error::Error for EraVM {}
1841impl NamedError for EraVM {
1842    fn get_error_name(&self) -> String {
1843        self.as_ref().to_owned()
1844    }
1845}
1846impl NamedError for EraVMCode {
1847    fn get_error_name(&self) -> String {
1848        self.as_ref().to_owned()
1849    }
1850}
1851impl From<EraVM> for crate::ZksyncError {
1852    fn from(val: EraVM) -> Self {
1853        val.to_unified()
1854    }
1855}
1856impl fmt::Display for EraVM {
1857    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1858        f.write_str(&self.get_message())
1859    }
1860}
1861#[cfg(feature = "runtime_documentation")]
1862impl Documented for EraVM {
1863    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1864    fn get_documentation(
1865        &self,
1866    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1867        self.to_unified().get_identifier().get_documentation()
1868    }
1869}
1870#[cfg(feature = "use_anyhow")]
1871impl From<anyhow::Error> for EraVM {
1872    fn from(value: anyhow::Error) -> Self {
1873        let message = format!("{value:#?}");
1874        EraVM::GenericError { message }
1875    }
1876}
1877#[cfg(feature = "packed_errors")]
1878impl From<EraVM> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1879    fn from(value: EraVM) -> Self {
1880        crate::packed::pack(value)
1881    }
1882}
1883#[cfg(feature = "serialized_errors")]
1884impl From<EraVM> for crate::serialized::SerializedError {
1885    fn from(value: EraVM) -> Self {
1886        let packed = crate::packed::pack(value);
1887        crate::serialized::serialize(packed).expect("Internal serialization error.")
1888    }
1889}
1890impl CustomErrorMessage for EraVM {
1891    fn get_message(&self) -> String {
1892        match self {
1893            EraVM::GenericError { message } => {
1894                format!("[core-eravm-0] Generic error: {message}")
1895            }
1896        }
1897    }
1898}
1899#[doc = "Errors in the contract execution environment, bootloader, etc."]
1900#[doc = ""]
1901#[doc = "Domain: Core"]
1902#[repr(u32)]
1903#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1904#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1905#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1906#[strum_discriminants(name(ExecutionPlatformCode))]
1907#[strum_discriminants(vis(pub))]
1908#[strum_discriminants(derive(AsRefStr, FromRepr))]
1909#[non_exhaustive]
1910pub enum ExecutionPlatform {
1911    GenericError { message: String } = 0u32,
1912}
1913impl core::error::Error for ExecutionPlatform {}
1914impl NamedError for ExecutionPlatform {
1915    fn get_error_name(&self) -> String {
1916        self.as_ref().to_owned()
1917    }
1918}
1919impl NamedError for ExecutionPlatformCode {
1920    fn get_error_name(&self) -> String {
1921        self.as_ref().to_owned()
1922    }
1923}
1924impl From<ExecutionPlatform> for crate::ZksyncError {
1925    fn from(val: ExecutionPlatform) -> Self {
1926        val.to_unified()
1927    }
1928}
1929impl fmt::Display for ExecutionPlatform {
1930    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1931        f.write_str(&self.get_message())
1932    }
1933}
1934#[cfg(feature = "runtime_documentation")]
1935impl Documented for ExecutionPlatform {
1936    type Documentation = &'static zksync_error_description::ErrorDocumentation;
1937    fn get_documentation(
1938        &self,
1939    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
1940        self.to_unified().get_identifier().get_documentation()
1941    }
1942}
1943#[cfg(feature = "use_anyhow")]
1944impl From<anyhow::Error> for ExecutionPlatform {
1945    fn from(value: anyhow::Error) -> Self {
1946        let message = format!("{value:#?}");
1947        ExecutionPlatform::GenericError { message }
1948    }
1949}
1950#[cfg(feature = "packed_errors")]
1951impl From<ExecutionPlatform> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
1952    fn from(value: ExecutionPlatform) -> Self {
1953        crate::packed::pack(value)
1954    }
1955}
1956#[cfg(feature = "serialized_errors")]
1957impl From<ExecutionPlatform> for crate::serialized::SerializedError {
1958    fn from(value: ExecutionPlatform) -> Self {
1959        let packed = crate::packed::pack(value);
1960        crate::serialized::serialize(packed).expect("Internal serialization error.")
1961    }
1962}
1963impl CustomErrorMessage for ExecutionPlatform {
1964    fn get_message(&self) -> String {
1965        match self {
1966            ExecutionPlatform::GenericError { message } => {
1967                format!("[core-exec-0] Generic error: {message}")
1968            }
1969        }
1970    }
1971}
1972#[doc = "Errors in the sequencer node"]
1973#[doc = ""]
1974#[doc = "Domain: Core"]
1975#[repr(u32)]
1976#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
1977#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
1978#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
1979#[strum_discriminants(name(SequencerCode))]
1980#[strum_discriminants(vis(pub))]
1981#[strum_discriminants(derive(AsRefStr, FromRepr))]
1982#[non_exhaustive]
1983pub enum Sequencer {
1984    GenericSequencerError { message: String } = 1u32,
1985    GenericError { message: String } = 0u32,
1986}
1987impl core::error::Error for Sequencer {}
1988impl NamedError for Sequencer {
1989    fn get_error_name(&self) -> String {
1990        self.as_ref().to_owned()
1991    }
1992}
1993impl NamedError for SequencerCode {
1994    fn get_error_name(&self) -> String {
1995        self.as_ref().to_owned()
1996    }
1997}
1998impl From<Sequencer> for crate::ZksyncError {
1999    fn from(val: Sequencer) -> Self {
2000        val.to_unified()
2001    }
2002}
2003impl fmt::Display for Sequencer {
2004    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2005        f.write_str(&self.get_message())
2006    }
2007}
2008#[cfg(feature = "runtime_documentation")]
2009impl Documented for Sequencer {
2010    type Documentation = &'static zksync_error_description::ErrorDocumentation;
2011    fn get_documentation(
2012        &self,
2013    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
2014        self.to_unified().get_identifier().get_documentation()
2015    }
2016}
2017#[cfg(feature = "use_anyhow")]
2018impl From<anyhow::Error> for Sequencer {
2019    fn from(value: anyhow::Error) -> Self {
2020        let message = format!("{value:#?}");
2021        Sequencer::GenericError { message }
2022    }
2023}
2024#[cfg(feature = "packed_errors")]
2025impl From<Sequencer> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
2026    fn from(value: Sequencer) -> Self {
2027        crate::packed::pack(value)
2028    }
2029}
2030#[cfg(feature = "serialized_errors")]
2031impl From<Sequencer> for crate::serialized::SerializedError {
2032    fn from(value: Sequencer) -> Self {
2033        let packed = crate::packed::pack(value);
2034        crate::serialized::serialize(packed).expect("Internal serialization error.")
2035    }
2036}
2037impl CustomErrorMessage for Sequencer {
2038    fn get_message(&self) -> String {
2039        match self {
2040            Sequencer::GenericSequencerError { message } => {
2041                format!("[core-seq-1] Generic error: {message}")
2042            }
2043            Sequencer::GenericError { message } => {
2044                format!("[core-seq-0] Generic error: {message}")
2045            }
2046        }
2047    }
2048}
2049#[doc = "Errors originating in the upstream Foundry implementation."]
2050#[doc = ""]
2051#[doc = "Domain: Foundry"]
2052#[repr(u32)]
2053#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
2054#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
2055#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
2056#[strum_discriminants(name(FoundryUpstreamCode))]
2057#[strum_discriminants(vis(pub))]
2058#[strum_discriminants(derive(AsRefStr, FromRepr))]
2059#[non_exhaustive]
2060pub enum FoundryUpstream {
2061    GenericError { message: String } = 0u32,
2062}
2063impl core::error::Error for FoundryUpstream {}
2064impl NamedError for FoundryUpstream {
2065    fn get_error_name(&self) -> String {
2066        self.as_ref().to_owned()
2067    }
2068}
2069impl NamedError for FoundryUpstreamCode {
2070    fn get_error_name(&self) -> String {
2071        self.as_ref().to_owned()
2072    }
2073}
2074impl From<FoundryUpstream> for crate::ZksyncError {
2075    fn from(val: FoundryUpstream) -> Self {
2076        val.to_unified()
2077    }
2078}
2079impl fmt::Display for FoundryUpstream {
2080    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2081        f.write_str(&self.get_message())
2082    }
2083}
2084#[cfg(feature = "runtime_documentation")]
2085impl Documented for FoundryUpstream {
2086    type Documentation = &'static zksync_error_description::ErrorDocumentation;
2087    fn get_documentation(
2088        &self,
2089    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
2090        self.to_unified().get_identifier().get_documentation()
2091    }
2092}
2093#[cfg(feature = "use_anyhow")]
2094impl From<anyhow::Error> for FoundryUpstream {
2095    fn from(value: anyhow::Error) -> Self {
2096        let message = format!("{value:#?}");
2097        FoundryUpstream::GenericError { message }
2098    }
2099}
2100#[cfg(feature = "packed_errors")]
2101impl From<FoundryUpstream> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
2102    fn from(value: FoundryUpstream) -> Self {
2103        crate::packed::pack(value)
2104    }
2105}
2106#[cfg(feature = "serialized_errors")]
2107impl From<FoundryUpstream> for crate::serialized::SerializedError {
2108    fn from(value: FoundryUpstream) -> Self {
2109        let packed = crate::packed::pack(value);
2110        crate::serialized::serialize(packed).expect("Internal serialization error.")
2111    }
2112}
2113impl CustomErrorMessage for FoundryUpstream {
2114    fn get_message(&self) -> String {
2115        match self {
2116            FoundryUpstream::GenericError { message } => {
2117                format!("[foundry-upstream-0] Generic error: {message}")
2118            }
2119        }
2120    }
2121}
2122#[doc = "Errors originating in the ZKsync codebase for Foundry."]
2123#[doc = ""]
2124#[doc = "Domain: Foundry"]
2125#[repr(u32)]
2126#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
2127#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
2128#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
2129#[strum_discriminants(name(FoundryZksyncCode))]
2130#[strum_discriminants(vis(pub))]
2131#[strum_discriminants(derive(AsRefStr, FromRepr))]
2132#[non_exhaustive]
2133pub enum FoundryZksync {
2134    GenericError { message: String } = 0u32,
2135}
2136impl core::error::Error for FoundryZksync {}
2137impl NamedError for FoundryZksync {
2138    fn get_error_name(&self) -> String {
2139        self.as_ref().to_owned()
2140    }
2141}
2142impl NamedError for FoundryZksyncCode {
2143    fn get_error_name(&self) -> String {
2144        self.as_ref().to_owned()
2145    }
2146}
2147impl From<FoundryZksync> for crate::ZksyncError {
2148    fn from(val: FoundryZksync) -> Self {
2149        val.to_unified()
2150    }
2151}
2152impl fmt::Display for FoundryZksync {
2153    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2154        f.write_str(&self.get_message())
2155    }
2156}
2157#[cfg(feature = "runtime_documentation")]
2158impl Documented for FoundryZksync {
2159    type Documentation = &'static zksync_error_description::ErrorDocumentation;
2160    fn get_documentation(
2161        &self,
2162    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
2163        self.to_unified().get_identifier().get_documentation()
2164    }
2165}
2166#[cfg(feature = "use_anyhow")]
2167impl From<anyhow::Error> for FoundryZksync {
2168    fn from(value: anyhow::Error) -> Self {
2169        let message = format!("{value:#?}");
2170        FoundryZksync::GenericError { message }
2171    }
2172}
2173#[cfg(feature = "packed_errors")]
2174impl From<FoundryZksync> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
2175    fn from(value: FoundryZksync) -> Self {
2176        crate::packed::pack(value)
2177    }
2178}
2179#[cfg(feature = "serialized_errors")]
2180impl From<FoundryZksync> for crate::serialized::SerializedError {
2181    fn from(value: FoundryZksync) -> Self {
2182        let packed = crate::packed::pack(value);
2183        crate::serialized::serialize(packed).expect("Internal serialization error.")
2184    }
2185}
2186impl CustomErrorMessage for FoundryZksync {
2187    fn get_message(&self) -> String {
2188        match self {
2189            FoundryZksync::GenericError { message } => {
2190                format!("[foundry-zksync-0] Generic error: {message}")
2191            }
2192        }
2193    }
2194}
2195#[doc = "Errors originating in the upstream Hardhat implementation."]
2196#[doc = ""]
2197#[doc = "Domain: Hardhat"]
2198#[repr(u32)]
2199#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
2200#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
2201#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
2202#[strum_discriminants(name(HardhatUpstreamCode))]
2203#[strum_discriminants(vis(pub))]
2204#[strum_discriminants(derive(AsRefStr, FromRepr))]
2205#[non_exhaustive]
2206pub enum HardhatUpstream {
2207    GenericError { message: String } = 0u32,
2208}
2209impl core::error::Error for HardhatUpstream {}
2210impl NamedError for HardhatUpstream {
2211    fn get_error_name(&self) -> String {
2212        self.as_ref().to_owned()
2213    }
2214}
2215impl NamedError for HardhatUpstreamCode {
2216    fn get_error_name(&self) -> String {
2217        self.as_ref().to_owned()
2218    }
2219}
2220impl From<HardhatUpstream> for crate::ZksyncError {
2221    fn from(val: HardhatUpstream) -> Self {
2222        val.to_unified()
2223    }
2224}
2225impl fmt::Display for HardhatUpstream {
2226    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2227        f.write_str(&self.get_message())
2228    }
2229}
2230#[cfg(feature = "runtime_documentation")]
2231impl Documented for HardhatUpstream {
2232    type Documentation = &'static zksync_error_description::ErrorDocumentation;
2233    fn get_documentation(
2234        &self,
2235    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
2236        self.to_unified().get_identifier().get_documentation()
2237    }
2238}
2239#[cfg(feature = "use_anyhow")]
2240impl From<anyhow::Error> for HardhatUpstream {
2241    fn from(value: anyhow::Error) -> Self {
2242        let message = format!("{value:#?}");
2243        HardhatUpstream::GenericError { message }
2244    }
2245}
2246#[cfg(feature = "packed_errors")]
2247impl From<HardhatUpstream> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
2248    fn from(value: HardhatUpstream) -> Self {
2249        crate::packed::pack(value)
2250    }
2251}
2252#[cfg(feature = "serialized_errors")]
2253impl From<HardhatUpstream> for crate::serialized::SerializedError {
2254    fn from(value: HardhatUpstream) -> Self {
2255        let packed = crate::packed::pack(value);
2256        crate::serialized::serialize(packed).expect("Internal serialization error.")
2257    }
2258}
2259impl CustomErrorMessage for HardhatUpstream {
2260    fn get_message(&self) -> String {
2261        match self {
2262            HardhatUpstream::GenericError { message } => {
2263                format!("[hardhat-upstream-0] Generic error: {message}")
2264            }
2265        }
2266    }
2267}
2268#[doc = "Errors originating in the ZKsync codebase for HardHat."]
2269#[doc = ""]
2270#[doc = "Domain: Hardhat"]
2271#[repr(u32)]
2272#[derive(AsRefStr, Clone, Debug, Eq, EnumDiscriminants, PartialEq)]
2273#[cfg_attr(feature = "use_serde", derive(serde::Serialize))]
2274#[cfg_attr(feature = "use_serde", derive(serde::Deserialize))]
2275#[strum_discriminants(name(HardhatZksyncCode))]
2276#[strum_discriminants(vis(pub))]
2277#[strum_discriminants(derive(AsRefStr, FromRepr))]
2278#[non_exhaustive]
2279pub enum HardhatZksync {
2280    GenericError { message: String } = 0u32,
2281}
2282impl core::error::Error for HardhatZksync {}
2283impl NamedError for HardhatZksync {
2284    fn get_error_name(&self) -> String {
2285        self.as_ref().to_owned()
2286    }
2287}
2288impl NamedError for HardhatZksyncCode {
2289    fn get_error_name(&self) -> String {
2290        self.as_ref().to_owned()
2291    }
2292}
2293impl From<HardhatZksync> for crate::ZksyncError {
2294    fn from(val: HardhatZksync) -> Self {
2295        val.to_unified()
2296    }
2297}
2298impl fmt::Display for HardhatZksync {
2299    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2300        f.write_str(&self.get_message())
2301    }
2302}
2303#[cfg(feature = "runtime_documentation")]
2304impl Documented for HardhatZksync {
2305    type Documentation = &'static zksync_error_description::ErrorDocumentation;
2306    fn get_documentation(
2307        &self,
2308    ) -> Result<Option<Self::Documentation>, crate::documentation::DocumentationError> {
2309        self.to_unified().get_identifier().get_documentation()
2310    }
2311}
2312#[cfg(feature = "use_anyhow")]
2313impl From<anyhow::Error> for HardhatZksync {
2314    fn from(value: anyhow::Error) -> Self {
2315        let message = format!("{value:#?}");
2316        HardhatZksync::GenericError { message }
2317    }
2318}
2319#[cfg(feature = "packed_errors")]
2320impl From<HardhatZksync> for crate::packed::PackedError<crate::error::domains::ZksyncError> {
2321    fn from(value: HardhatZksync) -> Self {
2322        crate::packed::pack(value)
2323    }
2324}
2325#[cfg(feature = "serialized_errors")]
2326impl From<HardhatZksync> for crate::serialized::SerializedError {
2327    fn from(value: HardhatZksync) -> Self {
2328        let packed = crate::packed::pack(value);
2329        crate::serialized::serialize(packed).expect("Internal serialization error.")
2330    }
2331}
2332impl CustomErrorMessage for HardhatZksync {
2333    fn get_message(&self) -> String {
2334        match self {
2335            HardhatZksync::GenericError { message } => {
2336                format!("[hardhat-zksync-0] Generic error: {message}")
2337            }
2338        }
2339    }
2340}