Replies: 1 comment
-
filed a more detailed issue here: if we can discern between the new and old format (at least for storage subkeys) we could do this in a backwards compatible way |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Description
The current
StoredNibblesSubKey
implementation incrates/trie/common/src/nibbles.rs
has a significant storage inefficiency:Storage Inefficiency: Uses a fixed 65-byte format (64 bytes for nibbles data + 1 byte for length) regardless of actual content size. This doubles the storage requirement from 32 bytes to 64 bytes for nibbles data, resulting in unnecessary storage overhead.
Current Implementation
Constraints for Solution
Any optimization must satisfy these requirements:
Ambiguity Resolution: The
Nibbles::pack()
method pads odd-length nibbles with a zero nibble, causing ambiguity between["0x0A"]
and["0x0A", "0x00"]
- both produce the same packed result. The solution must preserve the original length to distinguish between these cases.Dictionary Order Preservation: Reth relies on proper dictionary ordering of
Nibbles
for trie operations, which must be preserved in any storage optimization.Proposed Solution
Use the existing
Nibbles::pack()
andNibbles::unpack()
methods to compress storage while preserving the original length to avoid ambiguity:Benefits
["0x0A"]
and["0x0A", "0x00"]
pack()
/unpack()
methodsImpact
StoragesTrie
tableBeta Was this translation helpful? Give feedback.
All reactions