diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index d9a6ae9761..873090aa47 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -814,6 +814,17 @@ with the filtering API. :meth:`~Eth.filter` for details on allowed filter parameters. +.. py:method:: Eth.submitHashrate(hashrate, nodeid) + + * Delegates to ``eth_submitHashrate`` RPC Method. + + .. code-block:: python + + >>> node_id = '59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c' + >>> web3.eth.submitHashrate(5000, node_id) + True + + Contracts --------- diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index dfaa228749..d3e0c3fc82 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -216,6 +216,7 @@ def func_wrapper(self, eth_tester, *args, **kwargs): class TestEthereumTesterEthModule(EthModuleTest): test_eth_sign = not_implemented(EthModuleTest.test_eth_sign, ValueError) + test_eth_submitHashrate = not_implemented(EthModuleTest.test_eth_submitHashrate, ValueError) @disable_auto_mine def test_eth_getTransactionReceipt_unmined(self, eth_tester, web3, unlocked_account): diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 91eeb8d9ff..1eec0db990 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -810,3 +810,8 @@ def test_eth_getTransactionFromBlock_deprecation(self, web3, block_with_txn): def test_eth_getCompilers_deprecation(self, web3): with pytest.raises(DeprecationWarning): web3.eth.getCompilers() + + def test_eth_submitHashrate(self, web3): + node_id = '59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c' + result = web3.eth.submitHashrate(5000, node_id) + assert result is True diff --git a/web3/_utils/rpc_abi.py b/web3/_utils/rpc_abi.py index 40eccb0bff..aa31a91803 100644 --- a/web3/_utils/rpc_abi.py +++ b/web3/_utils/rpc_abi.py @@ -51,6 +51,7 @@ 'eth_sendRawTransaction': ['bytes'], 'eth_sendTransaction': TRANSACTION_PARAMS_ABIS, 'eth_sign': ['address', 'bytes'], + 'eth_submitHashrate': ['uint', None], # personal 'personal_sendTransaction': TRANSACTION_PARAMS_ABIS, 'personal_lockAccount': ['address'], diff --git a/web3/eth.py b/web3/eth.py index 4475d7a1a4..3708959a05 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -390,6 +390,11 @@ def getLogs(self, filter_params): "eth_getLogs", [filter_params], ) + def submitHashrate(self, hashrate, node_id): + return self.web3.manager.request_blocking( + "eth_submitHashrate", [hashrate, node_id], + ) + def uninstallFilter(self, filter_id): return self.web3.manager.request_blocking( "eth_uninstallFilter", [filter_id], diff --git a/web3/middleware/pythonic.py b/web3/middleware/pythonic.py index 726d206959..b7df3724f9 100644 --- a/web3/middleware/pythonic.py +++ b/web3/middleware/pythonic.py @@ -287,6 +287,7 @@ def to_hexbytes(num_bytes, val, variable_length=False): (estimate_gas_with_block_id, is_length(2)), )), 'eth_sendTransaction': apply_formatter_at_index(transaction_param_formatter, 0), + 'eth_submitHashrate': apply_formatter_at_index(hexstr_if_str(to_hex), 1), # personal 'personal_importRawKey': apply_formatter_at_index( compose(remove_0x_prefix, hexstr_if_str(to_hex)),