From e40360670cd223f52b4b79eb94ff607e2a3a1c33 Mon Sep 17 00:00:00 2001 From: debjit Date: Fri, 3 Jan 2025 17:23:34 +0530 Subject: [PATCH] contract code size limit change --- src/evm_config.rs | 10 ++++++++-- src/execute.rs | 11 ++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/evm_config.rs b/src/evm_config.rs index a9a3b6c..2af0e0a 100644 --- a/src/evm_config.rs +++ b/src/evm_config.rs @@ -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}; @@ -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); diff --git a/src/execute.rs b/src/execute.rs index 2b49333..cb98fa8 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -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, @@ -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);