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

eth/gasprice: set default percentile to 60%, count blocks instead of transactions #15828

Merged
merged 9 commits into from
Jan 10, 2018

Conversation

Arachnid
Copy link
Contributor

@Arachnid Arachnid commented Jan 7, 2018

The first should address a long term issue where we recommend a gas price that is greater than that required for 50% of transactions in recent blocks, which can lead to gas price inflation as people take this figure and add a margin to it, resulting in a positive feedback loop.

The latter is a more experimental change following ethgasstation's suggestion: https://twitter.com/ETHGasStation/status/949264877788585984

The insight being that each miner can set their own inclusion policy; rather than looking at a percentile of recent transactions, we should instead look at a percentile of recent blocks; a gas price that was sufficient to be included in n% of recent blocks should be sufficient to get our TX included quickly.

This will need some experimentation and trialling on nodes to see how well it fares before public release.

Still todo:

  • Allow users to specify the percentile in calls to the oracle
  • Allow users to specify a gas limit, and only consider transactions with at least that much gas when estimating gas price.

@Arachnid Arachnid requested a review from karalabe as a code owner January 7, 2018 18:56
@GitCop
Copy link

GitCop commented Jan 7, 2018

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: e12af2bfe7f2bde9df7108e70ce011b988451602
  • Commits must be prefixed with the package(s) they modify

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

@Arachnid Arachnid changed the title Set default GPO percentile to 25%, and count blocks instead of transactions Set default GPO percentile to 35%, and count blocks instead of transactions Jan 7, 2018
@GitCop
Copy link

GitCop commented Jan 7, 2018

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: 134cb611ad535c77ba75b74e6fa0936b07ceff4c
  • Commits must be prefixed with the package(s) they modify

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

@Arachnid Arachnid changed the title Set default GPO percentile to 35%, and count blocks instead of transactions Set default GPO percentile to 60%, and count blocks instead of transactions Jan 7, 2018
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'd like @karalabe to thumb it up too

continue
}
if minPrice == nil || tx.GasPrice().Cmp(minPrice) < 0 {
minPrice = tx.GasPrice()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tx.GasPrice creates a copy internally. Calling it twice here will alloc twice. It would be cleaner to do:

if curPrice := tx.GasPrice(); minPrice == nil || curPrice.Cmp(minPrice) < 0 {
 	minPrice = curPrice
}

prices[i] = tx.GasPrice()
var minPrice *big.Int
for _, tx := range txs {
sender, err := types.Sender(signer, tx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit reluctant about this change here as is. This essentially does an ecrecover. So for a single gas estimation, on mainnet we would iterate over 20 blocks x 200-300 tx, that's 4-6K ecrecovers. That would imho be a very expensive operation to do, borderline unusable on a mobile phone (maybe fully).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we could cache the senders of transactions so we don't need to ecrecover all the time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In here, or in general? We could modify this to not reprocess existing blocks, if they've been seen already by a previous call to the oracle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm very mistaken, tx sender caching helps here. The GPO loads recent blocks, so they'll be in the BlockChain LRU. The txs in those blocks have cached sender information.

fjl
fjl previously approved these changes Jan 9, 2018
@fjl fjl changed the title Set default GPO percentile to 60%, and count blocks instead of transactions eth/gasprice: set default percentile to 60%, count blocks instead of transactions Jan 9, 2018
txs := block.Transactions()
var minPrice *big.Int
sort.Sort(transactionsByGasPrice(txs))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block.Transactions() returns the internal slice (https://github.com/ethereum/go-ethereum/blob/master/core/types/block.go#L287), which means sorting it will have nasty side effects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhh, good catch!

@fjl fjl dismissed their stale review January 9, 2018 13:13

@karalabe found issue

@karalabe karalabe added this to the 1.8.0 milestone Jan 10, 2018
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fjl fjl merged commit b06e20b into ethereum:master Jan 10, 2018
mariameda pushed a commit to NiluPlatform/go-nilu that referenced this pull request Aug 23, 2018
…transactions (ethereum#15828)

The first should address a long term issue where we recommend a gas
price that is greater than that required for 50% of transactions in
recent blocks, which can lead to gas price inflation as people take
this figure and add a margin to it, resulting in a positive feedback
loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants