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

Review codebase for gas optimizations related to inefficient Enum storage #55

Open
loothero opened this issue Feb 18, 2025 · 0 comments

Comments

@loothero
Copy link
Member

loothero commented Feb 18, 2025

Currently Starknet uses an entire felt to store the variant of an enum. This is true even if you have an enum with only a couple variants such as

enum Color {
     blue,
     yellow,
     red
}

As such, it's highly inefficient to store enums directly. I see two good options:

  1. If Cairo/Starknet allows it, implement StorePacking on the Enumerator to provide more specific instructions on packing.
  2. Otherwise, use u8 for storage and convert to Enum after taking out of storage.

Note, for models which is infrequently written to, this is a non-issue. Focus instead on models which are written to most frequently, with the goal of getting those to one or two felts.

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

1 participant