You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The root hash calculation returns a wrong value when some keys are removed. This does not happen for all keys.
Here is a test that reproduces the bug:
#[test]fntest_insert_and_revert(){// Arrangelet db = Arc::new(MemoryDB::new(true));letmut trie = PatriciaTrie::new(db.clone(),Arc::new(HasherKeccak::new()));let root_0 = trie.commit().unwrap();// Insert "do"let root_1 = {
trie.insert(b"do".to_vec(),b"verb".to_vec()).unwrap();
trie.root().unwrap()};// Insert "doge"let root_2 = {
trie.insert(b"doge".to_vec(),b"coin".to_vec()).unwrap();
trie.root().unwrap()};// Insert "dog"{
trie.insert(b"dog".to_vec(),b"puppy".to_vec()).unwrap();
trie.root().unwrap()};// Remove "dog"{
trie.remove(b"dog").unwrap();// It fails here, the root hash does not match the expected oneassert_eq!(root_2, trie.root().unwrap());}// Remove "doge"{
trie.remove(b"doge").unwrap();assert_eq!(root_1, trie.root().unwrap());}// Remove "do"{
trie.remove(b"do").unwrap();// Now the trie is empty but the hash is not the one of an empty trieassert_eq!(root_0, trie.root().unwrap());}}
The text was updated successfully, but these errors were encountered:
The root hash calculation returns a wrong value when some keys are removed. This does not happen for all keys.
Here is a test that reproduces the bug:
The text was updated successfully, but these errors were encountered: