fix: only take non-mempool tx to calculate bundle price #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
fix: only take non-mempool tx to calculate bundle price
Rationale
In current implementation, when a builder receive a bundle, it will simulate all txs within the bundle. Bundle price = sum( gas price * gas used ) /sum(gas used ) , ensure bundle price > = 1 gwei. It seems not a good solution. Consider the following example:
There is a public mempool tx with 100 gwei, gas usage 21,000 and its a simple transfer tx. A malicious actor can submit a 0 gas price tx to bundle it up with the public mempool tx, this tx has 0 gwei gas price, it can involve very complex smart contract calls and it has a gas usage of 1,000,000.
In that case, it will be (10021000+01000000)/(21000+1000000)=2.05 gwei. This means this bundle can be included by builders and land on chain.
However, the malicious actor is essentially a "free rider" in this scenario, and this actor is able to "exploit" the bundle scoring algorithm and make high-gas-usage tx land on chain for free.
Example
add an example CLI or API response...
Changes
Notable changes: