Skip to content

Commit

Permalink
eth/precompiles/modexp: fix complexity calc (length^2, not 2^2).
Browse files Browse the repository at this point in the history
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
  • Loading branch information
veox committed Sep 4, 2018
1 parent b11a7b8 commit e93255c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion eth/precompiles/modexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _compute_complexity(length):
length ** 2 // 4 + 96 * length - 3072
)
else:
return 2 ** 2 // 16 + 480 * length - 199680
return length ** 2 // 16 + 480 * length - 199680


def _extract_lengths(data):
Expand Down
5 changes: 0 additions & 5 deletions tests/json-fixtures/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ def expand_fixtures_forks(all_fixtures):
# Ideally, this list should be empty.
# WHEN ADDING ENTRIES, ALWAYS PROVIDE AN EXPLANATION!
INCORRECT_UPSTREAM_TESTS = {
# Upstream seems to specify that the precompile call fails, but `py-evm`
# handles it just fine.
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-417351843
# * https://github.com/ethereum/tests/pull/405#issuecomment-417855812
('stReturnDataTest/modexp_modsize0_returndatasize.json', 'modexp_modsize0_returndatasize', 'Byzantium', 4), # noqa: E501
}


Expand Down

0 comments on commit e93255c

Please sign in to comment.