Skip to content

Commit e92c17a

Browse files
author
pacrob
committed
deprecate geth admin start_rpc for start_http and stop_rpc for stop_http
1 parent 90ed2cf commit e92c17a

File tree

10 files changed

+141
-51
lines changed

10 files changed

+141
-51
lines changed

docs/providers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ Geth
451451
- :meth:`web3.geth.admin.datadir() <web3.geth.admin.datadir>`
452452
- :meth:`web3.geth.admin.node_info() <web3.geth.admin.node_info>`
453453
- :meth:`web3.geth.admin.peers() <web3.geth.admin.peers>`
454-
- :meth:`web3.geth.admin.start_rpc() <web3.geth.admin.start_rpc>`
454+
- :meth:`web3.geth.admin.start_http() <web3.geth.admin.start_http>`
455455
- :meth:`web3.geth.admin.start_ws() <web3.geth.admin.start_ws>`
456-
- :meth:`web3.geth.admin.stop_rpc() <web3.geth.admin.stop_rpc>`
456+
- :meth:`web3.geth.admin.stop_http() <web3.geth.admin.stop_http>`
457457
- :meth:`web3.geth.admin.stop_ws() <web3.geth.admin.stop_ws>`
458458
- :meth:`web3.geth.personal.ec_recover()`
459459
- :meth:`web3.geth.personal.import_raw_key() <web3.geth.personal.import_raw_key>`

docs/web3.geth.rst

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und
112112
True
113113
114114
115-
.. py:method:: start_rpc(host='localhost', port=8545, cors="", apis="eth,net,web3")
115+
.. py:method:: start_http(host='localhost', port=8545, cors="", apis="eth,net,web3")
116116
117-
* Delegates to ``admin_startRPC`` RPC Method
117+
* Delegates to ``admin_startHTTP`` RPC Method
118118

119119
Starts the HTTP based JSON RPC API webserver on the specified ``host`` and
120120
``port``, with the ``rpccorsdomain`` set to the provided ``cors`` value and
@@ -123,8 +123,14 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und
123123

124124
.. code-block:: python
125125
126-
>>> web3.geth.admin.start_rpc()
126+
>>> web3.geth.admin.start_http()
127127
True
128+
129+
130+
.. py:method:: start_rpc()
131+
132+
.. warning:: Deprecated: This method is deprecated in favor of
133+
:meth:`~web3.geth.admin.start_http()`
128134

129135

130136
.. py:method:: start_ws(host='localhost', port=8546, cors="", apis="eth,net,web3")
@@ -142,18 +148,24 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und
142148
True
143149
144150
145-
.. py:method:: stop_rpc()
151+
.. py:method:: stop_http()
146152
147-
* Delegates to ``admin_stopRPC`` RPC Method
153+
* Delegates to ``admin_stopHTTP`` RPC Method
148154

149155
Stops the HTTP based JSON RPC server.
150156

151157
.. code-block:: python
152158
153-
>>> web3.geth.admin.stop_rpc()
159+
>>> web3.geth.admin.stop_http()
154160
True
155161
156162
163+
.. py:method:: stop_rpc()
164+
165+
.. warning:: Deprecated: This method is deprecated in favor of
166+
:meth:`~web3.geth.admin.stop_http()`
167+
168+
157169
.. py:method:: stop_ws()
158170
159171
* Delegates to ``admin_stopWS`` RPC Method

newsfragments/2507.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate Geth Admin StartRPC and StopRPC for StartHTTP and StopHTTP

tests/integration/go_ethereum/test_goethereum_http.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,21 @@ class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest):
104104
def test_admin_peers(self, w3: "Web3") -> None:
105105
super().test_admin_peers(w3)
106106

107-
def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
107+
def test_admin_start_stop_http(self, w3: "Web3") -> None:
108108
# This test causes all tests after it to fail on CI if it's allowed to run
109-
pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time')
110-
super().test_admin_start_stop_rpc(w3)
109+
pytest.xfail(reason='Only one HTTP endpoint is allowed to be active at any time')
110+
super().test_admin_start_stop_http(w3)
111111

112112
def test_admin_start_stop_ws(self, w3: "Web3") -> None:
113113
# This test causes all tests after it to fail on CI if it's allowed to run
114114
pytest.xfail(reason='Only one WS endpoint is allowed to be active at any time')
115115
super().test_admin_start_stop_ws(w3)
116116

117+
def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
118+
# This test causes all tests after it to fail on CI if it's allowed to run
119+
pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time')
120+
super().test_admin_start_stop_rpc(w3)
121+
117122

118123
class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest):
119124
pass
@@ -162,17 +167,23 @@ async def test_admin_peers(self, w3: "Web3") -> None:
162167
await super().test_admin_peers(w3)
163168

164169
@pytest.mark.asyncio
165-
async def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
170+
async def test_admin_start_stop_http(self, w3: "Web3") -> None:
166171
# This test causes all tests after it to fail on CI if it's allowed to run
167-
pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time')
168-
await super().test_admin_start_stop_rpc(w3)
172+
pytest.xfail(reason='Only one HTTP endpoint is allowed to be active at any time')
173+
await super().test_admin_start_stop_http(w3)
169174

170175
@pytest.mark.asyncio
171176
async def test_admin_start_stop_ws(self, w3: "Web3") -> None:
172177
# This test causes all tests after it to fail on CI if it's allowed to run
173178
pytest.xfail(reason='Only one WS endpoint is allowed to be active at any time')
174179
await super().test_admin_start_stop_ws(w3)
175180

181+
@pytest.mark.asyncio
182+
async def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
183+
# This test causes all tests after it to fail on CI if it's allowed to run
184+
pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time')
185+
await super().test_admin_start_stop_rpc(w3)
186+
176187

177188
class TestGoEthereumAsyncNetModuleTest(GoEthereumAsyncNetModuleTest):
178189
pass

tests/integration/go_ethereum/test_goethereum_ipc.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,21 @@ class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest):
6666
def test_admin_peers(w3):
6767
super().test_admin_peers(w3)
6868

69-
@pytest.mark.xfail(reason="websockets aren't enabled with our IPC flags")
70-
def test_admin_start_stop_ws(w3):
69+
def test_admin_start_stop_http(self, w3: "Web3") -> None:
70+
# This test causes all tests after it to fail on CI if it's allowed to run
71+
pytest.xfail(reason='Only one HTTP endpoint is allowed to be active at any time')
72+
super().test_admin_start_stop_http(w3)
73+
74+
def test_admin_start_stop_ws(self, w3: "Web3") -> None:
75+
# This test causes all tests after it to fail on CI if it's allowed to run
76+
pytest.xfail(reason='Only one WS endpoint is allowed to be active at any time')
7177
super().test_admin_start_stop_ws(w3)
7278

79+
def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
80+
# This test causes all tests after it to fail on CI if it's allowed to run
81+
pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time')
82+
super().test_admin_start_stop_rpc(w3)
83+
7384

7485
class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest):
7586
pass

tests/integration/go_ethereum/test_goethereum_ws.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,19 @@ class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest):
7979
def test_admin_peers(self, w3: "Web3") -> None:
8080
super().test_admin_peers(w3)
8181

82+
def test_admin_start_stop_http(self, w3: "Web3") -> None:
83+
# This test causes all tests after it to fail on CI if it's allowed to run
84+
pytest.xfail(reason='Only one HTTP endpoint is allowed to be active at any time')
85+
super().test_admin_start_stop_http(w3)
86+
8287
def test_admin_start_stop_ws(self, w3: "Web3") -> None:
8388
# This test inconsistently causes all tests after it to fail on CI if it's allowed to run
8489
pytest.xfail(reason='Only one WebSocket endpoint is allowed to be active at any time')
8590
super().test_admin_start_stop_ws(w3)
8691

8792
def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
8893
pytest.xfail(reason="This test inconsistently causes all tests after it on CI to fail if it's allowed to run") # noqa: E501
89-
super().test_admin_start_stop_ws(w3)
94+
super().test_admin_start_stop_rpc(w3)
9095

9196

9297
class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest):

web3/_utils/module_testing/go_ethereum_admin_module.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,22 @@ def test_admin_peers(self, w3: "Web3") -> None:
4545
result = w3.geth.admin.peers()
4646
assert len(result) == 1
4747

48-
def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
49-
stop = w3.geth.admin.stop_rpc()
48+
def test_admin_start_stop_http(self, w3: "Web3") -> None:
49+
stop = w3.geth.admin.stop_http()
5050
assert stop is True
5151

52-
start = w3.geth.admin.start_rpc()
52+
start = w3.geth.admin.start_http()
5353
assert start is True
5454

55+
def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
56+
with pytest.warns(DeprecationWarning, match='deprecated in favor of stop_http'):
57+
stop = w3.geth.admin.stop_rpc()
58+
assert stop is True
59+
60+
with pytest.warns(DeprecationWarning, match='deprecated in favor of start_http'):
61+
start = w3.geth.admin.start_rpc()
62+
assert start is True
63+
5564
def test_admin_start_stop_ws(self, w3: "Web3") -> None:
5665
stop = w3.geth.admin.stop_ws()
5766
assert stop is True
@@ -85,13 +94,23 @@ async def test_admin_peers(self, w3: "Web3") -> None:
8594
assert len(result) == 1
8695

8796
@pytest.mark.asyncio
88-
async def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
89-
stop = await w3.geth.admin.stop_rpc() # type: ignore
97+
async def test_admin_start_stop_http(self, w3: "Web3") -> None:
98+
stop = await w3.geth.admin.stop_http() # type: ignore
9099
assert stop is True
91100

92-
start = await w3.geth.admin.start_rpc() # type: ignore
101+
start = await w3.geth.admin.start_http() # type: ignore
93102
assert start is True
94103

104+
@pytest.mark.asyncio
105+
async def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
106+
with pytest.warns(DeprecationWarning, match='deprecated in favor of stop_http'):
107+
stop = await w3.geth.admin.stop_rpc()
108+
assert stop is True
109+
110+
with pytest.warns(DeprecationWarning, match='deprecated in favor of start_http'):
111+
start = await w3.geth.admin.start_rpc()
112+
assert start is True
113+
95114
@pytest.mark.asyncio
96115
async def test_admin_start_stop_ws(self, w3: "Web3") -> None:
97116
stop = await w3.geth.admin.stop_ws() # type: ignore

web3/_utils/rpc_abi.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ class RPC:
3434
admin_datadir = RPCEndpoint("admin_datadir")
3535
admin_nodeInfo = RPCEndpoint("admin_nodeInfo")
3636
admin_peers = RPCEndpoint("admin_peers")
37-
admin_startRPC = RPCEndpoint("admin_startRPC")
37+
admin_startHTTP = RPCEndpoint("admin_startHTTP")
3838
admin_startWS = RPCEndpoint("admin_startWS")
39-
admin_stopRPC = RPCEndpoint("admin_stopRPC")
39+
admin_stopHTTP = RPCEndpoint("admin_stopHTTP")
4040
admin_stopWS = RPCEndpoint("admin_stopWS")
41+
# deprecated
42+
admin_startRPC = RPCEndpoint("admin_startRPC")
43+
admin_stopRPC = RPCEndpoint("admin_stopRPC")
4144

4245
# eth
4346
eth_accounts = RPCEndpoint("eth_accounts")

web3/geth.py

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
datadir,
2222
node_info,
2323
peers,
24+
start_http,
2425
start_rpc,
2526
start_ws,
27+
stop_http,
2628
stop_rpc,
2729
stop_ws,
2830
)
31+
from web3._utils.decorators import (
32+
deprecated_for,
33+
)
2934
from web3._utils.miner import (
3035
make_dag,
3136
set_etherbase,
@@ -210,9 +215,12 @@ class BaseGethAdmin(Module):
210215
_datadir = datadir
211216
_node_info = node_info
212217
_peers = peers
213-
_start_rpc = start_rpc
218+
_start_http = start_http
214219
_start_ws = start_ws
220+
_stop_http = stop_http
215221
_stop_ws = stop_ws
222+
# deprecated
223+
_start_rpc = start_rpc
216224
_stop_rpc = stop_rpc
217225

218226

@@ -231,12 +239,12 @@ def node_info(self) -> NodeInfo:
231239
def peers(self) -> List[Peer]:
232240
return self._peers()
233241

234-
def start_rpc(self,
235-
host: str = "localhost",
236-
port: int = 8546,
237-
cors: str = "",
238-
apis: str = "eth,net,web3") -> bool:
239-
return self._start_rpc(host, port, cors, apis)
242+
def start_http(self,
243+
host: str = "localhost",
244+
port: int = 8546,
245+
cors: str = "",
246+
apis: str = "eth,net,web3") -> bool:
247+
return self._start_http(host, port, cors, apis)
240248

241249
def start_ws(self,
242250
host: str = "localhost",
@@ -245,12 +253,24 @@ def start_ws(self,
245253
apis: str = "eth,net,web3") -> bool:
246254
return self._start_ws(host, port, cors, apis)
247255

248-
def stop_rpc(self) -> bool:
256+
def stop_http(self) -> bool:
249257
return self._stop_rpc()
250258

251259
def stop_ws(self) -> bool:
252260
return self._stop_ws()
253261

262+
@deprecated_for("start_http")
263+
def start_rpc(self,
264+
host: str = "localhost",
265+
port: int = 8546,
266+
cors: str = "",
267+
apis: str = "eth,net,web3") -> bool:
268+
return self._start_rpc(host, port, cors, apis)
269+
270+
@deprecated_for("stop_http")
271+
def stop_rpc(self) -> bool:
272+
return self._stop_rpc()
273+
254274

255275
class AsyncGethAdmin(BaseGethAdmin):
256276
is_async = True
@@ -267,12 +287,12 @@ async def node_info(self) -> Awaitable[NodeInfo]:
267287
async def peers(self) -> Awaitable[List[Peer]]:
268288
return await self._peers() # type: ignore
269289

270-
async def start_rpc(self,
271-
host: str = "localhost",
272-
port: int = 8546,
273-
cors: str = "",
274-
apis: str = "eth,net,web3") -> Awaitable[bool]:
275-
return await self._start_rpc(host, port, cors, apis) # type: ignore
290+
async def start_http(self,
291+
host: str = "localhost",
292+
port: int = 8546,
293+
cors: str = "",
294+
apis: str = "eth,net,web3") -> Awaitable[bool]:
295+
return await self._start_http(host, port, cors, apis) # type: ignore
276296

277297
async def start_ws(self,
278298
host: str = "localhost",
@@ -281,12 +301,24 @@ async def start_ws(self,
281301
apis: str = "eth,net,web3") -> Awaitable[bool]:
282302
return await self._start_ws(host, port, cors, apis) # type: ignore
283303

284-
async def stop_rpc(self) -> Awaitable[bool]:
285-
return await self._stop_rpc() # type: ignore
304+
async def stop_http(self) -> Awaitable[bool]:
305+
return await self._stop_http() # type: ignore
286306

287307
async def stop_ws(self) -> Awaitable[bool]:
288308
return await self._stop_ws() # type: ignore
289309

310+
@deprecated_for("start_http")
311+
async def start_rpc(self,
312+
host: str = "localhost",
313+
port: int = 8546,
314+
cors: str = "",
315+
apis: str = "eth,net,web3") -> Awaitable[bool]:
316+
return await self._start_rpc(host, port, cors, apis)
317+
318+
@deprecated_for("stop_http")
319+
async def stop_rpc(self) -> Awaitable[bool]:
320+
return await self._stop_rpc()
321+
290322

291323
class GethMiner(Module):
292324
"""

web3/providers/eth_tester/defaults.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,20 +320,16 @@ def personal_send_transaction(eth_tester: "EthereumTester", params: Any) -> HexS
320320
},
321321
'admin': {
322322
'add_peer': not_implemented,
323+
'datadir': not_implemented,
323324
'node_info': not_implemented,
324-
'start_rpc': not_implemented,
325+
'peers': not_implemented,
326+
'start_http': not_implemented,
325327
'start_ws': not_implemented,
326-
'stop_rpc': not_implemented,
328+
'stop_http': not_implemented,
327329
'stop_ws': not_implemented,
328330
# deprecated
329-
'addPeer': not_implemented,
330-
'datadir': not_implemented,
331-
'nodeInfo': not_implemented,
332-
'peers': not_implemented,
333-
'startRPC': not_implemented,
334-
'startWS': not_implemented,
335-
'stopRPC': not_implemented,
336-
'stopWS': not_implemented,
331+
'start_rpc': not_implemented,
332+
'stop_rpc': not_implemented,
337333
},
338334
'debug': {
339335
'backtraceAt': not_implemented,

0 commit comments

Comments
 (0)