Skip to content

Commit ec39341

Browse files
refactor: update result comparison method and test case
1 parent 757501f commit ec39341

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

tests/osaka/eip7883_modexp_gas_increase/conftest.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
from ethereum_test_forks import Fork, Osaka
8-
from ethereum_test_tools import Account, Address, Alloc, Storage, Transaction
8+
from ethereum_test_tools import Account, Address, Alloc, Bytes, Storage, Transaction, keccak256
99
from ethereum_test_tools.vm.opcode import Opcodes as Op
1010

1111
from ...byzantium.eip198_modexp_precompile.helpers import ModExpInput
@@ -109,17 +109,11 @@ def gas_measure_contract(
109109

110110
if call_succeeds:
111111
code += Op.SSTORE(call_contract_post_storage.store_next(precompile_gas), gas_calculation)
112-
# + Op.RETURNDATACOPY(dest_offset=0, offset=0, size=Op.RETURNDATASIZE())
113-
# + Op.SSTORE(call_contract_post_storage.store_next(
114-
# keccak256(Bytes(vector.expected))), Op.SHA3(0, Op.RETURNDATASIZE()))
115-
116-
for i in range(len(modexp_expected) // 32):
117-
code += Op.RETURNDATACOPY(0, i * 32, 32)
118-
code += Op.SSTORE(
119-
call_contract_post_storage.store_next(modexp_expected[i * 32 : (i + 1) * 32]),
120-
Op.MLOAD(0),
121-
)
122-
112+
code += Op.RETURNDATACOPY(dest_offset=0, offset=0, size=Op.RETURNDATASIZE())
113+
code += Op.SSTORE(
114+
call_contract_post_storage.store_next(keccak256(Bytes(modexp_expected))),
115+
Op.SHA3(0, Op.RETURNDATASIZE()),
116+
)
123117
return pre.deploy_contract(code)
124118

125119

tests/osaka/eip7883_modexp_gas_increase/vector/legacy.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
},
7777
{
7878
"Input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000202030006",
79-
"Expected": "0200",
79+
"Expected": "0002",
8080
"Name": "legacy-case-16"
8181
},
8282
{
@@ -131,32 +131,32 @@
131131
},
132132
{
133133
"Input": "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030006",
134-
"Expected": "0200",
134+
"Expected": "0002",
135135
"Name": "legacy-case-27"
136136
},
137137
{
138138
"Input": "000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010035ee4e488f45e64d2f07becd54646357381d32f30b74c299a8c25d5202c04938ef6c4764a04f10fc908b78c4486886000f6d290251a79681a83b950c7e5c37351",
139-
"Expected": "01000000000000000000000000000000",
139+
"Expected": "00000000000000000000000000000001",
140140
"Name": "legacy-case-31"
141141
},
142142
{
143143
"Input": "0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000cd935b43e42204fcbfb734a6e27735e8e90204fcc1fd2727bb040f9eecb",
144-
"Expected": "010000000000000000000000",
144+
"Expected": "000000000000000000000001",
145145
"Name": "legacy-case-32"
146146
},
147147
{
148148
"Input": "0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060846813a8d2d451387340fa0597c6545ae63",
149-
"Expected": "010000000000",
149+
"Expected": "000000000001",
150150
"Name": "legacy-case-33"
151151
},
152152
{
153153
"Input": "0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000d02534f82b1013f20d9c7d18d62cd95674d2e013f20d9c7d18d62cd95674d2f",
154-
"Expected": "01000000000000000000000000",
154+
"Expected": "00000000000000000000000001",
155155
"Name": "legacy-case-34"
156156
},
157157
{
158158
"Input": "0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000120785e45de3d6be050ba3c4d33ff0bb2d010ace3b1dfe9c49f4c7a8075102fa19a86c010ace3b1dfe9c49f4c7a8075102fa19a86d",
159-
"Expected": "000000010000000000000000000000000000",
159+
"Expected": "000000000000000000000000000000000001",
160160
"Name": "legacy-case-35"
161161
}
162162
]

tests/osaka/eip7883_modexp_gas_increase/vector/vectors.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"Input": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
4-
"Expected": "000000000000000000000000000000000000000000000000000000000000000000",
3+
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
4+
"Expected": "000000000000000000000000000000000000000000000000000000000000000001",
55
"Name": "geth-fail-length",
66
"GasOld": 200,
77
"GasNew": 1600
@@ -141,7 +141,7 @@
141141
},
142142
{
143143
"Input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000181000000000000000000000000000000000000000000000000000000000000000801ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2cffffffffffffffffffffffffffffffffffffffffffffffffffffffff3b10000000006c01ffffffffffffffffffffffffffffffffffffffffffffffdffffb97ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3bffffffffffffffffffffffffffffffffffffffffffffffffffffffffebafd93b37ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc5bb6affffffff3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2a",
144-
"Expected": "0001000000000000",
144+
"Expected": "0000000000000001",
145145
"Name": "guido-4-even",
146146
"GasOld": 1026,
147147
"GasNew": 94448

0 commit comments

Comments
 (0)