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

Inline value should never be recorded. #184

Merged
merged 4 commits into from
Feb 14, 2023
Merged

Conversation

cheme
Copy link
Contributor

@cheme cheme commented Feb 13, 2023

When value are inline, they are encoded into their parent node and we shall not record them individually.

Should fix: paritytech/substrate#13357

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add some tests?

if value_recording_required {
let is_inline = L::MAX_INLINE_VALUE
.map(|max| data.as_ref().len() < max as usize)
.unwrap_or(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.unwrap_or(true);
.unwrap_or(false);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true I think: if No inline limit, then this is the old trie version where all values are inline so is_inline should be true for MAX_INLINE_VALUE I think (I allways end up needing to think twice here).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh okay. This is really confusing. Could you please leave some comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, also inverse the comparison order (seems more readable this way).

@cheme
Copy link
Contributor Author

cheme commented Feb 14, 2023

Can you please add some tests?

was my morning plan 👍

@@ -452,7 +452,7 @@ fn test_recorder_with_cache_get_hash_internal<T: TrieLayout>() {
assert!(cache.get_node(&root).is_some());
// Also the data should be cached.

if T::MAX_INLINE_VALUE.map_or(true, |l| l as usize >= key_value[1].1.len()) {
if T::MAX_INLINE_VALUE.map_or(true, |l| l as usize > key_value[1].1.len()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test was not correct

@cheme cheme requested a review from arkpar February 14, 2023 09:28
@cheme
Copy link
Contributor Author

cheme commented Feb 14, 2023

Will release as 0.25.1

@cheme cheme merged commit 0b5b7a5 into paritytech:master Feb 14, 2023
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

Successfully merging this pull request may close these issues.

Merkle proof with unused entry
3 participants