Skip to content

Commit e93255c

Browse files
committed
eth/precompiles/modexp: fix complexity calc (length^2, not 2^2).
There was a typo in the "complexity" calculation function, a special interim value from EIP-198 used to determine total gas use. The code path was never previously exercised. NOTE: previous-commit "fixtures bump" was to commit: 9b1f07c58a70d1b17c4489c49eb9bebf4a27d290
1 parent b11a7b8 commit e93255c

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

eth/precompiles/modexp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _compute_complexity(length):
3535
length ** 2 // 4 + 96 * length - 3072
3636
)
3737
else:
38-
return 2 ** 2 // 16 + 480 * length - 199680
38+
return length ** 2 // 16 + 480 * length - 199680
3939

4040

4141
def _extract_lengths(data):

tests/json-fixtures/test_state.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,6 @@ def expand_fixtures_forks(all_fixtures):
138138
# Ideally, this list should be empty.
139139
# WHEN ADDING ENTRIES, ALWAYS PROVIDE AN EXPLANATION!
140140
INCORRECT_UPSTREAM_TESTS = {
141-
# Upstream seems to specify that the precompile call fails, but `py-evm`
142-
# handles it just fine.
143-
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-417351843
144-
# * https://github.com/ethereum/tests/pull/405#issuecomment-417855812
145-
('stReturnDataTest/modexp_modsize0_returndatasize.json', 'modexp_modsize0_returndatasize', 'Byzantium', 4), # noqa: E501
146141
}
147142

148143

0 commit comments

Comments
 (0)