Skip to content

Commit

Permalink
Update ethereum/tests fixtures (#1224)
Browse files Browse the repository at this point in the history
* fixtures: update to db8ae9de91c303caad3eb9354015c07a0ec3adc3

Rolls forwards up to 2018-01-22.

Passing of test_state_fixtures determined using `git bisect run`.

* tests/test_state_fixtures(): bump fixtures and mark new test `xfail`.

The upstream generated test is not sufficiently specific, and it's hard
to determine which of the two implementations is incorrect.

The principal author of the test case (Yoichi Hirai, github @pirapira)
seems currently unavailable, so it's difficult for me to get specific
details.

* 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

Squashed commit:

tests: update "very big number" in test_modexp_gas_fee_calculation().

... and also fix that test's name, from "calculTation".

The very-big-number is not actually in EIP-198; the latter has
this to say:

> it’s not possible to provide enough gas to make that computation.

That's a bit cryptic, but the gist is that the most that can be
represented in a 256-bit number is

0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

which is

115792089237316195423570985008687907853269984665640564039457584007913129639935

and that's less than the

10684346944173007063723051170445283632835119638284563472873463025465780712173320789629146724657549280936306536701227228889744512638312451529980055895215896

required by this vector, or even the (erroneous)

708647586132375115992254428253169996062012306153720251921480414128428353393856280

that was in the test previously.

* fixtures: update to 61185fe4b8762118fe9ee318539683b47cb04ed6 + mark RevertInCreateInInit as xfail.

Rolls forwards up to 2018-03-01.

Break in `RevertInCreateInInit.json` determined by
`git bisect run`.

The test is marked `xfail` to expicitly highlight the fact.

This is done in 3 places - all are run as part of CI.

* fixtures: update to f4faae91c5ba192c3fd9b8cf418c24e627786312

Determined state tests as "good" by `git bisect run`.
  • Loading branch information
veox authored and pipermerriam committed Sep 10, 2018
1 parent 971bc60 commit d521ea2
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 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
2 changes: 1 addition & 1 deletion fixtures
Submodule fixtures updated 14326 files
4 changes: 2 additions & 2 deletions tests/core/vm/test_modexp_precompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
(EIP198_VECTOR_A, 13056),
(
EIP198_VECTOR_C,
708647586132375115992254428253169996062012306153720251921480414128428353393856280,
10684346944173007063723051170445283632835119638284563472873463025465780712173320789629146724657549280936306536701227228889744512638312451529980055895215896, # noqa: E501
),
),
)
def test_modexp_gas_fee_calcultation(data, expected):
def test_modexp_gas_fee_calculation(data, expected):
actual = _compute_modexp_gas_fee(data)
assert actual == expected

Expand Down
18 changes: 17 additions & 1 deletion tests/json-fixtures/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,33 @@
BASE_FIXTURE_PATH = os.path.join(ROOT_PROJECT_DIR, 'fixtures', 'BlockchainTests')


# These are tests that are thought to be incorrect or buggy upstream,
# at the commit currently checked out in submodule `fixtures`.
# Ideally, this list should be empty.
# WHEN ADDING ENTRIES, ALWAYS PROVIDE AN EXPLANATION!
INCORRECT_UPSTREAM_TESTS = {
# The test considers a "synthetic" scenario (the state described there can't
# be arrived at using regular consensus rules).
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-418775512
# The result is in conflict with the yellow-paper:
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-418800369
('GeneralStateTests/stRevertTest/RevertInCreateInInit_d0g0v0.json', 'RevertInCreateInInit_d0g0v0_Byzantium'), # noqa: E501
}


def blockchain_fixture_mark_fn(fixture_path, fixture_name):
if fixture_path.startswith('bcExploitTest'):
return pytest.mark.skip("Exploit tests are slow")
elif fixture_path == 'bcWalletTest/walletReorganizeOwners.json':
return pytest.mark.skip("Wallet owner reorganization tests are slow")
elif (fixture_path, fixture_name) in INCORRECT_UPSTREAM_TESTS:
return pytest.mark.xfail(reason="Listed in INCORRECT_UPSTREAM_TESTS.")


def blockchain_fixture_ignore_fn(fixture_path, fixture_name):
if fixture_path.startswith('GeneralStateTests'):
# General state tests are also exported as blockchain tests. We
# skip them here so we don't run them twice"
# skip them here so we don't run them twice
return True


Expand Down
16 changes: 16 additions & 0 deletions tests/json-fixtures/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ def expand_fixtures_forks(all_fixtures):
}


# These are tests that are thought to be incorrect or buggy upstream,
# at the commit currently checked out in submodule `fixtures`.
# Ideally, this list should be empty.
# WHEN ADDING ENTRIES, ALWAYS PROVIDE AN EXPLANATION!
INCORRECT_UPSTREAM_TESTS = {
# The test considers a "synthetic" scenario (the state described there can't
# be arrived at using regular consensus rules).
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-418775512
# The result is in conflict with the yellow-paper:
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-418800369
('stRevertTest/RevertInCreateInInit.json', 'RevertInCreateInInit', 'Byzantium', 0),
}


def mark_statetest_fixtures(fixture_path, fixture_key, fixture_fork, fixture_index):
fixture_id = (fixture_path, fixture_key, fixture_fork, fixture_index)
if fixture_path.startswith('stTransactionTest/zeroSigTransa'):
Expand All @@ -144,6 +158,8 @@ def mark_statetest_fixtures(fixture_path, fixture_key, fixture_fork, fixture_ind
return pytest.mark.skip("Skipping slow test")
elif fixture_path.startswith('stQuadraticComplexityTest'):
return pytest.mark.skip("Skipping slow test")
elif fixture_id in INCORRECT_UPSTREAM_TESTS:
return pytest.mark.xfail(reason="Listed in INCORRECT_UPSTREAM_TESTS.")


def pytest_generate_tests(metafunc):
Expand Down
15 changes: 15 additions & 0 deletions tests/trinity/json-fixtures-over-rpc/test_rpc_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@
'DelegateCallSpam_EIP150',
)

# These are tests that are thought to be incorrect or buggy upstream,
# at the commit currently checked out in submodule `fixtures`.
# Ideally, this list should be empty.
# WHEN ADDING ENTRIES, ALWAYS PROVIDE AN EXPLANATION!
INCORRECT_UPSTREAM_TESTS = {
# The test considers a "synthetic" scenario (the state described there can't
# be arrived at using regular consensus rules).
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-418775512
# The result is in conflict with the yellow-paper:
# * https://github.com/ethereum/py-evm/pull/1224#issuecomment-418800369
('GeneralStateTests/stRevertTest/RevertInCreateInInit_d0g0v0.json', 'RevertInCreateInInit_d0g0v0_Byzantium'), # noqa: E501
}

RPC_STATE_NORMALIZERS = {
'balance': remove_leading_zeros,
'code': empty_to_0x,
Expand Down Expand Up @@ -162,6 +175,8 @@ def blockchain_fixture_mark_fn(fixture_path, fixture_name):
if not should_run_slow_tests():
return pytest.mark.skip("skipping slow test on a quick run")
break
if (fixture_path, fixture_name) in INCORRECT_UPSTREAM_TESTS:
return pytest.mark.xfail(reason="Listed in INCORRECT_UPSTREAM_TESTS.")


def pytest_generate_tests(metafunc):
Expand Down

0 comments on commit d521ea2

Please sign in to comment.