Skip to content

Commit 89d8145

Browse files
committed
Clean up unnecessary persistent connection logic for batch:
- Now that we separate send and receive for batching, we no longer have to create a workaround for response formatters to contract calls. We pass all response formatters together as we do with regular contract calls, to be applited to the response as it comes back. - from comment on PR #3705: move skip marker to decorator
1 parent c94ff95 commit 89d8145

File tree

3 files changed

+3
-41
lines changed

3 files changed

+3
-41
lines changed

tests/integration/go_ethereum/test_goethereum_legacy_ws.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ def w3(start_geth_process_and_yield_port):
5555
return _w3
5656

5757

58+
@pytest.mark.skip("LegacyWebSocketProvider does not support concurrent requests")
5859
class TestGoEthereumWeb3ModuleTest(GoEthereumWeb3ModuleTest):
5960
def test_batch_requests_concurrently_with_regular_requests(
6061
self, w3: "Web3"
6162
) -> None:
62-
pytest.skip("LegacyWebSocketProvider does not support concurrent requests")
63+
pass
6364

6465

6566
class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest):

web3/contract/utils.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
from web3._utils.batching import (
4747
BatchRequestInformation,
4848
)
49-
from web3._utils.compat import (
50-
TypeAlias,
51-
)
5249
from web3._utils.contracts import (
5350
prepare_transaction,
5451
)
@@ -65,7 +62,6 @@
6562
from web3.types import (
6663
ABIElementIdentifier,
6764
BlockIdentifier,
68-
RPCEndpoint,
6965
StateOverride,
7066
TContractEvent,
7167
TContractFn,
@@ -485,8 +481,7 @@ async def async_call_contract_function(
485481
output_types,
486482
)
487483

488-
BatchingReturnData: TypeAlias = Tuple[Tuple[RPCEndpoint, Any], Tuple[Any, ...]]
489-
request_information = tuple(cast(BatchingReturnData, return_data))
484+
request_information = tuple(cast(BatchRequestInformation, return_data))
490485
method_and_params = request_information[0]
491486

492487
# append return data formatter to result formatters
@@ -503,8 +498,6 @@ async def async_call_contract_function(
503498
)
504499
return (method_and_params, response_formatters)
505500

506-
return return_data
507-
508501
try:
509502
output_data = async_w3.codec.decode(output_types, return_data)
510503
except DecodingError as e:

web3/providers/persistent/request_processor.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
Union,
1414
)
1515

16-
from eth_utils.toolz import (
17-
compose,
18-
)
19-
2016
from web3._utils.batching import (
2117
BATCH_REQUEST_ID,
2218
)
@@ -228,34 +224,6 @@ def get_request_information_for_response(
228224

229225
return request_info
230226

231-
def append_result_formatter_for_request(
232-
self, request_id: int, result_formatter: Callable[..., Any]
233-
) -> None:
234-
cache_key = generate_cache_key(request_id)
235-
cached_request_info_for_id: RequestInformation = (
236-
self._request_information_cache.get_cache_entry(cache_key)
237-
)
238-
if cached_request_info_for_id is not None:
239-
(
240-
current_result_formatters,
241-
error_formatters,
242-
null_result_formatters,
243-
) = cached_request_info_for_id.response_formatters
244-
cached_request_info_for_id.response_formatters = (
245-
compose(
246-
result_formatter,
247-
current_result_formatters,
248-
),
249-
error_formatters,
250-
null_result_formatters,
251-
)
252-
else:
253-
self._provider.logger.debug(
254-
"No cached request info for response id `%s`. Cannot "
255-
"append response formatter for response.",
256-
request_id,
257-
)
258-
259227
def append_middleware_response_processor(
260228
self,
261229
response: RPCResponse,

0 commit comments

Comments
 (0)