|
33 | 33 | from tests.benchmark.compute.helpers import DEFAULT_BINOP_ARGS, make_dup, neg |
34 | 34 |
|
35 | 35 |
|
36 | | -@pytest.mark.repricing |
37 | 36 | @pytest.mark.parametrize( |
38 | 37 | "opcode,opcode_args", |
39 | 38 | [ |
40 | | - ( |
| 39 | + pytest.param( |
41 | 40 | Op.ADD, |
42 | 41 | DEFAULT_BINOP_ARGS, |
| 42 | + marks=pytest.mark.repricing, |
43 | 43 | ), |
44 | | - ( |
| 44 | + pytest.param( |
45 | 45 | Op.MUL, |
46 | 46 | DEFAULT_BINOP_ARGS, |
| 47 | + marks=pytest.mark.repricing, |
47 | 48 | ), |
48 | | - ( |
| 49 | + pytest.param( |
49 | 50 | # After every 2 SUB operations, values return to initial. |
50 | 51 | Op.SUB, |
51 | 52 | DEFAULT_BINOP_ARGS, |
| 53 | + marks=pytest.mark.repricing, |
52 | 54 | ), |
53 | | - ( |
| 55 | + pytest.param( |
54 | 56 | # This has the cycle of 2: |
55 | 57 | # v[0] = a // b |
56 | 58 | # v[1] = a // v[0] = a // (a // b) = b |
|
63 | 65 | # optimized paths for division by 1 and 2 words. |
64 | 66 | 0x100000000000000000000000000000033, |
65 | 67 | ), |
| 68 | + marks=pytest.mark.repricing, |
66 | 69 | ), |
67 | | - ( |
| 70 | + pytest.param( |
68 | 71 | # This has the cycle of 2, see above. |
69 | 72 | Op.DIV, |
70 | 73 | ( |
|
75 | 78 | 0x10000000000000033, |
76 | 79 | ), |
77 | 80 | ), |
78 | | - ( |
| 81 | + pytest.param( |
79 | 82 | # Same as DIV-0 |
80 | 83 | # But the numerator made positive, and the divisor made negative. |
81 | 84 | Op.SDIV, |
82 | 85 | ( |
83 | 86 | 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F, |
84 | 87 | 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCD, |
85 | 88 | ), |
| 89 | + marks=pytest.mark.repricing, |
86 | 90 | ), |
87 | | - ( |
| 91 | + pytest.param( |
88 | 92 | # Same as DIV-1 |
89 | 93 | # But the numerator made positive, and the divisor made negative. |
90 | 94 | Op.SDIV, |
|
93 | 97 | 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFCD, |
94 | 98 | ), |
95 | 99 | ), |
96 | | - ( |
| 100 | + pytest.param( |
97 | 101 | # Not suitable for MOD, as values quickly become zero. |
98 | 102 | Op.MOD, |
99 | 103 | DEFAULT_BINOP_ARGS, |
| 104 | + marks=pytest.mark.repricing, |
100 | 105 | ), |
101 | | - ( |
| 106 | + pytest.param( |
102 | 107 | # Not suitable for SMOD, as values quickly become zero. |
103 | 108 | Op.SMOD, |
104 | 109 | DEFAULT_BINOP_ARGS, |
| 110 | + marks=pytest.mark.repricing, |
105 | 111 | ), |
106 | | - ( |
| 112 | + pytest.param( |
107 | 113 | # This keeps the values unchanged |
108 | 114 | # pow(2**256-1, 2**256-1, 2**256) == 2**256-1. |
109 | 115 | Op.EXP, |
110 | 116 | ( |
111 | 117 | 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, |
112 | 118 | 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, |
113 | 119 | ), |
| 120 | + marks=pytest.mark.repricing, |
114 | 121 | ), |
115 | | - ( |
| 122 | + pytest.param( |
116 | 123 | # Not great, as we always sign-extend the 4 bytes. |
117 | 124 | Op.SIGNEXTEND, |
118 | 125 | ( |
119 | 126 | 3, |
120 | 127 | 0xFFDADADA, # Negative to have more work. |
121 | 128 | ), |
| 129 | + marks=pytest.mark.repricing, |
122 | 130 | ), |
123 | 131 | ], |
124 | 132 | ids=lambda param: "" if isinstance(param, tuple) else param, |
@@ -150,7 +158,7 @@ def test_arithmetic( |
150 | 158 | ) |
151 | 159 |
|
152 | 160 |
|
153 | | -@pytest.mark.repricing |
| 161 | +@pytest.mark.repricing(mod_bits=255) |
154 | 162 | @pytest.mark.parametrize("mod_bits", [255, 191, 127, 63]) |
155 | 163 | @pytest.mark.parametrize("op", [Op.MOD, Op.SMOD]) |
156 | 164 | def test_mod( |
@@ -269,6 +277,7 @@ def test_mod( |
269 | 277 | ) |
270 | 278 |
|
271 | 279 |
|
| 280 | +@pytest.mark.repricing(mod_bits=255) |
272 | 281 | @pytest.mark.parametrize("mod_bits", [255, 191, 127, 63]) |
273 | 282 | @pytest.mark.parametrize("op", [Op.ADDMOD, Op.MULMOD]) |
274 | 283 | def test_mod_arithmetic( |
|
0 commit comments