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

Quadratic complexity in mine_block #382

Open
Tracked by #303
agostbiro opened this issue Apr 12, 2024 · 0 comments
Open
Tracked by #303

Quadratic complexity in mine_block #382

agostbiro opened this issue Apr 12, 2024 · 0 comments

Comments

@agostbiro
Copy link
Collaborator

agostbiro commented Apr 12, 2024

mine_block has quadratic complexity in the number of callers as it reruns the comparator function on all transactions for each transaction:

https://github.com/NomicFoundation/hardhat/blob/b267db8d1f2acb6f5611e82b74b9d9e555024c84/crates/edr_evm/src/mempool.rs#L54-L59

Note that we're doing order preserving removal from IndexMap as well in the loop in certain cases which has linear complexity:

https://github.com/NomicFoundation/hardhat/blob/69e340761ce52812fe720689bcec972345fc8df7/crates/edr_evm/src/miner.rs#L134-L157

@agostbiro agostbiro changed the title Worst-case quadratic complexity in mine_block Quadratic complexity in mine_block Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

3 participants