Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase replacement transaction minimum gas price bump to 12.5% #1570

Merged
merged 3 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/web3.eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`).

Expand Down
8 changes: 4 additions & 4 deletions tests/core/utilities/test_prepare_transaction_replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_prepare_transaction_replacement(web3):
assert replacement_transaction == {
'value': 1,
'nonce': 2,
'gasPrice': 11,
'gasPrice': 12,
}


Expand All @@ -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,
}


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions web3/_utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions web3/_utils/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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.1))
wolovim marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand Down