diff --git a/newsfragments/2053.bugfix.rst b/newsfragments/2053.bugfix.rst new file mode 100644 index 0000000000..5a256fa288 --- /dev/null +++ b/newsfragments/2053.bugfix.rst @@ -0,0 +1 @@ +Fix broken tests and use the new 1559 params for most of our test transactions. \ No newline at end of file diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index a9ddbbd19e..f5e30c3dc8 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -15,6 +15,24 @@ ) +def pytest_collection_modifyitems(items): + """ + Certain tests have their context dirtied by other tests. We can somewhat + control when these tests are run by overriding this pytest hook and customizing + when certain tests are run. This may help a test to pass due to a cleaner context. + """ + + test_names_to_append_to_start = [ + 'test_eth_get_logs_with_logs', + 'test_eth_call_old_contract_state', + ] + for index, item in enumerate(items): + test_name = item.name if "[" not in item.name else item.name[:item.name.find("[")] + if test_name in test_names_to_append_to_start: + test_item = items.pop(index) + items.insert(0, test_item) + + @pytest.fixture(scope="module") def math_contract_factory(web3): contract_factory = web3.eth.contract(abi=MATH_ABI, bytecode=MATH_BYTECODE) diff --git a/tests/integration/go_ethereum/common.py b/tests/integration/go_ethereum/common.py index 0c65884dd0..5d47444875 100644 --- a/tests/integration/go_ethereum/common.py +++ b/tests/integration/go_ethereum/common.py @@ -1,6 +1,3 @@ -# from concurrent.futures._base import ( -# TimeoutError as FuturesTimeoutError, -# ) import pytest from web3._utils.module_testing import ( # noqa: F401 @@ -20,20 +17,16 @@ def _check_web3_clientVersion(self, client_version): class GoEthereumEthModuleTest(EthModuleTest): - # @pytest.mark.xfail( - # strict=False, - # raises=FuturesTimeoutError, - # reason='Sometimes a TimeoutError is hit when waiting for the txn to be mined', - # ) - @pytest.mark.skip(reason="London TODO: crashes on [address_conversion_func1]") + @pytest.mark.xfail( + strict=False, + reason='Sometimes a TimeoutError is hit when waiting for the txn to be mined', + ) def test_eth_replace_transaction_already_mined(self, web3, unlocked_account_dual_type): - web3.geth.miner.start() - super().test_eth_replace_transaction_already_mined(web3, unlocked_account_dual_type) - web3.geth.miner.stop() - - @pytest.mark.skip(reason="London TODO: pending call isn't found") - def test_eth_call_old_contract_state(self, web3, math_contract, unlocked_account): - super().test_eth_call_old_contract_state(web3, math_contract, unlocked_account) + try: + web3.geth.miner.start() + super().test_eth_replace_transaction_already_mined(web3, unlocked_account_dual_type) + finally: + web3.geth.miner.stop() @pytest.mark.xfail(reason='eth_signTypedData has not been released in geth') def test_eth_sign_typed_data(self, web3, unlocked_account_dual_type): diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index 0d1145bc42..d7a5373b8f 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -272,18 +272,34 @@ def test_eth_getBlockByHash_pending( assert block['hash'] is not None @disable_auto_mine + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') def test_eth_get_transaction_receipt_unmined(self, eth_tester, web3, unlocked_account): super().test_eth_get_transaction_receipt_unmined(web3, unlocked_account) @disable_auto_mine - def test_eth_replaceTransaction_deprecated(self, eth_tester, web3, unlocked_account): - super().test_eth_replaceTransaction_deprecated(web3, unlocked_account) + def test_eth_replace_transaction_legacy(self, eth_tester, web3, unlocked_account): + super().test_eth_replace_transaction_legacy(web3, unlocked_account) @disable_auto_mine + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') def test_eth_replace_transaction(self, eth_tester, web3, unlocked_account): super().test_eth_replace_transaction(web3, unlocked_account) + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') + def test_eth_replace_transaction_underpriced(self, web3, emitter_contract_address): + super().test_eth_replace_transaction_underpriced(web3, emitter_contract_address) + + @disable_auto_mine + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') + def test_eth_replaceTransaction_deprecated(self, eth_tester, web3, unlocked_account): + super().test_eth_replaceTransaction_deprecated(web3, unlocked_account) + + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') + def test_eth_replace_transaction_already_mined(self, web3, emitter_contract_address): + super().test_eth_replace_transaction_already_mined(web3, emitter_contract_address) + @disable_auto_mine + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') def test_eth_replace_transaction_incorrect_nonce(self, eth_tester, web3, unlocked_account): super().test_eth_replace_transaction_incorrect_nonce(web3, unlocked_account) @@ -429,24 +445,32 @@ def test_eth_estimate_gas_revert_without_msg(self, web3, revert_contract, unlock web3.eth.estimate_gas(txn_params) @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') - def test_1559_default_fees(self, web3, emitter_contract_address): - super().test_1559_default_fees(web3, emitter_contract_address) + def test_eth_send_transaction(self, web3, emitter_contract_address): + super().test_eth_send_transaction(web3, emitter_contract_address) + + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') + def test_eth_sendTransaction_deprecated(self, web3, emitter_contract_address): + super().test_eth_sendTransaction_deprecated(web3, emitter_contract_address) + + @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') + def test_eth_send_transaction_with_nonce(self, web3, emitter_contract_address): + super().test_eth_send_transaction_with_nonce(web3, emitter_contract_address) @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') - def test_1559_canonical(self, web3, emitter_contract_address): - super().test_1559_canonical(web3, emitter_contract_address) + def test_eth_send_transaction_default_fees(self, web3, emitter_contract_address): + super().test_eth_send_transaction_default_fees(web3, emitter_contract_address) @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') - def test_1559_hex_fees(self, web3, emitter_contract_address): - super().test_1559_hex_fees(web3, emitter_contract_address) + def test_eth_send_transaction_hex_fees(self, web3, emitter_contract_address): + super().test_eth_send_transaction_hex_fees(web3, emitter_contract_address) @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') - def test_1559_no_gas(self, web3, emitter_contract_address): - super().test_1559_no_gas(web3, emitter_contract_address) + def test_eth_send_transaction_no_gas(self, web3, emitter_contract_address): + super().test_eth_send_transaction_no_gas(web3, emitter_contract_address) @pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester') - def test_1559_no_max_fee(self, web3, emitter_contract_address): - super().test_1559_no_max_fee(web3, emitter_contract_address) + def test_eth_send_transaction_no_max_fee(self, web3, emitter_contract_address): + super().test_eth_send_transaction_no_max_fee(web3, emitter_contract_address) class TestEthereumTesterVersionModule(VersionModuleTest): diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 740dd7a881..9cfe787070 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -779,7 +779,8 @@ def test_eth_send_transaction_addr_checksum_required( 'to': unlocked_account, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': web3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } with pytest.raises(InvalidAddress): @@ -790,7 +791,7 @@ def test_eth_send_transaction_addr_checksum_required( invalid_params = cast(TxParams, dict(txn_params, **{'to': non_checksum_addr})) web3.eth.send_transaction(invalid_params) - def test_eth_send_transaction( + def test_eth_send_transaction_legacy( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -809,6 +810,29 @@ def test_eth_send_transaction( assert txn['gas'] == 21000 assert txn['gasPrice'] == txn_params['gasPrice'] + # default send_transaction tests were updated to use 1559 canonical txn params + def test_eth_send_transaction( + self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + ) -> None: + txn_params: TxParams = { + 'from': unlocked_account_dual_type, + 'to': unlocked_account_dual_type, + 'value': Wei(1), + 'gas': Wei(21000), + 'maxFeePerGas': web3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + } + txn_hash = web3.eth.send_transaction(txn_params) + txn = web3.eth.get_transaction(txn_hash) + + assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) + assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) + assert txn['value'] == 1 + assert txn['gas'] == 21000 + assert txn['maxFeePerGas'] == txn_params['maxFeePerGas'] + assert txn['maxPriorityFeePerGas'] == txn_params['maxPriorityFeePerGas'] + assert txn['gasPrice'] is None + def test_eth_sendTransaction_deprecated( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: @@ -817,7 +841,8 @@ def test_eth_sendTransaction_deprecated( 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': web3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } with pytest.warns(DeprecationWarning, match="sendTransaction is deprecated in favor of send_transaction"): @@ -828,16 +853,22 @@ def test_eth_sendTransaction_deprecated( assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) assert txn['value'] == 1 assert txn['gas'] == 21000 - assert txn['gasPrice'] == txn_params['gasPrice'] + assert txn['maxFeePerGas'] == txn_params['maxFeePerGas'] + assert txn['maxPriorityFeePerGas'] == txn_params['maxPriorityFeePerGas'] + assert txn['gasPrice'] is None - def test_1559_default_fees( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + def test_eth_send_transaction_with_nonce( + self, web3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { - 'from': unlocked_account_dual_type, - 'to': unlocked_account_dual_type, + 'from': unlocked_account, + 'to': unlocked_account, 'value': Wei(1), 'gas': Wei(21000), + # unique gas price to ensure transaction hash different from other tests + 'maxFeePerGas': web3.toWei(4.321, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'nonce': web3.eth.get_transaction_count(unlocked_account), } txn_hash = web3.eth.send_transaction(txn_params) txn = web3.eth.get_transaction(txn_hash) @@ -846,11 +877,12 @@ def test_1559_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 txn['maxFeePerGas'] == txn_params['maxFeePerGas'] + assert txn['maxPriorityFeePerGas'] == txn_params['maxPriorityFeePerGas'] + assert txn['nonce'] == txn_params['nonce'] assert txn['gasPrice'] is None - def test_1559_canonical( + def test_eth_send_transaction_default_fees( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -858,8 +890,6 @@ def test_1559_canonical( 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'maxFeePerGas': Wei(250 * 10**9), - 'maxPriorityFeePerGas': Wei(2 * 10**9), } txn_hash = web3.eth.send_transaction(txn_params) txn = web3.eth.get_transaction(txn_hash) @@ -868,11 +898,11 @@ def test_1559_canonical( assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) assert txn['value'] == 1 assert txn['gas'] == 21000 - assert txn['maxFeePerGas'] == 250 * 10**9 - assert txn['maxPriorityFeePerGas'] == 2 * 10**9 + assert txn['maxPriorityFeePerGas'] == 1 * 10**9 + assert txn['maxFeePerGas'] >= 1 * 10**9 assert txn['gasPrice'] is None - def test_1559_hex_fees( + def test_eth_send_transaction_hex_fees( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -893,7 +923,7 @@ def test_1559_hex_fees( assert txn['maxFeePerGas'] == 250 * 10**9 assert txn['maxPriorityFeePerGas'] == 2 * 10**9 - def test_1559_no_gas( + def test_eth_send_transaction_no_gas( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -911,7 +941,7 @@ def test_1559_no_gas( assert txn['value'] == 1 assert txn['gas'] == 121000 # 21000 + buffer - def test_1559_with_gas_price( + def test_eth_send_transaction_with_gas_price( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -926,7 +956,7 @@ def test_1559_with_gas_price( with pytest.raises(TransactionTypeMismatch): web3.eth.send_transaction(txn_params) - def test_1559_no_priority_fee( + def test_eth_send_transaction_no_priority_fee( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -939,7 +969,7 @@ def test_1559_no_priority_fee( with pytest.raises(InvalidTransaction, match='maxPriorityFeePerGas must be defined'): web3.eth.send_transaction(txn_params) - def test_1559_no_max_fee( + def test_eth_send_transaction_no_max_fee( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -962,7 +992,7 @@ def test_1559_no_max_fee( assert txn['maxFeePerGas'] >= block['baseFeePerGas'] # assert txn['maxFeePerGas'] == base_fee * 2 - def test_1559_max_fee_less_than_tip( + def test_eth_send_transaction_max_fee_less_than_tip( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -978,41 +1008,48 @@ def test_1559_max_fee_less_than_tip( ): web3.eth.send_transaction(txn_params) - def test_eth_send_transaction_with_nonce( - self, web3: "Web3", unlocked_account: ChecksumAddress + def test_eth_replace_transaction_legacy( + self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { - 'from': unlocked_account, - 'to': unlocked_account, + 'from': unlocked_account_dual_type, + 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - # Increased gas price to ensure transaction hash different from other tests - 'gasPrice': Wei(web3.eth.gas_price * 3), - 'nonce': web3.eth.get_transaction_count(unlocked_account), + 'gasPrice': web3.eth.gas_price, } txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) - assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) - assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) - assert txn['value'] == 1 - assert txn['gas'] == 21000 - assert txn['gasPrice'] == txn_params['gasPrice'] - assert txn['nonce'] == txn_params['nonce'] + txn_params['gasPrice'] = Wei(web3.eth.gas_price * 2) + replace_txn_hash = web3.eth.replace_transaction(txn_hash, txn_params) + replace_txn = web3.eth.get_transaction(replace_txn_hash) + + assert is_same_address(replace_txn['from'], cast(ChecksumAddress, txn_params['from'])) + assert is_same_address(replace_txn['to'], cast(ChecksumAddress, txn_params['to'])) + assert replace_txn['value'] == 1 + assert replace_txn['gas'] == 21000 + assert replace_txn['gasPrice'] == txn_params['gasPrice'] def test_eth_replace_transaction( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: + one_gwei_in_wei = web3.toWei(1, 'gwei') + two_gwei_in_wei = web3.toWei(2, 'gwei') + three_gwei_in_wei = web3.toWei(3, 'gwei') + txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': two_gwei_in_wei, + 'maxPriorityFeePerGas': one_gwei_in_wei, } txn_hash = web3.eth.send_transaction(txn_params) - txn_params['gasPrice'] = Wei(web3.eth.gas_price * 2) + txn_params['maxFeePerGas'] = three_gwei_in_wei + txn_params['maxPriorityFeePerGas'] = two_gwei_in_wei + replace_txn_hash = web3.eth.replace_transaction(txn_hash, txn_params) replace_txn = web3.eth.get_transaction(replace_txn_hash) @@ -1020,21 +1057,48 @@ def test_eth_replace_transaction( assert is_same_address(replace_txn['to'], cast(ChecksumAddress, txn_params['to'])) assert replace_txn['value'] == 1 assert replace_txn['gas'] == 21000 - assert replace_txn['gasPrice'] == txn_params['gasPrice'] + assert replace_txn['maxFeePerGas'] == three_gwei_in_wei + assert replace_txn['maxPriorityFeePerGas'] == two_gwei_in_wei + + def test_eth_replace_transaction_underpriced( + self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + ) -> None: + txn_params: TxParams = { + 'from': unlocked_account_dual_type, + 'to': unlocked_account_dual_type, + 'value': Wei(1), + 'gas': Wei(21000), + 'maxFeePerGas': web3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(2, 'gwei'), + } + txn_hash = web3.eth.send_transaction(txn_params) + + one_gwei_in_wei = web3.toWei(1, 'gwei') + txn_params['maxFeePerGas'] = one_gwei_in_wei + txn_params['maxPriorityFeePerGas'] = one_gwei_in_wei + + with pytest.raises(ValueError, match="replacement transaction underpriced"): + web3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replaceTransaction_deprecated( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: + one_gwei_in_wei = web3.toWei(1, 'gwei') + two_gwei_in_wei = web3.toWei(2, 'gwei') + three_gwei_in_wei = web3.toWei(3, 'gwei') + txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': two_gwei_in_wei, + 'maxPriorityFeePerGas': one_gwei_in_wei, } txn_hash = web3.eth.send_transaction(txn_params) - txn_params['gasPrice'] = Wei(web3.eth.gas_price * 2) + txn_params['maxFeePerGas'] = three_gwei_in_wei + txn_params['maxPriorityFeePerGas'] = two_gwei_in_wei with pytest.warns( DeprecationWarning, match="replaceTransaction is deprecated in favor of replace_transaction" @@ -1046,7 +1110,8 @@ def test_eth_replaceTransaction_deprecated( assert is_same_address(replace_txn['to'], cast(ChecksumAddress, txn_params['to'])) assert replace_txn['value'] == 1 assert replace_txn['gas'] == 21000 - assert replace_txn['gasPrice'] == txn_params['gasPrice'] + assert replace_txn['maxFeePerGas'] == three_gwei_in_wei + assert replace_txn['maxPriorityFeePerGas'] == two_gwei_in_wei def test_eth_replace_transaction_non_existing_transaction( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress @@ -1056,7 +1121,8 @@ def test_eth_replace_transaction_non_existing_transaction( 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': web3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } with pytest.raises(TransactionNotFound): web3.eth.replace_transaction( @@ -1072,12 +1138,14 @@ def test_eth_replace_transaction_already_mined( 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': web3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } txn_hash = web3.eth.send_transaction(txn_params) - web3.eth.wait_for_transaction_receipt(txn_hash) + web3.eth.wait_for_transaction_receipt(txn_hash, timeout=10) - txn_params['gasPrice'] = Wei(web3.eth.gas_price * 2) + txn_params['maxFeePerGas'] = web3.toWei(3, 'gwei') + txn_params['maxPriorityFeePerGas'] = web3.toWei(2, 'gwei') with pytest.raises(ValueError, match="Supplied transaction with hash"): web3.eth.replace_transaction(txn_hash, txn_params) @@ -1089,12 +1157,14 @@ def test_eth_replace_transaction_incorrect_nonce( 'to': unlocked_account, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': web3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } txn_hash = web3.eth.send_transaction(txn_params) txn = web3.eth.get_transaction(txn_hash) - txn_params['gasPrice'] = Wei(web3.eth.gas_price * 2) + txn_params['maxFeePerGas'] = web3.toWei(3, 'gwei') + txn_params['maxPriorityFeePerGas'] = web3.toWei(2, 'gwei') txn_params['nonce'] = Nonce(txn['nonce'] + 1) with pytest.raises(ValueError): web3.eth.replace_transaction(txn_hash, txn_params) @@ -1568,7 +1638,8 @@ def test_eth_get_transaction_receipt_unmined( 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'gasPrice': web3.eth.gas_price, + 'maxFeePerGas': web3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': web3.toWei(1, 'gwei') }) with pytest.raises(TransactionNotFound): web3.eth.get_transaction_receipt(txn_hash) diff --git a/web3/_utils/module_testing/math_contract.py b/web3/_utils/module_testing/math_contract.py index 269b0f8ba8..d351f0d5a6 100644 --- a/web3/_utils/module_testing/math_contract.py +++ b/web3/_utils/module_testing/math_contract.py @@ -95,11 +95,12 @@ contract Contract { function main() { memory[0x40:0x60] = 0x60; - + if (!msg.data.length) { stop(); } - - var var0 = msg.data[0x00:0x20] / 0x0100000000000000000000000000000000000000000000000000000000; - + + var var0 = + msg.data[0x00:0x20] / 0x0100000000000000000000000000000000000000000000000000000000; + if (var0 == 0x16216f39) { // Dispatch table entry for return13() var var1 = 0x0083; @@ -154,36 +155,36 @@ return memory[temp11:temp11 + (temp10 + 0x20) - temp11]; } else { stop(); } } - + function return13() returns (var r0) { var var0 = 0x0d; return var0; } - + function counter() returns (var r0) { return storage[0x00]; } - + function increment(var arg0) returns (var r0) { storage[0x00] = storage[0x00] + arg0; var temp0 = memory[0x40:0x60]; memory[temp0:temp0 + 0x20] = storage[0x00]; var temp1 = memory[0x40:0x60]; - log(memory[temp1:temp1 + (temp0 + 0x20) - temp1], [0x3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5]); + log(memory[temp1:temp1 + (temp0 + 0x20) - temp1], + [0x3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5]); var var0 = storage[0x00]; - return var0; - } - + return var0;} + function add(var arg0, var arg1) returns (var r0) { var var0 = arg0 + arg1; return var0; } - + function increment() returns (var r0) { var var0 = 0x00; var var1 = 0x020d; var var2 = 0x01; return increment(var2); } - + function multiply7(var arg0) returns (var r0) { var var0 = arg0 * 0x07; return var0; diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 165dc7a339..e4a39e592f 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -193,9 +193,14 @@ def prepare_replacement_transaction( if 'nonce' not in new_transaction: new_transaction = assoc(new_transaction, 'nonce', current_transaction['nonce']) - if 'gasPrice' in new_transaction: + if 'maxFeePerGas' in new_transaction or 'maxPriorityFeePerGas' in new_transaction: + # for now, the client decides if a 1559 txn can replace the existing txn or not + pass + + elif 'gasPrice' in new_transaction and current_transaction['gasPrice'] is not None: if new_transaction['gasPrice'] <= current_transaction['gasPrice']: raise ValueError('Supplied gas price must exceed existing transaction gas price') + else: generated_gas_price = web3.eth.generate_gas_price(new_transaction) minimum_gas_price = int(math.ceil(current_transaction['gasPrice'] * gas_multiplier))