Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd, core, eth, miner: remove txpool gas price limits #14442
Historically our transaction pool enforced all transactions to meet a certain pricing threshold to accept and forward. This however is limiting the network from propagating low price transactions, even if there is some miner out there willing to process them. This PR attempts to fix this.
The motto of the PR (i.e. base design rationale): We don't care if the pool contains a ton of non-executable-because-insanely-cheap transactions, since we'll have a hard upper cap and the cheap transactions get kicked out the moment there's something more expensive arriving.
Side note: the PR reduces the default gas price from 20 Shannon to 18 Shannon. This is actually a noop since our miner code had a weird snippet that set its accepted gas limit to 90% of what thee user specified. :| I removed that.
cmd, core, eth, miner: remove txpool gas price limits
First up, our previous code was messy when it came to gas price handling and tracking local transactions as both were done both in the miner as well as the tx pool. However it makes absolutely no sense to track these in two places. If the pool already enforces the correct prices, the miner shouldn't need to care at all, just mint whatever it's given. As such, this commit drops all notions of gas price and local transactions from the miner, and whenever
The crux of the commit is the implementation of
With this data structure given, we can add it as a "virtual" layer on top of the existing transaction pool. Every time a transaction is added or removed from the pool via any existing method, it's added to this price pool too without caring about its price at all. However if the transaction pool saturates (count >= maxPending + maxQueued), any new transaction being added will first ensure it's not under priced (more expensive than the cheapest). If so, the price pool can discard the cheapest N transactions to make room for the new one.
If the user changes the minimum gas price via
core: enforce min 10% price bump for replacement txs
Since the first commit enables users to potentially add transactions that are way below any price point accepted by miners, those transactions will get stuck in the network until they are flushed out by more expensive ones.
The catch here is that a malicious user might add a transaction at
It also features an extra optimization compared to the old code, whereby replacement transactions are injected directly into the executable list (if it has a good nonce), instead of adding it into the non-executable queue and then promoting it later. This should help prevent replacement transactions from wasting computing resources by placing them into the queue and afterwards moving the to pending.
core: replace txpool priced map with a simple heap
The worst case scenario for the priced map data structure is if all transactions in the dataset have different price points. However with an active fee market, this is somewhat to be expected. As such, per the suggestion of @Arachnid, this commit dumps the map out of the data structure, and instead of a price-point heap, it uses a full transaction heap sorted by gas price. This should make the code a tad simpler to reason about while maintaining the same (expected case) runtime/memory complexity.
Separated out that reheap function for you.…
On May 9, 2017 7:33 PM, "Nick Johnson" ***@***.***> wrote: @karalabe <https://github.com/karalabe> What changed? I don't see any new commits. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#14442 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAH6GevLJK5gT4GbNXNRcEdqiUjPkFEyks5r4JV0gaJpZM4NUOxc> .