diff --git a/eth/precompiles/modexp.py b/eth/precompiles/modexp.py index f971bd4b93..e477ce6013 100644 --- a/eth/precompiles/modexp.py +++ b/eth/precompiles/modexp.py @@ -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): diff --git a/fixtures b/fixtures index 47b09f42c0..f4faae91c5 160000 --- a/fixtures +++ b/fixtures @@ -1 +1 @@ -Subproject commit 47b09f42c0681548a00da5ab1c98808b368af49a +Subproject commit f4faae91c5ba192c3fd9b8cf418c24e627786312 diff --git a/tests/core/vm/test_modexp_precompile.py b/tests/core/vm/test_modexp_precompile.py index 1a2210981b..3d8f32af65 100644 --- a/tests/core/vm/test_modexp_precompile.py +++ b/tests/core/vm/test_modexp_precompile.py @@ -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 diff --git a/tests/json-fixtures/test_blockchain.py b/tests/json-fixtures/test_blockchain.py index 5d0de5382a..ce72ba1ca7 100644 --- a/tests/json-fixtures/test_blockchain.py +++ b/tests/json-fixtures/test_blockchain.py @@ -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 diff --git a/tests/json-fixtures/test_state.py b/tests/json-fixtures/test_state.py index d35597e176..91b0ab468e 100644 --- a/tests/json-fixtures/test_state.py +++ b/tests/json-fixtures/test_state.py @@ -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'): @@ -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): diff --git a/tests/trinity/json-fixtures-over-rpc/test_rpc_fixtures.py b/tests/trinity/json-fixtures-over-rpc/test_rpc_fixtures.py index f65dbed88c..297a82b270 100644 --- a/tests/trinity/json-fixtures-over-rpc/test_rpc_fixtures.py +++ b/tests/trinity/json-fixtures-over-rpc/test_rpc_fixtures.py @@ -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, @@ -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):