Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Add support for additional block building algorithm #76

Merged
merged 36 commits into from
Jun 30, 2023

Conversation

Wazzymandias
Copy link
Contributor

@Wazzymandias Wazzymandias commented Jun 14, 2023

📝 Summary

  • This PR adds support for a new block building algorithm type, called greedy-buckets
  • The new algorithm attempts to insert transactions by both effective gas price and profit. This is in contrast to the greedy algorithm which simply uses effective gas price

Testing

  • Tested locally and on production mainnet
  • Observed a healthy number of higher bids with the new algorithm, screenshot below compares how often the new algorithm in blue outbid the existing one in orange:
image
  • Below is a chart that compares top bid of each algorithm per block building attempt
    image

📚 References


core/types/transaction.go Outdated Show resolved Hide resolved
core/types/transaction.go Outdated Show resolved Hide resolved
core/types/transaction.go Outdated Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_greedy.go Outdated Show resolved Hide resolved
miner/algo_greedy.go Outdated Show resolved Hide resolved
miner/algo_greedy.go Outdated Show resolved Hide resolved
miner/algo_greedy.go Outdated Show resolved Hide resolved
miner/algo_greedy.go Outdated Show resolved Hide resolved
@Wazzymandias Wazzymandias requested a review from Ruteri June 16, 2023 21:45
Copy link
Contributor

@dvush dvush left a comment

Choose a reason for hiding this comment

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

I think this is what we want!

  • left some comment

miner/algo_common.go Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_greedy_buckets.go Outdated Show resolved Hide resolved
core/types/transaction.go Outdated Show resolved Hide resolved
@Wazzymandias Wazzymandias force-pushed the build-300/improve-block-algo branch from 9f740a6 to 1c5300a Compare June 21, 2023 22:36
@Wazzymandias Wazzymandias requested a review from dvush June 21, 2023 22:48
@Wazzymandias Wazzymandias changed the title [WIP] Add support for additional block building algorithm Add support for additional block building algorithm Jun 22, 2023
@Wazzymandias Wazzymandias requested a review from Ruteri June 23, 2023 15:16
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
@Wazzymandias Wazzymandias requested a review from dvush June 26, 2023 14:35
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_common.go Show resolved Hide resolved
@Wazzymandias Wazzymandias force-pushed the build-300/improve-block-algo branch 2 times, most recently from 960e40b to 5136f70 Compare June 28, 2023 02:18
@Wazzymandias Wazzymandias force-pushed the build-300/improve-block-algo branch from 5136f70 to c9cad3d Compare June 28, 2023 05:42
@Wazzymandias Wazzymandias requested a review from Ruteri June 28, 2023 15:44
miner/algo_common.go Outdated Show resolved Hide resolved
miner/algo_common.go Outdated Show resolved Hide resolved
@Wazzymandias Wazzymandias requested a review from Ruteri June 28, 2023 17:26
miner/worker.go Outdated Show resolved Hide resolved
miner/algo_greedy_buckets.go Outdated Show resolved Hide resolved
miner/algo_greedy_buckets.go Show resolved Hide resolved
…eedy buckets algorithm to only reinsert when low profit error occurs. Update TxWithMinerFee to set price and set profit after low profit error to reinsert back into heap
@Wazzymandias Wazzymandias force-pushed the build-300/improve-block-algo branch from f43740c to adaaf14 Compare June 29, 2023 21:27
@Wazzymandias Wazzymandias merged commit 44debde into main Jun 30, 2023
@Wazzymandias Wazzymandias deleted the build-300/improve-block-algo branch June 30, 2023 11:11
avalonche pushed a commit that referenced this pull request Jul 6, 2023
* Add initial implementation for builder bucketized merging algorithm

* Simplify logic and update buckets to initialize from top of heap rather than static size from max element of heap

* Add logic to commit transactions when heap is empty

* Fix erroneous integer division

* Move profit function to TxWithMinerFee pointer receiver, refactor sorting algorithm

* Add logic for enforcing profit on bundles and sbundles

* Split greedy buckets builder from greedy builder

* Add greedy bucket worker

* Update tests to support separate greedy buckets builder, add retry logic

* Make new multi worker explicit in supported algorithm types, update ShiftAndPushByAccountForTx

* Reduce retry count to 1, update signature formatting

* Add else statement with panic clause for unsupported order type in algo greedy buckets

* Update greedy buckets algorithm to use gas used for transaction on retries

* Remove tx profit validation for the scope of this PR due to performance implications of rolling back state on low profit

* Update method signatures to algoConf

* Move closures to outside function, add low profit error and update greedy buckets algorithm to only reinsert when low profit error occurs. Update TxWithMinerFee to set price and set profit after low profit error to reinsert back into heap
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants