-
Notifications
You must be signed in to change notification settings - Fork 72
fix decode compact prefix db #227
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
fix decode compact prefix db #227
Conversation
- partial prefix for attached value was not appended - support for child trie root prefix
bkchr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide some test for these changes.
- decode compact proof to prefixed db, trie read failed
trie-db/test/src/trie_codec.rs
Outdated
| ) { | ||
| // Reconstruct the partial DB from the compact encoding. | ||
| let mut db = MemoryDB::<L>::default(); | ||
| let mut db = PrefixedMemoryDB::<L>::default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can not just change an existing test if you introduce new code. We for sure want to ensure that both still work.
Also you don't use your newly introduced function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made new function decode_compact_from_iter_with_prefix to avoid breaking interface (new root_prefix arg).
Old decode_compact_from_iter just calls decode_compact_from_iter_with_prefix with empty prefix.
This test with PrefixedMemoryDB panics on master, so this branch fixes existing functionality.
- test both MemoryDB and PrefixedMemoryDB
trie-db/test/src/trie_codec.rs
Outdated
| encoded.push(Vec::new()); // Add an extra item to ensure it is not read. | ||
| test_decode_compact::<T>(&encoded, items, root, encoded.len() - 1); | ||
| test_decode_compact::<T>(MemoryDB::<T>::default(), &encoded, &items, root, encoded.len() - 1); | ||
| test_decode_compact::<T>(PrefixedMemoryDB::<T>::default(), &encoded, &items, root, encoded.len() - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are still not testing the function that you introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, removed new function.
Running this test on master (before this PR) will panic, keeping it as regression test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay perfect.
use KeySpacedDBMut wrapper
add support for child trie root prefix(use prefixed db wrapper)