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

Consider limiting trie key length by 32 bytes #9363

Open
Longarithm opened this issue Jul 27, 2023 · 2 comments
Open

Consider limiting trie key length by 32 bytes #9363

Longarithm opened this issue Jul 27, 2023 · 2 comments
Labels
A-storage Area: storage and databases

Comments

@Longarithm
Copy link
Member

Eth model assumes that key length is always 32 bytes (Zulip). We don't, but it complicates things for us.

Most contract devs use short keys, as they benefit from low costs, but it's possible to create a key of 2 KB size, which trie depth can be unpleasantly big. We should consider replacing these keys in trie with their hashes, so that trie depth will be always limited by 64 (nibbles).

If we proceed with other tree structure like AVL (discussion), then it won't be needed because tree depth will depend only on number of keys.

@Longarithm Longarithm added the A-storage Area: storage and databases label Jul 27, 2023
@jakmeier
Copy link
Contributor

For flat storage, could we keep using the non-hashed keys? Or are long keys also problematic there?

Keeping plain keys would presumably be better for data locality. But admittedly, I don't think we have much data to back up this claim.

@Longarithm
Copy link
Member Author

Yes, for flat storage we should keep long keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-storage Area: storage and databases
Projects
None yet
Development

No branches or pull requests

2 participants