We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Redundant async/await in AsyncJSONBaseProvider serde methods
* Version: 5.20
* Python: 3.9.5
* OS: Linux

```
aiohttp==3.7.4.post0
web3==5.20
```


### What was wrong?

Serde methods internally do not await on any coroutines, so there is no reason to have them `async`

### How can it be fixed?

Remove `async/await` in those methods.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `web3/providers/async_base.py`
Content:
```
1 import itertools
2 from typing import (
3     TYPE_CHECKING,
4     Any,
5     Callable,
6     Sequence,
7     Tuple,
8     cast,
9 )
10 import warnings
11 
12 from eth_utils import (
13     to_bytes,
14     to_text,
15 )
16 
17 from web3._utils.encoding import (
18     FriendlyJsonSerde,
19 )
20 from web3.middleware import (
21     async_combine_middlewares,
22 )
23 from web3.types import (
24     Middleware,
25     MiddlewareOnion,
26     RPCEndpoint,
27     RPCResponse,
28 )
29 
30 if TYPE_CHECKING:
31     from web3 import Web3  # noqa: F401
32 
33 
34 class AsyncBaseProvider:
35     _middlewares: Tuple[Middleware, ...] = ()
36     # a tuple of (all_middlewares, request_func)
37     _request_func_cache: Tuple[Tuple[Middleware, ...], Callable[..., RPCResponse]] = (None, None)
38 
39     def __init__(self) -> None:
40         warnings.warn(
41             "Async providers are still being developed and refined. "
42             "Expect breaking changes in minor releases.")
43 
44     @property
45     def middlewares(self) -> Tuple[Middleware, ...]:
46         return self._middlewares
47 
48     @middlewares.setter
49     def middlewares(
50         self, values: MiddlewareOnion
51     ) -> None:
52         # tuple(values) converts to MiddlewareOnion -> Tuple[Middleware, ...]
53         self._middlewares = tuple(values)  # type: ignore
54 
55     async def request_func(
56         self, web3: "Web3", outer_middlewares: MiddlewareOnion
57     ) -> Callable[[RPCEndpoint], Any]:
58         all_middlewares: Tuple[Middleware] = tuple(outer_middlewares) + tuple(self.middlewares)  # type: ignore # noqa: E501
59 
60         cache_key = self._request_func_cache[0]
61         if cache_key is None or cache_key != all_middlewares:
62             self._request_func_cache = (
63                 all_middlewares,
64                 await self._generate_request_func(web3, all_middlewares)
65             )
66         return self._request_func_cache[-1]
67 
68     async def _generate_request_func(
69         self, web3: "Web3", middlewares: Sequence[Middleware]
70     ) -> Callable[..., RPCResponse]:
71         return await async_combine_middlewares(
72             middlewares=middlewares,
73             web3=web3,
74             provider_request_fn=self.make_request,
75         )
76 
77     async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
78         raise NotImplementedError("Providers must implement this method")
79 
80     async def isConnected(self) -> bool:
81         raise NotImplementedError("Providers must implement this method")
82 
83 
84 class AsyncJSONBaseProvider(AsyncBaseProvider):
85     def __init__(self) -> None:
86         self.request_counter = itertools.count()
87 
88     async def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:
89         rpc_dict = {
90             "jsonrpc": "2.0",
91             "method": method,
92             "params": params or [],
93             "id": next(self.request_counter),
94         }
95         encoded = FriendlyJsonSerde().json_encode(rpc_dict)
96         return to_bytes(text=encoded)
97 
98     async def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:
99         text_response = to_text(raw_response)
100         return cast(RPCResponse, FriendlyJsonSerde().json_decode(text_response))
101 
102     async def isConnected(self) -> bool:
103         try:
104             response = await self.make_request(RPCEndpoint('web3_clientVersion'), [])
105         except IOError:
106             return False
107 
108         assert response['jsonrpc'] == '2.0'
109         assert 'error' not in response
110 
111         return True
112
```

Path: `web3/providers/async_rpc.py`
Content:
```
1 import logging
2 from typing import (
3     Any,
4     Dict,
5     Iterable,
6     Optional,
7     Tuple,
8     Union,
9 )
10 
11 from eth_typing import (
12     URI,
13 )
14 from eth_utils import (
15     to_dict,
16 )
17 
18 from web3._utils.http import (
19     construct_user_agent,
20 )
21 from web3._utils.request import (
22     async_make_post_request,
23     get_default_http_endpoint,
24 )
25 from web3.types import (
26     RPCEndpoint,
27     RPCResponse,
28 )
29 
30 from .async_base import (
31     AsyncJSONBaseProvider,
32 )
33 
34 
35 class AsyncHTTPProvider(AsyncJSONBaseProvider):
36     logger = logging.getLogger("web3.providers.HTTPProvider")
37     endpoint_uri = None
38     _request_kwargs = None
39 
40     def __init__(
41         self, endpoint_uri: Optional[Union[URI, str]] = None,
42             request_kwargs: Optional[Any] = None
43     ) -> None:
44         if endpoint_uri is None:
45             self.endpoint_uri = get_default_http_endpoint()
46         else:
47             self.endpoint_uri = URI(endpoint_uri)
48 
49         self._request_kwargs = request_kwargs or {}
50 
51         super().__init__()
52 
53     def __str__(self) -> str:
54         return "RPC connection {0}".format(self.endpoint_uri)
55 
56     @to_dict
57     def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]:
58         if 'headers' not in self._request_kwargs:
59             yield 'headers', self.get_request_headers()
60         for key, value in self._request_kwargs.items():
61             yield key, value
62 
63     def get_request_headers(self) -> Dict[str, str]:
64         return {
65             'Content-Type': 'application/json',
66             'User-Agent': construct_user_agent(str(type(self))),
67         }
68 
69     async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
70         self.logger.debug("Making request HTTP. URI: %s, Method: %s",
71                           self.endpoint_uri, method)
72         request_data = await self.encode_rpc_request(method, params)
73         raw_response = await async_make_post_request(
74             self.endpoint_uri,
75             request_data,
76             **self.get_request_kwargs()
77         )
78         response = await self.decode_rpc_response(raw_response)
79         self.logger.debug("Getting response HTTP. URI: %s, "
80                           "Method: %s, Response: %s",
81                           self.endpoint_uri, method, response)
82         return response
83
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/web3/providers/async_base.py b/web3/providers/async_base.py
--- a/web3/providers/async_base.py
+++ b/web3/providers/async_base.py
@@ -85,7 +85,7 @@
     def __init__(self) -> None:
         self.request_counter = itertools.count()
 
-    async def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:
+    def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:
         rpc_dict = {
             "jsonrpc": "2.0",
             "method": method,
@@ -95,7 +95,7 @@
         encoded = FriendlyJsonSerde().json_encode(rpc_dict)
         return to_bytes(text=encoded)
 
-    async def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:
+    def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:
         text_response = to_text(raw_response)
         return cast(RPCResponse, FriendlyJsonSerde().json_decode(text_response))
 
diff --git a/web3/providers/async_rpc.py b/web3/providers/async_rpc.py
--- a/web3/providers/async_rpc.py
+++ b/web3/providers/async_rpc.py
@@ -69,13 +69,13 @@
     async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
         self.logger.debug("Making request HTTP. URI: %s, Method: %s",
                           self.endpoint_uri, method)
-        request_data = await self.encode_rpc_request(method, params)
+        request_data = self.encode_rpc_request(method, params)
         raw_response = await async_make_post_request(
             self.endpoint_uri,
             request_data,
             **self.get_request_kwargs()
         )
-        response = await self.decode_rpc_response(raw_response)
+        response = self.decode_rpc_response(raw_response)
         self.logger.debug("Getting response HTTP. URI: %s, "
                           "Method: %s, Response: %s",
                           self.endpoint_uri, method, response)

{"golden_diff": "diff --git a/web3/providers/async_base.py b/web3/providers/async_base.py\n--- a/web3/providers/async_base.py\n+++ b/web3/providers/async_base.py\n@@ -85,7 +85,7 @@\n     def __init__(self) -> None:\n         self.request_counter = itertools.count()\n \n-    async def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:\n+    def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:\n         rpc_dict = {\n             \"jsonrpc\": \"2.0\",\n             \"method\": method,\n@@ -95,7 +95,7 @@\n         encoded = FriendlyJsonSerde().json_encode(rpc_dict)\n         return to_bytes(text=encoded)\n \n-    async def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:\n+    def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:\n         text_response = to_text(raw_response)\n         return cast(RPCResponse, FriendlyJsonSerde().json_decode(text_response))\n \ndiff --git a/web3/providers/async_rpc.py b/web3/providers/async_rpc.py\n--- a/web3/providers/async_rpc.py\n+++ b/web3/providers/async_rpc.py\n@@ -69,13 +69,13 @@\n     async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:\n         self.logger.debug(\"Making request HTTP. URI: %s, Method: %s\",\n                           self.endpoint_uri, method)\n-        request_data = await self.encode_rpc_request(method, params)\n+        request_data = self.encode_rpc_request(method, params)\n         raw_response = await async_make_post_request(\n             self.endpoint_uri,\n             request_data,\n             **self.get_request_kwargs()\n         )\n-        response = await self.decode_rpc_response(raw_response)\n+        response = self.decode_rpc_response(raw_response)\n         self.logger.debug(\"Getting response HTTP. URI: %s, \"\n                           \"Method: %s, Response: %s\",\n                           self.endpoint_uri, method, response)\n", "issue": "Redundant async/await in AsyncJSONBaseProvider serde methods\n* Version: 5.20\r\n* Python: 3.9.5\r\n* OS: Linux\r\n\r\n```\r\naiohttp==3.7.4.post0\r\nweb3==5.20\r\n```\r\n\r\n\r\n### What was wrong?\r\n\r\nSerde methods internally do not await on any coroutines, so there is no reason to have them `async`\r\n\r\n### How can it be fixed?\r\n\r\nRemove `async/await` in those methods.\r\n\n", "before_files": [{"content": "import itertools\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    Callable,\n    Sequence,\n    Tuple,\n    cast,\n)\nimport warnings\n\nfrom eth_utils import (\n    to_bytes,\n    to_text,\n)\n\nfrom web3._utils.encoding import (\n    FriendlyJsonSerde,\n)\nfrom web3.middleware import (\n    async_combine_middlewares,\n)\nfrom web3.types import (\n    Middleware,\n    MiddlewareOnion,\n    RPCEndpoint,\n    RPCResponse,\n)\n\nif TYPE_CHECKING:\n    from web3 import Web3  # noqa: F401\n\n\nclass AsyncBaseProvider:\n    _middlewares: Tuple[Middleware, ...] = ()\n    # a tuple of (all_middlewares, request_func)\n    _request_func_cache: Tuple[Tuple[Middleware, ...], Callable[..., RPCResponse]] = (None, None)\n\n    def __init__(self) -> None:\n        warnings.warn(\n            \"Async providers are still being developed and refined. \"\n            \"Expect breaking changes in minor releases.\")\n\n    @property\n    def middlewares(self) -> Tuple[Middleware, ...]:\n        return self._middlewares\n\n    @middlewares.setter\n    def middlewares(\n        self, values: MiddlewareOnion\n    ) -> None:\n        # tuple(values) converts to MiddlewareOnion -> Tuple[Middleware, ...]\n        self._middlewares = tuple(values)  # type: ignore\n\n    async def request_func(\n        self, web3: \"Web3\", outer_middlewares: MiddlewareOnion\n    ) -> Callable[[RPCEndpoint], Any]:\n        all_middlewares: Tuple[Middleware] = tuple(outer_middlewares) + tuple(self.middlewares)  # type: ignore # noqa: E501\n\n        cache_key = self._request_func_cache[0]\n        if cache_key is None or cache_key != all_middlewares:\n            self._request_func_cache = (\n                all_middlewares,\n                await self._generate_request_func(web3, all_middlewares)\n            )\n        return self._request_func_cache[-1]\n\n    async def _generate_request_func(\n        self, web3: \"Web3\", middlewares: Sequence[Middleware]\n    ) -> Callable[..., RPCResponse]:\n        return await async_combine_middlewares(\n            middlewares=middlewares,\n            web3=web3,\n            provider_request_fn=self.make_request,\n        )\n\n    async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:\n        raise NotImplementedError(\"Providers must implement this method\")\n\n    async def isConnected(self) -> bool:\n        raise NotImplementedError(\"Providers must implement this method\")\n\n\nclass AsyncJSONBaseProvider(AsyncBaseProvider):\n    def __init__(self) -> None:\n        self.request_counter = itertools.count()\n\n    async def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:\n        rpc_dict = {\n            \"jsonrpc\": \"2.0\",\n            \"method\": method,\n            \"params\": params or [],\n            \"id\": next(self.request_counter),\n        }\n        encoded = FriendlyJsonSerde().json_encode(rpc_dict)\n        return to_bytes(text=encoded)\n\n    async def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:\n        text_response = to_text(raw_response)\n        return cast(RPCResponse, FriendlyJsonSerde().json_decode(text_response))\n\n    async def isConnected(self) -> bool:\n        try:\n            response = await self.make_request(RPCEndpoint('web3_clientVersion'), [])\n        except IOError:\n            return False\n\n        assert response['jsonrpc'] == '2.0'\n        assert 'error' not in response\n\n        return True\n", "path": "web3/providers/async_base.py"}, {"content": "import logging\nfrom typing import (\n    Any,\n    Dict,\n    Iterable,\n    Optional,\n    Tuple,\n    Union,\n)\n\nfrom eth_typing import (\n    URI,\n)\nfrom eth_utils import (\n    to_dict,\n)\n\nfrom web3._utils.http import (\n    construct_user_agent,\n)\nfrom web3._utils.request import (\n    async_make_post_request,\n    get_default_http_endpoint,\n)\nfrom web3.types import (\n    RPCEndpoint,\n    RPCResponse,\n)\n\nfrom .async_base import (\n    AsyncJSONBaseProvider,\n)\n\n\nclass AsyncHTTPProvider(AsyncJSONBaseProvider):\n    logger = logging.getLogger(\"web3.providers.HTTPProvider\")\n    endpoint_uri = None\n    _request_kwargs = None\n\n    def __init__(\n        self, endpoint_uri: Optional[Union[URI, str]] = None,\n            request_kwargs: Optional[Any] = None\n    ) -> None:\n        if endpoint_uri is None:\n            self.endpoint_uri = get_default_http_endpoint()\n        else:\n            self.endpoint_uri = URI(endpoint_uri)\n\n        self._request_kwargs = request_kwargs or {}\n\n        super().__init__()\n\n    def __str__(self) -> str:\n        return \"RPC connection {0}\".format(self.endpoint_uri)\n\n    @to_dict\n    def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]:\n        if 'headers' not in self._request_kwargs:\n            yield 'headers', self.get_request_headers()\n        for key, value in self._request_kwargs.items():\n            yield key, value\n\n    def get_request_headers(self) -> Dict[str, str]:\n        return {\n            'Content-Type': 'application/json',\n            'User-Agent': construct_user_agent(str(type(self))),\n        }\n\n    async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:\n        self.logger.debug(\"Making request HTTP. URI: %s, Method: %s\",\n                          self.endpoint_uri, method)\n        request_data = await self.encode_rpc_request(method, params)\n        raw_response = await async_make_post_request(\n            self.endpoint_uri,\n            request_data,\n            **self.get_request_kwargs()\n        )\n        response = await self.decode_rpc_response(raw_response)\n        self.logger.debug(\"Getting response HTTP. URI: %s, \"\n                          \"Method: %s, Response: %s\",\n                          self.endpoint_uri, method, response)\n        return response\n", "path": "web3/providers/async_rpc.py"}], "after_files": [{"content": "import itertools\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    Callable,\n    Sequence,\n    Tuple,\n    cast,\n)\nimport warnings\n\nfrom eth_utils import (\n    to_bytes,\n    to_text,\n)\n\nfrom web3._utils.encoding import (\n    FriendlyJsonSerde,\n)\nfrom web3.middleware import (\n    async_combine_middlewares,\n)\nfrom web3.types import (\n    Middleware,\n    MiddlewareOnion,\n    RPCEndpoint,\n    RPCResponse,\n)\n\nif TYPE_CHECKING:\n    from web3 import Web3  # noqa: F401\n\n\nclass AsyncBaseProvider:\n    _middlewares: Tuple[Middleware, ...] = ()\n    # a tuple of (all_middlewares, request_func)\n    _request_func_cache: Tuple[Tuple[Middleware, ...], Callable[..., RPCResponse]] = (None, None)\n\n    def __init__(self) -> None:\n        warnings.warn(\n            \"Async providers are still being developed and refined. \"\n            \"Expect breaking changes in minor releases.\")\n\n    @property\n    def middlewares(self) -> Tuple[Middleware, ...]:\n        return self._middlewares\n\n    @middlewares.setter\n    def middlewares(\n        self, values: MiddlewareOnion\n    ) -> None:\n        # tuple(values) converts to MiddlewareOnion -> Tuple[Middleware, ...]\n        self._middlewares = tuple(values)  # type: ignore\n\n    async def request_func(\n        self, web3: \"Web3\", outer_middlewares: MiddlewareOnion\n    ) -> Callable[[RPCEndpoint], Any]:\n        all_middlewares: Tuple[Middleware] = tuple(outer_middlewares) + tuple(self.middlewares)  # type: ignore # noqa: E501\n\n        cache_key = self._request_func_cache[0]\n        if cache_key is None or cache_key != all_middlewares:\n            self._request_func_cache = (\n                all_middlewares,\n                await self._generate_request_func(web3, all_middlewares)\n            )\n        return self._request_func_cache[-1]\n\n    async def _generate_request_func(\n        self, web3: \"Web3\", middlewares: Sequence[Middleware]\n    ) -> Callable[..., RPCResponse]:\n        return await async_combine_middlewares(\n            middlewares=middlewares,\n            web3=web3,\n            provider_request_fn=self.make_request,\n        )\n\n    async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:\n        raise NotImplementedError(\"Providers must implement this method\")\n\n    async def isConnected(self) -> bool:\n        raise NotImplementedError(\"Providers must implement this method\")\n\n\nclass AsyncJSONBaseProvider(AsyncBaseProvider):\n    def __init__(self) -> None:\n        self.request_counter = itertools.count()\n\n    def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:\n        rpc_dict = {\n            \"jsonrpc\": \"2.0\",\n            \"method\": method,\n            \"params\": params or [],\n            \"id\": next(self.request_counter),\n        }\n        encoded = FriendlyJsonSerde().json_encode(rpc_dict)\n        return to_bytes(text=encoded)\n\n    def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:\n        text_response = to_text(raw_response)\n        return cast(RPCResponse, FriendlyJsonSerde().json_decode(text_response))\n\n    async def isConnected(self) -> bool:\n        try:\n            response = await self.make_request(RPCEndpoint('web3_clientVersion'), [])\n        except IOError:\n            return False\n\n        assert response['jsonrpc'] == '2.0'\n        assert 'error' not in response\n\n        return True\n", "path": "web3/providers/async_base.py"}, {"content": "import logging\nfrom typing import (\n    Any,\n    Dict,\n    Iterable,\n    Optional,\n    Tuple,\n    Union,\n)\n\nfrom eth_typing import (\n    URI,\n)\nfrom eth_utils import (\n    to_dict,\n)\n\nfrom web3._utils.http import (\n    construct_user_agent,\n)\nfrom web3._utils.request import (\n    async_make_post_request,\n    get_default_http_endpoint,\n)\nfrom web3.types import (\n    RPCEndpoint,\n    RPCResponse,\n)\n\nfrom .async_base import (\n    AsyncJSONBaseProvider,\n)\n\n\nclass AsyncHTTPProvider(AsyncJSONBaseProvider):\n    logger = logging.getLogger(\"web3.providers.HTTPProvider\")\n    endpoint_uri = None\n    _request_kwargs = None\n\n    def __init__(\n        self, endpoint_uri: Optional[Union[URI, str]] = None,\n            request_kwargs: Optional[Any] = None\n    ) -> None:\n        if endpoint_uri is None:\n            self.endpoint_uri = get_default_http_endpoint()\n        else:\n            self.endpoint_uri = URI(endpoint_uri)\n\n        self._request_kwargs = request_kwargs or {}\n\n        super().__init__()\n\n    def __str__(self) -> str:\n        return \"RPC connection {0}\".format(self.endpoint_uri)\n\n    @to_dict\n    def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]:\n        if 'headers' not in self._request_kwargs:\n            yield 'headers', self.get_request_headers()\n        for key, value in self._request_kwargs.items():\n            yield key, value\n\n    def get_request_headers(self) -> Dict[str, str]:\n        return {\n            'Content-Type': 'application/json',\n            'User-Agent': construct_user_agent(str(type(self))),\n        }\n\n    async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:\n        self.logger.debug(\"Making request HTTP. URI: %s, Method: %s\",\n                          self.endpoint_uri, method)\n        request_data = self.encode_rpc_request(method, params)\n        raw_response = await async_make_post_request(\n            self.endpoint_uri,\n            request_data,\n            **self.get_request_kwargs()\n        )\n        response = self.decode_rpc_response(raw_response)\n        self.logger.debug(\"Getting response HTTP. URI: %s, \"\n                          \"Method: %s, Response: %s\",\n                          self.endpoint_uri, method, response)\n        return response\n", "path": "web3/providers/async_rpc.py"}]}