Skip to content

Commit

Permalink
contract code size limit change
Browse files Browse the repository at this point in the history
  • Loading branch information
debjit-bw committed Jan 3, 2025
1 parent e4525bd commit e403606
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/evm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use alloy_consensus::Header;
use alloy_primitives::{Address, U256};
use reth::revm::{inspector_handle_register, Database, GetInspector};
use reth::revm::{Evm, EvmBuilder};
use reth_chainspec::{ChainSpec, Head};
use reth_chainspec::{ChainSpec, EthereumHardforks, Head};
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_evm_ethereum::{revm_spec, revm_spec_by_timestamp_after_merge};
use reth_primitives::{transaction::FillTxEnv, TransactionSigned};
Expand Down Expand Up @@ -192,7 +192,13 @@ impl ConfigureEvmEnv for GnosisEvmConfig {
attributes: reth_evm::NextBlockEnvAttributes,
) -> Result<(CfgEnvWithHandlerCfg, BlockEnv), Self::Error> {
// configure evm env based on parent block
let cfg = CfgEnv::default().with_chain_id(self.chain_spec.chain().id());
let mut cfg = CfgEnv::default().with_chain_id(self.chain_spec.chain().id());
if !self
.chain_spec
.is_shanghai_active_at_timestamp(attributes.timestamp)
{
cfg.limit_contract_code_size = Some(usize::MAX);
}

// ensure we're not missing any timestamp based hardforks
let spec_id = revm_spec_by_timestamp_after_merge(&self.chain_spec, attributes.timestamp);
Expand Down
11 changes: 10 additions & 1 deletion src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use reth_node_ethereum::BasicBlockExecutorProvider;
use reth_primitives::EthPrimitives;
use reth_primitives::{BlockWithSenders, Receipt};
use reth_revm::db::State;
use revm_primitives::CfgEnv;
use revm_primitives::{
db::{Database, DatabaseCommit},
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, U256,
Expand Down Expand Up @@ -140,7 +141,15 @@ where
///
/// Caution: this does not initialize the tx environment.
fn evm_env_for_block(&self, header: &Header, total_difficulty: U256) -> EnvWithHandlerCfg {
let mut cfg = CfgEnvWithHandlerCfg::new(Default::default(), Default::default());
let mut cfg_env = CfgEnv::default().with_chain_id(self.chain_spec.chain().id());
if !self
.chain_spec
.is_shanghai_active_at_timestamp(header.timestamp)
{
cfg_env.limit_contract_code_size = Some(usize::MAX);
}

let mut cfg = CfgEnvWithHandlerCfg::new(cfg_env, Default::default());
let mut block_env = BlockEnv::default();
self.evm_config
.fill_cfg_and_block_env(&mut cfg, &mut block_env, header, total_difficulty);
Expand Down

0 comments on commit e403606

Please sign in to comment.