Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions crates/revm/src/context/inner_evm_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{
},
journaled_state::JournaledState,
primitives::{
AccessListItem, Account, Address, AnalysisKind, Bytecode, Bytes, EVMError, Env, Eof,
HashSet, Spec,
AccessListItem, Account, Address, AnalysisKind, Bytecode, Bytes, CfgEnv, EVMError, Env,
Eof, HashSet, Spec,
SpecId::{self, *},
B256, EOF_MAGIC_BYTES, EOF_MAGIC_HASH, U256,
},
Expand Down Expand Up @@ -125,6 +125,11 @@ impl<DB: Database> InnerEvmContext<DB> {
&mut self.env
}

/// Returns referecne to [`CfgEnv`].
pub fn cfg(&self) -> &CfgEnv {
&self.env.cfg
}

/// Returns the error by replacing it with `Ok(())`, if any.
#[inline]
pub fn take_error(&mut self) -> Result<(), EVMError<DB::Error>> {
Expand Down Expand Up @@ -271,7 +276,8 @@ impl<DB: Database> InnerEvmContext<DB> {
return;
}

if interpreter_result.output.len() > MAX_CODE_SIZE {
let max_code_size = self.cfg().limit_contract_code_size.unwrap_or(MAX_CODE_SIZE);
if interpreter_result.output.len() > max_code_size {
self.journaled_state.checkpoint_revert(journal_checkpoint);
interpreter_result.result = InstructionResult::CreateContractSizeLimit;
return;
Expand Down Expand Up @@ -340,14 +346,8 @@ impl<DB: Database> InnerEvmContext<DB> {

// EIP-170: Contract code size limit
// By default limit is 0x6000 (~25kb)
if SPEC::enabled(SPURIOUS_DRAGON)
&& interpreter_result.output.len()
> self
.env
.cfg
.limit_contract_code_size
.unwrap_or(MAX_CODE_SIZE)
{
let max_code_size = self.cfg().limit_contract_code_size.unwrap_or(MAX_CODE_SIZE);
if SPEC::enabled(SPURIOUS_DRAGON) && interpreter_result.output.len() > max_code_size {
self.journaled_state.checkpoint_revert(journal_checkpoint);
interpreter_result.result = InstructionResult::CreateContractSizeLimit;
return;
Expand Down