Skip to content

Commit 1bdb901

Browse files
committed
Rename all references of geth_poa to extradata_to_poa
- The middleware changed names in the refactor, but this commit puts the finishing touches and closes ethereum#899
1 parent 3823eb8 commit 1bdb901

File tree

8 files changed

+32
-26
lines changed

8 files changed

+32
-26
lines changed

docs/examples.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ Inject the middleware into the middleware onion
688688

689689
.. code-block:: python
690690
691-
from web3.middleware import geth_poa_middleware
692-
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
691+
from web3.middleware import extradata_to_poa_middleware
692+
w3.middleware_onion.inject(extradata_to_poa_middleware, layer=0)
693693
694694
Just remember that you have to sign all transactions locally, as infura does not handle any keys from your wallet ( refer to `this`_ )
695695

docs/middleware.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,15 @@ Time-based Cache Middleware
446446
Proof of Authority
447447
~~~~~~~~~~~~~~~~~~
448448

449-
.. py:method:: web3.middleware.geth_poa_middleware
450-
web3.middleware.async_geth_poa_middleware
449+
.. py:class:: web3.middleware.extradata_to_poa_middleware
451450
452451
.. note::
453452
It's important to inject the middleware at the 0th layer of the middleware onion:
454-
``w3.middleware_onion.inject(geth_poa_middleware, layer=0)``
453+
``w3.middleware_onion.inject(extradata_to_poa_middleware, layer=0)``
455454

456-
The ``geth_poa_middleware`` is required to connect to ``geth --dev`` or the Goerli
457-
public network. It may also be needed for other EVM compatible blockchains like Polygon
458-
or BNB Chain (Binance Smart Chain).
455+
The ``extradata_to_poa_middleware`` is required to connect to ``geth --dev`` and may
456+
also be needed for other EVM compatible blockchains like Polygon or
457+
BNB Chain (Binance Smart Chain).
459458

460459
If the middleware is not injected at the 0th layer of the middleware onion, you may get
461460
errors like the example below when interacting with your EVM node.
@@ -468,7 +467,8 @@ errors like the example below when interacting with your EVM node.
468467
for more details. The full extraData is: HexBytes('...')
469468
470469
471-
The easiest way to connect to a default ``geth --dev`` instance which loads the middleware is:
470+
The easiest way to connect to a default ``geth --dev`` instance which loads the
471+
middleware is:
472472

473473

474474
.. code-block:: python
@@ -489,25 +489,26 @@ unique IPC location and loads the middleware:
489489
# connect to the IPC location started with 'geth --dev --datadir ~/mynode'
490490
>>> w3 = Web3(IPCProvider('~/mynode/geth.ipc'))
491491
492-
>>> from web3.middleware import geth_poa_middleware
492+
>>> from web3.middleware import extradata_to_poa_middleware
493493
494494
# inject the poa compatibility middleware to the innermost layer (0th layer)
495-
>>> w3.middleware_onion.inject(geth_poa_middleware, layer=0)
495+
>>> w3.middleware_onion.inject(extradata_to_poa_middleware, layer=0)
496496
497497
# confirm that the connection succeeded
498498
>>> w3.client_version
499499
'Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9'
500500
501-
Why is ``geth_poa_middleware`` necessary?
502-
'''''''''''''''''''''''''''''''''''''''''
501+
Why is ``extradata_to_poa_middleware`` necessary?
502+
'''''''''''''''''''''''''''''''''''''''''''''''''
503503

504504
There is no strong community consensus on a single Proof-of-Authority (PoA) standard yet.
505505
Some nodes have successful experiments running though. One is go-ethereum (geth),
506506
which uses a prototype PoA for its development mode and the Goerli test network.
507507

508508
Unfortunately, it does deviate from the yellow paper specification, which constrains the
509-
``extraData`` field in each block to a maximum of 32-bytes. Geth's PoA uses more than
510-
32 bytes, so this middleware modifies the block data a bit before returning it.
509+
``extraData`` field in each block to a maximum of 32-bytes. Geth is one such example
510+
where PoA uses more than 32 bytes, so this middleware modifies the block data a bit
511+
before returning it.
511512

512513
.. _local-filter:
513514

docs/providers.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ AsyncHTTPProvider
467467
- :meth:`Attribute Dict Middleware <web3.middleware.async_attrdict_middleware>`
468468
- :meth:`Buffered Gas Estimate Middleware <web3.middleware.async_buffered_gas_estimate_middleware>`
469469
- :meth:`Gas Price Strategy Middleware <web3.middleware.async_gas_price_strategy_middleware>`
470-
- :meth:`Geth POA Middleware <web3.middleware.async_geth_poa_middleware>`
471470
- :meth:`Local Filter Middleware <web3.middleware.async_local_filter_middleware>`
472471
- :meth:`Simple Cache Middleware <web3.middleware.async_construct_simple_cache_middleware>`
473472
- :meth:`Stalecheck Middleware <web3.middleware.async_make_stalecheck_middleware>`

tests/core/eth-module/test_poa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_full_extra_data(w3, request_mocker):
2626
assert block.extraData == b"\xff" * 32
2727

2828

29-
def test_geth_proof_of_authority(w3, request_mocker):
29+
def test_extradata_to_poa_middleware(w3, request_mocker):
3030
w3.middleware_onion.inject(extradata_to_poa_middleware, layer=0)
3131

3232
with request_mocker(

web3/_utils/module_testing/eth_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ async def test_validation_middleware_chain_id_mismatch(
650650
await async_w3.eth.send_transaction(txn_params)
651651

652652
@pytest.mark.asyncio
653-
async def test_geth_poa_middleware(
653+
async def test_extradata_to_poa_middleware(
654654
self, async_w3: "AsyncWeb3", request_mocker: Type[RequestMocker]
655655
) -> None:
656656
async_w3.middleware_onion.inject(extradata_to_poa_middleware, "poa", layer=0)

web3/_utils/module_testing/persistent_connection_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ async def _mocked_recv_coro() -> bytes:
316316
async_w3.provider._ws.__setattr__("recv", actual_recv_fxn)
317317

318318
@pytest.mark.asyncio
319-
async def test_async_geth_poa_middleware_on_eth_subscription(
319+
async def test_async_extradata_to_poa_middleware_on_eth_subscription(
320320
self,
321321
async_w3: "_PersistentConnectionWeb3",
322322
) -> None:

web3/middleware/proof_of_authority.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,35 @@
3434

3535
is_not_null = complement(is_null)
3636

37-
remap_geth_poa_fields = apply_key_map(
37+
remap_extradata_to_poa_fields = apply_key_map(
3838
{
3939
"extraData": "proofOfAuthorityData",
4040
}
4141
)
4242

43-
pythonic_geth_poa = apply_formatters_to_dict(
43+
pythonic_extradata_to_poa = apply_formatters_to_dict(
4444
{
4545
"proofOfAuthorityData": HexBytes,
4646
}
4747
)
4848

49-
geth_poa_cleanup = compose(pythonic_geth_poa, remap_geth_poa_fields)
49+
extradata_to_poa_cleanup = compose(
50+
pythonic_extradata_to_poa, remap_extradata_to_poa_fields
51+
)
5052

5153

5254
extradata_to_poa_middleware = FormattingMiddlewareBuilder.build(
5355
result_formatters={
54-
RPC.eth_getBlockByHash: apply_formatter_if(is_not_null, geth_poa_cleanup),
55-
RPC.eth_getBlockByNumber: apply_formatter_if(is_not_null, geth_poa_cleanup),
56+
RPC.eth_getBlockByHash: apply_formatter_if(
57+
is_not_null, extradata_to_poa_cleanup
58+
),
59+
RPC.eth_getBlockByNumber: apply_formatter_if(
60+
is_not_null, extradata_to_poa_cleanup
61+
),
5662
RPC.eth_subscribe: apply_formatter_if(
5763
is_not_null,
5864
# original call to eth_subscribe returns a string, needs a dict check
59-
apply_formatter_if(is_dict, geth_poa_cleanup),
65+
apply_formatter_if(is_dict, extradata_to_poa_cleanup),
6066
),
6167
},
6268
)

web3/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class BlockData(TypedDict, total=False):
219219
withdrawals: Sequence[WithdrawalData]
220220
withdrawalsRoot: HexBytes
221221

222-
# geth_poa_middleware replaces extraData w/ proofOfAuthorityData
222+
# extradata_to_poa_middleware replaces extraData w/ proofOfAuthorityData
223223
proofOfAuthorityData: HexBytes
224224

225225

0 commit comments

Comments
 (0)