-
Notifications
You must be signed in to change notification settings - Fork 654
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
[WIP] [BLOCKED] Add Python 3.8 testing #1885
Conversation
2000193
to
3513f69
Compare
@@ -203,7 +203,10 @@ def test_new_vs_reference_code_stream_iter(bytecode): | |||
assert latest.program_counter == reference.program_counter | |||
|
|||
|
|||
@given(read_len=st.integers(min_value=0), bytecode=st.binary(max_size=128)) | |||
@given( | |||
read_len=st.integers(min_value=0, max_value=2048), |
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 (here and in test below) certainly requires review.
max_value=2**63-1
works just fine, too. 2**63
(gets passed implicitly if max_value
not present) is what breaks the test.
See also commit message, copied below.
A failure happens because the underlying io.BytesIO.read(size) call gets a size=9223372036854775808. That's (2^63), but it seems that the biggest size that BytesIO can read is (2^63)-1.
The error surfaced after an update of package hypothesis
from v3 to v4 (version that is latest ATM), and is possibly an issue from upstream. Or it could be ours.
Anyway, limiting read_len fixes the issue. Could use (2^63)-1, too, but considering that bytecode
max_size is limited, I don't see the point.
Likely a limitation of CPython; I'd guess the read index is an int64
on 64-bit machines (since -1
is a valid value). Also possible that hypothesis
doesn't know.
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 seems fine to me.
Remaining lint failures (after commit 7ffeef7) are actual inconsistencies in the codebase. |
b5a2ba4
to
7ffeef7
Compare
You might also want to bump the minimum supported |
@@ -775,7 +775,7 @@ def __call__(self, computation: 'ComputationAPI') -> None: | |||
def as_opcode(cls: Type[T], | |||
logic_fn: Callable[['ComputationAPI'], None], | |||
mnemonic: str, | |||
gas_cost: int) -> Type[T]: | |||
gas_cost: int) -> T: |
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.
ABC made same as the consumer:
Lines 39 to 43 in 3f33ac8
@classmethod | |
def as_opcode(cls: Type[T], | |
logic_fn: Callable[..., Any], | |
mnemonic: str, | |
gas_cost: int) -> T: |
Before the change, mypy
said:
eth/vm/opcode.py:40: error: Return type "Opcode" of "as_opcode" incompatible with return type "Type[Opcode]" in supertype "OpcodeAPI"
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.
Yeah, I agree with your call here, too. The implementation is clearly returning an Opcode
instance instead of class, and would require a lot of refactoring to change (if we even wanted to).
The only thing I'd add it that the ABC docs should update, too.
@@ -51,7 +51,7 @@ def __init__( | |||
self, | |||
db: AtomicDatabaseAPI, | |||
execution_context: ExecutionContextAPI, | |||
state_root: bytes) -> None: | |||
state_root: Hash32) -> None: |
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.
@carver This is the example of cargo-culting I mentioned on gitter: consumer changed to fit the ABC; previous commit went the other way (ABC changed to appease the consumer).
mypy
said (before the change):
eth/vm/state.py:57: error: Argument 2 to "AccountDatabaseAPI" has incompatible type "bytes"; expected "Hash32"
... so I gave it exactly what it asked. But I don't know if it's right or not.
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.
Yeah, in this case, it looks like the right thing to do to go with Hash32
, since it's logically the hash of the root node. 👍
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.
Should has_root()
of AccountDB
(and ABC AccountDatabaseAPI
) have a state_root
argument that's Hash32
also?..
Lines 135 to 136 in 0d79bb6
def has_root(self, state_root: bytes) -> bool: | |
return state_root in self._batchtrie |
This doesn't produce a linting error; just wondering if this would be right to change now, too.
3e9ae1d
to
a46b2b2
Compare
Remaining errors in
This has me scratching my head. |
More importantly to
This comes from While waiting for There are nested dependencies that have similar pinnings as Downstream projects with "The hell you make is the one you deserve." |
Minimal set of dependencies that otherwise break the virtualenv, detailed here: ethereum#1872 (comment)
That version added support for Python 3.8 internally: https://github.com/ethereum/eth-utils/blob/master/docs/releases.rst#eth-utils-180-2019-11-04 This is also what's being installed according to `pip freeze`.
Python package `plyvel` doesn't have pre-built wheels for Python 3.8 yet, so the CI machines need to build the wheel themselves. They need LevelDB header files for that. This change installs the headers system-wide. SQUASHED: CircleCI YAML can't handle complex map merging via anchors. So, do the blunt thing, and install the dependency on _all_ CI runs, even ones that don't need it.
... and CodeStream, of course - it's just that SlowCodeStream comes first, so the test fails on it. A failure happens because the underlying io.BytesIO.read(size) call gets a size=9223372036854775808. That's (2^63), but it seems that the biggest size that BytesIO can read is (2^63)-1. The error surfaced after an update of package `hypothesis` from v3 to v4 (version that is latest ATM), and is possibly an issue from upstream. Or it could be ours. Anyway, limiting read_len fixes the issue. Could use (2^63)-1, too, but considering that `bytecode` max_size is limited, I don't see the point.
The messages silenced in this commit are all: On Python 3 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired behavior Sadly, `mypy` doesn't say which particular fields are problematic; I've tried my best to single them out - hopefully, nothing extraneous got in.
99.99% cargo-culting. I don't understand the purpose of this structuring, but the function signatures don't match, and this is the only permutation I could find between OpcodeAPI, Opcode and FRONTIER_OPCODES that stops producing an error when running `mypy`: eth/vm/opcode.py:40: error: Return type "Opcode" of "as_opcode" incompatible with return type "Type[Opcode]" in supertype "OpcodeAPI"
Again, 99.99% cargo-culting. This just silences a `mypy` error: eth/vm/state.py:57: error: Argument 2 to "AccountDatabaseAPI" has incompatible type "bytes"; expected "Hash32" A valid state root will definitely be a 32-byte-long hash. Question is if this is the right place to make sure of it; and whether that should be made more explicit in code than being picky about a type.
This silences `mypy` error: eth/chains/base.py:250: error: Unexpected keyword argument "chain_context" for "VirtualMachineAPI" eth/abc.py:2270: note: "VirtualMachineAPI" defined here
AccountDB (from eth/db/account.py) has a setter for the `state_root` property, and `BaseState` (from eth/vm/state.py) forcibly sets the state root in its revert() function. This helps silence `mypy` error: eth/vm/state.py:170: error: Property "state_root" defined in "AccountDatabaseAPI" is read-only
0d79bb6
to
7350ac3
Compare
Just noticed that a new |
Well, it's been a while. I see Enough has changed in dependencies to start a fresh PR, closing. |
v1.9.0 is installed now anyway, but this has been suggested in ethereum#1885 (comment)
v1.9.0 is installed now anyway, but this has been suggested in ethereum#1885 (comment)
Minimal set of dependencies that otherwise break the virtualenv, detailed here: ethereum#1872 (comment) SQUASHED: setup: bump `plyvel` version so pre-built wheel can be used: ethereum#1872 (comment) setup: bump minimum eth-utils to v1.8.0 (has Python 3.8 support). v1.9.0 is installed now anyway, but this has been suggested in ethereum#1885 (comment) setup: bump `pyflake` nested dependency to that with Python 3.8 support. Get around: AttributeError: 'FlakesChecker' object has no attribute 'CONSTANT' `pyflakes` has proper support from v2.2.0, which in turn was added to `flake8` as a dependency in the v3.8.x branch: https://gitlab.com/pycqa/flake8/-/blob/3.8.0/setup.cfg Also bump `flake8-bugbear` to latest version while we're at it, even though its dependency on `flake8` is rather lax: https://github.com/PyCQA/flake8-bugbear/blob/20.1.4/setup.py#L41
Superseded by PR #1940.
Blocked by
pyflakes
; see #1885 (comment).What was wrong?
Nothing; Python 3.8 has been released.
How was it fixed?
See #1872 for even more verbose noise.
Note: Many
lint
fixes are 99.99% cargo-culting, especially those relating to low-level APIs, e.g.AccountDatabaseAPI
,OpcodeAPI
,VirtualMachineAPI
. I don't understand the structuring of the codebase to make an informed decision on what has to be chiseled, the underlying ABCs or the consumers. So my principle is/was "less LOCs changed == better".libleveldb-dev
on all CI jobs, so we can get it on Python 3.8 jobs, so it can build aplyvel
wheel locally (otherwise not yet available).coincurve
dep to latest: that has a Python 3.8 wheel: fixes installation on Arch Linux.pyflakes
dep to latest (so it has Python 3.8 support).mypy
due to nested dependency (typed-ast
) local wheel build fail.mypy
found to be broken (lint
jobs across all Pythons).hypothesis
to latest (not much consideration given).core
jobs across all Pythons).Closes #1872 as implemented.
To-Do
trinity
and see if API interfaces are now broken.Cute Animal Picture
Source: Cmycherrytree, via imgur