File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 19
19
BlockchainTestFiller ,
20
20
Bytecode ,
21
21
Environment ,
22
+ StateTestFiller ,
22
23
Transaction ,
23
24
)
24
25
from ethereum_test_tools .code .generators import While
@@ -955,3 +956,40 @@ def test_empty_block(
955
956
post = {},
956
957
blocks = [Block (txs = [])],
957
958
)
959
+
960
+
961
+ @pytest .mark .valid_from ("Cancun" )
962
+ @pytest .mark .parametrize (
963
+ "empty_calldata" ,
964
+ [False , True ],
965
+ )
966
+ def test_worst_calldataload (
967
+ state_test : StateTestFiller ,
968
+ pre : Alloc ,
969
+ fork : Fork ,
970
+ empty_calldata : bool ,
971
+ ):
972
+ """Test running a block with as many CALLDATALOAD as possible."""
973
+ env = Environment ()
974
+
975
+ code_prefix = Op .JUMPDEST
976
+ code_suffix = Op .PUSH0 + Op .JUMP
977
+ code_body_len = MAX_CODE_SIZE - len (code_prefix ) - len (code_suffix )
978
+ code_loop_iter = Op .POP (Op .PUSH0 + Op .CALLDATALOAD )
979
+ code_body = code_loop_iter * (code_body_len // len (code_loop_iter ))
980
+ code = code_prefix + code_body + code_suffix
981
+ assert len (code ) == MAX_CODE_SIZE
982
+
983
+ tx = Transaction (
984
+ to = pre .deploy_contract (code = code ),
985
+ data = [] if empty_calldata else [0x42 ] * 32 ,
986
+ gas_limit = env .gas_limit ,
987
+ sender = pre .fund_eoa (),
988
+ )
989
+
990
+ state_test (
991
+ env = env ,
992
+ pre = pre ,
993
+ post = {},
994
+ tx = tx ,
995
+ )
You can’t perform that action at this time.
0 commit comments