Skip to content

Commit

Permalink
fix: double substate discard in eip-3860 (#160)
Browse files Browse the repository at this point in the history
* fix: double substate discard in eip-3860

* fix: use CreateContractLimit error for initcode limit violation
  • Loading branch information
vimpunk authored Apr 18, 2023
1 parent 5fb8a49 commit b436a7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
4 changes: 0 additions & 4 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ pub enum ExitError {
/// Other normal errors.
#[cfg_attr(feature = "with-codec", codec(index = 13))]
Other(Cow<'static, str>),

/// Init code exceeds limit (runtime).
#[cfg_attr(feature = "with-codec", codec(index = 7))]
InitCodeLimit,
}

impl From<ExitError> for ExitReason {
Expand Down
7 changes: 3 additions & 4 deletions src/executor/stack/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
// EIP-3860
if init_code.len() > limit {
self.state.metadata_mut().gasometer.fail();
let _ = self.exit_substate(StackExitKind::Failed);
return Err(ExitError::OutOfGas);
return Err(ExitError::CreateContractLimit);
}
return self
.state
Expand Down Expand Up @@ -437,7 +436,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
if init_code.len() > limit {
self.state.metadata_mut().gasometer.fail();
let _ = self.exit_substate(StackExitKind::Failed);
return emit_exit!(ExitError::InitCodeLimit.into(), Vec::new());
return emit_exit!(ExitError::CreateContractLimit.into(), Vec::new());
}
}

Expand Down Expand Up @@ -478,7 +477,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
if init_code.len() > limit {
self.state.metadata_mut().gasometer.fail();
let _ = self.exit_substate(StackExitKind::Failed);
return emit_exit!(ExitError::InitCodeLimit.into(), Vec::new());
return emit_exit!(ExitError::CreateContractLimit.into(), Vec::new());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/executor/stack/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ impl<'config> MemoryStackSubstate<'config> {
&mut self.metadata
}

/// Deconstruct the executor, return state to be applied. Panic if the
/// executor is not in the top-level substate.
/// Deconstruct the memory stack substate, return state to be applied. Panic if the
/// substate is not in the top-level substate.
#[must_use]
pub fn deconstruct<B: Backend>(
mut self,
Expand Down
3 changes: 2 additions & 1 deletion src/executor/stack/precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ pub trait PrecompileHandle {
}

/// A set of precompiles.
/// Checks of the provided address being in the precompile set should be
///
/// Checks if the provided address is in the precompile set. This should be
/// as cheap as possible since it may be called often.
pub trait PrecompileSet {
/// Tries to execute a precompile in the precompile set.
Expand Down

0 comments on commit b436a7f

Please sign in to comment.