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

Fix issue #2035, third attempt #2041

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/trie/proof_decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,9 +1105,10 @@ impl<T: AsRef<[u8]>> DecodedTrieProof<T> {
// `iter_entry` is still pointing to the child at index `parent_to_child_nibble`.
// Since we're jumping to its next sibling, all we have to do is skip over it
// and its descedants.
iter_entry += 1;
iter_entry += self.entries[iter_entry].child_entries_follow_up;
iter_entry += 1;
iterating_up = false;
continue; // Continue in order to refresh `iter_entry_decoded`.
}

let mut iter_entry_partial_key_iter = iter_entry_decoded.partial_key;
Expand Down
Binary file added lib/src/trie/proof_decode/issue_2035_ter_proof
Binary file not shown.
40 changes: 40 additions & 0 deletions lib/src/trie/proof_decode/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2431,3 +2431,43 @@ fn issue_2035_bis() {
.collect::<Vec<_>>()
);
}

#[test]
fn issue_2035_ter() {
// Repro for the third issue in <https://github.com/smol-dot/smoldot/issues/2035>.
let proof = include_bytes!("./issue_2035_ter_proof");
let state_root_hash: [u8; 32] = [
41, 58, 166, 224, 119, 219, 231, 9, 12, 167, 17, 84, 219, 167, 26, 243, 212, 63, 97, 115,
107, 26, 110, 144, 12, 215, 113, 172, 8, 193, 142, 60,
];
let key: [u8; 44] = [
0x63, 0xf7, 0x8c, 0x98, 0x72, 0x3d, 0xdc, 0x90, 0x73, 0x52, 0x3e, 0xf3, 0xbe, 0xef, 0xda,
0x0c, 0xa9, 0x5d, 0xac, 0x46, 0xc0, 0x7a, 0x40, 0xd9, 0x15, 0x06, 0xe7, 0x63, 0x7e, 0xc4,
0xba, 0x57, 0x0f, 0x47, 0x4e, 0xe8, 0x5a, 0x3c, 0xd6, 0x22, 0xf8, 0x07, 0x00, 0x00,
];

let decoded = super::decode_and_verify_proof(super::Config { proof }).unwrap();

let next_key = decoded.next_key(
&state_root_hash,
trie::bytes_to_nibbles(key.iter().copied()),
false,
iter::empty(),
false,
);

assert_eq!(
next_key.unwrap().unwrap().collect::<Vec<_>>(),
trie::bytes_to_nibbles(
[
0x63, 0xf7, 0x8c, 0x98, 0x72, 0x3d, 0xdc, 0x90, 0x73, 0x52, 0x3e, 0xf3, 0xbe, 0xef,
0xda, 0x0c, 0xa9, 0x5d, 0xac, 0x46, 0xc0, 0x7a, 0x40, 0xd9, 0x15, 0x06, 0xe7, 0x63,
0x7e, 0xc4, 0xba, 0x57, 0x16, 0x03, 0x94, 0x31, 0x5f, 0xe9, 0x5b, 0x98, 0xf3, 0x07,
0x00, 0x00
]
.iter()
.copied()
)
.collect::<Vec<_>>()
);
}
2 changes: 1 addition & 1 deletion wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Fixed

- Fix another bug concerning incomplete Merkle proofs, similar to the one fixed in v2.0.32. ([#2039](https://github.com/smol-dot/smoldot/pull/2039))
- Fix another bug concerning incomplete Merkle proofs, similar to the one fixed in v2.0.32. ([#2039](https://github.com/smol-dot/smoldot/pull/2039), [#2041](https://github.com/smol-dot/smoldot/pull/2041))

## 2.0.32 - 2024-11-08

Expand Down
Loading