Skip to content

Commit

Permalink
Support Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Dec 16, 2022
1 parent e04acaf commit 927abbd
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 32 deletions.
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.

11 changes: 6 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
5 changes: 3 additions & 2 deletions tests/core/middleware/test_eth_tester_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def test_get_block_formatters(w3):
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 len(keys_diff) == 2
# mixHash and miner not implemented in eth-tester
assert keys_diff == set(["mixHash", "miner"])


@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
4 changes: 4 additions & 0 deletions web3/providers/eth_tester/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ def is_hexstr(value: Any) -> bool:
"extra_data": "extraData",
"gas_used": "gasUsed",
"base_fee_per_gas": "baseFeePerGas",
# 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

0 comments on commit 927abbd

Please sign in to comment.