Skip to content

Commit

Permalink
Make some VM errors non-exhaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
slowli committed Aug 12, 2024
1 parent e11bafd commit b86a6bf
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/lib/multivm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies] # FIXME: revise
[dependencies]
zk_evm_1_5_0.workspace = true
zk_evm_1_4_1.workspace = true
zk_evm_1_4_0.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions core/lib/vm_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ categories.workspace = true
[dependencies]
zksync_contracts.workspace = true
zksync_system_constants.workspace = true
zksync_types.workspace = true # FIXME: move VM-related types? (e.g., VM events, circuit stats)
zksync_utils.workspace = true # FIXME: move VM-related types? (e.g., compressed bytecodes)
zksync_types.workspace = true
zksync_utils.workspace = true

hex.workspace = true
serde.workspace = true
Expand Down
1 change: 1 addition & 0 deletions core/lib/vm_interface/src/types/errors/bootloader_error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Error codes returned by the bootloader.
#[derive(Debug)]
#[non_exhaustive]
pub enum BootloaderErrorCode {
EthCall,
AccountTxValidationFailed,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Errors related to bytecode compression.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum BytecodeCompressionError {
#[error("Bytecode compression failed")]
BytecodeCompressionFailed,
Expand Down
2 changes: 0 additions & 2 deletions core/lib/vm_interface/src/types/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ mod bytecode_compression;
mod halt;
mod tx_revert_reason;
mod vm_revert_reason;

// FIXME: make errors non-exhaustive?
5 changes: 2 additions & 3 deletions core/lib/vm_interface/src/types/errors/tx_revert_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use super::{halt::Halt, BootloaderErrorCode, VmRevertReason};

#[derive(Debug, Clone, PartialEq)]
pub enum TxRevertReason {
// Returned when the execution of an L2 transaction has failed
// Or EthCall has failed
/// Returned when the execution of an L2 transaction or a call has failed.
TxReverted(VmRevertReason),
// Returned when some validation has failed or some internal errors
/// Returned when some validation has failed or some internal errors.
Halt(Halt),
}

Expand Down
2 changes: 2 additions & 0 deletions core/lib/vm_interface/src/types/errors/vm_revert_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt;
use zksync_types::U256;

#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum VmRevertReasonParsingError {
#[error("Incorrect data offset. Data: {0:?}")]
IncorrectDataOffset(Vec<u8>),
Expand All @@ -14,6 +15,7 @@ pub enum VmRevertReasonParsingError {

/// Rich Revert Reasons `https://github.com/0xProject/ZEIPs/issues/32`
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum VmRevertReason {
General {
msg: String,
Expand Down
2 changes: 1 addition & 1 deletion core/node/state_keeper/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn vm_revert_reason_as_metric_label(reason: &VmRevertReason) -> &'static str {
VmRevertReason::General { .. } => "General",
VmRevertReason::InnerTxError => "InnerTxError",
VmRevertReason::VmError => "VmError",
VmRevertReason::Unknown { .. } => "Unknown",
_ => "Unknown",
}
}

Expand Down

0 comments on commit b86a6bf

Please sign in to comment.