Skip to content

Commit

Permalink
Refactore ExitFatal (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD authored Jul 17, 2024
1 parent a5bbed7 commit f3bf275
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ pub enum ExitError {
/// https://eips.ethereum.org/EIPS/eip-2681
#[cfg_attr(feature = "with-codec", codec(index = 14))]
MaxNonce,

/// `usize` casting overflow
#[cfg_attr(feature = "with-codec", codec(index = 15))]
UsizeOverflow,
}

impl From<ExitError> for ExitReason {
Expand All @@ -182,8 +186,6 @@ impl From<ExitError> for ExitReason {
pub enum ExitFatal {
/// The operation is not supported.
NotSupported,
/// `usize` casting overflow
UsizeOverflow,
/// The trap (interrupt) is unhandled.
UnhandledInterrupt,
/// The environment explicitly set call errors as fatal error.
Expand Down
2 changes: 1 addition & 1 deletion core/src/eval/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ macro_rules! op3_u256_fn {
macro_rules! as_usize_or_fail {
( $v:expr ) => {{
if $v > crate::utils::USIZE_MAX {
return Control::Exit(ExitFatal::UsizeOverflow.into());
return Control::Exit(ExitError::UsizeOverflow.into());
}

$v.as_usize()
Expand Down
2 changes: 1 addition & 1 deletion core/src/eval/misc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::Control;

use crate::utils::USIZE_MAX;
use crate::{ExitError, ExitFatal, ExitRevert, ExitSucceed, Machine};
use crate::{ExitError, ExitRevert, ExitSucceed, Machine};
use core::cmp::min;
use primitive_types::{H256, U256};

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/eval/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ macro_rules! push_u256 {
macro_rules! as_usize_or_fail {
( $v:expr ) => {{
if $v > crate::utils::USIZE_MAX {
return Control::Exit(ExitFatal::UsizeOverflow.into());
return Control::Exit(ExitError::UsizeOverflow.into());
}

$v.as_usize()
Expand Down
3 changes: 1 addition & 2 deletions runtime/src/eval/system.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use super::Control;
use crate::prelude::*;
use crate::{
CallScheme, Capture, Context, CreateScheme, ExitError, ExitFatal, ExitSucceed, Handler,
Runtime, Transfer,
CallScheme, Capture, Context, CreateScheme, ExitError, ExitSucceed, Handler, Runtime, Transfer,
};
use core::cmp::max;
use evm_core::utils::{U64_MAX, USIZE_MAX};
Expand Down

0 comments on commit f3bf275

Please sign in to comment.