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