Skip to content
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

Python 3.11 Support #2699

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,103 @@ jobs:
environment:
TOXENV: py310-wheel-cli

#
# Python 3.11
#
py311-core:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-core

py311-ens:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-ens

py311-ethpm:
<<: *ethpm_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-ethpm
# Please don't use this key for any shenanigans
WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22

py311-integration-goethereum-ipc:
<<: *geth_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-goethereum-ipc
GETH_VERSION: v1.10.25

py311-integration-goethereum-ipc_flaky:
<<: *geth_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-goethereum-ipc_flaky
GETH_VERSION: v1.10.25

py311-integration-goethereum-http:
<<: *geth_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-goethereum-http
GETH_VERSION: v1.10.25

py311-integration-goethereum-http_async:
<<: *geth_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-goethereum-http_async
GETH_VERSION: v1.10.25

py311-integration-goethereum-http_flaky:
<<: *geth_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-goethereum-http_flaky
GETH_VERSION: v1.10.25

py311-integration-goethereum-ws:
<<: *geth_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-goethereum-ws
GETH_VERSION: v1.10.25

py311-integration-goethereum-ws_flaky:
<<: *geth_steps
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-goethereum-ws_flaky
GETH_VERSION: v1.10.25

py311-integration-ethtester-pyevm:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-integration-ethtester
ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend

py311-wheel-cli:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-wheel-cli

benchmark:
<<: *geth_steps
docker:
Expand All @@ -632,6 +729,7 @@ workflows:
- py38-core
- py39-core
- py310-core
- py311-core
- lint
- docs
- benchmark
Expand Down Expand Up @@ -680,3 +778,14 @@ workflows:
- py310-integration-goethereum-ws_flaky
- py310-integration-ethtester-pyevm
- py310-wheel-cli
- py311-ens
- py311-ethpm
- py311-integration-goethereum-ipc
- py311-integration-goethereum-ipc_flaky
- py311-integration-goethereum-http
- py311-integration-goethereum-http_async
- py311-integration-goethereum-http_flaky
- py311-integration-goethereum-ws
- py311-integration-goethereum-ws_flaky
- py311-integration-ethtester-pyevm
- py311-wheel-cli
27 changes: 14 additions & 13 deletions ethpm/_utils/protobuf/ipfs_file_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions newsfragments/2699.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support Python 3.11
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

extras_require = {
"tester": [
"eth-tester[py-evm]==v0.7.0-b.1",
"eth-tester[py-evm]==v0.8.0-b.3",
"py-geth>=3.10.0",
],
"linter": [
Expand Down Expand Up @@ -80,11 +80,12 @@
include_package_data=True,
install_requires=[
"aiohttp>=3.7.4.post0",
"eth-abi>=3.0.0",
"eth-account>=0.7.0",
"eth-hash[pycryptodome]>=0.2.0",
"eth-abi>=4.0.0-b.2",
"parsimonious==0.9.0", # TODO - fix in eth-abi
"eth-account>=0.8.0",
"eth-hash[pycryptodome]>=0.5.1",
"eth-typing>=3.0.0",
"eth-utils>=2.0.0",
"eth-utils>=2.1.0",
"hexbytes>=0.1.0",
"jsonschema>=4.0.0",
"lru-dict>=1.1.6",
Expand Down Expand Up @@ -114,5 +115,6 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
)
4 changes: 1 addition & 3 deletions tests/core/middleware/test_eth_tester_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def test_get_block_formatters(w3):
all_block_keys = set(BlockData.__annotations__.keys())
latest_block_keys = set(latest_block.keys())

keys_diff = all_block_keys.difference(latest_block_keys)
assert len(keys_diff) == 1
assert keys_diff.pop() == "mixHash" # mixHash is not implemented in eth-tester
assert all_block_keys == latest_block_keys


@pytest.mark.parametrize(
Expand Down
1 change: 1 addition & 0 deletions tests/core/module-class/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def test_attach_methods_with_mungers(web3_with_external_modules):
}
)

w3.provider.ethereum_tester.mine_block()
assert w3.eth.get_block(0, False)["baseFeePerGas"] == 1000000000
assert w3.eth.get_block(1, False)["baseFeePerGas"] == 875000000

Expand Down
8 changes: 4 additions & 4 deletions tests/ens/test_get_text.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from eth_tester.exceptions import (
TransactionFailed,
from eth_utils.exceptions import (
ValidationError,
)

from ens.exceptions import (
Expand Down Expand Up @@ -29,7 +29,7 @@ def test_set_text_fails_with_bad_address(ens):
address = ens.w3.eth.accounts[2]
ens.setup_address("tester.eth", address)
zero_address = "0x" + "00" * 20
with pytest.raises(TransactionFailed):
with pytest.raises(ValidationError):
ens.set_text(
"tester.eth", "url", "http://example.com", transact={"from": zero_address}
)
Expand Down Expand Up @@ -97,7 +97,7 @@ async def test_async_set_text_fails_with_bad_address(async_ens):
address = accounts[2]
await async_ens.setup_address("tester.eth", address)
zero_address = "0x" + "00" * 20
with pytest.raises(TransactionFailed):
with pytest.raises(ValidationError):
await async_ens.set_text(
"tester.eth", "url", "http://example.com", transact={"from": zero_address}
)
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,16 @@ def test_eth_send_transaction_no_gas(self, eth_tester, w3, unlocked_account):
def test_eth_send_transaction_no_max_fee(self, eth_tester, w3, unlocked_account):
super().test_eth_send_transaction_no_max_fee(w3, unlocked_account)

def test_eth_getBlockByNumber_safe(
self, w3: "Web3", empty_block: BlockData
) -> None:
super().test_eth_getBlockByNumber_safe(w3, empty_block)

def test_eth_getBlockByNumber_finalized(
self, w3: "Web3", empty_block: BlockData
) -> None:
super().test_eth_getBlockByNumber_finalized(w3, empty_block)


class TestEthereumTesterNetModule(NetModuleTest):
pass
Expand Down
19 changes: 13 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tox]
envlist=
py{37,38,39,310}-ens
py{37,38,39,310}-ethpm
py{37,38,39,310}-core
py{37,38,39,310}-integration-{goethereum,ethtester}
py{37,38,39,310,311}-ens
py{37,38,39,310,311}-ethpm
py{37,38,39,310,311}-core
py{37,38,39,310,311}-integration-{goethereum,ethtester}
lint
docs
benchmark
py{37,38,39,310}-wheel-cli
py{37,38,39,310,311}-wheel-cli

[isort]
combine_as_imports=True
Expand All @@ -28,7 +28,7 @@ extend-ignore=E203,W503

[testenv]
allowlist_externals=/usr/bin/make
install_command=python -m pip install --no-use-pep517 {opts} {packages}
install_command=python -m pip install {opts} {packages}
usedevelop=True
commands=
core: pytest {posargs:tests/core}
Expand Down Expand Up @@ -58,6 +58,7 @@ basepython =
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11

[testenv:lint]
basepython=python
Expand Down Expand Up @@ -111,6 +112,12 @@ allowlist_externals={[common-wheel-cli]allowlist_externals}
commands={[common-wheel-cli]commands}
skip_install=true

[testenv:py311-wheel-cli]
deps={[common-wheel-cli]deps}
allowlist_externals={[common-wheel-cli]allowlist_externals}
commands={[common-wheel-cli]commands}
skip_install=true

[common-wheel-cli-windows]
deps=wheel
allowlist_externals=
Expand Down
2 changes: 1 addition & 1 deletion web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def raise_contract_logic_error_on_revert(response: RPCResponse) -> RPCResponse:
if data[:10] == "0x556f1830":
parsed_data_as_bytes = to_bytes(hexstr=data[10:])
abi_decoded_data = abi.decode(
OFFCHAIN_LOOKUP_FIELDS.values(), parsed_data_as_bytes
list(OFFCHAIN_LOOKUP_FIELDS.values()), parsed_data_as_bytes
)
offchain_lookup_payload = dict(
zip(OFFCHAIN_LOOKUP_FIELDS.keys(), abi_decoded_data)
Expand Down
4 changes: 3 additions & 1 deletion web3/providers/eth_tester/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def call_eth_tester(
data_payload = parsed_data_as_bytes[
4:
] # everything but the function selector
abi_decoded_data = abi.decode(OFFCHAIN_LOOKUP_FIELDS.values(), data_payload)
abi_decoded_data = abi.decode(
list(OFFCHAIN_LOOKUP_FIELDS.values()), data_payload
)
offchain_lookup_payload = dict(
zip(OFFCHAIN_LOOKUP_FIELDS.keys(), abi_decoded_data)
)
Expand Down
5 changes: 5 additions & 0 deletions web3/providers/eth_tester/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ def is_hexstr(value: Any) -> bool:
"extra_data": "extraData",
"gas_used": "gasUsed",
"base_fee_per_gas": "baseFeePerGas",
"mix_hash": "mixHash",
# eth-tester changed the miner key to coinbase since
# there is no longer any mining happening, but the current
# JSON-RPC spec still says miner
"coinbase": "miner",
}
block_result_remapper = apply_key_map(BLOCK_RESULT_KEY_MAPPING)

Expand Down