diff --git a/.circleci/config.yml b/.circleci/config.yml index f95b86d73d..421c2f3c50 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 parameters: geth_version: # update default value when updating geth integration test fixture - default: "v1.11.6" + default: "v1.13.9" type: string pygeth_version: # update default value when updating geth integration test fixture @@ -107,7 +107,6 @@ geth_steps: &geth_steps fi sudo ln -s /home/circleci/.py-geth/geth-<< pipeline.parameters.geth_version >>/bin/geth /usr/local/bin/geth geth version - geth makedag 0 $HOME/.ethash - run: name: run tox command: python -m tox -r @@ -148,7 +147,6 @@ geth_custom_steps: &geth_custom_steps sudo apt-get update; sudo apt-get install -y build-essential; ./custom_geth version - ./custom_geth makedag 0 $HOME/.ethash - run: name: run tox command: python -m tox -r diff --git a/docs/contributing.rst b/docs/contributing.rst index b6df22b68b..d0628ad19b 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -373,13 +373,13 @@ Geth Fixtures .. code:: sh - $ python -m geth.install v1.11.6 + $ python -m geth.install v1.13.9 2. Specify the Geth binary and run the fixture creation script (from within the web3.py directory): .. code:: sh - $ GETH_BINARY=~/.py-geth/geth-v1.11.6/bin/geth python ./tests/integration/generate_fixtures/go_ethereum.py ./tests/integration/geth-1.11.6-fixture + $ GETH_BINARY=~/.py-geth/geth-v1.13.9/bin/geth python ./tests/integration/generate_fixtures/go_ethereum.py ./tests/integration/geth-1.13.9-fixture 3. The output of this script is your fixture, a zip file, which is now stored in ``/tests/integration/``. Update the ``/tests/integration/go_ethereum/conftest.py`` and diff --git a/newsfragments/3191.internal.rst b/newsfragments/3191.internal.rst new file mode 100644 index 0000000000..dab22fede9 --- /dev/null +++ b/newsfragments/3191.internal.rst @@ -0,0 +1 @@ +Create test fixture for latest ``geth`` version. Run tests with ``geth`` in ``--dev`` mode. \ No newline at end of file diff --git a/setup.py b/setup.py index 4c36bfa6b9..afa5b8cb48 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ extras_require = { "tester": [ "eth-tester[py-evm]==v0.9.1-b.1", - "py-geth>=3.11.0", + "py-geth>=3.14.0", ], "linter": [ "black>=22.1.0", diff --git a/tests/core/mining-module/conftest.py b/tests/core/mining-module/conftest.py deleted file mode 100644 index 5dd1555ad7..0000000000 --- a/tests/core/mining-module/conftest.py +++ /dev/null @@ -1,11 +0,0 @@ -import pytest - - -@pytest.fixture(autouse=True) -def always_wait_for_mining_start(w3, wait_for_miner_start, skip_if_testrpc): - skip_if_testrpc(w3) - - wait_for_miner_start(w3) - - assert w3.eth.mining - assert w3.eth.hashrate diff --git a/tests/core/mining-module/test_miner_hashrate.py b/tests/core/mining-module/test_miner_hashrate.py deleted file mode 100644 index 0c6b16df66..0000000000 --- a/tests/core/mining-module/test_miner_hashrate.py +++ /dev/null @@ -1,11 +0,0 @@ -from flaky import ( - flaky, -) - - -@flaky(max_runs=3) -def test_miner_hashrate(w3_empty, wait_for_miner_start): - w3 = w3_empty - - hashrate = w3.eth.hashrate - assert hashrate > 0 diff --git a/tests/core/mining-module/test_miner_setExtra.py b/tests/core/mining-module/test_miner_setExtra.py deleted file mode 100644 index 40adf5b4a1..0000000000 --- a/tests/core/mining-module/test_miner_setExtra.py +++ /dev/null @@ -1,39 +0,0 @@ -import random - -from eth_utils import ( - decode_hex, -) -from flaky import ( - flaky, -) - -from web3._utils.threads import ( - Timeout, -) - - -@flaky(max_runs=3) -def test_miner_set_extra(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 - - web3.geth.miner.set_extra(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 diff --git a/tests/core/mining-module/test_miner_setGasPrice.py b/tests/core/mining-module/test_miner_setGasPrice.py deleted file mode 100644 index c535155430..0000000000 --- a/tests/core/mining-module/test_miner_setGasPrice.py +++ /dev/null @@ -1,28 +0,0 @@ -import random - -from flaky import ( - flaky, -) - -from web3._utils.threads import ( - Timeout, -) - - -@flaky(max_runs=3) -def test_miner_set_gas_price(web3_empty, wait_for_block): - web3 = web3_empty - - initial_gas_price = web3.eth.gas_price - - # sanity check - assert web3.eth.gas_price > 1000 - - web3.geth.miner.set_gas_price(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 diff --git a/tests/core/mining-module/test_miner_start.py b/tests/core/mining-module/test_miner_start.py deleted file mode 100644 index daa04e6835..0000000000 --- a/tests/core/mining-module/test_miner_start.py +++ /dev/null @@ -1,34 +0,0 @@ -import random - -from flaky import ( - flaky, -) - -from web3._utils.threads import ( - Timeout, -) - - -@flaky(max_runs=3) -def test_miner_start(w3_empty, wait_for_miner_start): - w3 = w3_empty - - # sanity - assert w3.eth.mining - assert w3.eth.hashrate - - w3.geth.miner.stop() - - with Timeout(60) as timeout: - while w3.eth.mining or w3.eth.hashrate: - timeout.sleep(random.random()) - - assert not w3.eth.mining - assert not w3.eth.hashrate - - w3.miner.start(1) - - wait_for_miner_start(w3) - - assert w3.eth.mining - assert w3.eth.hashrate diff --git a/tests/core/mining-module/test_miner_stop.py b/tests/core/mining-module/test_miner_stop.py deleted file mode 100644 index 1e2af7698c..0000000000 --- a/tests/core/mining-module/test_miner_stop.py +++ /dev/null @@ -1,27 +0,0 @@ -import random - -from flaky import ( - flaky, -) - -from web3._utils.threads import ( - Timeout, -) - - -@flaky(max_runs=3) -def test_miner_stop(w3_empty): - w3 = w3_empty - - assert w3.eth.mining - assert w3.eth.hashrate - - w3.geth.miner.stop() - - with Timeout(60) as timeout: - while w3.eth.mining or w3.eth.hashrate: - timeout.sleep(random.random()) - timeout.check() - - assert not w3.eth.mining - assert not w3.eth.hashrate diff --git a/tests/core/mining-module/test_setEtherBase.py b/tests/core/mining-module/test_setEtherBase.py deleted file mode 100644 index 13d165c334..0000000000 --- a/tests/core/mining-module/test_setEtherBase.py +++ /dev/null @@ -1,6 +0,0 @@ -def test_miner_set_etherbase(web3_empty): - web3 = web3_empty - assert web3.eth.coinbase == web3.eth.accounts[0] - new_account = web3.personal.new_account("this-is-a-password") - web3.geth.miner.set_etherbase(new_account) - assert web3.eth.coinbase == new_account diff --git a/tests/integration/generate_fixtures/common.py b/tests/integration/generate_fixtures/common.py index 13abb1c081..844f354758 100644 --- a/tests/integration/generate_fixtures/common.py +++ b/tests/integration/generate_fixtures/common.py @@ -15,9 +15,6 @@ from web3 import ( constants, ) -from web3.exceptions import ( - TransactionNotFound, -) # use same coinbase value as in `web3.py/tests/integration/common.py` COINBASE = "0xdc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd" @@ -26,6 +23,7 @@ KEYFILE_DATA = '{"address":"dc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd","crypto":{"cipher":"aes-128-ctr","ciphertext":"52e06bc9397ea9fa2f0dae8de2b3e8116e92a2ecca9ad5ff0061d1c449704e98","cipherparams":{"iv":"aa5d0a5370ef65395c1a6607af857124"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"9fdf0764eb3645ffc184e166537f6fe70516bf0e34dc7311dea21f100f0c9263"},"mac":"4e0b51f42b865c15c485f4faefdd1f01a38637e5247f8c75ffe6a8c0eba856f6"},"id":"5a6124e0-10f1-4c1c-ae3e-d903eacb740a","version":3}' # noqa: E501 KEYFILE_PW = "web3py-test" +KEYFILE_PW_TXT = "pw.txt" KEYFILE_FILENAME = "UTC--2017-08-24T19-42-47.517572178Z--dc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd" # noqa: E501 RAW_TXN_ACCOUNT = "0x39EEed73fb1D3855E90Cbd42f348b3D7b340aAA6" @@ -40,20 +38,22 @@ "config": { "chainId": 131277322940537, # the string 'web3py' as an integer "homesteadBlock": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, "eip150Block": 0, "eip155Block": 0, "eip158Block": 0, - "istanbulBlock": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, "petersburgBlock": 0, + "istanbulBlock": 0, "berlinBlock": 0, "londonBlock": 0, "arrowGlacierBlock": 0, "grayGlacierBlock": 0, "shanghaiTime": 0, + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": True, }, - "nonce": "0x0000000000000042", + "nonce": "0x0", "alloc": { COINBASE: {"balance": "1000000000000000000000000000"}, UNLOCKABLE_ACCOUNT: {"balance": "1000000000000000000000000000"}, @@ -65,7 +65,7 @@ "0000000000000000000000000000000000000005": {"balance": "1"}, "0000000000000000000000000000000000000006": {"balance": "1"}, }, - "timestamp": "0x00", + "timestamp": "0x0", "parentHash": constants.HASH_ZERO, "extraData": "0x3535353535353535353535353535353535353535353535353535353535353535", "gasLimit": "0x3b9aca00", # 1,000,000,000 @@ -172,6 +172,9 @@ def get_geth_process( geth_binary, "--datadir", datadir, + "--dev", + "--dev.period", + "1", "--ipcpath", ipc_path, "--nodiscover", @@ -210,11 +213,9 @@ def mine_block(w3): origin_block_number = w3.eth.block_number start_time = time.time() - w3.geth.miner.start(1) while time.time() < start_time + 120: block_number = w3.eth.block_number if block_number > origin_block_number: - w3.geth.miner.stop() return block_number else: time.sleep(0.1) @@ -222,31 +223,12 @@ def mine_block(w3): raise ValueError("No block mined during wait period") -def mine_transaction_hash(w3, txn_hash): - start_time = time.time() - w3.geth.miner.start(1) - while time.time() < start_time + 120: - try: - receipt = w3.eth.get_transaction_receipt(txn_hash) - except TransactionNotFound: - continue - if receipt is not None: - w3.geth.miner.stop() - return receipt - else: - time.sleep(0.1) - else: - raise ValueError( - "Math contract deploy transaction not mined during wait period" - ) - - def deploy_contract(w3, name, factory): name = name.upper() w3.geth.personal.unlock_account(w3.eth.coinbase, KEYFILE_PW) deploy_txn_hash = factory.constructor().transact({"from": w3.eth.coinbase}) print(f"{name}_CONTRACT_DEPLOY_HASH: {deploy_txn_hash}") - deploy_receipt = mine_transaction_hash(w3, deploy_txn_hash) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn_hash) print(f"{name}_CONTRACT_DEPLOY_TRANSACTION_MINED") contract_address = deploy_receipt["contractAddress"] assert is_checksum_address(contract_address) diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index 6a3abf2607..038e25c9a3 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -69,13 +69,13 @@ def graceful_kill_on_exit(proc): @contextlib.contextmanager -def get_geth_process(geth_binary, datadir, genesis_file_path, geth_ipc_path, geth_port): +def get_geth_process(geth_binary, datadir, geth_port): init_datadir_command = ( geth_binary, "--datadir", datadir, "init", - genesis_file_path, + os.path.join(datadir, "genesis.json"), ) subprocess.check_output( init_datadir_command, @@ -87,17 +87,15 @@ def get_geth_process(geth_binary, datadir, genesis_file_path, geth_ipc_path, get geth_binary, "--datadir", datadir, - "--ipcpath", - geth_ipc_path, - "--ethash.dagsondisk", + "--dev", + "--dev.period", "1", - "--gcmode", - "archive", - "--nodiscover", "--port", geth_port, "--miner.etherbase", common.COINBASE[2:], + "--password", + os.path.join(datadir, "keystore", "pw.txt"), "--rpc.enabledeprecatedpersonal", ) @@ -139,21 +137,20 @@ def generate_go_ethereum_fixture(destination_dir): keyfile_path = os.path.join(keystore_dir, common.KEYFILE_FILENAME) with open(keyfile_path, "w") as keyfile: keyfile.write(common.KEYFILE_DATA) + keyfile_pw = os.path.join(keystore_dir, common.KEYFILE_PW_TXT) + with open(keyfile_pw, "w") as keyfile_pw_file: + keyfile_pw_file.write(common.KEYFILE_PW) genesis_file_path = os.path.join(datadir, "genesis.json") with open(genesis_file_path, "w") as genesis_file: genesis_file.write(json.dumps(common.GENESIS_DATA)) - geth_ipc_path_dir = stack.enter_context(common.tempdir()) - geth_ipc_path = os.path.join(geth_ipc_path_dir, "geth.ipc") - + geth_ipc_path = f"{datadir}/geth.ipc" geth_port = get_open_port() geth_binary = common.get_geth_binary() with get_geth_process( geth_binary=geth_binary, datadir=datadir, - genesis_file_path=genesis_file_path, - geth_ipc_path=geth_ipc_path, geth_port=geth_port, ): common.wait_for_socket(geth_ipc_path) @@ -168,8 +165,6 @@ def generate_go_ethereum_fixture(destination_dir): with get_geth_process( geth_binary=geth_binary, datadir=datadir, - genesis_file_path=genesis_file_path, - geth_ipc_path=geth_ipc_path, geth_port=geth_port, ): common.wait_for_socket(geth_ipc_path) @@ -193,23 +188,13 @@ def verify_chain_state(w3, chain_data): assert receipt.blockNumber <= latest.number -def mine_transaction_hash(w3, txn_hash): - w3.geth.miner.start(1) - try: - return w3.eth.wait_for_transaction_receipt(txn_hash, timeout=120) - finally: - w3.geth.miner.stop() - - def mine_block(w3): origin_block_number = w3.eth.block_number start_time = time.time() - w3.geth.miner.start(1) while time.time() < start_time + 120: block_number = w3.eth.block_number if block_number > origin_block_number: - w3.geth.miner.stop() return block_number else: time.sleep(0.1) @@ -256,7 +241,7 @@ def setup_chain_state(w3): } ) print("TXN_HASH_WITH_LOG:", txn_hash_with_log) - txn_receipt_with_log = mine_transaction_hash(w3, txn_hash_with_log) + txn_receipt_with_log = w3.eth.wait_for_transaction_receipt(txn_hash_with_log) block_with_log = w3.eth.get_block(txn_receipt_with_log["blockHash"]) print("BLOCK_HASH_WITH_LOG:", block_with_log["hash"]) @@ -280,8 +265,8 @@ def setup_chain_state(w3): {"gas": 320000, "from": w3.eth.coinbase} ) print("TXN_HASH_REVERT_WITH_MSG:", txn_hash_revert_with_msg) - txn_receipt_revert_with_msg = common.mine_transaction_hash( - w3, txn_hash_revert_with_msg + txn_receipt_revert_with_msg = w3.eth.wait_for_transaction_receipt( + txn_hash_revert_with_msg ) block_hash_revert_with_msg = w3.eth.get_block( txn_receipt_revert_with_msg["blockHash"] @@ -294,8 +279,8 @@ def setup_chain_state(w3): ) ) print("TXN_HASH_REVERT_WITH_NO_MSG:", txn_hash_revert_with_no_msg) - txn_receipt_revert_with_no_msg = common.mine_transaction_hash( - w3, txn_hash_revert_with_no_msg + txn_receipt_revert_with_no_msg = w3.eth.wait_for_transaction_receipt( + txn_hash_revert_with_no_msg ) block_hash_revert_no_msg = w3.eth.get_block( txn_receipt_revert_with_no_msg["blockHash"] @@ -346,7 +331,6 @@ def setup_chain_state(w3): # Block with Transaction # w3.geth.personal.unlock_account(coinbase, common.KEYFILE_PW) - w3.geth.miner.start(1) mined_txn_hash = w3.eth.send_transaction( { "from": coinbase, @@ -356,7 +340,7 @@ def setup_chain_state(w3): "gas_price": w3.eth.gas_price, } ) - mined_txn_receipt = mine_transaction_hash(w3, mined_txn_hash) + mined_txn_receipt = w3.eth.wait_for_transaction_receipt(mined_txn_hash) print("MINED_TXN_HASH:", mined_txn_hash) block_with_txn = w3.eth.get_block(mined_txn_receipt["blockHash"]) print("BLOCK_WITH_TXN_HASH:", block_with_txn["hash"]) diff --git a/tests/integration/geth-1.11.6-fixture.zip b/tests/integration/geth-1.11.6-fixture.zip deleted file mode 100644 index 429ab04428..0000000000 Binary files a/tests/integration/geth-1.11.6-fixture.zip and /dev/null differ diff --git a/tests/integration/geth-1.13.9-fixture.zip b/tests/integration/geth-1.13.9-fixture.zip new file mode 100644 index 0000000000..8917945623 Binary files /dev/null and b/tests/integration/geth-1.13.9-fixture.zip differ diff --git a/tests/integration/go_ethereum/conftest.py b/tests/integration/go_ethereum/conftest.py index ca57cc66ca..9b81041f7d 100644 --- a/tests/integration/go_ethereum/conftest.py +++ b/tests/integration/go_ethereum/conftest.py @@ -36,7 +36,7 @@ KEYFILE_PW = "web3py-test" -GETH_FIXTURE_ZIP = "geth-1.11.6-fixture.zip" +GETH_FIXTURE_ZIP = "geth-1.13.9-fixture.zip" @pytest.fixture(scope="module") @@ -84,14 +84,17 @@ def base_geth_command_arguments(geth_binary, datadir): geth_binary, "--datadir", str(datadir), - "--nodiscover", - "--fakepow", + "--dev", + "--dev.period", + "5", # dev.period > 1 for tests which require pending blocks + "--password", + os.path.join(datadir, "keystore", "pw.txt"), ) @pytest.fixture(scope="module") def geth_zipfile_version(get_geth_version): - if get_geth_version.major == 1 and get_geth_version.minor in [10, 11]: + if get_geth_version.major == 1 and get_geth_version.minor in [11, 12, 13]: return GETH_FIXTURE_ZIP raise AssertionError("Unsupported geth version") diff --git a/tests/integration/go_ethereum/test_goethereum_http.py b/tests/integration/go_ethereum/test_goethereum_http.py index 5013e7cf80..ac4258f0a0 100644 --- a/tests/integration/go_ethereum/test_goethereum_http.py +++ b/tests/integration/go_ethereum/test_goethereum_http.py @@ -57,7 +57,7 @@ def _geth_command_arguments(rpc_port, base_geth_command_arguments, geth_version) "--http.port", rpc_port, "--http.api", - "admin,eth,net,web3,personal,miner,txpool", + "admin,eth,net,web3,personal,txpool", "--ipcdisable", "--allow-insecure-unlock", "--miner.etherbase", diff --git a/tests/integration/go_ethereum/test_goethereum_ipc.py b/tests/integration/go_ethereum/test_goethereum_ipc.py index 9b5d114f6f..1120329b19 100644 --- a/tests/integration/go_ethereum/test_goethereum_ipc.py +++ b/tests/integration/go_ethereum/test_goethereum_ipc.py @@ -5,9 +5,6 @@ from tests.integration.common import ( COINBASE, ) -from tests.utils import ( - get_open_port, -) from web3 import ( Web3, ) @@ -25,11 +22,8 @@ def _geth_command_arguments(geth_ipc_path, base_geth_command_arguments): - geth_port = get_open_port() yield from base_geth_command_arguments yield from ( - "--port", - geth_port, "--ipcpath", geth_ipc_path, "--miner.etherbase", diff --git a/tests/integration/go_ethereum/test_goethereum_ws.py b/tests/integration/go_ethereum/test_goethereum_ws.py index 22e2c66ad1..f24ae85917 100644 --- a/tests/integration/go_ethereum/test_goethereum_ws.py +++ b/tests/integration/go_ethereum/test_goethereum_ws.py @@ -42,13 +42,13 @@ def _geth_command_arguments(ws_port, base_geth_command_arguments, geth_version): "--ws.port", ws_port, "--ws.api", - "admin,eth,net,web3,personal,miner", + "admin,eth,net,web3,personal", "--ws.origins", "*", "--ipcdisable", "--allow-insecure-unlock", ) - if geth_version.minor not in [10, 11]: + if geth_version.minor not in [11, 12, 13]: raise AssertionError("Unsupported Geth version") else: raise AssertionError("Unsupported Geth version") diff --git a/tests/integration/go_ethereum/test_goethereum_ws_v2/conftest.py b/tests/integration/go_ethereum/test_goethereum_ws_v2/conftest.py index c2c904d5e6..87ad255c72 100644 --- a/tests/integration/go_ethereum/test_goethereum_ws_v2/conftest.py +++ b/tests/integration/go_ethereum/test_goethereum_ws_v2/conftest.py @@ -34,7 +34,7 @@ def _geth_command_arguments(ws_port, base_geth_command_arguments, geth_version): "--ipcdisable", "--allow-insecure-unlock", ) - if geth_version.minor not in [10, 11]: + if geth_version.minor not in [11, 12, 13]: raise AssertionError("Unsupported Geth version") else: raise AssertionError("Unsupported Geth version") diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index cc5d8a4fbc..42eafdc1e6 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -31,6 +31,9 @@ NetModuleTest, Web3ModuleTest, ) +from web3._utils.module_testing.eth_module import ( + UNKNOWN_ADDRESS, +) from web3.exceptions import ( MethodUnavailable, ) @@ -293,12 +296,6 @@ class TestEthereumTesterEthModule(EthModuleTest): test_eth_sign_transaction_ens_names = not_implemented( EthModuleTest.test_eth_sign_transaction_ens_names, MethodUnavailable ) - test_eth_submit_hashrate = not_implemented( - EthModuleTest.test_eth_submit_hashrate, MethodUnavailable - ) - test_eth_submit_work = not_implemented( - EthModuleTest.test_eth_submit_work, MethodUnavailable - ) test_eth_get_raw_transaction = not_implemented( EthModuleTest.test_eth_get_raw_transaction, MethodUnavailable ) @@ -311,9 +308,6 @@ class TestEthereumTesterEthModule(EthModuleTest): test_eth_get_raw_transaction_by_block_raises_error = not_implemented( EthModuleTest.test_eth_get_raw_transaction_by_block, MethodUnavailable ) - test_eth_replace_transaction_already_mined = not_implemented( - EthModuleTest.test_eth_replace_transaction_already_mined, MethodUnavailable - ) test_eth_call_with_override_param_type_check = not_implemented( EthModuleTest.test_eth_call_with_override_param_type_check, TypeError, @@ -327,9 +321,6 @@ class TestEthereumTesterEthModule(EthModuleTest): test_eth_fee_history_no_reward_percentiles = not_implemented( EthModuleTest.test_eth_fee_history_no_reward_percentiles, MethodUnavailable ) - test_eth_send_transaction_with_nonce = not_implemented( - EthModuleTest.test_eth_send_transaction_with_nonce, MethodUnavailable - ) test_eth_create_access_list = not_implemented( EthModuleTest.test_eth_create_access_list, MethodUnavailable, @@ -411,6 +402,49 @@ def test_eth_modify_transaction_legacy(self, eth_tester, w3, unlocked_account): def test_eth_modify_transaction(self, eth_tester, w3, unlocked_account): super().test_eth_modify_transaction(w3, unlocked_account) + @disable_auto_mine + def test_eth_get_logs_without_logs( + self, eth_tester, w3: "Web3", block_with_txn_with_log: BlockData + ) -> None: + # Note: This was the old way the test was written before geth started returning + # an error when the `toBlock` was before the `fromBlock` + + # Test with block range + filter_params = { + "fromBlock": 0, + "toBlock": block_with_txn_with_log["number"] - 1, + } + result = w3.eth.get_logs(filter_params) + assert len(result) == 0 + + # the range is wrong + filter_params = { + "fromBlock": block_with_txn_with_log["number"], + "toBlock": block_with_txn_with_log["number"] - 1, + } + result = w3.eth.get_logs(filter_params) + assert len(result) == 0 + + # Test with `address` + + # filter with other address + filter_params = { + "fromBlock": 0, + "address": UNKNOWN_ADDRESS, + } + result = w3.eth.get_logs(filter_params) + assert len(result) == 0 + + # Test with multiple `address` + + # filter with other address + filter_params = { + "fromBlock": 0, + "address": [UNKNOWN_ADDRESS, UNKNOWN_ADDRESS], + } + result = w3.eth.get_logs(filter_params) + assert len(result) == 0 + @disable_auto_mine def test_eth_call_old_contract_state( self, eth_tester, w3, math_contract, unlocked_account diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 5f479e060f..683c0e8633 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -55,7 +55,7 @@ from web3._utils.module_testing.module_testing_utils import ( assert_contains_log, async_mock_offchain_lookup_request_response, - mine_pending_block, + flaky_geth_dev_mining, mock_offchain_lookup_request_response, ) from web3._utils.type_conversion import ( @@ -507,8 +507,8 @@ async def test_eth_send_transaction_default_fees( assert is_same_address(txn["to"], cast(ChecksumAddress, txn_params["to"])) assert txn["value"] == 1 assert txn["gas"] == 21000 - assert txn["maxPriorityFeePerGas"] == 1 * 10**9 - assert txn["maxFeePerGas"] >= 1 * 10**9 + assert is_integer(txn["maxPriorityFeePerGas"]) + assert is_integer(txn["maxFeePerGas"]) assert txn["gasPrice"] == txn["maxFeePerGas"] @pytest.mark.asyncio @@ -635,7 +635,7 @@ async def test_validation_middleware_chain_id_mismatch( "from": async_unlocked_account_dual_type, "to": async_unlocked_account_dual_type, "value": Wei(1), - "gas": Wei(21000), + "gas": 21000, "maxFeePerGas": async_w3.to_wei(2, "gwei"), "maxPriorityFeePerGas": async_w3.to_wei(1, "gwei"), "chainId": wrong_chain_id, @@ -964,7 +964,6 @@ async def test_eth_getBlockByNumber_earliest( assert block["hash"] == genesis_block["hash"] @pytest.mark.asyncio - @pytest.mark.xfail(reason="Integration test suite not yet set up for PoS") async def test_eth_getBlockByNumber_safe( self, async_w3: "AsyncWeb3", async_empty_block: BlockData ) -> None: @@ -973,7 +972,6 @@ async def test_eth_getBlockByNumber_safe( assert isinstance(block["number"], int) @pytest.mark.asyncio - @pytest.mark.xfail(reason="Integration test suite not yet set up for PoS") async def test_eth_getBlockByNumber_finalized( self, async_w3: "AsyncWeb3", async_empty_block: BlockData ) -> None: @@ -1712,7 +1710,7 @@ async def test_async_eth_wait_for_transaction_receipt_unmined( } ) - timeout = 2 + timeout = 0.01 with pytest.raises(TimeExhausted) as exc_info: await async_w3.eth.wait_for_transaction_receipt(txn_hash, timeout=timeout) @@ -1769,8 +1767,8 @@ async def test_async_eth_get_logs_without_logs( "fromBlock": async_block_with_txn_with_log["number"], "toBlock": BlockNumber(async_block_with_txn_with_log["number"] - 1), } - result = await async_w3.eth.get_logs(filter_params) - assert len(result) == 0 + with pytest.raises(ValueError): + result = await async_w3.eth.get_logs(filter_params) # Test with `address` @@ -2110,6 +2108,7 @@ async def test_async_eth_sign_ens_names( assert is_bytes(signature) assert len(signature) == 32 + 32 + 1 + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_legacy( self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress @@ -2119,9 +2118,7 @@ async def test_async_eth_replace_transaction_legacy( "to": async_unlocked_account_dual_type, "value": Wei(1), "gas": 21000, - "gasPrice": async_w3.to_wei( - 1, "gwei" - ), # must be greater than base_fee post London + "gasPrice": async_w3.to_wei(1, "gwei"), } txn_hash = await async_w3.eth.send_transaction(txn_params) @@ -2139,6 +2136,7 @@ async def test_async_eth_replace_transaction_legacy( assert replace_txn["gas"] == 21000 assert replace_txn["gasPrice"] == txn_params["gasPrice"] + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction( self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress @@ -2173,6 +2171,7 @@ async def test_async_eth_replace_transaction( assert replace_txn["maxFeePerGas"] == three_gwei_in_wei assert replace_txn["maxPriorityFeePerGas"] == two_gwei_in_wei + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_underpriced( self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress @@ -2194,6 +2193,7 @@ async def test_async_eth_replace_transaction_underpriced( with pytest.raises(ValueError, match="replacement transaction underpriced"): await async_w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_non_existing_transaction( self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress @@ -2214,8 +2214,8 @@ async def test_async_eth_replace_transaction_non_existing_transaction( txn_params, ) + @flaky_geth_dev_mining @pytest.mark.asyncio - @pytest.mark.xfail(reason="AsyncGethMiner is missing.") async def test_async_eth_replace_transaction_already_mined( self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -2228,17 +2228,14 @@ async def test_async_eth_replace_transaction_already_mined( "maxPriorityFeePerGas": async_w3.to_wei(1, "gwei"), } txn_hash = await async_w3.eth.send_transaction(txn_params) - try: - async_w3.geth.miner.start() # type: ignore - await async_w3.eth.wait_for_transaction_receipt(txn_hash, timeout=10) - finally: - async_w3.geth.miner.stop() # type: ignore + await async_w3.eth.wait_for_transaction_receipt(txn_hash, timeout=10) txn_params["maxFeePerGas"] = async_w3.to_wei(3, "gwei") txn_params["maxPriorityFeePerGas"] = async_w3.to_wei(2, "gwei") with pytest.raises(ValueError, match="Supplied transaction with hash"): await async_w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_incorrect_nonce( self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress @@ -2260,6 +2257,7 @@ async def test_async_eth_replace_transaction_incorrect_nonce( with pytest.raises(ValueError): await async_w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_gas_price_too_low( self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress @@ -2277,6 +2275,7 @@ async def test_async_eth_replace_transaction_gas_price_too_low( with pytest.raises(ValueError): await async_w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_gas_price_defaulting_minimum( self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress @@ -2300,6 +2299,7 @@ async def test_async_eth_replace_transaction_gas_price_defaulting_minimum( gas_price * 1.125 ) # minimum gas price + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_higher( self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress @@ -2328,6 +2328,7 @@ def higher_gas_price_strategy(async_w3: "AsyncWeb3", txn: TxParams) -> Wei: ) # Strategy provides higher gas price async_w3.eth.set_gas_price_strategy(None) # reset strategy + @flaky_geth_dev_mining @pytest.mark.asyncio async def test_async_eth_replace_transaction_gas_price_defaulting_strategy_lower( self, async_w3: "AsyncWeb3", async_unlocked_account: ChecksumAddress @@ -2377,7 +2378,6 @@ async def test_async_eth_new_block_filter(self, async_w3: "AsyncWeb3") -> None: changes = await async_w3.eth.get_filter_changes(filter.filter_id) assert is_list_like(changes) - assert not changes result = await async_w3.eth.uninstall_filter(filter.filter_id) assert result is True @@ -2563,12 +2563,12 @@ def test_eth_get_balance(self, w3: "Web3") -> None: def test_eth_get_balance_with_block_identifier(self, w3: "Web3") -> None: miner_address = w3.eth.get_block(1)["miner"] - genesis_balance = w3.eth.get_balance(miner_address, 0) - later_balance = w3.eth.get_balance(miner_address, 1) + balance_post_genesis = w3.eth.get_balance(miner_address, 1) + later_balance = w3.eth.get_balance(miner_address, "latest") - assert is_integer(genesis_balance) + assert is_integer(balance_post_genesis) assert is_integer(later_balance) - assert later_balance > genesis_balance + assert later_balance > balance_post_genesis @pytest.mark.parametrize( "address, expect_success", @@ -3078,17 +3078,18 @@ def test_eth_send_transaction( def test_eth_send_transaction_with_nonce( self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: - mine_pending_block(w3) # gives an accurate transaction count after mining - + max_priority_fee_per_gas = w3.to_wei(1.234, "gwei") + max_fee_per_gas = Wei( + w3.eth.get_block("latest")["baseFeePerGas"] + max_priority_fee_per_gas + ) txn_params: TxParams = { "from": unlocked_account, "to": unlocked_account, "value": Wei(1), "gas": 21000, - # unique maxFeePerGas to ensure transaction hash different from other tests - "maxFeePerGas": w3.to_wei(4.321, "gwei"), - "maxPriorityFeePerGas": w3.to_wei(1, "gwei"), - "nonce": w3.eth.get_transaction_count(unlocked_account), + "maxFeePerGas": max_fee_per_gas, + "maxPriorityFeePerGas": max_priority_fee_per_gas, + "nonce": Nonce(w3.eth.get_transaction_count(unlocked_account, "pending")), } txn_hash = w3.eth.send_transaction(txn_params) txn = w3.eth.get_transaction(txn_hash) @@ -3100,7 +3101,8 @@ def test_eth_send_transaction_with_nonce( assert txn["maxFeePerGas"] == txn_params["maxFeePerGas"] assert txn["maxPriorityFeePerGas"] == txn_params["maxPriorityFeePerGas"] assert txn["nonce"] == txn_params["nonce"] - assert txn["gasPrice"] == txn_params["maxFeePerGas"] + assert is_integer(txn["gasPrice"]) + assert is_integer(txn_params["maxFeePerGas"]) def test_eth_send_transaction_default_fees( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress @@ -3118,8 +3120,8 @@ def test_eth_send_transaction_default_fees( assert is_same_address(txn["to"], cast(ChecksumAddress, txn_params["to"])) assert txn["value"] == 1 assert txn["gas"] == 21000 - assert txn["maxPriorityFeePerGas"] == 1 * 10**9 - assert txn["maxFeePerGas"] >= 1 * 10**9 + assert is_integer(txn["maxPriorityFeePerGas"]) + assert is_integer(txn["maxFeePerGas"]) assert txn["gasPrice"] == txn["maxFeePerGas"] def test_eth_send_transaction_hex_fees( @@ -3194,13 +3196,13 @@ def test_eth_send_transaction_no_priority_fee( def test_eth_send_transaction_no_max_fee( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - maxPriorityFeePerGas = w3.to_wei(2, "gwei") + max_priority_fee_per_gas = w3.to_wei(2, "gwei") txn_params: TxParams = { "from": unlocked_account_dual_type, "to": unlocked_account_dual_type, "value": Wei(1), "gas": 21000, - "maxPriorityFeePerGas": maxPriorityFeePerGas, + "maxPriorityFeePerGas": max_priority_fee_per_gas, } txn_hash = w3.eth.send_transaction(txn_params) txn = w3.eth.get_transaction(txn_hash) @@ -3209,9 +3211,9 @@ def test_eth_send_transaction_no_max_fee( assert is_same_address(txn["to"], cast(ChecksumAddress, txn_params["to"])) assert txn["value"] == 1 assert txn["gas"] == 21000 - - block = w3.eth.get_block("latest") - assert txn["maxFeePerGas"] == maxPriorityFeePerGas + 2 * block["baseFeePerGas"] + assert is_integer(txn["maxPriorityFeePerGas"]) + assert txn["maxPriorityFeePerGas"] == max_priority_fee_per_gas + assert is_integer(txn["maxFeePerGas"]) def test_eth_send_transaction_max_fee_less_than_tip( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress @@ -3334,6 +3336,7 @@ def gas_price_strategy(_w3: "Web3", _txn: TxParams) -> str: assert txn["gasPrice"] == two_gwei_in_wei w3.eth.set_gas_price_strategy(None) # reset strategy + @flaky_geth_dev_mining def test_eth_replace_transaction_legacy( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -3362,6 +3365,7 @@ def test_eth_replace_transaction_legacy( assert replace_txn["gas"] == 21000 assert replace_txn["gasPrice"] == txn_params["gasPrice"] + @flaky_geth_dev_mining def test_eth_replace_transaction( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -3395,6 +3399,7 @@ def test_eth_replace_transaction( assert replace_txn["maxFeePerGas"] == three_gwei_in_wei assert replace_txn["maxPriorityFeePerGas"] == two_gwei_in_wei + @flaky_geth_dev_mining def test_eth_replace_transaction_underpriced( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -3415,6 +3420,7 @@ def test_eth_replace_transaction_underpriced( with pytest.raises(ValueError, match="replacement transaction underpriced"): w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining def test_eth_replace_transaction_non_existing_transaction( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -3434,6 +3440,7 @@ def test_eth_replace_transaction_non_existing_transaction( txn_params, ) + @flaky_geth_dev_mining def test_eth_replace_transaction_already_mined( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -3446,17 +3453,14 @@ def test_eth_replace_transaction_already_mined( "maxPriorityFeePerGas": w3.to_wei(1, "gwei"), } txn_hash = w3.eth.send_transaction(txn_params) - try: - w3.geth.miner.start() # type: ignore - w3.eth.wait_for_transaction_receipt(txn_hash, timeout=10) - finally: - w3.geth.miner.stop() # type: ignore + w3.eth.wait_for_transaction_receipt(txn_hash, timeout=10) txn_params["maxFeePerGas"] = w3.to_wei(3, "gwei") txn_params["maxPriorityFeePerGas"] = w3.to_wei(2, "gwei") with pytest.raises(ValueError, match="Supplied transaction with hash"): w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining def test_eth_replace_transaction_incorrect_nonce( self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: @@ -3477,6 +3481,7 @@ def test_eth_replace_transaction_incorrect_nonce( with pytest.raises(ValueError): w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining def test_eth_replace_transaction_gas_price_too_low( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -3493,6 +3498,7 @@ def test_eth_replace_transaction_gas_price_too_low( with pytest.raises(ValueError): w3.eth.replace_transaction(txn_hash, txn_params) + @flaky_geth_dev_mining def test_eth_replace_transaction_gas_price_defaulting_minimum( self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: @@ -3515,6 +3521,7 @@ def test_eth_replace_transaction_gas_price_defaulting_minimum( gas_price * 1.125 ) # minimum gas price + @flaky_geth_dev_mining def test_eth_replace_transaction_gas_price_defaulting_strategy_higher( self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: @@ -3542,6 +3549,7 @@ def higher_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei: ) # Strategy provides higher gas price w3.eth.set_gas_price_strategy(None) # reset strategy + @flaky_geth_dev_mining def test_eth_replace_transaction_gas_price_defaulting_strategy_lower( self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: @@ -4199,7 +4207,6 @@ def test_eth_getBlockByNumber_earliest( assert block["number"] == 0 assert block["hash"] == genesis_block["hash"] - @pytest.mark.xfail(reason="Integration test suite not yet set up for PoS") def test_eth_getBlockByNumber_safe( self, w3: "Web3", empty_block: BlockData ) -> None: @@ -4207,7 +4214,6 @@ def test_eth_getBlockByNumber_safe( assert block is not None assert isinstance(block["number"], int) - @pytest.mark.xfail(reason="Integration test suite not yet set up for PoS") def test_eth_getBlockByNumber_finalized( self, w3: "Web3", empty_block: BlockData ) -> None: @@ -4336,7 +4342,7 @@ def test_eth_wait_for_transaction_receipt_unmined( } ) - timeout = 2 + timeout = 0.01 with pytest.raises(TimeExhausted) as exc_info: w3.eth.wait_for_transaction_receipt(txn_hash, timeout=timeout) @@ -4394,7 +4400,6 @@ def test_eth_new_block_filter(self, w3: "Web3") -> None: changes = w3.eth.get_filter_changes(filter.filter_id) assert is_list_like(changes) - assert not changes result = w3.eth.uninstall_filter(filter.filter_id) assert result is True @@ -4427,8 +4432,8 @@ def test_eth_get_logs_without_logs( "fromBlock": block_with_txn_with_log["number"], "toBlock": BlockNumber(block_with_txn_with_log["number"] - 1), } - result = w3.eth.get_logs(filter_params) - assert len(result) == 0 + with pytest.raises(ValueError): + w3.eth.get_logs(filter_params) # Test with `address` @@ -4585,25 +4590,6 @@ def test_eth_uninstall_filter(self, w3: "Web3") -> None: failure = w3.eth.uninstall_filter(filter.filter_id) assert failure is False - def test_eth_submit_hashrate(self, w3: "Web3") -> None: - # node_id from EIP 1474: https://github.com/ethereum/EIPs/pull/1474/files - node_id = HexStr( - "59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c" - ) - result = w3.eth.submit_hashrate(5000, node_id) - assert result is True - - def test_eth_submit_work(self, w3: "Web3") -> None: - nonce = 1 - pow_hash = HexStr( - "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" - ) - mix_digest = HexStr( - "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000" - ) - result = w3.eth.submit_work(nonce, pow_hash, mix_digest) - assert result is False - def test_eth_get_raw_transaction(self, w3: "Web3", mined_txn_hash: HexStr) -> None: raw_transaction = w3.eth.get_raw_transaction(mined_txn_hash) assert is_bytes(raw_transaction) diff --git a/web3/_utils/module_testing/module_testing_utils.py b/web3/_utils/module_testing/module_testing_utils.py index 7cb0e0b25a..6d66400961 100644 --- a/web3/_utils/module_testing/module_testing_utils.py +++ b/web3/_utils/module_testing/module_testing_utils.py @@ -22,6 +22,9 @@ from eth_utils import ( is_same_address, ) +from flaky import ( + flaky, +) from hexbytes import ( HexBytes, ) @@ -49,6 +52,14 @@ ) +""" +flaky_geth_dev_mining decorator for tests requiring a pending block +for the duration of the test. This behavior can be flaky +due to timing of the test running as a block is mined. +""" +flaky_geth_dev_mining = flaky(max_runs=3) + + def mine_pending_block(w3: "Web3") -> None: timeout = 10 diff --git a/web3/tools/benchmark/main.py b/web3/tools/benchmark/main.py index 8c40e12cee..16eb7abfec 100644 --- a/web3/tools/benchmark/main.py +++ b/web3/tools/benchmark/main.py @@ -13,10 +13,6 @@ Union, ) -from eth_typing import ( - ChecksumAddress, -) - from web3 import ( AsyncHTTPProvider, AsyncWeb3, @@ -105,17 +101,6 @@ async def async_benchmark(func: Callable[..., Any], n: int) -> Union[float, str] return "N/A" -def unlocked_account(w3: Web3) -> ChecksumAddress: - w3.geth.personal.unlock_account(w3.eth.coinbase, KEYFILE_PW) - return w3.eth.coinbase - - -async def async_unlocked_account(async_w3: AsyncWeb3) -> ChecksumAddress: - coinbase = await async_w3.eth.coinbase - await async_w3.geth.personal.unlock_account(coinbase, KEYFILE_PW) - return coinbase - - def main(logger: logging.Logger, num_calls: int) -> None: fixture = GethBenchmarkFixture() for built_fixture in fixture.build(): @@ -127,12 +112,15 @@ def main(logger: logging.Logger, num_calls: int) -> None: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) + # -- sync -- # + coinbase = w3_http.eth.coinbase + + # -- async -- # async_w3_http = loop.run_until_complete( build_async_w3_http(fixture.endpoint_uri) ) - async_unlocked_acct = loop.run_until_complete( - async_unlocked_account(async_w3_http) - ) + async_coinbase = loop.run_until_complete(async_w3_http.eth.coinbase) + methods = [ { "name": "eth_gasPrice", @@ -146,15 +134,15 @@ def main(logger: logging.Logger, num_calls: int) -> None: "exec": lambda: w3_http.eth.send_transaction( { "to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601", - "from": unlocked_account(w3_http), - "value": Wei(12345), + "from": coinbase, + "value": Wei(1), } ), "async_exec": lambda: async_w3_http.eth.send_transaction( { "to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601", - "from": async_unlocked_acct, - "value": Wei(12345), + "from": async_coinbase, + "value": Wei(1), } ), }, diff --git a/web3/tools/benchmark/node.py b/web3/tools/benchmark/node.py index d85a2b7a6e..43895d1caa 100644 --- a/web3/tools/benchmark/node.py +++ b/web3/tools/benchmark/node.py @@ -24,7 +24,7 @@ kill_proc_gracefully, ) -GETH_FIXTURE_ZIP = "geth-1.11.6-fixture.zip" +GETH_FIXTURE_ZIP = "geth-1.13.9-fixture.zip" # use same coinbase value as in `web3.py/tests/integration/generate_fixtures/common.py` COINBASE = "0xdc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd" @@ -80,20 +80,23 @@ def _geth_binary(self) -> str: def _geth_command_arguments(self, datadir: str) -> Sequence[str]: return ( self.geth_binary, + "--dev", + "--dev.period", + "100", "--datadir", str(datadir), "--nodiscover", - "--fakepow", "--http", "--http.port", self.rpc_port, "--http.api", - "admin,eth,net,web3,personal,miner", + "admin,eth,net,web3", "--ipcdisable", "--allow-insecure-unlock", "--miner.etherbase", COINBASE[2:], - "--rpc.enabledeprecatedpersonal", + "--password", + os.path.join(datadir, "keystore", "pw.txt"), ) def _geth_process(