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

Keys iterator of the store::UnorderedMap consumes gas while skipping (skip). FreeList iterator is not lazy. #1135

Closed
fadeevab opened this issue Jan 20, 2024 · 4 comments

Comments

@fadeevab
Copy link

fadeevab commented Jan 20, 2024

skip is not cheap (FreeList::Iterator::skip) because it's not lazy, it reads every value while moving to the nth position to figure out whether a slot is occupied or not. Skipping over a few thousand elements may be impossible because gas will be consumed earlier.

~30TGas to skip 300 elements

So if you have 10k accounts in the map, you can't practically skip 2-3k accounts, e.g. you can't view/print most of the map.

@fadeevab
Copy link
Author

@frol Iterating by keys is broken. Ideally, it's better to:

  1. Fix the map (although, I don't see how),
    - OR -
  2. Rename the current store::UnorderedMap to "something else map", e.g. FragmentedMap.
  3. pop operation could be added for fast O(1) removals to the original UnorderedMap.

@ruseinov
Copy link
Collaborator

I suggest to combine this with that. Let's answer questions there, estimate and proceed.

@fadeevab
Copy link
Author

@ruseinov yes, agree

@frol
Copy link
Collaborator

frol commented Feb 26, 2024

Closing as "duplicate"

@frol frol closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants