-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the state tests embedded in the blockchain tests #1577
Use the state tests embedded in the blockchain tests #1577
Conversation
7ee7041
to
a8b1a74
Compare
19d47a1
to
5bb8b02
Compare
b767a6e
to
5c15617
Compare
@@ -34,6 +36,84 @@ | |||
BASE_FIXTURE_PATH = os.path.join(ROOT_PROJECT_DIR, 'fixtures', 'BlockchainTests') | |||
|
|||
|
|||
# These are the slowest tests from the full blockchain test run. This list | |||
# should be regenerated occasionally using `--durations 100`. | |||
SLOWEST_TESTS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR but just as an idea: Isn't there something in Circle CI that we can differentiate between CI runs for PRs and CI runs on master? I think it would be nice if we could at least achieve that all these tests run from time to time. So that, even if we don't get immediate feedback that our PR broke one of these, we at least get notified about it some time after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible with Travis and I would be surprised if it wasn't also possible with Circle CI. It could be nice to have a nightly build which takes master and runs all the tests, and maybe even does benchmarking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dug around a bit and couldn't find anything in the CircleCI interface to do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CircleCI exposes some useful environment variables such as CIRCLE_PULL_REQUEST and CIRCLE_BRANCH you could use to detect whether you're building a branch or not.
I've opened a PR which attempts to schedule a nightly build which runs all the tests, even the slowest ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I would feel a bit better if I knew the reason why the GeneralStateTests
exist twice 😅
@@ -1,10 +1,10 @@ | |||
[tox] | |||
envlist= | |||
py{35,36}-{core,database,transactions,vm,native-blockchain} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a bit confused why the GeneralStateTests
also exists outside of the BlockchainTest
and if there is something we might be forgetting about dropping those. Do you know why they exist in the first place? Did you check if the number of tests that are run still matches after this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream docs:
https://ethereum-tests.readthedocs.io/en/latest/test_types/state_tests.html
https://ethereum-tests.readthedocs.io/en/latest/test_types/blockchain_tests.html
So, you should be confused as to why GeneralStateTests
exist inside BlockchainTests
, not the other way around. ^_^
Anyway, according to the docs, all of the former should eventually make their way into the latter:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish I had taken better notes, I saw somewhere that winsvega wanted to remove the state tests entirely, given that they've been duplicated to the blockchain tests. I neglected to save the link unfortunately.
And that last link is a little scary. It's possible that there's been an error in test generation and that some of the state tests are missing from BlockchainTests/GeneralStateTests
, but the idea is definitely that they be perfect duplicates.
I just did a quick scan, and I'm missing something: what happened to the blockchain tests that are not in the state tests. Are they distributed in the different forks now? |
@carver Good question. You mean like this one?..
They are in the same submodule that gets pulled in as (I haven't tested this particular PR yet, and whether it has inadvertently removed something.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just marking this 👎 so no one merges by accident while we confirm that none of the blockchain tests got dropped.
- py36-native-state-frontier | ||
- py36-native-state-homestead | ||
- py36-native-state-eip150 | ||
- py36-native-state-eip158 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are still state tests, they just happen to be in a different folder. I think the job name could stay the same. But it's a minor opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're blockchain tests now! Blockchain tests which happen to also contain state tests. The command for this specific one is now:
native-blockchain-eip158: pytest {posargs:tests/json-fixtures/test_blockchain.py --fork EIP158}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat orthogonal but it would be good to rename the EIPXXX
to their long form fork names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are their long form fork names? The EIP's page just calls it 158 and doesn't say when it was scheduled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
150 is apparently Tangerine Whistle and yeah, that name is 200% more exciting than EIP-150 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to do that in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "Spurious Dragon" is the other one. Look in eth.vm.forks
and you can find them (and there should be things within each module to hint at which EIPXXX they correspond to.
@@ -35,14 +35,13 @@ commands= | |||
rpc-state-quadratic: pytest {posargs:tests/trinity/json-fixtures-over-rpc/test_rpc_fixtures.py -k 'GeneralStateTests and stQuadraticComplexityTest'} | |||
transactions: pytest {posargs:tests/json-fixtures/test_transactions.py} | |||
vm: pytest {posargs:tests/json-fixtures/test_virtual_machine.py} | |||
native-blockchain: pytest {posargs:tests/json-fixtures/test_blockchain.py} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. You mean like this one?..
pytest -k 'test_blockchain_fixtures[/home/veox/src/py-evm/fixtures/BlockchainTests/bcUncleTest/uncleWithSameBlockNumber.json:uncleWithSameBlockNumber_Homestead]'
They are in the same submodule that gets pulled in as
fixtures
.(I haven't tested this particular PR yet, and whether it has inadvertently removed something.)
@veox right, the complete removal of this test (non-state blockchain tests) is what threw me off. Just wanted to make sure we had confirmation that nothing got dropped in the refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A weak indicator is bcForkStressTest/ForkStressTest.json
making it into the list of slowest tests:
(Got to run right now, so can't take a proper look.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SLOWEST_TESTS isn't a great indication because I generated those myself and didn't use tox/circleci. But here's proof that regular blockchain tests are being run:
(py-evm-ojdIf4Yr) brian@rhythm:~/ef/py-evm$ pytest tests/json-fixtures/test_blockchain.py --fork Byzantium --collect-only | grep -v GeneralStateTests | head
============================= test session starts ==============================
platform linux -- Python 3.6.6, pytest-3.6.4, py-1.7.0, pluggy-0.7.1
rootdir: /home/brian/ef/py-evm, inifile: pytest.ini
plugins: xdist-1.18.1, profiling-1.3.0, cov-2.5.1, asyncio-0.9.0, asyncio-network-simulator-0.1.0a2, hypothesis-3.69.5
collected 4945 items
<Module 'tests/json-fixtures/test_blockchain.py'>
<Function 'test_blockchain_fixtures[/home/brian/ef/py-evm/fixtures/BlockchainTests/bcBlockGasLimitTest/BlockGasLimit2p63m1.json:BlockGasLimit2p63m1_Byzantium:Byzantium]'>
<Function 'test_blockchain_fixtures[/home/brian/ef/py-evm/fixtures/BlockchainTests/bcBlockGasLimitTest/GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideFirst.json:GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideFirst_Byzantium:Byzantium]'>
<Function 'test_blockchain_fixtures[/home/brian/ef/py-evm/fixtures/BlockchainTests/bcBlockGasLimitTest/GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideLast.json:GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideLast_Byzantium:Byzantium]'>
<Function 'test_blockchain_fixtures[/home/brian/ef/py-evm/fixtures/BlockchainTests/bcBlockGasLimitTest/SuicideTransaction.json:SuicideTransaction_Byzantium:Byzantium]'>
Each of these native-blockchain-*
jobs is now running all the blockchain tests for a given fork, which (primarily) includes state tests, but also includes the blockchain tests which were previously being run by the native-blockchain
job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way we would be missing some tests would be if this collection of forks doesn't cover the full set of blockchain tests: frontier, homestead, eip150, eip158, byzantium, constantinople, metropolis
. Let me think of a way to test whether that's true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well shucks, looks like we're missing some tests:
(py-evm-ojdIf4Yr) brian@rhythm:~/ef/py-evm$ pytest tests/json-fixtures/test_blockchain.py --collect-only 2>/dev/null | grep -oP '\[\K.*(?=\])' | cut -d':' -f3 | sort | uniq
Byzantium
Constantinople
EIP150
EIP158
EIP158ToByzantiumAt5
Frontier
FrontierToHomesteadAt5
Homestead
HomesteadToDaoAt5
HomesteadToEIP150At5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks for catching this Carver! I've pushed a commit which adds the missing tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, well I pretty much just pointed and grumbled. Thanks for hunting it down!
86fa931
to
9d28e83
Compare
Mostly a copy-paste from `py-evm` codebase; relevant PRs that introduced the functionality there: ethereum/py-evm#1470 ethereum/py-evm#1577
Mostly a copy-paste from `py-evm` codebase; relevant PRs that introduced the functionality there: ethereum/py-evm#1470 ethereum/py-evm#1577
Mostly a copy-paste from `py-evm` codebase; relevant PRs that introduced the functionality there: ethereum/py-evm#1470 ethereum/py-evm#1577
When state tests fail they tell you the root state hash has changed, but there's no easy way of telling which parts of the state have changed. However, a copy of the state tests is also available under the blockchain tests, and that copy includes the full expected state tree.
This PR changes which version of the state tests are run. In combination with #1573 this should make diagnosing test failures much easier.
--fork
flag, to allow running just a subset of the testsSLOWEST_TESTS
has been regenerated. There are now more tests (each of the indexes appears as a separate blockchain test) so the list is a little longer now. The 60ish tests skipped here (out of 10851) account for 15 of the 21 minutes it takes to run the test suite on my machine.Cute Animal Picture