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

turbohash #171

Merged
merged 1 commit into from
Dec 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
2 changes: 1 addition & 1 deletion src/perf/trie_only_perftest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct Args {

pub fn run() -> Result<(), Box<dyn Error>> {
let args = Args::parse();
let turbohash = 0;
let turbohash = 1;

let host = ("127.0.0.1", cadence::DEFAULT_PORT);
let socket = net::UdpSocket::bind("0.0.0.0:0").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/proto/sync_trie.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ message DbTrieNode {
bytes key = 1;
repeated uint32 childChars = 2;
uint32 items = 3;
bytes hash = 4;
map<uint32, bytes> childHashes = 4;
}

10 changes: 8 additions & 2 deletions src/storage/trie/merkle_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ impl MerkleTrie {

if let Some(root) = self.root.as_mut() {
let mut txn = RocksDbTransactionBatch::new();
let results = root.insert(ctx, db, &mut txn, keys, 0)?;
// root_stub_map: the hash of a node is stored/cached in the parent of that node (in a hashmap)
// the root doesn't have a parent, but still needs a hashmap here to satisfy the API. Note also
// that the root's hash will NOT be populated anywhere in this map. Use root.hash() for that.
let mut root_stub_map = HashMap::new();
let results = root.insert(ctx, &mut root_stub_map, db, &mut txn, keys, 0)?;

txn_batch.merge(txn);
Ok(results)
Expand Down Expand Up @@ -185,7 +189,9 @@ impl MerkleTrie {

if let Some(root) = self.root.as_mut() {
let mut txn = RocksDbTransactionBatch::new();
let results = root.delete(ctx, db, &mut txn, keys, 0)?;
// root_stub_map: see comment in insert()
let root_stub_map = &mut HashMap::new();
let results = root.delete(ctx, root_stub_map, db, &mut txn, keys, 0)?;

txn_batch.merge(txn);
Ok(results)
Expand Down
Loading