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

Compact binary serde for TrieUpdates #11370

Closed
Tracked by #11200
shekhirin opened this issue Oct 1, 2024 · 0 comments · Fixed by #11409
Closed
Tracked by #11200

Compact binary serde for TrieUpdates #11370

shekhirin opened this issue Oct 1, 2024 · 0 comments · Fixed by #11409
Assignees
Labels
A-trie Related to Merkle Patricia Trie implementation C-enhancement New feature or request

Comments

@shekhirin
Copy link
Collaborator

shekhirin commented Oct 1, 2024

Problem

We serialize TrieUpdates and StorageTrieUpdates using hex encoding for nibbles. It's fine for a human-readable format like JSON, but suboptimal for a binary one like bincode.

#[cfg_attr(feature = "serde", serde(serialize_with = "serialize_nibbles_map"))]
pub(crate) account_nodes: HashMap<Nibbles, BranchNodeCompact>,
#[cfg_attr(feature = "serde", serde(serialize_with = "serialize_nibbles_set"))]
pub(crate) removed_nodes: HashSet<Nibbles>,

/// Collection of updated storage trie nodes.
#[cfg_attr(feature = "serde", serde(serialize_with = "serialize_nibbles_map"))]
pub(crate) storage_nodes: HashMap<Nibbles, BranchNodeCompact>,
/// Collection of removed storage trie nodes.
#[cfg_attr(feature = "serde", serde(serialize_with = "serialize_nibbles_set"))]
pub(crate) removed_nodes: HashSet<Nibbles>,

Solution

Provide a custom serde implementation for these structs via serde_as, similar to #11331.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trie Related to Merkle Patricia Trie implementation C-enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant