From 5a449981b4223412ccaca1d3f39f099cb1678252 Mon Sep 17 00:00:00 2001 From: DB Date: Wed, 18 May 2022 05:50:39 -0400 Subject: [PATCH 1/9] removed more depecrated methods in geth and parity --- docs/web3.geth.rst | 70 -------- docs/web3.parity.rst | 29 ---- web3/_utils/admin.py | 11 -- web3/_utils/miner.py | 12 -- .../go_ethereum_personal_module.py | 151 ------------------ web3/_utils/personal.py | 13 -- web3/geth.py | 60 ------- web3/parity.py | 33 ---- 8 files changed, 379 deletions(-) diff --git a/docs/web3.geth.rst b/docs/web3.geth.rst index f448e35c7a..c17cc500be 100644 --- a/docs/web3.geth.rst +++ b/docs/web3.geth.rst @@ -54,12 +54,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und } -.. py:method:: nodeInfo() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.node_info()` - - .. py:method:: peers() * Delegates to ``admin_peers`` RPC Method @@ -118,10 +112,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und True -.. py:method:: addPeer(node_url) - - .. warning:: Deprecated: This method is deprecated in favor of :meth:`~web3.geth.admin.add_peer()` - .. py:method:: start_rpc(host='localhost', port=8545, cors="", apis="eth,net,web3") * Delegates to ``admin_startRPC`` RPC Method @@ -137,12 +127,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und True -.. py:method:: startRPC(host='localhost', port=8545, cors="", apis="eth,net,web3") - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.start_rpc()` - - .. py:method:: start_ws(host='localhost', port=8546, cors="", apis="eth,net,web3") * Delegates to ``admin_startWS`` RPC Method @@ -158,12 +142,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und True -.. py:method:: startWS(host='localhost', port=8546, cors="", apis="eth,net,web3") - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.start_ws()` - - .. py:method:: stop_rpc() * Delegates to ``admin_stopRPC`` RPC Method @@ -176,12 +154,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und True -.. py:method:: stopRPC() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.stop_rpc()` - - .. py:method:: stop_ws() * Delegates to ``admin_stopWS`` RPC Method @@ -194,12 +166,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und True -.. py:method:: stopWS() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.stop_ws()` - - .. py:module:: web3.geth.personal GethPersonal API @@ -219,12 +185,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. ['0xd3CdA913deB6f67967B99D67aCDFa1712C293601'] -.. py:method:: listAccounts() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.list_accounts()` - - .. py:method:: list_wallets() * Delegates to ``personal_listWallets`` RPC Method @@ -257,12 +217,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' -.. py:method:: importRawKey() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.import_raw_key()` - - .. py:method:: new_account(self, passphrase) * Delegates to ``personal_newAccount`` RPC Method @@ -276,12 +230,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' -.. py:method:: newAccount() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.new_account()` - - .. py:method:: lock_account(self, account) * Delegates to ``personal_lockAccount`` RPC Method @@ -293,12 +241,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. >>> web3.geth.personal.lock_account('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') -.. py:method:: lockAccount() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.lock_account()` - - .. py:method:: unlock_account(self, account, passphrase, duration=None) * Delegates to ``personal_unlockAccount`` RPC Method @@ -317,12 +259,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. True -.. py:method:: unlockAccount() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.unlock_account()` - - .. py:method:: send_transaction(self, transaction, passphrase) * Delegates to ``personal_sendTransaction`` RPC Method @@ -330,12 +266,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. Sends the transaction. -.. py:method:: sendTransaction() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.send_transaction()` - - .. py:module:: web3.geth.txpool GethTxPool API diff --git a/docs/web3.parity.rst b/docs/web3.parity.rst index 8eeb2fd82a..cf4c2cf7e7 100644 --- a/docs/web3.parity.rst +++ b/docs/web3.parity.rst @@ -25,10 +25,6 @@ The following methods are available on the ``web3.parity.personal`` namespace. >>> web3.parity.personal.list_accounts() ['0xd3CdA913deB6f67967B99D67aCDFa1712C293601'] -.. py:method:: listAccounts - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.parity.personal.list_accounts()` .. py:method:: import_raw_key(self, private_key, passphrase) @@ -42,11 +38,6 @@ The following methods are available on the ``web3.parity.personal`` namespace. >>> web3.parity.personal.import_raw_key(some_private_key, 'the-passphrase') '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' -.. py:method:: importRawKey(self, private_key, passphrase) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.parity.personal.import_raw_key()` - .. py:method:: new_account(self, password) * Delegates to ``personal_newAccount`` RPC Method @@ -59,11 +50,6 @@ The following methods are available on the ``web3.parity.personal`` namespace. >>> web3.parity.personal.new_account('the-passphrase') '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' -.. py:method:: newAccount(self, password) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.parity.personal.new_account()` - .. py:method:: unlock_account(self, account, passphrase, duration=None) * Delegates to ``personal_unlockAccount`` RPC Method @@ -80,22 +66,12 @@ The following methods are available on the ``web3.parity.personal`` namespace. >>> web3.parity.personal.unlock_account('0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'the-passphrase') True -.. py:method:: unlockAccount(self, account, passphrase, duration=None) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.parity.personal.unlock_account()` - .. py:method:: send_transaction(self, transaction, passphrase) * Delegates to ``personal_sendTransaction`` RPC Method Sends the transaction. -.. py:method:: sendTransaction(self, account, passphrase, duration=None) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.parity.personal.send_transaction()` - .. py:method:: sign_typed_data(self, jsonMessage, account, passphrase) * Delegates to ``personal_signTypedData`` RPC Method @@ -104,8 +80,3 @@ The following methods are available on the ``web3.parity.personal`` namespace. and **NOT** the JSON String itself. Signs the ``Structured Data`` (or ``Typed Data``) with the passphrase of the given ``account`` - -.. py:method:: signTypedData(self, jsonMessage, account, passphrase) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.parity.personal.sign_typed_data()` diff --git a/web3/_utils/admin.py b/web3/_utils/admin.py index 86e946d550..a19ad98dfe 100644 --- a/web3/_utils/admin.py +++ b/web3/_utils/admin.py @@ -11,7 +11,6 @@ RPC, ) from web3.method import ( - DeprecatedMethod, Method, default_root_munger, ) @@ -85,13 +84,3 @@ def __call__( RPC.admin_stopWS, is_property=True, ) - -# -# Deprecated Methods -# -addPeer = DeprecatedMethod(add_peer, 'addPeer', 'add_peer') -nodeInfo = DeprecatedMethod(node_info, 'nodeInfo', 'node_info') -startRPC = DeprecatedMethod(start_rpc, 'startRPC', 'start_rpc') -stopRPC = DeprecatedMethod(stop_rpc, 'stopRPC', 'stop_rpc') -startWS = DeprecatedMethod(start_ws, 'startWS', 'start_ws') -stopWS = DeprecatedMethod(stop_ws, 'stopWS', 'stop_ws') diff --git a/web3/_utils/miner.py b/web3/_utils/miner.py index f39c99953e..2797a505b9 100644 --- a/web3/_utils/miner.py +++ b/web3/_utils/miner.py @@ -10,7 +10,6 @@ RPC, ) from web3.method import ( - DeprecatedMethod, Method, default_root_munger, ) @@ -65,14 +64,3 @@ RPC.miner_stopAutoDag, is_property=True, ) - - -# -# Deprecated Methods -# -makeDag = DeprecatedMethod(make_dag, 'makeDag', 'make_dag') -setExtra = DeprecatedMethod(set_extra, 'setExtra', 'set_extra') -setEtherbase = DeprecatedMethod(set_etherbase, 'setEtherbase', 'set_etherbase') -setGasPrice = DeprecatedMethod(set_gas_price, 'setGasPrice', 'set_gas_price') -startAutoDag = DeprecatedMethod(start_auto_dag, 'startAutoDag', 'start_auto_dag') -stopAutoDag = DeprecatedMethod(stop_auto_dag, 'stopAutoDag', 'stop_auto_dag') diff --git a/web3/_utils/module_testing/go_ethereum_personal_module.py b/web3/_utils/module_testing/go_ethereum_personal_module.py index 34bff726b2..54a9be0c36 100644 --- a/web3/_utils/module_testing/go_ethereum_personal_module.py +++ b/web3/_utils/module_testing/go_ethereum_personal_module.py @@ -49,11 +49,6 @@ def test_personal_import_raw_key(self, w3: "Web3") -> None: actual = w3.geth.personal.import_raw_key(PRIVATE_KEY_HEX, PASSWORD) assert actual == ADDRESS - def test_personal_importRawKey_deprecated(self, w3: "Web3") -> None: - with pytest.warns(DeprecationWarning): - actual = w3.geth.personal.importRawKey(SECOND_PRIVATE_KEY_HEX, PASSWORD) - assert actual == SECOND_ADDRESS - def test_personal_list_accounts(self, w3: "Web3") -> None: accounts = w3.geth.personal.list_accounts() assert is_list_like(accounts) @@ -64,17 +59,6 @@ def test_personal_list_accounts(self, w3: "Web3") -> None: in accounts )) - def test_personal_listAccounts_deprecated(self, w3: "Web3") -> None: - with pytest.warns(DeprecationWarning): - accounts = w3.geth.personal.listAccounts() - assert is_list_like(accounts) - assert len(accounts) > 0 - assert all(( - is_checksum_address(item) - for item - in accounts - )) - def test_personal_list_wallets(self, w3: "Web3") -> None: wallets = w3.geth.personal.list_wallets() assert is_list_like(wallets) @@ -90,13 +74,6 @@ def test_personal_lock_account( # TODO: how do we test this better? w3.geth.personal.lock_account(unlockable_account_dual_type) - def test_personal_lockAccount_deprecated( - self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress - ) -> None: - with pytest.warns(DeprecationWarning): - # TODO: how do we test this better? - w3.geth.personal.lockAccount(unlockable_account_dual_type) - def test_personal_unlock_account_success( self, w3: "Web3", @@ -109,41 +86,16 @@ def test_personal_unlock_account_success( ) assert result is True - def test_personal_unlockAccount_success_deprecated( - self, - w3: "Web3", - unlockable_account_dual_type: ChecksumAddress, - unlockable_account_pw: str, - ) -> None: - with pytest.warns(DeprecationWarning): - result = w3.geth.personal.unlockAccount( - unlockable_account_dual_type, - unlockable_account_pw - ) - assert result is True - def test_personal_unlock_account_failure( self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: with pytest.raises(ValueError): w3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password') - def test_personal_unlockAccount_failure_deprecated( - self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress - ) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError): - w3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password') - def test_personal_new_account(self, w3: "Web3") -> None: new_account = w3.geth.personal.new_account(PASSWORD) assert is_checksum_address(new_account) - def test_personal_newAccount_deprecated(self, w3: "Web3") -> None: - with pytest.warns(DeprecationWarning): - new_account = w3.geth.personal.newAccount(PASSWORD) - assert is_checksum_address(new_account) - def test_personal_send_transaction( self, w3: "Web3", @@ -168,32 +120,6 @@ def test_personal_send_transaction( assert transaction['value'] == txn_params['value'] assert transaction['gasPrice'] == txn_params['gasPrice'] - def test_personal_sendTransaction_deprecated( - self, - w3: "Web3", - unlockable_account_dual_type: ChecksumAddress, - unlockable_account_pw: str, - ) -> None: - assert w3.eth.get_balance(unlockable_account_dual_type) > constants.WEI_PER_ETHER - txn_params: TxParams = { - 'from': unlockable_account_dual_type, - 'to': unlockable_account_dual_type, - 'gas': 21000, - 'value': Wei(1), - 'gasPrice': w3.toWei(1, 'gwei'), - } - with pytest.warns(DeprecationWarning): - txn_hash = w3.geth.personal.sendTransaction(txn_params, unlockable_account_pw) - assert txn_hash - - transaction = w3.eth.get_transaction(txn_hash) - - assert is_same_address(transaction['from'], cast(ChecksumAddress, txn_params['from'])) - assert is_same_address(transaction['to'], cast(ChecksumAddress, txn_params['to'])) - assert transaction['gas'] == txn_params['gas'] - assert transaction['value'] == txn_params['value'] - assert transaction['gasPrice'] == txn_params['gasPrice'] - def test_personal_sign_and_ecrecover( self, w3: "Web3", @@ -209,22 +135,6 @@ def test_personal_sign_and_ecrecover( signer = w3.geth.personal.ec_recover(message, signature) assert is_same_address(signer, unlockable_account_dual_type) - def test_personal_sign_and_ecrecover_deprecated( - self, - w3: "Web3", - unlockable_account_dual_type: ChecksumAddress, - unlockable_account_pw: str, - ) -> None: - with pytest.warns(DeprecationWarning): - message = 'test-web3-geth-personal-sign' - signature = w3.geth.personal.sign( - message, - unlockable_account_dual_type, - unlockable_account_pw - ) - signer = w3.geth.personal.ecRecover(message, signature) - assert is_same_address(signer, unlockable_account_dual_type) - @pytest.mark.xfail( reason="personal_sign_typed_data JSON RPC call has not been released in geth" ) @@ -287,67 +197,6 @@ def test_personal_sign_typed_data( assert signature == expected_signature assert len(signature) == 32 + 32 + 1 - @pytest.mark.xfail(reason="personal_signTypedData JSON RPC call has not been released in geth") - def test_personal_sign_typed_data_deprecated( - self, - w3: "Web3", - unlockable_account_dual_type: ChecksumAddress, - unlockable_account_pw: str, - ) -> None: - with pytest.warns(DeprecationWarning): - typed_message = ''' - { - "types": { - "EIP712Domain": [ - {"name": "name", "type": "string"}, - {"name": "version", "type": "string"}, - {"name": "chainId", "type": "uint256"}, - {"name": "verifyingContract", "type": "address"} - ], - "Person": [ - {"name": "name", "type": "string"}, - {"name": "wallet", "type": "address"} - ], - "Mail": [ - {"name": "from", "type": "Person"}, - {"name": "to", "type": "Person"}, - {"name": "contents", "type": "string"} - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": "0x01", - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - "contents": "Hello, Bob!" - } - } - ''' - signature = HexBytes(w3.geth.personal.sign_typed_data( - json.loads(typed_message), - unlockable_account_dual_type, - unlockable_account_pw - )) - - expected_signature = HexBytes( - "0xc8b56aaeefd10ab4005c2455daf28d9082af661ac347cd" - "b612d5b5e11f339f2055be831bf57a6e6cb5f6d93448fa35" - "c1bd56fe1d745ffa101e74697108668c401c" - ) - assert signature == expected_signature - assert len(signature) == 32 + 32 + 1 - class GoEthereumAsyncPersonalModuleTest: diff --git a/web3/_utils/personal.py b/web3/_utils/personal.py index d9690cc44a..b874eb70b7 100644 --- a/web3/_utils/personal.py +++ b/web3/_utils/personal.py @@ -21,7 +21,6 @@ RPC, ) from web3.method import ( - DeprecatedMethod, Method, default_root_munger, ) @@ -94,15 +93,3 @@ def __call__(self, account: ChecksumAddress, passphrase: str, RPC.personal_ecRecover, mungers=[default_root_munger], ) - -# -# Deprecated Methods -# -importRawKey = DeprecatedMethod(import_raw_key, 'importRawKey', 'import_raw_key') -newAccount = DeprecatedMethod(new_account, 'newAccount', 'new_account') -listAccounts = DeprecatedMethod(list_accounts, 'listAccounts', 'list_accounts') -sendTransaction = DeprecatedMethod(send_transaction, 'sendTransaction', 'send_transaction') -lockAccount = DeprecatedMethod(lock_account, 'lockAccount', 'lock_account') -unlockAccount = DeprecatedMethod(unlock_account, 'unlockAccount', 'unlock_account') -signTypedData = DeprecatedMethod(sign_typed_data, 'signTypedData', 'sign_typed_data') -ecRecover = DeprecatedMethod(ec_recover, 'ecRecover', 'ec_recover') diff --git a/web3/geth.py b/web3/geth.py index fd56ae295a..315f52676c 100644 --- a/web3/geth.py +++ b/web3/geth.py @@ -28,39 +28,25 @@ ) from web3._utils.miner import ( make_dag, - makeDag, set_etherbase, set_extra, set_gas_price, - setEtherbase, - setExtra, - setGasPrice, start, start_auto_dag, - startAutoDag, stop, stop_auto_dag, - stopAutoDag, ) from web3._utils.personal import ( ec_recover, - ecRecover, import_raw_key, - importRawKey, list_accounts, list_wallets, - listAccounts, lock_account, - lockAccount, new_account, - newAccount, send_transaction, - sendTransaction, sign, sign_typed_data, - signTypedData, unlock_account, - unlockAccount, ) from web3._utils.txpool import ( content, @@ -96,15 +82,6 @@ class BaseGethPersonal(Module): _sign = sign _sign_typed_data = sign_typed_data _unlock_account = unlock_account - # deprecated - _ecRecover = ecRecover - _importRawKey = importRawKey - _listAccounts = listAccounts - _lockAccount = lockAccount - _newAccount = newAccount - _sendTransaction = sendTransaction - _signTypedData = signTypedData - _unlockAccount = unlockAccount class GethPersonal(BaseGethPersonal): @@ -146,36 +123,6 @@ def unlock_account(self, duration: Optional[int] = None) -> bool: return self._unlock_account(account, passphrase, duration) - def ecRecover(self, message: str, signature: HexStr) -> ChecksumAddress: - return self._ecRecover(message, signature) - - def importRawKey(self, private_key: str, passphrase: str) -> ChecksumAddress: - return self._importRawKey(private_key, passphrase) - - def listAccounts(self) -> List[ChecksumAddress]: - return self._listAccounts() - - def lockAccount(self, account: ChecksumAddress) -> bool: - return self._lockAccount(account) - - def newAccount(self, passphrase: str) -> ChecksumAddress: - return self._newAccount(passphrase) - - def sendTransaction(self, transaction: TxParams, passphrase: str) -> HexBytes: - return self._sendTransaction(transaction, passphrase) - - def signTypedData(self, - message: Dict[str, Any], - account: ChecksumAddress, - password: Optional[str] = None) -> HexStr: - return self._signTypedData(message, account, password) - - def unlockAccount(self, - account: ChecksumAddress, - passphrase: str, - duration: Optional[int] = None) -> bool: - return self._unlockAccount(account, passphrase, duration) - class AsyncGethPersonal(BaseGethPersonal): is_async = True @@ -353,13 +300,6 @@ class GethMiner(Module): stop = stop start_auto_dag = start_auto_dag stop_auto_dag = stop_auto_dag - # deprecated - makeDag = makeDag - setExtra = setExtra - setEtherbase = setEtherbase - setGasPrice = setGasPrice - startAutoDag = startAutoDag - stopAutoDag = stopAutoDag class Geth(Module): diff --git a/web3/parity.py b/web3/parity.py index 4b47a40b21..d32d52eed6 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -22,26 +22,18 @@ from web3._utils.personal import ( ec_recover, - ecRecover, import_raw_key, - importRawKey, list_accounts, - listAccounts, new_account, - newAccount, send_transaction, - sendTransaction, sign, sign_typed_data, - signTypedData, unlock_account, - unlockAccount, ) from web3._utils.rpc_abi import ( RPC, ) from web3.method import ( - DeprecatedMethod, Method, default_root_munger, ) @@ -75,14 +67,6 @@ class ParityPersonal(Module): sign = sign sign_typed_data = sign_typed_data unlock_account = unlock_account - # deprecated - ecRecover = ecRecover - importRawKey = importRawKey - listAccounts = listAccounts - newAccount = newAccount - sendTransaction = sendTransaction - signTypedData = signTypedData - unlockAccount = unlockAccount class Parity(Module): @@ -219,20 +203,3 @@ def trace_transactions_munger( RPC.parity_mode, is_property=True ) - - # Deprecated Methods - addReservedPeer = DeprecatedMethod(add_reserved_peer, 'addReservedPeer', 'add_reserved_peer') - listStorageKeys = DeprecatedMethod(list_storage_keys, 'listStorageKeys', 'list_storage_keys') - netPeers = DeprecatedMethod(net_peers, 'netPeers', 'net_peers') - setMode = DeprecatedMethod(set_mode, 'setMode', 'set_mode') - traceBlock = DeprecatedMethod(trace_block, 'traceBlock', 'trace_block') - traceCall = DeprecatedMethod(trace_call, 'traceCall', 'trace_call') - traceFilter = DeprecatedMethod(trace_filter, 'traceFilter', 'trace_filter') - traceRawTransaction = DeprecatedMethod(trace_raw_transaction, 'traceRawTransaction', - 'trace_raw_transaction') - traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction', - 'trace_replay_transaction') - traceReplayBlockTransactions = DeprecatedMethod(trace_replay_block_transactions, - 'traceReplayBlockTransactions', - 'trace_replay_block_transactions') - traceTransaction = DeprecatedMethod(trace_transaction, 'traceTransaction', 'trace_transaction') From 7fe617fdad26e5be30a2a4051bd194df7ad56910 Mon Sep 17 00:00:00 2001 From: pacrob Date: Thu, 2 Jun 2022 14:03:51 -0600 Subject: [PATCH 2/9] remove deprecated methods from Net module and add newsfragments --- docs/web3.net.rst | 11 ----------- newsfragments/2480.breaking-change.rst | 1 + newsfragments/2480.doc.rst | 1 + tests/integration/test_ethereum_tester.py | 16 ---------------- web3/_utils/module_testing/net_module.py | 10 ---------- web3/net.py | 11 ----------- 6 files changed, 2 insertions(+), 48 deletions(-) create mode 100644 newsfragments/2480.breaking-change.rst create mode 100644 newsfragments/2480.doc.rst diff --git a/docs/web3.net.rst b/docs/web3.net.rst index a774aa61c7..73448c0397 100644 --- a/docs/web3.net.rst +++ b/docs/web3.net.rst @@ -12,11 +12,6 @@ Properties The following properties are available on the ``web3.net`` namespace. -.. py:method:: chainId - :property: - - .. warning:: Deprecated: This property is deprecated as of EIP 1474. - .. py:method:: listening :property: @@ -41,12 +36,6 @@ The following properties are available on the ``web3.net`` namespace. >>> web3.net.peer_count 1 -.. py:method:: peerCount - :property: - - .. warning:: Deprecated: This property is deprecated in favor of - :attr:`~web3.geth.admin.peer_count` - .. py:method:: version :property: diff --git a/newsfragments/2480.breaking-change.rst b/newsfragments/2480.breaking-change.rst new file mode 100644 index 0000000000..5422602b39 --- /dev/null +++ b/newsfragments/2480.breaking-change.rst @@ -0,0 +1 @@ +Remove deprecated methods from Geth, Parity and Net modules diff --git a/newsfragments/2480.doc.rst b/newsfragments/2480.doc.rst new file mode 100644 index 0000000000..d6f8ebb17e --- /dev/null +++ b/newsfragments/2480.doc.rst @@ -0,0 +1 @@ +Remove deprecated methods from Geth, Parity, and Net modules diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index 2015c170fb..c0d07b1b8a 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -372,10 +372,6 @@ def test_eth_call_old_contract_state(self, eth_tester, w3, math_contract, unlock def test_eth_get_storage_at(self, w3, emitter_contract_address): super().test_eth_get_storage_at(w3, emitter_contract_address) - @pytest.mark.xfail(reason='json-rpc method is not implemented on eth-tester') - def test_eth_getStorageAt_deprecated(self, w3, emitter_contract_address): - super().test_eth_getStorageAt_deprecated(w3, emitter_contract_address) - @pytest.mark.xfail(reason='json-rpc method is not implemented on eth-tester') def test_eth_get_storage_at_ens_name(self, w3, emitter_contract_address): super().test_eth_get_storage_at_ens_name(w3, emitter_contract_address) @@ -509,10 +505,6 @@ class TestEthereumTesterPersonalModule(GoEthereumPersonalModuleTest): GoEthereumPersonalModuleTest.test_personal_sign_and_ecrecover, ValueError, ) - test_personal_sign_and_ecrecover_deprecated = not_implemented( - GoEthereumPersonalModuleTest.test_personal_sign_and_ecrecover, - ValueError, - ) # Test overridden here since eth-tester returns False rather than None for failed unlock def test_personal_unlock_account_failure(self, @@ -521,14 +513,6 @@ def test_personal_unlock_account_failure(self, result = w3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password') assert result is False - def test_personal_unlockAccount_failure_deprecated(self, - w3, - unlockable_account_dual_type): - with pytest.warns(DeprecationWarning, - match="unlockAccount is deprecated in favor of unlock_account"): - result = w3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password') - assert result is False - @pytest.mark.xfail(raises=ValueError, reason="list_wallets not implemented in eth-tester") def test_personal_list_wallets(self, w3: "Web3") -> None: super().test_personal_list_wallets(w3) diff --git a/web3/_utils/module_testing/net_module.py b/web3/_utils/module_testing/net_module.py index dd894a735a..2ece0efb7f 100644 --- a/web3/_utils/module_testing/net_module.py +++ b/web3/_utils/module_testing/net_module.py @@ -30,16 +30,6 @@ def test_net_peer_count(self, w3: "Web3") -> None: assert is_integer(peer_count) - def test_net_peerCount(self, w3: "Web3") -> None: - with pytest.warns(DeprecationWarning): - peer_count = w3.net.peerCount - - assert is_integer(peer_count) - - def test_net_chainId_deprecation(self, w3: "Web3") -> None: - with pytest.raises(DeprecationWarning): - w3.net.chainId - class AsyncNetModuleTest: @pytest.mark.asyncio diff --git a/web3/net.py b/web3/net.py index fc5e3fc6d1..7f407ac487 100644 --- a/web3/net.py +++ b/web3/net.py @@ -1,14 +1,12 @@ from typing import ( Awaitable, Callable, - NoReturn, ) from web3._utils.rpc_abi import ( RPC, ) from web3.method import ( - DeprecatedMethod, Method, default_root_munger, ) @@ -33,10 +31,6 @@ class Net(Module): mungers=[default_root_munger], ) - @property - def chainId(self) -> NoReturn: - raise DeprecationWarning("This method has been deprecated in EIP 1474.") - @property def listening(self) -> bool: return self._listening() @@ -49,11 +43,6 @@ def peer_count(self) -> int: def version(self) -> str: return self._version() - # - # Deprecated Methods - # - peerCount = DeprecatedMethod(peer_count, 'peerCount', 'peer_count') # type: ignore - class AsyncNet(Module): is_async = True From 791fbd4cf22e101be7b6389b713f0cd97acd509d Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 8 Jun 2022 11:54:07 -0600 Subject: [PATCH 3/9] Remove a few stray nodeInfos --- docs/providers.rst | 4 ++-- tests/core/admin-module/test_admin_nodeInfo.py | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/docs/providers.rst b/docs/providers.rst index cb1395ecd7..602558bd5b 100644 --- a/docs/providers.rst +++ b/docs/providers.rst @@ -138,7 +138,7 @@ For example, the following retrieves the client enode endpoint for both geth and enode = w3.parity.enode elif connected and w3.clientVersion.startswith('Geth'): - enode = w3.geth.admin.nodeInfo['enode'] + enode = w3.geth.admin.node_info['enode'] else: enode = None @@ -399,7 +399,7 @@ AsyncHTTPProvider ... 'admin' : (AsyncGethAdmin,)}) ... }, ... middlewares=[] # See supported middleware section below for middleware options - ... ) + ... ) >>> custom_session = ClientSession() # If you want to pass in your own session >>> await w3.provider.cache_async_session(custom_session) # This method is an async method so it needs to be handled accordingly diff --git a/tests/core/admin-module/test_admin_nodeInfo.py b/tests/core/admin-module/test_admin_nodeInfo.py index 7c209418aa..782af3c811 100644 --- a/tests/core/admin-module/test_admin_nodeInfo.py +++ b/tests/core/admin-module/test_admin_nodeInfo.py @@ -1,16 +1,6 @@ import pytest -def test_admin_nodeInfo(w3, skip_if_testrpc): - skip_if_testrpc(w3) - - with pytest.warns(DeprecationWarning): - node_info = w3.geth.admin.nodeInfo - - assert 'enode' in node_info - assert 'id' in node_info - - def test_admin_node_info(w3, skip_if_testrpc): skip_if_testrpc(w3) From fdeac84e42ebc09808906f4658a22e1d23cbf80c Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 8 Jun 2022 11:56:52 -0600 Subject: [PATCH 4/9] Remove test for deprecated addPeer --- tests/core/admin-module/test_admin_addPeer.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/core/admin-module/test_admin_addPeer.py b/tests/core/admin-module/test_admin_addPeer.py index 896821ef95..11ad05ae2c 100644 --- a/tests/core/admin-module/test_admin_addPeer.py +++ b/tests/core/admin-module/test_admin_addPeer.py @@ -1,16 +1,6 @@ import pytest -def test_admin_addPeer(w3, skip_if_testrpc): - skip_if_testrpc(w3) - - with pytest.warns(DeprecationWarning): - result = w3.geth.admin.addPeer( - 'enode://44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d@127.0.0.1:30304', # noqa: E501 - ) - assert result is True - - def test_admin_add_peer(w3, skip_if_testrpc): skip_if_testrpc(w3) From 3ea5f414d694aaa36ce14dd7eaccf1fb79c7e811 Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 8 Jun 2022 12:07:18 -0600 Subject: [PATCH 5/9] Clean up geth.miner.set_extra test, remove deprecated geth.miner.setExtra test --- .../core/mining-module/test_miner_setExtra.py | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/tests/core/mining-module/test_miner_setExtra.py b/tests/core/mining-module/test_miner_setExtra.py index ecbf4786bf..9a49bc192b 100644 --- a/tests/core/mining-module/test_miner_setExtra.py +++ b/tests/core/mining-module/test_miner_setExtra.py @@ -24,7 +24,7 @@ def test_miner_set_extra(web3_empty, wait_for_block): # sanity assert initial_extra != new_extra_data - web3.geth.miner.setExtra(new_extra_data) + web3.geth.miner.set_extra(new_extra_data) with Timeout(60) as timeout: while True: @@ -36,27 +36,3 @@ def test_miner_set_extra(web3_empty, wait_for_block): after_extra = decode_hex(web3.eth.get_block(web3.eth.block_number)['extraData']) assert after_extra == new_extra_data - - -@flaky(max_runs=3) -def test_miner_setExtra(web3_empty, wait_for_block): - web3 = web3_empty - - initial_extra = decode_hex(web3.eth.get_block(web3.eth.block_number)['extraData']) - - new_extra_data = b'-this-is-32-bytes-of-extra-data-' - - # sanity - assert initial_extra != new_extra_data - - with pytest.warns(DeprecationWarning): - web3.geth.miner.setExtra(new_extra_data) - with Timeout(60) as timeout: - while True: - extra_data = decode_hex(web3.eth.get_block(web3.eth.block_number)['extraData']) - if extra_data == new_extra_data: - break - timeout.sleep(random.random()) - - after_extra = decode_hex(web3.eth.get_block(web3.eth.block_number)['extraData']) - assert after_extra == new_extra_data From 61da7e6de5051b1d62e7c544c8c190e792bfe1e0 Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 8 Jun 2022 12:08:46 -0600 Subject: [PATCH 6/9] Remove setEtherbase test --- tests/core/mining-module/test_setEtherBase.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/core/mining-module/test_setEtherBase.py b/tests/core/mining-module/test_setEtherBase.py index a057e851e4..1944586fbb 100644 --- a/tests/core/mining-module/test_setEtherBase.py +++ b/tests/core/mining-module/test_setEtherBase.py @@ -7,12 +7,3 @@ def test_miner_set_etherbase(web3_empty): new_account = web3.personal.newAccount('this-is-a-password') web3.geth.miner.set_etherbase(new_account) assert web3.eth.coinbase == new_account - - -def test_miner_setEtherbase(web3_empty): - web3 = web3_empty - assert web3.eth.coinbase == web3.eth.accounts[0] - new_account = web3.personal.newAccount('this-is-a-password') - with pytest.warns(DeprecationWarning): - web3.geth.miner.setEtherbase(new_account) - assert web3.eth.coinbase == new_account From 93ca8df8b16f2b3ff616a908f33116df2a4944c6 Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 8 Jun 2022 12:09:26 -0600 Subject: [PATCH 7/9] Remove setGasPrice test --- .../mining-module/test_miner_setGasPrice.py | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/tests/core/mining-module/test_miner_setGasPrice.py b/tests/core/mining-module/test_miner_setGasPrice.py index 70852cf20a..73dc5d0f14 100644 --- a/tests/core/mining-module/test_miner_setGasPrice.py +++ b/tests/core/mining-module/test_miner_setGasPrice.py @@ -27,23 +27,3 @@ def test_miner_set_gas_price(web3_empty, wait_for_block): after_gas_price = web3.eth.gas_price assert after_gas_price < initial_gas_price - - -@flaky(max_runs=3) -def test_miner_setGasPrice(web3_empty, wait_for_block): - web3 = web3_empty - - initial_gas_price = web3.eth.gas_price - assert web3.eth.gas_price > 1000 - - # sanity check - - with pytest.warns(DeprecationWarning): - web3.geth.miner.setGasPrice(initial_gas_price // 2) - - with Timeout(60) as timeout: - while web3.eth.gas_price == initial_gas_price: - timeout.sleep(random.random()) - - after_gas_price = web3.eth.gas_price - assert after_gas_price < initial_gas_price From 015ddbdd332d1a6d52391abd3604c47d2ff65b04 Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 8 Jun 2022 12:14:48 -0600 Subject: [PATCH 8/9] Clean up stray personal.newAccount --- tests/core/eth-module/conftest.py | 2 +- tests/core/mining-module/test_setEtherBase.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/core/eth-module/conftest.py b/tests/core/eth-module/conftest.py index de445279c3..969bec12cd 100644 --- a/tests/core/eth-module/conftest.py +++ b/tests/core/eth-module/conftest.py @@ -12,7 +12,7 @@ def extra_accounts(w3, account_password): num_accounts_to_create = 10 - len(w3.eth.accounts) for i in range(num_accounts_to_create): - w3.personal.newAccount(account_password) + w3.personal.new_account(account_password) return w3.eth.accounts diff --git a/tests/core/mining-module/test_setEtherBase.py b/tests/core/mining-module/test_setEtherBase.py index 1944586fbb..d4d040cdd9 100644 --- a/tests/core/mining-module/test_setEtherBase.py +++ b/tests/core/mining-module/test_setEtherBase.py @@ -4,6 +4,6 @@ def test_miner_set_etherbase(web3_empty): web3 = web3_empty assert web3.eth.coinbase == web3.eth.accounts[0] - new_account = web3.personal.newAccount('this-is-a-password') + new_account = web3.personal.new_account('this-is-a-password') web3.geth.miner.set_etherbase(new_account) assert web3.eth.coinbase == new_account From d9c09717bace492a291bbee2982cc404dcc9f799 Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 8 Jun 2022 12:59:34 -0600 Subject: [PATCH 9/9] lint --- tests/core/admin-module/test_admin_addPeer.py | 3 --- tests/core/admin-module/test_admin_nodeInfo.py | 3 --- tests/core/mining-module/test_miner_setExtra.py | 1 - tests/core/mining-module/test_miner_setGasPrice.py | 1 - tests/core/mining-module/test_setEtherBase.py | 3 --- 5 files changed, 11 deletions(-) diff --git a/tests/core/admin-module/test_admin_addPeer.py b/tests/core/admin-module/test_admin_addPeer.py index 11ad05ae2c..f196ff32c1 100644 --- a/tests/core/admin-module/test_admin_addPeer.py +++ b/tests/core/admin-module/test_admin_addPeer.py @@ -1,6 +1,3 @@ -import pytest - - def test_admin_add_peer(w3, skip_if_testrpc): skip_if_testrpc(w3) diff --git a/tests/core/admin-module/test_admin_nodeInfo.py b/tests/core/admin-module/test_admin_nodeInfo.py index 782af3c811..b270a50969 100644 --- a/tests/core/admin-module/test_admin_nodeInfo.py +++ b/tests/core/admin-module/test_admin_nodeInfo.py @@ -1,6 +1,3 @@ -import pytest - - def test_admin_node_info(w3, skip_if_testrpc): skip_if_testrpc(w3) diff --git a/tests/core/mining-module/test_miner_setExtra.py b/tests/core/mining-module/test_miner_setExtra.py index 9a49bc192b..974a4aa157 100644 --- a/tests/core/mining-module/test_miner_setExtra.py +++ b/tests/core/mining-module/test_miner_setExtra.py @@ -1,4 +1,3 @@ -import pytest import random from eth_utils import ( diff --git a/tests/core/mining-module/test_miner_setGasPrice.py b/tests/core/mining-module/test_miner_setGasPrice.py index 73dc5d0f14..c535155430 100644 --- a/tests/core/mining-module/test_miner_setGasPrice.py +++ b/tests/core/mining-module/test_miner_setGasPrice.py @@ -1,4 +1,3 @@ -import pytest import random from flaky import ( diff --git a/tests/core/mining-module/test_setEtherBase.py b/tests/core/mining-module/test_setEtherBase.py index d4d040cdd9..1d11189991 100644 --- a/tests/core/mining-module/test_setEtherBase.py +++ b/tests/core/mining-module/test_setEtherBase.py @@ -1,6 +1,3 @@ -import pytest - - def test_miner_set_etherbase(web3_empty): web3 = web3_empty assert web3.eth.coinbase == web3.eth.accounts[0]