Skip to content

Commit 31f7ab9

Browse files
author
Paul Robinson
authored
Deprecate Geth Admin StartRPC and StopRPC (#2507)
* deprecate geth admin start_rpc for start_http and stop_rpc for stop_http
1 parent ed49179 commit 31f7ab9

File tree

11 files changed

+176
-67
lines changed

11 files changed

+176
-67
lines changed

docs/providers.rst

+2-2
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

+18-6
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

+1
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

+17-6
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

+13-2
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

+6-1
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/admin.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
RPC,
1212
)
1313
from web3.method import (
14+
DeprecatedMethod,
1415
Method,
1516
default_root_munger,
1617
)
@@ -62,8 +63,8 @@ def __call__(
6263
pass
6364

6465

65-
start_rpc: Method[ServerConnection] = Method(
66-
RPC.admin_startRPC,
66+
start_http: Method[ServerConnection] = Method(
67+
RPC.admin_startHTTP,
6768
mungers=[admin_start_params_munger],
6869
)
6970

@@ -74,8 +75,8 @@ def __call__(
7475
)
7576

7677

77-
stop_rpc: Method[Callable[[], bool]] = Method(
78-
RPC.admin_stopRPC,
78+
stop_http: Method[Callable[[], bool]] = Method(
79+
RPC.admin_stopHTTP,
7980
is_property=True,
8081
)
8182

@@ -84,3 +85,9 @@ def __call__(
8485
RPC.admin_stopWS,
8586
is_property=True,
8687
)
88+
89+
#
90+
# Deprecated Methods
91+
#
92+
start_rpc = DeprecatedMethod(start_http, 'start_rpc', 'start_http')
93+
stop_rpc = DeprecatedMethod(stop_http, 'stop_rpc', 'stop_http')

web3/_utils/module_testing/go_ethereum_admin_module.py

+25-6
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

+5-2
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")

0 commit comments

Comments
 (0)