3636CONTRACT_START_ADDRESS_DEFAULT = 0x1000000000000000000000000000000000001000
3737CONTRACT_ADDRESS_INCREMENTS_DEFAULT = 0x100
3838
39- MAX_BYTECODE_SIZE = 24576
40-
4139
4240def pytest_addoption (parser : pytest .Parser ):
4341 """Add command-line options to pytest."""
@@ -98,13 +96,15 @@ class Alloc(BaseAlloc):
9896 _contract_address_iterator : Iterator [Address ] = PrivateAttr ()
9997 _eoa_iterator : Iterator [EOA ] = PrivateAttr ()
10098 _evm_code_type : EVMCodeType | None = PrivateAttr (None )
99+ _fork : Fork = PrivateAttr ()
101100
102101 def __init__ (
103102 self ,
104103 * args ,
105104 alloc_mode : AllocMode ,
106105 contract_address_iterator : Iterator [Address ],
107106 eoa_iterator : Iterator [EOA ],
107+ fork : Fork ,
108108 evm_code_type : EVMCodeType | None = None ,
109109 ** kwargs ,
110110 ):
@@ -114,6 +114,7 @@ def __init__(
114114 self ._contract_address_iterator = contract_address_iterator
115115 self ._eoa_iterator = eoa_iterator
116116 self ._evm_code_type = evm_code_type
117+ self ._fork = fork
117118
118119 def __setitem__ (self , address : Address | FixedSizeBytesConvertible , account : Account | None ):
119120 """Set account associated with an address."""
@@ -166,8 +167,9 @@ def deploy_contract(
166167
167168 code = self .code_pre_processor (code , evm_code_type = evm_code_type )
168169 code_bytes = bytes (code ) if not isinstance (code , (bytes , str )) else code
169- assert len (code_bytes ) <= MAX_BYTECODE_SIZE , (
170- f"code too large: { len (code_bytes )} > { MAX_BYTECODE_SIZE } "
170+ max_code_size = self ._fork .max_code_size ()
171+ assert len (code_bytes ) <= max_code_size , (
172+ f"code too large: { len (code_bytes )} > { max_code_size } "
171173 )
172174
173175 super ().__setitem__ (
@@ -424,11 +426,13 @@ def pre(
424426 contract_address_iterator : Iterator [Address ],
425427 eoa_iterator : Iterator [EOA ],
426428 evm_code_type : EVMCodeType ,
429+ fork : Fork ,
427430) -> Alloc :
428431 """Return default pre allocation for all tests (Empty alloc)."""
429432 return Alloc (
430433 alloc_mode = alloc_mode ,
431434 contract_address_iterator = contract_address_iterator ,
432435 eoa_iterator = eoa_iterator ,
436+ fork = fork ,
433437 evm_code_type = evm_code_type ,
434438 )
0 commit comments