33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 | @pytest.mark.parametrize(
"modexp_input,modexp_expected",
[
pytest.param(
ModExpInput(
base="ff" * 31 + "fc",
exponent="02",
modulus="05",
declared_base_length=32,
declared_exponent_length=1,
declared_modulus_length=1,
),
ModExpOutput(
call_success=True,
returned_data="0x04",
),
id="32-bytes-long-base",
),
pytest.param(
ModExpInput(
base="ff" * 32 + "fb",
exponent="02",
modulus="05",
declared_base_length=33,
declared_exponent_length=1,
declared_modulus_length=1,
),
ModExpOutput(
call_success=True,
returned_data="0x01",
),
id="33-bytes-long-base", # higher cost than 32 bytes
),
pytest.param(
ModExpInput(
base="ee" * 32,
exponent="ff" * Spec.MAX_LENGTH_BYTES, # 1024 is upper limit
modulus="03",
declared_base_length=32,
declared_exponent_length=1024,
declared_modulus_length=1,
),
ModExpOutput(
call_success=True,
returned_data="0x02",
),
id="1024-bytes-long-exp",
),
pytest.param(
ModExpInput(
base="e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb5",
exponent="010001",
modulus="fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b",
declared_base_length=64,
declared_exponent_length=3,
declared_modulus_length=64,
),
ModExpOutput(
call_success=True,
returned_data=(
"0xc36d804180c35d4426b57b50c5bfcca5c01856d104564cd513b461d3c8b8409128a5573e416d0ebe38f5f736766d9dc27143e4da981dfa4d67f7dc474cbee6d2"
),
),
id="nagydani-1-pow0x10001",
),
pytest.param(
ModExpInput(
base="8d74b1229cc36912165d7ed62334d5ce0683ad12dbade86cdbd705f46693d6c0",
exponent="00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
modulus="8f70e8f94c5ad28ed971e258ea3854ebf57131ae4c842e5cafe1c70db8272caf",
declared_base_length=32,
declared_exponent_length=64,
declared_modulus_length=32,
),
ModExpOutput(
call_success=True,
returned_data=(
"0x0000000000000000000000000000000000000000000000000000000000000001"
),
),
id="zero-exponent-64bytes",
),
],
)
def test_modexp_different_base_lengths(
state_test: StateTestFiller,
pre: Alloc,
tx: Transaction,
post: Dict,
) -> None:
"""Mainnet test for triggering gas cost increase."""
state_test(pre=pre, tx=tx, post=post)
|