@pytest.mark.valid_from("Cancun")deftest_worst_modexp(blockchain_test:BlockchainTestFiller,pre:Alloc,fork:Fork,):"""Test running a block with as many MODEXP calls as possible."""env=Environment()base_mod_length=32exp_length=32base=2**(8*base_mod_length)-1mod=2**(8*base_mod_length)-2# Prevents base == modexp=2**(8*exp_length)-1# MODEXP calldatacalldata=(Op.MSTORE(0*32,base_mod_length)+Op.MSTORE(1*32,exp_length)+Op.MSTORE(2*32,base_mod_length)+Op.MSTORE(3*32,base)+Op.MSTORE(4*32,exp)+Op.MSTORE(5*32,mod))# EIP-2565mul_complexity=math.ceil(base_mod_length/8)**2iter_complexity=exp.bit_length()-1gas_cost=math.floor((mul_complexity*iter_complexity)/3)attack_block=Op.POP(Op.STATICCALL(gas_cost,0x5,0,32*6,0,0))code=code_loop_precompile_call(calldata,attack_block)code_address=pre.deploy_contract(code=code)tx=Transaction(to=code_address,gas_limit=env.gas_limit,sender=pre.fund_eoa(),)blockchain_test(env=env,pre=pre,post={},blocks=[Block(txs=[tx])],)