Skip to content

Deprecate Geth Admin StartRPC and StopRPC #2507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/providers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,9 @@ Geth
- :meth:`web3.geth.admin.datadir() <web3.geth.admin.datadir>`
- :meth:`web3.geth.admin.node_info() <web3.geth.admin.node_info>`
- :meth:`web3.geth.admin.peers() <web3.geth.admin.peers>`
- :meth:`web3.geth.admin.start_rpc() <web3.geth.admin.start_rpc>`
- :meth:`web3.geth.admin.start_http() <web3.geth.admin.start_http>`
- :meth:`web3.geth.admin.start_ws() <web3.geth.admin.start_ws>`
- :meth:`web3.geth.admin.stop_rpc() <web3.geth.admin.stop_rpc>`
- :meth:`web3.geth.admin.stop_http() <web3.geth.admin.stop_http>`
- :meth:`web3.geth.admin.stop_ws() <web3.geth.admin.stop_ws>`
- :meth:`web3.geth.personal.ec_recover()`
- :meth:`web3.geth.personal.import_raw_key() <web3.geth.personal.import_raw_key>`
Expand Down
24 changes: 18 additions & 6 deletions docs/web3.geth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und
True


.. py:method:: start_rpc(host='localhost', port=8545, cors="", apis="eth,net,web3")
.. py:method:: start_http(host='localhost', port=8545, cors="", apis="eth,net,web3")

* Delegates to ``admin_startRPC`` RPC Method
* Delegates to ``admin_startHTTP`` RPC Method

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

.. code-block:: python

>>> web3.geth.admin.start_rpc()
>>> web3.geth.admin.start_http()
True


.. py:method:: start_rpc()

.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.admin.start_http()`


.. py:method:: start_ws(host='localhost', port=8546, cors="", apis="eth,net,web3")
Expand All @@ -142,18 +148,24 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und
True


.. py:method:: stop_rpc()
.. py:method:: stop_http()

* Delegates to ``admin_stopRPC`` RPC Method
* Delegates to ``admin_stopHTTP`` RPC Method

Stops the HTTP based JSON RPC server.

.. code-block:: python

>>> web3.geth.admin.stop_rpc()
>>> web3.geth.admin.stop_http()
True


.. py:method:: stop_rpc()

.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.admin.stop_http()`


.. py:method:: stop_ws()

* Delegates to ``admin_stopWS`` RPC Method
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2507.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate Geth Admin StartRPC and StopRPC for StartHTTP and StopHTTP
23 changes: 17 additions & 6 deletions tests/integration/go_ethereum/test_goethereum_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,21 @@ class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest):
def test_admin_peers(self, w3: "Web3") -> None:
super().test_admin_peers(w3)

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

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

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


class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest):
pass
Expand Down Expand Up @@ -162,17 +167,23 @@ async def test_admin_peers(self, w3: "Web3") -> None:
await super().test_admin_peers(w3)

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

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

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


class TestGoEthereumAsyncNetModuleTest(GoEthereumAsyncNetModuleTest):
pass
Expand Down
15 changes: 13 additions & 2 deletions tests/integration/go_ethereum/test_goethereum_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,21 @@ class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest):
def test_admin_peers(w3):
super().test_admin_peers(w3)

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

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

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


class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest):
pass
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/go_ethereum/test_goethereum_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@ class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest):
def test_admin_peers(self, w3: "Web3") -> None:
super().test_admin_peers(w3)

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

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

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


class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest):
Expand Down
15 changes: 11 additions & 4 deletions web3/_utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
RPC,
)
from web3.method import (
DeprecatedMethod,
Method,
default_root_munger,
)
Expand Down Expand Up @@ -62,8 +63,8 @@ def __call__(
pass


start_rpc: Method[ServerConnection] = Method(
RPC.admin_startRPC,
start_http: Method[ServerConnection] = Method(
RPC.admin_startHTTP,
mungers=[admin_start_params_munger],
)

Expand All @@ -74,8 +75,8 @@ def __call__(
)


stop_rpc: Method[Callable[[], bool]] = Method(
RPC.admin_stopRPC,
stop_http: Method[Callable[[], bool]] = Method(
RPC.admin_stopHTTP,
is_property=True,
)

Expand All @@ -84,3 +85,9 @@ def __call__(
RPC.admin_stopWS,
is_property=True,
)

#
# Deprecated Methods
#
start_rpc = DeprecatedMethod(start_http, 'start_rpc', 'start_http')
stop_rpc = DeprecatedMethod(stop_http, 'stop_rpc', 'stop_http')
31 changes: 25 additions & 6 deletions web3/_utils/module_testing/go_ethereum_admin_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@ def test_admin_peers(self, w3: "Web3") -> None:
result = w3.geth.admin.peers()
assert len(result) == 1

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

start = w3.geth.admin.start_rpc()
start = w3.geth.admin.start_http()
assert start is True

def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
with pytest.warns(DeprecationWarning, match='deprecated in favor of stop_http'):
stop = w3.geth.admin.stop_rpc()
assert stop is True

with pytest.warns(DeprecationWarning, match='deprecated in favor of start_http'):
start = w3.geth.admin.start_rpc()
assert start is True

def test_admin_start_stop_ws(self, w3: "Web3") -> None:
stop = w3.geth.admin.stop_ws()
assert stop is True
Expand Down Expand Up @@ -85,13 +94,23 @@ async def test_admin_peers(self, w3: "Web3") -> None:
assert len(result) == 1

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

start = await w3.geth.admin.start_rpc() # type: ignore
start = await w3.geth.admin.start_http() # type: ignore
assert start is True

@pytest.mark.asyncio
async def test_admin_start_stop_rpc(self, w3: "Web3") -> None:
with pytest.warns(DeprecationWarning, match='deprecated in favor of stop_http'):
stop = await w3.geth.admin.stop_rpc()
assert stop is True

with pytest.warns(DeprecationWarning, match='deprecated in favor of start_http'):
start = await w3.geth.admin.start_rpc()
assert start is True

@pytest.mark.asyncio
async def test_admin_start_stop_ws(self, w3: "Web3") -> None:
stop = await w3.geth.admin.stop_ws() # type: ignore
Expand Down
7 changes: 5 additions & 2 deletions web3/_utils/rpc_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ class RPC:
admin_datadir = RPCEndpoint("admin_datadir")
admin_nodeInfo = RPCEndpoint("admin_nodeInfo")
admin_peers = RPCEndpoint("admin_peers")
admin_startRPC = RPCEndpoint("admin_startRPC")
admin_startHTTP = RPCEndpoint("admin_startHTTP")
admin_startWS = RPCEndpoint("admin_startWS")
admin_stopRPC = RPCEndpoint("admin_stopRPC")
admin_stopHTTP = RPCEndpoint("admin_stopHTTP")
admin_stopWS = RPCEndpoint("admin_stopWS")
# deprecated
admin_startRPC = RPCEndpoint("admin_startRPC")
admin_stopRPC = RPCEndpoint("admin_stopRPC")

# eth
eth_accounts = RPCEndpoint("eth_accounts")
Expand Down
Loading