@@ -1706,3 +1706,74 @@ def test_worst_calldataload(
1706
1706
post = {},
1707
1707
tx = tx ,
1708
1708
)
1709
+
1710
+
1711
+ @pytest .mark .parametrize (
1712
+ "opcode" ,
1713
+ [
1714
+ pytest .param (Op .PUSH0 , id = "PUSH0" ),
1715
+ pytest .param (Op .PUSH1 , id = "PUSH1" ),
1716
+ pytest .param (Op .PUSH2 , id = "PUSH2" ),
1717
+ pytest .param (Op .PUSH3 , id = "PUSH3" ),
1718
+ pytest .param (Op .PUSH4 , id = "PUSH4" ),
1719
+ pytest .param (Op .PUSH5 , id = "PUSH5" ),
1720
+ pytest .param (Op .PUSH6 , id = "PUSH6" ),
1721
+ pytest .param (Op .PUSH7 , id = "PUSH7" ),
1722
+ pytest .param (Op .PUSH8 , id = "PUSH8" ),
1723
+ pytest .param (Op .PUSH9 , id = "PUSH9" ),
1724
+ pytest .param (Op .PUSH10 , id = "PUSH10" ),
1725
+ pytest .param (Op .PUSH11 , id = "PUSH11" ),
1726
+ pytest .param (Op .PUSH12 , id = "PUSH12" ),
1727
+ pytest .param (Op .PUSH13 , id = "PUSH13" ),
1728
+ pytest .param (Op .PUSH14 , id = "PUSH14" ),
1729
+ pytest .param (Op .PUSH15 , id = "PUSH15" ),
1730
+ pytest .param (Op .PUSH16 , id = "PUSH16" ),
1731
+ pytest .param (Op .PUSH17 , id = "PUSH17" ),
1732
+ pytest .param (Op .PUSH18 , id = "PUSH18" ),
1733
+ pytest .param (Op .PUSH19 , id = "PUSH19" ),
1734
+ pytest .param (Op .PUSH20 , id = "PUSH20" ),
1735
+ pytest .param (Op .PUSH21 , id = "PUSH21" ),
1736
+ pytest .param (Op .PUSH22 , id = "PUSH22" ),
1737
+ pytest .param (Op .PUSH23 , id = "PUSH23" ),
1738
+ pytest .param (Op .PUSH24 , id = "PUSH24" ),
1739
+ pytest .param (Op .PUSH25 , id = "PUSH25" ),
1740
+ pytest .param (Op .PUSH26 , id = "PUSH26" ),
1741
+ pytest .param (Op .PUSH27 , id = "PUSH27" ),
1742
+ pytest .param (Op .PUSH28 , id = "PUSH28" ),
1743
+ pytest .param (Op .PUSH29 , id = "PUSH29" ),
1744
+ pytest .param (Op .PUSH30 , id = "PUSH30" ),
1745
+ pytest .param (Op .PUSH31 , id = "PUSH31" ),
1746
+ pytest .param (Op .PUSH32 , id = "PUSH32" ),
1747
+ ],
1748
+ )
1749
+ def test_worst_push (
1750
+ state_test : StateTestFiller ,
1751
+ pre : Alloc ,
1752
+ fork : Fork ,
1753
+ opcode : Op ,
1754
+ ):
1755
+ """Test running a block with as many PUSH as possible."""
1756
+ env = Environment ()
1757
+
1758
+ op = Op .PUSH0 if Op .PUSH0 == opcode else opcode (1 )
1759
+ opcode_sequence = op * MAX_STACK_HEIGHT
1760
+ target_contract_address = pre .deploy_contract (code = opcode_sequence )
1761
+
1762
+ calldata = Bytecode ()
1763
+ attack_block = Op .POP (Op .STATICCALL (Op .GAS , target_contract_address , 0 , 0 , 0 , 0 ))
1764
+
1765
+ code = code_loop_precompile_call (calldata , attack_block , fork )
1766
+ code_address = pre .deploy_contract (code = code )
1767
+
1768
+ tx = Transaction (
1769
+ to = code_address ,
1770
+ gas_limit = env .gas_limit ,
1771
+ sender = pre .fund_eoa (),
1772
+ )
1773
+
1774
+ state_test (
1775
+ env = env ,
1776
+ pre = pre ,
1777
+ post = {},
1778
+ tx = tx ,
1779
+ )
0 commit comments