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