From e72e49022566ecf328a4a417ade82914e32637a5 Mon Sep 17 00:00:00 2001 From: Nicolas Feignon Date: Tue, 28 Jan 2020 13:14:43 +0100 Subject: [PATCH 1/3] Increase replacement tx minimum gas price bump Parity requires a gas price 12.5% higher than the previous one to accept a replacement transaction in its transaction queue. --- docs/web3.eth.rst | 2 +- web3/_utils/transactions.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index 36f217a856..7d755d8530 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -679,7 +679,7 @@ The following methods are available on the ``web3.eth`` namespace. If the ``new_transaction`` does not specify a ``gasPrice`` value, the highest of the following 2 values will be used: - * The pending transaction's ``gasPrice`` * 1.1 - This is typically the minimum + * The pending transaction's ``gasPrice`` * 1.125 - This is typically the minimum ``gasPrice`` increase a node requires before it accepts a replacement transaction. * The ``gasPrice`` as calculated by the current gas price strategy(See :ref:`Gas_Price`). diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 604cc33ae8..6a62308a68 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -195,7 +195,7 @@ def prepare_replacement_transaction( raise ValueError('Supplied gas price must exceed existing transaction gas price') else: generated_gas_price = web3.eth.generateGasPrice(new_transaction) - minimum_gas_price = int(math.ceil(current_transaction['gasPrice'] * 1.1)) + minimum_gas_price = int(math.ceil(current_transaction['gasPrice'] * 1.125)) if generated_gas_price and generated_gas_price > minimum_gas_price: new_transaction = assoc(new_transaction, 'gasPrice', generated_gas_price) else: From 280090a21ba210f36ef0b5646baac5531da2c245 Mon Sep 17 00:00:00 2001 From: Marc Garreau Date: Tue, 18 Feb 2020 15:08:37 -0700 Subject: [PATCH 2/3] parameterize gas multiplier --- .../utilities/test_prepare_transaction_replacement.py | 8 ++++---- web3/_utils/module_testing/eth_module.py | 4 ++-- web3/_utils/transactions.py | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/core/utilities/test_prepare_transaction_replacement.py b/tests/core/utilities/test_prepare_transaction_replacement.py index e57b103aca..4ae9d3a465 100644 --- a/tests/core/utilities/test_prepare_transaction_replacement.py +++ b/tests/core/utilities/test_prepare_transaction_replacement.py @@ -24,7 +24,7 @@ def test_prepare_transaction_replacement(web3): assert replacement_transaction == { 'value': 1, 'nonce': 2, - 'gasPrice': 11, + 'gasPrice': 12, } @@ -38,7 +38,7 @@ def test_prepare_transaction_replacement_without_nonce_sets_correct_nonce(web3): assert replacement_transaction == { 'value': 1, 'nonce': 2, - 'gasPrice': 11, + 'gasPrice': 12, } @@ -83,7 +83,7 @@ def test_prepare_transaction_replacement_gas_price_defaulting(web3): replacement_transaction = prepare_replacement_transaction( web3, current_transaction, new_transaction) - assert replacement_transaction['gasPrice'] == 11 + assert replacement_transaction['gasPrice'] == 12 def test_prepare_transaction_replacement_gas_price_defaulting_when_strategy_higer(web3): @@ -119,4 +119,4 @@ def lower_gas_price_strategy(web3, txn): replacement_transaction = prepare_replacement_transaction( web3, current_transaction, new_transaction) - assert replacement_transaction['gasPrice'] == 11 + assert replacement_transaction['gasPrice'] == 12 diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 525b1dfa42..c4930d0f73 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -530,7 +530,7 @@ def test_eth_replaceTransaction_gas_price_defaulting_minimum( replace_txn_hash = web3.eth.replaceTransaction(txn_hash, txn_params) replace_txn = web3.eth.getTransaction(replace_txn_hash) - assert replace_txn['gasPrice'] == 11 # minimum gas price + assert replace_txn['gasPrice'] == 12 # minimum gas price def test_eth_replaceTransaction_gas_price_defaulting_strategy_higher( self, web3: "Web3", unlocked_account: ChecksumAddress @@ -575,7 +575,7 @@ def lower_gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: replace_txn_hash = web3.eth.replaceTransaction(txn_hash, txn_params) replace_txn = web3.eth.getTransaction(replace_txn_hash) # Strategy provices lower gas price - minimum preferred - assert replace_txn['gasPrice'] == 11 + assert replace_txn['gasPrice'] == 12 def test_eth_modifyTransaction( self, web3: "Web3", unlocked_account: ChecksumAddress diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 6a62308a68..733c1fccbb 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -179,7 +179,10 @@ def assert_valid_transaction_params(transaction_params: TxParams) -> None: def prepare_replacement_transaction( - web3: "Web3", current_transaction: TxData, new_transaction: TxParams + web3: "Web3", + current_transaction: TxData, + new_transaction: TxParams, + gas_multiplier: float = 1.125 ) -> TxParams: if current_transaction['blockHash'] is not None: raise ValueError('Supplied transaction with hash {} has already been mined' @@ -195,7 +198,7 @@ def prepare_replacement_transaction( raise ValueError('Supplied gas price must exceed existing transaction gas price') else: generated_gas_price = web3.eth.generateGasPrice(new_transaction) - minimum_gas_price = int(math.ceil(current_transaction['gasPrice'] * 1.125)) + minimum_gas_price = int(math.ceil(current_transaction['gasPrice'] * gas_multiplier)) if generated_gas_price and generated_gas_price > minimum_gas_price: new_transaction = assoc(new_transaction, 'gasPrice', generated_gas_price) else: From 4440f64a03763a7fd40dfb6e019f530ccb2792c4 Mon Sep 17 00:00:00 2001 From: Marc Garreau Date: Thu, 20 Feb 2020 13:56:05 -0700 Subject: [PATCH 3/3] add newsfragment --- newsfragments/1570.bugfix.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 newsfragments/1570.bugfix.rst diff --git a/newsfragments/1570.bugfix.rst b/newsfragments/1570.bugfix.rst new file mode 100644 index 0000000000..e6686d86a8 --- /dev/null +++ b/newsfragments/1570.bugfix.rst @@ -0,0 +1,5 @@ +Increase replacement tx minimum gas price bump + +Parity/OpenEthereum requires a replacement transaction's +gas to be a minimum of 12.5% higher than the original +(vs. Geth's 10%).