Skip to content

vms/avm: Simplify Peek function in mempool #2449

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

Merged
merged 6 commits into from
Dec 9, 2023
Merged

vms/avm: Simplify Peek function in mempool #2449

merged 6 commits into from
Dec 9, 2023

Conversation

dhrubabasu
Copy link
Contributor

Why this should be merged

We currently iterate through all the transactions in the mempool to build as full of a block as possible. This could cause an instance where we do this iteration many times:

Suppose we have a mempool with txs of size [5, 6, 6, 6, 6, 1, 1, 1, 1, 1] and we are attempting to build a block of size 10.

Pre-this PR, the blocks will be built like so:

[5, 1, 1, 1, 1, 1]
[6]
[6]
[6]
[6]

However, to get the txs of size 1 into the first block, we iterate through all the txs of size 6 five times. Instead, we could build a block with as many of the highest priority txs (oldest for avm and platformvm) and stop when we hit a transaction that exceeds our block size. This produces blocks like this with no iteration:

[5]
[6]
[6]
[6]
[6, 1, 1, 1, 1]
[1]

How this works

Modify Peek to just return the oldest tx in the mempool. Check the size of the tx in the block builder itself.

How this was tested

CI + added UT

@dhrubabasu dhrubabasu added this to the v1.10.18 milestone Dec 8, 2023
@dhrubabasu dhrubabasu self-assigned this Dec 8, 2023
@StephenButtolph StephenButtolph added this pull request to the merge queue Dec 8, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 8, 2023
@StephenButtolph StephenButtolph added this pull request to the merge queue Dec 9, 2023
Merged via the queue into dev with commit 80fa254 Dec 9, 2023
@StephenButtolph StephenButtolph deleted the avm-peek branch December 9, 2023 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants