Open wanyvic opened 10 months ago
I tried to import reference-trie 0.29.1 and trie-db 0.28.0 into my code and wrote a demo, but I encountered a compilation error. demo:
use hash_db::Hasher;
use memory_db::{HashKey, MemoryDB};
use reference_trie::{RefHasher, RefSecTrieDBMut, RefTrieDBBuilder};
use trie_db::{DBValue, Trie, TrieMut};
fn main() {
let mut memdb = MemoryDB::<RefHasher, HashKey<_>, DBValue>::default();
let mut root = Default::default();
{
let mut t = RefSecTrieDBMut::new(&mut memdb, &mut root);
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
}
let t = RefTrieDBBuilder::new(&memdb, &root).build();
assert_eq!(
t.get(&RefHasher::hash(&[0x01u8, 0x23])).unwrap().unwrap(),
vec![0x01u8, 0x23],
);
}
compilation error:
--> src/main.rs:12:11
|
12 | t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]).unwrap();
| ^^^^^^ method not found in `SecTrieDBMut<'_, ExtensionLayout>`
The reason for the error is that the version of trie-db
used by the reference-trie
crate is 0.27.0, which conflicts with the version specified in the Cargo.toml
file mentioned in https://github.com/paritytech/trie/blob/6eb4b88e0781da2db7dda0021249a8fa4244bc5d/test-support/reference-trie/Cargo.toml#L13.
The
reference-trie
version 0.29.1 on crates.io is using an older version oftrie-db
(0.27.0), which is inconsistent with the version specified in theCargo.toml
file. This inconsistency may lead to ambiguity when importing external crates.https://crates.io/crates/reference-trie/0.29.1/dependencies
https://github.com/paritytech/trie/blob/6eb4b88e0781da2db7dda0021249a8fa4244bc5d/test-support/reference-trie/Cargo.toml#L13