Skip to content

Commit

Permalink
Bump gas estimate percentile to 20%
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjw committed Aug 8, 2018
1 parent cab6a5b commit 9ccc9d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions tests/core/gas-strategies/test_time_based_gas_price_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,20 @@ def _get_block_by_something(method, params):
(
# 120 second wait times
(dict(max_wait_seconds=80, sample_size=5, probability=98), 70),
(dict(max_wait_seconds=80, sample_size=5, probability=90), 23),
(dict(max_wait_seconds=80, sample_size=5, probability=50), 7),
(dict(max_wait_seconds=80, sample_size=5, probability=90), 25),
(dict(max_wait_seconds=80, sample_size=5, probability=50), 11),
# 60 second wait times
(dict(max_wait_seconds=60, sample_size=5, probability=98), 92),
(dict(max_wait_seconds=60, sample_size=5, probability=90), 48),
(dict(max_wait_seconds=60, sample_size=5, probability=50), 7),
(dict(max_wait_seconds=60, sample_size=5, probability=90), 49),
(dict(max_wait_seconds=60, sample_size=5, probability=50), 11),
# 40 second wait times
(dict(max_wait_seconds=40, sample_size=5, probability=98), 100),
(dict(max_wait_seconds=40, sample_size=5, probability=90), 81),
(dict(max_wait_seconds=40, sample_size=5, probability=50), 7),
(dict(max_wait_seconds=40, sample_size=5, probability=50), 11),
# 20 second wait times
(dict(max_wait_seconds=20, sample_size=5, probability=98), 100),
(dict(max_wait_seconds=20, sample_size=5, probability=90), 100),
(dict(max_wait_seconds=20, sample_size=5, probability=50), 34),
(dict(max_wait_seconds=20, sample_size=5, probability=50), 36),
),
)
def test_time_based_gas_price_strategy(strategy_params, expected):
Expand All @@ -150,7 +150,7 @@ def test_time_based_gas_price_strategy(strategy_params, expected):
)
w3.eth.setGasPriceStrategy(time_based_gas_price_strategy)
actual = w3.eth.generateGasPrice()
assert actual == expected
assert int(actual) == expected


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion web3/gas_strategies/time_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _aggregate_miner_data(raw_data):
for miner, miner_data in data_by_miner.items():
_, block_hashes, gas_prices = map(set, zip(*miner_data))
try:
price_percentile = percentile(gas_prices, percentile=15)
price_percentile = percentile(gas_prices, percentile=20)
except InsufficientData:
price_percentile = min(gas_prices)
yield MinerData(
Expand Down
2 changes: 1 addition & 1 deletion web3/utils/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def percentile(values=None, percentile=None):
"""Calculates a simplified weighted average percentile
"""
if values in [None, tuple(), []] or len(values) < 1:
raise InsufficientData("Expected a sequence of at least 1 integers, got {0}".format(values))
raise InsufficientData("Expected a sequence of at least 1 integers, got {0!r}".format(values))
if percentile is None:
raise ValueError("Expected a percentile choice, got {0}".format(percentile))

Expand Down

0 comments on commit 9ccc9d1

Please sign in to comment.