From 03c47e5b7b1bf8d013aaefc7a86582860063096e Mon Sep 17 00:00:00 2001 From: cchudant Date: Mon, 25 Nov 2024 15:00:36 +0000 Subject: [PATCH] fix: apply trie log backwards, and match rocksdb version with madara --- Cargo.toml | 2 +- src/key_value_db.rs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c449603..596679a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ starknet-types-core = { version = "0.1.7", default-features = false, features = ] } # Optionals -rocksdb = { optional = true, version = "0.21.0", features = [ +rocksdb = { optional = true, version = "0.22", features = [ "multi-threaded-cf", ] } diff --git a/src/key_value_db.rs b/src/key_value_db.rs index be09664..29553ef 100644 --- a/src/key_value_db.rs +++ b/src/key_value_db.rs @@ -254,17 +254,18 @@ where )) })?, ); + // Apply backwards for (key, change) in changes.0 { let key = DatabaseKey::from(&key); match (&change.old_value, &change.new_value) { - (Some(_), Some(new_value)) => { - txn.insert(&key, new_value, Some(&mut batch))?; + (Some(old_value), Some(_)) => { + txn.insert(&key, old_value, Some(&mut batch))?; } - (Some(_), None) => { - txn.remove(&key, Some(&mut batch))?; + (Some(old_value), None) => { + txn.insert(&key, old_value, Some(&mut batch))?; } - (None, Some(new_value)) => { - txn.insert(&key, new_value, Some(&mut batch))?; + (None, Some(_)) => { + txn.remove(&key, Some(&mut batch))?; } (None, None) => unreachable!(), };